SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
gamepp.h
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <string>
5#include <string_view>
6
7#include <sourcepp/Math.h>
8
9namespace gamepp {
10
12public:
20 [[nodiscard]] static std::optional<GameInstance> find(std::string_view windowNameOverride = "");
21
26 [[nodiscard]] std::string getWindowTitle() const;
27
32 [[nodiscard]] sourcepp::math::Vec2i getWindowPos() const;
33
38 [[nodiscard]] sourcepp::math::Vec2i getWindowSize() const;
39
45 const GameInstance& command(std::string_view command) const; // NOLINT(*-use-nodiscard)
46
52 const GameInstance& inputBegin(std::string_view input) const; // NOLINT(*-use-nodiscard)
53
59 const GameInstance& inputEnd(std::string_view input) const; // NOLINT(*-use-nodiscard)
60
66 const GameInstance& inputOnce(std::string_view input) const; // NOLINT(*-use-nodiscard)
67
74 const GameInstance& inputHold(std::string_view input, double sec) const; // NOLINT(*-use-nodiscard)
75
81 const GameInstance& wait(double sec) const; // NOLINT(*-use-nodiscard)
82
83protected:
84 GameInstance() = default;
85
86 void* hwnd;
87};
88
89} // namespace gamepp
const GameInstance & inputHold(std::string_view input, double sec) const
Begin and end "pressing" an input in the given timespan, like holding the use key.
Definition: gamepp.cpp:104
const GameInstance & inputBegin(std::string_view input) const
Begin "pressing" an input such as forward or left.
Definition: gamepp.cpp:89
sourcepp::math::Vec2i getWindowSize() const
Get the window size on-screen.
Definition: gamepp.cpp:79
const GameInstance & wait(double sec) const
Sleep on the current thread for the given number of seconds.
Definition: gamepp.cpp:109
const GameInstance & command(std::string_view command) const
Send a command to the engine (ran as if it was entered into the console by the user).
Definition: gamepp.cpp:83
static std::optional< GameInstance > find(std::string_view windowNameOverride="")
Find a running instance of a Source engine game.
Definition: gamepp.cpp:67
const GameInstance & inputOnce(std::string_view input) const
Begin and end "pressing" an input in one tick, like tapping the use key.
Definition: gamepp.cpp:99
const GameInstance & inputEnd(std::string_view input) const
End "pressing" an input such as forward or left.
Definition: gamepp.cpp:94
std::string getWindowTitle() const
Get the human-readable window title.
Definition: gamepp.cpp:71
sourcepp::math::Vec2i getWindowPos() const
Get the window position on-screen.
Definition: gamepp.cpp:75
Definition: gamepp.h:9