diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index 5b304d1a3..fd7cb6f51 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -80,10 +80,8 @@ struct GameInterface : ::GameInterface void MenuClosed() override; bool CanSave() override; bool StartGame(FNewGameStartup& gs) override; - void DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) override; bool SaveGame(FSaveGameNode*) override; bool LoadGame(FSaveGameNode*) override; - void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override; void QuitToTitle() override; FString GetCoordString() override; ReservedSpace GetReservedScreenSpace(int viewsize) override; diff --git a/source/blood/src/d_menu.cpp b/source/blood/src/d_menu.cpp index fe5c6a6ba..d4ba90fe0 100644 --- a/source/blood/src/d_menu.cpp +++ b/source/blood/src/d_menu.cpp @@ -145,7 +145,7 @@ void UpdateNetworkMenus(void) { if (li->mAction == NAME_MultiMenu) { - li->mEnabled = false; + li->mEnabled = -1; } } } @@ -194,29 +194,6 @@ class DBloodImageScrollerMenu : public DImageScrollerMenu // //---------------------------------------------------------------------------- -void GameInterface::DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) -{ -#if 0 - if (!text) return; - int shade = (state != NIT_InactiveState) ? 32 : 48; - int pal = (state != NIT_InactiveState) ? 5 : 5; - if (state == NIT_SelectedState) shade = 32 - (I_GetBuildTime() & 63); - auto gamefont = fontnum == NIT_BigFont ? BigFont : SmallFont; - - if (flags & LMF_Centered) - { - int width = gamefont->StringWidth(text); - xpos -= width / 2; - } - DrawText(twod, gamefont, CR_UNDEFINED, xpos+1, ypos+1, text, DTA_Color, 0xff000000, //DTA_Alpha, 0.5, - DTA_FullscreenScale, FSMode_Fit320x200, TAG_DONE); - - DrawText(twod, gamefont, CR_UNDEFINED, xpos, ypos, text, DTA_TranslationIndex, TRANSLATION(Translation_Remap, pal), DTA_Color, shadeToLight(shade), - DTA_FullscreenScale, FSMode_Fit320x200, TAG_DONE); -#endif -} - - void GameInterface::MenuOpened() { itemBloodQAV.reset(new CGameMenuItemQAV(160, 100, "BDRIP.QAV", true)); @@ -254,24 +231,6 @@ FSavegameInfo GameInterface::GetSaveSig() return { SAVESIG_BLD, MINSAVEVER_BLD, SAVEVER_BLD }; } -void GameInterface::DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) -{ - if (text) - { - int height = SmallFont->GetHeight(); - - auto lines = FString(text).Split("\n"); - int y = 100 - (height * lines.Size() / 2); - for (auto& l : lines) - { - int width = SmallFont->StringWidth(l); - int x = 160 - width / 2; - DrawText(twod, SmallFont, CR_UNTRANSLATED, x, y, l, DTA_FullscreenScale, FSMode_Fit320x200, TAG_DONE); - y += height; - } - } -} - void GameInterface::QuitToTitle() { Mus_Stop(); diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index 1ced8e3a3..b92d22dfe 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -209,7 +209,7 @@ class DMenuItemBase : public DObject public: double mXpos, mYpos; FName mAction; - bool mEnabled; + int mEnabled; bool Activate(); bool SetString(int i, const char *s); diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 28c061c35..577862f81 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1865,6 +1865,13 @@ DEFINE_ACTION_FUNCTION(_Screen, GetViewWindow) return MIN(numret, 4); } +DEFINE_ACTION_FUNCTION_NATIVE(_Build, ShadeToLight, shadeToLight) +{ + PARAM_PROLOGUE; + PARAM_INT(shade); + ACTION_RETURN_INT(shadeToLight(shade)); +} + extern bool demoplayback; DEFINE_GLOBAL(multiplayer) DEFINE_GLOBAL(netgame) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index b70f99896..558d5e59c 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -28,16 +28,13 @@ LISTMENU "MainMenu" CaptionItem "Blood" position 160, 45 Linespacing 20 - /* - centermenu - NativeTextItem "$MNU_NEWGAME", "n", "EpisodeMenu" - NativeTextItem "$MNU_MULTIPLAYER", "m", "MultiMenu" - NativeTextItem "$MNU_OPTIONS", "o", "OptionsMenu" - NativeTextItem "$MNU_LOADGAME", "l", "LoadGameMenu" - NativeTextItem "$MNU_HELP", "h", "HelpMenu" - NativeTextItem "$MNU_CREDITS", "c", "CreditsMenu" - NativeTextItem "$MNU_QUITGAME", "q", "QuitMenu" - */ + BloodTextItem "$MNU_NEWGAME", "n", "EpisodeMenu" + BloodTextItem "$MNU_MULTIPLAYER", "m", "MultiMenu" + BloodTextItem "$MNU_OPTIONS", "o", "OptionsMenu" + BloodTextItem "$MNU_LOADGAME", "l", "LoadGameMenu" + BloodTextItem "$MNU_HELP", "h", "HelpMenu" + BloodTextItem "$MNU_CREDITS", "c", "CreditsMenu" + BloodTextItem "$MNU_QUITGAME", "q", "QuitMenu" BloodDripDrawer } ifgame(ShadowWarrior) diff --git a/wadsrc/static/zscript/base.zs b/wadsrc/static/zscript/base.zs index a2a49abe3..a33b3a40d 100644 --- a/wadsrc/static/zscript/base.zs +++ b/wadsrc/static/zscript/base.zs @@ -653,3 +653,12 @@ struct StringStruct native native int CodePointCount() const; native int, int GetNextCodePoint(int position) const; } + +struct Translation version("2.4") +{ + static int MakeID(int group, int num) + { + return (group << 16) + num; + } +} + diff --git a/wadsrc/static/zscript/games/blood/ui/menu.zs b/wadsrc/static/zscript/games/blood/ui/menu.zs index 7ce4d4c6c..518bd6378 100644 --- a/wadsrc/static/zscript/games/blood/ui/menu.zs +++ b/wadsrc/static/zscript/games/blood/ui/menu.zs @@ -51,4 +51,42 @@ class ListMenuItemBloodDripDrawer : ListMenuItem } native override void Draw(bool selected, ListMenuDescriptor desc); -} \ No newline at end of file +} + + + +//============================================================================= +// +// text item +// +//============================================================================= + +class ListMenuItemBloodTextItem : ListMenuItemTextItem +{ + void Init(ListMenuDescriptor desc, String text, String hotkey, Name child, int param = 0) + { + Super.Init(desc, text, hotkey, child, param); + } + + 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) + { + int shade = Selectable()? 32: 48; + int pal = 5; + let gamefont = generic_ui ? NewSmallFont : BigFont; + int xpos = mXpos - gamefont.StringWidth(mText) / 2; + int cr = generic_ui? Font.CR_GRAY : Font.CR_UNDEFINED; + int trans = generic_ui? 0 : Translation.MakeID(Translation_Remap, pal); + + if (selected) shade = 32 - ((MSTime() * 120 / 1000) & 63); + + Screen.DrawText(gamefont, Font.CR_UNDEFINED, xpos+1, mYpos+1, mText, DTA_Color, 0xff000000, DTA_FullscreenScale, FSMode_Fit320x200); + Screen.DrawText(gamefont, Font.CR_UNDEFINED, xpos, mYpos, mText, DTA_TranslationIndex, trans, DTA_Color, Build.shadeToLight(shade), DTA_FullscreenScale, FSMode_Fit320x200); + } + +} + diff --git a/wadsrc/static/zscript/razebase.zs b/wadsrc/static/zscript/razebase.zs index 47dc20f56..6d9460e38 100644 --- a/wadsrc/static/zscript/razebase.zs +++ b/wadsrc/static/zscript/razebase.zs @@ -28,6 +28,11 @@ enum EGameType }; +struct Build +{ + native static Color shadeToLight(int shade); +} + /* struct TileFiles { diff --git a/wadsrc/static/zscript/ui/menu/listmenuitems.zs b/wadsrc/static/zscript/ui/menu/listmenuitems.zs index be66bcd8c..391195cfd 100644 --- a/wadsrc/static/zscript/ui/menu/listmenuitems.zs +++ b/wadsrc/static/zscript/ui/menu/listmenuitems.zs @@ -219,12 +219,12 @@ class ListMenuItemSelectable : ListMenuItem override bool CheckCoordinate(int x, int y) { - return mEnabled && y >= mYpos && y < mYpos + mHeight; // no x check here + return mEnabled > 0 && y >= mYpos && y < mYpos + mHeight; // no x check here } override bool Selectable() { - return mEnabled; + return mEnabled > 0; } override bool CheckHotkey(int c) diff --git a/wadsrc/static/zscript/ui/menu/menuitembase.zs b/wadsrc/static/zscript/ui/menu/menuitembase.zs index 12b13556c..53a32e47f 100644 --- a/wadsrc/static/zscript/ui/menu/menuitembase.zs +++ b/wadsrc/static/zscript/ui/menu/menuitembase.zs @@ -8,7 +8,7 @@ class MenuItemBase : Object native ui version("2.4") { protected native double mXpos, mYpos; protected native Name mAction; - native bool mEnabled; + native int mEnabled; void Init(double xpos = 0, double ypos = 0, Name actionname = 'None') {