- implementing the Witchaven menu.

Main menu is working, skill menu still to do.
This commit is contained in:
Christoph Oelckers 2020-10-25 22:11:00 +01:00
parent 6dfd36dba7
commit 45d2fd95a9
7 changed files with 217 additions and 5 deletions

View file

@ -1347,6 +1347,8 @@ static const gamefilter games[] = {
{ "Plutopak", GAMEFLAG_PLUTOPAK},
{ "Worldtour", GAMEFLAG_WORLDTOUR},
{ "Shareware", GAMEFLAG_SHAREWARE},
{ "Witchaven", GAMEFLAG_WH},
{ "Witchaven2", GAMEFLAG_WH2},
};
bool validFilter(const char* str)

View file

@ -15,10 +15,11 @@ void InitFonts()
{
// Remap table for the menu font.
uint8_t remapbuf[256];
for (int i = 0; i < 256; i++) remapbuf[i] = i;
for(int i = 242; i < 252; i++) //yellow to green
remapbuf[i] = (uint8_t) (368 - i);
for(int i = 117; i < 127; i++) //green to yellow
remapbuf[i] = (uint8_t) (368 - i);
//for(int i = 117; i < 127; i++) //green to yellow
//remapbuf[i] = (uint8_t) (368 - i);
lookups.makeTable(20, remapbuf, 0, 0, 0, true);
GlyphSet fontdata;

View file

@ -255,7 +255,12 @@ void GameInterface::Startup()
}
}
bool showmainmenu;
bool GameInterface::CanSave()
{
return false;// !bRecord && !bPlayback && !paused && !bInDemo && nTotalPlayers == 1;
}
void GameInterface::DrawBackground()
{
if (isWh2())
@ -264,7 +269,8 @@ void GameInterface::DrawBackground()
}
else
{
// This only shows the low res menu, the larger one is rather poor.
bool showmainmenu = CurrentMenu && CurrentMenu->GetClass()->TypeName == FName("WHMainMenu");
// This only shows the low res menu, the larger one is rather poor because it places the actual menu into a postage stamp size window.
DrawTexture(twod, tileGetTexture(showmainmenu ? MAINMENU : TITLEPIC), 0, 0, DTA_Fullscreen, FSMode_ScaleToFit43, TAG_DONE);
}
}

View file

@ -480,7 +480,7 @@ struct GameInterface : public ::GameInterface
//GameStats getStats() override;
//void MenuOpened() override;
//void MenuSound(EMenuSounds snd) override;
//bool CanSave() override;
bool CanSave() override;
//bool StartGame(FNewGameStartup& gs) override;
//FSavegameInfo GetSaveSig() override;
//void SerializeGameState(FSerializer& arc) override;

View file

@ -66,6 +66,29 @@ LISTMENU "MainMenu"
ExhumedTextItem "$MNU_OPTIONS", "v", "OptionsMenu"
ExhumedTextItem "$MNU_QUITGAME", "q", "QuitMenu"
}
ifgame(Witchaven)
{
class "WHMainMenu"
position 213, 60
Linespacing 18
WH1TextItem "$MNU_NEWGAME", "n", "SkillMenu"
WH1TextItem "$MNU_MULTIPLAYER", "m", "MultiMenu"
WH1TextItem "$MNU_OPTIONS", "o", "OptionsMenu"
WH1TextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
WH1TextItem "$MNU_QUITGAME", "q", "QuitMenu"
}
/*
ifgame(Witchaven2)
{
position 160, 50
Linespacing 14
WH2TextItem "$MNU_NEWGAME", "n", "SkillMenu"
WH2TextItem "$MNU_MULTIPLAYER", "m", "MultiMenu"
WH2TextItem "$MNU_OPTIONS", "o", "OptionsMenu"
WH2TextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
WH2TextItem "$MNU_QUITGAME", "q", "QuitMenu"
}
*/
}
//-------------------------------------------------------------------------------------------
@ -136,6 +159,30 @@ LISTMENU "IngameMenu"
ExhumedTextItem "$MNU_OPTIONS", "v", "OptionsMenu"
ExhumedTextItem "$MNU_QUITGAME", "q", "QuitMenu"
}
ifgame(Witchaven)
{
position 160, 50
Linespacing 16
WH1TextItem "$MNU_NEWGAME", "n", "SkillMenu"
WH1TextItem "$MNU_OPTIONS", "o", "OptionsMenu"
WH1TextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
WH1TextItem "$MNU_SAVEGAME", "s", "SaveGameMenu"
WH1TextItem "$MNU_ENDGAME", "e", "EndgameMenu"
WH1TextItem "$MNU_QUITGAME", "q", "QuitMenu"
}
/*
ifgame(Witchaven2)
{
position 160, 50
Linespacing 15
WH2TextItem "$MNU_NEWGAME", "n", "SkillMenu"
WH2TextItem "$MNU_OPTIONS", "o", "OptionsMenu"
WH2TextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
WH2TextItem "$MNU_SAVEGAME", "s", "SaveGameMenu"
WH2TextItem "$MNU_ENDGAME", "e", ""EndgameMenu"
WH2TextItem "$MNU_QUITGAME", "q", "QuitMenu"
}
*/
}
//-------------------------------------------------------------------------------------------
@ -190,6 +237,20 @@ LISTMENU "SkillMenu"
Position 35, 32
Linespacing 17
}
/*
ifgame(Witchaven)
{
CaptionItem "$MNU_DIFFICULTY"
Position 35, 32
Linespacing 17
}
ifgame(Witchaven2)
{
CaptionItem "$MNU_DIFFICULTY"
Position 35, 32
Linespacing 17
}
*/
}
//-------------------------------------------------------------------------------------------

View file

@ -32,3 +32,4 @@ version "4.3"
#include "zscript/games/blood/ui/menu.zs"
#include "zscript/games/sw/ui/menu.zs"
#include "zscript/games/exhumed/ui/menu.zs"
#include "zscript/games/wh/ui/menu_wh1.zs"

View file

@ -0,0 +1,141 @@
class WHMenuDelegate : RazeMenuDelegate
{
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");
let fontscale = 1.;
if (drawit)
{
int width = font.StringWidth(title) * fontscale;
double scalex = 1.;
if (texid.isValid())
{
if (texsize.X - 60 < width)
{
// First start squashing the font down to 0.7x the original width.
fontscale = (texsize.X - 66) / width;
if (fontscale < 0.7)
{
// If that is not enough, extend the box.
fontscale = 0.7;
width *= 0.7;
scalex = width / (texsize.X - 66);
}
else width *= fontscale;
}
screen.DrawTexture(texid, false, 160, 15, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_CenterOffsetRel, true, DTA_ScaleX, scalex);
}
screen.DrawText(font, Font.CR_UNTRANSLATED, 160 - width / 2, 17 - fonth / 2, title, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_ScaleX, fontscale);
}
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.
*/
return y;
}
override bool DrawSelector(ListMenuDescriptor desc)
{
/*
let item = desc.mItems[desc.mSelectedItem];
let x = item.GetX();
let y = item.GetY();
let tex = TexMan.CheckForTexture("YINYANG");
x -= TexMan.GetSize(tex) / 4 + 2;
y += 4;
Screen.DrawTexture(tex, true, x, y, DTA_FullscreenScale, FSMode_Fit320x200,
DTA_CenterOffset, true, DTA_Color, 0xfff0f0f0, DTA_ScaleX, 0.5, DTA_ScaleY, 0.5);
*/
return true;
}
}
class WHMainMenu : ListMenu
{
}
//=============================================================================
//
// logo
//
//=============================================================================
class ListMenuItemWHLogo : ListMenuItem
{
void Init(ListMenuDescriptor desc)
{
Super.Init(0, 0);
}
override void Draw(bool selected, ListMenuDescriptor desc)
{
screen.DrawTexture(TexMan.CheckForTexture("menulogo"), false, 160, 15, DTA_FullscreenScale, FSMode_Fit320x200, DTA_CenterOffsetRel, true, DTA_Color, 0xfff0f0f0);
}
}
//=============================================================================
//
// text item
//
//=============================================================================
class ListMenuItemWH1TextItem : ListMenuItemTextItem
{
void Init(ListMenuDescriptor desc, String text, String hotkey, Name child, int param = 0)
{
Super.Init(desc, text, hotkey, child, param);
if (child == 'none') mEnabled = -1;
}
void InitDirect(double x, double y, int height, String hotkey, String text, Font font, int color, int color2, Name child, int param = 0)
{
Super.InitDirect(x, y, height, hotkey, text, font, color, color2, child, param);
}
override void Draw(bool selected, ListMenuDescriptor desc)
{
let gamefont = generic_ui ? NewSmallFont : BigFont;
int cr = generic_ui? Font.CR_Fire : Font.CR_UNDEFINED;
double scalex = 1.;
int trans = 0;
Color colr = Color(255, 255, 255, 255);
let fontscale = 0.7;
double length = gamefont.StringWidth(mText) * fontscale;
double xpos = mXpos - length / 2;
if (xpos + length > 315)
{
xpos = 315 - length;
}
if (gamefont == NewSmallFont)
{
if (!selectable()) cr = Font.CR_BLACK;
else if (selected) cr = Font.CR_GREEN;
}
else
{
if (!selectable()) cr = Font.CR_BLACK;
else if (selected) trans = Translation.MakeID(Translation_Remap, 20);
}
if (!selectable()) colr = Color(255, 128, 128, 128);
if (selected)
{
int mclock = MSTime() * 120 / 1000;
int light = 223 + (Build.calcSinTableValue(mclock<<4) / 512.);
colr = Color(255, light, light, light);
}
Screen.DrawText(BigFont, cr, xpos, mYpos, mText, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Color, colr, DTA_TranslationIndex, trans, DTA_ScaleX, scalex * fontscale, DTA_ScaleY, fontscale);
}
}