From: <av...@us...> - 2009-12-15 22:39:34
|
Revision: 3431 http://sc2.svn.sourceforge.net/sc2/?rev=3431&view=rev Author: avolkov Date: 2009-12-15 22:39:26 +0000 (Tue, 15 Dec 2009) Log Message: ----------- Planet orbit menu cleanup: own MENU_STATE for all; clear sub-menu functions; MENU_STATE hacks removed; not relying on MENU_STATE.Initialized; moved colors to colors.h; planet surface always drawn in ScanContext; Better names for some menu items Modified Paths: -------------- trunk/sc2/src/uqm/colors.h trunk/sc2/src/uqm/credits.c trunk/sc2/src/uqm/hyper.c trunk/sc2/src/uqm/menu.c trunk/sc2/src/uqm/menustat.h trunk/sc2/src/uqm/planets/generate.h trunk/sc2/src/uqm/planets/pl_stuff.c trunk/sc2/src/uqm/planets/planets.c trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/report.c trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/planets/scan.h trunk/sc2/src/uqm/planets/solarsys.c Modified: trunk/sc2/src/uqm/colors.h =================================================================== --- trunk/sc2/src/uqm/colors.h 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/colors.h 2009-12-15 22:39:26 UTC (rev 3431) @@ -68,7 +68,11 @@ BUILD_COLOR (MAKE_RGB15 (0x06, 0x06, 0x06), 0x00) #define WHITE_COLOR \ BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) -#define BLUE_COLOR \ +#define BRIGHT_RED_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x04) +#define BRIGHT_GREEN_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02) +#define BRIGHT_BLUE_COLOR \ BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x1F), 0x01) #define NORMAL_ILLUMINATED_COLOR \ @@ -390,12 +394,44 @@ #define ROSTER_MODIFY_SHIP_COLOR \ WHITE_COLOR +// === Scan menu and general === +#define SCAN_PC_TITLE_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x15), 0x3B) + +#define SCAN_INFO_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x19), 0x3B) + +#define SCAN_MINERAL_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15_INIT (0x13, 0x00, 0x00), 0x2C) + +#define SCAN_ENERGY_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0C, 0x0C, 0x0C), 0x1C) + +#define SCAN_BIOLOGICAL_TEXT_COLOR \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x0E, 0x00), 0x6C) + +#define SCAN_MINERAL_TINT_COLOR \ + BRIGHT_RED_COLOR_INIT + +#define SCAN_ENERGY_TINT_COLOR \ + WHITE_COLOR_INIT + +#define SCAN_BIOLOGICAL_TINT_COLOR \ + BRIGHT_GREEN_COLOR_INIT + + // Temporary, until we can use C'99 features: #define BLACK_COLOR_INIT \ BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x00), 0x00) #define WHITE_COLOR_INIT \ BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1F, 0x1F), 0x0F) +#define BRIGHT_RED_COLOR_INIT \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x00, 0x00), 0x04) +#define BRIGHT_GREEN_COLOR_INIT \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x1F, 0x00), 0x02) +#define BRIGHT_BLUE_COLOR_INIT \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x1F), 0x01) #define UNDEFINED_COLOR_INIT \ BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x00), 0x00) Modified: trunk/sc2/src/uqm/credits.c =================================================================== --- trunk/sc2/src/uqm/credits.c 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/credits.c 2009-12-15 22:39:26 UTC (rev 3431) @@ -39,7 +39,7 @@ #define CREDITS_TIMEOUT (ONE_SECOND * 5) -#define TRANS_COLOR BLUE_COLOR +#define TRANS_COLOR BRIGHT_BLUE_COLOR // Positive or negative scroll rate in pixel lines per second static int CreditsRate; Modified: trunk/sc2/src/uqm/hyper.c =================================================================== --- trunk/sc2/src/uqm/hyper.c 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/hyper.c 2009-12-15 22:39:26 UTC (rev 3431) @@ -50,6 +50,19 @@ static BYTE fuel_ticks; static COUNT hyper_dx, hyper_dy, hyper_extra; +// HyperspaceMenu() items +enum HyperMenuItems +{ + // XXX: Must match the enum in menustat.h + STARMAP = 1, + EQUIP_DEVICE, + CARGO, + ROSTER, + GAME_MENU, + NAVIGATION, +}; + + void MoveSIS (SIZE *pdx, SIZE *pdy) { Modified: trunk/sc2/src/uqm/menu.c =================================================================== --- trunk/sc2/src/uqm/menu.c 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/menu.c 2009-12-15 22:39:26 UTC (rev 3431) @@ -70,7 +70,7 @@ } #define ALT_MANIFEST 0x80 -#define ALT_EXIT_MENU0 0x81 +#define ALT_EXIT_MANIFEST 0x81 static UNICODE pm_crew_str[128]; static UNICODE pm_fuel_str[128]; @@ -151,29 +151,29 @@ return PM_LAUNCH_LANDER; break; case PM_SAVE_GAME: - return PM_EXIT_MENU1; + return PM_EXIT_GAME_MENU; break; case PM_CONVERSE: - return PM_SAVE_LOAD1; + return PM_ENCOUNTER_GAME_MENU; break; case PM_FUEL: - return PM_EXIT_MENU2; + return PM_EXIT_OUTFIT; break; case PM_CREW: - return PM_EXIT_MENU3; + return PM_EXIT_SHIPYARD; break; case PM_SOUND_ON: - return PM_EXIT_MENU4; + return PM_EXIT_SETTINGS; break; case PM_ALT_SCAN: case PM_ALT_STARMAP: return PM_ALT_NAVIGATE; break; case PM_ALT_CARGO: - return PM_ALT_EXITMENU0; + return PM_ALT_EXIT_MANIFEST; break; case PM_ALT_MSCAN: - return PM_ALT_EXITMENU1; + return PM_ALT_EXIT_SCAN; break; } return BaseState; @@ -256,7 +256,7 @@ switch (AdjBase + CurState) { case PM_SOUND_OFF: - NextState = PM_EXIT_MENU4; + NextState = PM_EXIT_SETTINGS; break; case PM_MUSIC_ON: case PM_MUSIC_OFF: @@ -299,9 +299,9 @@ *BaseState = PM_ALT_SCAN + adj; *CurState = PM_ALT_MANIFEST - PM_ALT_SCAN - adj; return TRUE; - case ALT_EXIT_MENU0: + case ALT_EXIT_MANIFEST: *BaseState = PM_ALT_CARGO; - *CurState = PM_ALT_EXITMENU0 - PM_ALT_CARGO; + *CurState = PM_ALT_EXIT_MANIFEST - PM_ALT_CARGO; return TRUE; } log_add (log_Error, "Unknown state combination: %d, %d", @@ -332,9 +332,9 @@ *BaseState = PM_ALT_CARGO; *CurState = PM_ALT_ROSTER - PM_ALT_CARGO; return TRUE; - case PM_SAVE_LOAD0: + case PM_GAME_MENU: *BaseState = PM_ALT_SCAN + adj; - *CurState = PM_ALT_SAVE0 - PM_ALT_SCAN - adj; + *CurState = PM_ALT_GAME_MENU - PM_ALT_SCAN - adj; return TRUE; case PM_NAVIGATE: *BaseState = PM_ALT_SCAN + adj; @@ -352,9 +352,9 @@ *BaseState = PM_ALT_MSCAN; *CurState = PM_ALT_BSCAN - PM_ALT_MSCAN; return TRUE; - case PM_EXIT_MENU0: + case PM_EXIT_SCAN: *BaseState = PM_ALT_MSCAN; - *CurState = PM_ALT_EXITMENU1 - PM_ALT_MSCAN; + *CurState = PM_ALT_EXIT_SCAN - PM_ALT_MSCAN; return TRUE; case PM_AUTO_SCAN: *BaseState = PM_ALT_MSCAN; @@ -381,8 +381,8 @@ return (PM_STARMAP - PM_SCAN); case PM_ALT_MANIFEST: return (ALT_MANIFEST); - case PM_ALT_SAVE0: - return (PM_SAVE_LOAD0 - PM_SCAN); + case PM_ALT_GAME_MENU: + return (PM_GAME_MENU - PM_SCAN); case PM_ALT_NAVIGATE: return (PM_NAVIGATE - PM_SCAN); case PM_ALT_CARGO: @@ -391,8 +391,8 @@ return (PM_DEVICES - PM_SCAN); case PM_ALT_ROSTER: return (PM_ROSTER - PM_SCAN); - case PM_ALT_EXITMENU0: - return (ALT_EXIT_MENU0); + case PM_ALT_EXIT_MANIFEST: + return (ALT_EXIT_MANIFEST); case PM_ALT_MSCAN: return (PM_MIN_SCAN - PM_MIN_SCAN); case PM_ALT_ESCAN: @@ -403,8 +403,8 @@ return (PM_AUTO_SCAN - PM_MIN_SCAN); case PM_ALT_DISPATCH: return (PM_LAUNCH_LANDER - PM_MIN_SCAN); - case PM_ALT_EXITMENU1: - return (PM_EXIT_MENU0 - PM_MIN_SCAN); + case PM_ALT_EXIT_SCAN: + return (PM_EXIT_SCAN - PM_MIN_SCAN); } return (NewState); } @@ -432,7 +432,7 @@ pMS->CurState = PM_CARGO - PM_SCAN; return TRUE; } - if (NewState == ALT_EXIT_MENU0) + if (NewState == ALT_EXIT_MANIFEST) { if (OrigBase == PM_SCAN) DrawMenuStateStrings (PM_ALT_SCAN, @@ -546,7 +546,7 @@ case PM_CHANGE_SHIP: NewState = 4; break; - case PM_EXIT_MENU4: + case PM_EXIT_SETTINGS: NewState = 5; break; } Modified: trunk/sc2/src/uqm/menustat.h =================================================================== --- trunk/sc2/src/uqm/menustat.h 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/menustat.h 2009-12-15 22:39:26 UTC (rev 3431) @@ -57,13 +57,13 @@ PM_DEVICES, PM_CARGO, PM_ROSTER, - PM_SAVE_LOAD0, + PM_GAME_MENU, PM_NAVIGATE, PM_MIN_SCAN, PM_ENE_SCAN, PM_BIO_SCAN, - PM_EXIT_MENU0, + PM_EXIT_SCAN, PM_AUTO_SCAN, PM_LAUNCH_LANDER, @@ -71,20 +71,20 @@ PM_LOAD_GAME, PM_QUIT_GAME, PM_CHANGE_SETTINGS, - PM_EXIT_MENU1, + PM_EXIT_GAME_MENU, PM_CONVERSE, PM_ATTACK, - PM_SAVE_LOAD1, + PM_ENCOUNTER_GAME_MENU, PM_FUEL, PM_MODULE, - PM_SAVE_LOAD2, - PM_EXIT_MENU2, + PM_OUTFIT_GAME_MENU, + PM_EXIT_OUTFIT, PM_CREW, - PM_SAVE_LOAD3, - PM_EXIT_MENU3, + PM_SHIPYARD_GAME_MENU, + PM_EXIT_SHIPYARD, PM_SOUND_ON, PM_SOUND_OFF, @@ -96,25 +96,25 @@ PM_CYBORG_SUPER, PM_CHANGE_CAPTAIN, PM_CHANGE_SHIP, - PM_EXIT_MENU4, + PM_EXIT_SETTINGS, PM_ALT_SCAN, PM_ALT_STARMAP, PM_ALT_MANIFEST, - PM_ALT_SAVE0, + PM_ALT_GAME_MENU, PM_ALT_NAVIGATE, PM_ALT_CARGO, PM_ALT_DEVICES, PM_ALT_ROSTER, - PM_ALT_EXITMENU0, + PM_ALT_EXIT_MANIFEST, PM_ALT_MSCAN, PM_ALT_ESCAN, PM_ALT_BSCAN, PM_ALT_ASCAN, PM_ALT_DISPATCH, - PM_ALT_EXITMENU1 + PM_ALT_EXIT_SCAN, }; extern BOOLEAN DoMenuChooser (MENU_STATE *pMS, BYTE BaseState); Modified: trunk/sc2/src/uqm/planets/generate.h =================================================================== --- trunk/sc2/src/uqm/planets/generate.h 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/planets/generate.h 2009-12-15 22:39:26 UTC (rev 3431) @@ -30,6 +30,8 @@ * (graphics and music) part. * - make generateOrbital return a meaningful value, specifically, whether * or not the player is going into orbit + * - make generateMinerals et al return the last object number (or count + * if called for all objects) and take non-pointer whichNode * - for GenerateNameFunction, set the name in an argument, instead * of in GLOBAL_SYS(PlanetName) * - make generateName work for moons Modified: trunk/sc2/src/uqm/planets/pl_stuff.c =================================================================== --- trunk/sc2/src/uqm/planets/pl_stuff.c 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/planets/pl_stuff.c 2009-12-15 22:39:26 UTC (rev 3431) @@ -242,19 +242,19 @@ PrepareNextRotationFrame (); } -// rgb.a is ignored +// tintColor.a is ignored void -DrawPlanet (int x, int y, int dy, Color rgb) +DrawPlanet (int dy, Color tintColor) { STAMP s; UBYTE a = 128; PLANET_ORBIT *Orbit = &pSolarSysState->Orbit; - s.origin.x = x; - s.origin.y = y; + s.origin.x = 0; + s.origin.y = 0; s.frame = pSolarSysState->TopoFrame; BatchGraphics (); - if (sameColor (rgb, BLACK_COLOR)) + if (sameColor (tintColor, BLACK_COLOR)) { // no tint -- just draw the surface DrawStamp (&s); } @@ -265,20 +265,21 @@ COUNT framew, frameh; RECT srect, drect, *psrect = NULL, *pdrect = NULL; FRAME tintFrame[2]; + tintFrame[0] = SetAbsFrameIndex (Orbit->TintFrame, 0); tintFrame[1] = SetAbsFrameIndex (Orbit->TintFrame, 1); framew = GetFrameWidth (tintFrame[0]); frameh = GetFrameHeight (tintFrame[0]); - if (!sameColor (rgb, pSolarSysState->Tint_rgb)) + if (!sameColor (tintColor, Orbit->TintColor)) { - pSolarSysState->Tint_rgb = rgb; + Orbit->TintColor = tintColor; // Buffer the topoMap to the tintFrame; arith_frame_blit (s.frame, NULL, tintFrame[0], NULL, 0, 0); - r = rgb.r / 2; - g = rgb.g / 2; - b = rgb.b / 2; + r = tintColor.r / 2; + g = tintColor.g / 2; + b = tintColor.b / 2; #ifdef USE_ADDITIVE_SCAN_BLIT a = 255; #endif Modified: trunk/sc2/src/uqm/planets/planets.c =================================================================== --- trunk/sc2/src/uqm/planets/planets.c 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/planets/planets.c 2009-12-15 22:39:26 UTC (rev 3431) @@ -35,6 +35,20 @@ #include "libs/graphics/gfx_common.h" +// PlanetOrbitMenu() items +enum PlanetMenuItems +{ + // XXX: Must match the enum in menustat.h + SCAN = 0, + STARMAP, + EQUIP_DEVICE, + CARGO, + ROSTER, + GAME_MENU, + NAVIGATION, +}; + + void DrawScannedObjects (BOOLEAN Reversed) { @@ -138,9 +152,11 @@ static void DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode) { - RECT r = { { SIS_ORG_X, SIS_ORG_Y }, - { SIS_SCREEN_WIDTH, SIS_SCREEN_HEIGHT } }; + RECT r; + SetContext (SpaceContext); + GetContextClipRect (&r); + BatchGraphics (); if (Mode != DRAW_ORBITAL_UPDATE) @@ -154,16 +170,14 @@ DrawPlanetSurfaceBorder (); } - SetContext (SpaceContext); - if (Mode == DRAW_ORBITAL_WAIT) { STAMP s; - s.frame = CaptureDrawable ( - LoadGraphic (ORBENTER_PMAP_ANIM)); + SetContext (GetScanContext (NULL)); + s.frame = CaptureDrawable (LoadGraphic (ORBENTER_PMAP_ANIM)); s.origin.x = -SAFE_X; - s.origin.y = SIS_SCREEN_HEIGHT - MAP_HEIGHT; + s.origin.y = 0; DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); } @@ -174,8 +188,8 @@ if (Mode != DRAW_ORBITAL_WAIT) { - DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, - SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, BLACK_COLOR); + SetContext (GetScanContext (NULL)); + DrawPlanet (0, BLACK_COLOR); } if (Mode != DRAW_ORBITAL_UPDATE) @@ -277,7 +291,7 @@ DestroyDrawable (ReleaseDrawable (Orbit->TintFrame)); Orbit->TintFrame = 0; - pSolarSysState->Tint_rgb = BLACK_COLOR; + Orbit->TintColor = BLACK_COLOR; DestroyDrawable (ReleaseDrawable (Orbit->ObjectFrame)); Orbit->ObjectFrame = 0; @@ -347,6 +361,10 @@ { case SCAN: ScanSystem (); + if (GLOBAL (CurrentActivity) & START_ENCOUNTER) + { // Found Fwiffo on Pluto + return FALSE; + } break; case EQUIP_DEVICE: select = DevicesMenu (); @@ -447,6 +465,10 @@ LockMutex (GraphicsLock); SetFlashRect (NULL); + // Need to make sure ScanContext is not active because we will destroy it + SetContext (SpaceContext); UnlockMutex (GraphicsLock); DrawMenuStateStrings (PM_STARMAP, -NAVIGATION); + + DestroyScanContext (); } Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/planets/planets.h 2009-12-15 22:39:26 UTC (rev 3431) @@ -21,27 +21,13 @@ #define END_INTERPLANETARY START_INTERPLANETARY -enum +enum PlanetScanTypes { - SCAN = 0, - STARMAP, - EQUIP_DEVICE, - CARGO, - ROSTER, - GAME_MENU, - NAVIGATION -}; - -enum -{ MINERAL_SCAN = 0, ENERGY_SCAN, BIOLOGICAL_SCAN, NUM_SCAN_TYPES, - EXIT_SCAN = NUM_SCAN_TYPES, - AUTO_SCAN, - DISPATCH_SHUTTLE }; #define MAP_WIDTH SIS_SCREEN_WIDTH @@ -155,6 +141,8 @@ // automatically drawn if present FRAME TintFrame; // tinted topo images for current scan type (dynamic) + Color TintColor; + // the color of the last used tint DWORD *lpTopoMap; // RGBA version of topo image; for 3d planet DWORD *ScratchArray; @@ -230,7 +218,6 @@ * [4] = bio 2 (world-specific) * [5] = bio 3 (world-specific) */ - Color Tint_rgb; FRAME TopoFrame; PLANET_ORBIT Orbit; BOOLEAN InOrbit; @@ -257,7 +244,7 @@ POINT planetOuterLocation (COUNT planetI); extern void LoadPlanet (FRAME SurfDefFrame); -extern void DrawPlanet (int x, int y, int dy, Color rgb); +extern void DrawPlanet (int dy, Color tintColor); extern void FreePlanet (void); extern void LoadStdLanderFont (PLANET_INFO *info); extern void FreeLanderFont (PLANET_INFO *info); Modified: trunk/sc2/src/uqm/planets/report.c =================================================================== --- trunk/sc2/src/uqm/planets/report.c 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/planets/report.c 2009-12-15 22:39:26 UTC (rev 3431) @@ -270,7 +270,7 @@ SetContext (OldContext); // TODO: Make CONTEXT ref-counted if (ownContext) - DestroyContext (context); + DestroyScanContext (); DestroyDrawable (ReleaseDrawable (saveStamp.frame)); Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/planets/scan.c 2009-12-15 22:39:26 UTC (rev 3431) @@ -57,7 +57,16 @@ static RECT cursorRect; static FRAME eraseFrame; +// ScanSystem() menu items +// The first three are from enum PlanetScanTypes in planets.h +enum ScanMenuItems +{ + EXIT_SCAN = NUM_SCAN_TYPES, + AUTO_SCAN, + DISPATCH_SHUTTLE, +}; + void RepairBackRect (RECT *pRect) { @@ -100,15 +109,13 @@ PrintScanTitlePC (TEXT *t, RECT *r, const char *txt, int xpos) { t->baseline.x = xpos; - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x15), 0x3B)); + SetContextForeGroundColor (SCAN_PC_TITLE_COLOR); t->pStr = txt; t->CharCount = (COUNT)~0; font_DrawText (t); TextRect (t, r, NULL); t->baseline.x += r->extent.width; - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x19), 0x3B)); + SetContextForeGroundColor (SCAN_INFO_COLOR); } static void @@ -171,8 +178,7 @@ t.pStr = buf; t.CharCount = (COUNT)~0; - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x15), 0x3B)); + SetContextForeGroundColor (SCAN_PC_TITLE_COLOR); SetContextFont (MicroFont); font_DrawText (&t); @@ -357,8 +363,7 @@ t.pStr = buf; t.CharCount = (COUNT)~0; - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x19), 0x3B)); + SetContextForeGroundColor (SCAN_INFO_COLOR); SetContextFont (MicroFont); font_DrawText (&t); @@ -616,7 +621,7 @@ OldContext = SetContext (ScanContext); BatchGraphics (); - DrawPlanet (0, 0, 0, BLACK_COLOR); + DrawPlanet (0, BLACK_COLOR); DrawScannedObjects (TRUE); if (newLoc) { @@ -628,132 +633,120 @@ SetContext (OldContext); } -static BOOLEAN DoScan (MENU_STATE *pMS); +static COUNT +getLandingFuelNeeded (void) +{ + COUNT fuel; -static BOOLEAN -PickPlanetSide (MENU_STATE *pMS) + fuel = pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity << 1; + if (fuel > 3 * FUEL_TANK_SCALE) + fuel = 3 * FUEL_TANK_SCALE; + + return fuel; +} + +static void +spawnFwiffo (void) { - DWORD TimeIn = GetTimeCounter (); - BOOLEAN select, cancel; + HSHIPFRAG hStarShip; - select = PulsedInputState.menu[KEY_MENU_SELECT]; - cancel = PulsedInputState.menu[KEY_MENU_CANCEL]; - - if (GLOBAL (CurrentActivity) & CHECK_ABORT) - { - goto ExitPlanetSide; - } + EncounterGroup = 0; + PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); + ReinitQueue (&GLOBAL (ip_group_q)); + assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); - if (!pMS->Initialized) + hStarShip = CloneShipFragment (SPATHI_SHIP, + &GLOBAL (npc_built_ship_q), 1); + if (hStarShip) { - pMS->InputFunc = PickPlanetSide; - SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); - if (!select) - { - pMS->Initialized = TRUE; + SHIP_FRAGMENT *StarShipPtr; - LockMutex (GraphicsLock); - SetContext (ScanContext); - // Set the current flash location - setPlanetCursorLoc (planetLoc); - savePlanetLocationImage (); - UnlockMutex (GraphicsLock); - - InitLander (0); - } + StarShipPtr = LockShipFrag (&GLOBAL (npc_built_ship_q), + hStarShip); + // Name Fwiffo + StarShipPtr->captains_name_index = NAME_OFFSET + + NUM_CAPTAINS_NAMES; + UnlockShipFrag (&GLOBAL (npc_built_ship_q), hStarShip); } - else if (select || cancel) - { - SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); +} - LockMutex (GraphicsLock); - DrawStatusMessage (NULL); - UnlockMutex (GraphicsLock); +// Returns TRUE if the parent menu should remain +static BOOLEAN +DispatchLander (void) +{ + InputFrameCallback *oldCallback; + SIZE landingFuel = getLandingFuelNeeded (); - FlushInput (); + EraseCoarseScan (); - if (!select) - { // Bailing out - LockMutex (GraphicsLock); - restorePlanetLocationImage (); - UnlockMutex (GraphicsLock); - } - else - { - InputFrameCallback *oldCallback; - COUNT fuel_required; + // Deactivate planet rotation callback + oldCallback = SetInputCallback (NULL); - fuel_required = (COUNT)( - pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity << 1); - if (fuel_required > 3 * FUEL_TANK_SCALE) - fuel_required = 3 * FUEL_TANK_SCALE; + LockMutex (GraphicsLock); + DeltaSISGauges (0, -landingFuel, 0); + SetContext (ScanContext); + drawPlanetCursor (FALSE); + UnlockMutex (GraphicsLock); - EraseCoarseScan (); + PlanetSide (planetLoc); + if (GLOBAL (CurrentActivity) & CHECK_ABORT) + return FALSE; - // Deactivate planet rotation callback - oldCallback = SetInputCallback (NULL); + if (GET_GAME_STATE (FOUND_PLUTO_SPATHI) == 1) + { + /* Create Fwiffo group and go into comm with it */ + spawnFwiffo (); - LockMutex (GraphicsLock); - DeltaSISGauges (0, -(SIZE)fuel_required, 0); - SetContext (ScanContext); - drawPlanetCursor (FALSE); - UnlockMutex (GraphicsLock); + NextActivity |= CHECK_LOAD; /* fake a load game */ + GLOBAL (CurrentActivity) |= START_ENCOUNTER; + SaveSolarSysLocation (); - PlanetSide (planetLoc); - if (GLOBAL (CurrentActivity) & CHECK_ABORT) - goto ExitPlanetSide; + return FALSE; + } - if (GET_GAME_STATE (FOUND_PLUTO_SPATHI) == 1) - { - /* Create Fwiffo group and go into comm with it */ - HSHIPFRAG hStarShip; + if (optWhichCoarseScan == OPT_PC) + PrintCoarseScanPC (); + else + PrintCoarseScan3DO (); - NextActivity |= CHECK_LOAD; /* fake a load game */ - GLOBAL (CurrentActivity) |= START_ENCOUNTER; + // Reactivate planet rotation callback + SetInputCallback (oldCallback); - EncounterGroup = 0; - PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); - ReinitQueue (&GLOBAL (ip_group_q)); - assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); + return TRUE; +} - hStarShip = CloneShipFragment (SPATHI_SHIP, - &GLOBAL (npc_built_ship_q), 1); - if (hStarShip) - { - SHIP_FRAGMENT *StarShipPtr; +typedef struct +{ + bool success; + // true when player selected a location +} PICK_PLANET_STATE; - StarShipPtr = LockShipFrag (&GLOBAL (npc_built_ship_q), - hStarShip); - // Name Fwiffo - StarShipPtr->captains_name_index = NAME_OFFSET + - NUM_CAPTAINS_NAMES; - UnlockShipFrag (&GLOBAL (npc_built_ship_q), hStarShip); - } +static BOOLEAN +DoPickPlanetSide (MENU_STATE *pMS) +{ + PICK_PLANET_STATE *pickState = pMS->privData; + DWORD TimeIn = GetTimeCounter (); + BOOLEAN select, cancel; - SaveSolarSysLocation (); - return (FALSE); - } + select = PulsedInputState.menu[KEY_MENU_SELECT]; + cancel = PulsedInputState.menu[KEY_MENU_CANCEL]; + + if (GLOBAL (CurrentActivity) & CHECK_ABORT) + { + pickState->success = false; + return FALSE; + } - if (optWhichCoarseScan == OPT_PC) - PrintCoarseScanPC (); - else - PrintCoarseScan3DO (); - - // Reactivate planet rotation callback - SetInputCallback (oldCallback); - } - - DrawMenuStateStrings (PM_MIN_SCAN, DISPATCH_SHUTTLE); - LockMutex (GraphicsLock); - SetFlashRect (SFR_MENU_3DO); - UnlockMutex (GraphicsLock); - -ExitPlanetSide: - SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); - - pMS->InputFunc = DoScan; - pMS->CurState = DISPATCH_SHUTTLE; + if (cancel) + { + pickState->success = false; + return FALSE; } + else if (select) + { + pickState->success = true; + return FALSE; + } else { SIZE dx = 0; @@ -791,8 +784,7 @@ new_pt.y = planetLoc.y; } - if (new_pt.x != planetLoc.x - || new_pt.y != planetLoc.y) + if (!pointsEqual (new_pt, planetLoc)) { setPlanetLoc (new_pt, TRUE); } @@ -805,13 +797,82 @@ SleepThreadUntil (TimeIn + ONE_SECOND / 40); } - return (TRUE); + return TRUE; } +static void +drawLandingFuelUsage (COUNT fuel) +{ + UNICODE buf[100]; + + sprintf (buf, "%s%1.1f", + GAME_STRING (NAVIGATION_STRING_BASE + 5), + (float) fuel / FUEL_TANK_SCALE); + DrawStatusMessage (buf); +} + +static void +eraseLandingFuelUsage (void) +{ + LockMutex (GraphicsLock); + DrawStatusMessage (NULL); + UnlockMutex (GraphicsLock); +} + +static BOOLEAN +PickPlanetSide (void) +{ + MENU_STATE MenuState; + PICK_PLANET_STATE PickState; + COUNT fuel = getLandingFuelNeeded (); + BOOLEAN retval = TRUE; + + memset (&MenuState, 0, sizeof MenuState); + MenuState.privData = &PickState; + + LockMutex (GraphicsLock); + ClearSISRect (CLEAR_SIS_RADAR); + SetContext (ScanContext); + BatchGraphics (); + DrawPlanet (0, BLACK_COLOR); + DrawScannedObjects (FALSE); + UnbatchGraphics (); + + drawLandingFuelUsage (fuel); + // Set the current flash location + setPlanetCursorLoc (planetLoc); + savePlanetLocationImage (); + UnlockMutex (GraphicsLock); + + InitLander (0); + + SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_SELECT); + + PickState.success = false; + MenuState.InputFunc = DoPickPlanetSide; + DoInput (&MenuState, TRUE); + + eraseLandingFuelUsage (); + if (PickState.success) + { // player chose a location + retval = DispatchLander (); + } + else + { // player bailed out + LockMutex (GraphicsLock); + restorePlanetLocationImage (); + UnlockMutex (GraphicsLock); + } + + SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + + return retval; +} + #define NUM_FLASH_COLORS 8 static void -DrawScannedStuff (COUNT y, BYTE CurState) +DrawScannedStuff (COUNT y, COUNT scan) { HELEMENT hElement, hNextElement; Color OldColor; @@ -821,76 +882,65 @@ for (hElement = GetHeadElement (); hElement; hElement = hNextElement) { ELEMENT *ElementPtr; - //Color OldColor; SIZE dy; + STAMP s; LockElement (hElement, &ElementPtr); hNextElement = GetSuccElement (ElementPtr); dy = y - ElementPtr->current.location.y; - if (LOBYTE (ElementPtr->scan_node) == CurState - && dy >= 0)// && dy <= 3) - { - COUNT i; - //DWORD Time; - STAMP s; + if (LOBYTE (ElementPtr->scan_node) != scan || dy < 0) + { // node of wrong type, or not time for it yet + UnlockElement (hElement); + continue; + } - // XXX: Hack: flag this as a scanned object - ElementPtr->state_flags |= APPEARING; + // XXX: flag this as 'found' scanned object + ElementPtr->state_flags |= APPEARING; - s.origin = ElementPtr->current.location; - s.frame = ElementPtr->current.image.frame; + s.origin = ElementPtr->current.location; + + if (dy >= NUM_FLASH_COLORS) + { // flashing done for this node, draw normal + s.frame = ElementPtr->next.image.frame; + DrawStamp (&s); + } + else + { + BYTE grad; + Color c = WHITE_COLOR; + COUNT nodeSize; - if (dy >= NUM_FLASH_COLORS) + // mineral -- white --> turquoise?? (contrasts with red) + // energy -- white --> red (contrasts with white) + // bio -- white --> violet (contrasts with green) + grad = 0xff - 0xff * dy / (NUM_FLASH_COLORS - 1); + switch (scan) { - i = (COUNT)(GetFrameIndex (ElementPtr->next.image.frame) - - GetFrameIndex (ElementPtr->current.image.frame) - + 1); - do - { - DrawStamp (&s); - s.frame = IncFrameIndex (s.frame); - } while (--i); + case MINERAL_SCAN: + c.r = grad; + break; + case ENERGY_SCAN: + c.g = grad; + c.b = grad; + break; + case BIOLOGICAL_SCAN: + c.g = grad; + break; } - else - { - BYTE r, g, b; - Color c; - - // mineral -- white --> turquoise?? (contrasts with red) - // energy -- white --> red (contrasts with white) - // bio -- white --> violet (contrasts with green) - b = (BYTE)(0x1f - 0x1f * dy / (NUM_FLASH_COLORS - 1)); - switch (CurState) - { - case (MINERAL_SCAN): - r = b; - g = 0x1f; - b = 0x1f; - break; - case (ENERGY_SCAN): - r = 0x1f; - g = b; - break; - case (BIOLOGICAL_SCAN): - r = 0x1f; - g = b; - b = 0x1f; - break; - } - - c = BUILD_COLOR (MAKE_RGB15 (r, g, b), 0); - - SetContextForeGroundColor (c); - i = (COUNT)(GetFrameIndex (ElementPtr->next.image.frame) - - GetFrameIndex (ElementPtr->current.image.frame) - + 1); - do - { - DrawFilledStamp (&s); - s.frame = IncFrameIndex (s.frame); - } while (--i); - } + + SetContextForeGroundColor (c); + + // flash the node from the smallest size to node size + // Get the node size for mineral, or number of transitions + // for other scan types (was set by GeneratePlanetSide()) + nodeSize = GetFrameIndex (ElementPtr->next.image.frame) + - GetFrameIndex (ElementPtr->current.image.frame); + if (dy > nodeSize) + dy = nodeSize; + + s.frame = SetRelFrameIndex (ElementPtr->current.image.frame, dy); + DrawFilledStamp (&s); } UnlockElement (hElement); @@ -920,248 +970,215 @@ return false; } -static BOOLEAN -DoScan (MENU_STATE *pMS) +static void +ScanPlanet (COUNT scanType) { #define SCAN_DURATION (ONE_SECOND * 7 / 4) // NUM_FLASH_COLORS for flashing blips; 1 for the final frame #define SCAN_LINES (MAP_HEIGHT + NUM_FLASH_COLORS + 1) #define SCAN_LINE_WAIT (SCAN_DURATION / SCAN_LINES) - BOOLEAN select, cancel; - select = PulsedInputState.menu[KEY_MENU_SELECT]; - cancel = PulsedInputState.menu[KEY_MENU_CANCEL]; - if (GLOBAL (CurrentActivity) & CHECK_ABORT) - return (FALSE); + PLANET_ORBIT *Orbit = &pSolarSysState->Orbit; + COUNT startScan, endScan; + COUNT scan; + RECT r; + static const Color textColors[] = + { + SCAN_MINERAL_TEXT_COLOR, + SCAN_ENERGY_TEXT_COLOR, + SCAN_BIOLOGICAL_TEXT_COLOR, + }; + static const Color tintColors[] = + { + SCAN_MINERAL_TINT_COLOR, + SCAN_ENERGY_TINT_COLOR, + SCAN_BIOLOGICAL_TINT_COLOR, + }; - if (!pMS->Initialized) + if (scanType == AUTO_SCAN) { - pMS->Initialized = TRUE; - pMS->InputFunc = DoScan; + startScan = MINERAL_SCAN; + endScan = BIOLOGICAL_SCAN; } - else if (cancel || (select && pMS->CurState == EXIT_SCAN)) + else { + startScan = scanType; + endScan = scanType; + } + + for (scan = startScan; scan <= endScan; ++scan) + { + TEXT t; + SWORD i; + Color tintColor; + // Alpha value will be ignored. + TimeCount TimeOut; + + t.baseline.x = SIS_SCREEN_WIDTH >> 1; + t.baseline.y = SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7; + t.align = ALIGN_CENTER; + t.CharCount = (COUNT)~0; + + pSolarSysState->CurNode = (COUNT)~0; + callGenerateForScanType (pSolarSysState, + pSolarSysState->pOrbitalDesc, &pSolarSysState->CurNode, + scan); + t.pStr = GAME_STRING (SCAN_STRING_BASE + scan); + LockMutex (GraphicsLock); SetContext (SpaceContext); + r.corner.x = 0; + r.corner.y = t.baseline.y - 10; + r.extent.width = SIS_SCREEN_WIDTH; + r.extent.height = t.baseline.y - r.corner.y + 1; + RepairBackRect (&r); + + SetContextFont (MicroFont); + SetContextForeGroundColor (textColors[scan]); + font_DrawText (&t); + + SetContext (ScanContext); + UnlockMutex (GraphicsLock); + + // Draw a virgin surface + LockMutex (GraphicsLock); BatchGraphics (); - DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, - SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, BLACK_COLOR); + DrawPlanet (0, BLACK_COLOR); UnbatchGraphics (); UnlockMutex (GraphicsLock); - EraseCoarseScan (); -// DrawMenuStateStrings (PM_SCAN, SCAN); + tintColor = tintColors[scan]; - return (FALSE); + // Draw the scan slowly line by line + TimeOut = GetTimeCounter (); + for (i = 0; i < SCAN_LINES; i++) + { + TimeOut += SCAN_LINE_WAIT; + if (WaitForAnyButtonUntil (TRUE, TimeOut, FALSE)) + break; + + LockMutex (GraphicsLock); + BatchGraphics (); + DrawPlanet (i, tintColor); + DrawScannedStuff (i, scan); + UnbatchGraphics (); +#ifdef SPIN_ON_SCAN + RotatePlanetSphere (TRUE); +#endif + UnlockMutex (GraphicsLock); + } + + if (i < SCAN_LINES) + { // Aborted by a keypress; draw in finished state + LockMutex (GraphicsLock); + BatchGraphics (); + // dy < 0 means "from dy to the end" + DrawPlanet (-i, tintColor); + DrawScannedStuff (SCAN_LINES - 1, scan); + UnbatchGraphics (); + UnlockMutex (GraphicsLock); + } + + // Reset the last used tint color + Orbit->TintColor = BLACK_COLOR; } + + LockMutex (GraphicsLock); + SetContext (SpaceContext); + r.corner.x = 0; + r.corner.y = (SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7) - 10; + r.extent.width = SIS_SCREEN_WIDTH; + r.extent.height = (SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7) + - r.corner.y + 1; + RepairBackRect (&r); + + SetContext (ScanContext); + if (scanType == AUTO_SCAN) + { // clear the last scan + DrawPlanet (0, BLACK_COLOR); + DrawScannedObjects (FALSE); + } + + UnlockMutex (GraphicsLock); + FlushInput (); +} + +static BOOLEAN +DoScan (MENU_STATE *pMS) +{ + BOOLEAN select, cancel; + + select = PulsedInputState.menu[KEY_MENU_SELECT]; + cancel = PulsedInputState.menu[KEY_MENU_CANCEL]; + + if (GLOBAL (CurrentActivity) & CHECK_ABORT) + return FALSE; + + if (cancel || (select && pMS->CurState == EXIT_SCAN)) + { + return FALSE; + } else if (select) { - BYTE min_scan, max_scan; - RECT r; - if (pMS->CurState == DISPATCH_SHUTTLE) { COUNT fuel_required; - UNICODE buf[100]; if ((pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED) || (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == GAS_GIANT_ATMOSPHERE)) { // cannot dispatch to shielded planets or gas giants PlayMenuSound (MENU_SOUND_FAILURE); - return (TRUE); + return TRUE; } - fuel_required = (COUNT)( - pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity << 1 - ); - if (fuel_required > 3 * FUEL_TANK_SCALE) - fuel_required = 3 * FUEL_TANK_SCALE; - - if (GLOBAL_SIS (FuelOnBoard) < (DWORD)fuel_required + fuel_required = getLandingFuelNeeded (); + if (GLOBAL_SIS (FuelOnBoard) < fuel_required || GLOBAL_SIS (NumLanders) == 0 || GLOBAL_SIS (CrewEnlisted) == 0) { PlayMenuSound (MENU_SOUND_FAILURE); - return (TRUE); + return TRUE; } - sprintf (buf, "%s%1.1f", - GAME_STRING (NAVIGATION_STRING_BASE + 5), - (float) fuel_required / FUEL_TANK_SCALE); LockMutex (GraphicsLock); - ClearSISRect (CLEAR_SIS_RADAR); - DrawStatusMessage (buf); + SetFlashRect (NULL); UnlockMutex (GraphicsLock); + if (!PickPlanetSide ()) + return FALSE; + + DrawMenuStateStrings (PM_MIN_SCAN, pMS->CurState); LockMutex (GraphicsLock); - SetFlashRect (NULL); - SetContext (ScanContext); - BatchGraphics (); - DrawPlanet (0, 0, 0, BLACK_COLOR); - DrawScannedObjects (FALSE); - UnbatchGraphics (); + SetFlashRect (SFR_MENU_3DO); UnlockMutex (GraphicsLock); - pMS->Initialized = FALSE; - pMS->CurFrame = 0; - // XXX: PickPlanetSide() will take over the InputFunc - // and later restore it when its done - return PickPlanetSide (pMS); + return TRUE; } // Various scans if (pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED) { // cannot scan shielded planets PlayMenuSound (MENU_SOUND_FAILURE); - return (TRUE); + return TRUE; } - min_scan = pMS->CurState; - if (min_scan != AUTO_SCAN) - max_scan = min_scan; - else - { - min_scan = MINERAL_SCAN; - max_scan = BIOLOGICAL_SCAN; - } - - for ( ; min_scan <= max_scan; ++min_scan) - { - TEXT t; - SWORD i; - - t.baseline.x = SIS_SCREEN_WIDTH >> 1; - t.baseline.y = SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7; - t.align = ALIGN_CENTER; - t.CharCount = (COUNT)~0; - - pSolarSysState->CurNode = (COUNT)~0; - callGenerateForScanType (pSolarSysState, - pSolarSysState->pOrbitalDesc, &pSolarSysState->CurNode, - min_scan); - pMS->delta_item = (SIZE)pSolarSysState->CurNode; - t.pStr = GAME_STRING (SCAN_STRING_BASE + min_scan); - - LockMutex (GraphicsLock); - SetContext (SpaceContext); - r.corner.x = 0; - r.corner.y = t.baseline.y - 10; - r.extent.width = SIS_SCREEN_WIDTH; - r.extent.height = t.baseline.y - r.corner.y + 1; - RepairBackRect (&r); - - SetContextFont (MicroFont); - switch (min_scan) - { - case MINERAL_SCAN: - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C)); - break; - case ENERGY_SCAN: - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x0C, 0x0C, 0x0C), 0x1C)); - break; - case BIOLOGICAL_SCAN: - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (0x00, 0x0E, 0x00), 0x6C)); - break; - } - font_DrawText (&t); - - SetContext (ScanContext); - UnlockMutex (GraphicsLock); - - { - Color rgb; - // Alpha value will be ignored. - TimeCount TimeOut; - - switch (min_scan) - { - case MINERAL_SCAN: - rgb = BUILD_COLOR (MAKE_RGB15 (0x1f, 0x00, 0x00), 0x00); - break; - case ENERGY_SCAN: - rgb = BUILD_COLOR (MAKE_RGB15 (0x1f, 0x1f, 0x1f), 0x00); - break; - case BIOLOGICAL_SCAN: - rgb = BUILD_COLOR (MAKE_RGB15 (0x00, 0x1f, 0x00), 0x00); - break; - } - - // Draw a virgin surface - LockMutex (GraphicsLock); - BatchGraphics (); - DrawPlanet (0, 0, 0, BLACK_COLOR); - UnbatchGraphics (); - UnlockMutex (GraphicsLock); - - // Draw the scan slowly line by line - TimeOut = GetTimeCounter (); - for (i = 0; i < SCAN_LINES; i++) - { - TimeOut += SCAN_LINE_WAIT; - if (WaitForAnyButtonUntil (TRUE, TimeOut, FALSE)) - break; - - LockMutex (GraphicsLock); - BatchGraphics (); - DrawPlanet (0, 0, i, rgb); - DrawScannedStuff (i, min_scan); - UnbatchGraphics (); -#ifdef SPIN_ON_SCAN - RotatePlanetSphere (TRUE); -#endif - UnlockMutex (GraphicsLock); - } - - if (i < SCAN_LINES) - { // Aborted by a keypress; draw in finished state - LockMutex (GraphicsLock); - BatchGraphics (); - // dy < 0 means "from dy to the end" - DrawPlanet (0, 0, -i, rgb); - DrawScannedStuff (SCAN_LINES - 1, min_scan); - UnbatchGraphics (); - UnlockMutex (GraphicsLock); - } - - pSolarSysState->Tint_rgb = BLACK_COLOR; - } - } - - LockMutex (GraphicsLock); - SetContext (SpaceContext); - r.corner.x = 0; - r.corner.y = (SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7) - 10; - r.extent.width = SIS_SCREEN_WIDTH; - r.extent.height = (SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7) - - r.corner.y + 1; - RepairBackRect (&r); - - SetContext (ScanContext); + ScanPlanet (pMS->CurState); if (pMS->CurState == AUTO_SCAN) { - DrawPlanet (0, 0, 0, BLACK_COLOR); - DrawScannedObjects (FALSE); - UnlockMutex (GraphicsLock); - pMS->CurState = DISPATCH_SHUTTLE; DrawMenuStateStrings (PM_MIN_SCAN, pMS->CurState); } - else - UnlockMutex (GraphicsLock); - - FlushInput (); } else if (optWhichMenu == OPT_PC || (!(pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED) && pSolarSysState->SysInfo.PlanetInfo.AtmoDensity != GAS_GIANT_ATMOSPHERE)) + { DoMenuChooser (pMS, PM_MIN_SCAN); + } - return (TRUE); + return TRUE; } static CONTEXT @@ -1192,24 +1209,36 @@ // TODO: Make CONTEXT ref-counted if (ScanContext) { - *owner = FALSE; - return ScanContext; + if (owner) + *owner = FALSE; } else { - *owner = TRUE; - return CreateScanContext (); + if (owner) + *owner = TRUE; + ScanContext = CreateScanContext (); } + return ScanContext; } void +DestroyScanContext (void) +{ + if (ScanContext) + { + DestroyContext (ScanContext); + ScanContext = NULL; + } +} + +void ScanSystem (void) { MENU_STATE MenuState; memset (&MenuState, 0, sizeof MenuState); - MenuState.InputFunc = DoScan; + GetScanContext (NULL); if (optWhichMenu == OPT_3DO && ((pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED) @@ -1217,7 +1246,6 @@ GAS_GIANT_ATMOSPHERE)) { MenuState.CurState = EXIT_SCAN; - ScanContext = NULL; } else { @@ -1227,7 +1255,6 @@ LockMutex (GraphicsLock); initPlanetLocationImage (); - ScanContext = CreateScanContext (); SetContext (ScanContext); DrawScannedObjects (FALSE); UnlockMutex (GraphicsLock); @@ -1244,22 +1271,26 @@ PrintCoarseScan3DO (); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); + + MenuState.InputFunc = DoScan; DoInput (&MenuState, FALSE); LockMutex (GraphicsLock); SetFlashRect (NULL); UnlockMutex (GraphicsLock); - if (ScanContext) - { - LockMutex (GraphicsLock); - SetContext (SpaceContext); - DestroyDrawable (ReleaseDrawable (eraseFrame)); - eraseFrame = NULL; - DestroyContext (ScanContext); - ScanContext = NULL; - UnlockMutex (GraphicsLock); - } + // cleanup scan graphics + LockMutex (GraphicsLock); + BatchGraphics (); + SetContext (ScanContext); + DrawPlanet (0, BLACK_COLOR); + SetContext (SpaceContext); + EraseCoarseScan (); + UnbatchGraphics (); + UnlockMutex (GraphicsLock); + + DestroyDrawable (ReleaseDrawable (eraseFrame)); + eraseFrame = NULL; } static void @@ -1371,7 +1402,7 @@ NodeElementPtr->mass_points = HIBYTE ( pSolarSysState->SysInfo.PlanetInfo.CurDensity); NodeElementPtr->current.image.frame = SetAbsFrameIndex ( - MiscDataFrame, (NUM_SCANDOT_TRANSITIONS << 1) + MiscDataFrame, (NUM_SCANDOT_TRANSITIONS * 2) + ElementCategory (EType) * 5); NodeElementPtr->next.image.frame = SetRelFrameIndex ( NodeElementPtr->current.image.frame, LOBYTE ( Modified: trunk/sc2/src/uqm/planets/scan.h =================================================================== --- trunk/sc2/src/uqm/planets/scan.h 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/planets/scan.h 2009-12-15 22:39:26 UTC (rev 3431) @@ -52,6 +52,7 @@ extern void RedrawSurfaceScan (const POINT *newLoc); extern CONTEXT GetScanContext (BOOLEAN *owner); +extern void DestroyScanContext (void); bool isNodeRetrieved (PLANET_INFO *planetInfo, BYTE scanType, BYTE nodeNr); void setNodeRetrieved (PLANET_INFO *planetInfo, BYTE scanType, BYTE nodeNr); Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2009-12-13 11:42:40 UTC (rev 3430) +++ trunk/sc2/src/uqm/planets/solarsys.c 2009-12-15 22:39:26 UTC (rev 3431) @@ -60,7 +60,19 @@ static void DrawOuterSystem (void); static void ValidateOrbits (void); +// SolarSysMenu() items +enum SolarSysMenuMenuItems +{ + // XXX: Must match the enum in menustat.h + STARMAP = 1, + EQUIP_DEVICE, + CARGO, + ROSTER, + GAME_MENU, + NAVIGATION, +}; + SOLARSYS_STATE *pSolarSysState; FRAME SISIPFrame; FRAME SunFrame; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |