2019-11-08 22:02:52 +00:00
|
|
|
#ifndef __M_MENU_MENU_H__
|
|
|
|
#define __M_MENU_MENU_H__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "v_font.h"
|
2020-05-25 15:11:32 +00:00
|
|
|
#include "c_cvars.h"
|
2019-11-08 22:02:52 +00:00
|
|
|
#include "version.h"
|
|
|
|
#include "textures.h"
|
2019-11-25 16:19:48 +00:00
|
|
|
#include "zstring.h"
|
2020-05-25 15:11:32 +00:00
|
|
|
#include "v_draw.h"
|
2020-06-14 16:57:55 +00:00
|
|
|
#include "menustate.h"
|
2020-06-20 16:01:02 +00:00
|
|
|
#include "gamestruct.h"
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
EXTERN_CVAR(Float, snd_menuvolume)
|
|
|
|
EXTERN_CVAR(Int, m_use_mouse);
|
|
|
|
|
2019-11-25 16:19:48 +00:00
|
|
|
enum EMax
|
2019-11-24 23:02:00 +00:00
|
|
|
{
|
|
|
|
MAXSKILLS = 7,
|
|
|
|
MAXVOLUMES = 7,
|
2019-11-25 22:21:51 +00:00
|
|
|
MAXMENUGAMEPLAYENTRIES = 7,
|
2019-11-24 23:02:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// These get filled in by the map definition parsers of the front ends.
|
|
|
|
extern FString gSkillNames[MAXSKILLS];
|
|
|
|
extern FString gVolumeNames[MAXVOLUMES];
|
|
|
|
extern FString gVolumeSubtitles[MAXVOLUMES];
|
|
|
|
extern int32_t gVolumeFlags[MAXVOLUMES];
|
2019-11-25 22:21:51 +00:00
|
|
|
extern int gDefaultVolume, gDefaultSkill;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
const int MENU_TICRATE = 30;
|
2019-11-23 22:05:24 +00:00
|
|
|
extern bool help_disabled, credits_disabled;
|
|
|
|
extern int g_currentMenu;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
2019-11-28 22:27:10 +00:00
|
|
|
enum MenuTransitionType
|
|
|
|
{ // Note: This enum is for logical categories, not visual types.
|
|
|
|
MA_None,
|
|
|
|
MA_Return,
|
|
|
|
MA_Advance,
|
|
|
|
};
|
|
|
|
|
|
|
|
class DMenu;
|
|
|
|
|
|
|
|
struct MenuTransition
|
|
|
|
{
|
|
|
|
DMenu* previous;
|
|
|
|
DMenu* current;
|
|
|
|
|
|
|
|
int32_t start;
|
|
|
|
int32_t length;
|
|
|
|
int32_t dir;
|
|
|
|
|
|
|
|
bool StartTransition(DMenu* from, DMenu* to, MenuTransitionType animtype);
|
|
|
|
bool Draw();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-11-25 22:21:51 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
EF_HIDEFROMSP = 1 << 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum MenuGameplayEntryFlags
|
|
|
|
{
|
|
|
|
MGE_Locked = 1u << 0u,
|
|
|
|
MGE_Hidden = 1u << 1u,
|
|
|
|
MGE_UserContent = 1u << 2u,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct MenuGameplayEntry
|
|
|
|
{
|
|
|
|
char name[64];
|
|
|
|
uint8_t flags;
|
|
|
|
|
|
|
|
bool isValid() const { return name[0] != '\0'; }
|
|
|
|
} MenuGameplayEntry;
|
|
|
|
|
|
|
|
typedef struct MenuGameplayStemEntry
|
|
|
|
{
|
|
|
|
MenuGameplayEntry entry;
|
|
|
|
MenuGameplayEntry subentries[MAXMENUGAMEPLAYENTRIES];
|
|
|
|
} MenuGameplayStemEntry;
|
|
|
|
|
|
|
|
extern MenuGameplayStemEntry g_MenuGameplayEntries[MAXMENUGAMEPLAYENTRIES];
|
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
|
2019-11-29 00:28:13 +00:00
|
|
|
enum EMenuSounds : int
|
|
|
|
{
|
2019-11-30 18:23:54 +00:00
|
|
|
ActivateSound,
|
2019-11-29 00:28:13 +00:00
|
|
|
CursorSound,
|
|
|
|
AdvanceSound,
|
|
|
|
BackSound,
|
|
|
|
CloseSound,
|
2019-11-30 09:03:20 +00:00
|
|
|
PageSound,
|
2020-08-04 22:32:29 +00:00
|
|
|
ChangeSound,
|
|
|
|
ChooseSound
|
2019-11-29 00:28:13 +00:00
|
|
|
};
|
|
|
|
|
2019-11-30 09:03:20 +00:00
|
|
|
EXTERN_CVAR(Bool, menu_sounds)
|
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
struct event_t;
|
2020-05-25 21:59:07 +00:00
|
|
|
class FGameTexture;
|
2019-11-08 22:02:52 +00:00
|
|
|
class FFont;
|
2019-11-29 00:28:13 +00:00
|
|
|
enum EColorRange : int;
|
2019-11-08 22:02:52 +00:00
|
|
|
class FPlayerClass;
|
|
|
|
class FKeyBindings;
|
|
|
|
|
|
|
|
enum EMenuKey
|
|
|
|
{
|
|
|
|
MKEY_Up,
|
|
|
|
MKEY_Down,
|
|
|
|
MKEY_Left,
|
|
|
|
MKEY_Right,
|
|
|
|
MKEY_PageUp,
|
|
|
|
MKEY_PageDown,
|
|
|
|
//----------------- Keys past here do not repeat.
|
|
|
|
MKEY_Enter,
|
|
|
|
MKEY_Back, // Back to previous menu
|
|
|
|
MKEY_Clear, // Clear keybinding/flip player sprite preview
|
|
|
|
NUM_MKEYS,
|
|
|
|
|
|
|
|
// These are not buttons but events sent from other menus
|
|
|
|
|
|
|
|
MKEY_Input, // Sent when input is confirmed
|
|
|
|
MKEY_Abort, // Input aborted
|
|
|
|
MKEY_MBYes,
|
|
|
|
MKEY_MBNo,
|
|
|
|
};
|
|
|
|
|
2019-11-23 11:38:38 +00:00
|
|
|
enum ENativeFontValues
|
|
|
|
{
|
|
|
|
NIT_BigFont,
|
|
|
|
NIT_SmallFont,
|
|
|
|
NIT_TinyFont,
|
|
|
|
|
|
|
|
NIT_ActiveColor = -1,
|
|
|
|
NIT_InactiveColor = -2,
|
2019-11-23 16:50:36 +00:00
|
|
|
NIT_SelectedColor = -3,
|
|
|
|
|
|
|
|
NIT_ActiveState = 1,
|
|
|
|
NIT_InactiveState = 2,
|
|
|
|
NIT_SelectedState = 3
|
2019-11-23 11:38:38 +00:00
|
|
|
// positive values for color are direct palswap indices.
|
|
|
|
};
|
|
|
|
|
2020-04-23 19:18:40 +00:00
|
|
|
extern FNewGameStartup NewGameStartupInfo;
|
2019-11-08 22:02:52 +00:00
|
|
|
extern EMenuState menuactive;
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// menu descriptor. This is created from the menu definition lump
|
|
|
|
// Items must be inserted in the order they are cycled through with the cursor
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
enum EMenuDescriptorType
|
|
|
|
{
|
|
|
|
MDESC_ListMenu,
|
|
|
|
MDESC_OptionsMenu,
|
2019-11-28 00:02:45 +00:00
|
|
|
MDESC_ImageScroller,
|
2019-11-08 22:02:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FMenuDescriptor
|
|
|
|
{
|
|
|
|
FName mMenuName;
|
|
|
|
FString mNetgameMessage;
|
|
|
|
int mType;
|
2019-11-21 21:31:46 +00:00
|
|
|
FName mClass;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
virtual ~FMenuDescriptor() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class FListMenuItem;
|
|
|
|
class FOptionMenuItem;
|
|
|
|
|
2019-11-24 21:31:27 +00:00
|
|
|
enum ListMenuFlags
|
|
|
|
{
|
|
|
|
LMF_Centered = 1,
|
2019-11-26 21:05:52 +00:00
|
|
|
LMF_DontSpace = 2,
|
|
|
|
LMF_Animate = 4,
|
2019-11-24 21:31:27 +00:00
|
|
|
};
|
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
struct FListMenuDescriptor : public FMenuDescriptor
|
|
|
|
{
|
|
|
|
TDeletingArray<FListMenuItem *> mItems;
|
2019-11-22 21:52:11 +00:00
|
|
|
FString mCaption;
|
2019-11-08 22:02:52 +00:00
|
|
|
int mSelectedItem;
|
|
|
|
int mSelectOfsX;
|
|
|
|
int mSelectOfsY;
|
2020-05-25 21:59:07 +00:00
|
|
|
FGameTexture *mSelector;
|
2019-11-08 22:02:52 +00:00
|
|
|
int mDisplayTop;
|
2019-11-23 16:50:36 +00:00
|
|
|
int mXpos, mYpos, mYbotton;
|
2019-11-08 22:02:52 +00:00
|
|
|
int mWLeft, mWRight;
|
|
|
|
int mLinespacing; // needs to be stored for dynamically created menus
|
|
|
|
int mAutoselect; // this can only be set by internal menu creation functions
|
2019-11-22 21:52:11 +00:00
|
|
|
int mScriptId;
|
|
|
|
int mSecondaryId;
|
2019-11-23 11:38:38 +00:00
|
|
|
int mNativeFontNum, mNativePalNum;
|
|
|
|
float mNativeFontScale;
|
2019-11-08 22:02:52 +00:00
|
|
|
FFont *mFont;
|
|
|
|
EColorRange mFontColor;
|
|
|
|
EColorRange mFontColor2;
|
|
|
|
FMenuDescriptor *mRedirect; // used to redirect overlong skill and episode menus to option menu based alternatives
|
2019-11-24 21:31:27 +00:00
|
|
|
int mFlags;
|
|
|
|
int mSpacing;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
2019-11-23 16:50:36 +00:00
|
|
|
FListMenuDescriptor()
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
2020-05-25 15:11:32 +00:00
|
|
|
void Reset();
|
2019-11-08 22:02:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FOptionMenuSettings
|
|
|
|
{
|
|
|
|
EColorRange mTitleColor;
|
|
|
|
EColorRange mFontColor;
|
|
|
|
EColorRange mFontColorValue;
|
|
|
|
EColorRange mFontColorMore;
|
|
|
|
EColorRange mFontColorHeader;
|
|
|
|
EColorRange mFontColorHighlight;
|
|
|
|
EColorRange mFontColorSelection;
|
|
|
|
int mLinespacing;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FOptionMenuDescriptor : public FMenuDescriptor
|
|
|
|
{
|
|
|
|
TDeletingArray<FOptionMenuItem *> mItems;
|
|
|
|
FString mTitle;
|
|
|
|
int mSelectedItem;
|
|
|
|
int mDrawTop;
|
|
|
|
int mScrollTop;
|
|
|
|
int mScrollPos;
|
|
|
|
int mIndent;
|
|
|
|
int mPosition;
|
|
|
|
bool mDontDim;
|
|
|
|
|
|
|
|
void CalcIndent();
|
|
|
|
FOptionMenuItem *GetItem(FName name);
|
|
|
|
void Reset()
|
|
|
|
{
|
|
|
|
// Reset the default settings (ignore all other values in the struct)
|
|
|
|
mPosition = 0;
|
|
|
|
mScrollTop = 0;
|
|
|
|
mIndent = 0;
|
|
|
|
mDontDim = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
2019-11-28 00:02:45 +00:00
|
|
|
|
|
|
|
struct FImageScrollerDescriptor : public FMenuDescriptor
|
|
|
|
{
|
|
|
|
struct ScrollerItem
|
|
|
|
{
|
|
|
|
int type; // 0: fullscreen image; 1: centered text
|
|
|
|
int scriptID;
|
|
|
|
FString text;
|
|
|
|
};
|
2019-11-28 22:27:10 +00:00
|
|
|
int mFlags = 0;
|
|
|
|
|
2019-11-28 00:02:45 +00:00
|
|
|
TArray<ScrollerItem> mItems;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
typedef TMap<FName, FMenuDescriptor *> MenuDescriptorList;
|
|
|
|
|
|
|
|
extern FOptionMenuSettings OptionSettings;
|
|
|
|
extern MenuDescriptorList MenuDescriptors;
|
|
|
|
|
|
|
|
#define CURSORSPACE (14 * CleanXfac_1)
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
struct FMenuRect
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
void set(int _x, int _y, int _w, int _h)
|
|
|
|
{
|
|
|
|
x = _x;
|
|
|
|
y = _y;
|
|
|
|
width = _w;
|
|
|
|
height = _h;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool inside(int _x, int _y)
|
|
|
|
{
|
|
|
|
return _x >= x && _x < x+width && _y >= y && _y < y+height;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-11-22 21:52:11 +00:00
|
|
|
class DMenu
|
2019-11-08 22:02:52 +00:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
bool mMouseCapture;
|
|
|
|
bool mBackbuttonSelected;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MOUSE_Click,
|
|
|
|
MOUSE_Move,
|
|
|
|
MOUSE_Release
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
BACKBUTTON_TIME = 4*MENU_TICRATE
|
|
|
|
};
|
|
|
|
|
|
|
|
static int MenuTime;
|
2020-06-14 16:57:55 +00:00
|
|
|
static bool InMenu;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
DMenu *mParentMenu;
|
2019-11-26 21:05:52 +00:00
|
|
|
DVector2 origin = { 0,0 };
|
2019-11-23 22:05:24 +00:00
|
|
|
int scriptID = INT_MAX;
|
2019-11-25 23:29:51 +00:00
|
|
|
bool canAnimate = false;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
DMenu(DMenu *parent = NULL);
|
2019-11-25 23:20:21 +00:00
|
|
|
virtual ~DMenu() = default;
|
2019-11-08 22:02:52 +00:00
|
|
|
virtual bool Responder (event_t *ev);
|
|
|
|
virtual bool MenuEvent (int mkey, bool fromcontroller);
|
|
|
|
virtual void Ticker ();
|
2019-11-22 21:52:11 +00:00
|
|
|
virtual void PreDraw() {}
|
|
|
|
virtual void PostDraw() {}
|
2019-11-08 22:02:52 +00:00
|
|
|
virtual void Drawer ();
|
|
|
|
virtual bool DimAllowed ();
|
|
|
|
virtual bool TranslateKeyboardEvents();
|
|
|
|
virtual void Close();
|
|
|
|
virtual bool MouseEvent(int type, int x, int y);
|
2019-11-22 21:52:11 +00:00
|
|
|
virtual void Destroy() {}
|
2019-11-08 22:02:52 +00:00
|
|
|
bool MouseEventBack(int type, int x, int y);
|
|
|
|
void SetCapture();
|
|
|
|
void ReleaseCapture();
|
2019-11-22 21:52:11 +00:00
|
|
|
void SetOrigin();
|
2019-11-08 22:02:52 +00:00
|
|
|
bool HasCapture()
|
|
|
|
{
|
|
|
|
return mMouseCapture;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// base class for menu items
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2019-11-24 19:40:53 +00:00
|
|
|
class DListMenu;
|
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
class FListMenuItem
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
int mXpos, mYpos;
|
2019-11-25 17:41:39 +00:00
|
|
|
int mHeight;
|
2019-11-08 22:02:52 +00:00
|
|
|
FName mAction;
|
|
|
|
|
|
|
|
public:
|
2019-11-23 22:05:24 +00:00
|
|
|
bool mEnabled, mHidden;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
FListMenuItem(int xpos = 0, int ypos = 0, FName action = NAME_None)
|
|
|
|
{
|
|
|
|
mXpos = xpos;
|
|
|
|
mYpos = ypos;
|
|
|
|
mAction = action;
|
|
|
|
mEnabled = true;
|
2019-11-23 22:05:24 +00:00
|
|
|
mHidden = false;
|
2019-11-08 22:02:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~FListMenuItem();
|
|
|
|
|
|
|
|
virtual bool CheckCoordinate(int x, int y);
|
|
|
|
virtual void Ticker();
|
2019-11-25 23:20:21 +00:00
|
|
|
virtual void Drawer(DListMenu *menu, const DVector2& origin, bool selected);
|
2019-11-08 22:02:52 +00:00
|
|
|
virtual bool Selectable();
|
2019-11-25 22:21:51 +00:00
|
|
|
virtual bool Activate(FName caller);
|
2019-11-08 22:02:52 +00:00
|
|
|
virtual FName GetAction(int *pparam);
|
|
|
|
virtual bool SetString(int i, const char *s);
|
|
|
|
virtual bool GetString(int i, char *s, int len);
|
|
|
|
virtual bool SetValue(int i, int value);
|
|
|
|
virtual bool GetValue(int i, int *pvalue);
|
|
|
|
virtual void Enable(bool on);
|
|
|
|
virtual bool MenuEvent (int mkey, bool fromcontroller);
|
|
|
|
virtual bool MouseEvent(int type, int x, int y);
|
|
|
|
virtual bool CheckHotkey(int c);
|
|
|
|
virtual int GetWidth();
|
2020-05-25 21:59:07 +00:00
|
|
|
virtual void DrawSelector(int xofs, int yofs, FGameTexture *tex);
|
2019-11-08 22:02:52 +00:00
|
|
|
void OffsetPositionY(int ydelta) { mYpos += ydelta; }
|
|
|
|
int GetY() { return mYpos; }
|
|
|
|
int GetX() { return mXpos; }
|
|
|
|
void SetX(int x) { mXpos = x; }
|
2019-11-23 16:50:36 +00:00
|
|
|
void SetY(int x) { mYpos = x; }
|
2019-11-25 17:41:39 +00:00
|
|
|
void SetHeight(int x) { mHeight = x; }
|
2019-11-25 22:21:51 +00:00
|
|
|
void SetAction(FName action) { mAction = action; }
|
2019-11-23 16:50:36 +00:00
|
|
|
};
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
class FListMenuItemStaticPatch : public FListMenuItem
|
|
|
|
{
|
|
|
|
protected:
|
2020-05-25 21:59:07 +00:00
|
|
|
FGameTexture *mTexture;
|
2019-11-08 22:02:52 +00:00
|
|
|
bool mCentered;
|
|
|
|
|
|
|
|
public:
|
2020-05-25 21:59:07 +00:00
|
|
|
FListMenuItemStaticPatch(int x, int y, FGameTexture *patch, bool centered);
|
2019-11-25 23:20:21 +00:00
|
|
|
void Drawer(DListMenu* menu, const DVector2& origin, bool selected);
|
2019-11-08 22:02:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class FListMenuItemStaticText : public FListMenuItem
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
const char *mText;
|
|
|
|
FFont *mFont;
|
|
|
|
EColorRange mColor;
|
|
|
|
bool mCentered;
|
|
|
|
|
|
|
|
public:
|
|
|
|
FListMenuItemStaticText(int x, int y, const char *text, FFont *font, EColorRange color, bool centered);
|
|
|
|
~FListMenuItemStaticText();
|
2019-11-25 23:20:21 +00:00
|
|
|
void Drawer(DListMenu* menu, const DVector2& origin, bool selected) override;
|
2019-11-08 22:02:52 +00:00
|
|
|
};
|
|
|
|
|
2019-12-11 19:35:25 +00:00
|
|
|
class FListMenuItemNativeStaticText : public FListMenuItem
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
FString mText;
|
|
|
|
int mFontnum;
|
|
|
|
int mPalnum;
|
|
|
|
bool mCentered;
|
|
|
|
|
|
|
|
public:
|
|
|
|
FListMenuItemNativeStaticText(int x, int y, const FString & text, int fontnum, int palnum, bool centered);
|
|
|
|
void Drawer(DListMenu* menu, const DVector2& origin, bool selected) override;
|
|
|
|
};
|
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// selectable items
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
class FListMenuItemSelectable : public FListMenuItem
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
int mHotkey;
|
|
|
|
int mParam;
|
|
|
|
|
|
|
|
public:
|
|
|
|
FListMenuItemSelectable(int x, int y, int height, FName childmenu, int mParam = -1);
|
2019-11-23 11:38:38 +00:00
|
|
|
bool CheckCoordinate(int x, int y) override;
|
|
|
|
bool Selectable() override;
|
|
|
|
bool CheckHotkey(int c) override;
|
2019-11-25 22:21:51 +00:00
|
|
|
bool Activate(FName caller) override;
|
2019-11-23 11:38:38 +00:00
|
|
|
bool MouseEvent(int type, int x, int y) override;
|
|
|
|
FName GetAction(int *pparam) override;
|
2019-11-08 22:02:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class FListMenuItemText : public FListMenuItemSelectable
|
|
|
|
{
|
2019-11-21 21:31:46 +00:00
|
|
|
FString mText;
|
2019-11-08 22:02:52 +00:00
|
|
|
FFont *mFont;
|
|
|
|
EColorRange mColor;
|
|
|
|
EColorRange mColorSelected;
|
|
|
|
public:
|
2019-11-21 21:31:46 +00:00
|
|
|
FListMenuItemText(int x, int y, int height, int hotkey, const FString &text, FFont *font, EColorRange color, EColorRange color2, FName child, int param = 0);
|
2019-11-08 22:02:52 +00:00
|
|
|
~FListMenuItemText();
|
2019-11-25 23:20:21 +00:00
|
|
|
void Drawer(DListMenu* menu, const DVector2& origin, bool selected) override;
|
2019-11-23 11:38:38 +00:00
|
|
|
int GetWidth() override;
|
2019-11-08 22:02:52 +00:00
|
|
|
};
|
|
|
|
|
2019-11-23 11:38:38 +00:00
|
|
|
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();
|
2019-11-25 23:20:21 +00:00
|
|
|
void Drawer(DListMenu* menu, const DVector2& origin, bool selected) override;
|
2019-11-23 11:38:38 +00:00
|
|
|
int GetWidth() override;
|
2020-05-25 21:59:07 +00:00
|
|
|
void DrawSelector(int xofs, int yofs, FGameTexture* tex) override { } // The text drawer handles this itself.
|
2019-11-23 11:38:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
class FListMenuItemPatch : public FListMenuItemSelectable
|
|
|
|
{
|
2020-05-25 21:59:07 +00:00
|
|
|
FGameTexture* mTexture;
|
2019-11-08 22:02:52 +00:00
|
|
|
public:
|
2020-05-25 21:59:07 +00:00
|
|
|
FListMenuItemPatch(int x, int y, int height, int hotkey, FGameTexture* patch, FName child, int param = 0);
|
2019-11-25 23:20:21 +00:00
|
|
|
void Drawer(DListMenu* menu, const DVector2& origin, bool selected) override;
|
2019-11-23 11:38:38 +00:00
|
|
|
int GetWidth() override;
|
2019-11-08 22:02:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// list menu class runs a menu described by a FListMenuDescriptor
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
class DListMenu : public DMenu
|
|
|
|
{
|
2019-11-22 21:52:11 +00:00
|
|
|
typedef DMenu Super;
|
2019-11-08 22:02:52 +00:00
|
|
|
protected:
|
2019-11-21 21:31:46 +00:00
|
|
|
FListMenuDescriptor *mDesc = nullptr;
|
|
|
|
FListMenuItem *mFocusControl = nullptr;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
DListMenu(DMenu *parent = NULL, FListMenuDescriptor *desc = NULL);
|
|
|
|
virtual void Init(DMenu *parent = NULL, FListMenuDescriptor *desc = NULL);
|
|
|
|
FListMenuItem *GetItem(FName name);
|
2019-11-28 00:02:45 +00:00
|
|
|
bool Responder (event_t *ev) override;
|
|
|
|
bool MenuEvent (int mkey, bool fromcontroller) override;
|
|
|
|
bool MouseEvent(int type, int x, int y) override;
|
|
|
|
void Ticker () override;
|
|
|
|
void Drawer () override;
|
2019-11-28 23:37:19 +00:00
|
|
|
void PreDraw() override;
|
2019-11-27 21:41:15 +00:00
|
|
|
virtual void SelectionChanged() {}
|
2019-11-08 22:02:52 +00:00
|
|
|
void SetFocus(FListMenuItem *fc)
|
|
|
|
{
|
|
|
|
mFocusControl = fc;
|
|
|
|
}
|
|
|
|
bool CheckFocus(FListMenuItem *fc)
|
|
|
|
{
|
|
|
|
return mFocusControl == fc;
|
|
|
|
}
|
|
|
|
void ReleaseFocus()
|
|
|
|
{
|
|
|
|
mFocusControl = NULL;
|
|
|
|
}
|
2019-11-24 19:40:53 +00:00
|
|
|
const FListMenuDescriptor* Descriptor() const
|
|
|
|
{
|
|
|
|
return mDesc;
|
|
|
|
}
|
2019-11-08 22:02:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// base class for menu items
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
class FOptionMenuItem : public FListMenuItem
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
FString mLabel;
|
2019-11-21 21:31:46 +00:00
|
|
|
bool mCentered = false;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
2019-11-29 00:28:13 +00:00
|
|
|
void drawText(int x, int y, int color, const char * text, bool grayed = false);
|
|
|
|
|
|
|
|
int drawLabel(int indent, int y, EColorRange color, bool grayed = false);
|
|
|
|
void drawValue(int indent, int y, int color, const char *text, bool grayed = false);
|
|
|
|
|
|
|
|
int CursorSpace();
|
|
|
|
|
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
FOptionMenuItem(const char *text, FName action = NAME_None, bool center = false)
|
|
|
|
: FListMenuItem(0, 0, action)
|
|
|
|
{
|
|
|
|
mLabel = text;
|
|
|
|
mCentered = center;
|
|
|
|
}
|
|
|
|
|
|
|
|
~FOptionMenuItem();
|
|
|
|
virtual int Draw(FOptionMenuDescriptor *desc, int y, int indent, bool selected);
|
|
|
|
virtual bool Selectable();
|
|
|
|
virtual int GetIndent();
|
|
|
|
virtual bool MouseEvent(int type, int x, int y);
|
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
struct FOptionValues
|
|
|
|
{
|
|
|
|
struct Pair
|
|
|
|
{
|
|
|
|
double Value;
|
|
|
|
FString TextValue;
|
|
|
|
FString Text;
|
|
|
|
};
|
|
|
|
|
|
|
|
TArray<Pair> mValues;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef TMap< FName, FOptionValues* > FOptionMap;
|
|
|
|
|
|
|
|
extern FOptionMap OptionValues;
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// Option menu class runs a menu described by a FOptionMenuDescriptor
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
class DOptionMenu : public DMenu
|
|
|
|
{
|
2019-11-22 21:52:11 +00:00
|
|
|
using Super = DMenu;
|
2019-11-08 22:02:52 +00:00
|
|
|
bool CanScrollUp;
|
|
|
|
bool CanScrollDown;
|
|
|
|
int VisBottom;
|
|
|
|
FOptionMenuItem *mFocusControl;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
FOptionMenuDescriptor *mDesc;
|
|
|
|
|
2020-01-05 11:12:14 +00:00
|
|
|
int GetPosition();
|
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
public:
|
|
|
|
FOptionMenuItem *GetItem(FName name);
|
|
|
|
DOptionMenu(DMenu *parent = NULL, FOptionMenuDescriptor *desc = NULL);
|
|
|
|
virtual void Init(DMenu *parent = NULL, FOptionMenuDescriptor *desc = NULL);
|
|
|
|
int FirstSelectable();
|
|
|
|
bool Responder (event_t *ev);
|
|
|
|
bool MenuEvent (int mkey, bool fromcontroller);
|
|
|
|
bool MouseEvent(int type, int x, int y);
|
|
|
|
void Ticker ();
|
|
|
|
void Drawer ();
|
2019-12-01 23:16:48 +00:00
|
|
|
virtual int GetIndent();
|
2019-11-08 22:02:52 +00:00
|
|
|
const FOptionMenuDescriptor *GetDescriptor() const { return mDesc; }
|
|
|
|
void SetFocus(FOptionMenuItem *fc)
|
|
|
|
{
|
|
|
|
mFocusControl = fc;
|
|
|
|
}
|
|
|
|
bool CheckFocus(FOptionMenuItem *fc)
|
|
|
|
{
|
|
|
|
return mFocusControl == fc;
|
|
|
|
}
|
|
|
|
void ReleaseFocus()
|
|
|
|
{
|
|
|
|
mFocusControl = NULL;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-11-29 00:28:13 +00:00
|
|
|
FFont *OptionFont();
|
|
|
|
int OptionHeight();
|
|
|
|
int OptionWidth(const char * s);
|
|
|
|
void DrawOptionText(int x, int y, int color, const char *text, bool grayed = false);
|
2019-11-08 22:02:52 +00:00
|
|
|
|
2019-11-28 00:02:45 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// ImageScroller
|
|
|
|
//
|
|
|
|
//=============================================================================
|
2019-12-01 16:48:56 +00:00
|
|
|
class ImageScreen;
|
2019-11-28 00:02:45 +00:00
|
|
|
|
|
|
|
class DImageScrollerMenu : public DMenu
|
|
|
|
{
|
2019-12-01 16:48:56 +00:00
|
|
|
DMenu* mCurrent = nullptr;
|
|
|
|
FImageScrollerDescriptor* mDesc = nullptr;
|
|
|
|
int index = 0;
|
2019-11-28 22:27:10 +00:00
|
|
|
MenuTransition pageTransition = {};
|
2019-11-28 00:02:45 +00:00
|
|
|
|
2019-12-01 19:17:30 +00:00
|
|
|
protected:
|
2019-12-01 16:48:56 +00:00
|
|
|
virtual ImageScreen* newImageScreen(FImageScrollerDescriptor::ScrollerItem* desc);
|
|
|
|
|
2019-11-28 22:27:10 +00:00
|
|
|
public:
|
2019-12-01 16:48:56 +00:00
|
|
|
void Init(DMenu* parent = nullptr, FImageScrollerDescriptor* desc = nullptr);
|
2019-11-28 22:27:10 +00:00
|
|
|
bool MenuEvent(int mkey, bool fromcontroller);
|
|
|
|
bool MouseEvent(int type, int x, int y);
|
|
|
|
void Ticker();
|
|
|
|
void Drawer();
|
2019-11-28 00:02:45 +00:00
|
|
|
};
|
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// Input some text
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
class DTextEnterMenu : public DMenu
|
|
|
|
{
|
2019-11-22 21:52:11 +00:00
|
|
|
using Super = DMenu;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
2019-11-29 23:49:50 +00:00
|
|
|
FString mEnterString;
|
|
|
|
int mEnterSize;
|
|
|
|
bool mInputGridOkay;
|
2019-11-08 22:02:52 +00:00
|
|
|
int InputGridX;
|
|
|
|
int InputGridY;
|
2019-11-29 23:49:50 +00:00
|
|
|
int CursorSize;
|
2019-11-08 22:02:52 +00:00
|
|
|
bool AllowColors;
|
2019-11-29 23:49:50 +00:00
|
|
|
FFont *displayFont;
|
|
|
|
|
|
|
|
|
|
|
|
void AppendChar(int ch);
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// [TP] Added allowcolors
|
2019-11-29 23:49:50 +00:00
|
|
|
DTextEnterMenu(DMenu *parent, FFont *dpf, FString textbuffer, int maxlen, bool showgrid, bool allowcolors = false);
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
void Drawer ();
|
|
|
|
bool MenuEvent (int mkey, bool fromcontroller);
|
|
|
|
bool Responder(event_t *ev);
|
|
|
|
bool TranslateKeyboardEvents();
|
|
|
|
bool MouseEvent(int type, int x, int y);
|
2019-11-29 23:49:50 +00:00
|
|
|
const char* GetText() { return mEnterString.GetChars(); }
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-12-01 16:48:56 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// Show a fullscreen image / centered text screen for an image scroller
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
class ImageScreen : public DMenu
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
const FImageScrollerDescriptor::ScrollerItem* mDesc;
|
|
|
|
public:
|
|
|
|
ImageScreen(const FImageScrollerDescriptor::ScrollerItem* it)
|
|
|
|
{
|
|
|
|
mDesc = it;
|
|
|
|
}
|
|
|
|
void Drawer() override;
|
|
|
|
};
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct event_t;
|
|
|
|
void M_EnableMenu (bool on) ;
|
|
|
|
bool M_Responder (event_t *ev);
|
|
|
|
void M_Ticker (void);
|
|
|
|
void M_Drawer (void);
|
2019-12-23 09:53:58 +00:00
|
|
|
void M_PreviousMenu();
|
2019-11-08 22:02:52 +00:00
|
|
|
void M_Init (void);
|
|
|
|
void M_CreateMenus();
|
|
|
|
void M_ActivateMenu(DMenu *menu);
|
2019-12-25 10:26:19 +00:00
|
|
|
void M_ClearMenus (bool final = false);
|
2019-11-08 22:02:52 +00:00
|
|
|
void M_ParseMenuDefs();
|
2020-04-23 19:18:40 +00:00
|
|
|
void M_StartupSkillMenu(FNewGameStartup *gs);
|
2019-11-08 22:02:52 +00:00
|
|
|
int M_GetDefaultSkill();
|
|
|
|
void M_StartControlPanel (bool makeSound);
|
2019-11-25 22:21:51 +00:00
|
|
|
bool M_SetMenu(FName menu, int param = -1, FName callingMenu = NAME_None);
|
2019-11-08 22:02:52 +00:00
|
|
|
void M_NotifyNewSave (const char *file, const char *title, bool okForQuicksave);
|
2019-11-29 00:28:13 +00:00
|
|
|
void M_StartMessage(const char *message, int messagemode, int scriptId, FName action = NAME_None);
|
2019-11-25 22:21:51 +00:00
|
|
|
void M_UnhideCustomMenu(int menu, int itemmask);
|
2019-11-29 00:28:13 +00:00
|
|
|
void M_MenuSound(EMenuSounds snd);
|
2019-11-30 18:23:54 +00:00
|
|
|
void M_Autosave();
|
2019-12-01 09:18:38 +00:00
|
|
|
bool M_Active();
|
2019-12-24 19:06:55 +00:00
|
|
|
void M_DeinitMenus();
|
2020-02-17 17:40:32 +00:00
|
|
|
void M_UnpauseSound();
|
2019-11-25 22:21:51 +00:00
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
void I_SetMouseCapture();
|
|
|
|
void I_ReleaseMouseCapture();
|
|
|
|
|
2019-11-22 21:52:11 +00:00
|
|
|
struct MenuClassDescriptor;
|
|
|
|
extern TArray<MenuClassDescriptor*> menuClasses;
|
|
|
|
|
2019-11-30 18:23:54 +00:00
|
|
|
using hFunc = std::function<void(bool)>;
|
|
|
|
DMenu* CreateMessageBoxMenu(DMenu* parent, const char* message, int messagemode, int scriptID, bool playsound, FName action = NAME_None, hFunc handler = nullptr);
|
|
|
|
|
|
|
|
|
2019-11-22 21:52:11 +00:00
|
|
|
struct MenuClassDescriptor
|
|
|
|
{
|
|
|
|
FName mName;
|
|
|
|
MenuClassDescriptor(const char* name) : mName(name)
|
|
|
|
{
|
|
|
|
//menuClasses.Push(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual DMenu* CreateNew() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class Menu> struct TMenuClassDescriptor : public MenuClassDescriptor
|
|
|
|
{
|
|
|
|
TMenuClassDescriptor(const char* name) : MenuClassDescriptor(name)
|
|
|
|
{}
|
|
|
|
DMenu* CreateNew()
|
|
|
|
{
|
|
|
|
return new Menu;
|
|
|
|
}
|
|
|
|
};
|
2019-11-08 22:02:52 +00:00
|
|
|
|
2019-11-29 23:49:50 +00:00
|
|
|
|
|
|
|
struct FSavegameManager
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
TArray<FSaveGameNode*> SaveGames;
|
|
|
|
FSaveGameNode NewSaveNode;
|
|
|
|
int LastSaved = -1;
|
|
|
|
int LastAccessed = -1;
|
|
|
|
TArray<char> SavePicData;
|
2020-05-25 21:59:07 +00:00
|
|
|
FGameTexture *SavePic = nullptr;
|
2019-11-29 23:49:50 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
int WindowSize = 0;
|
|
|
|
FString SaveCommentString;
|
|
|
|
FSaveGameNode *quickSaveSlot = nullptr;
|
|
|
|
~FSavegameManager();
|
|
|
|
|
|
|
|
private:
|
|
|
|
int InsertSaveNode(FSaveGameNode *node);
|
|
|
|
public:
|
|
|
|
void NotifyNewSave(const FString &file, const FString &title, bool okForQuicksave, bool forceQuicksave);
|
|
|
|
void ClearSaveGames();
|
|
|
|
|
|
|
|
void ReadSaveStrings();
|
|
|
|
void UnloadSaveData();
|
|
|
|
|
|
|
|
int RemoveSaveSlot(int index);
|
|
|
|
void LoadSavegame(int Selected);
|
|
|
|
void DoSave(int Selected, const char *savegamestring);
|
|
|
|
unsigned ExtractSaveData(int index);
|
|
|
|
void ClearSaveStuff();
|
|
|
|
bool DrawSavePic(int x, int y, int w, int h);
|
|
|
|
void DrawSaveComment(FFont *font, int cr, int x, int y, int scalefactor);
|
|
|
|
void SetFileInfo(int Selected);
|
|
|
|
unsigned SavegameCount();
|
|
|
|
FSaveGameNode *GetSavegame(int i);
|
|
|
|
void InsertNewSaveNode();
|
|
|
|
bool RemoveNewSaveNode();
|
|
|
|
|
2019-11-30 21:46:00 +00:00
|
|
|
void LoadGame(FSaveGameNode* node);
|
|
|
|
void SaveGame(FSaveGameNode* node, bool ok4q, bool forceq);
|
2019-11-30 18:23:54 +00:00
|
|
|
|
2019-11-29 23:49:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern FSavegameManager savegameManager;
|
2020-06-14 16:57:55 +00:00
|
|
|
extern DMenu* CurrentMenu;
|
2019-11-29 23:49:50 +00:00
|
|
|
|
2019-11-24 23:02:00 +00:00
|
|
|
#endif
|