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:
+10
-18
@@ -22,6 +22,7 @@
|
|||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
#include "sounds.h"
|
#include "sounds.h"
|
||||||
#include "gamestr.h"
|
#include "gamestr.h"
|
||||||
|
#include "util.h"
|
||||||
#include "libs/graphics/widgets.h"
|
#include "libs/graphics/widgets.h"
|
||||||
#include "libs/sound/trackplayer.h"
|
#include "libs/sound/trackplayer.h"
|
||||||
#include "libs/log.h"
|
#include "libs/log.h"
|
||||||
@@ -89,7 +90,7 @@ DoConfirmExit (void)
|
|||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
STAMP s;
|
STAMP s;
|
||||||
FRAME F;
|
RECT ctxRect;
|
||||||
CONTEXT oldContext;
|
CONTEXT oldContext;
|
||||||
RECT oldRect;
|
RECT oldRect;
|
||||||
BOOLEAN response = FALSE, done;
|
BOOLEAN response = FALSE, done;
|
||||||
@@ -98,13 +99,12 @@ DoConfirmExit (void)
|
|||||||
GetContextClipRect (&oldRect);
|
GetContextClipRect (&oldRect);
|
||||||
SetContextClipRect (NULL);
|
SetContextClipRect (NULL);
|
||||||
|
|
||||||
|
GetContextClipRect (&ctxRect);
|
||||||
r.extent.width = CONFIRM_WIN_WIDTH + 4;
|
r.extent.width = CONFIRM_WIN_WIDTH + 4;
|
||||||
r.extent.height = CONFIRM_WIN_HEIGHT + 4;
|
r.extent.height = CONFIRM_WIN_HEIGHT + 4;
|
||||||
r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1;
|
r.corner.x = (ctxRect.extent.width - r.extent.width) >> 1;
|
||||||
r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1;
|
r.corner.y = (ctxRect.extent.height - r.extent.height) >> 1;
|
||||||
s.origin = r.corner;
|
s = SaveContextFrame (&r);
|
||||||
F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));
|
|
||||||
|
|
||||||
SetSystemRect (&r);
|
SetSystemRect (&r);
|
||||||
|
|
||||||
DrawConfirmationWindow (response);
|
DrawConfirmationWindow (response);
|
||||||
@@ -142,7 +142,7 @@ DoConfirmExit (void)
|
|||||||
SleepThread (ONE_SECOND / 30);
|
SleepThread (ONE_SECOND / 30);
|
||||||
} while (!done);
|
} while (!done);
|
||||||
|
|
||||||
s.frame = F;
|
// Restore the screen under the confirmation window
|
||||||
DrawStamp (&s);
|
DrawStamp (&s);
|
||||||
DestroyDrawable (ReleaseDrawable (s.frame));
|
DestroyDrawable (ReleaseDrawable (s.frame));
|
||||||
ClearSystemRect ();
|
ClearSystemRect ();
|
||||||
@@ -192,9 +192,7 @@ DoPopupWindow (const char *msg)
|
|||||||
stringbank *bank = StringBank_Create ();
|
stringbank *bank = StringBank_Create ();
|
||||||
const char *lines[30];
|
const char *lines[30];
|
||||||
WIDGET_LABEL label;
|
WIDGET_LABEL label;
|
||||||
RECT r;
|
|
||||||
STAMP s;
|
STAMP s;
|
||||||
FRAME F;
|
|
||||||
CONTEXT oldContext;
|
CONTEXT oldContext;
|
||||||
RECT oldRect;
|
RECT oldRect;
|
||||||
RECT windowRect;
|
RECT windowRect;
|
||||||
@@ -224,15 +222,9 @@ DoPopupWindow (const char *msg)
|
|||||||
GetContextClipRect (&oldRect);
|
GetContextClipRect (&oldRect);
|
||||||
SetContextClipRect (NULL);
|
SetContextClipRect (NULL);
|
||||||
|
|
||||||
/* TODO: Better measure of dimensions than this */
|
// TODO: Maybe DrawLabelAsWindow() should return a saved STAMP?
|
||||||
r.extent.width = SCREEN_WIDTH;
|
// We do not know the dimensions here, and so save the whole context
|
||||||
r.extent.height = SCREEN_HEIGHT;
|
s = SaveContextFrame (NULL);
|
||||||
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;
|
|
||||||
|
|
||||||
Widget_SetFont (StarConFont);
|
Widget_SetFont (StarConFont);
|
||||||
Widget_SetWindowColors (SHADOWBOX_BACKGROUND_COLOR, SHADOWBOX_DARK_COLOR,
|
Widget_SetWindowColors (SHADOWBOX_BACKGROUND_COLOR, SHADOWBOX_DARK_COLOR,
|
||||||
|
|||||||
@@ -78,12 +78,7 @@ ConfirmSaveLoad (STAMP *MsgStamp)
|
|||||||
r.extent.height += 8;
|
r.extent.height += 8;
|
||||||
if (MsgStamp)
|
if (MsgStamp)
|
||||||
{
|
{
|
||||||
MsgStamp->origin = r.corner;
|
*MsgStamp = SaveContextFrame (&r);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
DrawStarConBox (&r, 2,
|
DrawStarConBox (&r, 2,
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19),
|
BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19),
|
||||||
|
|||||||
+4
-13
@@ -536,6 +536,8 @@ SaveProblemMessage (STAMP *MsgStamp)
|
|||||||
TEXT t;
|
TEXT t;
|
||||||
UNICODE *ppStr[MAX_MSG_LINES];
|
UNICODE *ppStr[MAX_MSG_LINES];
|
||||||
|
|
||||||
|
// TODO: This should probably just use DoPopupWindow()
|
||||||
|
|
||||||
ppStr[0] = GAME_STRING (SAVEGAME_STRING_BASE + 2);
|
ppStr[0] = GAME_STRING (SAVEGAME_STRING_BASE + 2);
|
||||||
|
|
||||||
SetContextFont (StarConFont);
|
SetContextFont (StarConFont);
|
||||||
@@ -566,17 +568,7 @@ SaveProblemMessage (STAMP *MsgStamp)
|
|||||||
r.extent.width += 8;
|
r.extent.width += 8;
|
||||||
r.extent.height += 8;
|
r.extent.height += 8;
|
||||||
|
|
||||||
{
|
*MsgStamp = SaveContextFrame (&r);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
BatchGraphics ();
|
BatchGraphics ();
|
||||||
DrawStarConBox (&r, 2,
|
DrawStarConBox (&r, 2,
|
||||||
@@ -613,9 +605,8 @@ SaveProblem (void)
|
|||||||
WaitForAnyButton (TRUE, WAIT_INFINITE, FALSE);
|
WaitForAnyButton (TRUE, WAIT_INFINITE, FALSE);
|
||||||
|
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
BatchGraphics ();
|
// Restore the screen under the message
|
||||||
DrawStamp (&s);
|
DrawStamp (&s);
|
||||||
UnbatchGraphics ();
|
|
||||||
SetContext (OldContext);
|
SetContext (OldContext);
|
||||||
DestroyDrawable (ReleaseDrawable (s.frame));
|
DestroyDrawable (ReleaseDrawable (s.frame));
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
|
|||||||
+10
-7
@@ -143,7 +143,8 @@ PauseGame (void)
|
|||||||
RECT r;
|
RECT r;
|
||||||
STAMP s;
|
STAMP s;
|
||||||
CONTEXT OldContext;
|
CONTEXT OldContext;
|
||||||
FRAME F;
|
STAMP saveStamp;
|
||||||
|
RECT ctxRect;
|
||||||
POINT oldOrigin;
|
POINT oldOrigin;
|
||||||
RECT OldRect;
|
RECT OldRect;
|
||||||
|
|
||||||
@@ -163,12 +164,15 @@ PauseGame (void)
|
|||||||
GetContextClipRect (&OldRect);
|
GetContextClipRect (&OldRect);
|
||||||
SetContextClipRect (NULL);
|
SetContextClipRect (NULL);
|
||||||
|
|
||||||
|
GetContextClipRect (&ctxRect);
|
||||||
GetFrameRect (ActivityFrame, &r);
|
GetFrameRect (ActivityFrame, &r);
|
||||||
r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1;
|
r.corner.x = (ctxRect.extent.width - r.extent.width) >> 1;
|
||||||
r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 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.origin = r.corner;
|
||||||
s.frame = ActivityFrame;
|
s.frame = ActivityFrame;
|
||||||
F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));
|
|
||||||
SetSystemRect (&r);
|
SetSystemRect (&r);
|
||||||
DrawStamp (&s);
|
DrawStamp (&s);
|
||||||
|
|
||||||
@@ -198,9 +202,8 @@ PauseGame (void)
|
|||||||
|
|
||||||
GamePaused = FALSE;
|
GamePaused = FALSE;
|
||||||
|
|
||||||
s.frame = F;
|
DrawStamp (&saveStamp);
|
||||||
DrawStamp (&s);
|
DestroyDrawable (ReleaseDrawable (saveStamp.frame));
|
||||||
DestroyDrawable (ReleaseDrawable (s.frame));
|
|
||||||
ClearSystemRect ();
|
ClearSystemRect ();
|
||||||
|
|
||||||
SetContextClipRect (&OldRect);
|
SetContextClipRect (&OldRect);
|
||||||
|
|||||||
Reference in New Issue
Block a user