mirror of
https://github.com/YimMenu/YimMenuV2.git
synced 2026-10-10 03:43:15 +08:00
Fixed hotkey issues (#757)
* Fix an issue where some hotkeys reset when loading * Fix the 'Clear' button in the hotkeys not working
This commit is contained in:
@@ -142,11 +142,17 @@ namespace YimMenu
|
||||
|
||||
void HotkeySystem::SaveStateImpl(nlohmann::json& state)
|
||||
{
|
||||
for (auto& hotkey : m_CommandHotkeys)
|
||||
for (const auto& hotkey : m_CommandHotkeys)
|
||||
{
|
||||
std::string key = std::to_string(hotkey.first);
|
||||
|
||||
if (!hotkey.second.m_Chain.empty())
|
||||
{
|
||||
state[std::to_string(hotkey.first).data()] = hotkey.second.m_Chain;
|
||||
state[key] = hotkey.second.m_Chain;
|
||||
}
|
||||
else if (state.contains(key))
|
||||
{
|
||||
state.erase(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,8 +161,8 @@ namespace YimMenu
|
||||
{
|
||||
for (auto& [key, value] : state.items())
|
||||
{
|
||||
if (m_CommandHotkeys.contains(std::atoi(key.data())))
|
||||
m_CommandHotkeys[std::atoi(key.data())].m_Chain = value.get<std::vector<int>>();
|
||||
if (m_CommandHotkeys.contains(static_cast<uint32_t>(std::stoul(key.data()))))
|
||||
m_CommandHotkeys[static_cast<uint32_t>(std::stoul(key.data()))].m_Chain = value.get<std::vector<int>>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace YimMenu
|
||||
public IStateSerializer
|
||||
{
|
||||
std::chrono::system_clock::time_point m_LastHotkeyTriggerTime;
|
||||
bool m_BeingModified;
|
||||
bool m_BeingModified = false;
|
||||
|
||||
public:
|
||||
HotkeySystem();
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace YimMenu::Submenus
|
||||
|
||||
for (auto& [name, link] : sortedCommands)
|
||||
{
|
||||
if (name.empty())
|
||||
continue;
|
||||
DrawHotkey(link, name);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user