From 70404bf53e9cdc6445dd81c1e962b6eb65453a86 Mon Sep 17 00:00:00 2001 From: Legulysse Date: Sun, 27 Oct 2024 00:38:02 +0200 Subject: [PATCH] Fix for imgui 1.91.1 with IMGUI_DISABLE_OBSOLETE_FUNCTIONS --- imgui-SFML.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/imgui-SFML.cpp b/imgui-SFML.cpp index ecc033b..38f7d9c 100644 --- a/imgui-SFML.cpp +++ b/imgui-SFML.cpp @@ -138,8 +138,8 @@ void updateJoystickDPadState(ImGuiIO& io); void updateJoystickAxisState(ImGuiIO& io); // clipboard functions -void setClipboardText(void* userData, const char* text); -const char* getClipboardText(void* userData); +void setClipboardText(ImGuiContext* /*ctx*/, const char* text); +const char* getClipboardText(ImGuiContext* /*ctx*/); std::string s_clipboardText; // mouse cursors @@ -229,6 +229,7 @@ bool Init(sf::Window& window, const sf::Vector2f& displaySize, bool loadDefaultF ImGui::SetCurrentContext(s_currWindowCtx->imContext); ImGuiIO& io = ImGui::GetIO(); + ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); // tell ImGui which features we support io.BackendFlags |= ImGuiBackendFlags_HasGamepad; @@ -244,8 +245,8 @@ bool Init(sf::Window& window, const sf::Vector2f& displaySize, bool loadDefaultF io.DisplaySize = ImVec2(displaySize.x, displaySize.y); // clipboard - io.SetClipboardTextFn = setClipboardText; - io.GetClipboardTextFn = getClipboardText; + platform_io.Platform_SetClipboardTextFn = setClipboardText; + platform_io.Platform_GetClipboardTextFn = getClipboardText; // load mouse cursors loadMouseCursor(ImGuiMouseCursor_Arrow, sf::Cursor::Arrow); @@ -1092,11 +1093,11 @@ void updateJoystickAxisState(ImGuiIO& io) { s_currWindowCtx->rTriggerInfo.threshold, 100, false); } -void setClipboardText(void* /*userData*/, const char* text) { +void setClipboardText(ImGuiContext* /*ctx*/, const char* text) { sf::Clipboard::setString(sf::String::fromUtf8(text, text + std::strlen(text))); } -const char* getClipboardText(void* /*userData*/) { +const char* getClipboardText(ImGuiContext* /*ctx*/) { std::basic_string tmp = sf::Clipboard::getString().toUtf8(); s_clipboardText.assign(tmp.begin(), tmp.end()); return s_clipboardText.c_str();