- 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;
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;

View file

@ -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();

View file

@ -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);

View file

@ -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)

View file

@ -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)

View file

@ -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;
}
}

View file

@ -51,4 +51,42 @@ class ListMenuItemBloodDripDrawer : ListMenuItem
}
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
{

View file

@ -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)

View file

@ -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')
{