Add WIP GlosSI Overlay

pull/130/head
Peter Repukat 3 years ago
parent 86cafae684
commit 9ccc46088a

@ -80,14 +80,14 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<ExternalIncludePath>..\deps\SFML\include;..\deps\WinReg;..\deps\spdlog\include;..\deps\ValveFileVDF;..\deps\subhook;..\deps\ViGEmClient\include;$(ExternalIncludePath)</ExternalIncludePath>
<ExternalIncludePath>..\deps\SFML\include;..\deps\WinReg;..\deps\spdlog\include;..\deps\ValveFileVDF;..\deps\subhook;..\deps\ViGEmClient\include;..\deps\imgui;..\deps\imgui-sfml;$(ExternalIncludePath)</ExternalIncludePath>
<LibraryPath>..\deps\SFML\out\build\x64-Debug\lib;..\deps\ViGEmClient\lib\debug\x64;$(LibraryPath)</LibraryPath>
<CopyLocalProjectReference>false</CopyLocalProjectReference>
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<ExternalIncludePath>..\deps\SFML\include;..\deps\WinReg;..\deps\spdlog\include;..\deps\ValveFileVDF;..\deps\subhook;..\deps\ViGEmClient\include;$(ExternalIncludePath)</ExternalIncludePath>
<ExternalIncludePath>..\deps\SFML\include;..\deps\WinReg;..\deps\spdlog\include;..\deps\ValveFileVDF;..\deps\subhook;..\deps\ViGEmClient\include;..\deps\imgui;..\deps\imgui-sfml;$(ExternalIncludePath)</ExternalIncludePath>
<LibraryPath>..\deps\SFML\out\build\x64-Release\lib;..\deps\ViGEmClient\lib\release\x64;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -129,7 +129,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>hid.lib;Cfgmgr32.lib;sfml-window-d.lib;sfml-system-d.lib;sfml-graphics-d.lib;dwmapi.lib;xinput9_1_0.lib;setupapi.lib;ViGEmClient.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>hid.lib;Cfgmgr32.lib;opengl32.lib;sfml-window-d.lib;sfml-system-d.lib;sfml-graphics-d.lib;dwmapi.lib;xinput9_1_0.lib;setupapi.lib;ViGEmClient.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -147,22 +147,33 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>hid.lib;Cfgmgr32.lib;xinput9_1_0.lib;setupapi.lib;ViGEmClient.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>hid.lib;Cfgmgr32.lib;opengl32.lib;xinput9_1_0.lib;setupapi.lib;ViGEmClient.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\deps\imgui-sfml\imgui-SFML.cpp" />
<ClCompile Include="..\deps\imgui\imgui.cpp" />
<ClCompile Include="..\deps\imgui\imgui_demo.cpp" />
<ClCompile Include="..\deps\imgui\imgui_draw.cpp" />
<ClCompile Include="..\deps\imgui\imgui_tables.cpp" />
<ClCompile Include="..\deps\imgui\imgui_widgets.cpp" />
<ClCompile Include="..\deps\subhook\subhook.c" />
<ClCompile Include="HidHide.cpp" />
<ClCompile Include="InputRedirector.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="Overlay.cpp" />
<ClCompile Include="SteamOverlayDetector.cpp" />
<ClCompile Include="SteamTarget.cpp" />
<ClCompile Include="TargetWindow.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\deps\imgui-sfml\imgui-SFML.h" />
<ClInclude Include="..\deps\imgui\imgui.h" />
<ClInclude Include="..\deps\subhook\subhook.h" />
<ClInclude Include="HidHide.h" />
<ClInclude Include="imconfig.h" />
<ClInclude Include="InputRedirector.h" />
<ClInclude Include="Overlay.h" />
<ClInclude Include="SteamOverlayDetector.h" />
<ClInclude Include="SteamTarget.h" />
<ClInclude Include="steam_sf_keymap.h" />

@ -13,6 +13,24 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Source Files\imgui">
<UniqueIdentifier>{2c3e6fba-dedb-4076-b773-ef773c7773fd}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\imgui">
<UniqueIdentifier>{c54f210b-d322-4887-8bc4-403e6235e7cd}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\subhook">
<UniqueIdentifier>{5923a6d8-ec50-409b-a004-5566024d25d6}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\subhook">
<UniqueIdentifier>{2b9ce4e5-3909-4902-bac0-b68210377d54}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\imgui-sfml">
<UniqueIdentifier>{70a0a051-1ecd-4e98-9da4-7ecc5fefb467}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\imgui-sfml">
<UniqueIdentifier>{5e050d12-af62-455e-afb1-d8a253f06ab8}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
@ -27,15 +45,36 @@
<ClCompile Include="SteamOverlayDetector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\deps\subhook\subhook.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="InputRedirector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HidHide.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Overlay.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\deps\imgui\imgui_widgets.cpp">
<Filter>Source Files\imgui</Filter>
</ClCompile>
<ClCompile Include="..\deps\imgui\imgui.cpp">
<Filter>Source Files\imgui</Filter>
</ClCompile>
<ClCompile Include="..\deps\imgui\imgui_draw.cpp">
<Filter>Source Files\imgui</Filter>
</ClCompile>
<ClCompile Include="..\deps\imgui\imgui_tables.cpp">
<Filter>Source Files\imgui</Filter>
</ClCompile>
<ClCompile Include="..\deps\subhook\subhook.c">
<Filter>Source Files\subhook</Filter>
</ClCompile>
<ClCompile Include="..\deps\imgui-sfml\imgui-SFML.cpp">
<Filter>Source Files\imgui-sfml</Filter>
</ClCompile>
<ClCompile Include="..\deps\imgui\imgui_demo.cpp">
<Filter>Source Files\imgui</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="SteamTarget.h">
@ -50,15 +89,27 @@
<ClInclude Include="steam_sf_keymap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\deps\subhook\subhook.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="InputRedirector.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HidHide.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Overlay.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="imconfig.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\deps\imgui\imgui.h">
<Filter>Header Files\imgui</Filter>
</ClInclude>
<ClInclude Include="..\deps\subhook\subhook.h">
<Filter>Header Files\subhook</Filter>
</ClInclude>
<ClInclude Include="..\deps\imgui-sfml\imgui-SFML.h">
<Filter>Header Files\imgui-sfml</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\deps\SFML\out\build\x64-Debug\lib\sfml-system-d-2.dll" />

@ -0,0 +1,142 @@
#include "Overlay.h"
#define IMGUI_USER_CONFIG "imconfig.h"
#include "imgui.h"
#include "imgui-SFML.h"
Overlay::Overlay(sf::RenderWindow& window, std::function<void()> on_close) : window_(window), on_close_(on_close)
{
ImGui::SFML::Init(window_);
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
window.resetGLStates();
auto& style = ImGui::GetStyle();
style.WindowBorderSize = 0;
style.WindowRounding = 12;
style.ScrollbarRounding = 12;
style.PopupRounding = 12;
style.ChildRounding = 5;
style.ScrollbarRounding = 12;
style.GrabRounding = 5;
ImVec4* colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_Text] = ImVec4(0.95f, 0.96f, 0.98f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.36f, 0.42f, 0.47f, 1.00f);
colors[ImGuiCol_WindowBg] = ImVec4(0.10f, 0.13f, 0.14f, 0.95f);
colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f);
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
colors[ImGuiCol_Border] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f);
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_FrameBg] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.12f, 0.20f, 0.28f, 1.00f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.09f, 0.12f, 0.14f, 1.00f);
colors[ImGuiCol_TitleBg] = ImVec4(0.18f, 0.21f, 0.24f, 0.94f);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.26f, 0.29f, 0.34f, 0.93f);
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
colors[ImGuiCol_MenuBarBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f);
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.39f);
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.18f, 0.22f, 0.25f, 1.00f);
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.09f, 0.21f, 0.31f, 1.00f);
colors[ImGuiCol_CheckMark] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f);
colors[ImGuiCol_SliderGrab] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f);
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.37f, 0.61f, 1.00f, 1.00f);
colors[ImGuiCol_Button] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
colors[ImGuiCol_ButtonHovered] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f);
colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
colors[ImGuiCol_Header] = ImVec4(0.15f, 0.20f, 0.25f, 0.95f);
colors[ImGuiCol_HeaderHovered] = ImVec4(0.29f, 0.54f, 0.83f, 0.96f);
colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_Separator] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f);
colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f);
colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f);
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
colors[ImGuiCol_Tab] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
colors[ImGuiCol_TabHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
colors[ImGuiCol_TabUnfocused] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.20f, 1.00f);
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.35f, 1.00f);
colors[ImGuiCol_TableBorderLight] = ImVec4(0.23f, 0.23f, 0.25f, 1.00f);
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f);
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
}
void Overlay::setEnabled(bool enabled)
{
enabled_ = enabled;
}
bool Overlay::toggle()
{
enabled_ = !enabled_;
return enabled_;
}
void Overlay::update()
{
ImGui::SFML::Update(window_, update_clock_.restart());
bool open = true;
if (enabled_) {
window_.clear(sf::Color(0, 0, 0, 64)); // make window slightly dim screen with overlay
ImGui::ShowDemoWindow(&open);
if (closeButton()) {
return;
}
}
ImGui::SFML::Render(window_);
}
void Overlay::ProcessEvent(sf::Event evnt)
{
ImGui::SFML::ProcessEvent(evnt);
}
void Overlay::Shutdown()
{
ImGui::SFML::Shutdown();
}
void Overlay::ShowNotification(std::string noti_text)
{}
bool Overlay::closeButton() const
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {0, 0});
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.f, 0.f, 0.0f));
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.6f, 0.f, 0.f, 0.9f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered,ImVec4(1.f, 0.16f, 0.16f, 1.00f));
ImGui::Begin("##CloseButton", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
ImGui::SetWindowSize({56 + 24, 32 + 24});
ImGui::SetWindowPos({window_.getSize().x - ImGui::GetWindowWidth() + 24, -24});
if (ImGui::Button("X##Close", {56, 48})) {
on_close_();
return true;
}
ImGui::End();
ImGui::PopStyleColor();
ImGui::PopStyleColor();
ImGui::PopStyleColor();
ImGui::PopStyleVar();
return false;
}

@ -0,0 +1,23 @@
#pragma once
#include <functional>
#include <string>
#include <SFML/Graphics.hpp>
class Overlay {
public:
Overlay(sf::RenderWindow& window, std::function<void()> on_close);
void setEnabled(bool enabled);
bool toggle();
void update();
static void ProcessEvent(sf::Event evnt);
static void Shutdown();
static void ShowNotification(std::string noti_text);
private:
sf::RenderWindow& window_;
sf::Clock update_clock_;
bool enabled_ = true;
std::function<void()> on_close_;
bool closeButton() const;
};

@ -27,28 +27,46 @@ limitations under the License.
SteamTarget::SteamTarget(int argc, char* argv[])
: window_([this] { run_ = false; }, getScreenshotHotkey()),
detector_([this](bool overlay_open) { onOverlayChanged(overlay_open); })
detector_([this](bool overlay_open) { onOverlayChanged(overlay_open); }),
overlay_(window_.getOverlay())
{
target_window_handle_ = window_.getSystemHandle();
}
int SteamTarget::run()
{
// TODO: Hide GlosSI overlay not based on time, but on game launch.
sf::Clock mock_clock;
bool mock_clock_flag = SteamOverlayDetector::IsSteamInjected();
if (!mock_clock_flag) {
spdlog::warn("Steam Overlay not detected. Keeping GlosSI Overlay!\n\
Application will not function!");
}
run_ = true;
#ifdef _WIN32
hidhide_.hideDevices(steam_path_);
input_redirector_.run();
#endif
keepControllerConfig(true);
while (run_) {
if (mock_clock_flag && mock_clock.getElapsedTime().asSeconds() > 5) {
window_.setClickThrough(true);
overlay_.setEnabled(false);
mock_clock_flag = false;
}
detector_.update();
window_.update();
overlayHotkeyWorkaround();
}
#ifdef _WIN32
input_redirector_.stop();
hidhide_.disableHidHide();
#endif
return 1;
}
@ -59,6 +77,18 @@ void SteamTarget::onOverlayChanged(bool overlay_open)
focusWindow(target_window_handle_);
}
else {
if (!overlay_trigger_flag_) {
overlay_trigger_flag_ = true;
overlay_trigger_clock_.restart();
}
else {
if (overlay_trigger_clock_.getElapsedTime().asSeconds() <= overlay_trigger_max_seconds_) {
window_.setClickThrough(!overlay_.toggle());
}
overlay_trigger_flag_ = false;
}
focusWindow(last_foreground_window_);
}
}

@ -25,6 +25,8 @@ limitations under the License.
#include <subhook.h>
#endif
#include "Overlay.h"
#include <filesystem>
class SteamTarget {
@ -69,10 +71,16 @@ class SteamTarget {
InputRedirector input_redirector_;
#endif
TargetWindow window_;
Overlay& overlay_;
SteamOverlayDetector detector_;
WindowHandle last_foreground_window_ = nullptr;
static inline WindowHandle target_window_handle_ = nullptr;
sf::Clock overlay_trigger_clock_;
uint32_t overlay_trigger_max_seconds_ = 4;
bool overlay_trigger_flag_ = false;
static constexpr std::wstring_view user_data_path_ = L"/userdata/";
static constexpr std::wstring_view config_file_name_ = L"/config/localconfig.vdf";
static constexpr std::string_view overlay_hotkey_name_ = "InGameOverlayShortcutKey ";

@ -28,28 +28,24 @@ limitations under the License.
#include <dwmapi.h>
#endif
static const bool DEV_MODE = false;
TargetWindow::TargetWindow(std::function<void()> on_close, std::vector<std::string> screenshot_hotkey)
: on_close_(std::move(on_close)), screenshot_keys_(std::move(screenshot_hotkey))
: on_close_(std::move(on_close)),
screenshot_keys_(std::move(screenshot_hotkey)),
overlay_(window_, [this]() { close(); })
{
if (DEV_MODE) {
window_.create(sf::VideoMode{1920, 1080}, "GlosSITarget", sf::Style::Default);
}
else {
window_.create(sf::VideoMode::getDesktopMode(), "GlosSITarget", sf::Style::None);
}
window_.create(sf::VideoMode::getDesktopMode(), "GlosSITarget", sf::Style::None);
window_.setActive(true);
#ifdef _WIN32
HWND hwnd = window_.getSystemHandle();
// transparent windows window...
MARGINS margins;
margins.cxLeftWidth = -1;
DwmExtendFrameIntoClientArea(hwnd, &margins);
if (!DEV_MODE) {
// always on top
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
// always on top
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
DEVMODE dev_mode = {};
dev_mode.dmSize = sizeof(DEVMODE);
@ -57,15 +53,12 @@ TargetWindow::TargetWindow(std::function<void()> on_close, std::vector<std::stri
if (EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &dev_mode) == 0) {
setFpsLimit(60);
} else {
setFpsLimit(dev_mode.dmDisplayFrequency);
}
setFpsLimit(dev_mode.dmDisplayFrequency);
#else
setFpsLimit(60);
#endif
if (!DEV_MODE) {
setClickThrough(true);
}
}
void TargetWindow::setFpsLimit(unsigned int fps_limit)
@ -91,19 +84,15 @@ void TargetWindow::update()
{
sf::Event event{};
while (window_.pollEvent(event)) {
Overlay::ProcessEvent(event);
if (event.type == sf::Event::Closed) {
window_.close();
on_close_();
close();
return;
}
}
if (DEV_MODE) {
window_.clear(sf::Color(0, 0, 0, 128));
}
else {
window_.clear(sf::Color::Transparent);
}
window_.clear(sf::Color::Transparent);
overlay_.update();
screenShotWorkaround();
window_.display();
}
@ -111,9 +100,15 @@ void TargetWindow::update()
void TargetWindow::close()
{
window_.close();
Overlay::Shutdown();
on_close_();
}
Overlay& TargetWindow::getOverlay()
{
return overlay_;
}
void TargetWindow::screenShotWorkaround()
{
#ifdef _WIN32

@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
#pragma once
#include "Overlay.h"
#include <functional>
#include <SFML/Graphics/RenderWindow.hpp>
@ -36,6 +38,8 @@ class TargetWindow {
void update();
void close();
Overlay& getOverlay();
/*
* Run once per frame
* - detects steam configured screenshot hotkey
@ -55,4 +59,6 @@ class TargetWindow {
const std::function<void()> on_close_;
sf::RenderWindow window_;
std::vector<std::string> screenshot_keys_;
Overlay overlay_;
};

@ -0,0 +1,30 @@
#pragma once
#include <SFML/Graphics/Color.hpp>
#include <SFML/System/Vector2.hpp>
#include "imgui-SFML_export.h"
#define IM_VEC2_CLASS_EXTRA \
template <typename T> \
ImVec2(const sf::Vector2<T>& v) \
{ \
x = static_cast<float>(v.x); \
y = static_cast<float>(v.y); \
} \
\
template <typename T> \
operator sf::Vector2<T>() const \
{ \
return sf::Vector2<T>(x, y); \
}
#define IM_VEC4_CLASS_EXTRA \
ImVec4(const sf::Color& c) : x(c.r / 255.f), y(c.g / 255.f), z(c.b / 255.f), w(c.a / 255.f) {} \
operator sf::Color() const \
{ \
return sf::Color(static_cast<sf::Uint8>(x * 255.f), static_cast<sf::Uint8>(y * 255.f), \
static_cast<sf::Uint8>(z * 255.f), static_cast<sf::Uint8>(w * 255.f)); \
}
#define ImTextureID unsigned int
Loading…
Cancel
Save