More cleanups.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3733 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Meep-Eep
2012-01-01 19:02:27 +00:00
parent dfd2cf0840
commit 7ad1112e61
+26 -23
View File
@@ -876,11 +876,11 @@ DMS_TryAddEscortShip (MENU_STATE *pMS)
// 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.
static BOOLEAN static BOOLEAN
DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN select, BOOLEAN cancel, DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN select, BOOLEAN cancel,
SBYTE dx, SBYTE dy, BYTE *newStateOut) SBYTE dx, SBYTE dy)
{ {
BYTE NewState;
assert (select || cancel || dx || dy); assert (select || cancel || dx || dy);
assert (pMS->delta_item & MODIFY_CREW_FLAG); assert (pMS->delta_item & MODIFY_CREW_FLAG);
@@ -907,26 +907,25 @@ DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN select, BOOLEAN cancel,
{ {
// 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.
COUNT Index = GetAvailableRaceCount (); COUNT availableCount = GetAvailableRaceCount ();
NewState = LOBYTE (pMS->delta_item); BYTE currentShip = LOBYTE (pMS->delta_item);
if (dx < 0 || dy < 0) if (dx < 0 || dy < 0)
{ {
if (NewState-- == 0) if (currentShip-- == 0)
NewState = Index - 1; currentShip = availableCount - 1;
} }
else if (dx > 0 || dy > 0) else if (dx > 0 || dy > 0)
{ {
if (++NewState == Index) if (++currentShip == availableCount)
NewState = 0; currentShip = 0;
} }
if (NewState != LOBYTE (pMS->delta_item)) if (currentShip != LOBYTE (pMS->delta_item))
{ {
DrawRaceStrings (pMS, NewState); DrawRaceStrings (pMS, currentShip);
pMS->delta_item = NewState | MODIFY_CREW_FLAG; pMS->delta_item = currentShip | MODIFY_CREW_FLAG;
} }
*newStateOut = NewState;
return TRUE; return TRUE;
} }
} }
@@ -1095,8 +1094,8 @@ DoModifyShips (MENU_STATE *pMS)
} }
else else
#endif /* WANT_SHIP_SPINS */ #endif /* WANT_SHIP_SPINS */
if (hStarShip == 0 && HINIBBLE (pMS->CurState) == 0 && if (!(pMS->delta_item & MODIFY_CREW_FLAG) &&
!(pMS->delta_item & MODIFY_CREW_FLAG) && select) hStarShip == 0 && HINIBBLE (pMS->CurState) == 0 && select)
{ {
// Select button was pressed over an empty escort // Select button was pressed over an empty escort
// ship slot. Switch to 'add escort ship' mode. // ship slot. Switch to 'add escort ship' mode.
@@ -1105,21 +1104,22 @@ DoModifyShips (MENU_STATE *pMS)
DrawRaceStrings (pMS, 0); DrawRaceStrings (pMS, 0);
return TRUE; return TRUE;
} }
else if (select || ((pMS->delta_item & MODIFY_CREW_FLAG) else if ((pMS->delta_item & MODIFY_CREW_FLAG) &&
&& (dx || dy || cancel))) hStarShip == 0 && HINIBBLE (pMS->CurState) == 0 &&
{ (dx || dy || select || cancel))
if (hStarShip == 0 && HINIBBLE (pMS->CurState) == 0)
{ {
// 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); UnlockMutex (GraphicsLock);
if (DMS_AddEscortShip (pMS, select, cancel, dx, dy, &NewState)) if (DMS_AddEscortShip (pMS, select, cancel, dx, dy))
return TRUE; return TRUE;
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
goto ChangeFlashRect; goto ChangeFlashRect;
} }
else if (select || ((pMS->delta_item & MODIFY_CREW_FLAG)
&& (dx || dy || cancel)))
{
if (select || cancel) if (select || cancel)
{ {
if ((pMS->delta_item & MODIFY_CREW_FLAG) if ((pMS->delta_item & MODIFY_CREW_FLAG)
@@ -1146,11 +1146,11 @@ DoModifyShips (MENU_STATE *pMS)
pMS->delta_item ^= MODIFY_CREW_FLAG; pMS->delta_item ^= MODIFY_CREW_FLAG;
if (!pMS->delta_item) if (!pMS->delta_item)
{
goto ChangeFlashRect; goto ChangeFlashRect;
}
else if (hStarShip == 0) if (hStarShip == 0)
{ {
// Enter crew editing mode for an escort ship.
SetContext (StatusContext); SetContext (StatusContext);
GetGaugeRect (&r, TRUE); GetGaugeRect (&r, TRUE);
SetFlashRect (&r); SetFlashRect (&r);
@@ -1160,11 +1160,13 @@ DoModifyShips (MENU_STATE *pMS)
} }
else else
{ {
// Enter crew editing mode for the flagship.
r.corner.x = pMS->flash_rect0.corner.x; r.corner.x = pMS->flash_rect0.corner.x;
r.corner.y = pMS->flash_rect0.corner.y r.corner.y = pMS->flash_rect0.corner.y
+ pMS->flash_rect0.extent.height - 6; + pMS->flash_rect0.extent.height - 6;
r.extent.width = SHIP_WIN_WIDTH; r.extent.width = SHIP_WIN_WIDTH;
r.extent.height = 5; r.extent.height = 5;
SetContext (SpaceContext); SetContext (SpaceContext);
SetFlashRect (&r); SetFlashRect (&r);
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
@@ -1180,6 +1182,7 @@ DoModifyShips (MENU_STATE *pMS)
} }
else if (cancel) else if (cancel)
{ {
// Leave escort ship editor.
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
pMS->InputFunc = DoShipyard; pMS->InputFunc = DoShipyard;