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