/** * @brief Updates the outfitter and equipment outfit image arrays. */ void outfits_updateEquipmentOutfits( void ) { int ew, ow; if (landed && land_doneLoading()) { if planet_hasService(land_planet, PLANET_SERVICE_OUTFITS) { ow = land_getWid( LAND_WINDOW_OUTFITS ); outfits_update(ow, NULL); outfits_updateQuantities(ow); } else if (!planet_hasService(land_planet, PLANET_SERVICE_SHIPYARD))
/** * @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); } }
/** * @brief Opens the outfit exchange center window. */ void outfits_open( unsigned int wid ) { int i; Outfit **outfits; char **soutfits; glTexture **toutfits; int noutfits; int w, h; int iw, ih; int bw, bh; glColour *bg, blend; const glColour *c; char **slottype; const char *slotname; /* Get dimensions. */ outfits_getSize( wid, &w, &h, &iw, &ih, &bw, &bh ); /* will allow buying from keyboard */ window_setAccept( wid, outfits_buy ); /* buttons */ window_addButton( wid, -20, 20, bw, bh, "btnCloseOutfits", "Takeoff", land_buttonTakeoff ); window_addButton( wid, -40-bw, 20, bw, bh, "btnSellOutfit", "Sell", outfits_sell ); window_addButton( wid, -60-bw*2, 20, bw, bh, "btnBuyOutfit", "Buy", outfits_buy ); /* fancy 128x128 image */ window_addRect( wid, 19 + iw + 20, -50, 128, 129, "rctImage", &cBlack, 0 ); window_addImage( wid, 20 + iw + 20, -50-128, 0, 0, "imgOutfit", NULL, 1 ); /* cust draws the modifier */ window_addCust( wid, -40-bw, 60+2*bh, bw, bh, "cstMod", 0, outfits_renderMod, NULL, NULL ); /* the descriptive text */ window_addText( wid, 20 + iw + 20 + 128 + 20, -60, 320, 160, 0, "txtOutfitName", &gl_defFont, &cBlack, NULL ); window_addText( wid, 20 + iw + 20 + 128 + 20, -60 - gl_defFont.h - 20, 320, 160, 0, "txtDescShort", &gl_smallFont, &cBlack, NULL ); window_addText( wid, 20 + iw + 20, -60-128-10, 60, 160, 0, "txtSDesc", &gl_smallFont, &cDConsole, "Owned:\n" "\n" "Slot:\n" "Size:\n" "Mass:\n" "\n" "Price:\n" "Money:\n" "License:\n" ); window_addText( wid, 20 + iw + 20 + 60, -60-128-10, 250, 160, 0, "txtDDesc", &gl_smallFont, &cBlack, NULL ); window_addText( wid, 20 + iw + 20, -60-128-10-160, w-(iw+80), 180, 0, "txtDescription", &gl_smallFont, NULL, NULL ); /* set up the outfits to buy/sell */ outfits = tech_getOutfit( land_planet->tech, &noutfits ); if (noutfits <= 0) { /* No outfits */ soutfits = malloc(sizeof(char*)); soutfits[0] = strdup("None"); toutfits = malloc(sizeof(glTexture*)); toutfits[0] = NULL; noutfits = 1; bg = NULL; slottype = NULL; } else { /* Create the outfit arrays. */ soutfits = malloc(sizeof(char*)*noutfits); toutfits = malloc(sizeof(glTexture*)*noutfits); bg = malloc(sizeof(glColour)*noutfits); slottype = malloc(sizeof(char*)*noutfits ); for (i=0; i<noutfits; i++) { soutfits[i] = strdup(outfits[i]->name); toutfits[i] = outfits[i]->gfx_store; /* Background colour. */ c = outfit_slotSizeColour( &outfits[i]->slot ); if (c == NULL) c = &cBlack; col_blend( &blend, c, &cGrey70, 0.4 ); memcpy( &bg[i], &blend, sizeof(glColour) ); /* Get slot name. */ slotname = outfit_slotName(outfits[i]); if ((strcmp(slotname,"NA") != 0) && (strcmp(slotname,"NULL") != 0)) { slottype[i] = malloc( 2 ); slottype[i][0] = outfit_slotName(outfits[i])[0]; slottype[i][1] = '\0'; } else slottype[i] = NULL; } free(outfits); } window_addImageArray( wid, 20, 20, iw, ih, "iarOutfits", 64, 64, toutfits, soutfits, noutfits, outfits_update, outfits_rmouse ); /* write the outfits stuff */ outfits_update( wid, NULL ); outfits_updateQuantities( wid ); toolkit_setImageArraySlotType( wid, "iarOutfits", slottype ); toolkit_setImageArrayBackground( wid, "iarOutfits", bg ); }