project64/Source/Project64/UserInterface/MenuShortCuts.h

160 lines
3.8 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
2022-09-26 02:31:54 +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
2022-09-26 02:31:54 +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;
}
inline ACCESS_MODE AccessMode(void) const
{
return m_AccessMode;
}
2016-01-27 09:11:59 +00:00
2022-09-26 02:31:54 +00:00
inline void SetInactive(bool Inactive)
{
m_bInactive = Inactive;
}
2020-05-12 12:19:05 +00:00
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:
2022-09-26 02:31:54 +00:00
typedef std::list<CMenuShortCutKey> SHORTCUT_KEY_LIST;
2016-01-27 09:11:59 +00:00
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
2022-09-26 02:31:54 +00:00
ACCESS_MODE m_Access;
LanguageStringID m_Section;
LanguageStringID m_Title;
SHORTCUT_KEY_LIST m_AccelList;
2016-01-27 09:11:59 +00:00
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);
2021-04-26 10:48:20 +00:00
bool Avaliable(RUNNING_STATE RunningState) const;
2016-01-27 09:11:59 +00:00
2022-09-26 02:31:54 +00:00
inline const SHORTCUT_KEY_LIST & GetAccelItems(void) const
{
return m_AccelList;
}
inline LanguageStringID Section(void) const
{
return m_Section;
}
inline LanguageStringID Title(void) const
{
return m_Title;
}
inline ACCESS_MODE AccessMode(void) const
{
return m_Access;
}
2016-01-27 09:11:59 +00:00
};
2022-09-26 02:31:54 +00:00
typedef std::map<int, CShortCutItem> MSC_MAP;
2016-01-27 09:11:59 +00:00
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;
2022-09-26 02:31:54 +00:00
2016-01-27 09:11:59 +00:00
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);
2022-09-26 02:31:54 +00:00
const MSC_MAP & GetShortCuts(void) const
{
return m_ShortCuts;
}
2016-01-27 09:11:59 +00:00
void Load(bool InitialValues = false);
void Save(void);
2021-04-26 10:48:20 +00:00
private:
CriticalSection m_CS;
MSC_MAP m_ShortCuts;
void AddShortCut(WORD ID, LangStr Section, LangStr LangID, CMenuShortCutKey::ACCESS_MODE AccessMode);
2016-01-27 09:11:59 +00:00
};