- reimplemented Blood's menu items.

This commit is contained in:
Christoph Oelckers 2020-10-07 00:50:26 +02:00
parent a7035a932f
commit 603c3b50ec
10 changed files with 72 additions and 59 deletions

View File

@ -80,10 +80,8 @@ struct GameInterface : ::GameInterface
void MenuClosed() override; void MenuClosed() override;
bool CanSave() override; bool CanSave() override;
bool StartGame(FNewGameStartup& gs) 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 SaveGame(FSaveGameNode*) override;
bool LoadGame(FSaveGameNode*) override; bool LoadGame(FSaveGameNode*) override;
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override;
void QuitToTitle() override; void QuitToTitle() override;
FString GetCoordString() override; FString GetCoordString() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override; ReservedSpace GetReservedScreenSpace(int viewsize) override;

View File

@ -145,7 +145,7 @@ void UpdateNetworkMenus(void)
{ {
if (li->mAction == NAME_MultiMenu) 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() void GameInterface::MenuOpened()
{ {
itemBloodQAV.reset(new CGameMenuItemQAV(160, 100, "BDRIP.QAV", true)); itemBloodQAV.reset(new CGameMenuItemQAV(160, 100, "BDRIP.QAV", true));
@ -254,24 +231,6 @@ FSavegameInfo GameInterface::GetSaveSig()
return { SAVESIG_BLD, MINSAVEVER_BLD, SAVEVER_BLD }; 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() void GameInterface::QuitToTitle()
{ {
Mus_Stop(); Mus_Stop();

View File

@ -209,7 +209,7 @@ class DMenuItemBase : public DObject
public: public:
double mXpos, mYpos; double mXpos, mYpos;
FName mAction; FName mAction;
bool mEnabled; int mEnabled;
bool Activate(); bool Activate();
bool SetString(int i, const char *s); bool SetString(int i, const char *s);

View File

@ -1865,6 +1865,13 @@ DEFINE_ACTION_FUNCTION(_Screen, GetViewWindow)
return MIN(numret, 4); return MIN(numret, 4);
} }
DEFINE_ACTION_FUNCTION_NATIVE(_Build, ShadeToLight, shadeToLight)
{
PARAM_PROLOGUE;
PARAM_INT(shade);
ACTION_RETURN_INT(shadeToLight(shade));
}
extern bool demoplayback; extern bool demoplayback;
DEFINE_GLOBAL(multiplayer) DEFINE_GLOBAL(multiplayer)
DEFINE_GLOBAL(netgame) DEFINE_GLOBAL(netgame)

View File

@ -28,16 +28,13 @@ LISTMENU "MainMenu"
CaptionItem "Blood" CaptionItem "Blood"
position 160, 45 position 160, 45
Linespacing 20 Linespacing 20
/* BloodTextItem "$MNU_NEWGAME", "n", "EpisodeMenu"
centermenu BloodTextItem "$MNU_MULTIPLAYER", "m", "MultiMenu"
NativeTextItem "$MNU_NEWGAME", "n", "EpisodeMenu" BloodTextItem "$MNU_OPTIONS", "o", "OptionsMenu"
NativeTextItem "$MNU_MULTIPLAYER", "m", "MultiMenu" BloodTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
NativeTextItem "$MNU_OPTIONS", "o", "OptionsMenu" BloodTextItem "$MNU_HELP", "h", "HelpMenu"
NativeTextItem "$MNU_LOADGAME", "l", "LoadGameMenu" BloodTextItem "$MNU_CREDITS", "c", "CreditsMenu"
NativeTextItem "$MNU_HELP", "h", "HelpMenu" BloodTextItem "$MNU_QUITGAME", "q", "QuitMenu"
NativeTextItem "$MNU_CREDITS", "c", "CreditsMenu"
NativeTextItem "$MNU_QUITGAME", "q", "QuitMenu"
*/
BloodDripDrawer BloodDripDrawer
} }
ifgame(ShadowWarrior) ifgame(ShadowWarrior)

View File

@ -653,3 +653,12 @@ struct StringStruct native
native int CodePointCount() const; native int CodePointCount() const;
native int, int GetNextCodePoint(int position) const; native int, int GetNextCodePoint(int position) const;
} }
struct Translation version("2.4")
{
static int MakeID(int group, int num)
{
return (group << 16) + num;
}
}

View File

@ -52,3 +52,41 @@ class ListMenuItemBloodDripDrawer : ListMenuItem
native override void Draw(bool selected, ListMenuDescriptor desc); native override void Draw(bool selected, ListMenuDescriptor desc);
} }
//=============================================================================
//
// 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);
}
}

View File

@ -28,6 +28,11 @@ enum EGameType
}; };
struct Build
{
native static Color shadeToLight(int shade);
}
/* /*
struct TileFiles struct TileFiles
{ {

View File

@ -219,12 +219,12 @@ class ListMenuItemSelectable : ListMenuItem
override bool CheckCoordinate(int x, int y) 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() override bool Selectable()
{ {
return mEnabled; return mEnabled > 0;
} }
override bool CheckHotkey(int c) override bool CheckHotkey(int c)

View File

@ -8,7 +8,7 @@ class MenuItemBase : Object native ui version("2.4")
{ {
protected native double mXpos, mYpos; protected native double mXpos, mYpos;
protected native Name mAction; protected native Name mAction;
native bool mEnabled; native int mEnabled;
void Init(double xpos = 0, double ypos = 0, Name actionname = 'None') void Init(double xpos = 0, double ypos = 0, Name actionname = 'None')
{ {