From: <av...@us...> - 2009-11-23 11:03:50
|
Revision: 3345 http://sc2.svn.sourceforge.net/sc2/?rev=3345&view=rev Author: avolkov Date: 2009-11-23 11:03:41 +0000 (Mon, 23 Nov 2009) Log Message: ----------- Standardized context frame save/restore; not yet used everywhere it should be Modified Paths: -------------- trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/planets/report.c trunk/sc2/src/uqm/util.c trunk/sc2/src/uqm/util.h Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2009-11-23 09:50:33 UTC (rev 3344) +++ trunk/sc2/src/uqm/gameopt.c 2009-11-23 11:03:41 UTC (rev 3345) @@ -1105,15 +1105,9 @@ LockMutex (GraphicsLock); OldContext = SetContext (SpaceContext); - DlgStamp.origin.x = 0; - DlgStamp.origin.y = 0; // Save the current state of the screen for later restoration - DlgRect.corner.x = SIS_ORG_X; - DlgRect.corner.y = SIS_ORG_Y; - DlgRect.extent.width = SIS_SCREEN_WIDTH; - DlgRect.extent.height = SIS_SCREEN_HEIGHT; - DlgStamp.frame = CaptureDrawable (LoadDisplayPixmap ( - &DlgRect, (FRAME)0)); + DlgStamp = SaveContextFrame (NULL); + GetContextClipRect (&DlgRect); pMS->Initialized = FALSE; pMS->InputFunc = DoPickGame; Modified: trunk/sc2/src/uqm/planets/report.c =================================================================== --- trunk/sc2/src/uqm/planets/report.c 2009-11-23 09:50:33 UTC (rev 3344) +++ trunk/sc2/src/uqm/planets/report.c 2009-11-23 11:03:41 UTC (rev 3345) @@ -23,6 +23,7 @@ #include "../controls.h" #include "../gamestr.h" #include "../setup.h" +#include "../util.h" #include "../sounds.h" #include "../uqmdebug.h" #include "options.h" @@ -238,6 +239,7 @@ CONTEXT OldContext; CONTEXT context; BOOLEAN ownContext; + STAMP saveStamp; #ifdef DEBUG if (disableInteractivity) @@ -246,6 +248,7 @@ context = GetScanContext (&ownContext); OldContext = SetContext (context); + saveStamp = SaveContextFrame (NULL); { FONT OldFont; FRAME OldFontEffect; @@ -265,14 +268,8 @@ SetContextFontEffect (OldFontEffect); SetContextFont (OldFont); } -#ifdef OLD - ClearDrawable (); - if (pSolarSysState->MenuState.Initialized >= 3) - DrawScannedObjects (FALSE); -#else /* !OLD */ - if (pSolarSysState->MenuState.Initialized < 3) - ClearDrawable (); -#endif /* OLD */ + // Restore previous screen + DrawStamp (&saveStamp); SetContext (OldContext); // TODO: Make CONTEXT ref-counted if (ownContext) Modified: trunk/sc2/src/uqm/util.c =================================================================== --- trunk/sc2/src/uqm/util.c 2009-11-23 09:50:33 UTC (rev 3344) +++ trunk/sc2/src/uqm/util.c 2009-11-23 11:03:41 UTC (rev 3345) @@ -111,6 +111,32 @@ 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 PauseGame (void) { Modified: trunk/sc2/src/uqm/util.h =================================================================== --- trunk/sc2/src/uqm/util.h 2009-11-23 09:50:33 UTC (rev 3344) +++ trunk/sc2/src/uqm/util.h 2009-11-23 11:03:41 UTC (rev 3345) @@ -25,5 +25,8 @@ COLOR InteriorColor); extern DWORD SeedRandomNumbers (void); +// saveRect can be NULL to save the entire context frame +extern STAMP SaveContextFrame (RECT *saveRect); + #endif /* _UTIL_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |