2016-03-01 15:47:10 +00:00
|
|
|
#ifndef __M_MENU_MENU_H__
|
|
|
|
#define __M_MENU_MENU_H__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "dobject.h"
|
|
|
|
#include "d_player.h"
|
|
|
|
#include "r_data/r_translate.h"
|
|
|
|
#include "c_cvars.h"
|
|
|
|
#include "v_font.h"
|
|
|
|
#include "textures/textures.h"
|
|
|
|
|
|
|
|
EXTERN_CVAR(Float, snd_menuvolume)
|
|
|
|
EXTERN_CVAR(Int, m_use_mouse);
|
|
|
|
|
|
|
|
|
|
|
|
struct event_t;
|
|
|
|
class FTexture;
|
|
|
|
class FFont;
|
2017-02-10 11:34:28 +00:00
|
|
|
enum EColorRange : int;
|
2016-03-01 15:47:10 +00:00
|
|
|
class FPlayerClass;
|
|
|
|
class FKeyBindings;
|
2017-02-11 16:20:12 +00:00
|
|
|
struct FBrokenLines;
|
2016-03-01 15:47:10 +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,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct FGameStartup
|
|
|
|
{
|
|
|
|
const char *PlayerClass;
|
|
|
|
int Episode;
|
|
|
|
int Skill;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern FGameStartup GameStartupInfo;
|
|
|
|
|
|
|
|
struct FSaveGameNode
|
|
|
|
{
|
2017-02-18 11:36:31 +00:00
|
|
|
FString SaveTitle;
|
2016-03-01 15:47:10 +00:00
|
|
|
FString Filename;
|
2017-02-18 13:08:16 +00:00
|
|
|
bool bOldVersion = false;
|
|
|
|
bool bMissingWads = false;
|
|
|
|
bool bNoDelete = false;
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
2017-02-18 13:08:16 +00:00
|
|
|
struct FSavegameManager
|
2017-02-11 16:20:12 +00:00
|
|
|
{
|
2017-02-18 12:05:33 +00:00
|
|
|
private:
|
2017-02-11 16:20:12 +00:00
|
|
|
TArray<FSaveGameNode*> SaveGames;
|
2017-02-18 12:05:33 +00:00
|
|
|
FSaveGameNode NewSaveNode;
|
2017-02-11 16:20:12 +00:00
|
|
|
int LastSaved = -1;
|
|
|
|
int LastAccessed = -1;
|
|
|
|
TArray<char> SavePicData;
|
|
|
|
FTexture *SavePic = nullptr;
|
|
|
|
FBrokenLines *SaveComment = nullptr;
|
|
|
|
|
2017-02-18 13:08:16 +00:00
|
|
|
public:
|
|
|
|
int WindowSize = 0;
|
|
|
|
FSaveGameNode *quickSaveSlot = nullptr;
|
2017-02-18 13:18:27 +00:00
|
|
|
~FSavegameManager();
|
2017-02-18 13:08:16 +00:00
|
|
|
|
2017-02-18 12:05:33 +00:00
|
|
|
private:
|
2017-02-11 16:20:12 +00:00
|
|
|
int InsertSaveNode(FSaveGameNode *node);
|
2017-02-18 12:05:33 +00:00
|
|
|
public:
|
2017-02-18 13:08:16 +00:00
|
|
|
void NotifyNewSave(const FString &file, const FString &title, bool okForQuicksave);
|
2017-02-18 12:05:33 +00:00
|
|
|
void ClearSaveGames();
|
2017-02-18 13:08:16 +00:00
|
|
|
|
2017-02-11 16:20:12 +00:00
|
|
|
void ReadSaveStrings();
|
2017-02-18 13:08:16 +00:00
|
|
|
void UnloadSaveData();
|
|
|
|
|
|
|
|
int RemoveSaveSlot(int index);
|
2017-02-11 16:20:12 +00:00
|
|
|
void LoadSavegame(int Selected);
|
|
|
|
void DoSave(int Selected, const char *savegamestring);
|
2017-02-18 13:08:16 +00:00
|
|
|
unsigned ExtractSaveData(int index);
|
2017-02-11 16:20:12 +00:00
|
|
|
void ClearSaveStuff();
|
|
|
|
bool DrawSavePic(int x, int y, int w, int h);
|
2017-02-18 13:08:16 +00:00
|
|
|
void DrawSaveComment(FFont *font, int cr, int x, int y, int scalefactor);
|
2017-02-11 16:20:12 +00:00
|
|
|
void SetFileInfo(int Selected);
|
2017-02-18 12:05:33 +00:00
|
|
|
unsigned SavegameCount();
|
2017-02-18 16:35:01 +00:00
|
|
|
FSaveGameNode *GetSavegame(int i);
|
2017-02-18 12:05:33 +00:00
|
|
|
void InsertNewSaveNode();
|
|
|
|
bool RemoveNewSaveNode();
|
2017-02-11 16:20:12 +00:00
|
|
|
|
|
|
|
};
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2017-02-18 13:08:16 +00:00
|
|
|
extern FSavegameManager savegameManager;
|
2017-02-18 18:19:14 +00:00
|
|
|
class DMenu;
|
|
|
|
extern DMenu *CurrentMenu;
|
|
|
|
extern int MenuTime;
|
2017-06-11 20:30:40 +00:00
|
|
|
class DMenuItemBase;
|
2016-03-01 15:47:10 +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
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2017-02-09 19:18:53 +00:00
|
|
|
class DMenuDescriptor : public DObject
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2017-02-09 19:18:53 +00:00
|
|
|
DECLARE_CLASS(DMenuDescriptor, DObject)
|
|
|
|
public:
|
2018-08-18 23:14:15 +00:00
|
|
|
FName mMenuName = NAME_None;
|
2016-03-01 15:47:10 +00:00
|
|
|
FString mNetgameMessage;
|
2017-02-16 17:55:36 +00:00
|
|
|
PClass *mClass = nullptr;
|
2017-06-11 07:57:10 +00:00
|
|
|
bool mProtected = false;
|
2017-06-11 20:30:40 +00:00
|
|
|
TArray<DMenuItemBase *> mItems;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2017-02-03 20:34:49 +00:00
|
|
|
virtual size_t PropagateMark() { return 0; }
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-02-09 19:18:53 +00:00
|
|
|
class DListMenuDescriptor : public DMenuDescriptor
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2017-02-09 19:18:53 +00:00
|
|
|
DECLARE_CLASS(DListMenuDescriptor, DMenuDescriptor)
|
|
|
|
|
|
|
|
public:
|
2016-03-01 15:47:10 +00:00
|
|
|
int mSelectedItem;
|
2017-02-19 16:24:30 +00:00
|
|
|
double mSelectOfsX;
|
|
|
|
double mSelectOfsY;
|
2016-03-01 15:47:10 +00:00
|
|
|
FTextureID mSelector;
|
|
|
|
int mDisplayTop;
|
2017-02-19 16:24:30 +00:00
|
|
|
double mXpos, mYpos;
|
2016-03-01 15:47:10 +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;
|
|
|
|
bool mCenter;
|
|
|
|
|
|
|
|
void Reset()
|
|
|
|
{
|
|
|
|
// Reset the default settings (ignore all other values in the struct)
|
|
|
|
mSelectOfsX = 0;
|
|
|
|
mSelectOfsY = 0;
|
|
|
|
mSelector.SetInvalid();
|
|
|
|
mDisplayTop = 0;
|
|
|
|
mXpos = 0;
|
|
|
|
mYpos = 0;
|
|
|
|
mLinespacing = 0;
|
|
|
|
mNetgameMessage = "";
|
|
|
|
mFont = NULL;
|
|
|
|
mFontColor = CR_UNTRANSLATED;
|
|
|
|
mFontColor2 = CR_UNTRANSLATED;
|
|
|
|
}
|
2017-02-03 20:34:49 +00:00
|
|
|
|
|
|
|
size_t PropagateMark() override;
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FOptionMenuSettings
|
|
|
|
{
|
|
|
|
EColorRange mTitleColor;
|
|
|
|
EColorRange mFontColor;
|
|
|
|
EColorRange mFontColorValue;
|
|
|
|
EColorRange mFontColorMore;
|
|
|
|
EColorRange mFontColorHeader;
|
|
|
|
EColorRange mFontColorHighlight;
|
|
|
|
EColorRange mFontColorSelection;
|
|
|
|
int mLinespacing;
|
|
|
|
};
|
|
|
|
|
2017-02-09 19:18:53 +00:00
|
|
|
class DOptionMenuDescriptor : public DMenuDescriptor
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2017-02-09 19:18:53 +00:00
|
|
|
DECLARE_CLASS(DOptionMenuDescriptor, DMenuDescriptor)
|
|
|
|
|
|
|
|
public:
|
2016-03-01 15:47:10 +00:00
|
|
|
FString mTitle;
|
|
|
|
int mSelectedItem;
|
|
|
|
int mDrawTop;
|
|
|
|
int mScrollTop;
|
|
|
|
int mScrollPos;
|
|
|
|
int mIndent;
|
|
|
|
int mPosition;
|
|
|
|
bool mDontDim;
|
|
|
|
|
|
|
|
void CalcIndent();
|
2017-02-11 20:28:48 +00:00
|
|
|
DMenuItemBase *GetItem(FName name);
|
2016-03-01 15:47:10 +00:00
|
|
|
void Reset()
|
|
|
|
{
|
|
|
|
// Reset the default settings (ignore all other values in the struct)
|
|
|
|
mPosition = 0;
|
|
|
|
mScrollTop = 0;
|
|
|
|
mIndent = 0;
|
|
|
|
mDontDim = 0;
|
|
|
|
}
|
2017-02-03 20:34:49 +00:00
|
|
|
size_t PropagateMark() override;
|
2017-02-09 19:18:53 +00:00
|
|
|
~DOptionMenuDescriptor()
|
|
|
|
{
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-02-09 19:18:53 +00:00
|
|
|
typedef TMap<FName, DMenuDescriptor *> MenuDescriptorList;
|
2016-03-01 15:47:10 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DMenu : public DObject
|
|
|
|
{
|
|
|
|
DECLARE_CLASS (DMenu, DObject)
|
|
|
|
HAS_OBJECT_POINTERS
|
|
|
|
|
2017-02-18 20:18:23 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MOUSE_Click,
|
|
|
|
MOUSE_Move,
|
|
|
|
MOUSE_Release
|
|
|
|
};
|
|
|
|
|
2017-03-08 12:34:26 +00:00
|
|
|
TObjPtr<DMenu*> mParentMenu;
|
2017-02-18 20:18:23 +00:00
|
|
|
bool mMouseCapture;
|
|
|
|
bool mBackbuttonSelected;
|
2017-02-19 12:07:49 +00:00
|
|
|
bool DontDim;
|
2018-09-15 10:30:05 +00:00
|
|
|
static int InMenu;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
DMenu(DMenu *parent = NULL);
|
2017-02-12 20:45:37 +00:00
|
|
|
bool TranslateKeyboardEvents();
|
2016-03-01 15:47:10 +00:00
|
|
|
virtual void Close();
|
2017-02-11 15:11:48 +00:00
|
|
|
|
2017-02-12 17:38:23 +00:00
|
|
|
bool CallResponder(event_t *ev);
|
2017-02-09 23:25:50 +00:00
|
|
|
bool CallMenuEvent(int mkey, bool fromcontroller);
|
2017-02-12 23:08:20 +00:00
|
|
|
void CallTicker();
|
2017-02-10 12:20:19 +00:00
|
|
|
void CallDrawer();
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
// base class for menu items
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
|
2017-02-03 23:19:25 +00:00
|
|
|
class DMenuItemBase : public DObject
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2017-02-03 23:19:25 +00:00
|
|
|
DECLARE_CLASS(DMenuItemBase, DObject)
|
2017-02-09 19:18:53 +00:00
|
|
|
public:
|
2017-02-19 16:24:30 +00:00
|
|
|
double mXpos, mYpos;
|
2018-08-18 23:14:15 +00:00
|
|
|
FName mAction;
|
2016-03-01 15:47:10 +00:00
|
|
|
bool mEnabled;
|
|
|
|
|
|
|
|
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);
|
2017-02-12 00:18:49 +00:00
|
|
|
void OffsetPositionY(int ydelta) { mYpos += ydelta; }
|
2017-02-19 16:24:30 +00:00
|
|
|
double GetY() { return mYpos; }
|
2017-02-12 00:18:49 +00:00
|
|
|
};
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
struct FOptionValues
|
|
|
|
{
|
|
|
|
struct Pair
|
|
|
|
{
|
|
|
|
double Value;
|
|
|
|
FString TextValue;
|
|
|
|
FString Text;
|
|
|
|
};
|
|
|
|
|
|
|
|
TArray<Pair> mValues;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef TMap< FName, FOptionValues* > FOptionMap;
|
|
|
|
|
|
|
|
extern FOptionMap OptionValues;
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//
|
2017-02-18 20:25:19 +00:00
|
|
|
//
|
2016-03-01 15:47:10 +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);
|
|
|
|
void M_ClearMenus ();
|
2018-08-01 15:53:58 +00:00
|
|
|
void M_PreviousMenu ();
|
2016-03-01 15:47:10 +00:00
|
|
|
void M_ParseMenuDefs();
|
|
|
|
void M_StartupSkillMenu(FGameStartup *gs);
|
|
|
|
void M_StartControlPanel (bool makeSound);
|
|
|
|
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);
|
2017-02-03 20:34:49 +00:00
|
|
|
void M_MarkMenus();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
|
2017-02-11 20:28:48 +00:00
|
|
|
struct IJoystickConfig;
|
2017-06-11 20:30:40 +00:00
|
|
|
DMenuItemBase * CreateOptionMenuItemStaticText(const char *name, int v = -1);
|
2017-02-11 20:28:48 +00:00
|
|
|
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);
|
2017-02-19 16:24:30 +00:00
|
|
|
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);
|
2017-04-18 14:42:28 +00:00
|
|
|
DMenuItemBase * CreateOptionMenuItemCommand(const char *label, FName cmd, bool centered = false);
|
2017-02-11 20:28:48 +00:00
|
|
|
|
2017-02-10 11:34:28 +00:00
|
|
|
#endif
|