project64/Source/Project64/UserInterface/MenuShortCuts.h

117 lines
3.6 KiB
C
Raw Normal View History

2016-01-27 09:11:59 +00:00
#pragma once
struct VIRTUAL_KEY
{
2020-05-12 12:19:05 +00:00
LPCTSTR Name;
int Key;
LPCTSTR KeyName;
2016-01-27 09:11:59 +00:00
};
class CMenuShortCutKey
{
public:
2017-04-29 05:55:30 +00:00
enum RUNNING_STATE
{
RUNNING_STATE_NOT_RUNNING = 1,
RUNNING_STATE_WINDOWED = 2,
RUNNING_STATE_FULLSCREEN = 3,
};
2016-01-27 09:11:59 +00:00
enum ACCESS_MODE
{
2017-04-29 05:55:30 +00:00
ACCESS_NONE = 0,
ACCESS_GAME_NOT_RUNNING = 1,
ACCESS_GAME_RUNNING_WINDOW = 2,
ACCESS_NOT_IN_FULLSCREEN = 3,
ACCESS_GAME_RUNNING_FULLSCREEN = 4,
ACCESS_GAME_RUNNING = 6,
ACCESS_ANYTIME = 7,
2016-01-27 09:11:59 +00:00
};
public:
CMenuShortCutKey(void);
CMenuShortCutKey(WORD key, bool bCtrl, bool bAlt, bool bShift, ACCESS_MODE AccessMode, bool bUserAdded, bool bInactive);
2017-04-29 05:55:30 +00:00
bool Match(WORD key, bool bCtrl, bool bAlt, bool bShift, RUNNING_STATE RunningState) const;
bool Active(RUNNING_STATE RunningState) const;
2016-01-27 09:11:59 +00:00
static VIRTUAL_KEY * VirtualKeyList(int &Size);
2017-04-29 05:55:30 +00:00
static RUNNING_STATE RunningState(void);
2016-01-27 09:11:59 +00:00
2020-05-12 12:19:05 +00:00
inline const std::wstring & Name(void) const { return m_ShortCutName; }
inline WORD Key(void) const { return m_key; }
inline bool Ctrl(void) const { return m_bCtrl; }
inline bool Alt(void) const { return m_bAlt; }
inline bool Shift(void) const { return m_bShift; }
inline bool UserAdded(void) const { return m_bUserAdded; }
inline bool Inactive(void) const { return m_bInactive; }
2016-01-27 09:11:59 +00:00
inline ACCESS_MODE AccessMode(void) const { return m_AccessMode; }
2020-05-12 12:19:05 +00:00
inline void SetInactive(bool Inactive) { m_bInactive = Inactive; }
private:
static VIRTUAL_KEY m_VirtualKeyList[];
std::wstring m_ShortCutName;
WORD m_key;
bool m_bCtrl;
bool m_bAlt;
bool m_bShift;
ACCESS_MODE m_AccessMode;
bool m_bUserAdded;
bool m_bInactive;
2016-01-27 09:11:59 +00:00
};
class CShortCutItem
{
public:
typedef std::list<CMenuShortCutKey> SHORTCUT_KEY_LIST;
private:
typedef CMenuShortCutKey::ACCESS_MODE ACCESS_MODE;
2017-04-29 05:55:30 +00:00
typedef CMenuShortCutKey::RUNNING_STATE RUNNING_STATE;
2016-01-27 09:11:59 +00:00
ACCESS_MODE m_Access;
LanguageStringID m_Section;
LanguageStringID m_Title;
SHORTCUT_KEY_LIST m_AccelList;
public:
CShortCutItem(LanguageStringID Section, LanguageStringID Title, ACCESS_MODE Access);
void Reset(LanguageStringID Section, LanguageStringID Title, ACCESS_MODE Access);
void AddShortCut(WORD key, bool bCtrl, bool bAlt, bool bShift, ACCESS_MODE AccessMode, bool bUserAdded = false, bool bInactive = false);
void RemoveItem(CMenuShortCutKey * ShortCut);
2017-04-29 05:55:30 +00:00
bool Avaliable(RUNNING_STATE RunningState);
2016-01-27 09:11:59 +00:00
2017-04-29 05:55:30 +00:00
inline const SHORTCUT_KEY_LIST & GetAccelItems(void) const { return m_AccelList; }
2016-01-27 09:11:59 +00:00
inline LanguageStringID Section(void) const { return m_Section; }
inline LanguageStringID Title(void) const { return m_Title; }
2017-04-29 05:55:30 +00:00
inline ACCESS_MODE AccessMode(void) const { return m_Access; }
2016-01-27 09:11:59 +00:00
};
typedef std::map<int, CShortCutItem> MSC_MAP;
class CShortCuts
{
typedef CShortCutItem::SHORTCUT_KEY_LIST SHORTCUT_KEY_LIST;
2017-04-29 05:55:30 +00:00
typedef CMenuShortCutKey::ACCESS_MODE ACCESS_MODE;
typedef CMenuShortCutKey::RUNNING_STATE RUNNING_STATE;
2016-01-27 09:11:59 +00:00
typedef LanguageStringID LangStr;
MSC_MAP m_ShortCuts;
CriticalSection m_CS;
void AddShortCut(WORD ID, LangStr Section, LangStr LangID, CMenuShortCutKey::ACCESS_MODE AccessMode);
public:
CShortCuts(void);
~CShortCuts(void);
2017-04-29 05:55:30 +00:00
std::wstring ShortCutString(int MenuID, RUNNING_STATE RunningState);
LangStr GetMenuItemName(WORD key, bool bCtrl, bool bAlt, bool bShift, RUNNING_STATE RunningState);
HACCEL GetAcceleratorTable(void);
MSC_MAP & GetShortCuts(void) { return m_ShortCuts; }
2016-01-27 09:11:59 +00:00
void Load(bool InitialValues = false);
void Save(void);
};