From: <Mee...@us...> - 2009-10-25 01:12:30
|
Revision: 3250 http://sc2.svn.sourceforge.net/sc2/?rev=3250&view=rev Author: Meep-Eep Date: 2009-10-25 01:12:19 +0000 (Sun, 25 Oct 2009) Log Message: ----------- Switch main menu to the new threadless flashing code. Modified Paths: -------------- trunk/sc2/src/uqm/menustat.h trunk/sc2/src/uqm/restart.c trunk/sc2/src/uqm/sis.c Modified: trunk/sc2/src/uqm/menustat.h =================================================================== --- trunk/sc2/src/uqm/menustat.h 2009-10-25 01:11:41 UTC (rev 3249) +++ trunk/sc2/src/uqm/menustat.h 2009-10-25 01:12:19 UTC (rev 3250) @@ -22,8 +22,8 @@ #include "libs/gfxlib.h" #include "libs/sndlib.h" #include "libs/tasklib.h" +#include "flash.h" - typedef struct menu_state { BOOLEAN (*InputFunc) (struct menu_state *pMS); @@ -41,6 +41,7 @@ Task flash_task; RECT flash_rect0, flash_rect1; FRAME flash_frame0, flash_frame1; + FlashContext *flashContext; MUSIC_REF hMusic; Modified: trunk/sc2/src/uqm/restart.c =================================================================== --- trunk/sc2/src/uqm/restart.c 2009-10-25 01:11:41 UTC (rev 3249) +++ trunk/sc2/src/uqm/restart.c 2009-10-25 01:12:19 UTC (rev 3250) @@ -89,30 +89,15 @@ } 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 @@ /* 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 @@ } 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 @@ 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 @@ 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 @@ break; } - LockMutex (GraphicsLock); - SetFlashRect (NULL, (FRAME)0); - UnlockMutex (GraphicsLock); + Flash_pause(pMS->flashContext); - return (FALSE); + return FALSE; } else { @@ -236,7 +231,7 @@ if (NewState != pMS->CurState) { BatchGraphics (); - DrawRestartMenu (pMS->CurState, NewState, pMS->CurFrame); + DrawRestartMenu (pMS, NewState, pMS->CurFrame); UnbatchGraphics (); pMS->CurState = NewState; } @@ -244,18 +239,17 @@ 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 @@ pMS->hMusic = 0; } - LockMutex (GraphicsLock); - SetFlashRect (NULL, (FRAME)0); - UnlockMutex (GraphicsLock); + Flash_terminate (pMS->flashContext); DestroyDrawable (ReleaseDrawable (pMS->CurFrame)); if (GLOBAL (CurrentActivity) == (ACTIVITY)~0) Modified: trunk/sc2/src/uqm/sis.c =================================================================== --- trunk/sc2/src/uqm/sis.c 2009-10-25 01:11:41 UTC (rev 3249) +++ trunk/sc2/src/uqm/sis.c 2009-10-25 01:12:19 UTC (rev 3250) @@ -1341,11 +1341,12 @@ // 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, + arith_frame_blit (flash_screen_frame, &screen_rect, cached_screen_frame, NULL, 0, 0); UnlockMutex (flash_mutex); if (cached_frame) @@ -1370,7 +1371,8 @@ #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 @@ 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 @@ 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 @@ } } - 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]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |