Brunot
Loading...
Searching...
No Matches
Options.h
Go to the documentation of this file.
1
10// ____ __ __ __
11// /\__ _\/\ \ /\ \/\ \
12// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
13// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
14// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
15// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
16// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
17
18#pragma once
19
20#include "AudioSystem.h"
21#include "Framework/Engine.h"
22#include "Framework/System.h"
23
24namespace sys
25{
26class Options : public System
27{
28public:
29#pragma region static_functions
30
34 static auto getEnum() -> Type
35 {
36 return Type::Options;
37 }
38
39
41 static float MAX_OVERRIDE_VOLUME()
42 {
43 constexpr auto value = 0.15f;
44 return value;
45 }
46
49 static float LOW_VOLUME()
50 {
51 constexpr auto value = 0.05f;
52 return value;
53 }
54
55#pragma endregion
56
57 Options();
58 ~Options() override = default;
59 Options(const Options& other) = default;
60 Options(Options&& other) noexcept = default;
61 auto operator=(const Options& other) -> Options&;
62 auto operator=(Options&& other) noexcept -> Options& = default;
63
64
65#pragma region overridden_functions
66
67 auto clone() const -> std::unique_ptr<GameObject> override
68 {
69 return std::make_unique<Options>(*this);
70 }
71
72 auto onUpdate(float dt) -> void override;
73
74 auto systemShowMenu() -> void override;
75
76 auto endWindow() -> void override
77 {
78 }; // for debug ImGUI
79
80 auto onRender() -> void override;
81 auto onEnterEngine() -> void override;
82 auto load(const Stream& stream) -> void override;
83 auto save(Stream& stream) const -> void override;
84
85#pragma endregion
86
87#pragma region Options_Functions
88
92 auto setMasterVolume(float newVolume) -> void;
93
97 auto setUIVolume(float newVolume) -> void;
98
102 auto setMusicVolume(float newVolume) -> void;
103
107 auto setFullscreen(bool flag) -> void;
108
112 auto getMasterVolume() const -> float;
113
117 auto getUIVolume() const -> float;
118
122 auto getMusicVolume() const -> float;
123
127 auto getFullscreen() const -> bool;
128
129#pragma endregion
130
131private:
132#pragma region member_variables
133
134 float masterVolume = 1.f;
135 float uiVolume = 1.f;
136 float musicVolume = 1.f;
137
138 bool fullScreen = true;
139
141
142#pragma endregion
143
144#pragma region helper_functions
145
146#pragma endregion
147
148#pragma region static_variables
149
150#pragma endregion
151
152};
153}
sys::Json Stream
Definition AudioObject.h:20
The class that holds the top node, and manages the main game loop, as well as startup and shutdown.
static auto getSystem() -> system *
A function to get a system.
Definition Engine.h:50
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:24
Type
Definition System.h:20
@ Options
Definition System.h:40
System(const std::string &typeName, Type systemType)
Definition System.cpp:75
Definition AudioSystem.h:26
Options(Options &&other) noexcept=default
AudioSystem * audio
Definition Options.h:140
float uiVolume
Definition Options.h:135
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Options.h:67
auto onUpdate(float dt) -> void override
called once every frame.
Definition Options.cpp:49
auto operator=(Options &&other) noexcept -> Options &=default
static auto getEnum() -> Type
function required by all systems
Definition Options.h:34
auto getUIVolume() const -> float
Returns the UI volume.
Definition Options.cpp:128
float musicVolume
Definition Options.h:136
auto load(const Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Options.cpp:62
auto setMusicVolume(float newVolume) -> void
Changes the master volume level through Audio system and then updates the Options system toggle.
Definition Options.cpp:107
auto systemShowMenu() -> void override
Specific systems should override this function to show their specific menu for the system.
Definition Options.cpp:72
~Options() override=default
bool fullScreen
Definition Options.h:138
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Options.cpp:54
static float MAX_OVERRIDE_VOLUME()
enum-like function to get the max volume of the game (this is the max volume the override channel sho...
Definition Options.h:41
static float LOW_VOLUME()
enum-like function to get the paused volume of the game (this is the volume the override channel shou...
Definition Options.h:49
auto onEnterEngine() -> void override
hook that is called when a GameObject enters the Engine tree.
Definition Options.cpp:58
Options(const Options &other)=default
auto setFullscreen(bool flag) -> void
Changes if the game is in fullscreen.
Definition Options.cpp:113
float masterVolume
Definition Options.h:134
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Options.h:76
auto setMasterVolume(float newVolume) -> void
Changes the master volume level through Audio system and then updates the Options system toggle.
Definition Options.cpp:95
Options()
Definition Options.cpp:31
auto getMusicVolume() const -> float
Returns the music volume.
Definition Options.cpp:133
auto getMasterVolume() const -> float
Returns the master volume.
Definition Options.cpp:123
auto setUIVolume(float newVolume) -> void
Changes the master volume level through Audio system and then updates the Options system toggle.
Definition Options.cpp:101
auto operator=(const Options &other) -> Options &
Definition Options.cpp:36
auto getFullscreen() const -> bool
Returns if the game is in fullscreen.
Definition Options.cpp:138
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Options.cpp:67
the type of elements in a basic_json container
Definition GameObject.h:37