- use a separate variable pointing to the current level for the UI code.
UI always runs on the primary level, so this does not need the ability to operate on multiple levels. Additionally, this can later be set to null when running play code so that scope violations result in an abort.
This commit is contained in:
parent
ba114f6f23
commit
4e052f2857
21 changed files with 107 additions and 103 deletions
|
|
@ -153,7 +153,8 @@ extern bool sendpause, sendsave, sendturn180, SendLand;
|
|||
|
||||
void *statcopy; // for statistics driver
|
||||
|
||||
FLevelLocals level; // info about current level
|
||||
FLevelLocals level; // info about current level
|
||||
FLevelLocals *currentUILevel = &level; // level for which to display the user interface.
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
|||
|
|
@ -413,9 +413,9 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#ifndef NO_DEFINE_LEVEL
|
||||
|
||||
extern FLevelLocals level;
|
||||
extern FLevelLocals *currentUILevel; // level for which to display the user interface. This will always be the one the current consoleplayer is in.
|
||||
|
||||
inline FSectorPortal *line_t::GetTransferredPortal()
|
||||
{
|
||||
|
|
@ -510,4 +510,3 @@ inline bool line_t::hitSkyWall(AActor* mo) const
|
|||
backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
|
||||
mo->Z() >= backsector->ceilingplane.ZatPoint(mo->PosRelative(this));
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -516,7 +516,6 @@ DBaseStatusBar *CreateCustomStatusBar(int script=0);
|
|||
|
||||
// Crosshair stuff ----------------------------------------------------------
|
||||
|
||||
void ST_FormatMapName(FString &mapname, const char *mapnamecolor = "");
|
||||
void ST_LoadCrosshair(bool alwaysload=false);
|
||||
void ST_Clear();
|
||||
void ST_CreateStatusBar(bool bTitleLevel);
|
||||
|
|
|
|||
|
|
@ -1075,7 +1075,7 @@ public:
|
|||
lastHud = hud;
|
||||
|
||||
// Handle inventory bar drawing
|
||||
if(CPlayer->inventorytics > 0 && !(level.flags & LEVEL_NOINVENTORYBAR) && (state == HUD_StatusBar || state == HUD_Fullscreen))
|
||||
if(CPlayer->inventorytics > 0 && !(currentUILevel->flags & LEVEL_NOINVENTORYBAR) && (state == HUD_StatusBar || state == HUD_Fullscreen))
|
||||
{
|
||||
SBarInfoMainBlock *inventoryBar = state == HUD_StatusBar ? script->huds[STBAR_INVENTORY] : script->huds[STBAR_INVENTORYFULLSCREEN];
|
||||
if(inventoryBar != lastInventoryBar)
|
||||
|
|
|
|||
|
|
@ -850,26 +850,26 @@ class CommandDrawString : public SBarInfoCommand
|
|||
switch(strValue)
|
||||
{
|
||||
case LEVELNAME:
|
||||
if(level.lumpnum != cache)
|
||||
if(currentUILevel->lumpnum != cache)
|
||||
{
|
||||
cache = level.lumpnum;
|
||||
str = level.LevelName;
|
||||
cache = currentUILevel->lumpnum;
|
||||
str = currentUILevel->LevelName;
|
||||
RealignString();
|
||||
}
|
||||
break;
|
||||
case LEVELLUMP:
|
||||
if(level.lumpnum != cache)
|
||||
if(currentUILevel->lumpnum != cache)
|
||||
{
|
||||
cache = level.lumpnum;
|
||||
str = level.MapName;
|
||||
cache = currentUILevel->lumpnum;
|
||||
str = currentUILevel->MapName;
|
||||
str.ToUpper();
|
||||
RealignString();
|
||||
}
|
||||
break;
|
||||
case SKILLNAME:
|
||||
if(level.lumpnum != cache) // Can only change skill between level.
|
||||
if(currentUILevel->lumpnum != cache) // Can only change skill between currentUILevel->
|
||||
{
|
||||
cache = level.lumpnum;
|
||||
cache = currentUILevel->lumpnum;
|
||||
str = G_SkillName();
|
||||
RealignString();
|
||||
}
|
||||
|
|
@ -904,7 +904,7 @@ class CommandDrawString : public SBarInfoCommand
|
|||
if(ACS_GlobalVars[valueArgument] != cache)
|
||||
{
|
||||
cache = ACS_GlobalVars[valueArgument];
|
||||
str = level.Behaviors.LookupString(ACS_GlobalVars[valueArgument]);
|
||||
str = currentUILevel->Behaviors.LookupString(ACS_GlobalVars[valueArgument]);
|
||||
RealignString();
|
||||
}
|
||||
break;
|
||||
|
|
@ -912,13 +912,13 @@ class CommandDrawString : public SBarInfoCommand
|
|||
if(ACS_GlobalArrays[valueArgument][consoleplayer] != cache)
|
||||
{
|
||||
cache = ACS_GlobalArrays[valueArgument][consoleplayer];
|
||||
str = level.Behaviors.LookupString(ACS_GlobalArrays[valueArgument][consoleplayer]);
|
||||
str = currentUILevel->Behaviors.LookupString(ACS_GlobalArrays[valueArgument][consoleplayer]);
|
||||
RealignString();
|
||||
}
|
||||
break;
|
||||
case TIME:
|
||||
{
|
||||
int sec = Tics2Seconds(level.time);
|
||||
int sec = Tics2Seconds(currentUILevel->time);
|
||||
str.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1389,25 +1389,25 @@ class CommandDrawNumber : public CommandDrawString
|
|||
num = statusBar->CPlayer->fragcount;
|
||||
break;
|
||||
case KILLS:
|
||||
num = level.killed_monsters;
|
||||
num = currentUILevel->killed_monsters;
|
||||
break;
|
||||
case MONSTERS:
|
||||
num = level.total_monsters;
|
||||
num = currentUILevel->total_monsters;
|
||||
break;
|
||||
case ITEMS:
|
||||
num = level.found_items;
|
||||
num = currentUILevel->found_items;
|
||||
break;
|
||||
case TOTALITEMS:
|
||||
num = level.total_items;
|
||||
num = currentUILevel->total_items;
|
||||
break;
|
||||
case SECRETS:
|
||||
num = level.found_secrets;
|
||||
num = currentUILevel->found_secrets;
|
||||
break;
|
||||
case SCORE:
|
||||
num = statusBar->CPlayer->mo->Score;
|
||||
break;
|
||||
case TOTALSECRETS:
|
||||
num = level.total_secrets;
|
||||
num = currentUILevel->total_secrets;
|
||||
break;
|
||||
case ARMORCLASS:
|
||||
case SAVEPERCENT:
|
||||
|
|
@ -1459,9 +1459,9 @@ class CommandDrawNumber : public CommandDrawString
|
|||
case AIRTIME:
|
||||
{
|
||||
if(statusBar->CPlayer->mo->waterlevel < 3)
|
||||
num = level.airsupply/TICRATE;
|
||||
num = currentUILevel->airsupply/TICRATE;
|
||||
else
|
||||
num = clamp<int>((statusBar->CPlayer->air_finished - level.time + (TICRATE-1))/TICRATE, 0, INT_MAX);
|
||||
num = clamp<int>((statusBar->CPlayer->air_finished - currentUILevel->time + (TICRATE-1))/TICRATE, 0, INT_MAX);
|
||||
break;
|
||||
}
|
||||
case SELECTEDINVENTORY:
|
||||
|
|
@ -1502,7 +1502,7 @@ class CommandDrawNumber : public CommandDrawString
|
|||
}
|
||||
default: break;
|
||||
}
|
||||
if(interpolationSpeed != 0 && (!hudChanged || level.time == 1))
|
||||
if(interpolationSpeed != 0 && (!hudChanged || currentUILevel->time == 1))
|
||||
{
|
||||
if(num < drawValue)
|
||||
drawValue -= clamp<int>((drawValue - num) >> 2, 1, interpolationSpeed);
|
||||
|
|
@ -1691,7 +1691,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
|
|||
if(alternateOnEmpty)
|
||||
SBarInfoCommandFlowControl::Draw(block, statusBar);
|
||||
|
||||
if(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel) != NULL && !(level.flags & LEVEL_NOINVENTORYBAR))
|
||||
if(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel) != NULL && !(currentUILevel->flags & LEVEL_NOINVENTORYBAR))
|
||||
{
|
||||
if(artiflash && statusBar->wrapper->artiflashTick)
|
||||
{
|
||||
|
|
@ -1791,7 +1791,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
|
|||
{
|
||||
SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged);
|
||||
|
||||
SetTruth(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel) == NULL || (level.flags & LEVEL_NOINVENTORYBAR), block, statusBar);
|
||||
SetTruth(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel) == NULL || (currentUILevel->flags & LEVEL_NOINVENTORYBAR), block, statusBar);
|
||||
|
||||
CommandDrawImage::Tick(block, statusBar, hudChanged);
|
||||
CommandDrawNumber::Tick(block, statusBar, hudChanged);
|
||||
|
|
@ -1910,7 +1910,7 @@ class CommandInventoryBarNotVisible : public SBarInfoCommandFlowControl
|
|||
{
|
||||
SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged);
|
||||
|
||||
SetTruth(statusBar->CPlayer->inventorytics <= 0 || (level.flags & LEVEL_NOINVENTORYBAR), block, statusBar);
|
||||
SetTruth(statusBar->CPlayer->inventorytics <= 0 || (currentUILevel->flags & LEVEL_NOINVENTORYBAR), block, statusBar);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -2727,16 +2727,16 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
max = fraglimit;
|
||||
break;
|
||||
case KILLS:
|
||||
value = level.killed_monsters;
|
||||
max = level.total_monsters;
|
||||
value = currentUILevel->killed_monsters;
|
||||
max = currentUILevel->total_monsters;
|
||||
break;
|
||||
case ITEMS:
|
||||
value = level.found_items;
|
||||
max = level.total_items;
|
||||
value = currentUILevel->found_items;
|
||||
max = currentUILevel->total_items;
|
||||
break;
|
||||
case SECRETS:
|
||||
value = level.found_secrets;
|
||||
max = level.total_secrets;
|
||||
value = currentUILevel->found_secrets;
|
||||
max = currentUILevel->total_secrets;
|
||||
break;
|
||||
case INVENTORY:
|
||||
{
|
||||
|
|
@ -2751,8 +2751,8 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
break;
|
||||
}
|
||||
case AIRTIME:
|
||||
value = clamp<int>(statusBar->CPlayer->air_finished - level.time, 0, INT_MAX);
|
||||
max = level.airsupply;
|
||||
value = clamp<int>(statusBar->CPlayer->air_finished - currentUILevel->time, 0, INT_MAX);
|
||||
max = currentUILevel->airsupply;
|
||||
break;
|
||||
case POWERUPTIME:
|
||||
{
|
||||
|
|
@ -2798,7 +2798,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
}
|
||||
else
|
||||
value = 0;
|
||||
if(interpolationSpeed != 0 && (!hudChanged || level.time == 1))
|
||||
if(interpolationSpeed != 0 && (!hudChanged || currentUILevel->time == 1))
|
||||
{
|
||||
// [BL] Since we used a percentage (in order to get the most fluid animation)
|
||||
// we need to establish a cut off point so the last pixel won't hang as the animation slows
|
||||
|
|
@ -3192,7 +3192,7 @@ class CommandDrawGem : public SBarInfoCommand
|
|||
|
||||
goalValue = reverse ? 100 - goalValue : goalValue;
|
||||
|
||||
if(interpolationSpeed != 0 && (!hudChanged || level.time == 1)) // At the start force an animation
|
||||
if(interpolationSpeed != 0 && (!hudChanged || currentUILevel->time == 1)) // At the start force an animation
|
||||
{
|
||||
if(goalValue < drawValue)
|
||||
drawValue -= clamp<int>((drawValue - goalValue) >> 2, 1, interpolationSpeed);
|
||||
|
|
@ -3202,7 +3202,7 @@ class CommandDrawGem : public SBarInfoCommand
|
|||
else
|
||||
drawValue = goalValue;
|
||||
|
||||
if(wiggle && level.time & 1)
|
||||
if(wiggle && currentUILevel->time & 1)
|
||||
chainWiggle = pr_chainwiggle() & 1;
|
||||
}
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -133,25 +133,6 @@ CUSTOM_CVAR(Int, am_showmaplabel, 2, CVAR_ARCHIVE)
|
|||
|
||||
CVAR (Bool, idmypos, false, 0);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Format the map name, include the map label if wanted
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void ST_FormatMapName(FString &mapname, const char *mapnamecolor)
|
||||
{
|
||||
cluster_info_t *cluster = FindClusterInfo (level.cluster);
|
||||
bool ishub = (cluster != NULL && (cluster->flags & CLUSTER_HUB));
|
||||
|
||||
mapname = "";
|
||||
if (am_showmaplabel == 1 || (am_showmaplabel == 2 && !ishub))
|
||||
{
|
||||
mapname << level.MapName << ": ";
|
||||
}
|
||||
mapname << mapnamecolor << level.LevelName;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Load crosshair definitions
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@
|
|||
#undef DD
|
||||
#endif
|
||||
|
||||
void FNodeBuilder::Extract (FLevelLocals &level)
|
||||
void FNodeBuilder::Extract (FLevelLocals &theLevel)
|
||||
{
|
||||
int i;
|
||||
|
||||
auto &outVerts = level.vertexes;
|
||||
auto &outVerts = theLevel.vertexes;
|
||||
int vertCount = Vertices.Size ();
|
||||
outVerts.Alloc(vertCount);
|
||||
|
||||
|
|
@ -65,12 +65,12 @@ void FNodeBuilder::Extract (FLevelLocals &level)
|
|||
outVerts[i].set(Vertices[i].x, Vertices[i].y);
|
||||
}
|
||||
|
||||
auto &outSubs = level.subsectors;
|
||||
auto &outSubs = theLevel.subsectors;
|
||||
auto subCount = Subsectors.Size();
|
||||
outSubs.Alloc(subCount);
|
||||
memset(&outSubs[0], 0, subCount * sizeof(subsector_t));
|
||||
|
||||
auto &outNodes = level.nodes;
|
||||
auto &outNodes = theLevel.nodes;
|
||||
auto nodeCount = Nodes.Size ();
|
||||
outNodes.Alloc(nodeCount);
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ void FNodeBuilder::Extract (FLevelLocals &level)
|
|||
}
|
||||
}
|
||||
|
||||
auto &outSegs = level.segs;
|
||||
auto &outSegs = theLevel.segs;
|
||||
if (GLNodes)
|
||||
{
|
||||
TArray<glseg_t> segs (Segs.Size()*5/4);
|
||||
|
|
|
|||
|
|
@ -612,7 +612,7 @@ unsigned FLevelLocals::GetStackPortal(AActor *point, int plane)
|
|||
|
||||
//============================================================================
|
||||
//
|
||||
// level.GetPortalOffsetPosition
|
||||
// GetPortalOffsetPosition
|
||||
//
|
||||
// Offsets a given coordinate if the trace from the origin crosses an
|
||||
// interactive line-to-line portal.
|
||||
|
|
|
|||
|
|
@ -2496,10 +2496,28 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetSpotState, GetSpotState)
|
|||
ACTION_RETURN_POINTER(GetSpotState(self, create));
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Format the map name, include the map label if wanted
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
EXTERN_CVAR(Int, am_showmaplabel)
|
||||
|
||||
static void FormatMapName(FLevelLocals *self, int cr, FString *result)
|
||||
{
|
||||
char mapnamecolor[3] = { '\34', char(cr + 'A'), 0 };
|
||||
ST_FormatMapName(*result, mapnamecolor);
|
||||
|
||||
cluster_info_t *cluster = FindClusterInfo(self->cluster);
|
||||
bool ishub = (cluster != nullptr && (cluster->flags & CLUSTER_HUB));
|
||||
|
||||
*result = "";
|
||||
if (am_showmaplabel == 1 || (am_showmaplabel == 2 && !ishub))
|
||||
{
|
||||
*result << self->MapName << ": ";
|
||||
}
|
||||
*result << mapnamecolor << self->LevelName;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, FormatMapName, FormatMapName)
|
||||
|
|
@ -2696,6 +2714,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_AltHUD, GetLatency, Net_GetLatency)
|
|||
//
|
||||
//==========================================================================
|
||||
DEFINE_GLOBAL(level);
|
||||
DEFINE_GLOBAL(currentUILevel);
|
||||
DEFINE_FIELD(FLevelLocals, sectors)
|
||||
DEFINE_FIELD(FLevelLocals, lines)
|
||||
DEFINE_FIELD(FLevelLocals, sides)
|
||||
|
|
|
|||
|
|
@ -1369,11 +1369,15 @@ bool ZCCCompiler::CompileFields(PContainerType *type, TArray<ZCC_VarDeclarator *
|
|||
{
|
||||
Error(field, "Cannot add field %s to %s. %s has native children which means it size may not change", FName(name->Name).GetChars(), type->TypeName.GetChars(), type->TypeName.GetChars());
|
||||
}
|
||||
else
|
||||
else if (type != nullptr)
|
||||
{
|
||||
auto f = type->AddField(name->Name, thisfieldtype, varflags);
|
||||
if (field->Flags & (ZCC_Version | ZCC_Deprecated)) f->mVersion = field->Version;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(field, "Cannot declare non-native global variables. Tried to declare %s", FName(name->Name).GetChars());
|
||||
}
|
||||
}
|
||||
name = static_cast<ZCC_VarName*>(name->SiblingNext);
|
||||
} while (name != field->Names);
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ void F2DDrawer::AddPoly(FTexture *texture, FVector2 *points, int npoints,
|
|||
// is necessary in order to best reproduce Doom's original lighting.
|
||||
double fadelevel;
|
||||
|
||||
if (vid_rendermode != 4 || level.lightMode == ELightMode::Doom || level.lightMode == ELightMode::ZDoomSoftware || level.lightMode == ELightMode::DoomSoftware)
|
||||
if (vid_rendermode != 4 || currentUILevel->lightMode == ELightMode::Doom || currentUILevel->lightMode == ELightMode::ZDoomSoftware || currentUILevel->lightMode == ELightMode::DoomSoftware)
|
||||
{
|
||||
double map = (NUMCOLORMAPS * 2.) - ((lightlevel + 12) * (NUMCOLORMAPS / 128.));
|
||||
fadelevel = clamp((map - 12) / NUMCOLORMAPS, 0.0, 1.0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue