-Updated menu system to support multiple hierarchies.

- fixed the PCmenu hierarchy for The Main Starmap, Manifest, and Scan menus
  - most menu functions now reside in menu.c (new file) instead of sis.c


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@551 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
ghaushe
2003-01-13 05:13:44 +00:00
parent 654b62a865
commit 982ae7ec88
13 changed files with 865 additions and 659 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.2: Changes towards version 0.2:
- Added support for multiple menu hierarchies, and a few PC hiers. -PBlue
- Fixed a potential semaphore race when suspending clock -PhracturedBlue - Fixed a potential semaphore race when suspending clock -PhracturedBlue
- Function name conflict fixes for Mac OSX -by peterb - Function name conflict fixes for Mac OSX -by peterb
- Minor fixes for pc-fonts (Outfit screen, gradient color swap) -by Nic - Minor fixes for pc-fonts (Outfit screen, gradient color swap) -by Nic
+2 -1
View File
@@ -89,7 +89,8 @@ Implementation bugs (low priority):
to disappear sometimes. The scaling should be made trilinear instead of to disappear sometimes. The scaling should be made trilinear instead of
nearest neighbor. nearest neighbor.
- PC Menu still has some issues - PC Menu still has some issues
- Still using 3DO menu hierarchy, so menu text isn't identical to PC - Support for PC hierarchies is now availiable, but only the main 'navigate'
and 'scan' menus have been converted. Lots more to do
-PC Font issues: -PC Font issues:
- Lander font isn't correct (for PC or 3DO) - Lander font isn't correct (for PC or 3DO)
- The PC version has text about the ship in the Outfit screen (Velocity etc) - The PC version has text about the ship in the Outfit screen (Velocity etc)
+4
View File
@@ -3075,6 +3075,10 @@ SOURCE=..\sc2code\melee.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\sc2code\menu.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\misc.c SOURCE=..\sc2code\misc.c
# End Source File # End Source File
# Begin Source File # Begin Source File
+1 -1
View File
@@ -4,7 +4,7 @@ uqm_CFILES="battle.c border.c build.c cleanup.c clock.c collide.c comm.c
dummy.c encount.c fmv.c galaxy.c gameinp.c gameopt.c dummy.c encount.c fmv.c galaxy.c gameinp.c gameopt.c
gendef.c getchar.c globdata.c gravity.c gravwell.c grpinfo.c gendef.c getchar.c globdata.c gravity.c gravwell.c grpinfo.c
hyper.c init.c intel.c intro.c ipdisp.c load.c loadship.c hyper.c init.c intel.c intro.c ipdisp.c load.c loadship.c
master.c melee.c misc.c oscill.c outfit.c pickmele.c master.c melee.c menu.c misc.c oscill.c outfit.c pickmele.c
pickship.c plandata.c process.c restart.c save.c settings.c pickship.c plandata.c process.c restart.c save.c settings.c
setup.c ship.c shipstat.c shipyard.c sis.c starbase.c setup.c ship.c shipstat.c shipyard.c sis.c starbase.c
starcon.c starmap.c state.c status.c tactrans.c starcon.c starmap.c state.c status.c tactrans.c
+3 -26
View File
@@ -26,7 +26,6 @@ DoSelectAction (INPUT_STATE InputState, PMENU_STATE pMS)
pMS->CurState = ATTACK + 1; pMS->CurState = ATTACK + 1;
return (FALSE); return (FALSE);
} }
if (!pMS->Initialized) if (!pMS->Initialized)
{ {
pMS->Initialized = TRUE; pMS->Initialized = TRUE;
@@ -51,33 +50,11 @@ DoSelectAction (INPUT_STATE InputState, PMENU_STATE pMS)
ClearSemaphore (GraphicsSem); ClearSemaphore (GraphicsSem);
} }
return ((BOOLEAN)pMS->Initialized); return ((BOOLEAN)pMS->Initialized);
default:
printf ("Unknown option: %d\n", pMS->CurState);
} }
} }
else DoMenuChooser (InputState, pMS, PM_CONVERSE);
{
BYTE NewState;
NewState = pMS->CurState;
if (GetInputXComponent (InputState) < 0
|| GetInputYComponent (InputState) < 0)
{
if (NewState-- == HAIL)
NewState = ATTACK + 1;
}
else if (GetInputXComponent (InputState) > 0
|| GetInputYComponent (InputState) > 0)
{
if (NewState++ == ATTACK + 1)
NewState = HAIL;
}
if (NewState != pMS->CurState)
{
DrawMenuStateStrings (PM_CONVERSE, NewState);
pMS->CurState = NewState;
}
}
return (TRUE); return (TRUE);
} }
+2 -76
View File
@@ -511,60 +511,8 @@ DoSettings (INPUT_STATE InputState, PMENU_STATE pMS)
FeedbackSetting (pMS->CurState); FeedbackSetting (pMS->CurState);
} }
else else if (DoMenuChooser (InputState, pMS, PM_SOUND_ON))
{
BYTE NewState;
NewState = pMS->CurState;
if (GetInputXComponent (InputState) < 0
|| GetInputYComponent (InputState) < 0)
{
do
{
if (NewState-- == SOUND_ON_SETTING)
NewState = EXIT_MENU_SETTING;
} while ((NewState == SOUND_ON_SETTING
&& (GLOBAL (glob_flags) & SOUND_DISABLED))
|| (NewState == SOUND_OFF_SETTING
&& !(GLOBAL (glob_flags) & SOUND_DISABLED))
|| (NewState == MUSIC_ON_SETTING
&& (GLOBAL (glob_flags) & MUSIC_DISABLED))
|| (NewState == MUSIC_OFF_SETTING
&& !(GLOBAL (glob_flags) & MUSIC_DISABLED))
|| (NewState >= CYBORG_OFF_SETTING
&& NewState <= CYBORG_SUPER_SETTING
&& NewState != cur_speed + CYBORG_OFF_SETTING)
);
}
else if (GetInputXComponent (InputState) > 0
|| GetInputYComponent (InputState) > 0)
{
do
{
if (NewState++ == EXIT_MENU_SETTING)
NewState = SOUND_ON_SETTING;
} while ((NewState == SOUND_ON_SETTING
&& (GLOBAL (glob_flags) & SOUND_DISABLED))
|| (NewState == SOUND_OFF_SETTING
&& !(GLOBAL (glob_flags) & SOUND_DISABLED))
|| (NewState == MUSIC_ON_SETTING
&& (GLOBAL (glob_flags) & MUSIC_DISABLED))
|| (NewState == MUSIC_OFF_SETTING
&& !(GLOBAL (glob_flags) & MUSIC_DISABLED))
|| (NewState >= CYBORG_OFF_SETTING
&& NewState <= CYBORG_SUPER_SETTING
&& NewState != cur_speed + CYBORG_OFF_SETTING)
);
}
if (NewState != pMS->CurState)
{
DrawMenuStateStrings (PM_SOUND_ON, NewState);
pMS->CurState = NewState;
FeedbackSetting (pMS->CurState); FeedbackSetting (pMS->CurState);
}
}
return (TRUE); return (TRUE);
} }
@@ -1293,29 +1241,7 @@ DoGameOptions
} }
} }
else else
{ DoMenuChooser (InputState, pMS, PM_SAVE_GAME);
BYTE NewState;
NewState = pMS->CurState;
if (GetInputXComponent (InputState) < 0
|| GetInputYComponent (InputState) < 0)
{
if (NewState-- == SAVE_GAME)
NewState = SETTINGS + 1;
}
else if (GetInputXComponent (InputState) > 0
|| GetInputYComponent (InputState) > 0)
{
if (NewState++ == SETTINGS + 1)
NewState = SAVE_GAME;
}
if (NewState != pMS->CurState)
{
DrawMenuStateStrings (PM_SAVE_GAME, NewState);
pMS->CurState = NewState;
}
}
return (TRUE); return (TRUE);
} }
+617
View File
@@ -0,0 +1,617 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "starcon.h"
#include "commglue.h"
#include "libs/graphics/gfx_common.h"
#include "libs/tasklib.h"
#include "options.h"
extern Task flash_task;
extern RECT flash_rect;
/* Draw the blue background for PC Menu Text */
static void
DrawPCMenuFrame (RECT *r)
{
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x0F, 0x0F, 0x0F), 0x08));
DrawRectangle (r);
r->corner.x++;
r->corner.y++;
r->extent.height--;
r->extent.width--;
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x06, 0x06, 0x06), 0x08));
DrawRectangle (r);
r->extent.height--;
r->extent.width--;
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x15), 0x08));
DrawFilledRectangle (r);
}
#define ALT_MANIFEST 0x80
#define ALT_EXIT_MENU0 0x81
/* Define all menu text. There is 1 item for each PM_* enum*/
static char menu_string[][11] = {
"scan",
"starmap",
"devices",
"cargo",
"roster",
"game",
"navigate",
"mineral",
"energy",
"biological",
"exit menu",
"autoscan",
"dispatch",
"save game",
"load game",
"settings",
"exit menu",
"converse",
"attack!",
"game",
"fuel",
"module",
"game",
"exit menu",
"crew",
"game",
"exit menu",
"sound",
"music",
"cyborg",
"captain",
"flagship",
"exit menu",
"",
"",
"",
"",
"",
//PM_ALTSCAN
"scan",
"starmap",
"manifest",
"game",
"navigate",
//PM_ALTERNATE_2
"cargo",
"devices",
"roster",
"exit menu",
//PM_ALTERNATE3 replaces PM_MIN_SCAN
"mineral",
"energy",
"biological",
"autoscan",
"dispatch",
"exit menu"
};
/* Actually display the menu text */
static void
DrawPCMenu (BYTE beg_index, BYTE end_index, BYTE NewState, BYTE hilite, RECT *r)
{
#define PC_MENU_HEIGHT 8
BYTE pos;
COUNT i;
int num_items;
FONT OldFont;
TEXT t;
UNICODE buf[40];
pos = beg_index + NewState;
num_items = 1 + end_index - beg_index;
r->corner.x -= 1;
r->extent.width += 1;
DrawFilledRectangle (r);
if (num_items * PC_MENU_HEIGHT > r->extent.height)
fprintf (stderr, "Warning, no room for all menu items!\n");
else
r->corner.y += (r->extent.height - num_items * PC_MENU_HEIGHT) / 2;
r->extent.height = num_items * PC_MENU_HEIGHT + 4;
DrawPCMenuFrame (r);
OldFont = SetContextFont (StarConFont);
t.align = ALIGN_LEFT;
t.baseline.x = r->corner.x + 2;
t.baseline.y = r->corner.y + PC_MENU_HEIGHT -1;
t.pStr = buf;
t.CharCount = (COUNT)~0;
r->corner.x++;
r->extent.width -= 2;
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x15, 0x15), 0x08));
for (i = beg_index; i <= end_index; i++)
{
wsprintf (buf, menu_string[i]);
if (hilite && pos == i)
{
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x08));
r->corner.y = t.baseline.y - PC_MENU_HEIGHT + 2;
r->extent.height = PC_MENU_HEIGHT - 1;
DrawFilledRectangle (r);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x08));
font_DrawText (&t);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x15, 0x15), 0x08));
}
else
font_DrawText (&t);
t.baseline.y += PC_MENU_HEIGHT;
}
}
/* Determine the last text item to display */
BYTE
GetEndMenuState (BYTE BaseState)
{
switch (BaseState)
{
case PM_SCAN:
case PM_STARMAP:
return PM_NAVIGATE;
break;
case PM_MIN_SCAN:
return PM_LAUNCH_LANDER;
break;
case PM_SAVE_GAME:
return PM_EXIT_MENU1;
break;
case PM_CONVERSE:
return PM_SAVE_LOAD1;
break;
case PM_FUEL:
return PM_EXIT_MENU2;
break;
case PM_CREW:
return PM_EXIT_MENU3;
break;
case PM_SOUND_ON:
return PM_EXIT_MENU4;
break;
case PM_ALT_SCAN:
case PM_ALT_STARMAP:
return PM_ALT_NAVIGATE;
break;
case PM_ALT_CARGO:
return PM_ALT_EXITMENU0;
break;
case PM_ALT_MSCAN:
return PM_ALT_EXITMENU1;
break;
}
return BaseState;
}
BYTE
GetBeginMenuState (BYTE BaseState)
{
return BaseState;
}
/* Correct Menu State for cases where the Menu shouldn't move */
BYTE
FixMenuState (BYTE BadState)
{
switch (BadState)
{
case PM_SOUND_ON:
if (GLOBAL (glob_flags) & SOUND_DISABLED)
return (PM_SOUND_OFF);
else
return (PM_SOUND_ON);
case PM_MUSIC_ON:
if (GLOBAL (glob_flags) & MUSIC_DISABLED)
return (PM_MUSIC_OFF);
else
return (PM_MUSIC_ON);
case PM_CYBORG_OFF:
return (PM_CYBORG_OFF +
((BYTE)(GLOBAL (glob_flags) & COMBAT_SPEED_MASK) >> COMBAT_SPEED_SHIFT));
}
return (BadState);
}
/* Choose the next menu to hilight in the 'forward' direction */
BYTE
NextMenuState (BYTE BaseState, BYTE CurState)
{
BYTE NextState;
BYTE AdjBase = BaseState;
if (BaseState == PM_STARMAP)
AdjBase--;
switch (AdjBase + CurState)
{
case PM_SOUND_ON:
case PM_SOUND_OFF:
NextState = PM_MUSIC_ON;
break;
case PM_MUSIC_ON:
case PM_MUSIC_OFF:
NextState = PM_CYBORG_OFF;
break;
case PM_CYBORG_OFF:
case PM_CYBORG_NORMAL:
case PM_CYBORG_DOUBLE:
case PM_CYBORG_SUPER:
NextState = PM_CHANGE_CAPTAIN;
break;
default:
NextState = AdjBase + CurState + 1;
}
if (NextState > GetEndMenuState (BaseState))
NextState = GetBeginMenuState (BaseState);
return (FixMenuState (NextState) - AdjBase);
}
/* Choose the next menu to hilight in the 'back' direction */
BYTE
PreviousMenuState (BYTE BaseState, BYTE CurState)
{
SWORD NextState;
BYTE AdjBase = BaseState;
if (BaseState == PM_STARMAP)
AdjBase--;
switch (AdjBase + CurState)
{
case PM_SOUND_OFF:
NextState = PM_EXIT_MENU4;
break;
case PM_MUSIC_ON:
case PM_MUSIC_OFF:
NextState = PM_SOUND_ON;
break;
case PM_CYBORG_OFF:
case PM_CYBORG_NORMAL:
case PM_CYBORG_DOUBLE:
case PM_CYBORG_SUPER:
NextState = PM_MUSIC_ON;
break;
case PM_CHANGE_CAPTAIN:
NextState = PM_CYBORG_OFF;
break;
default:
NextState = AdjBase + CurState - 1;
}
if (NextState < GetBeginMenuState (BaseState))
NextState = GetEndMenuState (BaseState);
return (FixMenuState ((BYTE)NextState) - AdjBase);
}
/* When using PC hierarchy, convert 3do->PC */
BOOLEAN
GetAlternateMenu (BYTE *BaseState, BYTE *CurState)
{
BYTE AdjBase = *BaseState;
BYTE adj = 0;
if (*BaseState == PM_STARMAP)
{
AdjBase--;
adj = 1;
}
if (*CurState & 0x80)
{
switch (*CurState)
{
case ALT_MANIFEST:
*BaseState = PM_ALT_SCAN + adj;
*CurState = PM_ALT_MANIFEST - PM_ALT_SCAN - adj;
return (TRUE);
case ALT_EXIT_MENU0:
*BaseState = PM_ALT_CARGO;
*CurState = PM_ALT_EXITMENU0 - PM_ALT_CARGO;
return (TRUE);
}
fprintf (stderr, "Unknown state combination: %d, %d\n",*BaseState, *CurState);
return (FALSE);
}
else
{
switch (AdjBase + *CurState)
{
case PM_SCAN:
*BaseState = PM_ALT_SCAN;
*CurState = PM_ALT_SCAN - PM_ALT_SCAN;
return (TRUE);
case PM_STARMAP:
*BaseState = PM_ALT_SCAN + adj;
*CurState = PM_ALT_STARMAP - PM_ALT_SCAN - adj;
return (TRUE);
case PM_DEVICES:
*BaseState = PM_ALT_CARGO;
*CurState = PM_ALT_DEVICES - PM_ALT_CARGO;
return (TRUE);
case PM_CARGO:
*BaseState = PM_ALT_CARGO;
*CurState = PM_ALT_CARGO - PM_ALT_CARGO;
return (TRUE);
case PM_ROSTER:
*BaseState = PM_ALT_CARGO;
*CurState = PM_ALT_ROSTER - PM_ALT_CARGO;
return (TRUE);
case PM_SAVE_LOAD0:
*BaseState = PM_ALT_SCAN + adj;
*CurState = PM_ALT_SAVE0 - PM_ALT_SCAN - adj;
return (TRUE);
case PM_NAVIGATE:
*BaseState = PM_ALT_SCAN + adj;
*CurState = PM_ALT_NAVIGATE - PM_ALT_SCAN - adj;
return (TRUE);
case PM_MIN_SCAN:
*BaseState = PM_ALT_MSCAN;
*CurState = PM_ALT_MSCAN - PM_ALT_MSCAN;
return (TRUE);
case PM_ENE_SCAN:
*BaseState = PM_ALT_MSCAN;
*CurState = PM_ALT_ESCAN - PM_ALT_MSCAN;
return (TRUE);
case PM_BIO_SCAN:
*BaseState = PM_ALT_MSCAN;
*CurState = PM_ALT_BSCAN - PM_ALT_MSCAN;
return (TRUE);
case PM_EXIT_MENU0:
*BaseState = PM_ALT_MSCAN;
*CurState = PM_ALT_EXITMENU1 - PM_ALT_MSCAN;
return (TRUE);
case PM_AUTO_SCAN:
*BaseState = PM_ALT_MSCAN;
*CurState = PM_ALT_ASCAN - PM_ALT_MSCAN;
return (TRUE);
case PM_LAUNCH_LANDER:
*BaseState = PM_ALT_MSCAN;
*CurState = PM_ALT_DISPATCH - PM_ALT_MSCAN;
return (TRUE);
}
return (FALSE);
}
}
/* When using PC hierarchy, convert PC->3DO */
BYTE
ConvertAlternateMenu (BYTE BaseState, BYTE NewState)
{
switch (BaseState + NewState)
{
case PM_ALT_SCAN:
return (PM_SCAN - PM_SCAN);
case PM_ALT_STARMAP:
return (PM_STARMAP - PM_SCAN);
case PM_ALT_MANIFEST:
return (ALT_MANIFEST);
case PM_ALT_SAVE0:
return (PM_SAVE_LOAD0 - PM_SCAN);
case PM_ALT_NAVIGATE:
return (PM_NAVIGATE - PM_SCAN);
case PM_ALT_CARGO:
return (PM_CARGO - PM_SCAN);
case PM_ALT_DEVICES:
return (PM_DEVICES - PM_SCAN);
case PM_ALT_ROSTER:
return (PM_ROSTER - PM_SCAN);
case PM_ALT_EXITMENU0:
return (ALT_EXIT_MENU0);
case PM_ALT_MSCAN:
return (PM_MIN_SCAN - PM_MIN_SCAN);
case PM_ALT_ESCAN:
return (PM_ENE_SCAN - PM_MIN_SCAN);
case PM_ALT_BSCAN:
return (PM_BIO_SCAN - PM_MIN_SCAN);
case PM_ALT_ASCAN:
return (PM_AUTO_SCAN - PM_MIN_SCAN);
case PM_ALT_DISPATCH:
return (PM_LAUNCH_LANDER - PM_MIN_SCAN);
case PM_ALT_EXITMENU1:
return (PM_EXIT_MENU0 - PM_MIN_SCAN);
}
return (NewState);
}
BOOLEAN
DoMenuChooser (INPUT_STATE InputState, PMENU_STATE pMS, BYTE BaseState)
{
{
BYTE NewState = pMS->CurState;
BYTE OrigBase = BaseState;
BOOLEAN useAltMenu = FALSE;
if (optWhichMenu == OPT_PC)
useAltMenu = GetAlternateMenu (&BaseState, &NewState);
if (GetInputXComponent (InputState) < 0
|| GetInputYComponent (InputState) < 0)
NewState = PreviousMenuState (BaseState, NewState);
else if (GetInputXComponent (InputState) > 0
|| GetInputYComponent (InputState) > 0)
NewState = NextMenuState (BaseState, NewState);
else if (useAltMenu && InputState & DEVICE_BUTTON1)
{
NewState = ConvertAlternateMenu (BaseState, NewState);
if (NewState == ALT_MANIFEST)
{
DrawMenuStateStrings (PM_ALT_CARGO, 0);
pMS->CurState = PM_CARGO - PM_SCAN;
return (TRUE);
}
if (NewState == ALT_EXIT_MENU0)
{
if (OrigBase == PM_SCAN)
DrawMenuStateStrings (PM_ALT_SCAN, PM_ALT_MANIFEST - PM_ALT_SCAN);
else
DrawMenuStateStrings (PM_ALT_STARMAP, PM_ALT_MANIFEST - PM_ALT_STARMAP);
pMS->CurState = ALT_MANIFEST;
return (TRUE);
}
return (FALSE);
}
else
return (FALSE);
DrawMenuStateStrings (BaseState, NewState);
if (useAltMenu)
NewState = ConvertAlternateMenu (BaseState, NewState);
pMS->CurState = NewState;
return (TRUE);
}
}
void
DrawMenuStateStrings (BYTE beg_index, SWORD NewState)
{
BYTE end_index;
RECT r;
STAMP s;
CONTEXT OldContext;
BYTE hilite = 1;
extern FRAME PlayFrame;
if (NewState < 0)
{
NewState = - NewState;
hilite = 0;
}
if (optWhichMenu == OPT_PC)
{
BYTE tmpState = (BYTE)NewState;
GetAlternateMenu (&beg_index, &tmpState);
NewState = tmpState;
}
if (beg_index == PM_STARMAP)
NewState--;
end_index = GetEndMenuState (beg_index);
s.frame = 0;
if (NewState <= end_index - beg_index)
s.frame = SetAbsFrameIndex (PlayFrame, beg_index + NewState);
SetSemaphore (GraphicsSem);
OldContext = SetContext (StatusContext);
GetContextClipRect (&r);
s.origin.x = RADAR_X - r.corner.x;
s.origin.y = RADAR_Y - r.corner.y;
r.corner.x = s.origin.x - 1;
r.corner.y = s.origin.y - 11;
r.extent.width = RADAR_WIDTH + 2;
BatchGraphics ();
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), 0x08));
if (s.frame && optWhichMenu == OPT_PC)
{
if (beg_index == PM_CREW)
sprintf (menu_string[PM_CREW], "crew(%d)", GLOBAL (CrewCost));
if (beg_index == PM_FUEL)
sprintf (menu_string[PM_FUEL], "fuel(%d)", GLOBAL (FuelCost));
if (beg_index == PM_SOUND_ON)
{
end_index = beg_index + 5;
switch (beg_index + NewState)
{
case PM_SOUND_ON:
case PM_SOUND_OFF:
NewState = 0;
break;
case PM_MUSIC_ON:
case PM_MUSIC_OFF:
NewState = 1;
break;
case PM_CYBORG_OFF:
case PM_CYBORG_NORMAL:
case PM_CYBORG_DOUBLE:
case PM_CYBORG_SUPER:
NewState = 2;
break;
case PM_CHANGE_CAPTAIN:
NewState = 3;
break;
case PM_CHANGE_SHIP:
NewState = 4;
break;
case PM_EXIT_MENU4:
NewState = 5;
break;
}
}
r.extent.height = RADAR_HEIGHT + 11;
DrawPCMenu (beg_index, end_index, (BYTE)NewState, hilite, &r);
s.frame = 0;
}
else
{
if(optWhichMenu == OPT_PC)
{
r.corner.x -= 1;
r.extent.width += 1;
r.extent.height = RADAR_HEIGHT + 11;
}
else
r.extent.height = 11;
DrawFilledRectangle (&r);
}
if (s.frame)
{
DrawStamp (&s);
switch (beg_index + NewState)
{
TEXT t;
UNICODE buf[4];
case PM_CREW:
t.baseline.x = s.origin.x + RADAR_WIDTH - 2;
t.baseline.y = s.origin.y + RADAR_HEIGHT - 2;
t.align = ALIGN_RIGHT;
t.CharCount = (COUNT)~0;
t.pStr = buf;
wsprintf (buf, "%u", GLOBAL (CrewCost));
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02));
font_DrawText (&t);
break;
case PM_FUEL:
t.baseline.x = s.origin.x + RADAR_WIDTH - 2;
t.baseline.y = s.origin.y + RADAR_HEIGHT - 2;
t.align = ALIGN_RIGHT;
t.CharCount = (COUNT)~0;
t.pStr = buf;
wsprintf (buf, "%u", GLOBAL (FuelCost));
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02));
font_DrawText (&t);
break;
}
}
UnbatchGraphics ();
if (flash_task
&& flash_rect.corner.x == RADAR_X
&& flash_rect.corner.y == RADAR_Y
&& flash_rect.extent.width == RADAR_WIDTH
&& flash_rect.extent.height == RADAR_HEIGHT)
SetFlashRect ((PRECT)~0L, (FRAME)0);
SetContext (OldContext);
ClearSemaphore (GraphicsSem);
}
+65 -75
View File
@@ -219,7 +219,7 @@ DoInstallModule (INPUT_STATE InputState, PMENU_STATE pMS)
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE); SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
ClearSISRect (CLEAR_SIS_RADAR);
SetFlashRect (NULL_PTR, (FRAME)0); SetFlashRect (NULL_PTR, (FRAME)0);
goto InitFlash; goto InitFlash;
} }
@@ -507,6 +507,64 @@ InitFlash:
return (TRUE); return (TRUE);
} }
void
ChangeFuelQuantity (INPUT_STATE InputState)
{
RECT r;
r.extent.height = 1;
if (GetInputXComponent (InputState) < 0
|| GetInputYComponent (InputState) < 0)
{
SetSemaphore (GraphicsSem);
SetContext (SpaceContext);
if (GetFTankCapacity (&r.corner) > GLOBAL_SIS (FuelOnBoard)
&& GLOBAL_SIS (ResUnits) >=
(DWORD)GLOBAL (FuelCost))
{
if (GLOBAL_SIS (FuelOnBoard) >=
FUEL_RESERVE - FUEL_TANK_SCALE)
{
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);
}
DeltaSISGauges (0, FUEL_TANK_SCALE, -GLOBAL (FuelCost));
SetContext (StatusContext);
GetGaugeRect (&r, FALSE);
SetFlashRect (&r, (FRAME)0);
}
ClearSemaphore (GraphicsSem);
}
else if (GetInputXComponent (InputState) > 0
|| GetInputYComponent (InputState) > 0)
{
SetSemaphore (GraphicsSem);
SetContext (SpaceContext);
if (GLOBAL_SIS (FuelOnBoard))
{
DeltaSISGauges (0, -FUEL_TANK_SCALE,
GLOBAL (FuelCost));
if (GLOBAL_SIS (FuelOnBoard)
% FUEL_VOLUME_PER_ROW == 0)
{
GetFTankCapacity (&r.corner);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xB, 0x00, 0x00), 0x2E));
r.extent.width = 5;
DrawFilledRectangle (&r);
}
}
SetContext (StatusContext);
GetGaugeRect (&r, FALSE);
SetFlashRect (&r, (FRAME)0);
ClearSemaphore (GraphicsSem);
}
}
BOOLEAN BOOLEAN
DoOutfit (INPUT_STATE InputState, PMENU_STATE pMS) DoOutfit (INPUT_STATE InputState, PMENU_STATE pMS)
@@ -602,7 +660,7 @@ DoOutfit (INPUT_STATE InputState, PMENU_STATE pMS)
DrawFlagshipName (FALSE); DrawFlagshipName (FALSE);
ClearSemaphore(GraphicsSem); ClearSemaphore(GraphicsSem);
{ {
RECT r; RECT r;
r.corner.x = 0; r.corner.x = 0;
@@ -610,7 +668,7 @@ DoOutfit (INPUT_STATE InputState, PMENU_STATE pMS)
r.extent.width = SCREEN_WIDTH; r.extent.width = SCREEN_WIDTH;
r.extent.height = SCREEN_HEIGHT; r.extent.height = SCREEN_HEIGHT;
ScreenTransition (3, &r); ScreenTransition (3, &r);
} }
PlayMusic (pMS->hMusic, TRUE, 1); PlayMusic (pMS->hMusic, TRUE, 1);
UnbatchGraphics (); UnbatchGraphics ();
@@ -693,78 +751,10 @@ ExitOutfit:
} }
else else
{ {
BYTE NewState; if (pMS->CurState == OUTFIT_DOFUEL)
RECT r; ChangeFuelQuantity(InputState);
else
r.extent.height = 1; DoMenuChooser (InputState, pMS, PM_FUEL);
NewState = pMS->CurState;
if (GetInputXComponent (InputState) < 0
|| GetInputYComponent (InputState) < 0)
{
if (NewState == OUTFIT_DOFUEL)
{
SetSemaphore (GraphicsSem);
SetContext (SpaceContext);
if (GetFTankCapacity (&r.corner) > GLOBAL_SIS (FuelOnBoard)
&& GLOBAL_SIS (ResUnits) >=
(DWORD)GLOBAL (FuelCost))
{
if (GLOBAL_SIS (FuelOnBoard) >=
FUEL_RESERVE - FUEL_TANK_SCALE)
{
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);
}
DeltaSISGauges (0, FUEL_TANK_SCALE, -GLOBAL (FuelCost));
SetContext (StatusContext);
GetGaugeRect (&r, FALSE);
SetFlashRect (&r, (FRAME)0);
}
ClearSemaphore (GraphicsSem);
}
else if (NewState-- == OUTFIT_FUEL)
NewState = OUTFIT_EXIT;
}
else if (GetInputXComponent (InputState) > 0
|| GetInputYComponent (InputState) > 0)
{
if (NewState == OUTFIT_DOFUEL)
{
SetSemaphore (GraphicsSem);
SetContext (SpaceContext);
if (GLOBAL_SIS (FuelOnBoard))
{
DeltaSISGauges (0, -FUEL_TANK_SCALE,
GLOBAL (FuelCost));
if (GLOBAL_SIS (FuelOnBoard)
% FUEL_VOLUME_PER_ROW == 0)
{
GetFTankCapacity (&r.corner);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xB, 0x00, 0x00), 0x2E));
r.extent.width = 5;
DrawFilledRectangle (&r);
}
}
SetContext (StatusContext);
GetGaugeRect (&r, FALSE);
SetFlashRect (&r, (FRAME)0);
ClearSemaphore (GraphicsSem);
}
else if (NewState++ == OUTFIT_EXIT)
NewState = OUTFIT_FUEL;
}
if (NewState != pMS->CurState)
{
DrawMenuStateStrings (PM_FUEL, NewState);
pMS->CurState = NewState;
}
} }
return (TRUE); return (TRUE);
+13 -34
View File
@@ -18,6 +18,7 @@
#include "starcon.h" #include "starcon.h"
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
#include "options.h"
//Added by Chris //Added by Chris
@@ -1166,7 +1167,15 @@ DoFlagshipCommands (INPUT_STATE InputState, PMENU_STATE pMS)
if (pMS->CurState) if (pMS->CurState)
{ {
BOOLEAN DoMenu;
BYTE NewState; BYTE NewState;
// For some reason, DoFlagshipCommands uses CurState a bit differently
pMS->CurState --;
DoMenu = DoMenuChooser (InputState, pMS,
(BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN));
pMS->CurState ++;
if (!DoMenu) {
NewState = pMS->CurState; NewState = pMS->CurState;
if ((InputState & DEVICE_BUTTON1) || LastActivity == CHECK_LOAD) if ((InputState & DEVICE_BUTTON1) || LastActivity == CHECK_LOAD)
@@ -1198,20 +1207,14 @@ DoFlagshipCommands (INPUT_STATE InputState, PMENU_STATE pMS)
} }
case CARGO: case CARGO:
{ {
extern void Cargo extern void Cargo (PMENU_STATE pMS);
(PMENU_STATE
pMS);
Cargo (pMS); Cargo (pMS);
break; break;
} }
case ROSTER: case ROSTER:
{ {
extern BOOLEAN Roster (void);
extern
BOOLEAN
Roster
(void);
if (!Roster ()) if (!Roster ())
InputState &= ~DEVICE_BUTTON1; InputState &= ~DEVICE_BUTTON1;
@@ -1312,9 +1315,10 @@ DoFlagshipCommands (INPUT_STATE InputState, PMENU_STATE pMS)
ClearSemaphore (GraphicsSem); ClearSemaphore (GraphicsSem);
if (InputState & DEVICE_BUTTON1) if (InputState & DEVICE_BUTTON1)
{ {
if (optWhichMenu != OPT_PC)
pMS->CurState = (NAVIGATION) + 1; pMS->CurState = (NAVIGATION) + 1;
DrawMenuStateStrings ((BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN), DrawMenuStateStrings ((BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN),
NAVIGATION); pMS->CurState - 1);
} }
} }
else else
@@ -1325,31 +1329,6 @@ DoFlagshipCommands (INPUT_STATE InputState, PMENU_STATE pMS)
DrawMenuStateStrings (PM_STARMAP, -NAVIGATION); DrawMenuStateStrings (PM_STARMAP, -NAVIGATION);
} }
} }
else
{
BYTE FirstState;
FirstState = (BYTE)(pMS->Initialized <= 1 ? STARMAP : SCAN);
if (GetInputXComponent (InputState) < 0
|| GetInputYComponent (InputState) < 0)
{
if (NewState-- == (BYTE)(FirstState + 1))
NewState = (NAVIGATION) + 1;
}
else if (GetInputXComponent (InputState) > 0
|| GetInputYComponent (InputState) > 0)
{
if (NewState++ == (NAVIGATION) + 1)
NewState = (BYTE)(FirstState + 1);
}
if (NewState != pMS->CurState)
{
DrawMenuStateStrings ((BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN),
(BYTE)(NewState - 1));
pMS->CurState = NewState;
}
} }
} }
} }
+1 -23
View File
@@ -1154,29 +1154,7 @@ DoScan (INPUT_STATE InputState, PMENU_STATE
else if (!(pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED) else if (!(pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED)
&& pSolarSysState->SysInfo.PlanetInfo.AtmoDensity != && pSolarSysState->SysInfo.PlanetInfo.AtmoDensity !=
GAS_GIANT_ATMOSPHERE) GAS_GIANT_ATMOSPHERE)
{ DoMenuChooser (InputState, pMS, PM_MIN_SCAN);
BYTE NewState;
NewState = pMS->CurState;
if (GetInputXComponent (InputState) < 0
|| GetInputYComponent (InputState) < 0)
{
if (NewState-- == MINERAL_SCAN)
NewState = DISPATCH_SHUTTLE;
}
else if (GetInputXComponent (InputState) > 0
|| GetInputYComponent (InputState) > 0)
{
if (NewState++ == DISPATCH_SHUTTLE)
NewState = MINERAL_SCAN;
}
if (NewState != pMS->CurState)
{
DrawMenuStateStrings (PM_MIN_SCAN, NewState);
pMS->CurState = NewState;
}
}
return (TRUE); return (TRUE);
} }
+1 -24
View File
@@ -1139,30 +1139,7 @@ ExitShipyard:
} }
} }
else else
{ DoMenuChooser (InputState, pMS, PM_CREW);
BYTE NewState;
NewState = pMS->CurState;
if (GetInputXComponent (InputState) < 0
|| GetInputYComponent (InputState) < 0)
{
if (NewState-- == SHIPYARD_CREW)
NewState = SHIPYARD_EXIT;
}
else if (GetInputXComponent (InputState) > 0
|| GetInputYComponent (InputState) > 0)
{
if (NewState++ == SHIPYARD_EXIT)
NewState = SHIPYARD_CREW;
}
if (NewState != pMS->CurState)
{
DrawMenuStateStrings (PM_CREW, NewState);
pMS->CurState = NewState;
}
}
return (TRUE); return (TRUE);
} }
+2 -264
View File
@@ -990,8 +990,8 @@ CountSISPieces (BYTE piece_type)
return (num_pieces); return (num_pieces);
} }
static Task flash_task; Task flash_task = 0;
static RECT flash_rect; RECT flash_rect;
static FRAME flash_frame; static FRAME flash_frame;
int flash_rect_func(void *data) int flash_rect_func(void *data)
@@ -1163,268 +1163,6 @@ SetFlashRect (PRECT pRect, FRAME f)
SetContext (OldContext); SetContext (OldContext);
} }
static void
DrawPCMenuFrame (RECT *r)
{
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x0F, 0x0F, 0x0F), 0x08));
DrawRectangle (r);
r->corner.x++;
r->corner.y++;
r->extent.height--;
r->extent.width--;
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x06, 0x06, 0x06), 0x08));
DrawRectangle (r);
r->extent.height--;
r->extent.width--;
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x15), 0x08));
DrawFilledRectangle (r);
}
static char menu_string[][11] = {
"scan",
"starmap",
"devices",
"cargo",
"roster",
"game",
"navigate",
"mineral",
"energy",
"biological",
"exit menu",
"autoscan",
"dispatch",
"save game",
"load game",
"settings",
"exit menu",
"converse",
"attack!",
"game",
"fuel",
"module",
"game",
"exit menu",
"crew",
"game",
"exit menu",
"sound",
"music",
"cyborg",
"captain",
"flagship",
"exit menu"
};
static void
DrawPCMenu (BYTE beg_index, BYTE end_index, BYTE NewState, BYTE hilite, RECT *r)
{
#define PC_MENU_HEIGHT 8
BYTE pos;
COUNT i;
int num_items;
FONT OldFont;
TEXT t;
UNICODE buf[40];
pos = beg_index + NewState;
num_items = 1 + end_index - beg_index;
r->corner.x -= 1;
r->extent.width += 1;
DrawFilledRectangle (r);
if (num_items * PC_MENU_HEIGHT > r->extent.height)
fprintf (stderr, "Warning, no room for all menu items!\n");
else
r->corner.y += (r->extent.height - num_items * PC_MENU_HEIGHT) / 2;
r->extent.height = num_items * PC_MENU_HEIGHT + 4;
DrawPCMenuFrame (r);
OldFont = SetContextFont (StarConFont);
t.align = ALIGN_LEFT;
t.baseline.x = r->corner.x + 2;
t.baseline.y = r->corner.y + PC_MENU_HEIGHT -1;
t.pStr = buf;
t.CharCount = (COUNT)~0;
r->corner.x++;
r->extent.width -= 2;
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x15, 0x15), 0x08));
for (i = beg_index; i <= end_index; i++)
{
wsprintf (buf, menu_string[i]);
if (hilite && pos == i)
{
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x08));
r->corner.y = t.baseline.y - PC_MENU_HEIGHT + 2;
r->extent.height = PC_MENU_HEIGHT - 1;
DrawFilledRectangle (r);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x08));
font_DrawText (&t);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x15, 0x15), 0x08));
}
else
font_DrawText (&t);
t.baseline.y += PC_MENU_HEIGHT;
}
}
void
DrawMenuStateStrings (BYTE beg_index, SWORD NewState)
{
BYTE end_index;
RECT r;
STAMP s;
CONTEXT OldContext;
BYTE hilite = 1;
extern FRAME PlayFrame;
if (NewState < 0)
{
NewState = - NewState;
hilite = 0;
}
switch (beg_index)
{
case PM_SCAN:
end_index = PM_NAVIGATE;
break;
case PM_STARMAP:
NewState--;
end_index = PM_NAVIGATE;
break;
case PM_MIN_SCAN:
end_index = PM_LAUNCH_LANDER;
break;
case PM_SAVE_GAME:
end_index = PM_EXIT_MENU1;
break;
case PM_CONVERSE:
end_index = PM_SAVE_LOAD1;
break;
case PM_FUEL:
end_index = PM_EXIT_MENU2;
break;
case PM_CREW:
end_index = PM_EXIT_MENU3;
break;
case PM_SOUND_ON:
end_index = PM_EXIT_MENU4;
break;
default:
end_index = beg_index;
break;
}
s.frame = 0;
if (NewState <= end_index - beg_index)
s.frame = SetAbsFrameIndex (PlayFrame, beg_index + NewState);
SetSemaphore (GraphicsSem);
OldContext = SetContext (StatusContext);
GetContextClipRect (&r);
s.origin.x = RADAR_X - r.corner.x;
s.origin.y = RADAR_Y - r.corner.y;
r.corner.x = s.origin.x - 1;
r.corner.y = s.origin.y - 11;
r.extent.width = RADAR_WIDTH + 2;
BatchGraphics ();
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), 0x08));
if (s.frame && optWhichMenu == OPT_PC)
{
if (beg_index == PM_CREW)
sprintf (menu_string[PM_CREW], "crew(%d)", GLOBAL (CrewCost));
if (beg_index == PM_FUEL)
sprintf (menu_string[PM_FUEL], "fuel(%d)", GLOBAL (FuelCost));
if (beg_index == PM_SOUND_ON)
{
end_index = beg_index + 5;
switch (beg_index + NewState)
{
case PM_SOUND_ON:
case PM_SOUND_OFF:
NewState = 0;
break;
case PM_MUSIC_ON:
case PM_MUSIC_OFF:
NewState = 1;
break;
case PM_CYBORG_OFF:
case PM_CYBORG_NORMAL:
case PM_CYBORG_DOUBLE:
case PM_CYBORG_SUPER:
NewState = 2;
break;
case PM_CHANGE_CAPTAIN:
NewState = 3;
break;
case PM_CHANGE_SHIP:
NewState = 4;
break;
case PM_EXIT_MENU4:
NewState = 5;
break;
}
}
r.extent.height = RADAR_HEIGHT + 11;
DrawPCMenu (beg_index, end_index, (BYTE)NewState, hilite, &r);
s.frame = 0;
}
else
{
if(optWhichMenu == OPT_PC)
{
r.corner.x -= 1;
r.extent.width += 1;
r.extent.height = RADAR_HEIGHT + 11;
}
else
r.extent.height = 11;
DrawFilledRectangle (&r);
}
if (s.frame)
{
DrawStamp (&s);
switch (beg_index + NewState)
{
TEXT t;
UNICODE buf[4];
case PM_CREW:
t.baseline.x = s.origin.x + RADAR_WIDTH - 2;
t.baseline.y = s.origin.y + RADAR_HEIGHT - 2;
t.align = ALIGN_RIGHT;
t.CharCount = (COUNT)~0;
t.pStr = buf;
wsprintf (buf, "%u", GLOBAL (CrewCost));
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02));
font_DrawText (&t);
break;
case PM_FUEL:
t.baseline.x = s.origin.x + RADAR_WIDTH - 2;
t.baseline.y = s.origin.y + RADAR_HEIGHT - 2;
t.align = ALIGN_RIGHT;
t.CharCount = (COUNT)~0;
t.pStr = buf;
wsprintf (buf, "%u", GLOBAL (FuelCost));
SetContextFont (TinyFont);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x02));
font_DrawText (&t);
break;
}
}
UnbatchGraphics ();
if (flash_task
&& flash_rect.corner.x == RADAR_X
&& flash_rect.corner.y == RADAR_Y
&& flash_rect.extent.width == RADAR_WIDTH
&& flash_rect.extent.height == RADAR_HEIGHT)
SetFlashRect ((PRECT)~0L, (FRAME)0);
SetContext (OldContext);
ClearSemaphore (GraphicsSem);
}
void void
SaveFlagshipState (void) SaveFlagshipState (void)
+19 -1
View File
@@ -48,7 +48,25 @@ enum
PM_CYBORG_SUPER, PM_CYBORG_SUPER,
PM_CHANGE_CAPTAIN, PM_CHANGE_CAPTAIN,
PM_CHANGE_SHIP, PM_CHANGE_SHIP,
PM_EXIT_MENU4 PM_EXIT_MENU4,
PM_ALT_SCAN,
PM_ALT_STARMAP,
PM_ALT_MANIFEST,
PM_ALT_SAVE0,
PM_ALT_NAVIGATE,
PM_ALT_CARGO,
PM_ALT_DEVICES,
PM_ALT_ROSTER,
PM_ALT_EXITMENU0,
PM_ALT_MSCAN,
PM_ALT_ESCAN,
PM_ALT_BSCAN,
PM_ALT_ASCAN,
PM_ALT_DISPATCH,
PM_ALT_EXITMENU1
}; };
#define CLEAR_SIS_RADAR (1 << 2) #define CLEAR_SIS_RADAR (1 << 2)