More DoModifyShips() cleanups. That should be all for now.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3737 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+205
-171
@@ -73,6 +73,14 @@ enum
|
|||||||
SHIPYARD_EXIT
|
SHIPYARD_EXIT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Editing mode for DoModifyShips()
|
||||||
|
typedef enum {
|
||||||
|
DMS_Mode_navigate, // Navigating the ship slots.
|
||||||
|
DMS_Mode_addEscort, // Selecting a ship to add to an empty slot.
|
||||||
|
DMS_Mode_editCrew, // Hiring or dismissing crew.
|
||||||
|
DMS_Mode_exit, // Leaving DoModifyShips() mode.
|
||||||
|
} DMS_Mode;
|
||||||
|
|
||||||
static COUNT ShipCost[] =
|
static COUNT ShipCost[] =
|
||||||
{
|
{
|
||||||
RACE_SHIP_COST
|
RACE_SHIP_COST
|
||||||
@@ -596,6 +604,63 @@ DMS_FlashEscortShipCrewCount (BYTE slotNr)
|
|||||||
SetFlashRect (&r);
|
SetFlashRect (&r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function for DoModifyShips(). Called to change the flash
|
||||||
|
// rectangle to the currently selected ship (flagship or escort ship).
|
||||||
|
static void
|
||||||
|
DMS_FlashActiveShip (MENU_STATE *pMS)
|
||||||
|
{
|
||||||
|
if (HINIBBLE (pMS->CurState))
|
||||||
|
{
|
||||||
|
// Flash the flag ship.
|
||||||
|
DMS_FlashFlagShip ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Flash the current escort ship slot.
|
||||||
|
DMS_FlashEscortShip (pMS->CurState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function for DoModifyShips(). Called to switch between
|
||||||
|
// the various edit modes.
|
||||||
|
// XXX: right now, this only switches the sound and flash rectangle.
|
||||||
|
// Perhaps we should move more of the code to modify other aspects
|
||||||
|
// here too.
|
||||||
|
static void
|
||||||
|
DMS_SetMode (MENU_STATE *pMS, DMS_Mode mode)
|
||||||
|
{
|
||||||
|
LockMutex (GraphicsLock);
|
||||||
|
switch (mode) {
|
||||||
|
case DMS_Mode_navigate:
|
||||||
|
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
|
||||||
|
DMS_FlashActiveShip (pMS);
|
||||||
|
break;
|
||||||
|
case DMS_Mode_addEscort:
|
||||||
|
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
|
||||||
|
SetFlashRect (SFR_MENU_3DO);
|
||||||
|
break;
|
||||||
|
case DMS_Mode_editCrew:
|
||||||
|
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
|
||||||
|
MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
|
||||||
|
if (HINIBBLE (pMS->CurState))
|
||||||
|
{
|
||||||
|
// Enter crew editing mode for the flagship.
|
||||||
|
DMS_FlashFlagShipCrewCount ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Enter crew editing mode for an escort ship.
|
||||||
|
DMS_FlashEscortShipCrewCount (pMS->CurState);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DMS_Mode_exit:
|
||||||
|
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
|
||||||
|
SetFlashRect (SFR_MENU_3DO);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
UnlockMutex (GraphicsLock);
|
||||||
|
}
|
||||||
|
|
||||||
#define MODIFY_CREW_FLAG (1 << 8)
|
#define MODIFY_CREW_FLAG (1 << 8)
|
||||||
#ifdef WANT_SHIP_SPINS
|
#ifdef WANT_SHIP_SPINS
|
||||||
// Helper function for DoModifyShips(), called when the player presses the
|
// Helper function for DoModifyShips(), called when the player presses the
|
||||||
@@ -603,6 +668,7 @@ DMS_FlashEscortShipCrewCount (BYTE slotNr)
|
|||||||
// It works both when the cursor is over an escort ship, while not editing
|
// It works both when the cursor is over an escort ship, while not editing
|
||||||
// the crew, and when a new ship is added.
|
// the crew, and when a new ship is added.
|
||||||
// hStarShip is the ship in the slot under the cursor (or 0 if no such ship).
|
// hStarShip is the ship in the slot under the cursor (or 0 if no such ship).
|
||||||
|
// Pre: GraphicsLock is locked.
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
DMS_SpinShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
|
DMS_SpinShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
|
||||||
{
|
{
|
||||||
@@ -649,7 +715,6 @@ DMS_SpinShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
|
|||||||
if (hStarShip)
|
if (hStarShip)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
SetFlashRect (SFR_MENU_3DO);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif /* WANT_SHIP_SPINS */
|
#endif /* WANT_SHIP_SPINS */
|
||||||
@@ -825,9 +890,6 @@ DMS_ModifyCrew (MENU_STATE *pMS, HSHIPFRAG hStarShip, SBYTE dy)
|
|||||||
if (hStarShip)
|
if (hStarShip)
|
||||||
StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
||||||
|
|
||||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
|
|
||||||
MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
|
|
||||||
|
|
||||||
if (hStarShip == 0)
|
if (hStarShip == 0)
|
||||||
{
|
{
|
||||||
// Add/Dismiss crew for the flagship.
|
// Add/Dismiss crew for the flagship.
|
||||||
@@ -893,39 +955,45 @@ DMS_TryAddEscortShip (MENU_STATE *pMS)
|
|||||||
{
|
{
|
||||||
ShowCombatShip (pMS, pMS->CurState, NULL);
|
ShowCombatShip (pMS, pMS->CurState, NULL);
|
||||||
// Reset flash rectangle
|
// Reset flash rectangle
|
||||||
LockMutex (GraphicsLock);
|
|
||||||
SetFlashRect (SFR_MENU_3DO);
|
|
||||||
UnlockMutex (GraphicsLock);
|
|
||||||
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
|
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
|
||||||
|
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA,
|
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA,
|
||||||
-((int)ShipCost[Index]));
|
-((int)ShipCost[Index]));
|
||||||
|
|
||||||
DMS_FlashEscortShipCrewCount (pMS->CurState);
|
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
|
DMS_SetMode (pMS, DMS_Mode_editCrew);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// not enough RUs to build, or cloning the ship failed.
|
// not enough RUs to build, or cloning the ship failed.
|
||||||
PlayMenuSound (MENU_SOUND_FAILURE);
|
PlayMenuSound (MENU_SOUND_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
|
|
||||||
MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function for DoModifyShips(), called when the player is in the
|
// Helper function for DoModifyShips(), called when the player is in the
|
||||||
// mode to add a new escort ship to the fleet (after pressing select on an
|
// mode to add a new escort ship to the fleet (after pressing select on an
|
||||||
// empty slot).
|
// empty slot).
|
||||||
// LOBYTE (pMS->delta_item) is used to store the currently highlighted ship.
|
// LOBYTE (pMS->delta_item) is used to store the currently highlighted ship.
|
||||||
static BOOLEAN
|
// Returns FALSE if the flash rectangle needs to be updated.
|
||||||
DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN select, BOOLEAN cancel,
|
static void
|
||||||
SBYTE dx, SBYTE dy)
|
DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN special, BOOLEAN select,
|
||||||
|
BOOLEAN cancel, SBYTE dx, SBYTE dy)
|
||||||
{
|
{
|
||||||
assert (select || cancel || dx || dy);
|
|
||||||
assert (pMS->delta_item & MODIFY_CREW_FLAG);
|
assert (pMS->delta_item & MODIFY_CREW_FLAG);
|
||||||
|
|
||||||
|
#ifdef WANT_SHIP_SPINS
|
||||||
|
if (special)
|
||||||
|
{
|
||||||
|
HSHIPFRAG hStarShip = GetEscortByStarShipIndex (pMS->delta_item);
|
||||||
|
DMS_SpinShip (pMS, hStarShip);
|
||||||
|
DMS_SetMode (pMS, DMS_Mode_addEscort);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
(void) special; // Satisfying compiler.
|
||||||
|
#endif /* WANT_SHIP_SPINS */
|
||||||
|
|
||||||
|
UnlockMutex (GraphicsLock);
|
||||||
if (cancel)
|
if (cancel)
|
||||||
{
|
{
|
||||||
// Cancel selecting an escort ship.
|
// Cancel selecting an escort ship.
|
||||||
@@ -934,18 +1002,15 @@ DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN select, BOOLEAN cancel,
|
|||||||
SetFlashRect (SFR_MENU_3DO);
|
SetFlashRect (SFR_MENU_3DO);
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
|
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
|
||||||
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
|
DMS_SetMode (pMS, DMS_Mode_navigate);
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
else if (select)
|
||||||
if (select)
|
|
||||||
{
|
{
|
||||||
// Selected a ship to be inserted in an empty escort
|
// Selected a ship to be inserted in an empty escort
|
||||||
// ship slot.
|
// ship slot.
|
||||||
DMS_TryAddEscortShip (pMS);
|
DMS_TryAddEscortShip (pMS);
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
else if (dx || dy)
|
||||||
{
|
{
|
||||||
// Motion key pressed while selecting a ship to be
|
// Motion key pressed while selecting a ship to be
|
||||||
// inserted in an empty escort ship slot.
|
// inserted in an empty escort ship slot.
|
||||||
@@ -967,9 +1032,8 @@ DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN select, BOOLEAN cancel,
|
|||||||
DrawRaceStrings (pMS, currentShip);
|
DrawRaceStrings (pMS, currentShip);
|
||||||
pMS->delta_item = currentShip | MODIFY_CREW_FLAG;
|
pMS->delta_item = currentShip | MODIFY_CREW_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
LockMutex (GraphicsLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function for DoModifyShips(), called when the player presses
|
// Helper function for DoModifyShips(), called when the player presses
|
||||||
@@ -995,7 +1059,9 @@ DMS_ScrapEscortShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
|
|||||||
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
|
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
|
||||||
|
|
||||||
SetContext (SpaceContext);
|
SetContext (SpaceContext);
|
||||||
DMS_FlashEscortShip (slotNr);
|
UnlockMutex (GraphicsLock);
|
||||||
|
DMS_SetMode (pMS, DMS_Mode_navigate);
|
||||||
|
LockMutex (GraphicsLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function for DoModifyShips(), called when the player presses
|
// Helper function for DoModifyShips(), called when the player presses
|
||||||
@@ -1039,7 +1105,104 @@ DMS_MoveCursor (BYTE curState, SBYTE dx, SBYTE dy)
|
|||||||
isFlagShipSelected ? 0xf : 0);
|
isFlagShipSelected ? 0xf : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* in this routine, the least significant byte of pMS->CurState is used
|
// Helper function for DoModifyShips(), called every time DoModifyShip() is
|
||||||
|
// called when we are in crew editing mode.
|
||||||
|
static void
|
||||||
|
DMS_EditCrewMode (MENU_STATE *pMS, HSHIPFRAG hStarShip,
|
||||||
|
BOOLEAN select, BOOLEAN cancel, SBYTE dy)
|
||||||
|
{
|
||||||
|
if (select || cancel)
|
||||||
|
{
|
||||||
|
// Leave crew editing mode.
|
||||||
|
if (hStarShip != 0)
|
||||||
|
{
|
||||||
|
// Exiting crew editing mode for an escort ship.
|
||||||
|
SHIP_FRAGMENT *StarShipPtr = LockShipFrag (
|
||||||
|
&GLOBAL (built_ship_q), hStarShip);
|
||||||
|
COUNT crew_level = StarShipPtr->crew_level;
|
||||||
|
UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
||||||
|
|
||||||
|
if (crew_level == 0)
|
||||||
|
{
|
||||||
|
// Scrapping the escort ship before exiting crew edit
|
||||||
|
// mode.
|
||||||
|
DMS_ScrapEscortShip (pMS, hStarShip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pMS->delta_item &= ~MODIFY_CREW_FLAG;
|
||||||
|
DMS_SetMode (pMS, DMS_Mode_navigate);
|
||||||
|
}
|
||||||
|
else if (dy)
|
||||||
|
{
|
||||||
|
// Hire or dismiss crew for the flagship or an escort
|
||||||
|
// ship.
|
||||||
|
DMS_ModifyCrew (pMS, hStarShip, dy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function for DoModifyShips(), called every time DoModifyShip() is
|
||||||
|
// called when we are in the mode where you can select a ship or empty slot.
|
||||||
|
void
|
||||||
|
DMS_NavigateShipSlots (MENU_STATE *pMS, BOOLEAN special, BOOLEAN select,
|
||||||
|
BOOLEAN cancel, SBYTE dx, SBYTE dy)
|
||||||
|
{
|
||||||
|
HSHIPFRAG hStarShip = GetEscortByStarShipIndex (pMS->CurState);
|
||||||
|
|
||||||
|
if (dx || dy)
|
||||||
|
{
|
||||||
|
// Moving through the ship slots.
|
||||||
|
BYTE NewState = DMS_MoveCursor (pMS->CurState, dx, dy);
|
||||||
|
if (NewState != pMS->CurState)
|
||||||
|
{
|
||||||
|
pMS->CurState = NewState;
|
||||||
|
DMS_FlashActiveShip(pMS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef WANT_SHIP_SPINS
|
||||||
|
(void) special; // Satisfying compiler.
|
||||||
|
#else
|
||||||
|
if (special)
|
||||||
|
{
|
||||||
|
DMS_SpinShip (pMS, hStarShip);
|
||||||
|
DMS_SetMode (pMS, DMS_Mode_navigate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* WANT_SHIP_SPINS */
|
||||||
|
if (select)
|
||||||
|
{
|
||||||
|
if (hStarShip == 0 && HINIBBLE (pMS->CurState) == 0)
|
||||||
|
{
|
||||||
|
// Select button was pressed over an empty escort
|
||||||
|
// ship slot. Switch to 'add escort ship' mode.
|
||||||
|
UnlockMutex (GraphicsLock);
|
||||||
|
pMS->delta_item = MODIFY_CREW_FLAG;
|
||||||
|
DrawRaceStrings (pMS, 0);
|
||||||
|
DMS_SetMode (pMS, DMS_Mode_addEscort);
|
||||||
|
LockMutex (GraphicsLock);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Select button was pressed over an escort ship or
|
||||||
|
// the flagship. Entering crew editing mode
|
||||||
|
pMS->delta_item |= MODIFY_CREW_FLAG;
|
||||||
|
DMS_SetMode (pMS, DMS_Mode_editCrew);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cancel)
|
||||||
|
{
|
||||||
|
// Leave escort ship editor.
|
||||||
|
UnlockMutex (GraphicsLock);
|
||||||
|
pMS->InputFunc = DoShipyard;
|
||||||
|
pMS->CurState = SHIPYARD_CREW;
|
||||||
|
DrawMenuStateStrings (PM_CREW, pMS->CurState);
|
||||||
|
DMS_SetMode (pMS, DMS_Mode_exit);
|
||||||
|
LockMutex (GraphicsLock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* In this routine, the least significant byte of pMS->CurState is used
|
||||||
* to store the current selected ship index
|
* to store the current selected ship index
|
||||||
* a special case for the row is hi-nibble == -1 (0xf), which specifies
|
* a special case for the row is hi-nibble == -1 (0xf), which specifies
|
||||||
* SIS as the selected ship
|
* SIS as the selected ship
|
||||||
@@ -1049,12 +1212,6 @@ DMS_MoveCursor (BYTE curState, SBYTE dx, SBYTE dy)
|
|||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
DoModifyShips (MENU_STATE *pMS)
|
DoModifyShips (MENU_STATE *pMS)
|
||||||
{
|
{
|
||||||
#ifdef WANT_SHIP_SPINS
|
|
||||||
BOOLEAN special = PulsedInputState.menu[KEY_MENU_SPECIAL];
|
|
||||||
#endif /* WANT_SHIP_SPINS */
|
|
||||||
BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT];
|
|
||||||
BOOLEAN cancel = PulsedInputState.menu[KEY_MENU_CANCEL];
|
|
||||||
|
|
||||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||||
{
|
{
|
||||||
pMS->InputFunc = DoShipyard;
|
pMS->InputFunc = DoShipyard;
|
||||||
@@ -1068,20 +1225,18 @@ DoModifyShips (MENU_STATE *pMS)
|
|||||||
pMS->CurState = MAKE_BYTE (0, 0xF);
|
pMS->CurState = MAKE_BYTE (0, 0xF);
|
||||||
pMS->delta_item = 0;
|
pMS->delta_item = 0;
|
||||||
|
|
||||||
|
DMS_SetMode (pMS, DMS_Mode_navigate);
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
SetContext (SpaceContext);
|
SetContext (SpaceContext);
|
||||||
goto ChangeFlashRect;
|
DMS_SetMode (pMS, DMS_Mode_navigate);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
BOOLEAN special = (PulsedInputState.menu[KEY_MENU_SPECIAL] != 0);
|
||||||
|
BOOLEAN select = (PulsedInputState.menu[KEY_MENU_SELECT] != 0);
|
||||||
|
BOOLEAN cancel = (PulsedInputState.menu[KEY_MENU_CANCEL] != 0);
|
||||||
SBYTE dx = 0;
|
SBYTE dx = 0;
|
||||||
SBYTE dy = 0;
|
SBYTE dy = 0;
|
||||||
BYTE NewState = pMS->CurState;
|
|
||||||
|
|
||||||
if (!(pMS->delta_item & MODIFY_CREW_FLAG))
|
|
||||||
{
|
|
||||||
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PulsedInputState.menu[KEY_MENU_RIGHT])
|
if (PulsedInputState.menu[KEY_MENU_RIGHT])
|
||||||
dx = 1;
|
dx = 1;
|
||||||
@@ -1092,155 +1247,34 @@ DoModifyShips (MENU_STATE *pMS)
|
|||||||
if (PulsedInputState.menu[KEY_MENU_DOWN])
|
if (PulsedInputState.menu[KEY_MENU_DOWN])
|
||||||
dy = 1;
|
dy = 1;
|
||||||
|
|
||||||
if (pMS->delta_item & MODIFY_CREW_FLAG)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (dx || dy)
|
|
||||||
{
|
|
||||||
NewState = DMS_MoveCursor (NewState, dx, dy);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (select || cancel
|
|
||||||
#ifdef WANT_SHIP_SPINS
|
|
||||||
|| special
|
|
||||||
#endif
|
|
||||||
|| NewState != pMS->CurState
|
|
||||||
|| ((pMS->delta_item & MODIFY_CREW_FLAG) && (dx || dy)))
|
|
||||||
{
|
|
||||||
HSHIPFRAG hStarShip;
|
|
||||||
|
|
||||||
hStarShip = GetEscortByStarShipIndex (pMS->CurState);
|
|
||||||
|
|
||||||
if ((pMS->delta_item & MODIFY_CREW_FLAG) && (hStarShip))
|
|
||||||
{
|
|
||||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
|
|
||||||
MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
|
|
||||||
}
|
|
||||||
|
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
|
|
||||||
#ifdef WANT_SHIP_SPINS
|
if (!(pMS->delta_item & MODIFY_CREW_FLAG))
|
||||||
if (special)
|
|
||||||
{
|
{
|
||||||
if (DMS_SpinShip (pMS, hStarShip))
|
// Navigating through the ship slots.
|
||||||
goto ChangeFlashRect;
|
DMS_NavigateShipSlots (pMS, special, select, cancel, dx, dy);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* WANT_SHIP_SPINS */
|
|
||||||
if (!(pMS->delta_item & MODIFY_CREW_FLAG) &&
|
|
||||||
hStarShip == 0 && HINIBBLE (pMS->CurState) == 0 && select)
|
|
||||||
{
|
{
|
||||||
// Select button was pressed over an empty escort
|
// Add an escort ship or edit the crew of a ship.
|
||||||
// ship slot. Switch to 'add escort ship' mode.
|
HSHIPFRAG hStarShip = GetEscortByStarShipIndex (pMS->CurState);
|
||||||
UnlockMutex (GraphicsLock);
|
|
||||||
pMS->delta_item = MODIFY_CREW_FLAG;
|
if (hStarShip == 0 && HINIBBLE (pMS->CurState) == 0)
|
||||||
DrawRaceStrings (pMS, 0);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else if ((pMS->delta_item & MODIFY_CREW_FLAG) &&
|
|
||||||
hStarShip == 0 && HINIBBLE (pMS->CurState) == 0 &&
|
|
||||||
(dx || dy || select || cancel))
|
|
||||||
{
|
{
|
||||||
// Cursor is over an empty escort ship slot, while we're
|
// Cursor is over an empty escort ship slot, while we're
|
||||||
// in 'add escort ship' mode.
|
// in 'add escort ship' mode.
|
||||||
UnlockMutex (GraphicsLock);
|
DMS_AddEscortShip (pMS, special, select, cancel, dx, dy);
|
||||||
if (DMS_AddEscortShip (pMS, select, cancel, dx, dy))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
LockMutex (GraphicsLock);
|
|
||||||
goto ChangeFlashRect;
|
|
||||||
}
|
|
||||||
else if (select || ((pMS->delta_item & MODIFY_CREW_FLAG)
|
|
||||||
&& (dx || dy || cancel)))
|
|
||||||
{
|
|
||||||
if (select || cancel)
|
|
||||||
{
|
|
||||||
if ((pMS->delta_item & MODIFY_CREW_FLAG)
|
|
||||||
&& hStarShip != 0)
|
|
||||||
{
|
|
||||||
// Pressing the select or cancel button in crew edit
|
|
||||||
// mode for an escort ship.
|
|
||||||
SHIP_FRAGMENT *StarShipPtr = LockShipFrag (
|
|
||||||
&GLOBAL (built_ship_q), hStarShip);
|
|
||||||
COUNT crew_level = StarShipPtr->crew_level;
|
|
||||||
UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
|
||||||
|
|
||||||
if (crew_level == 0)
|
|
||||||
{
|
|
||||||
// Scrap escort ship, then exiting crew edit
|
|
||||||
// mode.
|
|
||||||
DMS_ScrapEscortShip (pMS, hStarShip);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Just exiting escort ship crew edit mode.
|
// Crew editing mode.
|
||||||
|
DMS_EditCrewMode (pMS, hStarShip, select, cancel, dy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pMS->delta_item ^= MODIFY_CREW_FLAG;
|
|
||||||
if (!pMS->delta_item)
|
|
||||||
goto ChangeFlashRect;
|
|
||||||
|
|
||||||
if (hStarShip == 0)
|
|
||||||
{
|
|
||||||
// Enter crew editing mode for the flagship.
|
|
||||||
DMS_FlashFlagShipCrewCount ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Enter crew editing mode for an escort ship.
|
|
||||||
DMS_FlashEscortShipCrewCount (pMS->CurState);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Entering crew editing mode
|
|
||||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
|
|
||||||
MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
|
|
||||||
}
|
|
||||||
else if (pMS->delta_item & MODIFY_CREW_FLAG)
|
|
||||||
{
|
|
||||||
// Hire or dismiss crew for the flagship or an escort
|
|
||||||
// ship.
|
|
||||||
DMS_ModifyCrew (pMS, hStarShip, dy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (cancel)
|
|
||||||
{
|
|
||||||
// Leave escort ship editor.
|
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
|
|
||||||
pMS->InputFunc = DoShipyard;
|
|
||||||
pMS->CurState = SHIPYARD_CREW;
|
|
||||||
DrawMenuStateStrings (PM_CREW, pMS->CurState);
|
|
||||||
LockMutex (GraphicsLock);
|
|
||||||
SetFlashRect (SFR_MENU_3DO);
|
|
||||||
UnlockMutex (GraphicsLock);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pMS->CurState = NewState;
|
|
||||||
|
|
||||||
ChangeFlashRect:
|
|
||||||
if (HINIBBLE (pMS->CurState))
|
|
||||||
{
|
|
||||||
// Flash the flag ship.
|
|
||||||
DMS_FlashFlagShip ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Flash the current escort ship slot.
|
|
||||||
DMS_FlashEscortShip (pMS->CurState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UnlockMutex (GraphicsLock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SleepThread (ONE_SECOND / 30);
|
SleepThread (ONE_SECOND / 30);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
Reference in New Issue
Block a user