mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
ImGui: readjust and fix imgui keybind configuration
In commit f5f14c153f0115af7a0ac5fe3b4be98b3816be84, a change was made to switch the default keys to pgup and pgdown. It appears however that these keys were used for the chat window. The defaults have been adjusted to (backtick and f10) for console, and (insert and f11) for the browser. There was also a bug in ImGuiConfig::Save() where it double nested the keyvalues, this has also been fixed. The keyvalue file now parser properly. The option panel in the console has been slightly reworked to also show the secondary binding options for both the console als browser allowing the user to change both the primary and secondary for both windows without having to manually edit the files.
This commit is contained in:
parent
6ed6711426
commit
6f534e9811
@ -353,37 +353,66 @@ void CConsole::DrawOptionsPanel(void)
|
||||
ImGui::Checkbox("Auto-scroll", &m_colorTextLogger.m_bAutoScroll);
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(100);
|
||||
ImGui::Spacing();
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
if (ImGui::SmallButton("Clear"))
|
||||
if (ImGui::SmallButton("Clear Text"))
|
||||
{
|
||||
ClearLog();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::Spacing();
|
||||
ImGui::SameLine();
|
||||
|
||||
// Copies all logged text to the clip board
|
||||
if (ImGui::SmallButton("Copy"))
|
||||
if (ImGui::SmallButton("Copy Text"))
|
||||
{
|
||||
AUTO_LOCK(m_colorTextLoggerMutex);
|
||||
m_colorTextLogger.Copy(true);
|
||||
}
|
||||
|
||||
ImGui::Text("Console hotkey:");
|
||||
ImGui::Text("Console HotKey:");
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Hotkey("##ToggleConsole", &g_ImGuiConfig.m_ConsoleConfig.m_nBind0, ImVec2(80, 80)))
|
||||
int selected = g_ImGuiConfig.m_ConsoleConfig.m_nBind0;
|
||||
|
||||
if (ImGui::Hotkey("##ToggleConsolePrimary", &selected, ImVec2(80, 80)) &&
|
||||
!g_ImGuiConfig.KeyUsed(selected))
|
||||
{
|
||||
g_ImGuiConfig.m_ConsoleConfig.m_nBind0 = selected;
|
||||
g_ImGuiConfig.Save();
|
||||
}
|
||||
|
||||
ImGui::Text("Browser hotkey:");
|
||||
ImGui::SameLine();
|
||||
selected = g_ImGuiConfig.m_ConsoleConfig.m_nBind1;
|
||||
|
||||
if (ImGui::Hotkey("##ToggleConsoleSecondary", &selected, ImVec2(80, 80)) &&
|
||||
!g_ImGuiConfig.KeyUsed(selected))
|
||||
{
|
||||
g_ImGuiConfig.m_ConsoleConfig.m_nBind1 = selected;
|
||||
g_ImGuiConfig.Save();
|
||||
}
|
||||
|
||||
ImGui::Text("Browser HotKey:");
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Hotkey("##ToggleBrowser", &g_ImGuiConfig.m_BrowserConfig.m_nBind0, ImVec2(80, 80)))
|
||||
selected = g_ImGuiConfig.m_BrowserConfig.m_nBind0;
|
||||
|
||||
if (ImGui::Hotkey("##ToggleBrowserPrimary", &selected, ImVec2(80, 80)) &&
|
||||
!g_ImGuiConfig.KeyUsed(selected))
|
||||
{
|
||||
g_ImGuiConfig.m_BrowserConfig.m_nBind0 = selected;
|
||||
g_ImGuiConfig.Save();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
selected = g_ImGuiConfig.m_BrowserConfig.m_nBind1;
|
||||
|
||||
if (ImGui::Hotkey("##ToggleBrowserSecondary", &selected, ImVec2(80, 80)) &&
|
||||
!g_ImGuiConfig.KeyUsed(selected))
|
||||
{
|
||||
g_ImGuiConfig.m_BrowserConfig.m_nBind1 = selected;
|
||||
g_ImGuiConfig.Save();
|
||||
}
|
||||
|
||||
|
23
src/thirdparty/imgui/misc/imgui_utility.cpp
vendored
23
src/thirdparty/imgui/misc/imgui_utility.cpp
vendored
@ -28,15 +28,15 @@ void ImGuiConfig::Load()
|
||||
KeyValues* pConsoleKV = pKeyMapKV->FindKey(GAME_CONSOLE_KEY);
|
||||
if (pConsoleKV)
|
||||
{
|
||||
m_ConsoleConfig.m_nBind0 = pConsoleKV->GetInt("$bindDef", VK_OEM_3);
|
||||
m_ConsoleConfig.m_nBind1 = pConsoleKV->GetInt("$bindExt", VK_INSERT);
|
||||
}
|
||||
m_ConsoleConfig.m_nBind0 = pConsoleKV->GetInt("$primaryKey", VK_OEM_3);
|
||||
m_ConsoleConfig.m_nBind1 = pConsoleKV->GetInt("$secondaryKey", VK_F10);
|
||||
}
|
||||
|
||||
KeyValues* pBrowserKV = pKeyMapKV->FindKey(GAME_BROWSER_KEY);
|
||||
if (pBrowserKV)
|
||||
{
|
||||
m_BrowserConfig.m_nBind0 = pBrowserKV->GetInt("$bindDef", VK_F10);
|
||||
m_BrowserConfig.m_nBind1 = pBrowserKV->GetInt("$bindExt", VK_HOME);
|
||||
m_BrowserConfig.m_nBind0 = pBrowserKV->GetInt("$primaryKey", VK_INSERT);
|
||||
m_BrowserConfig.m_nBind1 = pBrowserKV->GetInt("$secondaryKey", VK_F11);
|
||||
}
|
||||
|
||||
pKeyMapKV->DeleteThis();
|
||||
@ -50,15 +50,14 @@ void ImGuiConfig::Save()
|
||||
FileSystem()->CreateDirHierarchy(SDK_USER_CFG_PATH, "PLATFORM"); // Create directory, so ImGui can load/save 'layout.ini'.
|
||||
|
||||
KeyValues kv("KeyMap");
|
||||
KeyValues* pKeyMapKV = kv.FindKey("KeyMap", true);
|
||||
|
||||
KeyValues* pConsoleKV = pKeyMapKV->FindKey(GAME_CONSOLE_KEY, true);
|
||||
pConsoleKV->SetInt("$bindDef", m_ConsoleConfig.m_nBind0);
|
||||
pConsoleKV->SetInt("$bindExt", m_ConsoleConfig.m_nBind1);
|
||||
KeyValues* pConsoleKV = kv.FindKey(GAME_CONSOLE_KEY, true);
|
||||
pConsoleKV->SetInt("$primaryKey", m_ConsoleConfig.m_nBind0);
|
||||
pConsoleKV->SetInt("$secondaryKey", m_ConsoleConfig.m_nBind1);
|
||||
|
||||
KeyValues* pBrowserKV = pKeyMapKV->FindKey(GAME_BROWSER_KEY, true);
|
||||
pBrowserKV->SetInt("$bindDef", m_BrowserConfig.m_nBind0);
|
||||
pBrowserKV->SetInt("$bindExt", m_BrowserConfig.m_nBind1);
|
||||
KeyValues* pBrowserKV = kv.FindKey(GAME_BROWSER_KEY, true);
|
||||
pBrowserKV->SetInt("$primaryKey", m_BrowserConfig.m_nBind0);
|
||||
pBrowserKV->SetInt("$secondaryKey", m_BrowserConfig.m_nBind1);
|
||||
|
||||
CUtlBuffer uBuf(0i64, 0, CUtlBuffer::TEXT_BUFFER);
|
||||
|
||||
|
12
src/thirdparty/imgui/misc/imgui_utility.h
vendored
12
src/thirdparty/imgui/misc/imgui_utility.h
vendored
@ -9,18 +9,24 @@ public:
|
||||
struct
|
||||
{
|
||||
int m_nBind0 = VK_OEM_3;
|
||||
int m_nBind1 = VK_PRIOR;
|
||||
int m_nBind1 = VK_F10;
|
||||
} m_ConsoleConfig;
|
||||
|
||||
struct
|
||||
{
|
||||
int m_nBind0 = VK_F10;
|
||||
int m_nBind1 = VK_NEXT;
|
||||
int m_nBind0 = VK_INSERT;
|
||||
int m_nBind1 = VK_F11;
|
||||
} m_BrowserConfig;
|
||||
|
||||
void Load();
|
||||
void Save();
|
||||
ImGuiStyle_t InitStyle() const;
|
||||
|
||||
inline bool KeyUsed(const int key) const
|
||||
{
|
||||
return (key == m_ConsoleConfig.m_nBind0 || key == m_ConsoleConfig.m_nBind1)
|
||||
|| (key == m_BrowserConfig.m_nBind0 || key == m_BrowserConfig.m_nBind1);
|
||||
};
|
||||
};
|
||||
|
||||
extern ImGuiConfig g_ImGuiConfig;
|
||||
|
Loading…
x
Reference in New Issue
Block a user