SteamTarget: Use Imgui-Docking branch and overhaul overlay

- might need to delete `%appdata%\GlosSI\imgui.ini`
pull/179/head
Peter Repukat 2 years ago
parent da51d351ed
commit 9d6bbdeecb

@ -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();

@ -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");

@ -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<std::codecvt_utf8<wchar_t>>().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<void(bool window_has_focus)>& elem_fn)
int Overlay::AddOverlayElem(const std::function<void(bool window_has_focus, ImGuiID dockspace_id)>& 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<Log> 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();
}
}

@ -38,7 +38,7 @@ class Overlay {
static void Shutdown();
static void AddLog(const spdlog::details::log_msg& msg);
static int AddOverlayElem(const std::function<void(bool window_has_focus)>& elem_fn);
static int AddOverlayElem(const std::function<void(bool window_has_focus, ImGuiID dockspace_id)>& elem_fn);
static void RemoveOverlayElem(int id);
private:
@ -47,10 +47,9 @@ class Overlay {
bool enabled_ = true;
std::function<void()> on_close_;
std::function<void()> 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<int, std::function<void(bool window_has_focus)>> OVERLAY_ELEMS_;
static inline std::map<int, std::function<void(bool window_has_focus, ImGuiID dockspace_id)>> OVERLAY_ELEMS_;
#ifdef _WIN32
std::string config_file_name_;

@ -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)) {

@ -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"

@ -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;

@ -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");

2
deps/imgui vendored

@ -1 +1 @@
Subproject commit 9aae45eb4a05a5a1f96be1ef37eb503a12ceb889
Subproject commit 9cd9c2eff99877a3f10a7f9c2a3a5b9c15ea36c6
Loading…
Cancel
Save