Split DoFlagshipCommands() into separate menu functions for IP, Orbital and Hyperspace; this allowed for some solarsys and manifest menu cleanups; temporary pBaseDesc setups removed; some invariant tests removed; some code moved around to more appropriate places

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3378 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-11-30 21:57:13 +00:00
parent 273a9933bb
commit d050f79cb6
19 changed files with 668 additions and 585 deletions
+8 -9
View File
@@ -73,15 +73,14 @@ DoSelectAction (MENU_STATE *pMS)
pMS->CurState = HAIL; pMS->CurState = HAIL;
return (FALSE); return (FALSE);
case ATTACK + 1: case ATTACK + 1:
pMS->Initialized = GameOptions (); // Clearing FlashRect is not necessary
if (pMS->Initialized) if (!GameOptions ())
{ return FALSE;
DrawMenuStateStrings (PM_CONVERSE, pMS->CurState); DrawMenuStateStrings (PM_CONVERSE, pMS->CurState);
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO); SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
} break;
return ((BOOLEAN)pMS->Initialized);
default: default:
printf ("Unknown option: %d\n", pMS->CurState); printf ("Unknown option: %d\n", pMS->CurState);
} }
+1 -11
View File
@@ -24,7 +24,6 @@
#ifdef NETPLAY #ifdef NETPLAY
# include "netplay/netmelee.h" # include "netplay/netmelee.h"
#endif #endif
#include "planets/planets.h"
#include "settings.h" #include "settings.h"
#include "sounds.h" #include "sounds.h"
#include "tactrans.h" #include "tactrans.h"
@@ -377,16 +376,7 @@ DoInput (void *pInputState, BOOLEAN resetInput)
soundFlags = MenuKeysToSoundFlags (&PulsedInputState); soundFlags = MenuKeysToSoundFlags (&PulsedInputState);
if (MenuSounds if (MenuSounds && (soundFlags & (sound_0 | sound_1)))
&& (pSolarSysState == 0
/* see if in menu */
|| pSolarSysState->MenuState.CurState
|| pSolarSysState->MenuState.Initialized > 2)
&& (soundFlags & (sound_0 | sound_1))
#ifdef NEVER
&& !PLRPlaying ((MUSIC_REF)~0)
#endif /* NEVER */
)
{ {
SOUND S; SOUND S;
+34 -13
View File
@@ -238,8 +238,6 @@ DrawDescriptionString (MENU_STATE *pMS, UNICODE *Str, COUNT CursorPos,
if (!(state & DDSHS_EDIT)) if (!(state & DDSHS_EDIT))
{ // normal state { // normal state
SetFlashRect (SFR_MENU_3DO);
if (pMS->CurState == CHANGE_CAPTAIN_SETTING) if (pMS->CurState == CHANGE_CAPTAIN_SETTING)
DrawCaptainsName (); DrawCaptainsName ();
else else
@@ -327,6 +325,10 @@ DoNaming (MENU_STATE *pMS)
pMS->Initialized = TRUE; pMS->Initialized = TRUE;
pMS->InputFunc = DoNaming; pMS->InputFunc = DoNaming;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
DrawDescriptionString (pMS, buf, 0, DDSHS_EDIT); DrawDescriptionString (pMS, buf, 0, DDSHS_EDIT);
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
@@ -357,6 +359,11 @@ DoNaming (MENU_STATE *pMS)
utf8StringCopy (Setting, tes.MaxSize, buf); utf8StringCopy (Setting, tes.MaxSize, buf);
else else
utf8StringCopy (buf, sizeof (buf), Setting); utf8StringCopy (buf, sizeof (buf), Setting);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
DrawDescriptionString (pMS, buf, 0, DDSHS_NORMAL); DrawDescriptionString (pMS, buf, 0, DDSHS_NORMAL);
if (namingCB) if (namingCB)
@@ -837,11 +844,12 @@ DoPickGame (MENU_STATE *pMS)
return (FALSE); return (FALSE);
} }
first_time = (BOOLEAN)(pMS->Initialized == 0); first_time = !pMS->Initialized;
SetMenuSounds (MENU_SOUND_ARROWS | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT); SetMenuSounds (MENU_SOUND_ARROWS | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT);
if (!pMS->Initialized) if (!pMS->Initialized)
{ {
// XXX: Save DoGameOptions() state
pMS->delta_item = (SIZE)pMS->CurState; pMS->delta_item = (SIZE)pMS->CurState;
pMS->CurState = NewState = prev_save; pMS->CurState = NewState = prev_save;
pMS->InputFunc = DoPickGame; pMS->InputFunc = DoPickGame;
@@ -863,10 +871,8 @@ Restart:
} }
else if (PulsedInputState.menu[KEY_MENU_CANCEL]) else if (PulsedInputState.menu[KEY_MENU_CANCEL])
{ {
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
pMS->ModuleFrame = 0; pMS->ModuleFrame = 0;
// XXX: Restore DoGameOptions() state
pMS->CurState = (BYTE)pMS->delta_item; pMS->CurState = (BYTE)pMS->delta_item;
ResumeMusic (); ResumeMusic ();
if (LastActivity == CHECK_LOAD) if (LastActivity == CHECK_LOAD)
@@ -894,7 +900,6 @@ Restart:
} }
else else
{ {
SetFlashRect (NULL);
DrawStamp (&MsgStamp); DrawStamp (&MsgStamp);
DestroyDrawable (ReleaseDrawable (MsgStamp.frame)); DestroyDrawable (ReleaseDrawable (MsgStamp.frame));
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
@@ -916,10 +921,10 @@ Restart:
if (LoadGame ((COUNT)pMS->CurState, NULL)) if (LoadGame ((COUNT)pMS->CurState, NULL))
GLOBAL (CurrentActivity) |= CHECK_LOAD; GLOBAL (CurrentActivity) |= CHECK_LOAD;
} }
SetFlashRect (NULL);
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
pMS->ModuleFrame = 0; pMS->ModuleFrame = 0;
// XXX: Restore DoGameOptions() state
pMS->CurState = (BYTE)pMS->delta_item; pMS->CurState = (BYTE)pMS->delta_item;
return (FALSE); return (FALSE);
} }
@@ -1076,7 +1081,6 @@ ChangeGameSelection:
} }
UnbatchGraphics (); UnbatchGraphics ();
} }
SetFlashRect (NULL);
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
} }
@@ -1125,7 +1129,7 @@ PickGame (MENU_STATE *pMS)
DoInput (pMS, TRUE); DoInput (pMS, TRUE);
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
pMS->Initialized = -1; pMS->Initialized = FALSE;
pMS->InputFunc = DoGameOptions; pMS->InputFunc = DoGameOptions;
retval = TRUE; retval = TRUE;
@@ -1169,13 +1173,13 @@ DoGameOptions (MENU_STATE *pMS)
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
if (pMS->Initialized <= 0) if (!pMS->Initialized)
{ {
if (LastActivity == CHECK_LOAD) if (LastActivity == CHECK_LOAD)
pMS->CurState = LOAD_GAME; pMS->CurState = LOAD_GAME;
DrawMenuStateStrings (PM_SAVE_GAME, pMS->CurState); DrawMenuStateStrings (PM_SAVE_GAME, pMS->CurState);
pMS->Initialized = 1; pMS->Initialized = TRUE;
pMS->InputFunc = DoGameOptions; pMS->InputFunc = DoGameOptions;
} }
else if (PulsedInputState.menu[KEY_MENU_CANCEL] else if (PulsedInputState.menu[KEY_MENU_CANCEL]
@@ -1191,7 +1195,15 @@ DoGameOptions (MENU_STATE *pMS)
{ {
case SAVE_GAME: case SAVE_GAME:
case LOAD_GAME: case LOAD_GAME:
return PickGame (pMS); LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
if (!PickGame (pMS))
return FALSE;
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
break;
case QUIT_GAME: case QUIT_GAME:
if (ConfirmExit ()) if (ConfirmExit ())
return FALSE; return FALSE;
@@ -1220,9 +1232,18 @@ GameOptions (void)
MenuState.InputFunc = DoGameOptions; MenuState.InputFunc = DoGameOptions;
MenuState.CurState = SAVE_GAME; MenuState.CurState = SAVE_GAME;
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
DoInput (&MenuState, TRUE); DoInput (&MenuState, TRUE);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
pLocMenuState = 0; pLocMenuState = 0;
return ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) ? FALSE : TRUE); return ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) ? FALSE : TRUE);
+74 -4
View File
@@ -22,10 +22,12 @@
#include "collide.h" #include "collide.h"
#include "colors.h" #include "colors.h"
#include "controls.h" #include "controls.h"
#include "gameopt.h"
#include "menustat.h" #include "menustat.h"
// for DrawMenuStateStrings() // for DrawMenuStateStrings()
#include "encount.h" #include "encount.h"
#include "ship.h" #include "ship.h"
#include "shipcont.h"
#include "process.h" #include "process.h"
#include "globdata.h" #include "globdata.h"
#include "sis.h" #include "sis.h"
@@ -35,11 +37,11 @@
#include "resinst.h" #include "resinst.h"
#include "setup.h" #include "setup.h"
#include "sounds.h" #include "sounds.h"
#include "options.h"
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
#include "libs/mathlib.h" #include "libs/mathlib.h"
#define XOFFS ((RADAR_SCAN_WIDTH + (UNIT_SCREEN_WIDTH << 2)) >> 1) #define XOFFS ((RADAR_SCAN_WIDTH + (UNIT_SCREEN_WIDTH << 2)) >> 1)
#define YOFFS ((RADAR_SCAN_HEIGHT + (UNIT_SCREEN_HEIGHT << 2)) >> 1) #define YOFFS ((RADAR_SCAN_HEIGHT + (UNIT_SCREEN_HEIGHT << 2)) >> 1)
@@ -1598,6 +1600,74 @@ SeedUniverse (void)
} }
} }
static BOOLEAN
DoHyperspaceMenu (MENU_STATE *pMS)
{
BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT];
BOOLEAN handled;
if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
|| GLOBAL_SIS (CrewEnlisted) == (COUNT)~0)
return FALSE;
handled = DoMenuChooser (pMS, PM_STARMAP);
if (handled)
return TRUE;
if (!select)
return TRUE;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
switch (pMS->CurState)
{
case EQUIP_DEVICE:
select = DevicesMenu ();
if (GET_GAME_STATE (PORTAL_COUNTER))
{ // A player-induced portal to QuasiSpace is opening
return FALSE;
}
if (GLOBAL (CurrentActivity) & START_ENCOUNTER)
{ // Selected Talking Pet, going into conversation
return FALSE;
}
break;
case CARGO:
CargoMenu ();
break;
case ROSTER:
select = RosterMenu ();
break;
case GAME_MENU:
if (!GameOptions ())
return FALSE; // abort or load
break;
case STARMAP:
StarMap ();
SetDefaultMenuRepeatDelay ();
return FALSE;
case NAVIGATION:
return FALSE;
}
if (!(GLOBAL (CurrentActivity) & CHECK_ABORT))
{
if (select)
{ // 3DO menu jumps to NAVIGATE after a successful submenu run
if (optWhichMenu != OPT_PC)
pMS->CurState = NAVIGATION;
DrawMenuStateStrings (PM_STARMAP, pMS->CurState);
}
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
return TRUE;
}
void void
HyperspaceMenu (void) HyperspaceMenu (void)
{ {
@@ -1613,9 +1683,9 @@ UnbatchGraphics ();
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
memset (&MenuState, 0, sizeof (MenuState)); memset (&MenuState, 0, sizeof (MenuState));
MenuState.InputFunc = DoFlagshipCommands; MenuState.InputFunc = DoHyperspaceMenu;
MenuState.Initialized = 1; MenuState.Initialized = TRUE;
MenuState.CurState = STARMAP + 1; MenuState.CurState = STARMAP;
DrawMenuStateStrings (PM_STARMAP, STARMAP); DrawMenuStateStrings (PM_STARMAP, STARMAP);
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
-4
View File
@@ -144,8 +144,6 @@ ip_group_preprocess (ELEMENT *ElementPtr)
- pSolarSysState->PlanetDesc + 1); - pSolarSysState->PlanetDesc + 1);
task = GroupPtr->task; task = GroupPtr->task;
if (pSolarSysState->MenuState.CurState)
goto ExitIPProcess;
if ((task & REFORM_GROUP) && --GroupPtr->group_counter == 0) if ((task & REFORM_GROUP) && --GroupPtr->group_counter == 0)
{ // Finished reforming the group { // Finished reforming the group
@@ -471,7 +469,6 @@ CheckGetAway:
+ (SIZE)((long)GroupPtr->loc.y + (SIZE)((long)GroupPtr->loc.y
* (DISPLAY_FACTOR >> 1) / radius); * (DISPLAY_FACTOR >> 1) / radius);
ExitIPProcess:
EPtr->next.location.x = DISPLAY_TO_WORLD (dest_pt.x) EPtr->next.location.x = DISPLAY_TO_WORLD (dest_pt.x)
+ (COORD)(LOG_SPACE_WIDTH >> 1) + (COORD)(LOG_SPACE_WIDTH >> 1)
- (LOG_SPACE_WIDTH >> (MAX_REDUCTION + 1)); - (LOG_SPACE_WIDTH >> (MAX_REDUCTION + 1));
@@ -672,7 +669,6 @@ flag_ship_preprocess (ELEMENT *ElementPtr)
ElementPtr->thrust_wait = FLIP_WAIT; ElementPtr->thrust_wait = FLIP_WAIT;
} }
if (pSolarSysState->MenuState.CurState == 0)
{ {
BYTE flagship_loc, ec; BYTE flagship_loc, ec;
SIZE vdx, vdy, radius; SIZE vdx, vdy, radius;
+2 -1
View File
@@ -800,7 +800,8 @@ ExitOutfit:
DoInstallModule (pMS); DoInstallModule (pMS);
break; break;
case OUTFIT_SAVELOAD: case OUTFIT_SAVELOAD:
if (GameOptions () == 0) // Clearing FlashRect is not necessary
if (!GameOptions ())
goto ExitOutfit; goto ExitOutfit;
DrawMenuStateStrings (PM_FUEL, pMS->CurState); DrawMenuStateStrings (PM_FUEL, pMS->CurState);
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
+12 -10
View File
@@ -303,10 +303,10 @@ DoDiscardCargo (MENU_STATE *pMS)
if (GLOBAL (CurrentActivity) & CHECK_ABORT) if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return (FALSE); return (FALSE);
if (!(pMS->Initialized & 1)) if (!pMS->Initialized)
{ {
pMS->InputFunc = DoDiscardCargo; pMS->InputFunc = DoDiscardCargo;
++pMS->Initialized; pMS->Initialized = TRUE;
NewState = pMS->CurState; NewState = pMS->CurState;
pMS->CurState = (BYTE)~0; pMS->CurState = (BYTE)~0;
@@ -372,16 +372,18 @@ SelectCargo:
} }
void void
Cargo (MENU_STATE *pMS) CargoMenu (void)
{ {
pMS->InputFunc = DoDiscardCargo; // XXX: Should get an own STATE struct
--pMS->Initialized; MENU_STATE MenuState;
pMS->CurState = 1;
MenuState.InputFunc = DoDiscardCargo;
MenuState.Initialized = FALSE;
// XXX: 1-based index because this had to work around the
// pSolarSysState->MenuState.CurState abuse. Should be changed.
MenuState.CurState = 1;
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
DoInput (pMS, TRUE); DoInput (&MenuState, TRUE);
pMS->InputFunc = DoFlagshipCommands;
pMS->CurState = CARGO + 1;
} }
+18 -17
View File
@@ -460,12 +460,12 @@ DoManipulateDevices (MENU_STATE *pMS)
if (GLOBAL (CurrentActivity) & CHECK_ABORT) if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return (FALSE); return (FALSE);
if (!(pMS->Initialized & 1)) if (!pMS->Initialized)
{ {
DrawDevices (pMS, (BYTE)~0, (BYTE)~0); DrawDevices (pMS, (BYTE)~0, (BYTE)~0);
pMS->InputFunc = DoManipulateDevices; pMS->InputFunc = DoManipulateDevices;
++pMS->Initialized; pMS->Initialized = TRUE;
NewState = pMS->CurState; NewState = pMS->CurState;
goto SelectDevice; goto SelectDevice;
} }
@@ -640,27 +640,28 @@ InventoryDevices (BYTE *pDeviceMap, COUNT Size)
} }
BOOLEAN BOOLEAN
Devices (MENU_STATE *pMS) DevicesMenu (void)
{ {
BYTE DeviceMap[NUM_DEVICES]; BYTE DeviceMap[NUM_DEVICES];
MENU_STATE MenuState;
pMS->first_item.x = InventoryDevices (DeviceMap, NUM_DEVICES); memset (&MenuState, 0, sizeof MenuState);
if (pMS->first_item.x)
MenuState.first_item.x = InventoryDevices (DeviceMap, NUM_DEVICES);
if (MenuState.first_item.x)
{ {
pMS->InputFunc = DoManipulateDevices; MenuState.InputFunc = DoManipulateDevices;
--pMS->Initialized; MenuState.Initialized = FALSE;
pMS->CurState = 1; // XXX: 1-based index because this had to work around the
pMS->first_item.y = 0; // pSolarSysState->MenuState.CurState abuse. Should be changed.
MenuState.CurState = 1;
MenuState.first_item.y = 0;
pMS->CurFrame = (FRAME)DeviceMap; // XXX: CurFrame hack
FlushInput (); MenuState.CurFrame = (FRAME)DeviceMap;
DoManipulateDevices (pMS); /* to make sure it's initialized */ //DoManipulateDevices (pMS); /* to make sure it's initialized */
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
DoInput (pMS, TRUE); DoInput (&MenuState, TRUE);
pMS->CurFrame = 0;
pMS->InputFunc = DoFlagshipCommands;
pMS->CurState = EQUIP_DEVICE + 1;
if (GLOBAL_SIS (CrewEnlisted) != (COUNT)~0 if (GLOBAL_SIS (CrewEnlisted) != (COUNT)~0
&& !(GLOBAL (CurrentActivity) & CHECK_ABORT)) && !(GLOBAL (CurrentActivity) & CHECK_ABORT))
+121
View File
@@ -23,10 +23,15 @@
#include "../colors.h" #include "../colors.h"
#include "../element.h" #include "../element.h"
#include "../settings.h" #include "../settings.h"
#include "../controls.h"
#include "../sounds.h"
#include "../gameopt.h"
#include "../shipcont.h"
#include "../setup.h" #include "../setup.h"
#include "../uqmdebug.h" #include "../uqmdebug.h"
#include "../resinst.h" #include "../resinst.h"
#include "../nameref.h" #include "../nameref.h"
#include "options.h"
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
@@ -295,3 +300,119 @@ FreeLanderFont (PLANET_INFO *info)
DestroyDrawable (ReleaseDrawable (info->LanderFontEff)); DestroyDrawable (ReleaseDrawable (info->LanderFontEff));
info->LanderFontEff = NULL; info->LanderFontEff = NULL;
} }
static BOOLEAN
DoPlanetOrbit (MENU_STATE *pMS)
{
BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT];
BOOLEAN handled;
if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
|| GLOBAL_SIS (CrewEnlisted) == (COUNT)~0)
return FALSE;
// XXX: pMS actually refers to pSolarSysState->MenuState
handled = DoMenuChooser (pMS, PM_SCAN);
if (handled)
return TRUE;
if (!select)
return TRUE;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
switch (pMS->CurState)
{
case SCAN:
ScanSystem ();
break;
case EQUIP_DEVICE:
select = DevicesMenu ();
if (GLOBAL (CurrentActivity) & START_ENCOUNTER)
{ // Invoked Talking Pet, a Caster or Sun Device over Chmmr,
// or a Caster for Ilwrath
// Going into conversation
return FALSE;
}
break;
case CARGO:
CargoMenu ();
break;
case ROSTER:
select = RosterMenu ();
break;
case GAME_MENU:
if (!GameOptions ())
return FALSE; // abort or load
break;
case STARMAP:
{
BOOLEAN AutoPilotSet;
LockMutex (GraphicsLock);
pSolarSysState->PauseRotate = 1;
RepairSISBorder ();
UnlockMutex (GraphicsLock);
TaskSwitch ();
AutoPilotSet = StarMap ();
SetDefaultMenuRepeatDelay ();
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return FALSE;
if (!AutoPilotSet)
{ // Redraw the orbital display
LoadPlanet (NULL);
LockMutex (GraphicsLock);
pSolarSysState->PauseRotate = 0;
UnlockMutex (GraphicsLock);
break;
}
// Fall through !!!
}
case NAVIGATION:
return FALSE;
}
if (!(GLOBAL (CurrentActivity) & CHECK_ABORT))
{
if (select)
{ // 3DO menu jumps to NAVIGATE after a successful submenu run
if (optWhichMenu != OPT_PC)
pMS->CurState = NAVIGATION;
DrawMenuStateStrings (PM_SCAN, pMS->CurState);
}
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
return TRUE;
}
void
PlanetOrbitMenu (void)
{
void *oldInputFunc = pSolarSysState->MenuState.InputFunc;
DrawMenuStateStrings (PM_SCAN, SCAN);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
pSolarSysState->MenuState.CurState = SCAN;
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
// XXX: temporary; will have an own MENU_STATE
pSolarSysState->MenuState.InputFunc = DoPlanetOrbit;
DoInput (&pSolarSysState->MenuState, TRUE);
pSolarSysState->MenuState.InputFunc = oldInputFunc;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_STARMAP, -NAVIGATION);
}
+2 -9
View File
@@ -237,20 +237,11 @@ extern void ExploreSolarSys (void);
extern void DrawStarBackGround (BOOLEAN ForPlanet); extern void DrawStarBackGround (BOOLEAN ForPlanet);
extern void XFormIPLoc (POINT *pIn, POINT *pOut, BOOLEAN ToDisplay); extern void XFormIPLoc (POINT *pIn, POINT *pOut, BOOLEAN ToDisplay);
extern PLAN_GEN_FUNC GenerateIP (BYTE Index); extern PLAN_GEN_FUNC GenerateIP (BYTE Index);
extern void DrawSystem (SIZE radius, BOOLEAN IsInnerSystem);
extern void DrawOval (RECT *pRect, BYTE num_off_pixels); extern void DrawOval (RECT *pRect, BYTE num_off_pixels);
extern void DrawFilledOval (RECT *pRect); extern void DrawFilledOval (RECT *pRect);
extern void FillOrbits (SOLARSYS_STATE *system, BYTE NumPlanets, extern void FillOrbits (SOLARSYS_STATE *system, BYTE NumPlanets,
PLANET_DESC *pBaseDesc, BOOLEAN TypesDefined); PLANET_DESC *pBaseDesc, BOOLEAN TypesDefined);
extern void ScanSystem (void);
extern void ChangeSolarSys (void);
extern BOOLEAN DoFlagshipCommands (MENU_STATE *pMS);
extern void ZoomSystem (void);
extern void LoadSolarSys (void);
extern void InitLander (BYTE LanderFlags); extern void InitLander (BYTE LanderFlags);
extern BOOLEAN ValidateOrbits (void);
extern void IP_reset (void);
extern void IP_frame (void);
extern RECT* RotatePlanet (int x, int dx, int dy, COUNT scale_amt, extern RECT* RotatePlanet (int x, int dx, int dy, COUNT scale_amt,
UBYTE zoom_from, RECT *r); UBYTE zoom_from, RECT *r);
@@ -263,5 +254,7 @@ extern void DeltaTopography (COUNT num_iterations, SBYTE *DepthArray,
extern UNICODE* GetNamedPlanetaryBody (void); extern UNICODE* GetNamedPlanetaryBody (void);
extern void GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize); extern void GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize);
extern void PlanetOrbitMenu (void);
#endif /* _PLANETS_H */ #endif /* _PLANETS_H */
+3 -188
View File
@@ -1586,8 +1586,8 @@ DoneSphereGrowth:
} }
} }
static BOOLEAN BOOLEAN
DoStarMap (void) StarMap (void)
{ {
MENU_STATE MenuState; MENU_STATE MenuState;
POINT universe; POINT universe;
@@ -1614,9 +1614,6 @@ DoStarMap (void)
if (cursorLoc.x == ~0 && cursorLoc.y == ~0) if (cursorLoc.x == ~0 && cursorLoc.y == ~0)
cursorLoc = universe; cursorLoc = universe;
UnlockMutex (GraphicsLock);
TaskSwitch ();
MenuState.InputFunc = DoMoveCursor; MenuState.InputFunc = DoMoveCursor;
MenuState.Initialized = FALSE; MenuState.Initialized = FALSE;
@@ -1643,10 +1640,10 @@ DoStarMap (void)
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
DrawHyperCoords (universe); DrawHyperCoords (universe);
DrawSISMessage (NULL); DrawSISMessage (NULL);
DrawStatusMessage (NULL); DrawStatusMessage (NULL);
UnlockMutex (GraphicsLock);
if (GLOBAL (autopilot.x) == universe.x if (GLOBAL (autopilot.x) == universe.x
&& GLOBAL (autopilot.y) == universe.y) && GLOBAL (autopilot.y) == universe.y)
@@ -1656,185 +1653,3 @@ DoStarMap (void)
&& GLOBAL (autopilot.y) != ~0); && GLOBAL (autopilot.y) != ~0);
} }
BOOLEAN
DoFlagshipCommands (MENU_STATE *pMS)
{
/* TODO: Make this carried cleanly by MENU_STATE structure */
// static DWORD NextTime;
if (!(pMS->Initialized & 1))
{
/* This has some dependency on the IPtask_func */
ChangeSolarSys ();
// NextTime = GetTimeCounter ();
}
else
{
BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT];
LockMutex (GraphicsLock);
if (*(volatile BYTE *)&pMS->CurState == 0
&& (*(volatile SIZE *)&pMS->Initialized & 1)
&& !(GLOBAL (CurrentActivity)
& (START_ENCOUNTER | END_INTERPLANETARY
| CHECK_ABORT | CHECK_LOAD))
&& GLOBAL_SIS (CrewEnlisted) != (COUNT)~0)
{
UnlockMutex (GraphicsLock);
IP_frame ();
return TRUE;
}
UnlockMutex (GraphicsLock);
if (pMS->CurState)
{
BOOLEAN DoMenu;
BYTE NewState;
/* If pMS->CurState == 0, then we're flying
* around in interplanetary. This needs to be
* corrected for the MenuChooser, which thinks
* that "0" is the first menu option */
pMS->CurState --;
DoMenu = DoMenuChooser (pMS,
(BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN));
pMS->CurState ++;
if (!DoMenu) {
NewState = pMS->CurState;
if (LastActivity == CHECK_LOAD)
select = TRUE; // Selected LOAD from main menu
if (select)
{
if (NewState != SCAN + 1 && NewState != (GAME_MENU) + 1)
{
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
}
switch (NewState - 1)
{
case SCAN:
ScanSystem ();
break;
case EQUIP_DEVICE:
{
if (!Devices (pMS))
select = FALSE;
if (GET_GAME_STATE (PORTAL_COUNTER)) {
// A player-induced portal to QuasiSpace is
// opening.
return (FALSE);
}
break;
}
case CARGO:
{
Cargo (pMS);
break;
}
case ROSTER:
{
if (!Roster ())
select = FALSE;
break;
}
case GAME_MENU:
if (GameOptions () == 0)
return (FALSE);
break;
case STARMAP:
{
BOOLEAN AutoPilotSet;
LockMutex (GraphicsLock);
if (++pMS->Initialized > 3) {
pSolarSysState->PauseRotate = 1;
RepairSISBorder ();
}
AutoPilotSet = DoStarMap ();
SetDefaultMenuRepeatDelay ();
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE
|| (GLOBAL (CurrentActivity) & CHECK_ABORT))
{
UnlockMutex (GraphicsLock);
return (FALSE);
}
else if (pMS->Initialized <= 3)
{
ZoomSystem ();
--pMS->Initialized;
}
UnlockMutex (GraphicsLock);
if (!AutoPilotSet && pMS->Initialized >= 3)
{
LoadPlanet (NULL);
--pMS->Initialized;
pSolarSysState->PauseRotate = 0;
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
break;
}
}
case NAVIGATION:
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
return (FALSE);
if (pMS->Initialized <= 1)
{
pMS->Initialized = 1;
}
else if (pMS->flash_task)
{ // In planet orbit
FreePlanet ();
LockMutex (GraphicsLock);
LoadSolarSys ();
ValidateOrbits ();
ZoomSystem ();
UnlockMutex (GraphicsLock);
}
LockMutex (GraphicsLock);
pMS->CurState = 0;
FlushInput ();
UnlockMutex (GraphicsLock);
break;
}
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
;
else if (pMS->CurState)
{
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
if (select)
{
if (optWhichMenu != OPT_PC)
pMS->CurState = (NAVIGATION) + 1;
DrawMenuStateStrings ((BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN),
pMS->CurState - 1);
}
}
else
{
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_STARMAP, -NAVIGATION);
}
}
}
}
}
return (!(GLOBAL (CurrentActivity)
& (START_ENCOUNTER | END_INTERPLANETARY
| CHECK_ABORT | CHECK_LOAD))
&& GLOBAL_SIS (CrewEnlisted) != (COUNT)~0);
}
+1 -1
View File
@@ -401,7 +401,7 @@ compShipPos (const void *ptr1, const void *ptr2)
} }
BOOLEAN BOOLEAN
Roster (void) RosterMenu (void)
{ {
SIZE num_support_ships; SIZE num_support_ships;
+11 -3
View File
@@ -667,8 +667,6 @@ PickPlanetSide (MENU_STATE *pMS)
// Set the current flash location // Set the current flash location
setPlanetCursorLoc (planetLoc); setPlanetCursorLoc (planetLoc);
savePlanetLocationImage (); savePlanetLocationImage ();
SetFlashRect (NULL);
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
InitLander (0); InitLander (0);
@@ -1001,15 +999,18 @@ DoScan (MENU_STATE *pMS)
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
SetFlashRect (NULL);
SetContext (ScanContext); SetContext (ScanContext);
BatchGraphics (); BatchGraphics ();
DrawPlanet (0, 0, 0, BLACK_COLOR); DrawPlanet (0, 0, 0, BLACK_COLOR);
DrawScannedObjects (FALSE); DrawScannedObjects (FALSE);
UnbatchGraphics (); UnbatchGraphics ();
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
pMS->Initialized = FALSE; pMS->Initialized = FALSE;
pMS->CurFrame = 0; pMS->CurFrame = 0;
// XXX: PickPlanetSide() will take over the InputFunc
// and later restore it when its done
return PickPlanetSide (pMS); return PickPlanetSide (pMS);
} }
@@ -1241,6 +1242,9 @@ ScanSystem (void)
} }
DrawMenuStateStrings (PM_MIN_SCAN, MenuState.CurState); DrawMenuStateStrings (PM_MIN_SCAN, MenuState.CurState);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
if (optWhichCoarseScan == OPT_PC) if (optWhichCoarseScan == OPT_PC)
PrintCoarseScanPC (); PrintCoarseScanPC ();
@@ -1250,6 +1254,10 @@ ScanSystem (void)
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
DoInput (&MenuState, FALSE); DoInput (&MenuState, FALSE);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
if (ScanContext) if (ScanContext)
{ {
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
+2
View File
@@ -43,6 +43,8 @@ struct scan_block
SCAN_DESC *scan_base; SCAN_DESC *scan_base;
}; };
extern void ScanSystem (void);
extern void RepairBackRect (RECT *pRect); extern void RepairBackRect (RECT *pRect);
extern void GeneratePlanetSide (void); extern void GeneratePlanetSide (void);
extern bool callGenerateForScanType (SOLARSYS_STATE *solarSys, extern bool callGenerateForScanType (SOLARSYS_STATE *solarSys,
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -23,9 +23,10 @@
#define FIELD_WIDTH (STATUS_WIDTH - 5) #define FIELD_WIDTH (STATUS_WIDTH - 5)
extern void Cargo (MENU_STATE *pMS); extern void CargoMenu (void);
extern BOOLEAN Roster (void); extern BOOLEAN RosterMenu (void);
extern BOOLEAN Devices (MENU_STATE *pMS); extern BOOLEAN DevicesMenu (void);
extern BOOLEAN StarMap (void);
extern void DrawCargoStrings (BYTE OldElement, BYTE NewElement); extern void DrawCargoStrings (BYTE OldElement, BYTE NewElement);
extern void ShowRemainingCapacity (void); extern void ShowRemainingCapacity (void);
+2 -1
View File
@@ -1258,7 +1258,8 @@ ExitShipyard:
} }
else else
{ {
if (GameOptions () == 0) // Clearing FlashRect is not necessary
if (!GameOptions ())
goto ExitShipyard; goto ExitShipyard;
DrawMenuStateStrings (PM_CREW, pMS->CurState); DrawMenuStateStrings (PM_CREW, pMS->CurState);
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
+3
View File
@@ -253,6 +253,9 @@ while (--ac > 0)
else if (GLOBAL (CurrentActivity) & START_INTERPLANETARY) else if (GLOBAL (CurrentActivity) & START_INTERPLANETARY)
{ {
GLOBAL (CurrentActivity) = MAKE_WORD (IN_INTERPLANETARY, 0); GLOBAL (CurrentActivity) = MAKE_WORD (IN_INTERPLANETARY, 0);
DrawAutoPilotMessage (TRUE);
SetGameClockRate (INTERPLANETARY_CLOCK_RATE);
ExploreSolarSys (); ExploreSolarSys ();
} }
else else
-3
View File
@@ -584,7 +584,6 @@ forAllMoons (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
COUNT i; COUNT i;
assert(pSolarSysState == system); assert(pSolarSysState == system);
assert(system->pBaseDesc == planet);
for (i = 0; i < planet->NumPlanets; i++) for (i = 0; i < planet->NumPlanets; i++)
callback (star, system, planet, &system->MoonDesc[i], arg); callback (star, system, planet, &system->MoonDesc[i], arg);
@@ -675,7 +674,6 @@ planetRecurse (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
assert(CurStarDescPtr == star); assert(CurStarDescPtr == star);
assert(pSolarSysState == system); assert(pSolarSysState == system);
system->pBaseDesc = planet;
planet->pPrevDesc = &system->SunDesc[0]; planet->pPrevDesc = &system->SunDesc[0];
if (universeRecurseArg->planetFuncPre != NULL) if (universeRecurseArg->planetFuncPre != NULL)
@@ -723,7 +721,6 @@ moonRecurse (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
assert(CurStarDescPtr == star); assert(CurStarDescPtr == star);
assert(pSolarSysState == system); assert(pSolarSysState == system);
assert(system->pBaseDesc == planet);
moon->pPrevDesc = planet; moon->pPrevDesc = planet;