Beginnings of a setup menu
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1370 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -6,7 +6,7 @@ uqm_CFILES="battle.c border.c build.c cleanup.c clock.c collide.c comm.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 menu.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 setupmenu.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
|
||||||
trans.c util.c velocity.c weapon.c"
|
trans.c util.c velocity.c weapon.c"
|
||||||
|
|
||||||
|
|||||||
+39
-24
@@ -20,6 +20,8 @@
|
|||||||
#include "uqmversion.h"
|
#include "uqmversion.h"
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
#include "credits.h"
|
#include "credits.h"
|
||||||
|
#include "libs/graphics/gfx_common.h"
|
||||||
|
#include "setupmenu.h"
|
||||||
|
|
||||||
//Added by Chris
|
//Added by Chris
|
||||||
|
|
||||||
@@ -46,6 +48,30 @@ enum
|
|||||||
QUIT_GAME
|
QUIT_GAME
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
DrawRestartMenuGraphic (PMENU_STATE pMS)
|
||||||
|
{
|
||||||
|
RECT r;
|
||||||
|
STAMP s;
|
||||||
|
|
||||||
|
s.frame = CaptureDrawable (
|
||||||
|
LoadGraphic (RESTART_PMAP_ANIM)
|
||||||
|
);
|
||||||
|
pMS->CurFrame = s.frame;
|
||||||
|
GetFrameRect (s.frame, &r);
|
||||||
|
s.origin.x = (SCREEN_WIDTH - r.extent.width) >> 1;
|
||||||
|
s.origin.y = (SCREEN_HEIGHT - r.extent.height) >> 1;
|
||||||
|
|
||||||
|
SetContextBackGroundColor (BLACK_COLOR);
|
||||||
|
BatchGraphics ();
|
||||||
|
ClearDrawable ();
|
||||||
|
FlushColorXForms ();
|
||||||
|
LockMutex (GraphicsLock);
|
||||||
|
DrawStamp (&s);
|
||||||
|
UnlockMutex (GraphicsLock);
|
||||||
|
UnbatchGraphics ();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
DrawRestartMenu (BYTE OldState, BYTE NewState, FRAME f)
|
DrawRestartMenu (BYTE OldState, BYTE NewState, FRAME f)
|
||||||
{
|
{
|
||||||
@@ -140,11 +166,19 @@ else if (InputState & DEVICE_EXIT) return (FALSE);
|
|||||||
GLOBAL (CurrentActivity) = SUPER_MELEE;
|
GLOBAL (CurrentActivity) = SUPER_MELEE;
|
||||||
break;
|
break;
|
||||||
case SETUP_GAME:
|
case SETUP_GAME:
|
||||||
PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 2),
|
LockMutex (GraphicsLock);
|
||||||
0, NotPositional (), NULL, GAME_SOUND_PRIORITY);
|
SetFlashRect (NULL_PTR, (FRAME)0);
|
||||||
|
UnlockMutex (GraphicsLock);
|
||||||
|
SetupMenu ();
|
||||||
|
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
|
||||||
InTime = GetTimeCounter ();
|
InTime = GetTimeCounter ();
|
||||||
|
SetTransitionSource (NULL);
|
||||||
|
BatchGraphics ();
|
||||||
|
DrawRestartMenuGraphic (pMS);
|
||||||
|
DrawRestartMenu ((BYTE)~0, pMS->CurState, pMS->CurFrame);
|
||||||
|
ScreenTransition (3, NULL);
|
||||||
|
UnbatchGraphics ();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
break;
|
|
||||||
case QUIT_GAME:
|
case QUIT_GAME:
|
||||||
PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 1),
|
PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 1),
|
||||||
0, NotPositional (), NULL, GAME_SOUND_PRIORITY);
|
0, NotPositional (), NULL, GAME_SOUND_PRIORITY);
|
||||||
@@ -264,29 +298,10 @@ LastActivity = WON_LAST_BATTLE;
|
|||||||
LastActivity = NextActivity = 0;
|
LastActivity = NextActivity = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
RECT r;
|
|
||||||
STAMP s;
|
|
||||||
|
|
||||||
s.frame = CaptureDrawable (
|
|
||||||
LoadGraphic (RESTART_PMAP_ANIM)
|
|
||||||
);
|
|
||||||
MenuState.CurFrame = s.frame;
|
|
||||||
GetFrameRect (s.frame, &r);
|
|
||||||
s.origin.x = (SCREEN_WIDTH - r.extent.width) >> 1;
|
|
||||||
s.origin.y = (SCREEN_HEIGHT - r.extent.height) >> 1;
|
|
||||||
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, TimeOut));
|
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, TimeOut));
|
||||||
if (TimeOut == ONE_SECOND / 8)
|
if (TimeOut == ONE_SECOND / 8)
|
||||||
SleepThread (ONE_SECOND * 3);
|
SleepThread (ONE_SECOND * 3);
|
||||||
|
DrawRestartMenuGraphic (&MenuState);
|
||||||
SetContextBackGroundColor (BLACK_COLOR);
|
|
||||||
BatchGraphics ();
|
|
||||||
ClearDrawable ();
|
|
||||||
FlushColorXForms ();
|
|
||||||
LockMutex (GraphicsLock);
|
|
||||||
DrawStamp (&s);
|
|
||||||
UnlockMutex (GraphicsLock);
|
|
||||||
UnbatchGraphics ();
|
|
||||||
|
|
||||||
FlushInput ();
|
FlushInput ();
|
||||||
GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
|
GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
|
||||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
|
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
|
||||||
@@ -295,7 +310,7 @@ LastActivity = WON_LAST_BATTLE;
|
|||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
SetFlashRect ((PRECT)0, (FRAME)0);
|
SetFlashRect ((PRECT)0, (FRAME)0);
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
DestroyDrawable (ReleaseDrawable (s.frame));
|
DestroyDrawable (ReleaseDrawable (MenuState.CurFrame));
|
||||||
|
|
||||||
if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
|
if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
|
||||||
goto TimedOut;
|
goto TimedOut;
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
// Copyright Michael Martin, 2004.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 "setupmenu.h"
|
||||||
|
#include "controls.h"
|
||||||
|
#include "libs/graphics/widgets.h"
|
||||||
|
|
||||||
|
typedef struct setup_menu_state {
|
||||||
|
BOOLEAN (*InputFunc) (struct setup_menu_state *pInputState);
|
||||||
|
COUNT MenuRepeatDelay;
|
||||||
|
BOOLEAN initialized;
|
||||||
|
int anim_frame_count;
|
||||||
|
DWORD NextTime;
|
||||||
|
} SETUP_MENU_STATE;
|
||||||
|
|
||||||
|
typedef SETUP_MENU_STATE *PSETUP_MENU_STATE;
|
||||||
|
|
||||||
|
#define NUM_STEPS 20
|
||||||
|
#define X_STEP (SCREEN_WIDTH / NUM_STEPS)
|
||||||
|
#define Y_STEP (SCREEN_HEIGHT / NUM_STEPS)
|
||||||
|
#define MENU_FRAME_RATE (ONE_SECOND / 60)
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
DoSetupMenu (PSETUP_MENU_STATE pInputState)
|
||||||
|
{
|
||||||
|
if (!pInputState->initialized)
|
||||||
|
{
|
||||||
|
SetDefaultMenuRepeatDelay ();
|
||||||
|
pInputState->anim_frame_count = NUM_STEPS;
|
||||||
|
pInputState->initialized = TRUE;
|
||||||
|
pInputState->NextTime = GetTimeCounter ();
|
||||||
|
}
|
||||||
|
|
||||||
|
BatchGraphics ();
|
||||||
|
if (pInputState->anim_frame_count)
|
||||||
|
{
|
||||||
|
RECT r;
|
||||||
|
COLOR bg, dark, medium;
|
||||||
|
int frame = --pInputState->anim_frame_count;
|
||||||
|
|
||||||
|
r.corner.x = ((frame * X_STEP) >> 1) + 2;
|
||||||
|
r.corner.y = ((frame * Y_STEP) >> 1) + 2;
|
||||||
|
r.extent.width = X_STEP * (NUM_STEPS - frame) - 4;
|
||||||
|
r.extent.height = Y_STEP * (NUM_STEPS - frame) - 4;
|
||||||
|
|
||||||
|
dark = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x08), 0x01);
|
||||||
|
medium = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x10), 0x01);
|
||||||
|
bg = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x1A), 0x09);
|
||||||
|
|
||||||
|
DrawShadowedBox(&r, bg, dark, medium);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RECT r;
|
||||||
|
COLOR bg, dark, medium, text, oldtext;
|
||||||
|
FONT oldfont = SetContextFont (StarConFont);
|
||||||
|
FONTEFFECT oldFontEffect = SetContextFontEffect (0, 0, 0);
|
||||||
|
TEXT t;
|
||||||
|
|
||||||
|
r.corner.x = 2;
|
||||||
|
r.corner.y = 2;
|
||||||
|
r.extent.width = SCREEN_WIDTH - 4;
|
||||||
|
r.extent.height = SCREEN_HEIGHT - 4;
|
||||||
|
|
||||||
|
dark = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x08), 0x01);
|
||||||
|
medium = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x10), 0x01);
|
||||||
|
bg = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x1A), 0x09);
|
||||||
|
text = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x00), 0x0E);
|
||||||
|
|
||||||
|
DrawShadowedBox(&r, bg, dark, medium);
|
||||||
|
|
||||||
|
oldtext = SetContextForeGroundColor (text);
|
||||||
|
t.baseline.x = r.corner.x + (r.extent.width >> 1);
|
||||||
|
t.baseline.y = r.corner.y + 8;
|
||||||
|
t.pStr = "Sorry!";
|
||||||
|
t.align = ALIGN_CENTER;
|
||||||
|
t.valign = VALIGN_BOTTOM;
|
||||||
|
t.CharCount = ~0;
|
||||||
|
font_DrawText (&t);
|
||||||
|
|
||||||
|
t.baseline.y += 100;
|
||||||
|
t.pStr = "The Setup menu has not yet been implemented.";
|
||||||
|
font_DrawText (&t);
|
||||||
|
|
||||||
|
t.baseline.y += 8;
|
||||||
|
t.pStr = "Please press Select or Cancel to return.";
|
||||||
|
font_DrawText (&t);
|
||||||
|
|
||||||
|
SetContextFontEffect (oldFontEffect.type, oldFontEffect.from, oldFontEffect.to);
|
||||||
|
SetContextFont (oldfont);
|
||||||
|
SetContextForeGroundColor (oldtext);
|
||||||
|
}
|
||||||
|
|
||||||
|
UnbatchGraphics ();
|
||||||
|
SleepThreadUntil (pInputState->NextTime + MENU_FRAME_RATE);
|
||||||
|
pInputState->NextTime = GetTimeCounter ();
|
||||||
|
return !(PulsedInputState.key[KEY_MENU_CANCEL] ||
|
||||||
|
PulsedInputState.key[KEY_MENU_SELECT]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SetupMenu (void)
|
||||||
|
{
|
||||||
|
SETUP_MENU_STATE s;
|
||||||
|
|
||||||
|
s.InputFunc = DoSetupMenu;
|
||||||
|
s.initialized = FALSE;
|
||||||
|
SetMenuSounds (0, MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
|
||||||
|
DoInput ((PVOID)&s, TRUE);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// Copyright Michael Martin, 2004.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SETUPMENU_H
|
||||||
|
#define _SETUPMENU_H
|
||||||
|
|
||||||
|
void SetupMenu (void);
|
||||||
|
|
||||||
|
#endif // _SETUPMENU_H
|
||||||
Reference in New Issue
Block a user