diff --git a/GlosSITarget/HidHide.cpp b/GlosSITarget/HidHide.cpp index 64e10ce..1655e32 100644 --- a/GlosSITarget/HidHide.cpp +++ b/GlosSITarget/HidHide.cpp @@ -197,9 +197,8 @@ void HidHide::UnPatchHook(const std::string& name, HMODULE module) void HidHide::enableOverlayElement() { - Overlay::AddOverlayElem([this](bool window_has_focus) { - ImGui::SetNextWindowPos({650, 100}, ImGuiCond_FirstUseEver); - ImGui::SetNextWindowSizeConstraints({400, 270}, {1000, 1000}); + Overlay::AddOverlayElem([this](bool window_has_focus, ImGuiID dockspace_id) { + ImGui::SetNextWindowDockID(dockspace_id, ImGuiCond_FirstUseEver); if (ImGui::Begin("Hidden Devices")) { if (window_has_focus && (overlay_elem_clock_.getElapsedTime().asSeconds() > OVERLAY_ELEM_REFRESH_INTERVAL_S_)) { // UnPatchValveHooks(); diff --git a/GlosSITarget/InputRedirector.cpp b/GlosSITarget/InputRedirector.cpp index 1fdfc02..498ce05 100644 --- a/GlosSITarget/InputRedirector.cpp +++ b/GlosSITarget/InputRedirector.cpp @@ -53,9 +53,8 @@ void InputRedirector::run() max_controller_count_ = Settings::controller.maxControllers; use_real_vid_pid_ = Settings::devices.realDeviceIds; #ifdef _WIN32 - Overlay::AddOverlayElem([this](bool window_has_focus) { - ImGui::SetNextWindowPos({650, 450}, ImGuiCond_FirstUseEver); - ImGui::SetNextWindowSizeConstraints({400, 270}, {1000, 1000}); + Overlay::AddOverlayElem([this](bool window_has_focus, ImGuiID dockspace_id) { + ImGui::SetNextWindowDockID(dockspace_id, ImGuiCond_FirstUseEver); ImGui::Begin("Controller Emulation"); int countcopy = max_controller_count_; ImGui::Text("Max. controller count"); diff --git a/GlosSITarget/Overlay.cpp b/GlosSITarget/Overlay.cpp index b1cadcd..dd7b6b4 100644 --- a/GlosSITarget/Overlay.cpp +++ b/GlosSITarget/Overlay.cpp @@ -38,12 +38,14 @@ Overlay::Overlay( ImGuiIO& io = ImGui::GetIO(); io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; + io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; + io.Fonts->Clear(); // clear fonts if you loaded some before (even if only default one was loaded) auto fontconf = ImFontConfig{}; fontconf.FontDataOwnedByAtlas = false; io.Fonts->AddFontFromMemoryTTF(Roboto_Regular_ttf.data(), Roboto_Regular_ttf.size(), 24, &fontconf); - ImGui::SFML::UpdateFontTexture(); // important call: updates font texture + ImGui::SFML::UpdateFontTexture(); #ifdef _WIN32 auto config_path = std::filesystem::temp_directory_path() @@ -56,6 +58,7 @@ Overlay::Overlay( if (!std::filesystem::exists(config_path)) std::filesystem::create_directories(config_path); config_path /= "imgui.ini"; + // This assumes that char is utf8 and wchar_t is utf16, which is guaranteed on Windows. config_file_name_ = std::wstring_convert>().to_bytes(config_path.wstring()); io.IniFilename = config_file_name_.data(); @@ -152,14 +155,31 @@ void Overlay::update() { ImGui::SFML::Update(window_, update_clock_.restart()); - showLogs(); + showLogs(0); + if (enabled_ || force_enable_) { + // Create a DockSpace node where any window can be docked + ImGui::SetNextWindowSize({ImGui::GetMainViewport()->Size.x * 0.6f, ImGui::GetMainViewport()->Size.y * 0.7f}, ImGuiCond_FirstUseEver); + ImGui::SetNextWindowPos({ImGui::GetMainViewport()->Size.x * 0.25f, 150 }, ImGuiCond_FirstUseEver); + ImGui::Begin("GlosSI Settings"); + if (Settings::settings_path_ != "") { + if (ImGui::Button("Save shortcut settings", {256, 32})) { + Settings::StoreSettings(); + } + } + ImGuiID dockspace_id = ImGui::GetID("GlosSI-DockSpace"); + ImGui::DockSpace(dockspace_id); + window_.clear(sf::Color(0, 0, 0, 128)); // make window slightly dim screen with overlay - std::ranges::for_each(OVERLAY_ELEMS_, [this](const auto& elem) { - elem.second(window_.hasFocus()); + + + std::ranges::for_each(OVERLAY_ELEMS_, [this, &dockspace_id](const auto& elem) { + elem.second(window_.hasFocus(), dockspace_id); }); + ImGui::End(); + // ImGui::ShowDemoWindow(); if (closeButton()) { @@ -167,7 +187,6 @@ void Overlay::update() } closeOverlayButton(); - saveSettingsButton(); } ImGui::SFML::Render(window_); @@ -188,7 +207,7 @@ void Overlay::AddLog(const spdlog::details::log_msg& msg) LOG_MSGS_.push_back({.time = msg.time, .level = msg.level, .payload = msg.payload.data()}); } -int Overlay::AddOverlayElem(const std::function& elem_fn) +int Overlay::AddOverlayElem(const std::function& elem_fn) { OVERLAY_ELEMS_.insert({overlay_element_id_, elem_fn}); // keep this non confusing, but longer... @@ -202,7 +221,7 @@ void Overlay::RemoveOverlayElem(int id) OVERLAY_ELEMS_.erase(id); } -void Overlay::showLogs() +void Overlay::showLogs(ImGuiID dockspace_id) { std::vector logs; if (!enabled_ && !log_expanded_) { @@ -240,6 +259,9 @@ void Overlay::showLogs() ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoTitleBar); } else { + //ImGui::SetNextWindowDockID(dockspace_id, ImGuiCond_FirstUseEver); + ImGui::SetNextWindowSize({ImGui::GetMainViewport()->Size.x * 0.2f, ImGui::GetMainViewport()->Size.y * 0.7f}, ImGuiCond_FirstUseEver); + ImGui::SetNextWindowPos({ImGui::GetMainViewport()->Size.x * 0.05f, 150}, ImGuiCond_FirstUseEver); log_expanded_ = ImGui::Begin("Log"); } if (log_expanded_) { @@ -314,16 +336,3 @@ bool Overlay::closeButton() const ImGui::PopStyleVar(); return false; } - -void Overlay::saveSettingsButton() const -{ - if (Settings::settings_path_ != "") { - ImGui::SetNextWindowPos({(window_.getSize().x - ImGui::GetWindowWidth()) / 2, (window_.getSize().y - ImGui::GetWindowHeight()) / 2}, ImGuiCond_FirstUseEver); - ImGui::SetNextWindowSizeConstraints({192, 96}, {512, 512}); - ImGui::Begin("Shortcut settings"); - if (ImGui::Button("Save settings", {256, 32})) { - Settings::StoreSettings(); - } - ImGui::End(); - } -} diff --git a/GlosSITarget/Overlay.h b/GlosSITarget/Overlay.h index b971bfa..1f0ebf1 100644 --- a/GlosSITarget/Overlay.h +++ b/GlosSITarget/Overlay.h @@ -38,7 +38,7 @@ class Overlay { static void Shutdown(); static void AddLog(const spdlog::details::log_msg& msg); - static int AddOverlayElem(const std::function& elem_fn); + static int AddOverlayElem(const std::function& elem_fn); static void RemoveOverlayElem(int id); private: @@ -47,10 +47,9 @@ class Overlay { bool enabled_ = true; std::function on_close_; std::function trigger_state_change_; - void showLogs(); + void showLogs(ImGuiID dockspace_id); bool closeOverlayButton() const; [[nodiscard]] bool closeButton() const; - void saveSettingsButton() const; bool force_enable_ = false; bool log_expanded_ = true; sf::Clock time_since_start_clock_; @@ -65,7 +64,7 @@ class Overlay { static constexpr int HIDE_NORMAL_LOGS_AFTER_S = 20; static inline int overlay_element_id_ = 0; - static inline std::map> OVERLAY_ELEMS_; + static inline std::map> OVERLAY_ELEMS_; #ifdef _WIN32 std::string config_file_name_; diff --git a/GlosSITarget/ProcessPriority.h b/GlosSITarget/ProcessPriority.h index 5357a77..f63a429 100644 --- a/GlosSITarget/ProcessPriority.h +++ b/GlosSITarget/ProcessPriority.h @@ -13,9 +13,8 @@ inline void init() { SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); - Overlay::AddOverlayElem([](bool window_has_focus) { - ImGui::SetNextWindowPos({913, 418}, ImGuiCond_FirstUseEver); - ImGui::SetNextWindowSizeConstraints({170, 325}, {1000, 1000}); + Overlay::AddOverlayElem([](bool window_has_focus, ImGuiID dockspace_id) { + ImGui::SetNextWindowDockID(dockspace_id, ImGuiCond_FirstUseEver); ImGui::Begin("Process Priority"); ImGui::Text("Might help with input-lag or bad game performance"); if (ImGui::RadioButton("Realtime", current_priority == REALTIME_PRIORITY_CLASS)) { diff --git a/GlosSITarget/Resource.rc b/GlosSITarget/Resource.rc index 88b5f35..0bece18 100644 --- a/GlosSITarget/Resource.rc +++ b/GlosSITarget/Resource.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,0,8,102000500230 - PRODUCTVERSION 0,0,8,102000500230 + FILEVERSION 0,0,8,1031000051035 + PRODUCTVERSION 0,0,8,1031000051035 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "Peter Repukat - FlatspotSoftware" VALUE "FileDescription", "GlosSI - SteamTarget" - VALUE "FileVersion", "0.0.8.1-2-gc5fc23d" + VALUE "FileVersion", "0.0.8.1-31-gda51d35" VALUE "InternalName", "GlosSITarget" VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware" VALUE "OriginalFilename", "GlosSITarget.exe" VALUE "ProductName", "GlosSI" - VALUE "ProductVersion", "0.0.8.1-2-gc5fc23d" + VALUE "ProductVersion", "0.0.8.1-31-gda51d35" END END BLOCK "VarFileInfo" @@ -184,6 +184,218 @@ IDI_ICON1 ICON "GloSC_Icon.ico" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GlosSITarget/TargetWindow.cpp b/GlosSITarget/TargetWindow.cpp index b411af6..32790c6 100644 --- a/GlosSITarget/TargetWindow.cpp +++ b/GlosSITarget/TargetWindow.cpp @@ -50,9 +50,9 @@ TargetWindow::TargetWindow( { createWindow(Settings::window.windowMode); - Overlay::AddOverlayElem([this](bool window_has_focus) { + Overlay::AddOverlayElem([this](bool window_has_focus, ImGuiID dockspace_id) { + ImGui::SetNextWindowDockID(dockspace_id, ImGuiCond_FirstUseEver); bool windowed_copy = windowed_; - ImGui::SetNextWindowPos({window_.getSize().x - 370.f, 100}, ImGuiCond_FirstUseEver); ImGui::Begin("Window mode"); if (ImGui::Checkbox("Window mode", &windowed_copy)) { toggle_window_mode_after_frame_ = true; diff --git a/GlosSITarget/UWPOverlayEnabler.h b/GlosSITarget/UWPOverlayEnabler.h index 110b329..02e63fa 100644 --- a/GlosSITarget/UWPOverlayEnabler.h +++ b/GlosSITarget/UWPOverlayEnabler.h @@ -60,10 +60,8 @@ inline void EnableUwpOverlay() inline void AddUwpOverlayOvWidget() { - Overlay::AddOverlayElem([](bool window_has_focus) { - ImGui::SetNextWindowPos({1200, 250}, ImGuiCond_FirstUseEver); - ImGui::SetNextWindowSizeConstraints({170, 325}, {1000, 1000}); - ImGui::SetNextWindowCollapsed(true, ImGuiCond_FirstUseEver); + Overlay::AddOverlayElem([](bool window_has_focus, ImGuiID dockspace_id) { + ImGui::SetNextWindowDockID(dockspace_id, ImGuiCond_FirstUseEver); ImGui::Begin("UWP-Overlay"); ImGui::Text("To enable the overlay on top of \"fullscreen\" UWP-Apps,"); ImGui::Text("a .dll has to be injected into explorer.exe"); diff --git a/deps/imgui b/deps/imgui index 9aae45e..9cd9c2e 160000 --- a/deps/imgui +++ b/deps/imgui @@ -1 +1 @@ -Subproject commit 9aae45eb4a05a5a1f96be1ef37eb503a12ceb889 +Subproject commit 9cd9c2eff99877a3f10a7f9c2a3a5b9c15ea36c6