Switch main menu to the new threadless flashing code.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3250 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#include "libs/gfxlib.h"
|
||||
#include "libs/sndlib.h"
|
||||
#include "libs/tasklib.h"
|
||||
|
||||
#include "flash.h"
|
||||
|
||||
typedef struct menu_state
|
||||
{
|
||||
@@ -41,6 +41,7 @@ typedef struct menu_state
|
||||
Task flash_task;
|
||||
RECT flash_rect0, flash_rect1;
|
||||
FRAME flash_frame0, flash_frame1;
|
||||
FlashContext *flashContext;
|
||||
|
||||
MUSIC_REF hMusic;
|
||||
|
||||
|
||||
+31
-39
@@ -89,30 +89,15 @@ DrawRestartMenuGraphic (MENU_STATE *pMS)
|
||||
}
|
||||
|
||||
static void
|
||||
DrawRestartMenu (BYTE OldState, BYTE NewState, FRAME f)
|
||||
DrawRestartMenu (MENU_STATE *pMS, BYTE NewState, FRAME f)
|
||||
{
|
||||
RECT r;
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetContext (ScreenContext);
|
||||
|
||||
r.corner.x = 0;
|
||||
r.corner.y = 0;
|
||||
r.extent.width = 0;
|
||||
r.extent.height = 0;
|
||||
SetContextClipRect (&r);
|
||||
|
||||
r.corner.x = 0;
|
||||
r.corner.y = 0;
|
||||
r.extent.width = SCREEN_WIDTH;
|
||||
r.extent.height = SCREEN_HEIGHT;
|
||||
SetFlashRect (&r, SetAbsFrameIndex (f, NewState + 1));
|
||||
|
||||
UnlockMutex (GraphicsLock);
|
||||
(void) OldState; /* Satisfying compiler (unused parameter) */
|
||||
POINT origin;
|
||||
origin.x = 0;
|
||||
origin.y = 0;
|
||||
Flash_setOverlay(pMS->flashContext,
|
||||
&origin, SetAbsFrameIndex (f, NewState + 1));
|
||||
}
|
||||
|
||||
|
||||
static BOOLEAN
|
||||
DoRestart (MENU_STATE *pMS)
|
||||
{
|
||||
@@ -123,6 +108,9 @@ DoRestart (MENU_STATE *pMS)
|
||||
/* Cancel any presses of the Pause key. */
|
||||
GamePaused = FALSE;
|
||||
|
||||
if (pMS->Initialized)
|
||||
Flash_process(pMS->flashContext);
|
||||
|
||||
if (!pMS->Initialized)
|
||||
{
|
||||
if (pMS->hMusic)
|
||||
@@ -133,9 +121,17 @@ DoRestart (MENU_STATE *pMS)
|
||||
}
|
||||
pMS->hMusic = LoadMusic (MAINMENU_MUSIC);
|
||||
InactTimeOut = (pMS->hMusic ? 120 : 20) * ONE_SECOND;
|
||||
|
||||
pMS->flashContext = Flash_createOverlay (ScreenContext,
|
||||
NULL, NULL, NULL);
|
||||
Flash_setMergeFactors (pMS->flashContext, -3, 3, 16);
|
||||
Flash_setSpeed (pMS->flashContext, (6 * ONE_SECOND) / 16, 0,
|
||||
(6 * ONE_SECOND) / 16, 0);
|
||||
Flash_setFrameTime (pMS->flashContext, ONE_SECOND / 16);
|
||||
Flash_setState(pMS->flashContext, FlashState_fadeIn,
|
||||
(3 * ONE_SECOND) / 16);
|
||||
DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame);
|
||||
Flash_start (pMS->flashContext);
|
||||
PlayMusic (pMS->hMusic, TRUE, 1);
|
||||
DrawRestartMenu ((BYTE)~0, pMS->CurState, pMS->CurFrame);
|
||||
pMS->Initialized = TRUE;
|
||||
|
||||
{
|
||||
@@ -189,9 +185,9 @@ DoRestart (MENU_STATE *pMS)
|
||||
GLOBAL (CurrentActivity) = SUPER_MELEE;
|
||||
break;
|
||||
case SETUP_GAME:
|
||||
LockMutex (GraphicsLock);
|
||||
SetFlashRect (NULL, (FRAME)0);
|
||||
UnlockMutex (GraphicsLock);
|
||||
Flash_pause(pMS->flashContext);
|
||||
Flash_setState(pMS->flashContext, FlashState_fadeIn,
|
||||
(3 * ONE_SECOND) / 16);
|
||||
SetupMenu ();
|
||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
|
||||
MENU_SOUND_SELECT);
|
||||
@@ -199,8 +195,9 @@ DoRestart (MENU_STATE *pMS)
|
||||
SetTransitionSource (NULL);
|
||||
BatchGraphics ();
|
||||
DrawRestartMenuGraphic (pMS);
|
||||
DrawRestartMenu ((BYTE)~0, pMS->CurState, pMS->CurFrame);
|
||||
ScreenTransition (3, NULL);
|
||||
DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame);
|
||||
Flash_continue(pMS->flashContext);
|
||||
UnbatchGraphics ();
|
||||
return TRUE;
|
||||
case QUIT_GAME:
|
||||
@@ -212,11 +209,9 @@ DoRestart (MENU_STATE *pMS)
|
||||
break;
|
||||
}
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetFlashRect (NULL, (FRAME)0);
|
||||
UnlockMutex (GraphicsLock);
|
||||
Flash_pause(pMS->flashContext);
|
||||
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -236,7 +231,7 @@ DoRestart (MENU_STATE *pMS)
|
||||
if (NewState != pMS->CurState)
|
||||
{
|
||||
BatchGraphics ();
|
||||
DrawRestartMenu (pMS->CurState, NewState, pMS->CurFrame);
|
||||
DrawRestartMenu (pMS, NewState, pMS->CurFrame);
|
||||
UnbatchGraphics ();
|
||||
pMS->CurState = NewState;
|
||||
}
|
||||
@@ -244,18 +239,17 @@ DoRestart (MENU_STATE *pMS)
|
||||
|
||||
if (MouseButtonDown)
|
||||
{
|
||||
LockMutex (GraphicsLock);
|
||||
SetFlashRect (NULL, (FRAME)0);
|
||||
UnlockMutex (GraphicsLock);
|
||||
Flash_pause(pMS->flashContext);
|
||||
DoPopupWindow (GAME_STRING (MAINMENU_STRING_BASE + 54));
|
||||
// Mouse not supported message
|
||||
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
|
||||
SetTransitionSource (NULL);
|
||||
BatchGraphics ();
|
||||
DrawRestartMenuGraphic (pMS);
|
||||
DrawRestartMenu ((BYTE)~0, pMS->CurState, pMS->CurFrame);
|
||||
DrawRestartMenu (pMS, pMS->CurState, pMS->CurFrame);
|
||||
ScreenTransition (3, NULL);
|
||||
UnbatchGraphics ();
|
||||
Flash_continue(pMS->flashContext);
|
||||
}
|
||||
|
||||
LastInputTime = GetTimeCounter ();
|
||||
@@ -330,9 +324,7 @@ RestartMenu (MENU_STATE *pMS)
|
||||
pMS->hMusic = 0;
|
||||
}
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetFlashRect (NULL, (FRAME)0);
|
||||
UnlockMutex (GraphicsLock);
|
||||
Flash_terminate (pMS->flashContext);
|
||||
DestroyDrawable (ReleaseDrawable (pMS->CurFrame));
|
||||
|
||||
if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
|
||||
|
||||
+14
-9
@@ -1341,8 +1341,9 @@ flash_rect_func (void *data)
|
||||
// Wait for the flash_screen_frame to get initialized
|
||||
FlushGraphics ();
|
||||
GetFrameRect (flash_screen_frame, &screen_rect);
|
||||
cached_screen_frame = CaptureDrawable (CreateDrawable (WANT_PIXMAP,
|
||||
screen_rect.extent.width, screen_rect.extent.height, 1));
|
||||
cached_screen_frame = CaptureDrawable (CreateDrawable (
|
||||
WANT_PIXMAP, screen_rect.extent.width,
|
||||
screen_rect.extent.height, 1));
|
||||
screen_rect.corner.x = 0;
|
||||
screen_rect.corner.y = 0;
|
||||
arith_frame_blit (flash_screen_frame, &screen_rect,
|
||||
@@ -1370,7 +1371,8 @@ flash_rect_func (void *data)
|
||||
#define MAX_F_STRENGTH 3
|
||||
int num = 0, denom = 0;
|
||||
|
||||
if ((fstrength += incr) > MAX_F_STRENGTH)
|
||||
fstrength += incr;
|
||||
if (fstrength > MAX_F_STRENGTH)
|
||||
{
|
||||
fstrength = MAX_F_STRENGTH - 1;
|
||||
incr = -1;
|
||||
@@ -1387,8 +1389,9 @@ flash_rect_func (void *data)
|
||||
RECT tmp_rect = framesize_rect;
|
||||
pStamp = &cached_stamp[fstrength - MIN_F_STRENGTH];
|
||||
cached[fstrength - MIN_F_STRENGTH] = 1;
|
||||
pStamp->frame = CaptureDrawable (CreateDrawable (WANT_PIXMAP,
|
||||
framesize_rect.extent.width, framesize_rect.extent.height, 1));
|
||||
pStamp->frame = CaptureDrawable (CreateDrawable (
|
||||
WANT_PIXMAP, framesize_rect.extent.width,
|
||||
framesize_rect.extent.height, 1));
|
||||
pStamp->origin.x = framesize_rect.corner.x;
|
||||
pStamp->origin.y = framesize_rect.corner.y;
|
||||
tmp_rect.corner.x = 0;
|
||||
@@ -1396,7 +1399,8 @@ flash_rect_func (void *data)
|
||||
|
||||
if (fstrength != NORMAL_F_STRENGTH)
|
||||
{
|
||||
arith_frame_blit (cached_frame, &tmp_rect, pStamp->frame, NULL,
|
||||
arith_frame_blit (cached_frame, &tmp_rect,
|
||||
pStamp->frame, NULL,
|
||||
fstrength > 0 ? fstrength : -fstrength, 16);
|
||||
|
||||
if (fstrength < 0)
|
||||
@@ -1413,15 +1417,16 @@ flash_rect_func (void *data)
|
||||
}
|
||||
}
|
||||
|
||||
arith_frame_blit (cached_screen_frame, &framesize_rect, pStamp->frame,
|
||||
&tmp_rect, num, denom);
|
||||
arith_frame_blit (cached_screen_frame, &framesize_rect,
|
||||
pStamp->frame, &tmp_rect, num, denom);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#define MIN_STRENGTH 4
|
||||
#define MAX_STRENGTH 6
|
||||
if ((strength += 2) > MAX_STRENGTH)
|
||||
strength += 2;
|
||||
if (strength > MAX_STRENGTH)
|
||||
strength = MIN_STRENGTH;
|
||||
if (cached[strength - MIN_STRENGTH])
|
||||
pStamp = &cached_stamp[strength - MIN_STRENGTH];
|
||||
|
||||
Reference in New Issue
Block a user