mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
ImGui: make config singleton static
Avoid indirection, also deduplicate common style var assignments.
This commit is contained in:
parent
f3ee2e3e90
commit
06b2226bbc
@ -106,7 +106,7 @@ bool CModAppSystemGroup::StaticCreate(CModAppSystemGroup* pModAppSystemGroup)
|
|||||||
g_pClientEntityList = (CClientEntityList*)g_FactorySystem.GetFactory(VCLIENTENTITYLIST_INTERFACE_VERSION);
|
g_pClientEntityList = (CClientEntityList*)g_FactorySystem.GetFactory(VCLIENTENTITYLIST_INTERFACE_VERSION);
|
||||||
g_pEngineTraceClient = (CEngineTraceClient*)g_FactorySystem.GetFactory(INTERFACEVERSION_ENGINETRACE_CLIENT);
|
g_pEngineTraceClient = (CEngineTraceClient*)g_FactorySystem.GetFactory(INTERFACEVERSION_ENGINETRACE_CLIENT);
|
||||||
|
|
||||||
g_pImGuiConfig->Load(); // Load ImGui configs.
|
g_ImGuiConfig.Load(); // Load ImGui configs.
|
||||||
DirectX_Init();
|
DirectX_Init();
|
||||||
|
|
||||||
#endif // !DEDICATED
|
#endif // !DEDICATED
|
||||||
|
@ -37,15 +37,15 @@ int CGame::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN)
|
if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN)
|
||||||
{
|
{
|
||||||
if (wParam == g_pImGuiConfig->m_ConsoleConfig.m_nBind0 ||
|
if (wParam == g_ImGuiConfig.m_ConsoleConfig.m_nBind0 ||
|
||||||
wParam == g_pImGuiConfig->m_ConsoleConfig.m_nBind1)
|
wParam == g_ImGuiConfig.m_ConsoleConfig.m_nBind1)
|
||||||
{
|
{
|
||||||
g_Console.ToggleActive();
|
g_Console.ToggleActive();
|
||||||
ResetInput(); // Disable input to game when console is drawn.
|
ResetInput(); // Disable input to game when console is drawn.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wParam == g_pImGuiConfig->m_BrowserConfig.m_nBind0 ||
|
if (wParam == g_ImGuiConfig.m_BrowserConfig.m_nBind0 ||
|
||||||
wParam == g_pImGuiConfig->m_BrowserConfig.m_nBind1)
|
wParam == g_ImGuiConfig.m_BrowserConfig.m_nBind1)
|
||||||
{
|
{
|
||||||
g_Browser.ToggleActive();
|
g_Browser.ToggleActive();
|
||||||
ResetInput(); // Disable input to game when browser is drawn.
|
ResetInput(); // Disable input to game when browser is drawn.
|
||||||
|
@ -368,17 +368,17 @@ void CConsole::OptionsPanel(void)
|
|||||||
ImGui::Text("Console hotkey:");
|
ImGui::Text("Console hotkey:");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if (ImGui::Hotkey("##ToggleConsole", &g_pImGuiConfig->m_ConsoleConfig.m_nBind0, ImVec2(80, 80)))
|
if (ImGui::Hotkey("##ToggleConsole", &g_ImGuiConfig.m_ConsoleConfig.m_nBind0, ImVec2(80, 80)))
|
||||||
{
|
{
|
||||||
g_pImGuiConfig->Save();
|
g_ImGuiConfig.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text("Browser hotkey:");
|
ImGui::Text("Browser hotkey:");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if (ImGui::Hotkey("##ToggleBrowser", &g_pImGuiConfig->m_BrowserConfig.m_nBind0, ImVec2(80, 80)))
|
if (ImGui::Hotkey("##ToggleBrowser", &g_ImGuiConfig.m_BrowserConfig.m_nBind0, ImVec2(80, 80)))
|
||||||
{
|
{
|
||||||
g_pImGuiConfig->Save();
|
g_ImGuiConfig.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
@ -36,7 +36,7 @@ void CImguiSurface::Animate()
|
|||||||
void CImguiSurface::SetStyleVar(const float width, const float height,
|
void CImguiSurface::SetStyleVar(const float width, const float height,
|
||||||
const float x, const float y)
|
const float x, const float y)
|
||||||
{
|
{
|
||||||
m_surfaceStyle = g_pImGuiConfig->InitStyle();
|
m_surfaceStyle = g_ImGuiConfig.InitStyle();
|
||||||
|
|
||||||
ImGui::SetNextWindowSize(ImVec2(width, height), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(width, height), ImGuiCond_FirstUseEver);
|
||||||
ImGui::SetWindowPos(ImVec2(x, y), ImGuiCond_FirstUseEver);
|
ImGui::SetWindowPos(ImVec2(x, y), ImGuiCond_FirstUseEver);
|
||||||
|
25
src/thirdparty/imgui/misc/imgui_utility.cpp
vendored
25
src/thirdparty/imgui/misc/imgui_utility.cpp
vendored
@ -115,14 +115,9 @@ ImGuiStyle_t ImGuiConfig::InitStyle() const
|
|||||||
style.WindowBorderSize = 0.0f;
|
style.WindowBorderSize = 0.0f;
|
||||||
style.FrameBorderSize = 1.0f;
|
style.FrameBorderSize = 1.0f;
|
||||||
style.ChildBorderSize = 1.0f;
|
style.ChildBorderSize = 1.0f;
|
||||||
style.PopupBorderSize = 1.0f;
|
|
||||||
style.TabBorderSize = 1.0f;
|
|
||||||
|
|
||||||
style.WindowRounding = 4.0f;
|
|
||||||
style.FrameRounding = 1.0f;
|
|
||||||
style.ChildRounding = 1.0f;
|
style.ChildRounding = 1.0f;
|
||||||
style.PopupRounding = 3.0f;
|
style.PopupRounding = 3.0f;
|
||||||
style.TabRounding = 1.0f;
|
|
||||||
style.ScrollbarRounding = 1.0f;
|
style.ScrollbarRounding = 1.0f;
|
||||||
|
|
||||||
result = ImGuiStyle_t::LEGACY;
|
result = ImGuiStyle_t::LEGACY;
|
||||||
@ -167,14 +162,9 @@ ImGuiStyle_t ImGuiConfig::InitStyle() const
|
|||||||
style.WindowBorderSize = 1.0f;
|
style.WindowBorderSize = 1.0f;
|
||||||
style.FrameBorderSize = 0.0f;
|
style.FrameBorderSize = 0.0f;
|
||||||
style.ChildBorderSize = 0.0f;
|
style.ChildBorderSize = 0.0f;
|
||||||
style.PopupBorderSize = 1.0f;
|
|
||||||
style.TabBorderSize = 1.0f;
|
|
||||||
|
|
||||||
style.WindowRounding = 4.0f;
|
|
||||||
style.FrameRounding = 1.0f;
|
|
||||||
style.ChildRounding = 1.0f;
|
style.ChildRounding = 1.0f;
|
||||||
style.PopupRounding = 3.0f;
|
style.PopupRounding = 3.0f;
|
||||||
style.TabRounding = 1.0f;
|
|
||||||
style.ScrollbarRounding = 3.0f;
|
style.ScrollbarRounding = 3.0f;
|
||||||
|
|
||||||
result = ImGuiStyle_t::MODERN;
|
result = ImGuiStyle_t::MODERN;
|
||||||
@ -223,20 +213,23 @@ ImGuiStyle_t ImGuiConfig::InitStyle() const
|
|||||||
style.WindowBorderSize = 1.0f;
|
style.WindowBorderSize = 1.0f;
|
||||||
style.FrameBorderSize = 1.0f;
|
style.FrameBorderSize = 1.0f;
|
||||||
style.ChildBorderSize = 0.0f;
|
style.ChildBorderSize = 0.0f;
|
||||||
style.PopupBorderSize = 1.0f;
|
|
||||||
style.TabBorderSize = 1.0f;
|
|
||||||
|
|
||||||
style.WindowRounding = 4.0f;
|
|
||||||
style.FrameRounding = 1.0f;
|
|
||||||
style.ChildRounding = 2.0f;
|
style.ChildRounding = 2.0f;
|
||||||
style.PopupRounding = 4.0f;
|
style.PopupRounding = 4.0f;
|
||||||
style.TabRounding = 1.0f;
|
|
||||||
style.GrabRounding = 1.0f;
|
style.GrabRounding = 1.0f;
|
||||||
style.ScrollbarRounding = 1.0f;
|
style.ScrollbarRounding = 1.0f;
|
||||||
|
|
||||||
result = ImGuiStyle_t::DEFAULT;
|
result = ImGuiStyle_t::DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
style.PopupBorderSize = 1.0f;
|
||||||
|
style.TabBorderSize = 1.0f;
|
||||||
|
style.TabBarBorderSize = 1.0f;
|
||||||
|
|
||||||
|
style.WindowRounding = 4.0f;
|
||||||
|
style.FrameRounding = 1.0f;
|
||||||
|
style.TabRounding = 1.0f;
|
||||||
|
|
||||||
style.ItemSpacing = ImVec2(5, 4);
|
style.ItemSpacing = ImVec2(5, 4);
|
||||||
style.FramePadding = ImVec2(4, 4);
|
style.FramePadding = ImVec2(4, 4);
|
||||||
style.WindowPadding = ImVec2(5, 5);
|
style.WindowPadding = ImVec2(5, 5);
|
||||||
@ -244,4 +237,4 @@ ImGuiStyle_t ImGuiConfig::InitStyle() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiConfig* g_pImGuiConfig = new ImGuiConfig();
|
ImGuiConfig g_ImGuiConfig;
|
||||||
|
2
src/thirdparty/imgui/misc/imgui_utility.h
vendored
2
src/thirdparty/imgui/misc/imgui_utility.h
vendored
@ -30,4 +30,4 @@ public:
|
|||||||
ImGuiStyle_t InitStyle() const;
|
ImGuiStyle_t InitStyle() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ImGuiConfig* g_pImGuiConfig;
|
extern ImGuiConfig g_ImGuiConfig;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user