From: <av...@us...> - 2009-12-08 22:46:22
|
Revision: 3408 http://sc2.svn.sourceforge.net/sc2/?rev=3408&view=rev Author: avolkov Date: 2009-12-08 22:46:15 +0000 (Tue, 08 Dec 2009) Log Message: ----------- Use SaveContextFrame() where appropriate Modified Paths: -------------- trunk/sc2/src/uqm/confirm.c trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/save.c trunk/sc2/src/uqm/util.c Modified: trunk/sc2/src/uqm/confirm.c =================================================================== --- trunk/sc2/src/uqm/confirm.c 2009-12-08 21:50:16 UTC (rev 3407) +++ trunk/sc2/src/uqm/confirm.c 2009-12-08 22:46:15 UTC (rev 3408) @@ -22,6 +22,7 @@ #include "setup.h" #include "sounds.h" #include "gamestr.h" +#include "util.h" #include "libs/graphics/widgets.h" #include "libs/sound/trackplayer.h" #include "libs/log.h" @@ -89,7 +90,7 @@ { RECT r; STAMP s; - FRAME F; + RECT ctxRect; CONTEXT oldContext; RECT oldRect; BOOLEAN response = FALSE, done; @@ -98,13 +99,12 @@ GetContextClipRect (&oldRect); SetContextClipRect (NULL); + GetContextClipRect (&ctxRect); r.extent.width = CONFIRM_WIN_WIDTH + 4; r.extent.height = CONFIRM_WIN_HEIGHT + 4; - r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1; - r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1; - s.origin = r.corner; - F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); - + r.corner.x = (ctxRect.extent.width - r.extent.width) >> 1; + r.corner.y = (ctxRect.extent.height - r.extent.height) >> 1; + s = SaveContextFrame (&r); SetSystemRect (&r); DrawConfirmationWindow (response); @@ -142,7 +142,7 @@ SleepThread (ONE_SECOND / 30); } while (!done); - s.frame = F; + // Restore the screen under the confirmation window DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); ClearSystemRect (); @@ -192,9 +192,7 @@ stringbank *bank = StringBank_Create (); const char *lines[30]; WIDGET_LABEL label; - RECT r; STAMP s; - FRAME F; CONTEXT oldContext; RECT oldRect; RECT windowRect; @@ -224,16 +222,10 @@ GetContextClipRect (&oldRect); SetContextClipRect (NULL); - /* TODO: Better measure of dimensions than this */ - r.extent.width = SCREEN_WIDTH; - r.extent.height = SCREEN_HEIGHT; - r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1; - r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1; - F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); + // TODO: Maybe DrawLabelAsWindow() should return a saved STAMP? + // We do not know the dimensions here, and so save the whole context + s = SaveContextFrame (NULL); - s.origin = r.corner; - s.frame = F; - Widget_SetFont (StarConFont); Widget_SetWindowColors (SHADOWBOX_BACKGROUND_COLOR, SHADOWBOX_DARK_COLOR, SHADOWBOX_MEDIUM_COLOR); Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2009-12-08 21:50:16 UTC (rev 3407) +++ trunk/sc2/src/uqm/gameopt.c 2009-12-08 22:46:15 UTC (rev 3408) @@ -78,12 +78,7 @@ r.extent.height += 8; if (MsgStamp) { - MsgStamp->origin = r.corner; - r.corner.x += clip_r.corner.x; - r.corner.y += clip_r.corner.y; - MsgStamp->frame = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); - r.corner.x -= clip_r.corner.x; - r.corner.y -= clip_r.corner.y; + *MsgStamp = SaveContextFrame (&r); } DrawStarConBox (&r, 2, BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19), Modified: trunk/sc2/src/uqm/save.c =================================================================== --- trunk/sc2/src/uqm/save.c 2009-12-08 21:50:16 UTC (rev 3407) +++ trunk/sc2/src/uqm/save.c 2009-12-08 22:46:15 UTC (rev 3408) @@ -536,6 +536,8 @@ TEXT t; UNICODE *ppStr[MAX_MSG_LINES]; + // TODO: This should probably just use DoPopupWindow() + ppStr[0] = GAME_STRING (SAVEGAME_STRING_BASE + 2); SetContextFont (StarConFont); @@ -566,17 +568,7 @@ r.extent.width += 8; r.extent.height += 8; - { - RECT clip_r; - - GetContextClipRect (&clip_r); - MsgStamp->origin = r.corner; - r.corner.x += clip_r.corner.x; - r.corner.y += clip_r.corner.y; - MsgStamp->frame = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); - r.corner.x -= clip_r.corner.x; - r.corner.y -= clip_r.corner.y; - } + *MsgStamp = SaveContextFrame (&r); BatchGraphics (); DrawStarConBox (&r, 2, @@ -613,9 +605,8 @@ WaitForAnyButton (TRUE, WAIT_INFINITE, FALSE); LockMutex (GraphicsLock); - BatchGraphics (); + // Restore the screen under the message DrawStamp (&s); - UnbatchGraphics (); SetContext (OldContext); DestroyDrawable (ReleaseDrawable (s.frame)); UnlockMutex (GraphicsLock); Modified: trunk/sc2/src/uqm/util.c =================================================================== --- trunk/sc2/src/uqm/util.c 2009-12-08 21:50:16 UTC (rev 3407) +++ trunk/sc2/src/uqm/util.c 2009-12-08 22:46:15 UTC (rev 3408) @@ -143,7 +143,8 @@ RECT r; STAMP s; CONTEXT OldContext; - FRAME F; + STAMP saveStamp; + RECT ctxRect; POINT oldOrigin; RECT OldRect; @@ -163,12 +164,15 @@ GetContextClipRect (&OldRect); SetContextClipRect (NULL); + GetContextClipRect (&ctxRect); GetFrameRect (ActivityFrame, &r); - r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1; - r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1; + r.corner.x = (ctxRect.extent.width - r.extent.width) >> 1; + r.corner.y = (ctxRect.extent.height - r.extent.height) >> 1; + saveStamp = SaveContextFrame (&r); + + // TODO: This should draw a localizable text message instead s.origin = r.corner; s.frame = ActivityFrame; - F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0)); SetSystemRect (&r); DrawStamp (&s); @@ -198,9 +202,8 @@ GamePaused = FALSE; - s.frame = F; - DrawStamp (&s); - DestroyDrawable (ReleaseDrawable (s.frame)); + DrawStamp (&saveStamp); + DestroyDrawable (ReleaseDrawable (saveStamp.frame)); ClearSystemRect (); SetContextClipRect (&OldRect); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |