Give rotating planet and lander views their own CONTEXT
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3497 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -141,10 +141,9 @@ extern PRIM_LINKS DisplayLinks;
|
||||
|
||||
#define DEATH_EXPLOSION 0
|
||||
|
||||
#define SURFACE_X SIS_ORG_X
|
||||
#define SURFACE_Y SIS_ORG_Y
|
||||
// TODO: redefine these in terms of CONTEXT width/height
|
||||
#define SURFACE_WIDTH SIS_SCREEN_WIDTH
|
||||
#define SURFACE_HEIGHT (SIS_SCREEN_HEIGHT - MAP_HEIGHT - 5)
|
||||
#define SURFACE_HEIGHT (SIS_SCREEN_HEIGHT - MAP_HEIGHT - MAP_BORDER_HEIGHT)
|
||||
|
||||
#define REPAIR_LANDER (1 << 7)
|
||||
#define REPAIR_TRANSITION (1 << 6)
|
||||
@@ -1198,7 +1197,7 @@ ScrollPlanetSide (SIZE dx, SIZE dy, int landingOffset)
|
||||
curLanderLoc = new_pt;
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
OldContext = SetContext (SpaceContext);
|
||||
OldContext = SetContext (PlanetContext);
|
||||
|
||||
BatchGraphics ();
|
||||
|
||||
@@ -1335,7 +1334,7 @@ AnimateLaunch (FRAME farray)
|
||||
TimeCount NextTime;
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetContext (SpaceContext);
|
||||
SetContext (PlanetContext);
|
||||
|
||||
r.corner.x = 0;
|
||||
r.corner.y = 0;
|
||||
@@ -1474,17 +1473,13 @@ InitPlanetSide (POINT pt)
|
||||
curLanderLoc = pt;
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetContext (SpaceContext);
|
||||
SetContext (PlanetContext);
|
||||
SetContextFont (TinyFont);
|
||||
|
||||
{
|
||||
RECT r;
|
||||
|
||||
r.corner.x = SURFACE_X;
|
||||
r.corner.y = SURFACE_Y;
|
||||
r.extent.width = SURFACE_WIDTH;
|
||||
r.extent.height = SURFACE_HEIGHT;
|
||||
SetContextClipRect (&r);
|
||||
GetContextClipRect (&r);
|
||||
|
||||
SetTransitionSource (&r);
|
||||
BatchGraphics ();
|
||||
@@ -1802,20 +1797,21 @@ SetPlanetMusic (BYTE planet_type)
|
||||
}
|
||||
|
||||
static void
|
||||
ReturnToOrbit (RECT *pRect)
|
||||
ReturnToOrbit (void)
|
||||
{
|
||||
CONTEXT OldContext;
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
OldContext = SetContext (SpaceContext);
|
||||
SetContextClipRect (pRect);
|
||||
RECT r;
|
||||
|
||||
SetTransitionSource (pRect);
|
||||
LockMutex (GraphicsLock);
|
||||
OldContext = SetContext (PlanetContext);
|
||||
GetContextClipRect (&r);
|
||||
|
||||
SetTransitionSource (&r);
|
||||
BatchGraphics ();
|
||||
DrawStarBackGround ();
|
||||
DrawPlanetSurfaceBorder ();
|
||||
RedrawSurfaceScan (NULL);
|
||||
ScreenTransition (3, pRect);
|
||||
ScreenTransition (3, &r);
|
||||
UnbatchGraphics ();
|
||||
|
||||
SetContext (OldContext);
|
||||
@@ -1983,13 +1979,6 @@ PlanetSide (POINT planetLoc)
|
||||
|
||||
if (!(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
||||
{
|
||||
RECT r;
|
||||
//CONTEXT OldContext;
|
||||
|
||||
r.corner.x = SIS_ORG_X;
|
||||
r.corner.y = SIS_ORG_Y;
|
||||
r.extent.width = SIS_SCREEN_WIDTH;
|
||||
r.extent.height = SIS_SCREEN_HEIGHT;
|
||||
if (crew_left == 0)
|
||||
{
|
||||
--GLOBAL_SIS (NumLanders);
|
||||
@@ -1997,7 +1986,7 @@ PlanetSide (POINT planetLoc)
|
||||
DrawLanders ();
|
||||
UnlockMutex (GraphicsLock);
|
||||
|
||||
ReturnToOrbit (&r);
|
||||
ReturnToOrbit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2006,7 +1995,7 @@ PlanetSide (POINT planetLoc)
|
||||
NotPositional (), NULL, GAME_SOUND_PRIORITY + 1);
|
||||
|
||||
LandingTakeoffSequence (&landerInputState, FALSE);
|
||||
ReturnToOrbit (&r);
|
||||
ReturnToOrbit ();
|
||||
AnimateLaunch (LanderFrame[6]);
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
|
||||
@@ -64,7 +64,7 @@ DrawDefaultPlanetSphere (void)
|
||||
{
|
||||
CONTEXT oldContext;
|
||||
|
||||
oldContext = SetContext (SpaceContext);
|
||||
oldContext = SetContext (PlanetContext);
|
||||
DrawPlanetSphere (SIS_SCREEN_WIDTH / 2, PLANET_ORG_Y);
|
||||
SetContext (oldContext);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ ZoomInPlanetSphere (void)
|
||||
* (SCAN_SCREEN_HEIGHT * 6 / 10) + 0.5);
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetContext (SpaceContext);
|
||||
SetContext (PlanetContext);
|
||||
|
||||
BatchGraphics ();
|
||||
if (i > 0)
|
||||
|
||||
@@ -48,6 +48,42 @@ enum PlanetMenuItems
|
||||
NAVIGATION,
|
||||
};
|
||||
|
||||
CONTEXT PlanetContext;
|
||||
// Context for rotating planet view and lander surface view
|
||||
|
||||
static void
|
||||
CreatePlanetContext (void)
|
||||
{
|
||||
CONTEXT oldContext;
|
||||
RECT r;
|
||||
|
||||
assert (PlanetContext == NULL);
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
|
||||
// PlanetContext rect is relative to SpaceContext
|
||||
oldContext = SetContext (SpaceContext);
|
||||
GetContextClipRect (&r);
|
||||
|
||||
PlanetContext = CreateContext ("PlanetContext");
|
||||
SetContext (PlanetContext);
|
||||
SetContextFGFrame (Screen);
|
||||
r.extent.height -= MAP_HEIGHT + MAP_BORDER_HEIGHT;
|
||||
SetContextClipRect (&r);
|
||||
|
||||
SetContext (oldContext);
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
|
||||
void
|
||||
DestroyPlanetContext (void)
|
||||
{
|
||||
if (PlanetContext)
|
||||
{
|
||||
DestroyContext (PlanetContext);
|
||||
PlanetContext = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DrawScannedObjects (BOOLEAN Reversed)
|
||||
@@ -223,6 +259,8 @@ LoadPlanet (FRAME SurfDefFrame)
|
||||
|
||||
assert (pSolarSysState->InOrbit && !pSolarSysState->TopoFrame);
|
||||
|
||||
CreatePlanetContext ();
|
||||
|
||||
if (WaitMode)
|
||||
{
|
||||
LockMutex (GraphicsLock);
|
||||
@@ -309,6 +347,12 @@ FreePlanet (void)
|
||||
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0;
|
||||
FreeLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
|
||||
|
||||
// Need to make sure our own CONTEXTs are not active because
|
||||
// we will destroy them now
|
||||
SetContext (SpaceContext);
|
||||
DestroyPlanetContext ();
|
||||
DestroyScanContext ();
|
||||
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
|
||||
@@ -459,10 +503,6 @@ PlanetOrbitMenu (void)
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetFlashRect (NULL);
|
||||
// Need to make sure ScanContext is not active because we will destroy it
|
||||
SetContext (SpaceContext);
|
||||
UnlockMutex (GraphicsLock);
|
||||
DrawMenuStateStrings (PM_STARMAP, -NAVIGATION);
|
||||
|
||||
DestroyScanContext ();
|
||||
}
|
||||
|
||||
@@ -227,6 +227,7 @@ struct solarsys_state
|
||||
|
||||
extern SOLARSYS_STATE *pSolarSysState;
|
||||
extern MUSIC_REF SpaceMusic;
|
||||
extern CONTEXT PlanetContext;
|
||||
|
||||
bool playerInSolarSystem (void);
|
||||
bool playerInPlanetOrbit (void);
|
||||
|
||||
+16
-24
@@ -85,23 +85,14 @@ RepairBackRect (RECT *pRect)
|
||||
static void
|
||||
EraseCoarseScan (void)
|
||||
{
|
||||
RECT oldClipRect;
|
||||
RECT clipRect;
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetContext (SpaceContext);
|
||||
// TODO: Give coarse scan an own context
|
||||
GetContextClipRect (&oldClipRect);
|
||||
clipRect = oldClipRect;
|
||||
clipRect.extent.height = SCAN_SCREEN_HEIGHT;
|
||||
SetContextClipRect (&clipRect);
|
||||
SetContext (PlanetContext);
|
||||
|
||||
BatchGraphics ();
|
||||
DrawStarBackGround ();
|
||||
DrawDefaultPlanetSphere ();
|
||||
UnbatchGraphics ();
|
||||
|
||||
SetContextClipRect (&oldClipRect);
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
|
||||
@@ -170,7 +161,7 @@ PrintCoarseScanPC (void)
|
||||
GetPlanetTitle (buf, sizeof (buf));
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetContext (SpaceContext);
|
||||
SetContext (PlanetContext);
|
||||
|
||||
t.align = ALIGN_CENTER;
|
||||
t.baseline.x = SIS_SCREEN_WIDTH >> 1;
|
||||
@@ -355,7 +346,7 @@ PrintCoarseScan3DO (void)
|
||||
GetPlanetTitle (buf, sizeof (buf));
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetContext (SpaceContext);
|
||||
SetContext (PlanetContext);
|
||||
|
||||
t.align = ALIGN_CENTER;
|
||||
t.baseline.x = SIS_SCREEN_WIDTH >> 1;
|
||||
@@ -1019,11 +1010,13 @@ ScanPlanet (COUNT scanType)
|
||||
t.pStr = GAME_STRING (SCAN_STRING_BASE + scan);
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetContext (SpaceContext);
|
||||
SetContext (PlanetContext);
|
||||
r.corner.x = 0;
|
||||
r.corner.y = t.baseline.y - 10;
|
||||
r.extent.width = SIS_SCREEN_WIDTH;
|
||||
r.extent.height = t.baseline.y - r.corner.y + 1;
|
||||
// XXX: I do not know why we are repairing it here, as there
|
||||
// should not be anything drawn over the stars at the moment
|
||||
RepairBackRect (&r);
|
||||
|
||||
SetContextFont (MicroFont);
|
||||
@@ -1073,12 +1066,7 @@ ScanPlanet (COUNT scanType)
|
||||
}
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
SetContext (SpaceContext);
|
||||
r.corner.x = 0;
|
||||
r.corner.y = (SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7) - 10;
|
||||
r.extent.width = SIS_SCREEN_WIDTH;
|
||||
r.extent.height = (SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7)
|
||||
- r.corner.y + 1;
|
||||
SetContext (PlanetContext);
|
||||
RepairBackRect (&r);
|
||||
|
||||
SetContext (ScanContext);
|
||||
@@ -1177,12 +1165,15 @@ CreateScanContext (void)
|
||||
CONTEXT context;
|
||||
RECT r;
|
||||
|
||||
// ScanContext rect is relative to SpaceContext
|
||||
oldContext = SetContext (SpaceContext);
|
||||
GetContextClipRect (&r);
|
||||
|
||||
context = CreateContext ("ScanContext");
|
||||
oldContext = SetContext (context);
|
||||
|
||||
SetContext (context);
|
||||
SetContextFGFrame (Screen);
|
||||
r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH;
|
||||
r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT;
|
||||
r.corner.x += r.extent.width - MAP_WIDTH;
|
||||
r.corner.y += r.extent.height - MAP_HEIGHT;
|
||||
r.extent.width = MAP_WIDTH;
|
||||
r.extent.height = MAP_HEIGHT;
|
||||
SetContextClipRect (&r);
|
||||
@@ -1227,7 +1218,9 @@ ScanSystem (void)
|
||||
|
||||
memset (&MenuState, 0, sizeof MenuState);
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
GetScanContext (NULL);
|
||||
UnlockMutex (GraphicsLock);
|
||||
|
||||
if (optWhichMenu == OPT_3DO &&
|
||||
((pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED)
|
||||
@@ -1273,7 +1266,6 @@ ScanSystem (void)
|
||||
BatchGraphics ();
|
||||
SetContext (ScanContext);
|
||||
DrawPlanet (0, BLACK_COLOR);
|
||||
SetContext (SpaceContext);
|
||||
EraseCoarseScan ();
|
||||
UnbatchGraphics ();
|
||||
UnlockMutex (GraphicsLock);
|
||||
|
||||
Reference in New Issue
Block a user