diff --git a/GlosSITarget/GlosSITarget.vcxproj b/GlosSITarget/GlosSITarget.vcxproj index 110915a..3a7eaa4 100644 --- a/GlosSITarget/GlosSITarget.vcxproj +++ b/GlosSITarget/GlosSITarget.vcxproj @@ -159,7 +159,6 @@ - diff --git a/GlosSITarget/GlosSITarget.vcxproj.filters b/GlosSITarget/GlosSITarget.vcxproj.filters index 958a665..6a20838 100644 --- a/GlosSITarget/GlosSITarget.vcxproj.filters +++ b/GlosSITarget/GlosSITarget.vcxproj.filters @@ -72,9 +72,6 @@ Source Files\imgui-sfml - - Source Files\imgui - diff --git a/GlosSITarget/Overlay.cpp b/GlosSITarget/Overlay.cpp index a35c03c..1d92536 100644 --- a/GlosSITarget/Overlay.cpp +++ b/GlosSITarget/Overlay.cpp @@ -1,8 +1,30 @@ +/* +Copyright 2021 Peter Repukat - FlatspotSoftware + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ #include "Overlay.h" -Overlay::Overlay(sf::RenderWindow& window, const std::function& on_close) : window_(window), on_close_(on_close) +#include + +Overlay::Overlay(sf::RenderWindow& window, std::function on_close) : window_(window), on_close_(std::move(on_close)) { ImGui::SFML::Init(window_); + + //Hack: Trick ImGui::SFML into thinking we already have focus (otherwise only notices after focus-lost) + const sf::Event ev(sf::Event::GainedFocus); + ProcessEvent(ev); + ImGuiIO& io = ImGui::GetIO(); io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; @@ -102,7 +124,7 @@ void Overlay::update() std::ranges::for_each(OVERLAY_ELEMS_, [](const auto& fn) { fn(); }); - ImGui::ShowDemoWindow(); + // ImGui::ShowDemoWindow(); if (closeButton()) { return; diff --git a/GlosSITarget/Overlay.h b/GlosSITarget/Overlay.h index 33127ae..88dcc62 100644 --- a/GlosSITarget/Overlay.h +++ b/GlosSITarget/Overlay.h @@ -1,3 +1,18 @@ +/* +Copyright 2021 Peter Repukat - FlatspotSoftware + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ #pragma once #include #include @@ -11,7 +26,7 @@ class Overlay { public: - Overlay(sf::RenderWindow& window, const std::function& on_close); + Overlay(sf::RenderWindow& window, std::function on_close); void setEnabled(bool enabled); bool isEnabled() const; diff --git a/GlosSITarget/TargetWindow.cpp b/GlosSITarget/TargetWindow.cpp index fceaf20..1fb53bc 100644 --- a/GlosSITarget/TargetWindow.cpp +++ b/GlosSITarget/TargetWindow.cpp @@ -44,7 +44,7 @@ TargetWindow::TargetWindow(std::function on_close, std::vector on_close, std::vector