Beispiel #1
0
Datei: land.c Projekt: Dinth/naev
/**
 * @brief Approaches guy in mission computer.
 */
static void bar_approach( unsigned int wid, char *str )
{
   (void) str;
   int pos, n;

   /* Get position. */
   pos = toolkit_getImageArrayPos( wid, "iarMissions" );

   /* Should never happen, but in case news is selected */
   if (pos == 0)
      return;

   /* Ignore news. */
   pos--;

   n = npc_getArraySize();
   npc_approach( pos );
   bar_genList( wid ); /* Always just in case. */
   if (n == npc_getArraySize())
      toolkit_setImageArrayPos( wid, "iarMissions", pos+1 );

   /* Reset markers. */
   mission_sysMark();

   /* Mission forced take off. */
   if (land_takeoff)
      takeoff(0);
}
Beispiel #2
0
/**
 * @brief Generates the mission list for the bar.
 *
 *    @param wid Window to create mission list for.
 */
static int bar_genList( unsigned int wid )
{
   glTexture **portraits;
   char **names, *focused;
   int w, h, iw, ih, bw, bh;
   int n, pos;

   /* Sanity check. */
   if (wid == 0)
      return 0;

   /* Get dimensions. */
   bar_getDim( wid, &w, &h, &iw, &ih, &bw, &bh );

   /* Save focus. */
   focused = strdup(window_getFocus(wid));

   /* Destroy widget if already exists. */
   if (widget_exists( wid, "iarMissions" )) {
      /* Store position. */
      pos = toolkit_getImageArrayPos( wid, "iarMissions" );

      window_destroyWidget( wid, "iarMissions" );
   }
   else
      pos = -1;

   /* We sort just in case. */
   npc_sort();

   /* Set up missions. */
   if (mission_portrait == NULL)
      mission_portrait = gl_newImage( PORTRAIT_GFX_PATH"news.png", 0 );
   n = npc_getArraySize();
   if (n <= 0) {
      n            = 1;
      portraits    = malloc(sizeof(glTexture*));
      portraits[0] = mission_portrait;
      names        = malloc(sizeof(char*));
      names[0]     = strdup("News");
   }
   else {
      n            = n+1;
      portraits    = malloc( sizeof(glTexture*) * n );
      portraits[0] = mission_portrait;
      npc_getTextureArray( &portraits[1], n-1 );
      names        = malloc( sizeof(char*) * n );
      names[0]     = strdup("News");
      npc_getNameArray( &names[1], n-1 );
   }
   window_addImageArray( wid, 20, -40,
         iw, ih, "iarMissions", 100, 75,
         portraits, names, n, bar_update, bar_approach );

   /* Restore position. */
   toolkit_setImageArrayPos( wid, "iarMissions", pos );

   /* write the outfits stuff */
   bar_update( wid, NULL );

   /* Restore focus. */
   window_setFocus( wid, focused );
   free(focused);

   return 0;
}