New quit confirmation dialog
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1003 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
Changes towards version 0.3:
|
Changes towards version 0.3:
|
||||||
|
- Confirmation dialog box for exiting the game is now menu-based
|
||||||
- Commander Hayes explains his predicament before you get the option to
|
- Commander Hayes explains his predicament before you get the option to
|
||||||
rescue, closes #366, from Nic
|
rescue, closes #366, from Nic
|
||||||
- Gestalt mode accelerates continuously as long as some key is held;
|
- Gestalt mode accelerates continuously as long as some key is held;
|
||||||
|
|||||||
+71
-27
@@ -21,21 +21,55 @@
|
|||||||
#include "commglue.h"
|
#include "commglue.h"
|
||||||
#include "libs/sound/trackplayer.h"
|
#include "libs/sound/trackplayer.h"
|
||||||
|
|
||||||
//Added by Chris
|
#define CONFIRM_WIN_WIDTH 80
|
||||||
|
#define CONFIRM_WIN_HEIGHT 26
|
||||||
|
|
||||||
void WaitForNoInput (SIZE Duration);
|
static void
|
||||||
|
DrawConfirmationWindow (BOOLEAN answer)
|
||||||
|
{
|
||||||
|
COLOR oldfg = SetContextForeGroundColor (MENU_BACKGROUND_COLOR);
|
||||||
|
FONT oldfont = SetContextFont (StarConFont);
|
||||||
|
RECT r;
|
||||||
|
TEXT t;
|
||||||
|
|
||||||
//End Added by Chris
|
r.extent.width = CONFIRM_WIN_WIDTH;
|
||||||
|
r.extent.height = CONFIRM_WIN_HEIGHT;
|
||||||
|
r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1;
|
||||||
|
r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1;
|
||||||
|
|
||||||
/* TODO: Replace the TO EXIT PRESS B code with a 'real' confirmation
|
BatchGraphics ();
|
||||||
screen. To avoid confusion (especially now that there is no
|
|
||||||
in-game model of the 3DO controller exits are currently always
|
|
||||||
confirmed. */
|
|
||||||
|
|
||||||
|
DrawFilledRectangle (&r);
|
||||||
|
SetContextForeGroundColor (MENU_TEXT_COLOR);
|
||||||
|
t.baseline.x = r.corner.x + (r.extent.width >> 1);
|
||||||
|
t.baseline.y = r.corner.y + 10;
|
||||||
|
t.pStr = "Really quit?";
|
||||||
|
t.align = ALIGN_CENTER;
|
||||||
|
t.valign = VALIGN_BOTTOM;
|
||||||
|
t.CharCount = ~0;
|
||||||
|
font_DrawText (&t);
|
||||||
|
t.baseline.y += 10;
|
||||||
|
t.baseline.x = r.corner.x + (r.extent.width >> 2);
|
||||||
|
t.pStr = "Yes";
|
||||||
|
SetContextForeGroundColor (answer ? MENU_HIGHLIGHT_COLOR : MENU_TEXT_COLOR);
|
||||||
|
font_DrawText (&t);
|
||||||
|
t.baseline.x += (r.extent.width >> 1);
|
||||||
|
t.pStr = "No";
|
||||||
|
SetContextForeGroundColor (answer ? MENU_TEXT_COLOR : MENU_HIGHLIGHT_COLOR);
|
||||||
|
font_DrawText (&t);
|
||||||
|
|
||||||
|
UnbatchGraphics ();
|
||||||
|
|
||||||
|
SetContextFont (oldfont);
|
||||||
|
SetContextForeGroundColor (oldfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This code assumes that you aren't in Character Mode. This is
|
||||||
|
* currently safe because VControl doesn't see keystrokes when you
|
||||||
|
* are, and thus cannot conclude that an exit is necessary. */
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
ConfirmExit (void)
|
DoConfirmExit (void)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
BOOLEAN result;
|
BOOLEAN result;
|
||||||
fprintf (stderr, "Confirming Exit!\n");
|
fprintf (stderr, "Confirming Exit!\n");
|
||||||
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE)
|
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE)
|
||||||
@@ -55,17 +89,18 @@ ConfirmExit (void)
|
|||||||
STAMP s;
|
STAMP s;
|
||||||
FRAME F;
|
FRAME F;
|
||||||
CONTEXT oldContext;
|
CONTEXT oldContext;
|
||||||
UNICODE response;
|
BOOLEAN response = TRUE, done;
|
||||||
|
|
||||||
oldContext = SetContext (ScreenContext);
|
oldContext = SetContext (ScreenContext);
|
||||||
|
|
||||||
s.frame = SetAbsFrameIndex (ActivityFrame, 1);
|
r.extent.width = CONFIRM_WIN_WIDTH;
|
||||||
GetFrameRect (s.frame, &r);
|
r.extent.height = CONFIRM_WIN_HEIGHT;
|
||||||
r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1;
|
r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1;
|
||||||
r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1;
|
r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1;
|
||||||
s.origin = r.corner;
|
s.origin = r.corner;
|
||||||
F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));
|
F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));
|
||||||
DrawStamp (&s);
|
|
||||||
|
DrawConfirmationWindow (response);
|
||||||
|
|
||||||
// Releasing the Semaphore lets the rotate_planet_task
|
// Releasing the Semaphore lets the rotate_planet_task
|
||||||
// draw a frame. PauseRotate can still allow one more frame
|
// draw a frame. PauseRotate can still allow one more frame
|
||||||
@@ -74,20 +109,35 @@ ConfirmExit (void)
|
|||||||
FlushGraphics ();
|
FlushGraphics ();
|
||||||
//SetSemaphore (GraphicsSem);
|
//SetSemaphore (GraphicsSem);
|
||||||
|
|
||||||
/* Possible bug... ConfirmExit is assuming
|
|
||||||
* CharacterMode is off. */
|
|
||||||
EnableCharacterMode ();
|
|
||||||
GLOBAL (CurrentActivity) |= CHECK_ABORT;
|
GLOBAL (CurrentActivity) |= CHECK_ABORT;
|
||||||
|
FlushInput ();
|
||||||
|
done = FALSE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
response = toupper (GetCharacter ());
|
// Forbid recursive calls or pausing here!
|
||||||
} while (response != 'Y' && response != 'N');
|
|
||||||
DisableCharacterMode ();
|
|
||||||
ExitRequested = FALSE;
|
ExitRequested = FALSE;
|
||||||
|
GamePaused = FALSE;
|
||||||
|
UpdateInputState ();
|
||||||
|
if (CurrentMenuState.select)
|
||||||
|
{
|
||||||
|
done = TRUE;
|
||||||
|
}
|
||||||
|
else if (CurrentMenuState.cancel)
|
||||||
|
{
|
||||||
|
done = TRUE;
|
||||||
|
response = FALSE;
|
||||||
|
}
|
||||||
|
else if (CurrentMenuState.left || CurrentMenuState.right)
|
||||||
|
{
|
||||||
|
response = !response;
|
||||||
|
DrawConfirmationWindow (response);
|
||||||
|
}
|
||||||
|
} while (!done);
|
||||||
|
|
||||||
s.frame = F;
|
s.frame = F;
|
||||||
DrawStamp (&s);
|
DrawStamp (&s);
|
||||||
DestroyDrawable (ReleaseDrawable (s.frame));
|
DestroyDrawable (ReleaseDrawable (s.frame));
|
||||||
if (response == 'Y')
|
if (response)
|
||||||
{
|
{
|
||||||
GameExiting = TRUE;
|
GameExiting = TRUE;
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
@@ -97,9 +147,8 @@ ConfirmExit (void)
|
|||||||
result = FALSE;
|
result = FALSE;
|
||||||
GameExiting = FALSE;
|
GameExiting = FALSE;
|
||||||
GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
|
GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
|
||||||
WaitForNoInput (ONE_SECOND / 4);
|
|
||||||
FlushInput ();
|
|
||||||
}
|
}
|
||||||
|
FlushInput ();
|
||||||
SetContext (oldContext);
|
SetContext (oldContext);
|
||||||
}
|
}
|
||||||
ClearSemaphore (GraphicsSem);
|
ClearSemaphore (GraphicsSem);
|
||||||
@@ -111,11 +160,6 @@ ConfirmExit (void)
|
|||||||
|
|
||||||
fprintf (stderr, "Exit was %sconfirmed.\n", result ? "" : "NOT ");
|
fprintf (stderr, "Exit was %sconfirmed.\n", result ? "" : "NOT ");
|
||||||
return (result);
|
return (result);
|
||||||
#endif
|
|
||||||
GLOBAL (CurrentActivity) |= CHECK_ABORT;
|
|
||||||
ExitRequested = FALSE;
|
|
||||||
GameExiting = TRUE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,11 +54,13 @@ extern volatile CONTROLLER_INPUT_STATE ImmediateInputState;
|
|||||||
extern volatile MENU_INPUT_STATE ImmediateMenuState;
|
extern volatile MENU_INPUT_STATE ImmediateMenuState;
|
||||||
|
|
||||||
void UpdateInputState (void);
|
void UpdateInputState (void);
|
||||||
|
void FlushInputState (void);
|
||||||
void TFB_ResetControls (void);
|
void TFB_ResetControls (void);
|
||||||
void SetMenuRepeatDelay (DWORD min, DWORD max, DWORD step, BOOLEAN gestalt);
|
void SetMenuRepeatDelay (DWORD min, DWORD max, DWORD step, BOOLEAN gestalt);
|
||||||
void SetDefaultMenuRepeatDelay (void);
|
void SetDefaultMenuRepeatDelay (void);
|
||||||
void ResetKeyRepeat (void);
|
void ResetKeyRepeat (void);
|
||||||
BOOLEAN PauseGame (void);
|
BOOLEAN PauseGame (void);
|
||||||
|
extern BOOLEAN DoConfirmExit (void);
|
||||||
|
|
||||||
BATTLE_INPUT_STATE p1_combat_summary (void);
|
BATTLE_INPUT_STATE p1_combat_summary (void);
|
||||||
BATTLE_INPUT_STATE p2_combat_summary (void);
|
BATTLE_INPUT_STATE p2_combat_summary (void);
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ _clear_menu_state (void)
|
|||||||
CachedMenuState.page_down = 0;
|
CachedMenuState.page_down = 0;
|
||||||
CachedMenuState.zoom_in = 0;
|
CachedMenuState.zoom_in = 0;
|
||||||
CachedMenuState.zoom_out = 0;
|
CachedMenuState.zoom_out = 0;
|
||||||
|
CachedGestalt = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -247,6 +248,12 @@ SetDefaultMenuRepeatDelay ()
|
|||||||
ResetKeyRepeat ();
|
ResetKeyRepeat ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FlushInputState (void)
|
||||||
|
{
|
||||||
|
_clear_menu_state ();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DoInput (PVOID pInputState, BOOLEAN resetInput)
|
DoInput (PVOID pInputState, BOOLEAN resetInput)
|
||||||
{
|
{
|
||||||
@@ -374,3 +381,22 @@ AnyButtonPress (BOOLEAN CheckSpecial)
|
|||||||
||CurrentMenuState.cancel
|
||CurrentMenuState.cancel
|
||||||
||CurrentMenuState.special;
|
||CurrentMenuState.special;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
ConfirmExit (void)
|
||||||
|
{
|
||||||
|
DWORD old_max_accel, old_min_accel, old_step_accel;
|
||||||
|
BOOLEAN old_gestalt_keys, result;
|
||||||
|
|
||||||
|
old_max_accel = _max_accel;
|
||||||
|
old_min_accel = _min_accel;
|
||||||
|
old_step_accel = _step_accel;
|
||||||
|
old_gestalt_keys = _gestalt_keys;
|
||||||
|
|
||||||
|
SetDefaultMenuRepeatDelay ();
|
||||||
|
|
||||||
|
result = DoConfirmExit ();
|
||||||
|
|
||||||
|
SetMenuRepeatDelay (old_min_accel, old_max_accel, old_step_accel, old_gestalt_keys);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ void
|
|||||||
FlushInput (void)
|
FlushInput (void)
|
||||||
{
|
{
|
||||||
TFB_ResetControls ();
|
TFB_ResetControls ();
|
||||||
GameExiting = ExitRequested = FALSE;
|
FlushInputState ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translates from SDLKeys to values defined in inplib.h
|
// Translates from SDLKeys to values defined in inplib.h
|
||||||
|
|||||||
@@ -816,7 +816,18 @@ UpdateCursorInfo:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TRUE);
|
{
|
||||||
|
BOOLEAN result = !(GLOBAL (CurrentActivity & CHECK_ABORT));
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
if (pMS->flash_task)
|
||||||
|
{
|
||||||
|
ConcludeTask (pMS->flash_task);
|
||||||
|
pMS->flash_task = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user