/** * @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 Opens the spaceport bar window. */ static void bar_open( unsigned int wid ) { int w, h, iw, ih, bw, bh, dh, th; /* Mark as generated. */ land_tabGenerate(LAND_WINDOW_BAR); /* Set window functions. */ window_onClose( wid, bar_close ); /* Get dimensions. */ bar_getDim( wid, &w, &h, &iw, &ih, &bw, &bh ); dh = gl_printHeightRaw( &gl_smallFont, w - iw - 60, land_planet->bar_description ); /* Approach when pressing enter */ window_setAccept( wid, bar_approach ); /* Buttons */ window_addButtonKey( wid, -20, 20, bw, bh, "btnCloseBar", "Take Off", land_buttonTakeoff, SDLK_t ); window_addButtonKey( wid, -20 - bw - 20, 20, bw, bh, "btnApproach", "Approach", bar_approach, SDLK_a ); /* Bar description. */ window_addText( wid, iw + 40, -40, w - iw - 60, dh, 0, "txtDescription", &gl_smallFont, &cBlack, land_planet->bar_description ); /* Add portrait text. */ th = -40 - dh - 40; window_addText( wid, iw + 40, th, w - iw - 60, gl_defFont.h, 1, "txtPortrait", &gl_defFont, &cDConsole, NULL ); /* Add mission description text. */ th -= 20 + PORTRAIT_HEIGHT + 20 + 20; window_addText( wid, iw + 60, th, w - iw - 100, h + th - (2*bh+60), 0, "txtMission", &gl_smallFont, &cBlack, NULL ); /* Generate the mission list. */ bar_genList( wid ); /* Set default keyboard focuse to the list */ window_setFocus( wid , "iarMissions" ); }
/** * @brief Opens the spaceport bar window. */ static void bar_open( unsigned int wid ) { int w, h, iw, ih, bw, bh, dh, th; /* Set window functions. */ window_onClose( wid, bar_close ); /* Get dimensions. */ bar_getDim( wid, &w, &h, &iw, &ih, &bw, &bh ); dh = gl_printHeightRaw( &gl_smallFont, w - iw - 60, land_planet->bar_description ); /* Buttons */ window_addButton( wid, -20, 20, bw, bh, "btnCloseBar", "Takeoff", land_buttonTakeoff ); window_addButton( wid, -20 - bw - 20, 20, bw, bh, "btnApproach", "Approach", bar_approach ); /* Bar description. */ window_addText( wid, iw + 40, -40, w - iw - 60, dh, 0, "txtDescription", &gl_smallFont, &cBlack, land_planet->bar_description ); /* Add portrait text. */ th = -40 - dh - 40; window_addText( wid, iw + 40, th, w - iw - 60, gl_defFont.h, 1, "txtPortrait", &gl_defFont, &cDConsole, NULL ); /* Add mission description text. */ th -= 20 + PORTRAIT_HEIGHT + 20 + 20; window_addText( wid, iw + 60, th, w - iw - 100, h + th - (2*bh+60), 0, "txtMission", &gl_smallFont, &cBlack, NULL ); /* Generate the mission list. */ bar_genList( wid ); }
/** * @brief Regenerates the bar list. */ void bar_regen (void) { if (!landed) return; bar_genList( land_getWid(LAND_WINDOW_BAR) ); }
/** * @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); } }