- 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:
Christoph Oelckers 2019-01-25 18:16:18 +01:00
parent ba114f6f23
commit 4e052f2857
21 changed files with 107 additions and 103 deletions

View file

@ -153,7 +153,8 @@ extern bool sendpause, sendsave, sendturn180, SendLand;
void *statcopy; // for statistics driver 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.
//========================================================================== //==========================================================================

View file

@ -413,9 +413,9 @@ public:
} }
}; };
#ifndef NO_DEFINE_LEVEL
extern FLevelLocals 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() inline FSectorPortal *line_t::GetTransferredPortal()
{ {
@ -510,4 +510,3 @@ inline bool line_t::hitSkyWall(AActor* mo) const
backsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
mo->Z() >= backsector->ceilingplane.ZatPoint(mo->PosRelative(this)); mo->Z() >= backsector->ceilingplane.ZatPoint(mo->PosRelative(this));
} }
#endif

View file

@ -516,7 +516,6 @@ DBaseStatusBar *CreateCustomStatusBar(int script=0);
// Crosshair stuff ---------------------------------------------------------- // Crosshair stuff ----------------------------------------------------------
void ST_FormatMapName(FString &mapname, const char *mapnamecolor = "");
void ST_LoadCrosshair(bool alwaysload=false); void ST_LoadCrosshair(bool alwaysload=false);
void ST_Clear(); void ST_Clear();
void ST_CreateStatusBar(bool bTitleLevel); void ST_CreateStatusBar(bool bTitleLevel);

View file

@ -1075,7 +1075,7 @@ public:
lastHud = hud; lastHud = hud;
// Handle inventory bar drawing // 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]; SBarInfoMainBlock *inventoryBar = state == HUD_StatusBar ? script->huds[STBAR_INVENTORY] : script->huds[STBAR_INVENTORYFULLSCREEN];
if(inventoryBar != lastInventoryBar) if(inventoryBar != lastInventoryBar)

View file

@ -850,26 +850,26 @@ class CommandDrawString : public SBarInfoCommand
switch(strValue) switch(strValue)
{ {
case LEVELNAME: case LEVELNAME:
if(level.lumpnum != cache) if(currentUILevel->lumpnum != cache)
{ {
cache = level.lumpnum; cache = currentUILevel->lumpnum;
str = level.LevelName; str = currentUILevel->LevelName;
RealignString(); RealignString();
} }
break; break;
case LEVELLUMP: case LEVELLUMP:
if(level.lumpnum != cache) if(currentUILevel->lumpnum != cache)
{ {
cache = level.lumpnum; cache = currentUILevel->lumpnum;
str = level.MapName; str = currentUILevel->MapName;
str.ToUpper(); str.ToUpper();
RealignString(); RealignString();
} }
break; break;
case SKILLNAME: 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(); str = G_SkillName();
RealignString(); RealignString();
} }
@ -904,7 +904,7 @@ class CommandDrawString : public SBarInfoCommand
if(ACS_GlobalVars[valueArgument] != cache) if(ACS_GlobalVars[valueArgument] != cache)
{ {
cache = ACS_GlobalVars[valueArgument]; cache = ACS_GlobalVars[valueArgument];
str = level.Behaviors.LookupString(ACS_GlobalVars[valueArgument]); str = currentUILevel->Behaviors.LookupString(ACS_GlobalVars[valueArgument]);
RealignString(); RealignString();
} }
break; break;
@ -912,13 +912,13 @@ class CommandDrawString : public SBarInfoCommand
if(ACS_GlobalArrays[valueArgument][consoleplayer] != cache) if(ACS_GlobalArrays[valueArgument][consoleplayer] != cache)
{ {
cache = ACS_GlobalArrays[valueArgument][consoleplayer]; cache = ACS_GlobalArrays[valueArgument][consoleplayer];
str = level.Behaviors.LookupString(ACS_GlobalArrays[valueArgument][consoleplayer]); str = currentUILevel->Behaviors.LookupString(ACS_GlobalArrays[valueArgument][consoleplayer]);
RealignString(); RealignString();
} }
break; break;
case TIME: case TIME:
{ {
int sec = Tics2Seconds(level.time); int sec = Tics2Seconds(currentUILevel->time);
str.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60); str.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60);
break; break;
} }
@ -1389,25 +1389,25 @@ class CommandDrawNumber : public CommandDrawString
num = statusBar->CPlayer->fragcount; num = statusBar->CPlayer->fragcount;
break; break;
case KILLS: case KILLS:
num = level.killed_monsters; num = currentUILevel->killed_monsters;
break; break;
case MONSTERS: case MONSTERS:
num = level.total_monsters; num = currentUILevel->total_monsters;
break; break;
case ITEMS: case ITEMS:
num = level.found_items; num = currentUILevel->found_items;
break; break;
case TOTALITEMS: case TOTALITEMS:
num = level.total_items; num = currentUILevel->total_items;
break; break;
case SECRETS: case SECRETS:
num = level.found_secrets; num = currentUILevel->found_secrets;
break; break;
case SCORE: case SCORE:
num = statusBar->CPlayer->mo->Score; num = statusBar->CPlayer->mo->Score;
break; break;
case TOTALSECRETS: case TOTALSECRETS:
num = level.total_secrets; num = currentUILevel->total_secrets;
break; break;
case ARMORCLASS: case ARMORCLASS:
case SAVEPERCENT: case SAVEPERCENT:
@ -1459,9 +1459,9 @@ class CommandDrawNumber : public CommandDrawString
case AIRTIME: case AIRTIME:
{ {
if(statusBar->CPlayer->mo->waterlevel < 3) if(statusBar->CPlayer->mo->waterlevel < 3)
num = level.airsupply/TICRATE; num = currentUILevel->airsupply/TICRATE;
else 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; break;
} }
case SELECTEDINVENTORY: case SELECTEDINVENTORY:
@ -1502,7 +1502,7 @@ class CommandDrawNumber : public CommandDrawString
} }
default: break; default: break;
} }
if(interpolationSpeed != 0 && (!hudChanged || level.time == 1)) if(interpolationSpeed != 0 && (!hudChanged || currentUILevel->time == 1))
{ {
if(num < drawValue) if(num < drawValue)
drawValue -= clamp<int>((drawValue - num) >> 2, 1, interpolationSpeed); drawValue -= clamp<int>((drawValue - num) >> 2, 1, interpolationSpeed);
@ -1691,7 +1691,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
if(alternateOnEmpty) if(alternateOnEmpty)
SBarInfoCommandFlowControl::Draw(block, statusBar); 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) if(artiflash && statusBar->wrapper->artiflashTick)
{ {
@ -1791,7 +1791,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
{ {
SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); 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); CommandDrawImage::Tick(block, statusBar, hudChanged);
CommandDrawNumber::Tick(block, statusBar, hudChanged); CommandDrawNumber::Tick(block, statusBar, hudChanged);
@ -1910,7 +1910,7 @@ class CommandInventoryBarNotVisible : public SBarInfoCommandFlowControl
{ {
SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); 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; max = fraglimit;
break; break;
case KILLS: case KILLS:
value = level.killed_monsters; value = currentUILevel->killed_monsters;
max = level.total_monsters; max = currentUILevel->total_monsters;
break; break;
case ITEMS: case ITEMS:
value = level.found_items; value = currentUILevel->found_items;
max = level.total_items; max = currentUILevel->total_items;
break; break;
case SECRETS: case SECRETS:
value = level.found_secrets; value = currentUILevel->found_secrets;
max = level.total_secrets; max = currentUILevel->total_secrets;
break; break;
case INVENTORY: case INVENTORY:
{ {
@ -2751,8 +2751,8 @@ class CommandDrawBar : public SBarInfoCommand
break; break;
} }
case AIRTIME: case AIRTIME:
value = clamp<int>(statusBar->CPlayer->air_finished - level.time, 0, INT_MAX); value = clamp<int>(statusBar->CPlayer->air_finished - currentUILevel->time, 0, INT_MAX);
max = level.airsupply; max = currentUILevel->airsupply;
break; break;
case POWERUPTIME: case POWERUPTIME:
{ {
@ -2798,7 +2798,7 @@ class CommandDrawBar : public SBarInfoCommand
} }
else else
value = 0; 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) // [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 // 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; 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) if(goalValue < drawValue)
drawValue -= clamp<int>((drawValue - goalValue) >> 2, 1, interpolationSpeed); drawValue -= clamp<int>((drawValue - goalValue) >> 2, 1, interpolationSpeed);
@ -3202,7 +3202,7 @@ class CommandDrawGem : public SBarInfoCommand
else else
drawValue = goalValue; drawValue = goalValue;
if(wiggle && level.time & 1) if(wiggle && currentUILevel->time & 1)
chainWiggle = pr_chainwiggle() & 1; chainWiggle = pr_chainwiggle() & 1;
} }
protected: protected:

View file

@ -133,25 +133,6 @@ CUSTOM_CVAR(Int, am_showmaplabel, 2, CVAR_ARCHIVE)
CVAR (Bool, idmypos, false, 0); 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 // Load crosshair definitions

View file

@ -52,11 +52,11 @@
#undef DD #undef DD
#endif #endif
void FNodeBuilder::Extract (FLevelLocals &level) void FNodeBuilder::Extract (FLevelLocals &theLevel)
{ {
int i; int i;
auto &outVerts = level.vertexes; auto &outVerts = theLevel.vertexes;
int vertCount = Vertices.Size (); int vertCount = Vertices.Size ();
outVerts.Alloc(vertCount); outVerts.Alloc(vertCount);
@ -65,12 +65,12 @@ void FNodeBuilder::Extract (FLevelLocals &level)
outVerts[i].set(Vertices[i].x, Vertices[i].y); outVerts[i].set(Vertices[i].x, Vertices[i].y);
} }
auto &outSubs = level.subsectors; auto &outSubs = theLevel.subsectors;
auto subCount = Subsectors.Size(); auto subCount = Subsectors.Size();
outSubs.Alloc(subCount); outSubs.Alloc(subCount);
memset(&outSubs[0], 0, subCount * sizeof(subsector_t)); memset(&outSubs[0], 0, subCount * sizeof(subsector_t));
auto &outNodes = level.nodes; auto &outNodes = theLevel.nodes;
auto nodeCount = Nodes.Size (); auto nodeCount = Nodes.Size ();
outNodes.Alloc(nodeCount); outNodes.Alloc(nodeCount);
@ -103,7 +103,7 @@ void FNodeBuilder::Extract (FLevelLocals &level)
} }
} }
auto &outSegs = level.segs; auto &outSegs = theLevel.segs;
if (GLNodes) if (GLNodes)
{ {
TArray<glseg_t> segs (Segs.Size()*5/4); TArray<glseg_t> segs (Segs.Size()*5/4);

View file

@ -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 // Offsets a given coordinate if the trace from the origin crosses an
// interactive line-to-line portal. // interactive line-to-line portal.

View file

@ -2496,10 +2496,28 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetSpotState, GetSpotState)
ACTION_RETURN_POINTER(GetSpotState(self, create)); 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) static void FormatMapName(FLevelLocals *self, int cr, FString *result)
{ {
char mapnamecolor[3] = { '\34', char(cr + 'A'), 0 }; 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) DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, FormatMapName, FormatMapName)
@ -2696,6 +2714,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_AltHUD, GetLatency, Net_GetLatency)
// //
//========================================================================== //==========================================================================
DEFINE_GLOBAL(level); DEFINE_GLOBAL(level);
DEFINE_GLOBAL(currentUILevel);
DEFINE_FIELD(FLevelLocals, sectors) DEFINE_FIELD(FLevelLocals, sectors)
DEFINE_FIELD(FLevelLocals, lines) DEFINE_FIELD(FLevelLocals, lines)
DEFINE_FIELD(FLevelLocals, sides) DEFINE_FIELD(FLevelLocals, sides)

View file

@ -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()); 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); auto f = type->AddField(name->Name, thisfieldtype, varflags);
if (field->Flags & (ZCC_Version | ZCC_Deprecated)) f->mVersion = field->Version; 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); name = static_cast<ZCC_VarName*>(name->SiblingNext);
} while (name != field->Names); } while (name != field->Names);

View file

@ -428,7 +428,7 @@ void F2DDrawer::AddPoly(FTexture *texture, FVector2 *points, int npoints,
// is necessary in order to best reproduce Doom's original lighting. // is necessary in order to best reproduce Doom's original lighting.
double fadelevel; 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.)); double map = (NUMCOLORMAPS * 2.) - ((lightlevel + 12) * (NUMCOLORMAPS / 128.));
fadelevel = clamp((map - 12) / NUMCOLORMAPS, 0.0, 1.0); fadelevel = clamp((map - 12) / NUMCOLORMAPS, 0.0, 1.0);

View file

@ -45,6 +45,7 @@ struct _ native // These are the global variables, the struct is only here to av
native ui BaseStatusBar StatusBar; native ui BaseStatusBar StatusBar;
native readonly Weapon WP_NOCHANGE; native readonly Weapon WP_NOCHANGE;
native int LocalViewPitch; native int LocalViewPitch;
native ui readonly LevelLocals currentUILevel;
} }

View file

@ -509,7 +509,7 @@ class ConversationMenu : Menu
override void Ticker() override void Ticker()
{ {
// [CW] Freeze the game depending on MAPINFO options. // [CW] Freeze the game depending on MAPINFO options.
if (ConversationPauseTic < gametic && !multiplayer && !level.no_dlg_freeze) if (ConversationPauseTic < gametic && !multiplayer && !currentUILevel.no_dlg_freeze)
{ {
menuactive = Menu.On; menuactive = Menu.On;
} }

View file

@ -57,9 +57,9 @@ class ReadThisMenu : GenericMenu
TextureID tex, prevpic; TextureID tex, prevpic;
// Did the mapper choose a custom help page via MAPINFO? // Did the mapper choose a custom help page via MAPINFO?
if (level.F1Pic.Length() != 0) if (currentUILevel.F1Pic.Length() != 0)
{ {
tex = TexMan.CheckForTexture(level.F1Pic, TexMan.Type_MiscPatch); tex = TexMan.CheckForTexture(currentUILevel.F1Pic, TexMan.Type_MiscPatch);
mScreen = 1; mScreen = 1;
} }
@ -98,7 +98,7 @@ class ReadThisMenu : GenericMenu
MenuSound("menu/choose"); MenuSound("menu/choose");
mScreen++; mScreen++;
mInfoTic = gametic; mInfoTic = gametic;
if (level.F1Pic.Length() != 0 || mScreen > gameinfo.infoPages.Size()) if (currentUILevel.F1Pic.Length() != 0 || mScreen > gameinfo.infoPages.Size())
{ {
Close(); Close();
} }

View file

@ -205,17 +205,17 @@ class AltHud ui
// work in cooperative hub games // work in cooperative hub games
if (hud_showsecrets) if (hud_showsecrets)
{ {
DrawStatLine(x, y, "S:", String.Format("%i/%i ", multiplayer? CPlayer.secretcount : level.found_secrets, level.total_secrets)); DrawStatLine(x, y, "S:", String.Format("%i/%i ", multiplayer? CPlayer.secretcount : currentUILevel.found_secrets, currentUILevel.total_secrets));
} }
if (hud_showitems) if (hud_showitems)
{ {
DrawStatLine(x, y, "I:", String.Format("%i/%i ", multiplayer? CPlayer.itemcount : level.found_items, level.total_items)); DrawStatLine(x, y, "I:", String.Format("%i/%i ", multiplayer? CPlayer.itemcount : currentUILevel.found_items, currentUILevel.total_items));
} }
if (hud_showmonsters) if (hud_showmonsters)
{ {
DrawStatLine(x, y, "K:", String.Format("%i/%i ", multiplayer? CPlayer.killcount : level.killed_monsters, level.total_monsters)); DrawStatLine(x, y, "K:", String.Format("%i/%i ", multiplayer? CPlayer.killcount : currentUILevel.killed_monsters, currentUILevel.total_monsters));
} }
} }
} }
@ -739,18 +739,18 @@ class AltHud ui
} }
else else
{ {
pos.xy = Level.GetAutomapPosition(); pos.xy = currentUILevel.GetAutomapPosition();
pos.z = Sector.PointInSector(pos.xy).floorplane.ZatPoint(pos.xy); pos.z = Sector.PointInSector(pos.xy).floorplane.ZatPoint(pos.xy);
} }
int xpos = hudwidth - SmallFont.StringWidth("X: -00000")-6; int xpos = hudwidth - SmallFont.StringWidth("X: -00000")-6;
int ypos = 18; int ypos = 18;
screen.DrawText(SmallFont, hudcolor_titl, hudwidth - 6 - SmallFont.StringWidth(level.MapName), ypos, level.MapName, screen.DrawText(SmallFont, hudcolor_titl, hudwidth - 6 - SmallFont.StringWidth(currentUILevel.MapName), ypos, currentUILevel.MapName,
DTA_KeepRatio, true, DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight);
screen.DrawText(SmallFont, hudcolor_titl, hudwidth - 6 - SmallFont.StringWidth(level.LevelName), ypos + h, level.LevelName, screen.DrawText(SmallFont, hudcolor_titl, hudwidth - 6 - SmallFont.StringWidth(currentUILevel.LevelName), ypos + h, currentUILevel.LevelName,
DTA_KeepRatio, true, DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight);
@ -793,10 +793,10 @@ class AltHud ui
{ {
int timeTicks = int timeTicks =
hud_showtime < 4 hud_showtime < 4
? level.maptime ? currentUILevel.maptime
: (hud_showtime < 6 : (hud_showtime < 6
? level.time ? currentUILevel.time
: level.totaltime); : currentUILevel.totaltime);
timeSeconds = Thinker.Tics2Seconds(timeTicks); timeSeconds = Thinker.Tics2Seconds(timeTicks);
} }
else else
@ -815,7 +815,7 @@ class AltHud ui
if (showMillis) if (showMillis)
{ {
int millis = (level.time % Thinker.TICRATE) * (1000 / Thinker.TICRATE); int millis = (currentUILevel.time % Thinker.TICRATE) * (1000 / Thinker.TICRATE);
timeString = String.Format("%02i:%02i:%02i.%03i", hours, minutes, seconds, millis); timeString = String.Format("%02i:%02i:%02i.%03i", hours, minutes, seconds, millis);
} }
else if (showSeconds) else if (showSeconds)
@ -946,23 +946,23 @@ class AltHud ui
if (am_showtotaltime) if (am_showtotaltime)
{ {
DrawTimeString(SmallFont, hudcolor_ttim, level.totaltime, hudwidth-2, bottom, 1); DrawTimeString(SmallFont, hudcolor_ttim, currentUILevel.totaltime, hudwidth-2, bottom, 1);
bottom -= fonth; bottom -= fonth;
} }
if (am_showtime) if (am_showtime)
{ {
if (level.clusterflags & level.CLUSTER_HUB) if (currentUILevel.clusterflags & currentUILevel.CLUSTER_HUB)
{ {
DrawTimeString(SmallFont, hudcolor_time, level.time, hudwidth-2, bottom, 1); DrawTimeString(SmallFont, hudcolor_time, currentUILevel.time, hudwidth-2, bottom, 1);
bottom -= fonth; bottom -= fonth;
} }
// Single level time for hubs // Single level time for hubs
DrawTimeString(SmallFont, hudcolor_ltim, level.maptime, hudwidth-2, bottom, 1); DrawTimeString(SmallFont, hudcolor_ltim, currentUILevel.maptime, hudwidth-2, bottom, 1);
} }
screen.DrawText(SmallFont, 0, 1, hudheight - fonth - 1, level.FormatMapName(hudcolor_titl), screen.DrawText(SmallFont, 0, 1, hudheight - fonth - 1, currentUILevel.FormatMapName(hudcolor_titl),
DTA_KeepRatio, true, DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight);

View file

@ -105,7 +105,7 @@ class DoomStatusBar : BaseStatusBar
DrawImage("STFBANY", (143, 168), DI_ITEM_OFFSETS|DI_TRANSLATABLE); DrawImage("STFBANY", (143, 168), DI_ITEM_OFFSETS|DI_TRANSLATABLE);
} }
if (CPlayer.mo.InvSel != null && !level.NoInventoryBar) if (CPlayer.mo.InvSel != null && !currentUILevel.NoInventoryBar)
{ {
DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198)); DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198));
if (CPlayer.mo.InvSel.Amount > 1) if (CPlayer.mo.InvSel.Amount > 1)
@ -153,7 +153,7 @@ class DoomStatusBar : BaseStatusBar
DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);
invY -= 20; invY -= 20;
} }
if (!isInventoryBarVisible() && !level.NoInventoryBar && CPlayer.mo.InvSel != null) if (!isInventoryBarVisible() && !currentUILevel.NoInventoryBar && CPlayer.mo.InvSel != null)
{ {
DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17)); DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17));
DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);

View file

@ -60,7 +60,7 @@ class HarmonyStatusBar : DoomStatusBar
DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);
invY -= 20; invY -= 20;
} }
if (!isInventoryBarVisible() && !level.NoInventoryBar && CPlayer.mo.InvSel != null) if (!isInventoryBarVisible() && !currentUILevel.NoInventoryBar && CPlayer.mo.InvSel != null)
{ {
DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17)); DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17));
DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);

View file

@ -43,7 +43,7 @@ class HereticStatusBar : BaseStatusBar
mHealthInterpolator.Update(CPlayer.health); mHealthInterpolator.Update(CPlayer.health);
// wiggle the chain if it moves // wiggle the chain if it moves
if (level.time & 1) if (currentUILevel.time & 1)
{ {
wiggle = (mHealthInterpolator.GetValue() != CPlayer.health) && Random[ChainWiggle](0, 1); wiggle = (mHealthInterpolator.GetValue() != CPlayer.health) && Random[ChainWiggle](0, 1);
} }
@ -200,7 +200,7 @@ class HereticStatusBar : BaseStatusBar
y -= 40; y -= 40;
} }
if (!isInventoryBarVisible() && !level.NoInventoryBar && CPlayer.mo.InvSel != null) if (!isInventoryBarVisible() && !currentUILevel.NoInventoryBar && CPlayer.mo.InvSel != null)
{ {
// This code was changed to always fit the item into the box, regardless of alignment or sprite size. // This code was changed to always fit the item into the box, regardless of alignment or sprite size.
// Heretic's ARTIBOX is 30x30 pixels. // Heretic's ARTIBOX is 30x30 pixels.

View file

@ -74,7 +74,7 @@ class HexenStatusBar : BaseStatusBar
DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (70, -16)); DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (70, -16));
} }
if (!isInventoryBarVisible() && !level.NoInventoryBar && CPlayer.mo.InvSel != null) if (!isInventoryBarVisible() && !currentUILevel.NoInventoryBar && CPlayer.mo.InvSel != null)
{ {
// This code was changed to always fit the item into the box, regardless of alignment or sprite size. // This code was changed to always fit the item into the box, regardless of alignment or sprite size.
// Heretic's ARTIBOX is 30x30 pixels. // Heretic's ARTIBOX is 30x30 pixels.

View file

@ -597,9 +597,9 @@ class BaseStatusBar native ui
int GetAirTime() int GetAirTime()
{ {
if(CPlayer.mo.waterlevel < 3) if(CPlayer.mo.waterlevel < 3)
return level.airsupply; return currentUILevel.airsupply;
else else
return max(CPlayer.air_finished - level.time, 0); return max(CPlayer.air_finished - currentUILevel.time, 0);
} }
int GetSelectedInventoryAmount() int GetSelectedInventoryAmount()
@ -654,7 +654,7 @@ class BaseStatusBar native ui
bool isInventoryBarVisible() bool isInventoryBarVisible()
{ {
if (CPlayer == null) return false; if (CPlayer == null) return false;
return (CPlayer.inventorytics > 0 && !level.NoInventoryBar); return (CPlayer.inventorytics > 0 && !currentUILevel.NoInventoryBar);
} }
//============================================================================ //============================================================================
@ -850,13 +850,13 @@ class BaseStatusBar native ui
let width = SmallFont.StringWidth("00:00:00"); let width = SmallFont.StringWidth("00:00:00");
if (am_showtime) if (am_showtime)
{ {
printtext = level.TimeFormatted(); printtext = currentUILevel.TimeFormatted();
DrawString(mSmallFont, level.TimeFormatted(), (-textdist-width, y), 0, crdefault); DrawString(mSmallFont, currentUILevel.TimeFormatted(), (-textdist-width, y), 0, crdefault);
y += height; y += height;
} }
if (am_showtotaltime) if (am_showtotaltime)
{ {
DrawString(mSmallFont, level.TimeFormatted(true), (-textdist-width, y), 0, crdefault); DrawString(mSmallFont, currentUILevel.TimeFormatted(true), (-textdist-width, y), 0, crdefault);
} }
if (!deathmatch) if (!deathmatch)
@ -866,25 +866,25 @@ class BaseStatusBar native ui
// Draw monster count // Draw monster count
if (am_showmonsters) if (am_showmonsters)
{ {
DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_MONSTERS"), crdefault+65, level.killed_monsters, level.total_monsters), (textdist, y), 0, highlight); DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_MONSTERS"), crdefault+65, currentUILevel.killed_monsters, currentUILevel.total_monsters), (textdist, y), 0, highlight);
y += height; y += height;
} }
// Draw secret count // Draw secret count
if (am_showsecrets) if (am_showsecrets)
{ {
DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_SECRETS"), crdefault+65, level.found_secrets, level.total_secrets), (textdist, y), 0, highlight); DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_SECRETS"), crdefault+65, currentUILevel.found_secrets, currentUILevel.total_secrets), (textdist, y), 0, highlight);
y += height; y += height;
} }
// Draw item count // Draw item count
if (am_showitems) if (am_showitems)
{ {
DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_ITEMS"), crdefault+65, level.found_items, level.total_items), (textdist, y), 0, highlight); DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_ITEMS"), crdefault+65, currentUILevel.found_items, currentUILevel.total_items), (textdist, y), 0, highlight);
} }
} }
String mapname = level.FormatMapName(crdefault); String mapname = currentUILevel.FormatMapName(crdefault);
BrokenLines lines = SmallFont.BreakLines(mapname, int(SCREENWIDTH / scale.X)); BrokenLines lines = SmallFont.BreakLines(mapname, int(SCREENWIDTH / scale.X));
int numlines = lines.Count(); int numlines = lines.Count();
int finalwidth = int(SmallFont.StringWidth(lines.StringAt(numlines-1)) * scale.X); int finalwidth = int(SmallFont.StringWidth(lines.StringAt(numlines-1)) * scale.X);

View file

@ -427,7 +427,7 @@ class StrifeStatusBar : BaseStatusBar
case POP_Log: case POP_Log:
{ {
// Draw the latest log message. // Draw the latest log message.
screen.DrawText(SmallFont2, Font.CR_UNTRANSLATED, left + 210 * xscale, top + 8 * yscale, Level.TimeFormatted(), screen.DrawText(SmallFont2, Font.CR_UNTRANSLATED, left + 210 * xscale, top + 8 * yscale, currentUILevel.TimeFormatted(),
DTA_CleanNoMove, true); DTA_CleanNoMove, true);
if (CPlayer.LogText.Length() > 0) if (CPlayer.LogText.Length() > 0)