2019-11-08 22:02:52 +00:00
|
|
|
#ifndef __M_MENU_MENU_H__
|
|
|
|
#define __M_MENU_MENU_H__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
#include "dobject.h"
|
2020-05-25 15:11:32 +00:00
|
|
|
#include "c_cvars.h"
|
2020-10-04 16:31:48 +00:00
|
|
|
#include "v_font.h"
|
2019-11-08 22:02:52 +00:00
|
|
|
#include "textures.h"
|
|
|
|
|
|
|
|
EXTERN_CVAR(Float, snd_menuvolume)
|
|
|
|
EXTERN_CVAR(Int, m_use_mouse);
|
|
|
|
|
2019-11-30 09:03:20 +00:00
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
struct event_t;
|
2020-10-04 16:31:48 +00:00
|
|
|
class FTexture;
|
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 FKeyBindings;
|
2020-10-04 16:31:48 +00:00
|
|
|
struct FBrokenLines;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
class DMenu;
|
|
|
|
extern DMenu *CurrentMenu;
|
|
|
|
extern int MenuTime;
|
|
|
|
class DMenuItemBase;
|
2020-10-04 22:23:30 +00:00
|
|
|
extern DObject* menuCustomizer;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// menu descriptor. This is created from the menu definition lump
|
|
|
|
// Items must be inserted in the order they are cycled through with the cursor
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
class DMenuDescriptor : public DObject
|
2019-11-08 22:02:52 +00:00
|
|
|
{
|
2020-10-04 16:31:48 +00:00
|
|
|
DECLARE_CLASS(DMenuDescriptor, DObject)
|
|
|
|
public:
|
|
|
|
FName mMenuName = NAME_None;
|
2019-11-08 22:02:52 +00:00
|
|
|
FString mNetgameMessage;
|
2020-10-04 16:31:48 +00:00
|
|
|
PClass *mClass = nullptr;
|
|
|
|
bool mProtected = false;
|
|
|
|
TArray<DMenuItemBase *> mItems;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
virtual size_t PropagateMark() { return 0; }
|
2019-11-08 22:02:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
class DListMenuDescriptor : public DMenuDescriptor
|
2019-11-24 21:31:27 +00:00
|
|
|
{
|
2020-10-04 16:31:48 +00:00
|
|
|
DECLARE_CLASS(DListMenuDescriptor, DMenuDescriptor)
|
2019-11-24 21:31:27 +00:00
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
public:
|
2019-11-08 22:02:52 +00:00
|
|
|
int mSelectedItem;
|
2020-10-04 16:31:48 +00:00
|
|
|
double mSelectOfsX;
|
|
|
|
double mSelectOfsY;
|
|
|
|
FTextureID mSelector;
|
2019-11-08 22:02:52 +00:00
|
|
|
int mDisplayTop;
|
2020-10-04 16:31:48 +00:00
|
|
|
double mXpos, mYpos;
|
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
|
|
|
|
FFont *mFont;
|
|
|
|
EColorRange mFontColor;
|
|
|
|
EColorRange mFontColor2;
|
2020-10-04 16:31:48 +00:00
|
|
|
bool mCenter;
|
|
|
|
bool mFromEngine;
|
|
|
|
int mVirtWidth;
|
|
|
|
int mVirtHeight;
|
2019-11-23 16:50:36 +00:00
|
|
|
|
2020-05-25 15:11:32 +00:00
|
|
|
void Reset();
|
2020-10-04 16:31:48 +00:00
|
|
|
size_t PropagateMark() override;
|
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;
|
|
|
|
};
|
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
class DOptionMenuDescriptor : public DMenuDescriptor
|
2019-11-08 22:02:52 +00:00
|
|
|
{
|
2020-10-04 16:31:48 +00:00
|
|
|
DECLARE_CLASS(DOptionMenuDescriptor, DMenuDescriptor)
|
|
|
|
|
|
|
|
public:
|
2019-11-08 22:02:52 +00:00
|
|
|
FString mTitle;
|
|
|
|
int mSelectedItem;
|
|
|
|
int mDrawTop;
|
|
|
|
int mScrollTop;
|
|
|
|
int mScrollPos;
|
|
|
|
int mIndent;
|
|
|
|
int mPosition;
|
|
|
|
bool mDontDim;
|
2020-10-04 16:31:48 +00:00
|
|
|
FFont *mFont;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
void CalcIndent();
|
2020-10-04 16:31:48 +00:00
|
|
|
DMenuItemBase *GetItem(FName name);
|
|
|
|
void Reset();
|
|
|
|
size_t PropagateMark() override;
|
|
|
|
~DOptionMenuDescriptor() = default;
|
2019-11-28 00:02:45 +00:00
|
|
|
};
|
2020-10-04 16:31:48 +00:00
|
|
|
|
2019-11-28 00:02:45 +00:00
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
typedef TMap<FName, DMenuDescriptor *> MenuDescriptorList;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
class DMenu : public DObject
|
2019-11-08 22:02:52 +00:00
|
|
|
{
|
2020-10-04 16:31:48 +00:00
|
|
|
DECLARE_CLASS (DMenu, DObject)
|
|
|
|
HAS_OBJECT_POINTERS
|
|
|
|
|
|
|
|
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MOUSE_Click,
|
|
|
|
MOUSE_Move,
|
|
|
|
MOUSE_Release
|
|
|
|
};
|
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
TObjPtr<DMenu*> mParentMenu;
|
|
|
|
bool mMouseCapture;
|
|
|
|
bool mBackbuttonSelected;
|
|
|
|
bool DontDim;
|
|
|
|
bool DontBlur;
|
|
|
|
static int InMenu;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
|
|
|
DMenu(DMenu *parent = NULL);
|
2020-10-04 16:31:48 +00:00
|
|
|
bool TranslateKeyboardEvents();
|
2019-11-08 22:02:52 +00:00
|
|
|
virtual void Close();
|
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
bool CallResponder(event_t *ev);
|
|
|
|
bool CallMenuEvent(int mkey, bool fromcontroller);
|
|
|
|
void CallTicker();
|
|
|
|
void CallDrawer();
|
2019-11-08 22:02:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// base class for menu items
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
class DMenuItemBase : public DObject
|
2019-11-08 22:02:52 +00:00
|
|
|
{
|
2020-10-04 16:31:48 +00:00
|
|
|
DECLARE_CLASS(DMenuItemBase, DObject)
|
2019-11-08 22:02:52 +00:00
|
|
|
public:
|
2020-10-04 16:31:48 +00:00
|
|
|
double mXpos, mYpos;
|
|
|
|
FName mAction;
|
|
|
|
bool mEnabled;
|
2019-11-08 22:02:52 +00:00
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
bool Activate();
|
|
|
|
bool SetString(int i, const char *s);
|
|
|
|
bool GetString(int i, char *s, int len);
|
|
|
|
bool SetValue(int i, int value);
|
|
|
|
bool GetValue(int i, int *pvalue);
|
|
|
|
void OffsetPositionY(int ydelta) { mYpos += ydelta; }
|
|
|
|
double GetY() { return mYpos; }
|
2019-11-08 22:02:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
struct FOptionValues
|
|
|
|
{
|
|
|
|
struct Pair
|
|
|
|
{
|
|
|
|
double Value;
|
|
|
|
FString TextValue;
|
|
|
|
FString Text;
|
|
|
|
};
|
|
|
|
|
|
|
|
TArray<Pair> mValues;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef TMap< FName, FOptionValues* > FOptionMap;
|
|
|
|
|
|
|
|
extern FOptionMap OptionValues;
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
2019-11-28 00:02:45 +00:00
|
|
|
//
|
2019-12-01 16:48:56 +00:00
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
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);
|
|
|
|
void M_Init (void);
|
|
|
|
void M_CreateMenus();
|
|
|
|
void M_ActivateMenu(DMenu *menu);
|
2020-10-04 16:31:48 +00:00
|
|
|
void M_ClearMenus ();
|
|
|
|
void M_PreviousMenu ();
|
2019-11-08 22:02:52 +00:00
|
|
|
void M_ParseMenuDefs();
|
2020-10-04 16:31:48 +00:00
|
|
|
void M_DoStartControlPanel(bool scaleoverride);
|
|
|
|
void M_SetMenu(FName menu, int param = -1);
|
|
|
|
void M_StartMessage(const char *message, int messagemode, FName action = NAME_None);
|
|
|
|
DMenu *StartPickerMenu(DMenu *parent, const char *name, FColorCVar *cvar);
|
|
|
|
void M_MarkMenus();
|
|
|
|
FTextureID GetMenuTexture(const char* const name);
|
|
|
|
void DeinitMenus();
|
2019-12-01 09:18:38 +00:00
|
|
|
bool M_Active();
|
2020-10-04 16:31:48 +00:00
|
|
|
inline bool M_IsAnimated() { return false; }
|
2019-11-29 23:49:50 +00:00
|
|
|
|
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
struct IJoystickConfig;
|
|
|
|
DMenuItemBase * CreateOptionMenuItemStaticText(const char *name, int v = -1);
|
|
|
|
DMenuItemBase * CreateOptionMenuItemSubmenu(const char *label, FName cmd, int center);
|
|
|
|
DMenuItemBase * CreateOptionMenuItemControl(const char *label, FName cmd, FKeyBindings *bindings);
|
|
|
|
DMenuItemBase * CreateOptionMenuItemJoyConfigMenu(const char *label, IJoystickConfig *joy);
|
|
|
|
DMenuItemBase * CreateListMenuItemPatch(double x, double y, int height, int hotkey, FTextureID tex, FName command, int param);
|
|
|
|
DMenuItemBase * CreateListMenuItemText(double x, double y, int height, int hotkey, const char *text, FFont *font, PalEntry color1, PalEntry color2, FName command, int param);
|
|
|
|
DMenuItemBase * CreateOptionMenuItemCommand(const char *label, FName cmd, bool centered = false);
|
2020-08-31 17:56:13 +00:00
|
|
|
|
2020-10-04 16:31:48 +00:00
|
|
|
void UpdateVRModes(bool considerQuadBuffered=true);
|
2020-08-31 17:56:13 +00:00
|
|
|
|
2019-11-24 23:02:00 +00:00
|
|
|
#endif
|