Standardized context frame save/restore; not yet used everywhere it should be

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3345 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-11-23 11:03:41 +00:00
parent b48fe236bd
commit d4155e0ebe
4 changed files with 36 additions and 16 deletions
+2 -8
View File
@@ -1105,15 +1105,9 @@ PickGame (MENU_STATE *pMS)
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
OldContext = SetContext (SpaceContext); OldContext = SetContext (SpaceContext);
DlgStamp.origin.x = 0;
DlgStamp.origin.y = 0;
// Save the current state of the screen for later restoration // Save the current state of the screen for later restoration
DlgRect.corner.x = SIS_ORG_X; DlgStamp = SaveContextFrame (NULL);
DlgRect.corner.y = SIS_ORG_Y; GetContextClipRect (&DlgRect);
DlgRect.extent.width = SIS_SCREEN_WIDTH;
DlgRect.extent.height = SIS_SCREEN_HEIGHT;
DlgStamp.frame = CaptureDrawable (LoadDisplayPixmap (
&DlgRect, (FRAME)0));
pMS->Initialized = FALSE; pMS->Initialized = FALSE;
pMS->InputFunc = DoPickGame; pMS->InputFunc = DoPickGame;
+5 -8
View File
@@ -23,6 +23,7 @@
#include "../controls.h" #include "../controls.h"
#include "../gamestr.h" #include "../gamestr.h"
#include "../setup.h" #include "../setup.h"
#include "../util.h"
#include "../sounds.h" #include "../sounds.h"
#include "../uqmdebug.h" #include "../uqmdebug.h"
#include "options.h" #include "options.h"
@@ -238,6 +239,7 @@ DoDiscoveryReport (SOUND ReadOutSounds)
CONTEXT OldContext; CONTEXT OldContext;
CONTEXT context; CONTEXT context;
BOOLEAN ownContext; BOOLEAN ownContext;
STAMP saveStamp;
#ifdef DEBUG #ifdef DEBUG
if (disableInteractivity) if (disableInteractivity)
@@ -246,6 +248,7 @@ DoDiscoveryReport (SOUND ReadOutSounds)
context = GetScanContext (&ownContext); context = GetScanContext (&ownContext);
OldContext = SetContext (context); OldContext = SetContext (context);
saveStamp = SaveContextFrame (NULL);
{ {
FONT OldFont; FONT OldFont;
FRAME OldFontEffect; FRAME OldFontEffect;
@@ -265,14 +268,8 @@ DoDiscoveryReport (SOUND ReadOutSounds)
SetContextFontEffect (OldFontEffect); SetContextFontEffect (OldFontEffect);
SetContextFont (OldFont); SetContextFont (OldFont);
} }
#ifdef OLD // Restore previous screen
ClearDrawable (); DrawStamp (&saveStamp);
if (pSolarSysState->MenuState.Initialized >= 3)
DrawScannedObjects (FALSE);
#else /* !OLD */
if (pSolarSysState->MenuState.Initialized < 3)
ClearDrawable ();
#endif /* OLD */
SetContext (OldContext); SetContext (OldContext);
// TODO: Make CONTEXT ref-counted // TODO: Make CONTEXT ref-counted
if (ownContext) if (ownContext)
+26
View File
@@ -111,6 +111,32 @@ SeedRandomNumbers (void)
return (cur_time); return (cur_time);
} }
STAMP
SaveContextFrame (RECT *saveRect)
{
STAMP s;
RECT r;
GetContextClipRect (&r);
if (saveRect)
{ // a portion of the context
r.corner.x += saveRect->corner.x;
r.corner.y += saveRect->corner.y;
r.extent = saveRect->extent;
s.origin = saveRect->corner;
}
else
{ // the entire context
s.origin.x = 0;
s.origin.y = 0;
}
s.frame = CaptureDrawable (LoadDisplayPixmap (&r, NULL));
return s;
}
BOOLEAN BOOLEAN
PauseGame (void) PauseGame (void)
{ {
+3
View File
@@ -25,5 +25,8 @@ extern void DrawStarConBox (RECT *pRect, SIZE BorderWidth,
COLOR InteriorColor); COLOR InteriorColor);
extern DWORD SeedRandomNumbers (void); extern DWORD SeedRandomNumbers (void);
// saveRect can be NULL to save the entire context frame
extern STAMP SaveContextFrame (RECT *saveRect);
#endif /* _UTIL_H */ #endif /* _UTIL_H */