mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 20:20:40 +00:00
- removed all the intermediate variables for the status bar size.
hud_size now gets used directly by the status bar code.
This commit is contained in:
parent
8d622f9340
commit
f9d48e1f68
18 changed files with 38 additions and 104 deletions
|
@ -144,7 +144,6 @@ struct GameInterface : ::GameInterface
|
|||
bool GenerateSavePic() override;
|
||||
void FreeGameData() override;
|
||||
void set_hud_layout(int size) override;
|
||||
void set_hud_scale(int size) override;
|
||||
FString statFPS() override;
|
||||
FSavegameInfo GetSaveSig() override;
|
||||
void MenuOpened() override;
|
||||
|
|
|
@ -65,11 +65,6 @@ void GameInterface::set_hud_layout(int layout)
|
|||
viewResizeView(layout);
|
||||
}
|
||||
|
||||
void GameInterface::set_hud_scale(int scale)
|
||||
{
|
||||
// Not implemented, only needed as a placeholder. Maybe implement it after all? The hud is a bit large at its default size.
|
||||
}
|
||||
|
||||
|
||||
fix16_t gViewLook, gViewAngle;
|
||||
float gViewAngleAdjust;
|
||||
|
|
|
@ -159,11 +159,7 @@ CUSTOM_CVARD(Int, snd_speech, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enables/disabl
|
|||
|
||||
// HUD
|
||||
|
||||
// This was particularly messy. EDuke and Rednukem had no consistent setting for this but a complex combination of 4 CVARs and lots of mod flags controlling the HUD layout
|
||||
// NBlood had this differently with an inverted scale of 0-7 with 0 having no HUD.
|
||||
// For consistency all frontends now use the same scale, with 0 being the smallest and 11 being the largest, which get converted to the internal settings by the set_hud_layout callback.
|
||||
|
||||
int hud_size_max = 11; // 11 is for Duke Nukem and its offspring games.
|
||||
int hud_size_max = 11; // The maximum is different for each game
|
||||
|
||||
CUSTOM_CVARD(Int, hud_size, 9, CVAR_ARCHIVE | CVAR_NOINITCALL, "Defines the HUD size and style")
|
||||
{
|
||||
|
@ -171,35 +167,22 @@ CUSTOM_CVARD(Int, hud_size, 9, CVAR_ARCHIVE | CVAR_NOINITCALL, "Defines the HUD
|
|||
else if (self > hud_size_max) self = hud_size_max;
|
||||
else
|
||||
{
|
||||
if (gi->validate_hud(self))
|
||||
gi->set_hud_layout(self);
|
||||
else
|
||||
Printf("Hud size %d not available\n", *self);
|
||||
gi->set_hud_layout(self);
|
||||
}
|
||||
}
|
||||
|
||||
// This is to allow flattening the overly complicated HUD configuration to one single value and keep the complexity safely inside the HUD code.
|
||||
// This is for game code to change the size, so that the range checks remain isolated here.
|
||||
bool G_ChangeHudLayout(int direction)
|
||||
{
|
||||
if (direction < 0 && hud_size > 0)
|
||||
{
|
||||
int layout = hud_size - 1;
|
||||
while (!gi->validate_hud(layout) && layout >= 0) layout--;
|
||||
if (layout >= 0 && layout < hud_size && gi->validate_hud(layout))
|
||||
{
|
||||
hud_size = layout;
|
||||
return true;
|
||||
}
|
||||
hud_size = hud_size - 1;
|
||||
return true;
|
||||
}
|
||||
else if (direction > 0 && hud_size < 11)
|
||||
else if (direction > 0 && hud_size < hud_size_max)
|
||||
{
|
||||
int layout = hud_size + 1;
|
||||
while (!gi->validate_hud(layout) && layout <= 11) layout++;
|
||||
if (layout <= 11 && layout > hud_size && gi->validate_hud(layout))
|
||||
{
|
||||
hud_size = layout;
|
||||
return true;
|
||||
}
|
||||
hud_size = hud_size + 1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -218,7 +201,7 @@ CUSTOM_CVARD(Int, hud_scale, 100, CVAR_ARCHIVE | CVAR_NOINITCALL, "changes the h
|
|||
{
|
||||
if (self < 36) self = 36;
|
||||
else if (self > 100) self = 100;
|
||||
else gi->set_hud_scale(self);
|
||||
else gi->UpdateScreenSize();
|
||||
}
|
||||
|
||||
CCMD(scaleup)
|
||||
|
@ -235,13 +218,6 @@ CCMD(scaledown)
|
|||
if (hud_scale != oldscale) gi->PlayHudSound();
|
||||
}
|
||||
|
||||
int hud_statusbarrange; // will be set by the game's configuration setup.
|
||||
CUSTOM_CVARD(Int, hud_custom, 0, CVAR_ARCHIVE|CVAR_NOINITCALL, "change the custom hud") // this has no backing implementation, it seems to be solely for scripted HUDs.
|
||||
{
|
||||
if (self < 0) self = 0;
|
||||
else if (self > 0 && self >= hud_statusbarrange) self = hud_statusbarrange - 1;
|
||||
}
|
||||
|
||||
CVARD(Bool, hud_stats, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable level statistics display")
|
||||
CVARD(Bool, hud_showmapname, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable map name display on load")
|
||||
CVARD(Bool, hud_position, false, CVAR_ARCHIVE, "aligns the status bar to the bottom/top")
|
||||
|
|
|
@ -57,9 +57,7 @@ struct GameInterface
|
|||
virtual void clearlocalinputstate() {}
|
||||
virtual void UpdateScreenSize() {}
|
||||
virtual void FreeGameData() {}
|
||||
virtual bool validate_hud(int) { return true; }
|
||||
virtual void set_hud_layout(int size) = 0;
|
||||
virtual void set_hud_scale(int size) {}
|
||||
virtual bool automapActive() { return false; }
|
||||
virtual void PlayHudSound() {}
|
||||
virtual FString statFPS() { return "FPS display not available"; }
|
||||
|
|
|
@ -338,9 +338,7 @@ struct GameInterface : ::GameInterface
|
|||
int app_main() override;
|
||||
void UpdateScreenSize() override;
|
||||
bool GenerateSavePic() override;
|
||||
bool validate_hud(int) override { return true; }
|
||||
void set_hud_layout(int size) override;
|
||||
void set_hud_scale(int size) override {}
|
||||
void DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) override;
|
||||
void MenuOpened() override;
|
||||
void MenuSound(EMenuSounds snd) override;
|
||||
|
|
|
@ -269,7 +269,7 @@ void Logo_d(const CompletionFunc &completion)
|
|||
|
||||
JobDesc jobs[3];
|
||||
int job = 0;
|
||||
if (VOLUMEALL && !inputState.CheckAllInput()) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes), []() { S_PlaySpecialMusic(MUS_INTRO); } };
|
||||
if (VOLUMEALL) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes), []() { S_PlaySpecialMusic(MUS_INTRO); } };
|
||||
if (!isNam()) jobs[job++] = { Create<DDRealmsScreen>(), nullptr };
|
||||
jobs[job++] = { Create<DTitleScreen>(), []() { S_PlaySound(NITEVISION_ONOFF, CHAN_AUTO, CHANF_UI); } };
|
||||
RunScreenJob(jobs, job, completion, true, true);
|
||||
|
|
|
@ -38,9 +38,7 @@ struct GameInterface : ::GameInterface
|
|||
void clearlocalinputstate() override;
|
||||
void UpdateScreenSize() override;
|
||||
bool GenerateSavePic() override;
|
||||
bool validate_hud(int) override;
|
||||
void set_hud_layout(int size) override;
|
||||
void set_hud_scale(int size) override;
|
||||
void PlayHudSound() override;
|
||||
bool automapActive() override;
|
||||
FString statFPS() override;
|
||||
|
|
|
@ -242,5 +242,6 @@ void setinterpolation(int* posptr);
|
|||
void stopinterpolation(int* posptr);
|
||||
void dointerpolations(int smoothratio);
|
||||
int* animateptr(int i);
|
||||
void updateviewport(void);
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -416,8 +416,6 @@ static void Startup(void)
|
|||
}
|
||||
|
||||
ud.last_level = -1;
|
||||
hud_size.Callback();
|
||||
hud_scale.Callback();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -432,6 +430,7 @@ int GameInterface::app_main()
|
|||
Startup();
|
||||
enginePostInit();
|
||||
videoInit();
|
||||
updateviewport();
|
||||
videoSetPalette(BASEPAL);
|
||||
app_loop();
|
||||
return 0;
|
||||
|
|
|
@ -657,7 +657,7 @@ void drawoverheadmap(int cposx, int cposy, int czoom, int cang)
|
|||
if (/*textret == 0 &&*/ ud.overhead_on == 2)
|
||||
{
|
||||
double scale = isRR() ? 0.5 : 1.;
|
||||
int top = isRR() ? 0 : ((ud.screen_size > 0) ? 147 : 179);
|
||||
int top = isRR() ? 0 : (hud_size < 11 ? 147 : 179);
|
||||
if (!(currentLevel->flags & MI_USERMAP))
|
||||
DrawText(twod, SmallFont2, CR_UNDEFINED, 5, top+6, GStrings.localize(gVolumeNames[volfromlevelnum(currentLevel->levelNumber)]),
|
||||
DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE);
|
||||
|
|
|
@ -195,14 +195,14 @@ void displaymasks_d(int snum)
|
|||
|
||||
if (ps[snum].scuba_on)
|
||||
{
|
||||
if (ud.screen_size > 4)
|
||||
if (hud_size < 9)
|
||||
{
|
||||
hud_drawsprite(44, (200 - 8 - tilesiz[SCUBAMASK].y), 65536, 0, SCUBAMASK, 0, p, 2 + 16);
|
||||
hud_drawsprite((320 - 43), (200 - 8 - tilesiz[SCUBAMASK].y), 65536, 1024, SCUBAMASK, 0, p, 2 + 4 + 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
hud_drawsprite(44 << 16, (200 - tilesiz[SCUBAMASK].y) << 16, 65536, 0, SCUBAMASK, 0, p, 2 + 16);
|
||||
hud_drawsprite(44, (200 - tilesiz[SCUBAMASK].y), 65536, 0, SCUBAMASK, 0, p, 2 + 16);
|
||||
hud_drawsprite((320 - 43), (200 - tilesiz[SCUBAMASK].y), 65536, 1024, SCUBAMASK, 0, p, 2 + 4 + 16);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ void nonsharedkeys(void)
|
|||
{
|
||||
if (G_ChangeHudLayout(1))
|
||||
{
|
||||
S_PlaySound(isRR() ? 341 : THUD, CHAN_AUTO, CHANF_UI);
|
||||
gi->PlayHudSound();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -92,7 +92,7 @@ void nonsharedkeys(void)
|
|||
{
|
||||
if (G_ChangeHudLayout(-1))
|
||||
{
|
||||
S_PlaySound(isRR() ? 341 : THUD, CHAN_AUTO, CHANF_UI);
|
||||
gi->PlayHudSound();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -211,16 +211,6 @@ void nonsharedkeys(void)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0 // ESC is blocked by the menu, this function is not particularly useful anyway.
|
||||
if (inputState.GetKeyStatus(sc_Escape) && ud.overhead_on && ps[myconnectindex].newowner == -1)
|
||||
{
|
||||
inputState.ClearKeyStatus(sc_Escape);
|
||||
ud.last_overhead = ud.overhead_on;
|
||||
ud.overhead_on = 0;
|
||||
ud.scrollmode = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Map))
|
||||
{
|
||||
buttonMap.ClearButton(gamefunc_Map);
|
||||
|
@ -739,7 +729,6 @@ static void processInputBits(player_struct *p, ControlInfo &info)
|
|||
}
|
||||
|
||||
if (gamequit) loc.bits |= SKB_GAMEQUIT;
|
||||
//if (inputState.GetKeyStatus(sc_Escape)) loc.bits |= SKB_ESCAPE; fixme. This never gets here because the menu eats the escape key.
|
||||
|
||||
if (!onVehicle)
|
||||
{
|
||||
|
@ -1320,6 +1309,7 @@ void registerinputcommands()
|
|||
C_RegisterFunction("jetpack", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_JETPACK; return CCMD_OK; });
|
||||
C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_TURNAROUND; return CCMD_OK; });
|
||||
C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_INVENTORY; return CCMD_OK; });
|
||||
C_RegisterFunction("backoff", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_ESCAPE; return CCMD_OK; });
|
||||
}
|
||||
|
||||
// This is called from ImputState::ClearAllInput and resets all static state being used here.
|
||||
|
|
|
@ -280,26 +280,29 @@ void DrawBorder()
|
|||
|
||||
void updateviewport(void)
|
||||
{
|
||||
ud.screen_size = clamp(ud.screen_size, 0, 64);
|
||||
int ss = std::max(ud.screen_size - 8, 0);
|
||||
static const uint8_t size_vals[] = { 60, 54, 48, 40, 32, 24, 16, 8, 8, 4, 4, 0 };
|
||||
static const uint8_t size_vals_rr[] = { 56, 48, 40, 32, 24, 16, 12, 8, 8, 4, 4, 0 };
|
||||
int ss = isRR() ? size_vals_rr[hud_size] : size_vals[hud_size];
|
||||
|
||||
ss = std::max(ss - 8, 0);
|
||||
|
||||
int x1 = scale(ss, xdim, 160);
|
||||
int x2 = xdim - x1;
|
||||
|
||||
int y1 = scale(ss, (200 * 100) - ((tilesiz[TILE_BOTTOMSTATUSBAR].y >> (isRR() ? 1 : 0)) * ud.statusbarscale), 200 - tilesiz[TILE_BOTTOMSTATUSBAR].y);
|
||||
int y1 = scale(ss, (200 * 100) - ((tilesiz[TILE_BOTTOMSTATUSBAR].y >> (isRR() ? 1 : 0)) * hud_scale), 200 - tilesiz[TILE_BOTTOMSTATUSBAR].y);
|
||||
int y2 = 200 * 100 - y1;
|
||||
|
||||
if (isRR() && ud.screen_size <= 12)
|
||||
if (isRR() && hud_size > 6)
|
||||
{
|
||||
x1 = 0;
|
||||
x2 = xdim;
|
||||
y1 = 0;
|
||||
if (ud.statusbarmode)
|
||||
if (hud_size >= 8)
|
||||
y2 = 200 * 100;
|
||||
}
|
||||
|
||||
int fbh = 0;
|
||||
if (ud.screen_size > 0 && ud.coop != 1 && ud.multimode > 1)
|
||||
if (hud_size < 11 && ud.coop != 1 && ud.multimode > 1)
|
||||
{
|
||||
int j = 0;
|
||||
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
|
@ -312,8 +315,8 @@ void updateviewport(void)
|
|||
}
|
||||
|
||||
y1 += fbh * 100;
|
||||
if (ud.screen_size >= 8 && ud.statusbarmode == 0)
|
||||
y2 -= (tilesiz[TILE_BOTTOMSTATUSBAR].y >> (isRR() ? 1 : 0)) * ud.statusbarscale;
|
||||
if (hud_size <= 7)
|
||||
y2 -= (tilesiz[TILE_BOTTOMSTATUSBAR].y >> (isRR() ? 1 : 0)) * hud_scale;
|
||||
y1 = scale(y1, ydim, 200 * 100);
|
||||
y2 = scale(y2, ydim, 200 * 100);
|
||||
|
||||
|
@ -326,22 +329,9 @@ void updateviewport(void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool GameInterface::validate_hud(int layout)
|
||||
{
|
||||
return layout <= 11;
|
||||
}
|
||||
|
||||
void GameInterface::set_hud_layout(int layout)
|
||||
{
|
||||
static const uint8_t screen_size_vals[] = { 60, 54, 48, 40, 32, 24, 16, 8, 8, 4, 4, 0 };
|
||||
static const uint8_t screen_size_vals_rr[] = { 56, 48, 40, 32, 24, 16, 12, 8, 8, 4, 4, 0 };
|
||||
if (validate_hud(layout))
|
||||
{
|
||||
ud.screen_size = isRR()? screen_size_vals_rr[layout] : screen_size_vals[layout];
|
||||
ud.statusbarmode = layout >= 8;
|
||||
ud.althud = layout >= 10;
|
||||
if (xdim > 0 && ydim > 0) updateviewport();
|
||||
}
|
||||
if (xdim > 0 && ydim > 0) updateviewport();
|
||||
}
|
||||
|
||||
void GameInterface::PlayHudSound()
|
||||
|
@ -349,12 +339,6 @@ void GameInterface::PlayHudSound()
|
|||
S_PlaySound(isRR() ? 341 : THUD, CHAN_AUTO, CHANF_UI);
|
||||
}
|
||||
|
||||
void GameInterface::set_hud_scale(int scale)
|
||||
{
|
||||
ud.statusbarscale = clamp(scale, 36, 100);
|
||||
if (xdim > 0 && ydim > 0) updateviewport();
|
||||
}
|
||||
|
||||
void GameInterface::UpdateScreenSize()
|
||||
{
|
||||
updateviewport();
|
||||
|
|
|
@ -407,9 +407,9 @@ void PrintLevelName_d(double alpha);
|
|||
void drawstatusbar_d(int snum)
|
||||
{
|
||||
DDukeStatusBar dsb;
|
||||
if (ud.screen_size <= 4)
|
||||
if (hud_size >= 9)
|
||||
{
|
||||
dsb.DrawHud(snum, ud.screen_size < 4 ? 0 : ud.althud ? 1 : 2);
|
||||
dsb.DrawHud(snum, hud_size == 11 ? 0 : hud_size == 10 ? 1 : 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -290,7 +290,7 @@ public:
|
|||
BeginStatusBar(320, 200, h, true);
|
||||
DrawInventory(p, 160, 154, 0);
|
||||
|
||||
if (ud.screen_size > 8)
|
||||
if (hud_size < 7)
|
||||
DrawWeaponBar(p, top);
|
||||
|
||||
DrawGraphic(tileGetTexture(BOTTOMSTATUSBAR), 0, top, DI_ITEM_LEFT_TOP, 1, -1, -1, scale, scale);
|
||||
|
@ -391,9 +391,9 @@ void PrintLevelName_r(double alpha);
|
|||
void drawstatusbar_r(int snum)
|
||||
{
|
||||
DRedneckStatusBar dsb;
|
||||
if (ud.screen_size <= 4)
|
||||
if (hud_size >= 9)
|
||||
{
|
||||
dsb.DrawHud(snum, ud.screen_size < 4 ? 0 : ud.althud ? 1 : 2);
|
||||
dsb.DrawHud(snum, hud_size == 11 ? 0 : hud_size == 10 ? 1 : 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ struct input_t // original name was input which is too generic for a type name.
|
|||
|
||||
struct user_defs
|
||||
{
|
||||
unsigned char god, cashman, eog, showallmap;
|
||||
unsigned char god, cashman, eog;
|
||||
unsigned char show_help, scrollmode, clipping;
|
||||
char user_name[MAXPLAYERS][32];
|
||||
unsigned char overhead_on, last_overhead, showweapons;
|
||||
|
@ -69,17 +69,16 @@ struct user_defs
|
|||
int folfvel, folavel, folx, foly, fola;
|
||||
int reccnt;
|
||||
|
||||
int runkey_mode, statusbarscale, weaponswitch;
|
||||
int runkey_mode, weaponswitch;
|
||||
|
||||
int entered_name, shadows, executions, auto_run;
|
||||
int coords, tickrate, levelstats, m_coop, coop, screen_size;
|
||||
int coords, tickrate, levelstats, m_coop, coop;
|
||||
int wchoice[MAXPLAYERS][MAX_WEAPONS], playerai;
|
||||
|
||||
int respawn_monsters, respawn_items, respawn_inventory, recstat, monsters_off, brightness;
|
||||
int m_respawn_items, m_respawn_monsters, m_respawn_inventory, m_recstat, m_monsters_off, detail;
|
||||
int m_ffire, ffire, m_player_skill, multimode;
|
||||
int player_skill, marker;
|
||||
int statusbarmode, althud;
|
||||
MapRecord* nextLevel;
|
||||
|
||||
};
|
||||
|
|
|
@ -3806,8 +3806,6 @@ void GameInterface::set_hud_layout(int requested_size)
|
|||
SetBorder(Player + myconnectindex, gs.BorderNum);
|
||||
SetRedrawScreen(Player + myconnectindex);
|
||||
}
|
||||
/*extern*/ void GameInterface::set_hud_scale(int requested_size) { }
|
||||
|
||||
::GameInterface* CreateInterface()
|
||||
{
|
||||
return new GameInterface;
|
||||
|
|
|
@ -2538,7 +2538,6 @@ struct GameInterface : ::GameInterface
|
|||
void FreeGameData() override;
|
||||
bool GenerateSavePic() override;
|
||||
void set_hud_layout(int size) override;
|
||||
void set_hud_scale(int size) override;
|
||||
void DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) override;
|
||||
void MenuOpened() override;
|
||||
void MenuSound(EMenuSounds snd) override;
|
||||
|
|
Loading…
Reference in a new issue