/** * @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; }
/** * @brief Saves the last place the player was. * * @param wid Unused. * @param wgt Unused. * @param tab Tab changed to. */ static void land_changeTab( unsigned int wid, char *wgt, int tab ) { int i; (void) wid; (void) wgt; unsigned int w; const char *torun_hook; unsigned int to_visit; /* Sane defaults. */ torun_hook = NULL; to_visit = 0; /* Find what switched. */ for (i=0; i<LAND_NUMWINDOWS; i++) { if (land_windowsMap[i] == tab) { last_window = i; w = land_getWid( i ); /* Must regenerate outfits. */ switch (i) { case LAND_WINDOW_MAIN: land_checkAddRefuel(); break; case LAND_WINDOW_OUTFITS: outfits_update( w, NULL ); outfits_updateQuantities( w ); to_visit = VISITED_OUTFITS; torun_hook = "outfits"; break; case LAND_WINDOW_SHIPYARD: shipyard_update( w, NULL ); to_visit = VISITED_SHIPYARD; torun_hook = "shipyard"; break; case LAND_WINDOW_BAR: bar_update( w, NULL ); to_visit = VISITED_BAR; torun_hook = "bar"; break; case LAND_WINDOW_MISSION: misn_update( w, NULL ); to_visit = VISITED_MISSION; torun_hook = "mission"; break; case LAND_WINDOW_COMMODITY: commodity_update( w, NULL ); to_visit = VISITED_COMMODITY; torun_hook = "commodity"; break; case LAND_WINDOW_EQUIPMENT: equipment_updateShips( w, NULL ); equipment_updateOutfits( w, NULL ); to_visit = VISITED_EQUIPMENT; torun_hook = "equipment"; break; default: break; } /* Clear markers if closing Mission Computer. */ if (i != LAND_WINDOW_MISSION) { space_clearComputerMarkers(); } break; } } /* Check land missions - always run hooks. */ /*if ((to_visit != 0) && !has_visited(to_visit)) {*/ { /* Run hooks, run after music in case hook wants to change music. */ if (torun_hook != NULL) if (hooks_run( torun_hook ) > 0) bar_genList( land_getWid(LAND_WINDOW_BAR) ); visited(to_visit); if (land_takeoff) takeoff(1); } }