More cleanups. Among other things, MENU_STATE.flash_rect0 is no longer used.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3734 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+90
-74
@@ -257,7 +257,7 @@ DrawRaceStrings (MENU_STATE *pMS, BYTE NewRaceItem)
|
|||||||
#define SHIP_WIN_FRAMES ((SHIP_WIN_WIDTH >> 1) + 1)
|
#define SHIP_WIN_FRAMES ((SHIP_WIN_WIDTH >> 1) + 1)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ShowShipCrew (SHIP_FRAGMENT *StarShipPtr, RECT *pRect)
|
ShowShipCrew (SHIP_FRAGMENT *StarShipPtr, const RECT *pRect)
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
TEXT t;
|
TEXT t;
|
||||||
@@ -535,6 +535,67 @@ CrewTransaction (SIZE crew_delta)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pre: GraphicsLock is locked.
|
||||||
|
static void
|
||||||
|
DMS_FlashFlagShip (void)
|
||||||
|
{
|
||||||
|
RECT r;
|
||||||
|
r.corner.x = 0;
|
||||||
|
r.corner.y = 0;
|
||||||
|
r.extent.width = SIS_SCREEN_WIDTH;
|
||||||
|
r.extent.height = 61;
|
||||||
|
SetFlashRect (&r);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
DMS_GetEscortShipRect (RECT *rOut, BYTE slotNr)
|
||||||
|
{
|
||||||
|
BYTE row = slotNr / HANGAR_SHIPS_ROW;
|
||||||
|
BYTE col = slotNr % HANGAR_SHIPS_ROW;
|
||||||
|
|
||||||
|
rOut->corner.x = hangar_x_coords[col];
|
||||||
|
rOut->corner.y = HANGAR_Y + (HANGAR_DY * row);
|
||||||
|
rOut->extent.width = SHIP_WIN_WIDTH;
|
||||||
|
rOut->extent.height = SHIP_WIN_HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pre: GraphicsLock is locked.
|
||||||
|
static void
|
||||||
|
DMS_FlashEscortShip (BYTE slotNr)
|
||||||
|
{
|
||||||
|
RECT r;
|
||||||
|
DMS_GetEscortShipRect (&r, slotNr);
|
||||||
|
SetFlashRect (&r);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pre: GraphicsLock is locked.
|
||||||
|
static void
|
||||||
|
DMS_FlashFlagShipCrewCount (void)
|
||||||
|
{
|
||||||
|
RECT r;
|
||||||
|
SetContext (StatusContext);
|
||||||
|
GetGaugeRect (&r, TRUE);
|
||||||
|
SetFlashRect (&r);
|
||||||
|
SetContext (SpaceContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pre: GraphicsLock is locked.
|
||||||
|
static void
|
||||||
|
DMS_FlashEscortShipCrewCount (BYTE slotNr)
|
||||||
|
{
|
||||||
|
RECT r;
|
||||||
|
BYTE row = slotNr / HANGAR_SHIPS_ROW;
|
||||||
|
BYTE col = slotNr % HANGAR_SHIPS_ROW;
|
||||||
|
|
||||||
|
r.corner.x = hangar_x_coords[col];
|
||||||
|
r.corner.y = (HANGAR_Y + (HANGAR_DY * row)) + (SHIP_WIN_HEIGHT - 6);
|
||||||
|
r.extent.width = SHIP_WIN_WIDTH;
|
||||||
|
r.extent.height = 5;
|
||||||
|
|
||||||
|
SetContext (SpaceContext);
|
||||||
|
SetFlashRect (&r);
|
||||||
|
}
|
||||||
|
|
||||||
#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
|
||||||
@@ -655,9 +716,10 @@ DMS_DismissFlagShipCrew (void)
|
|||||||
// Buy crew for an escort ship
|
// Buy crew for an escort ship
|
||||||
// Returns the change in crew (1 on success, 0 on failure).
|
// Returns the change in crew (1 on success, 0 on failure).
|
||||||
static SIZE
|
static SIZE
|
||||||
DMS_HireEscortShipCrew (MENU_STATE *pMS, SHIP_FRAGMENT *StarShipPtr)
|
DMS_HireEscortShipCrew (SHIP_FRAGMENT *StarShipPtr)
|
||||||
{
|
{
|
||||||
COUNT templateMaxCrew;
|
COUNT templateMaxCrew;
|
||||||
|
RECT r;
|
||||||
|
|
||||||
{
|
{
|
||||||
// XXX Split this off into a separate function?
|
// XXX Split this off into a separate function?
|
||||||
@@ -698,7 +760,8 @@ DMS_HireEscortShipCrew (MENU_STATE *pMS, SHIP_FRAGMENT *StarShipPtr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
++StarShipPtr->crew_level;
|
++StarShipPtr->crew_level;
|
||||||
ShowShipCrew (StarShipPtr, &pMS->flash_rect0);
|
DMS_GetEscortShipRect (&r, StarShipPtr->index);
|
||||||
|
ShowShipCrew (StarShipPtr, &r);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -708,9 +771,10 @@ DMS_HireEscortShipCrew (MENU_STATE *pMS, SHIP_FRAGMENT *StarShipPtr)
|
|||||||
// Dismiss crew from an escort ship
|
// Dismiss crew from an escort ship
|
||||||
// Returns the change in crew (-1 on success, 0 on failure).
|
// Returns the change in crew (-1 on success, 0 on failure).
|
||||||
static SIZE
|
static SIZE
|
||||||
DMS_DismissEscortShipCrew (MENU_STATE *pMS, SHIP_FRAGMENT *StarShipPtr)
|
DMS_DismissEscortShipCrew (SHIP_FRAGMENT *StarShipPtr)
|
||||||
{
|
{
|
||||||
SIZE crew_delta = 0;
|
SIZE crew_delta = 0;
|
||||||
|
RECT r;
|
||||||
|
|
||||||
if (StarShipPtr->crew_level > 0)
|
if (StarShipPtr->crew_level > 0)
|
||||||
{
|
{
|
||||||
@@ -727,8 +791,7 @@ DMS_DismissEscortShipCrew (MENU_STATE *pMS, SHIP_FRAGMENT *StarShipPtr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// With the last crew member, the ship
|
// With the last crew member, the ship will be scrapped.
|
||||||
// will be scrapped.
|
|
||||||
// Give RU for the ship.
|
// Give RU for the ship.
|
||||||
DeltaSISGauges (0, 0, (COUNT)ShipCost[StarShipPtr->race_id]);
|
DeltaSISGauges (0, 0, (COUNT)ShipCost[StarShipPtr->race_id]);
|
||||||
}
|
}
|
||||||
@@ -740,7 +803,8 @@ DMS_DismissEscortShipCrew (MENU_STATE *pMS, SHIP_FRAGMENT *StarShipPtr)
|
|||||||
PlayMenuSound (MENU_SOUND_FAILURE);
|
PlayMenuSound (MENU_SOUND_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowShipCrew (StarShipPtr, &pMS->flash_rect0);
|
DMS_GetEscortShipRect (&r, StarShipPtr->index);
|
||||||
|
ShowShipCrew (StarShipPtr, &r);
|
||||||
|
|
||||||
return crew_delta;
|
return crew_delta;
|
||||||
}
|
}
|
||||||
@@ -779,13 +843,7 @@ DMS_ModifyCrew (MENU_STATE *pMS, HSHIPFRAG hStarShip, SBYTE dy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (crew_delta != 0)
|
if (crew_delta != 0)
|
||||||
{
|
DMS_FlashFlagShipCrewCount ();
|
||||||
RECT r;
|
|
||||||
SetContext (StatusContext);
|
|
||||||
GetGaugeRect (&r, TRUE);
|
|
||||||
SetFlashRect (&r);
|
|
||||||
SetContext (SpaceContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -793,26 +851,16 @@ DMS_ModifyCrew (MENU_STATE *pMS, HSHIPFRAG hStarShip, SBYTE dy)
|
|||||||
if (dy < 0)
|
if (dy < 0)
|
||||||
{
|
{
|
||||||
// Add crew for an escort ship.
|
// Add crew for an escort ship.
|
||||||
crew_delta = DMS_HireEscortShipCrew (pMS, StarShipPtr);
|
crew_delta = DMS_HireEscortShipCrew (StarShipPtr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Dismiss crew from an escort ship.
|
// Dismiss crew from an escort ship.
|
||||||
crew_delta = DMS_DismissEscortShipCrew (pMS, StarShipPtr);
|
crew_delta = DMS_DismissEscortShipCrew (StarShipPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crew_delta != 0)
|
if (crew_delta != 0)
|
||||||
{
|
DMS_FlashEscortShipCrewCount (StarShipPtr->index);
|
||||||
RECT r;
|
|
||||||
r.corner.x = pMS->flash_rect0.corner.x;
|
|
||||||
r.corner.y = pMS->flash_rect0.corner.y
|
|
||||||
+ pMS->flash_rect0.extent.height - 6;
|
|
||||||
r.extent.width = SHIP_WIN_WIDTH;
|
|
||||||
r.extent.height = 5;
|
|
||||||
|
|
||||||
SetContext (SpaceContext);
|
|
||||||
SetFlashRect (&r);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crew_delta == 0)
|
if (crew_delta == 0)
|
||||||
@@ -843,7 +891,6 @@ DMS_TryAddEscortShip (MENU_STATE *pMS)
|
|||||||
if (GLOBAL_SIS (ResUnits) >= (DWORD)ShipCost[Index]
|
if (GLOBAL_SIS (ResUnits) >= (DWORD)ShipCost[Index]
|
||||||
&& CloneShipFragment (Index, &GLOBAL (built_ship_q), 1))
|
&& CloneShipFragment (Index, &GLOBAL (built_ship_q), 1))
|
||||||
{
|
{
|
||||||
RECT r;
|
|
||||||
ShowCombatShip (pMS, pMS->CurState, NULL);
|
ShowCombatShip (pMS, pMS->CurState, NULL);
|
||||||
//Reset flash rectangle
|
//Reset flash rectangle
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
@@ -854,13 +901,8 @@ DMS_TryAddEscortShip (MENU_STATE *pMS)
|
|||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA,
|
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA,
|
||||||
-((int)ShipCost[Index]));
|
-((int)ShipCost[Index]));
|
||||||
r.corner.x = pMS->flash_rect0.corner.x;
|
|
||||||
r.corner.y = pMS->flash_rect0.corner.y
|
DMS_FlashEscortShipCrewCount (pMS->CurState);
|
||||||
+ pMS->flash_rect0.extent.height - 6;
|
|
||||||
r.extent.width = SHIP_WIN_WIDTH;
|
|
||||||
r.extent.height = 5;
|
|
||||||
SetContext (SpaceContext);
|
|
||||||
SetFlashRect (&r);
|
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -935,15 +977,16 @@ DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN select, BOOLEAN cancel,
|
|||||||
static void
|
static void
|
||||||
DMS_ScrapEscortShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
|
DMS_ScrapEscortShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
|
||||||
{
|
{
|
||||||
RECT r;
|
|
||||||
SHIP_FRAGMENT *StarShipPtr =
|
SHIP_FRAGMENT *StarShipPtr =
|
||||||
LockShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
LockShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
||||||
|
BYTE slotNr;
|
||||||
|
|
||||||
SetFlashRect (NULL);
|
SetFlashRect (NULL);
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
ShowCombatShip (pMS, pMS->CurState, StarShipPtr);
|
ShowCombatShip (pMS, pMS->CurState, StarShipPtr);
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
|
|
||||||
|
slotNr = StarShipPtr->index;
|
||||||
UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
||||||
|
|
||||||
RemoveQueue (&GLOBAL (built_ship_q), hStarShip);
|
RemoveQueue (&GLOBAL (built_ship_q), hStarShip);
|
||||||
@@ -951,13 +994,8 @@ DMS_ScrapEscortShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
|
|||||||
// refresh SIS display
|
// refresh SIS display
|
||||||
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
|
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
|
||||||
|
|
||||||
r.corner.x = pMS->flash_rect0.corner.x;
|
|
||||||
r.corner.y = pMS->flash_rect0.corner.y;
|
|
||||||
r.extent.width = SHIP_WIN_WIDTH;
|
|
||||||
r.extent.height = SHIP_WIN_HEIGHT;
|
|
||||||
|
|
||||||
SetContext (SpaceContext);
|
SetContext (SpaceContext);
|
||||||
SetFlashRect (&r);
|
DMS_FlashEscortShip (slotNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function for DoModifyShips(), called when the player presses
|
// Helper function for DoModifyShips(), called when the player presses
|
||||||
@@ -1070,7 +1108,6 @@ DoModifyShips (MENU_STATE *pMS)
|
|||||||
|| ((pMS->delta_item & MODIFY_CREW_FLAG) && (dx || dy)))
|
|| ((pMS->delta_item & MODIFY_CREW_FLAG) && (dx || dy)))
|
||||||
{
|
{
|
||||||
HSHIPFRAG hStarShip;
|
HSHIPFRAG hStarShip;
|
||||||
RECT r;
|
|
||||||
|
|
||||||
hStarShip = GetEscortByStarShipIndex (pMS->CurState);
|
hStarShip = GetEscortByStarShipIndex (pMS->CurState);
|
||||||
|
|
||||||
@@ -1150,28 +1187,18 @@ DoModifyShips (MENU_STATE *pMS)
|
|||||||
|
|
||||||
if (hStarShip == 0)
|
if (hStarShip == 0)
|
||||||
{
|
{
|
||||||
// Enter crew editing mode for an escort ship.
|
// Enter crew editing mode for the flagship.
|
||||||
SetContext (StatusContext);
|
DMS_FlashFlagShipCrewCount ();
|
||||||
GetGaugeRect (&r, TRUE);
|
|
||||||
SetFlashRect (&r);
|
|
||||||
SetContext (SpaceContext);
|
|
||||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
|
|
||||||
MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Enter crew editing mode for the flagship.
|
// Enter crew editing mode for an escort ship.
|
||||||
r.corner.x = pMS->flash_rect0.corner.x;
|
DMS_FlashEscortShipCrewCount (pMS->CurState);
|
||||||
r.corner.y = pMS->flash_rect0.corner.y
|
|
||||||
+ pMS->flash_rect0.extent.height - 6;
|
|
||||||
r.extent.width = SHIP_WIN_WIDTH;
|
|
||||||
r.extent.height = 5;
|
|
||||||
|
|
||||||
SetContext (SpaceContext);
|
|
||||||
SetFlashRect (&r);
|
|
||||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
|
|
||||||
MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)
|
else if (pMS->delta_item & MODIFY_CREW_FLAG)
|
||||||
{
|
{
|
||||||
@@ -1202,24 +1229,13 @@ ChangeFlashRect:
|
|||||||
if (HINIBBLE (pMS->CurState))
|
if (HINIBBLE (pMS->CurState))
|
||||||
{
|
{
|
||||||
// Flash the flag ship.
|
// Flash the flag ship.
|
||||||
pMS->flash_rect0.corner.x = 0;
|
DMS_FlashFlagShip ();
|
||||||
pMS->flash_rect0.corner.y = 0;
|
|
||||||
pMS->flash_rect0.extent.width = SIS_SCREEN_WIDTH;
|
|
||||||
pMS->flash_rect0.extent.height = 61;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Flash the current escort ship slot.
|
// Flash the current escort ship slot.
|
||||||
BYTE row = pMS->CurState / HANGAR_SHIPS_ROW;
|
DMS_FlashEscortShip (pMS->CurState);
|
||||||
BYTE col = pMS->CurState % HANGAR_SHIPS_ROW;
|
|
||||||
|
|
||||||
pMS->flash_rect0.corner.x = hangar_x_coords[col];
|
|
||||||
pMS->flash_rect0.corner.y =
|
|
||||||
HANGAR_Y + (HANGAR_DY * row);
|
|
||||||
pMS->flash_rect0.extent.width = SHIP_WIN_WIDTH;
|
|
||||||
pMS->flash_rect0.extent.height = SHIP_WIN_HEIGHT;
|
|
||||||
}
|
}
|
||||||
SetFlashRect (&pMS->flash_rect0);
|
|
||||||
}
|
}
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user