Reverted melee ship selection box drawing; free_ship() is back; fixes #11, #29 and #30

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@683 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2003-02-05 08:57:26 +00:00
parent 04d9ae174d
commit 583a0c1202
3 changed files with 203 additions and 172 deletions
+130 -57
View File
@@ -18,6 +18,7 @@
#include <ctype.h>
#include "starcon.h"
#include "libs/graphics/drawable.h"
#include "melee.h"
#include "options.h"
#include "file.h"
@@ -58,6 +59,10 @@ enum
#define MELEE_BOX_HEIGHT 34
#define MELEE_BOX_SPACE 1
#define NAME_AREA_HEIGHT 7
#define MELEE_WIDTH 133
#define MELEE_HEIGHT (48 + NAME_AREA_HEIGHT)
#define INFO_ORIGIN_X 3
#define INFO_WIDTH 58
#define TEAM_INFO_ORIGIN_Y 3
@@ -1433,13 +1438,34 @@ DoPickShip (INPUT_STATE InputState, PMELEE_STATE pMS)
static void
LoadMeleeInfo (PMELEE_STATE pMS)
{
PickMeleeFrame = CaptureDrawable (
STAMP s;
CONTEXT OldContext;
// reverting to original behavior
OldContext = SetContext (OffScreenContext);
DestroyDrawable (ReleaseDrawable (PickMeleeFrame));
PickMeleeFrame = CaptureDrawable (CreateDrawable (
WANT_PIXMAP, MELEE_WIDTH, MELEE_HEIGHT, 2
));
s.origin.x = s.origin.y = 0;
s.frame = CaptureDrawable (
LoadGraphic (MELEE_PICK_MASK_PMAP_ANIM)
);
SetContextFGFrame (PickMeleeFrame);
DrawStamp (&s);
s.frame = IncFrameIndex (s.frame);
SetContextFGFrame (IncFrameIndex (PickMeleeFrame));
DrawStamp (&s);
DestroyDrawable (ReleaseDrawable (s.frame));
MeleeFrame = CaptureDrawable (
LoadGraphic (MELEE_SCREEN_PMAP_ANIM)
);
SetContext (OldContext);
InitSpace ();
LoadTeamList (pMS, 0);
@@ -1462,8 +1488,103 @@ FreeMeleeInfo (PMELEE_STATE pMS)
DestroyDrawable (ReleaseDrawable (MeleeFrame));
MeleeFrame = 0;
DestroyDrawable (ReleaseDrawable (PickMeleeFrame));
PickMeleeFrame = 0;
}
static
BuildAndDrawShipList (PMELEE_STATE pMS)
{
COUNT i;
CONTEXT OldContext;
OldContext = SetContext (OffScreenContext);
for (i = 0; i < NUM_SIDES; ++i)
{
COUNT j, side;
RECT r;
TEXT t;
STAMP s;
UNICODE buf[10];
side = !i;
s.frame = SetAbsFrameIndex (PickMeleeFrame, side);
SetContextFGFrame (s.frame);
GetFrameRect (s.frame, &r);
t.baseline.x = r.extent.width >> 1;
t.baseline.y = r.extent.height
- NAME_AREA_HEIGHT + 4;
r.corner.x += 2;
r.corner.y += 2;
r.extent.width -= (2 * 2) + (ICON_WIDTH + 2) + 1;
r.extent.height -= (2 * 2) + NAME_AREA_HEIGHT;
SetContextForeGroundColor (PICK_BG_COLOR);
DrawFilledRectangle (&r);
r.corner.x += 2;
r.extent.width += (ICON_WIDTH + 2) - (2 * 2);
r.corner.y += r.extent.height;
r.extent.height = NAME_AREA_HEIGHT;
DrawFilledRectangle (&r);
t.align = ALIGN_CENTER;
t.pStr = pMS->TeamImage[i].TeamName;
t.CharCount = (COUNT)~0;
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (
MAKE_RGB15 (0xA, 0xA, 0x1F), 0x9));
font_DrawText (&t);
wsprintf (buf, "%d", pMS->star_bucks[i]);
t.baseline.x = 4;
t.baseline.y = 7;
t.align = ALIGN_LEFT;
t.pStr = buf;
t.CharCount = (COUNT)~0;
SetContextForeGroundColor (BUILD_COLOR (
MAKE_RGB15 (0x4, 0x5, 0x1F), 0x4B));
font_DrawText (&t);
for (j = 0; j < NUM_MELEE_ROWS; ++j)
{
COUNT k;
for (k = 0; k < NUM_MELEE_COLUMNS; ++k)
{
BYTE StarShip;
if ((StarShip = pMS->TeamImage[i].ShipList[j][k]) != (BYTE)~0)
{
BYTE ship_cost;
HSTARSHIP hStarShip, hBuiltShip;
STARSHIPPTR StarShipPtr, BuiltShipPtr;
hStarShip = GetStarShipFromIndex (&master_q, StarShip);
StarShipPtr = LockStarShip (&master_q, hStarShip);
hBuiltShip = Build (&race_q[side],
StarShipPtr->RaceResIndex,
1 << side,
NameCaptain (&race_q[side], StarShipPtr));
s.origin.x = 4 + ((ICON_WIDTH + 2) * k);
s.origin.y = 10 + ((ICON_HEIGHT + 2) * j);
s.frame = StarShipPtr->RaceDescPtr->ship_info.icons;
DrawStamp (&s);
ship_cost = StarShipPtr->RaceDescPtr->
ship_info.ship_cost;
UnlockStarShip (&master_q, hStarShip);
BuiltShipPtr = LockStarShip (&race_q[side], hBuiltShip);
BuiltShipPtr->ShipFacing = (j * NUM_MELEE_COLUMNS) + k;
BuiltShipPtr->special_counter = ship_cost;
BuiltShipPtr->captains_name_index =
StarShipCaptain (BuiltShipPtr);
BuiltShipPtr->RaceDescPtr = StarShipPtr->RaceDescPtr;
UnlockStarShip (&race_q[side], hBuiltShip);
}
}
}
}
SetContext (OldContext);
}
static BOOLEAN
@@ -1568,60 +1689,9 @@ DoMelee (INPUT_STATE InputState, PMELEE_STATE pMS)
}
do
{
COUNT i;
SetContext (OffScreenContext);
for (i = 0; i < NUM_SIDES; ++i)
{
COUNT j, side;
side = !i;
for (j = 0; j < NUM_MELEE_ROWS; ++j)
{
COUNT k;
for (k = 0; k < NUM_MELEE_COLUMNS; ++k)
{
BYTE StarShip;
if ((StarShip = pMS->TeamImage[i].ShipList[j][k]) != (BYTE)~0)
{
BYTE ship_cost;
HSTARSHIP hStarShip, hBuiltShip;
STARSHIPPTR StarShipPtr,
BuiltShipPtr;
hStarShip = GetStarShipFromIndex (&master_q, StarShip);
StarShipPtr = LockStarShip (
&master_q, hStarShip
);
hBuiltShip = Build (&race_q[side],
StarShipPtr->RaceResIndex,
1 << side,
NameCaptain (&race_q[side], StarShipPtr));
ship_cost = StarShipPtr->RaceDescPtr->
ship_info.ship_cost;
UnlockStarShip (
&master_q, hStarShip
);
BuiltShipPtr = LockStarShip (
&race_q[side], hBuiltShip
);
BuiltShipPtr->ShipFacing =
(j * NUM_MELEE_COLUMNS) + k;
BuiltShipPtr->special_counter = ship_cost;
BuiltShipPtr->captains_name_index =
StarShipCaptain (BuiltShipPtr);
BuiltShipPtr->RaceDescPtr =
StarShipPtr->RaceDescPtr;
UnlockStarShip (
&race_q[side], hBuiltShip
);
}
}
}
}
SetSemaphore (GraphicsSem);
BuildAndDrawShipList (pMS);
ClearSemaphore (GraphicsSem);
while (SoundPlaying ())
;
@@ -1858,6 +1928,9 @@ Melee (void)
DestroySound (ReleaseSound (GameSounds));
GameSounds = 0;
DestroyDrawable (ReleaseDrawable (PickMeleeFrame));
PickMeleeFrame = 0;
FlushInput ();
}
}
+72 -114
View File
@@ -24,117 +24,6 @@
#define PICK_Y_OFFS 24
#define PICK_SIDE_OFFS 100
#define NAME_AREA_HEIGHT 7
#define MELEE_WIDTH 133
#define MELEE_HEIGHT (48 + NAME_AREA_HEIGHT)
static void
DrawMeleeFrame (STARSHIPPTR LastStarShipPtr, COUNT which_player)
{
TEXT t;
UNICODE buf[10];
STAMP s;
RECT r;
GetFrameRect (PickMeleeFrame, &r);
r.corner.x = PICK_X_OFFS - 3;
r.corner.y = PICK_Y_OFFS - 9 + ((1 - which_player) * PICK_SIDE_OFFS);
s.origin = r.corner;
s.frame = PickMeleeFrame;
DrawStamp (&s);
t.baseline.x = r.corner.x + (r.extent.width >> 1);
t.baseline.y = r.corner.y + (r.extent.height - NAME_AREA_HEIGHT + 4);
r.corner.x += 2;
r.corner.y += 2;
r.extent.width -= (2 * 2) + (ICON_WIDTH + 2) + 1;
r.extent.height -= (2 * 2) + NAME_AREA_HEIGHT;
SetContextForeGroundColor (PICK_BG_COLOR);
DrawFilledRectangle (&r);
r.corner.x += 2;
r.extent.width += (ICON_WIDTH + 2) - (2 * 2);
r.corner.y += r.extent.height;
r.extent.height = NAME_AREA_HEIGHT;
DrawFilledRectangle (&r);
t.align = ALIGN_CENTER;
t.pStr = pMeleeState->TeamImage[1 - which_player].TeamName;
t.CharCount = (COUNT)~0;
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0x1F), 0x9));
font_DrawText (&t);
r.corner.x = PICK_X_OFFS - 3;
r.corner.y = PICK_Y_OFFS - 9 + ((1 - which_player) * PICK_SIDE_OFFS);
wsprintf (buf, "%d", pMeleeState->star_bucks[1 - which_player]);
t.baseline.x = r.corner.x + 4;
t.baseline.y = r.corner.y + 7;
t.align = ALIGN_LEFT;
t.pStr = buf;
t.CharCount = (COUNT)~0;
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x4, 0x5, 0x1F), 0x4B));
font_DrawText (&t);
if (LastStarShipPtr == 0 || LastStarShipPtr->special_counter == 0)
{
COUNT cur_bucks;
HSTARSHIP hBattleShip, hNextShip;
cur_bucks = 0;
for (hBattleShip = GetHeadLink (&race_q[which_player]);
hBattleShip != 0; hBattleShip = hNextShip)
{
int col;
STARSHIPPTR StarShipPtr;
StarShipPtr = LockStarShip (&race_q[which_player], hBattleShip);
if (StarShipPtr == LastStarShipPtr)
LastStarShipPtr->RaceResIndex = 0;
col = StarShipPtr->ShipFacing;
s.origin.x = r.corner.x + 4
+ ((ICON_WIDTH + 2) * (col % NUM_MELEE_COLS_ORIG));
s.origin.y = r.corner.y + 10
+ ((ICON_HEIGHT + 2) * (col / NUM_MELEE_COLS_ORIG));
s.frame = StarShipPtr->RaceDescPtr->ship_info.icons;
DrawStamp (&s);
if (StarShipPtr->RaceResIndex)
cur_bucks += StarShipPtr->special_counter;
else
{
extern FRAME status;
// Draw the X through destroyed ships
--s.origin.x;
--s.origin.y;
s.frame = SetAbsFrameIndex (status, 3);
DrawStamp (&s);
}
hNextShip = _GetSuccLink (StarShipPtr);
UnlockStarShip (&race_q[which_player], hBattleShip);
}
r.extent.width -= 4;
t.baseline.x = r.corner.x + r.extent.width;
t.baseline.y = r.corner.y + 7;
r.corner.x += r.extent.width - (6 * 3);
r.corner.y += 2;
r.extent.width = (6 * 3);
r.extent.height = 7 - 2;
SetContextForeGroundColor (PICK_BG_COLOR);
DrawFilledRectangle (&r);
wsprintf (buf, "%d", cur_bucks);
t.align = ALIGN_RIGHT;
t.pStr = buf;
t.CharCount = (COUNT)~0;
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C));
font_DrawText (&t);
}
}
HSTARSHIP
GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player)
@@ -145,22 +34,91 @@ GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player)
HSTARSHIP hBattleShip, hNextShip;
STARSHIPPTR StarShipPtr;
RECT flash_rect;
TEXT t;
UNICODE buf[10];
STAMP s;
CONTEXT OldContext;
if (!(GLOBAL (CurrentActivity) & IN_BATTLE))
return (0);
SetContext (SpaceContext);
s.frame = SetAbsFrameIndex (PickMeleeFrame, which_player);
DrawMeleeFrame (LastStarShipPtr, which_player);
OldContext = SetContext (OffScreenContext);
SetContextFGFrame (s.frame);
if (LastStarShipPtr == 0 || LastStarShipPtr->special_counter == 0)
{
COUNT cur_bucks;
cur_bucks = 0;
for (hBattleShip = GetHeadLink (&race_q[which_player]);
hBattleShip != 0; hBattleShip = hNextShip)
{
StarShipPtr = LockStarShip (&race_q[which_player], hBattleShip);
if (StarShipPtr == LastStarShipPtr)
{
extern FRAME status;
LastStarShipPtr->RaceResIndex = 0;
col = LastStarShipPtr->ShipFacing;
s.origin.x = 3
+ ((ICON_WIDTH + 2) * (col % NUM_MELEE_COLS_ORIG));
s.origin.y = 9
+ ((ICON_HEIGHT + 2) * (col / NUM_MELEE_COLS_ORIG));
s.frame = SetAbsFrameIndex (status, 3);
DrawStamp (&s);
s.frame = SetAbsFrameIndex (PickMeleeFrame, which_player);
}
else if (StarShipPtr->RaceResIndex)
{
cur_bucks += StarShipPtr->special_counter;
}
hNextShip = _GetSuccLink (StarShipPtr);
UnlockStarShip (&race_q[which_player], hBattleShip);
}
GetFrameRect (s.frame, &flash_rect);
flash_rect.extent.width -= 4;
t.baseline.x = flash_rect.extent.width;
flash_rect.corner.x = flash_rect.extent.width - (6 * 3);
flash_rect.corner.y = 2;
flash_rect.extent.width = (6 * 3);
flash_rect.extent.height = 7 - 2;
SetContextForeGroundColor (PICK_BG_COLOR);
DrawFilledRectangle (&flash_rect);
wsprintf (buf, "%d", cur_bucks);
t.baseline.y = 7;
t.align = ALIGN_RIGHT;
t.pStr = buf;
t.CharCount = (COUNT)~0;
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (
MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C));
font_DrawText (&t);
}
SetContext (SpaceContext);
s.origin.x = PICK_X_OFFS - 3;
s.origin.y = PICK_Y_OFFS - 9
+ ((1 - which_player) * PICK_SIDE_OFFS);
DrawStamp (&s);
if (LOBYTE (battle_counter) == 0 || HIBYTE (battle_counter) == 0)
{
DWORD TimeOut;
INPUT_STATE PressState, ButtonState;
DrawMeleeFrame (LastStarShipPtr, 1 - which_player);
s.origin.y = PICK_Y_OFFS - 9 + (which_player * PICK_SIDE_OFFS);
s.frame = SetAbsFrameIndex (PickMeleeFrame,
(COUNT) (1 - which_player));
DrawStamp (&s);
TimeOut = GetTimeCounter () + (ONE_SECOND * 4);
SetContext (OldContext);
ClearSemaphore (GraphicsSem);
PressState = AnyButtonPress (TRUE);
+1 -1
View File
@@ -140,7 +140,7 @@ new_ship (PELEMENT DeadShipPtr)
SetElementStarShip (DeadShipPtr, 0);
RestartMusic = OpponentAlive (DeadStarShipPtr);
// free_ship (DeadStarShipPtr, TRUE);
free_ship (DeadStarShipPtr, TRUE);
UnbatchGraphics ();
if (GetNextStarShip (DeadStarShipPtr,
WHICH_SIDE (DeadShipPtr->turn_wait)) && RestartMusic)