- WIP commit.

This commit is contained in:
Christoph Oelckers 2019-11-23 12:38:38 +01:00
parent ceb07280cf
commit f2fc3fc2cb
14 changed files with 248 additions and 158 deletions

View file

@ -168,6 +168,14 @@ struct GameStats
int timesecnd;
};
enum ETextOrientation
{
TOR_Default,
TOR_Left,
TOR_Center,
TOR_Right
};
struct GameInterface
{
virtual ~GameInterface() {}
@ -179,6 +187,9 @@ struct GameInterface
virtual bool mouseInactiveConditional(bool condition) { return condition; }
virtual FString statFPS() { return "FPS display not available"; }
virtual GameStats getStats() { return {}; }
virtual void DrawNativeMenuText(int fontnum, int palnum, int xpos, int ypos, float fontscale, const char* text, int orientation = TOR_Default) {}
virtual int GetMenuFontHeight(int fontnum) { return 16; /* something arbitrarily non-zero */ }
virtual int GetMenuTextWidth(int fontnum, const char* text) { return 10 * strlen(text); }
};
extern GameInterface* gi;

View file

@ -403,7 +403,7 @@ void V_InitFontColors ()
TranslationLookup.Clear();
TranslationColors.Clear();
while ((lump = fileSystem.Iterate("textcolors.txt", &lastlump)) != -1)
while ((lump = fileSystem.Iterate("demolition/textcolors.txt", &lastlump)) != -1)
{
FScanner sc(lump);
while (sc.GetString())

View file

@ -24,6 +24,7 @@
#include "z_music.h"
#include "statistics.h"
#include "menu.h"
#include "gstrings.h"
#ifndef NETCODE_DISABLE
#include "enet.h"
#endif
@ -378,6 +379,7 @@ int CONFIG_Init()
{
playername = userConfig.CommandName;
}
GStrings.LoadStrings();
V_InitFonts();
buttonMap.SetGameAliases();
Mus_Init();

View file

@ -39,6 +39,7 @@
#include "d_event.h"
#include "menu.h"
#include "v_draw.h"
#include "baselayer.h"
//=============================================================================
//
@ -254,10 +255,14 @@ void DListMenu::Drawer ()
PreDraw();
for(unsigned i=0;i<mDesc->mItems.Size(); i++)
{
if (mDesc->mItems[i]->mEnabled) mDesc->mItems[i]->Drawer(mDesc->mSelectedItem == (int)i);
auto o = origin;
if (mDesc->mItems[i]->mEnabled) mDesc->mItems[i]->Drawer(o, mDesc->mSelectedItem == (int)i);
o.y += gi->GetMenuFontHeight(mDesc->mNativeFontNum);
}
/*
if (mDesc->mSelectedItem >= 0 && mDesc->mSelectedItem < (int)mDesc->mItems.Size())
mDesc->mItems[mDesc->mSelectedItem]->DrawSelector(mDesc->mSelectOfsX, mDesc->mSelectOfsY, mDesc->mSelector);
*/
PostDraw();
Super::Drawer();
}
@ -281,7 +286,7 @@ void FListMenuItem::Ticker()
{
}
void FListMenuItem::Drawer(bool selected)
void FListMenuItem::Drawer(const vec2_t& origin, bool selected)
{
}
@ -380,7 +385,7 @@ FListMenuItemStaticPatch::FListMenuItemStaticPatch(int x, int y, FTexture *patch
mCentered = centered;
}
void FListMenuItemStaticPatch::Drawer(bool selected)
void FListMenuItemStaticPatch::Drawer(const vec2_t& origin, bool selected)
{
if (!mTexture)
{
@ -417,7 +422,7 @@ FListMenuItemStaticText::FListMenuItemStaticText(int x, int y, const char *text,
mCentered = centered;
}
void FListMenuItemStaticText::Drawer(bool selected)
void FListMenuItemStaticText::Drawer(const vec2_t& origin, bool selected)
{
const char *text = mText;
if (text != NULL)
@ -521,7 +526,7 @@ FListMenuItemText::~FListMenuItemText()
{
}
void FListMenuItemText::Drawer(bool selected)
void FListMenuItemText::Drawer(const vec2_t& origin, bool selected)
{
const char *text = mText;
if (mText.Len())
@ -543,6 +548,48 @@ int FListMenuItemText::GetWidth()
}
//=============================================================================
//
// native text item
//
//=============================================================================
FListMenuItemNativeText::FListMenuItemNativeText(int x, int y, int height, int hotkey, const FString& text, int fontnum, int palnum, float fontscale, FName child, int param)
: FListMenuItemSelectable(x, y, height, child, param)
{
mText = text;
mFontnum = NIT_BigFont;
mPalnum = NIT_ActiveColor;
mFontscale = fontscale;
mHotkey = hotkey;
}
FListMenuItemNativeText::~FListMenuItemNativeText()
{
}
void FListMenuItemNativeText::Drawer(const vec2_t& origin, bool selected)
{
const char* text = mText;
if (mText.Len())
{
if (*text == '$') text = GStrings(text + 1);
gi->DrawNativeMenuText(mFontnum, selected ? NIT_SelectedColor : mPalnum, mXpos + origin.x, mYpos + origin.y, mFontscale, text);
}
}
int FListMenuItemText::GetWidth()
{
const char* text = mText;
if (mText.Len())
{
if (*text == '$') text = GStrings(text + 1);
return mFont->StringWidth(text);
}
return 1;
}
//=============================================================================
//
// patch item
@ -556,7 +603,7 @@ FListMenuItemPatch::FListMenuItemPatch(int x, int y, int height, int hotkey, FTe
mTexture = patch;
}
void FListMenuItemPatch::Drawer(bool selected)
void FListMenuItemPatch::Drawer(const vec2_t& origin, bool selected)
{
DrawTexture (&twod, mTexture, mXpos, mYpos, DTA_Clean, true, TAG_DONE);
}

View file

@ -53,6 +53,18 @@ enum EMenuKey
MKEY_MBNo,
};
enum ENativeFontValues
{
NIT_BigFont,
NIT_SmallFont,
NIT_TinyFont,
NIT_ActiveColor = -1,
NIT_InactiveColor = -2,
NIT_SelectedColor = -3
// positive values for color are direct palswap indices.
};
struct FGameStartup
{
@ -118,11 +130,13 @@ struct FListMenuDescriptor : public FMenuDescriptor
int mAutoselect; // this can only be set by internal menu creation functions
int mScriptId;
int mSecondaryId;
int mNativeFontNum, mNativePalNum;
float mNativeFontScale;
FFont *mFont;
EColorRange mFontColor;
EColorRange mFontColor2;
FMenuDescriptor *mRedirect; // used to redirect overlong skill and episode menus to option menu based alternatives
bool mCenter;
int mCenter;
void Reset()
{
@ -140,6 +154,9 @@ struct FListMenuDescriptor : public FMenuDescriptor
mFontColor2 = CR_UNTRANSLATED;
mScriptId = 0;
mSecondaryId = 0;
mNativeFontNum = NIT_BigFont;
mNativePalNum = NIT_ActiveColor;
mNativeFontScale = 1.f;
}
};
@ -289,7 +306,7 @@ public:
virtual bool CheckCoordinate(int x, int y);
virtual void Ticker();
virtual void Drawer(bool selected);
virtual void Drawer(const vec2_t &origin, bool selected);
virtual bool Selectable();
virtual bool Activate();
virtual FName GetAction(int *pparam);
@ -317,7 +334,7 @@ protected:
public:
FListMenuItemStaticPatch(int x, int y, FTexture *patch, bool centered);
void Drawer(bool selected);
void Drawer(const vec2_t& origin, bool selected);
};
class FListMenuItemStaticText : public FListMenuItem
@ -331,56 +348,9 @@ protected:
public:
FListMenuItemStaticText(int x, int y, const char *text, FFont *font, EColorRange color, bool centered);
~FListMenuItemStaticText();
void Drawer(bool selected);
void Drawer(const vec2_t& origin, bool selected) override;
};
//=============================================================================
//
// the player sprite window
//
//=============================================================================
#if 0
class FListMenuItemPlayerDisplay : public FListMenuItem
{
FListMenuDescriptor *mOwner;
FTexture *mBackdrop;
FRemapTable mRemap;
FPlayerClass *mPlayerClass;
int mPlayerTics;
bool mNoportrait;
uint8_t mRotation;
uint8_t mMode; // 0: automatic (used by class selection), 1: manual (used by player setup)
uint8_t mTranslate;
int mSkin;
int mRandomClass;
int mRandomTimer;
int mClassNum;
void SetPlayerClass(int classnum, bool force = false);
bool UpdatePlayerClass();
void UpdateRandomClass();
void UpdateTranslation();
public:
enum
{
PDF_ROTATION = 0x10001,
PDF_SKIN = 0x10002,
PDF_CLASS = 0x10003,
PDF_MODE = 0x10004,
PDF_TRANSLATE = 0x10005,
};
FListMenuItemPlayerDisplay(FListMenuDescriptor *menu, int x, int y, PalEntry c1, PalEntry c2, bool np, FName action);
~FListMenuItemPlayerDisplay();
virtual void Ticker();
virtual void Drawer(bool selected);
bool SetValue(int i, int value);
};
#endif
//=============================================================================
//
// selectable items
@ -396,12 +366,12 @@ protected:
public:
FListMenuItemSelectable(int x, int y, int height, FName childmenu, int mParam = -1);
bool CheckCoordinate(int x, int y);
bool Selectable();
bool CheckHotkey(int c);
bool Activate();
bool MouseEvent(int type, int x, int y);
FName GetAction(int *pparam);
bool CheckCoordinate(int x, int y) override;
bool Selectable() override;
bool CheckHotkey(int c) override;
bool Activate() override;
bool MouseEvent(int type, int x, int y) override;
FName GetAction(int *pparam) override;
};
class FListMenuItemText : public FListMenuItemSelectable
@ -413,17 +383,32 @@ class FListMenuItemText : public FListMenuItemSelectable
public:
FListMenuItemText(int x, int y, int height, int hotkey, const FString &text, FFont *font, EColorRange color, EColorRange color2, FName child, int param = 0);
~FListMenuItemText();
void Drawer(bool selected);
int GetWidth();
void Drawer(const vec2_t& origin, bool selected) override;
int GetWidth() override;
};
class FListMenuItemNativeText : public FListMenuItemSelectable
{
// This draws the item with the game frontend's native text drawer and uses a front end defined font, it takes only symbolic constants as parameters.
FString mText;
int mFontnum;
int mPalnum;
float mFontscale;
public:
FListMenuItemNativeText(int x, int y, int height, int hotkey, const FString& text, int fontnum, int palnum, float fontscale, FName child, int param = 0);
~FListMenuItemNativeText();
void Drawer(const vec2_t& origin, bool selected) override;
int GetWidth() override;
};
class FListMenuItemPatch : public FListMenuItemSelectable
{
FTexture* mTexture;
public:
FListMenuItemPatch(int x, int y, int height, int hotkey, FTexture* patch, FName child, int param = 0);
void Drawer(bool selected);
int GetWidth();
void Drawer(const vec2_t& origin, bool selected) override;
int GetWidth() override;
};
//=============================================================================

View file

@ -159,7 +159,7 @@ static bool CheckSkipGameBlock(FScanner &sc)
if (!(filter & 1)) // todo: apply correct filter.
{
SkipSubBlock(sc);
return true;
return !sc.CheckString("else");
}
return false;
}
@ -362,26 +362,90 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc)
if (desc->mSelectedItem == -1) desc->mSelectedItem = desc->mItems.Size()-1;
}
else if (sc.Compare("Font"))
else if (sc.Compare("NativeTextItem"))
{
sc.MustGetString();
FString text = sc.String;
sc.MustGetStringName(",");
sc.MustGetString();
int hotkey = sc.String[0];
sc.MustGetStringName(",");
sc.MustGetString();
FName action = sc.String;
int param = 0;
if (sc.CheckString(","))
{
sc.MustGetNumber();
param = sc.Number;
}
auto it = new FListMenuItemNativeText(desc->mXpos, desc->mYpos, desc->mLinespacing, hotkey, text, desc->mNativeFontNum, desc->mNativePalNum, desc->mNativeFontScale, action, param);
desc->mItems.Push(it);
desc->mYpos += desc->mLinespacing;
if (desc->mSelectedItem == -1) desc->mSelectedItem = desc->mItems.Size() - 1;
}
else if (sc.Compare("NativeFont"))
{
desc->mNativePalNum = NIT_ActiveColor;
desc->mNativeFontScale = 1.f;
sc.MustGetString();
FFont *newfont = V_GetFont(sc.String);
if (newfont != NULL) desc->mFont = newfont;
if (sc.Compare("Big")) desc->mNativeFontNum = NIT_BigFont;
else if (sc.Compare("Small")) desc->mNativeFontNum = NIT_SmallFont;
else if (sc.Compare("Tiny")) desc->mNativeFontNum = NIT_TinyFont;
else sc.ScriptError("Unknown native font type");
if (sc.CheckString(","))
{
sc.MustGetString();
desc->mFontColor2 = desc->mFontColor = V_FindFontColor((FName)sc.String);
if (sc.Compare("Active")) desc->mNativePalNum = NIT_ActiveColor;
else if (sc.Compare("Inactive")) desc->mNativePalNum = NIT_InactiveColor;
else if (sc.Compare("Selected")) desc->mNativePalNum = NIT_SelectedColor;
else
{
char* ep;
int v = (int)strtoll(sc.String, &ep, 0);
if (*ep != 0) sc.ScriptError("Unknown native palette");
desc->mNativePalNum = v;
}
if (sc.CheckString(","))
{
sc.MustGetString();
desc->mFontColor2 = V_FindFontColor((FName)sc.String);
sc.MustGetFloat();
desc->mNativeFontScale = sc.Float;
}
}
}
else if (sc.Compare("Position"))
{
sc.MustGetNumber();
sc.MustGetStringName(",");
desc->mXpos = sc.Number;
sc.MustGetNumber();
desc->mYpos = sc.Number;
if (sc.CheckString(","))
{
desc->mCenter = sc.Number;
}
}
else if (sc.Compare("Font"))
{
sc.MustGetString();
FFont* newfont = V_GetFont(sc.String);
if (newfont != NULL) desc->mFont = newfont;
if (sc.CheckString(","))
{
sc.MustGetString();
desc->mFontColor2 = desc->mFontColor = V_FindFontColor((FName)sc.String);
if (sc.CheckString(","))
{
sc.MustGetString();
desc->mFontColor2 = V_FindFontColor((FName)sc.String);
}
}
else
{
desc->mFontColor = OptionSettings.mFontColor;
desc->mFontColor2 = OptionSettings.mFontColorValue;
}
else
{
desc->mFontColor = OptionSettings.mFontColor;
desc->mFontColor2 = OptionSettings.mFontColorValue;
}
}
else if (sc.Compare("NetgameMessage"))
{

View file

@ -60,13 +60,13 @@ void FStringTable::LoadStrings ()
int lastlump, lump;
lastlump = 0;
while ((lump = fileSystem.Iterate("Language/lmacros", &lastlump, ELookupMode::NoExtension)) != -1)
while ((lump = fileSystem.Iterate("demolition/lmacros", &lastlump, ELookupMode::NoExtension)) != -1)
{
readMacros(lump);
}
lastlump = 0;
while ((lump = fileSystem.Iterate ("Language/language", &lastlump, ELookupMode::NoExtension)) != -1)
while ((lump = fileSystem.Iterate ("demolition/language", &lastlump, ELookupMode::NoExtension)) != -1)
{
auto lumpdata = fileSystem.GetFileData(lump);

View file

@ -154,6 +154,12 @@ struct GameInterface : ::GameInterface
bool mouseInactiveConditional(bool condition) override;
FString statFPS() override;
GameStats getStats() override;
// Access to the front end specific menu code. Use is restricted to the main menu, the ingame menu and the skill/episode selection.
// Everything else is either custom screens or will use the generic option menu style.
void DrawNativeMenuText(int fontnum, int palnum, int xpos, int ypos, float fontscale, const char* text, int orientation = TOR_Default) override;
int GetMenuFontHeight(int fontnum) override;
int GetMenuTextWidth(int fontnum, const char* text) override;
};
END_DUKE_NS

View file

@ -192,22 +192,6 @@ they effectively stand in for curly braces as struct initializers.
MenuGameplayStemEntry g_MenuGameplayEntries[MAXMENUGAMEPLAYENTRIES];
// common font types
// tilenums are set after namesdyn runs
// emptychar x,y between x,y zoom cursorLeft cursorCenter cursorScale textflags
// tilenum shade_deselected shade_disabled pal pal_selected pal_deselected pal_disabled
MenuFont_t MF_Redfont = { { 5<<16, 15<<16 }, { 0, 0 }, 65536, 20<<16, 110<<16, 65536, TEXT_BIGALPHANUM | TEXT_UPPERCASE,
-1, 10, 0, 0, 0, 0, 1,
0, 0, 1 };
MenuFont_t MF_Bluefont = { { 5<<16, 7<<16 }, { 0, 0 }, 65536, 10<<16, 110<<16, 32768, 0,
-1, 10, 0, 0, 10, 10, 16,
0, 0, 16 };
MenuFont_t MF_Minifont = { { 4<<16, 5<<16 }, { 1<<16, 1<<16 }, 65536, 10<<16, 110<<16, 32768, 0,
-1, 10, 0, 0, 2, 2, 0,
0, 0, 16 };
static MenuMenuFormat_t MMF_Top_Main = { { MENU_MARGIN_CENTER<<16, 55<<16, }, -(170<<16) };
static MenuMenuFormat_t MMF_Top_Episode = { { MENU_MARGIN_CENTER<<16, 48<<16, }, -(190<<16) };
static MenuMenuFormat_t MMF_Top_NewGameCustom = { { MENU_MARGIN_CENTER<<16, 48<<16, }, -(190<<16) };

View file

@ -1693,36 +1693,6 @@ void Menu_Init(void)
}
}
#if 0
// prepare sound setup
if (WW2GI)
ME_SOUND_DUKETALK.name = "GI talk:";
else if (NAM)
ME_SOUND_DUKETALK.name = "Grunt talk:";
if (IONMAIDEN)
{
MF_Redfont.between.x = 2<<16;
MF_Redfont.cursorScale = 32768;
MF_Redfont.zoom = 16384;
MF_Bluefont.zoom = 16384;
// hack; should swap out pointers
MF_Minifont = MF_Bluefont;
MMF_Top_Main.pos.x = 40<<16;
MMF_Top_Main.pos.y = 130<<16;
MMF_Top_Main.bottomcutoff = 190<<16;
M_OPTIONS.format = &MMF_Top_Main;
MEF_MainMenu.width = MEF_OptionsMenu.width = -(160<<16);
MEF_MainMenu.marginBottom = 7<<16;
M_OPTIONS.title = NoTitle;
SELECTDIR_z = 16384;
}
#endif
if (RR)
{