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#pragma endregion
40
41 Options();
42 ~Options() override = default;
43 Options(const Options& other) = default;
44 Options(Options&& other) noexcept = default;
45 auto operator=(const Options& other) -> Options&;
46 auto operator=(Options&& other) noexcept -> Options& = default;
47
48
49#pragma region overridden_functions
50
51 auto clone() const -> std::unique_ptr<GameObject> override
52 {
53 return std::make_unique<Options>(*this);
54 }
55
56 auto onUpdate(float dt) -> void override;
57
58 auto systemShowMenu() -> void override;
59
60 auto endWindow() -> void override
61 {
62 }; // for debug ImGUI
63
64 auto onRender() -> void override;
65 auto onEnterEngine() -> void override;
66 auto load(const Stream& stream) -> void override;
67 auto save(Stream& stream) const -> void override;
68
69#pragma endregion
70
71#pragma region Options_Functions
72
76 auto setMasterVolume(float newVolume) -> void;
77
81 auto setUIVolume(float newVolume) -> void;
82
86 auto setMusicVolume(float newVolume) -> void;
87
91 auto setFullscreen(bool flag) -> void;
92
96 auto getMasterVolume() const -> float;
97
101 auto getUIVolume() const -> float;
102
106 auto getMusicVolume() const -> float;
107
111 auto getFullscreen() const -> bool;
112
113#pragma endregion
114
115private:
116#pragma region member_variables
117
118 float masterVolume = 1.f;
119 float uiVolume = 1.f;
120 float musicVolume = 1.f;
121
122 bool fullScreen = true;
123
125
126#pragma endregion
127
128#pragma region helper_functions
129
130#pragma endregion
131
132#pragma region static_variables
133
134#pragma endregion
135
136
137};
138}
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:46
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:23
Type
Definition System.h:20
@ Options
Definition System.h:39
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:124
float uiVolume
Definition Options.h:119
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Options.h:51
auto onUpdate(float dt) -> void override
called once every frame.
Definition Options.cpp:47
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:126
float musicVolume
Definition Options.h:120
auto load(const Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Options.cpp:60
auto setMusicVolume(float newVolume) -> void
Changes the master volume level through Audio system and then updates the Options system toggle.
Definition Options.cpp:105
auto systemShowMenu() -> void override
Specific systems should override this function to show their specific menu for the system.
Definition Options.cpp:70
~Options() override=default
bool fullScreen
Definition Options.h:122
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Options.cpp:52
auto onEnterEngine() -> void override
hook that is called when a GameObject enters the Engine tree.
Definition Options.cpp:56
Options(const Options &other)=default
auto setFullscreen(bool flag) -> void
Changes if the game is in fullscreen.
Definition Options.cpp:111
float masterVolume
Definition Options.h:118
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Options.h:60
auto setMasterVolume(float newVolume) -> void
Changes the master volume level through Audio system and then updates the Options system toggle.
Definition Options.cpp:93
Options()
Definition Options.cpp:29
auto getMusicVolume() const -> float
Returns the music volume.
Definition Options.cpp:131
auto getMasterVolume() const -> float
Returns the master volume.
Definition Options.cpp:121
auto setUIVolume(float newVolume) -> void
Changes the master volume level through Audio system and then updates the Options system toggle.
Definition Options.cpp:99
auto operator=(const Options &other) -> Options &
Definition Options.cpp:34
auto getFullscreen() const -> bool
Returns if the game is in fullscreen.
Definition Options.cpp:136
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Options.cpp:65
the type of elements in a basic_json container
Definition GameObject.h:32