- implemented the menu caption for Duke et.al.

This commit is contained in:
Christoph Oelckers 2020-10-06 20:49:55 +02:00
parent d22bdf9dc7
commit bec1f67178
6 changed files with 92 additions and 17 deletions

View file

@ -72,6 +72,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "d_net.h"
#include "automap.h"
#include "v_draw.h"
#include "gi.h"
CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
@ -744,6 +745,7 @@ static TArray<GrpEntry> SetupGame()
currentGame = LumpFilter;
currentGame.Truncate(currentGame.IndexOf("."));
CheckFrontend(g_gameType);
gameinfo.gametype = g_gameType;
return usedgroups;
}

View file

@ -1111,6 +1111,7 @@ bool CheckSkipGameOptionBlock(FScanner &sc)
#endif
void SetDefaultMenuColors()
{
PClass* cls = nullptr;
//OptionSettings.mTitleColor = CR_RED;// V_FindFontColor(gameinfo.mTitleColor);
OptionSettings.mFontColor = CR_RED;
OptionSettings.mFontColorValue = CR_GRAY;
@ -1119,31 +1120,43 @@ void SetDefaultMenuColors()
OptionSettings.mFontColorHighlight = CR_YELLOW;
OptionSettings.mFontColorSelection = CR_BRICK;
if (g_gameType & (GAMEFLAG_NAM | GAMEFLAG_NAPALM | GAMEFLAG_WW2GI))
{
OptionSettings.mFontColor = CR_DARKGREEN;
OptionSettings.mFontColorHeader = CR_DARKGRAY;
OptionSettings.mFontColorHighlight = CR_WHITE;
OptionSettings.mFontColorSelection = CR_DARKGREEN;
}
else if (g_gameType & GAMEFLAG_BLOOD)
if (g_gameType & GAMEFLAG_BLOOD)
{
OptionSettings.mFontColorHeader = CR_DARKGRAY;
OptionSettings.mFontColorHighlight = CR_WHITE;
OptionSettings.mFontColorSelection = CR_DARKRED;
auto cls = PClass::FindClass("MenuCustomizerBlood");
if (cls) menuCustomizer = cls->CreateNew();
}
else if (g_gameType & GAMEFLAG_RRALL)
{
OptionSettings.mFontColor = CR_BROWN;
OptionSettings.mFontColorHeader = CR_DARKBROWN;
OptionSettings.mFontColorHighlight = CR_ORANGE;
OptionSettings.mFontColorSelection = CR_TAN;
cls = PClass::FindClass("MenuCustomizerBlood");
}
else if (g_gameType & GAMEFLAG_SW)
{
OptionSettings.mFontColorHeader = CR_DARKRED;
OptionSettings.mFontColorHighlight = CR_WHITE;
}
else if (g_gameType & GAMEFLAG_PSEXHUMED)
{
OptionSettings.mFontColorHeader = CR_LIGHTBLUE;
OptionSettings.mFontColorHighlight = CR_SAPPHIRE;
OptionSettings.mFontColor = CR_GOLD;
}
else
{
if (g_gameType & (GAMEFLAG_NAM | GAMEFLAG_NAPALM | GAMEFLAG_WW2GI))
{
OptionSettings.mFontColor = CR_DARKGREEN;
OptionSettings.mFontColorHeader = CR_DARKGRAY;
OptionSettings.mFontColorHighlight = CR_WHITE;
OptionSettings.mFontColorSelection = CR_DARKGREEN;
}
else if (g_gameType & GAMEFLAG_RRALL)
{
OptionSettings.mFontColor = CR_BROWN;
OptionSettings.mFontColorHeader = CR_DARKBROWN;
OptionSettings.mFontColorHighlight = CR_ORANGE;
OptionSettings.mFontColorSelection = CR_TAN;
}
cls = PClass::FindClass("MenuCustomizerDuke");
}
if (!cls) cls = PClass::FindClass("MenuCustomize");
if (cls) menuCustomizer = cls->CreateNew();
}

View file

@ -46,6 +46,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "sounds.h"
#include "conlabel.h"
#include "conlabeldef.h"
#include "gi.h"
BEGIN_DUKE_NS
@ -1880,6 +1881,7 @@ int ConCompiler::parsecommand()
else if (pcount == 31) g_gameType |= GAMEFLAG_PLUTOPAK | GAMEFLAG_WORLDTOUR;
else if (pcount != 26) I_FatalError("Invalid CONs. Cannot detect version. gamestartup has %d entries", pcount);
}
gameinfo.gametype = g_gameType;
popscriptvalue();
auto parseone = [&]() { return params[pget++]; };

View file

@ -21,5 +21,6 @@ version "4.3"
#include "zscript/ui/menu/textentermenu.zs"
#include "zscript/ui/menu/menucustomize.zs"
#include "zscript/games/duke/ui/menu.zs"
#include "zscript/games/blood/ui/menu.zs"

View file

@ -0,0 +1,27 @@
class MenuCustomizerDuke : MenuCustomize
{
override int DrawCaption(String title, Font fnt, int y, bool drawit)
{
let font = generic_ui? NewConsoleFont : BigFont; // this ignores the passed font intentionally.
let texid = TexMan.CheckForTexture("MENUBAR");
let texsize = TexMan.GetScaledSize(texid);
let fonth = font.GetGlyphHeight("A");
if (drawit)
{
int width = font.StringWidth(title);
double scalex = (gameinfo.gameType & GAMEFLAG_RRALL)? 0.4 : 1.;
double scaley = scalex;
if (texid.isValid())
{
screen.DrawTexture(texid, false, 160, 19, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_CenterOffsetRel, true, DTA_Color, 0xff808080);
if (texsize.X - 30 < width) scalex = (texsize.X - 30) / width; // Squash the text if it doesn't fit.
}
screen.DrawText(font, Font.CR_UNTRANSLATED, 160 - width / 2 * scalex, 18 - fonth / 2 * scaley, title, DTA_ScaleX, scalex, DTA_ScaleY, scaley, DTA_FullscreenScale, FSMode_Fit320x200Top);
}
double fx, fy, fw, fh;
[fx, fy, fw, fh] = Screen.GetFullscreenRect(320, 200, FSMode_ScaleToFit43Top);
int h = texid.isValid()? texsize.Y : fonth;
return int((y+h) * fh / 200); // This must be the covered height of the header in true pixels.
}
}

View file

@ -1,3 +1,33 @@
enum EGameType
{
GAMEFLAG_DUKE = 0x00000001,
GAMEFLAG_NAM = 0x00000002,
GAMEFLAG_NAPALM = 0x00000004,
GAMEFLAG_WW2GI = 0x00000008,
GAMEFLAG_ADDON = 0x00000010,
GAMEFLAG_SHAREWARE = 0x00000020,
GAMEFLAG_DUKEBETA = 0x00000060, // includes 0x20 since it's a shareware beta
GAMEFLAG_PLUTOPAK = 0x00000080,
GAMEFLAG_RR = 0x00000100,
GAMEFLAG_RRRA = 0x00000200,
GAMEFLAG_RRALL = GAMEFLAG_RR | GAMEFLAG_RRRA,
GAMEFLAG_BLOOD = 0x00000800,
GAMEFLAG_SW = 0x00001000,
GAMEFLAG_POWERSLAVE = 0x00002000,
GAMEFLAG_EXHUMED = 0x00004000,
GAMEFLAG_PSEXHUMED = GAMEFLAG_POWERSLAVE | GAMEFLAG_EXHUMED, // the two games really are the same, except for the name and the publisher.
GAMEFLAG_WORLDTOUR = 0x00008000,
GAMEFLAG_DUKEDC = 0x00010000,
GAMEFLAGMASK = 0x0000FFFF, // flags allowed from grpinfo
// We still need these for the parsers.
GAMEFLAG_FURY = 0,
GAMEFLAG_DEER = 0,
};
/*
struct TileFiles
{