Add .clang-format

pull/130/head
Peter Repukat 3 years ago
parent d6fb4d84bc
commit 98316efea4

@ -0,0 +1,6 @@
UseTab: false
IndentWidth: 4
BreakBeforeBraces: "Stroustrup"
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 0

@ -168,6 +168,7 @@
<None Include="..\deps\SFML\out\build\x64-Debug\lib\sfml-window-d-2.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</DeploymentContent>
</None>
<None Include=".clang-format" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

@ -37,5 +37,6 @@
<None Include="..\deps\SFML\out\build\x64-Debug\lib\sfml-system-d-2.dll" />
<None Include="..\deps\SFML\out\build\x64-Debug\lib\sfml-window-d-2.dll" />
<None Include="..\deps\SFML\out\build\x64-Debug\lib\sfml-graphics-d-2.dll" />
<None Include=".clang-format" />
</ItemGroup>
</Project>

@ -1,12 +1,28 @@
/*
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 "SteamTarget.h"
#include <iostream>
SteamTarget::SteamTarget(int argc, char* argv[]) : window_([this] { run_ = false; }) {
SteamTarget::SteamTarget(int argc, char *argv[]) : window_([this] { run_ = false; })
{
}
int SteamTarget::run() {
int SteamTarget::run()
{
run_ = true;
window_.setFpsLimit(90);
while (run_) {

@ -1,15 +1,28 @@
/*
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 "TargetWindow.h"
class SteamTarget
{
public:
explicit SteamTarget(int argc, char* argv[]);
class SteamTarget {
public:
explicit SteamTarget(int argc, char *argv[]);
int run();
private:
private:
bool run_ = false;
TargetWindow window_;
};

@ -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.
*/
#include "TargetWindow.h"
#include <utility>
@ -9,56 +24,59 @@
#include <dwmapi.h>
#endif
TargetWindow::TargetWindow(std::function<void()> on_close) : on_close_(std::move(on_close))
{
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();
MARGINS margins;
margins.cxLeftWidth = -1;
DwmExtendFrameIntoClientArea(hwnd, &margins);
// window clickthough.
SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOPMOST);
// always on top
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
#ifdef _WIN32
HWND hwnd = window_.getSystemHandle();
MARGINS margins;
margins.cxLeftWidth = -1;
DwmExtendFrameIntoClientArea(hwnd, &margins);
// always on top
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
#endif
setClickThrough(true);
}
void TargetWindow::setFpsLimit(unsigned int fps_limit)
{
window_.setFramerateLimit(fps_limit);
window_.setFramerateLimit(fps_limit);
}
void TargetWindow::setClickThrough(bool click_through)
{
}
#ifdef _WIN32
HWND hwnd = window_.getSystemHandle();
if (click_through) {
SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOPMOST);
}
else {
SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_LAYERED);
}
#endif
}
void TargetWindow::update()
{
sf::Event event{};
while (window_.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window_.close();
on_close_();
}
}
window_.clear(sf::Color::Transparent);
//window_.clear(sf::Color(255,0,0,1));
window_.display();
sf::Event event{};
while (window_.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window_.close();
on_close_();
}
}
window_.clear(sf::Color::Transparent);
//window_.clear(sf::Color(255,0,0,1));
window_.display();
}
void TargetWindow::close()
{
window_.close();
on_close_();
window_.close();
on_close_();
}

@ -1,20 +1,33 @@
/*
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 <functional>
#include <SFML/Graphics/RenderWindow.hpp>
class TargetWindow
{
public:
explicit TargetWindow(std::function<void()> on_close = [](){});
class TargetWindow {
public:
explicit TargetWindow(std::function<void()> on_close = []() {});
void setFpsLimit(unsigned int fps_limit);
void setClickThrough(bool click_through);
void update();
void close();
private:
private:
const std::function<void()> on_close_;
sf::RenderWindow window_;
};

@ -32,7 +32,8 @@ limitations under the License.
// return SteamTarget::exec();
//}
int main(int argc, char* argv[]) {
SteamTarget target(argc, argv);
return target.run();
int main(int argc, char *argv[])
{
SteamTarget target(argc, argv);
return target.run();
}
Loading…
Cancel
Save