Use SaveContextFrame() where appropriate

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3408 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-12-08 22:46:15 +00:00
parent 939fc2e5db
commit 63f66cf010
4 changed files with 25 additions and 44 deletions
+10 -18
View File
@@ -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 @@ DoConfirmExit (void)
{
RECT r;
STAMP s;
FRAME F;
RECT ctxRect;
CONTEXT oldContext;
RECT oldRect;
BOOLEAN response = FALSE, done;
@@ -98,13 +99,12 @@ DoConfirmExit (void)
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 @@ DoConfirmExit (void)
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 @@ DoPopupWindow (const char *msg)
stringbank *bank = StringBank_Create ();
const char *lines[30];
WIDGET_LABEL label;
RECT r;
STAMP s;
FRAME F;
CONTEXT oldContext;
RECT oldRect;
RECT windowRect;
@@ -224,15 +222,9 @@ DoPopupWindow (const char *msg)
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));
s.origin = r.corner;
s.frame = F;
// TODO: Maybe DrawLabelAsWindow() should return a saved STAMP?
// We do not know the dimensions here, and so save the whole context
s = SaveContextFrame (NULL);
Widget_SetFont (StarConFont);
Widget_SetWindowColors (SHADOWBOX_BACKGROUND_COLOR, SHADOWBOX_DARK_COLOR,
+1 -6
View File
@@ -78,12 +78,7 @@ ConfirmSaveLoad (STAMP *MsgStamp)
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),
+4 -13
View File
@@ -536,6 +536,8 @@ SaveProblemMessage (STAMP *MsgStamp)
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 @@ SaveProblemMessage (STAMP *MsgStamp)
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 @@ SaveProblem (void)
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);
+10 -7
View File
@@ -143,7 +143,8 @@ PauseGame (void)
RECT r;
STAMP s;
CONTEXT OldContext;
FRAME F;
STAMP saveStamp;
RECT ctxRect;
POINT oldOrigin;
RECT OldRect;
@@ -163,12 +164,15 @@ PauseGame (void)
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 @@ PauseGame (void)
GamePaused = FALSE;
s.frame = F;
DrawStamp (&s);
DestroyDrawable (ReleaseDrawable (s.frame));
DrawStamp (&saveStamp);
DestroyDrawable (ReleaseDrawable (saveStamp.frame));
ClearSystemRect ();
SetContextClipRect (&OldRect);