Add "Return to Game" button in overlay

experimental/UWP_Inject 0.0.4.0
Peter Repukat 2 years ago
parent 8d152771b7
commit b838ecff6d

@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,3,1011000000300
PRODUCTVERSION 0,0,3,1011000000300
FILEVERSION 0,0,3,1012008015277
PRODUCTVERSION 0,0,3,1012008015277
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Peter Repukat - FlatspotSoftware"
VALUE "FileDescription", "GlosSI - Config"
VALUE "FileVersion", "0.0.3.1-11-gbbbf3fc"
VALUE "FileVersion", "0.0.3.1-12-g8d15277"
VALUE "InternalName", "GlosSIConfig"
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSIConfig.exe"
VALUE "ProductName", "GlosSi"
VALUE "ProductVersion", "0.0.3.1-11-gbbbf3fc"
VALUE "ProductVersion", "0.0.3.1-12-g8d15277"
END
END
BLOCK "VarFileInfo"
@ -845,6 +845,10 @@ END

@ -23,9 +23,11 @@ limitations under the License.
Overlay::Overlay(
sf::RenderWindow& window,
std::function<void()> on_close,
std::function<void()> trigger_state_change,
bool force_enable)
: window_(window),
on_close_(std::move(on_close)),
trigger_state_change_(std::move(trigger_state_change)),
force_enable_(force_enable)
{
ImGui::SFML::Init(window_);
@ -160,6 +162,8 @@ void Overlay::update()
if (closeButton()) {
return;
}
closeOverlayButton();
}
ImGui::SFML::Render(window_);
@ -246,6 +250,29 @@ void Overlay::showLogs()
}
}
bool Overlay::closeOverlayButton() const
{
if (force_enable_) {
return false;
}
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {0, 0});
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.f, 0.f, 0.0f));
ImGui::Begin("##CloseOverlayButton", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
ImGui::SetWindowPos({(window_.getSize().x - ImGui::GetWindowWidth()) / 2, 32});
ImGui::SetWindowSize({256, 32});
if (ImGui::Button("Return to Game", {256, 32})) {
trigger_state_change_();
ImGui::End();
ImGui::PopStyleColor();
ImGui::PopStyleVar();
return true;
}
ImGui::End();
ImGui::PopStyleColor();
ImGui::PopStyleVar();
return false;
}
bool Overlay::closeButton() const
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {0, 0});
@ -256,6 +283,11 @@ bool Overlay::closeButton() const
ImGui::SetWindowSize({56 + 32, 32 + 32});
ImGui::SetWindowPos({window_.getSize().x - ImGui::GetWindowWidth() + 32, -32});
if (ImGui::Button("X##Close", {56, 32})) {
ImGui::End();
ImGui::PopStyleColor();
ImGui::PopStyleColor();
ImGui::PopStyleColor();
ImGui::PopStyleVar();
on_close_();
return true;
}

@ -28,7 +28,7 @@ limitations under the License.
class Overlay {
public:
Overlay(sf::RenderWindow& window, std::function<void()> on_close, bool force_enable = false);
Overlay(sf::RenderWindow& window, std::function<void()> on_close, std::function<void()> trigger_state_change, bool force_enable = false);
void setEnabled(bool enabled);
bool isEnabled() const;
@ -46,7 +46,9 @@ class Overlay {
sf::Clock update_clock_;
bool enabled_ = true;
std::function<void()> on_close_;
std::function<void()> trigger_state_change_;
void showLogs();
bool closeOverlayButton() const;
[[nodiscard]] bool closeButton() const;
bool force_enable_ = false;
bool log_expanded_ = true;

@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,3,1011002805066
PRODUCTVERSION 0,0,3,1011002805066
FILEVERSION 0,0,3,1012008015277
PRODUCTVERSION 0,0,3,1012008015277
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.3.1-11-g28c5c66"
VALUE "FileVersion", "0.0.3.1-12-g8d15277"
VALUE "InternalName", "GlosSITarget"
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSITarget.exe"
VALUE "ProductName", "GlosSI"
VALUE "ProductVersion", "0.0.3.1-11-g28c5c66"
VALUE "ProductVersion", "0.0.3.1-12-g8d15277"
END
END
BLOCK "VarFileInfo"
@ -648,6 +648,50 @@ END

@ -33,6 +33,7 @@ limitations under the License.
SteamTarget::SteamTarget(int argc, char* argv[])
: window_(
[this] { run_ = false; },
[this] { toggleGlossiOverlay(); },
getScreenshotHotkey(),
[this]() {
target_window_handle_ = window_.getSystemHandle();
@ -115,6 +116,11 @@ void SteamTarget::onOverlayChanged(bool overlay_open)
if (overlay_open) {
focusWindow(target_window_handle_);
window_.setClickThrough(!overlay_open);
} else {
if (!(overlay_.expired() ? false : overlay_.lock()->isEnabled())) {
window_.setClickThrough(!overlay_open);
focusWindow(last_foreground_window_);
}
}
if (!overlay_trigger_flag_) {
overlay_trigger_flag_ = true;
@ -122,22 +128,26 @@ void SteamTarget::onOverlayChanged(bool overlay_open)
}
else {
if (overlay_trigger_clock_.getElapsedTime().asSeconds() <= overlay_trigger_max_seconds_) {
const auto ov_opened = overlay_.expired() ? false : overlay_.lock()->toggle();
window_.setClickThrough(!ov_opened);
if (ov_opened) {
spdlog::info("Opened GlosSI-overlay");
focusWindow(target_window_handle_);
}
else {
focusWindow(last_foreground_window_);
spdlog::info("Closed GlosSI-overlay");
}
toggleGlossiOverlay();
}
overlay_trigger_flag_ = false;
}
if (!(overlay_.expired() ? false : overlay_.lock()->isEnabled())) {
window_.setClickThrough(!overlay_open);
}
void SteamTarget::toggleGlossiOverlay()
{
if (overlay_.expired()) {
return;
}
const auto ov_opened = overlay_.lock()->toggle();
window_.setClickThrough(!ov_opened);
if (ov_opened) {
spdlog::info("Opened GlosSI-overlay");
focusWindow(target_window_handle_);
}
else {
focusWindow(last_foreground_window_);
spdlog::info("Closed GlosSI-overlay");
}
}

@ -37,6 +37,7 @@ class SteamTarget {
private:
void onOverlayChanged(bool overlay_open);
void toggleGlossiOverlay();
void focusWindow(WindowHandle hndl);
std::filesystem::path getSteamPath() const;
std::wstring getSteamUserId() const;

@ -38,9 +38,11 @@ limitations under the License.
TargetWindow::TargetWindow(
std::function<void()> on_close,
std::function<void()> toggle_overlay_state,
std::vector<std::string> screenshot_hotkey,
std::function<void()> on_window_changed)
: on_close_(std::move(on_close)),
toggle_overlay_state_(std::move(toggle_overlay_state)),
screenshot_keys_(std::move(screenshot_hotkey)),
on_window_changed_(std::move(on_window_changed))
{
@ -289,7 +291,7 @@ void TargetWindow::createWindow(bool window_mode)
spdlog::debug("Limiting overlay to FPS to {}", dev_mode.dmDisplayFrequency);
}
overlay_ = std::make_shared<Overlay>(window_, [this]() { close(); }, windowed_);
overlay_ = std::make_shared<Overlay>(window_, [this]() { close(); }, toggle_overlay_state_, windowed_);
ImGuiIO& io = ImGui::GetIO();
io.FontGlobalScale = dpi / 96.f;

@ -32,6 +32,7 @@ class TargetWindow {
public:
explicit TargetWindow(
std::function<void()> on_close = []() {},
std::function<void()> toggle_overlay_state = []() {},
std::vector<std::string> screenshot_hotkey = {"KEY_F12"},
std::function<void()> on_window_changed = []() {}
);
@ -64,6 +65,7 @@ class TargetWindow {
private:
const std::function<void()> on_close_;
const std::function<void()> toggle_overlay_state_;
sf::RenderWindow window_;
std::vector<std::string> screenshot_keys_;
const std::function<void()> on_window_changed_;

Loading…
Cancel
Save