Add/Remove fuel 10 at a time with PageUp/PageDown, from from Scott A. Colcord, Nic.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3752 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
Changes towards version 0.8:
|
Changes towards version 0.8:
|
||||||
|
- PageUp/PageDown now add/remove 10 fuel in the shipyard, from
|
||||||
|
Scott A. Colcord, Nic
|
||||||
- Annihigate flash thread - SvdB
|
- Annihigate flash thread - SvdB
|
||||||
- Switch SetFlashRect() to the new flash code - SvdB
|
- Switch SetFlashRect() to the new flash code - SvdB
|
||||||
- Add C++ support to the build system, from Scott A. Colcord
|
- Add C++ support to the build system, from Scott A. Colcord
|
||||||
|
|||||||
+81
-92
@@ -85,7 +85,8 @@ DrawModuleStrings (MENU_STATE *pMS, BYTE NewModule)
|
|||||||
t.align = ALIGN_RIGHT;
|
t.align = ALIGN_RIGHT;
|
||||||
t.CharCount = (COUNT)~0;
|
t.CharCount = (COUNT)~0;
|
||||||
t.pStr = buf;
|
t.pStr = buf;
|
||||||
sprintf (buf, "%u", GLOBAL (ModuleCost[NewModule]) * MODULE_COST_SCALE);
|
sprintf (buf, "%u",
|
||||||
|
GLOBAL (ModuleCost[NewModule]) * MODULE_COST_SCALE);
|
||||||
SetContextFont (TinyFont);
|
SetContextFont (TinyFont);
|
||||||
SetContextForeGroundColor (
|
SetContextForeGroundColor (
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02));
|
BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02));
|
||||||
@@ -98,43 +99,38 @@ DrawModuleStrings (MENU_STATE *pMS, BYTE NewModule)
|
|||||||
static void
|
static void
|
||||||
RedistributeFuel (void)
|
RedistributeFuel (void)
|
||||||
{
|
{
|
||||||
COUNT m;
|
const DWORD FuelVolume = GLOBAL_SIS (FuelOnBoard);
|
||||||
DWORD FuelVolume;
|
const CONTEXT OldContext = SetContext (SpaceContext);
|
||||||
RECT r;
|
RECT r;
|
||||||
|
|
||||||
FuelVolume = GLOBAL_SIS (FuelOnBoard);
|
|
||||||
if (FuelVolume <= FUEL_RESERVE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
GLOBAL_SIS (FuelOnBoard) = 0;
|
|
||||||
m = FUEL_VOLUME_PER_ROW;
|
|
||||||
|
|
||||||
r.extent.width = 3;
|
|
||||||
r.extent.height = 1;
|
r.extent.height = 1;
|
||||||
while (FuelVolume -= m)
|
|
||||||
{
|
|
||||||
GLOBAL_SIS (FuelOnBoard) += FUEL_VOLUME_PER_ROW;
|
|
||||||
GetFTankCapacity (&r.corner);
|
|
||||||
DrawPoint (&r.corner);
|
|
||||||
r.corner.x += r.extent.width + 1;
|
|
||||||
DrawPoint (&r.corner);
|
|
||||||
r.corner.x -= r.extent.width;
|
|
||||||
SetContextForeGroundColor (SetContextBackGroundColor (BLACK_COLOR));
|
|
||||||
DrawFilledRectangle (&r);
|
|
||||||
if (FuelVolume < FUEL_VOLUME_PER_ROW)
|
|
||||||
m = (COUNT)FuelVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
FuelVolume = GLOBAL_SIS (FuelOnBoard) + m;
|
// Loop through all the rows to draw
|
||||||
|
BatchGraphics ();
|
||||||
r.extent.width = 5;
|
for (GLOBAL_SIS (FuelOnBoard) = FUEL_RESERVE;
|
||||||
while ((GLOBAL_SIS (FuelOnBoard) += FUEL_VOLUME_PER_ROW) <
|
GLOBAL_SIS (FuelOnBoard) < GetFTankCapacity (&r.corner);
|
||||||
GetFTankCapacity (&r.corner))
|
GLOBAL_SIS (FuelOnBoard) += FUEL_VOLUME_PER_ROW)
|
||||||
{
|
{
|
||||||
SetContextForeGroundColor (
|
// If we're less than the fuel level, draw fuel.
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2E));
|
if (GLOBAL_SIS (FuelOnBoard) < FuelVolume)
|
||||||
|
{
|
||||||
|
r.extent.width = 3;
|
||||||
|
DrawPoint (&r.corner);
|
||||||
|
r.corner.x += r.extent.width + 1;
|
||||||
|
DrawPoint (&r.corner);
|
||||||
|
r.corner.x -= r.extent.width;
|
||||||
|
SetContextForeGroundColor (
|
||||||
|
SetContextBackGroundColor (BLACK_COLOR));
|
||||||
|
}
|
||||||
|
else // Otherwise, draw an empty bar.
|
||||||
|
{
|
||||||
|
r.extent.width = 5;
|
||||||
|
SetContextForeGroundColor (
|
||||||
|
BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2E));
|
||||||
|
}
|
||||||
DrawFilledRectangle (&r);
|
DrawFilledRectangle (&r);
|
||||||
}
|
}
|
||||||
|
UnbatchGraphics ();
|
||||||
|
SetContext (OldContext);
|
||||||
|
|
||||||
GLOBAL_SIS (FuelOnBoard) = FuelVolume;
|
GLOBAL_SIS (FuelOnBoard) = FuelVolume;
|
||||||
}
|
}
|
||||||
@@ -348,7 +344,8 @@ DoInstallModule (MENU_STATE *pMS)
|
|||||||
GLOBAL (ModuleCost[old_slot_piece])
|
GLOBAL (ModuleCost[old_slot_piece])
|
||||||
* MODULE_COST_SCALE);
|
* MODULE_COST_SCALE);
|
||||||
|
|
||||||
if (pMS->CurState == PLANET_LANDER || pMS->CurState == EMPTY_SLOT + 3)
|
if (pMS->CurState == PLANET_LANDER ||
|
||||||
|
pMS->CurState == EMPTY_SLOT + 3)
|
||||||
DisplayLanders (pMS);
|
DisplayLanders (pMS);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -402,7 +399,8 @@ DoInstallModule (MENU_STATE *pMS)
|
|||||||
NewItem = NewState < EMPTY_SLOT ? pMS->CurState : pMS->delta_item;
|
NewItem = NewState < EMPTY_SLOT ? pMS->CurState : pMS->delta_item;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (NewState >= EMPTY_SLOT && (PulsedInputState.menu[KEY_MENU_UP] || PulsedInputState.menu[KEY_MENU_DOWN]))
|
if (NewState >= EMPTY_SLOT && (PulsedInputState.menu[KEY_MENU_UP]
|
||||||
|
|| PulsedInputState.menu[KEY_MENU_DOWN]))
|
||||||
{
|
{
|
||||||
if (PulsedInputState.menu[KEY_MENU_UP])
|
if (PulsedInputState.menu[KEY_MENU_UP])
|
||||||
{
|
{
|
||||||
@@ -551,69 +549,58 @@ InitFlash:
|
|||||||
static void
|
static void
|
||||||
ChangeFuelQuantity (void)
|
ChangeFuelQuantity (void)
|
||||||
{
|
{
|
||||||
RECT r;
|
int incr = 0; // Fuel increment in fuel points (not units).
|
||||||
|
|
||||||
r.extent.height = 1;
|
if (PulsedInputState.menu[KEY_MENU_UP])
|
||||||
|
incr = FUEL_TANK_SCALE; // +1 Unit
|
||||||
if (PulsedInputState.menu[KEY_MENU_UP])
|
|
||||||
{
|
|
||||||
LockMutex (GraphicsLock);
|
|
||||||
SetContext (SpaceContext);
|
|
||||||
if (GetFTankCapacity (&r.corner) > GLOBAL_SIS (FuelOnBoard)
|
|
||||||
&& GLOBAL_SIS (ResUnits) >= (DWORD)GLOBAL (FuelCost))
|
|
||||||
{
|
|
||||||
if (GLOBAL_SIS (FuelOnBoard) >= FUEL_RESERVE)
|
|
||||||
{
|
|
||||||
r.extent.width = 3;
|
|
||||||
DrawPoint (&r.corner);
|
|
||||||
r.corner.x += r.extent.width + 1;
|
|
||||||
DrawPoint (&r.corner);
|
|
||||||
r.corner.x -= r.extent.width;
|
|
||||||
SetContextForeGroundColor (
|
|
||||||
SetContextBackGroundColor (BLACK_COLOR));
|
|
||||||
DrawFilledRectangle (&r);
|
|
||||||
}
|
|
||||||
PreUpdateFlashRect ();
|
|
||||||
DeltaSISGauges (0, FUEL_TANK_SCALE, -GLOBAL (FuelCost));
|
|
||||||
PostUpdateFlashRect ();
|
|
||||||
SetContext (StatusContext);
|
|
||||||
GetGaugeRect (&r, FALSE);
|
|
||||||
SetFlashRect (&r);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // no more room for fuel or not enough RUs
|
|
||||||
PlayMenuSound (MENU_SOUND_FAILURE);
|
|
||||||
}
|
|
||||||
UnlockMutex (GraphicsLock);
|
|
||||||
}
|
|
||||||
else if (PulsedInputState.menu[KEY_MENU_DOWN])
|
else if (PulsedInputState.menu[KEY_MENU_DOWN])
|
||||||
|
incr = -FUEL_TANK_SCALE; // -1 Unit
|
||||||
|
else if (PulsedInputState.menu[KEY_MENU_PAGE_UP])
|
||||||
|
incr = FUEL_VOLUME_PER_ROW; // +1 Bar
|
||||||
|
else if (PulsedInputState.menu[KEY_MENU_PAGE_DOWN])
|
||||||
|
incr = -FUEL_VOLUME_PER_ROW; // -1 Bar
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Clamp incr to what we can afford/hold/have.
|
||||||
{
|
{
|
||||||
LockMutex (GraphicsLock);
|
const int maxFit = GetFuelTankCapacity () - GLOBAL_SIS (FuelOnBoard);
|
||||||
SetContext (SpaceContext);
|
const int maxAfford = GLOBAL_SIS (ResUnits) / GLOBAL (FuelCost);
|
||||||
if (GLOBAL_SIS (FuelOnBoard))
|
const int minFit = -GLOBAL_SIS (FuelOnBoard);
|
||||||
{
|
|
||||||
PreUpdateFlashRect ();
|
if (incr > maxFit)
|
||||||
DeltaSISGauges (0, -FUEL_TANK_SCALE, GLOBAL (FuelCost));
|
incr = maxFit; // All we can hold.
|
||||||
PostUpdateFlashRect ();
|
|
||||||
if (GLOBAL_SIS (FuelOnBoard) % FUEL_VOLUME_PER_ROW == 0 &&
|
if (incr > maxAfford * FUEL_TANK_SCALE)
|
||||||
GLOBAL_SIS (FuelOnBoard) >= FUEL_RESERVE)
|
incr = maxAfford * FUEL_TANK_SCALE; // All we can afford.
|
||||||
{
|
|
||||||
GetFTankCapacity (&r.corner);
|
if (incr < minFit)
|
||||||
SetContextForeGroundColor (
|
incr = minFit; // All we have.
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2E));
|
}
|
||||||
r.extent.width = 5;
|
|
||||||
DrawFilledRectangle (&r);
|
LockMutex (GraphicsLock);
|
||||||
}
|
if (!incr)
|
||||||
}
|
{
|
||||||
else
|
// No more room, not enough RUs, or no fuel left to drain.
|
||||||
{ // no fuel left to drain
|
PlayMenuSound (MENU_SOUND_FAILURE);
|
||||||
PlayMenuSound (MENU_SOUND_FAILURE);
|
}
|
||||||
}
|
else
|
||||||
SetContext (StatusContext);
|
{
|
||||||
|
const int cost = (incr / FUEL_TANK_SCALE) * GLOBAL (FuelCost);
|
||||||
|
PreUpdateFlashRect ();
|
||||||
|
DeltaSISGauges (0, incr, -cost);
|
||||||
|
PostUpdateFlashRect ();
|
||||||
|
RedistributeFuel ();
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // Make fuel gauge flash.
|
||||||
|
RECT r;
|
||||||
|
CONTEXT oldContext = SetContext (StatusContext);
|
||||||
GetGaugeRect (&r, FALSE);
|
GetGaugeRect (&r, FALSE);
|
||||||
SetFlashRect (&r);
|
SetFlashRect (&r);
|
||||||
UnlockMutex (GraphicsLock);
|
SetContext (oldContext);
|
||||||
}
|
}
|
||||||
|
UnlockMutex (GraphicsLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -810,7 +797,9 @@ ExitOutfit:
|
|||||||
switch (pMS->CurState)
|
switch (pMS->CurState)
|
||||||
{
|
{
|
||||||
case OUTFIT_DOFUEL:
|
case OUTFIT_DOFUEL:
|
||||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
|
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN |
|
||||||
|
MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN,
|
||||||
|
MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
|
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
|
||||||
|
|||||||
Reference in New Issue
Block a user