/** * @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); }
/** * @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; /* 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" )) window_destroyWidget( wid, "iarMissions" ); /* 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, NULL ); /* write the outfits stuff */ bar_update( wid, NULL ); /* Restore focus. */ window_setFocus( wid, focused ); free(focused); return 0; }