Brunot
Loading...
Searching...
No Matches
Selector.h
Go to the documentation of this file.
1
12// ____ __ __ __
13// /\__ _\/\ \ /\ \/\ \
14// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
15// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
16// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
17// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
18// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
19
20
21#pragma once
22#include "Framework/Component.h"
23
24struct Message;
25class Menu;
26
31class Selector : public Component
32{
33public:
34#pragma region static_functions
35 static auto bindLuaTypes(sol::state& lua) -> void {}
36 static auto getEnum() -> ComponentTypeEnum
37 {
38 return cSelector;
39 }
40
41#pragma endregion
42
43 Selector();
44 // If you have messages, you will need to un-default the copy and move constructor and call linkMessages in them
45 Selector(const Selector&);
46 auto operator=(const Selector&) -> Selector& = default;
47 ~Selector() override = default;
48 Selector(Selector&& other) noexcept;
49 auto operator=(Selector&& other) noexcept -> Selector& = default;
50
51#pragma region overriden_functions
52
53 auto clone() const -> std::unique_ptr<GameObject> override
54 {
55 return std::make_unique<Selector>(*this);
56 }
57
58 auto componentShowMenu() -> void override;
59 auto onUpdate(float dt) -> void override;
60
61 auto onEnterEngine() -> void override;
62 auto endWindow() -> void override
63 {
64 } // for debug ImGUI
65 auto onRender() -> void override;
66 auto load(const Stream& stream) -> void override;
67 auto save(Stream& stream) const -> void override;
68
69 friend auto to_json(json& j, const Selector& s) -> void;
70 friend auto from_json(const json& j, Selector& s) -> void;
71
73 virtual auto isValidID(int id) -> bool;
74
75
76#pragma endregion
77
78#pragma region Selector_functions
79
81 auto select() -> void;
82
84 virtual auto select(int id) -> void;
85
87 auto highlight() -> void;
88
90 auto undoHighlight() -> void;
91
93 auto moveToNewParent(Entity* newParent) const -> void;
94
96 auto moveWithoutHighlight(Entity* newParent) const -> void;
97
99 auto moveUp() -> void;
101 auto moveDown() -> void;
103 auto moveLeft() -> void;
105 auto moveRight() -> void;
106
107#pragma endregion
108
109#pragma region messaging_functions
110
111 virtual auto linkMessages() -> void;
112
113 virtual auto receiveLeftKeyPressed(const Message* message) -> Message;
114 virtual auto receiveRightKeyPressed(const Message* message) -> Message;
115 virtual auto receiveUpKeyPressed(const Message* message) -> Message;
116 virtual auto receiveDownKeyPressed(const Message* message) -> Message;
117
118 virtual auto receiveSelectKeyPressed(const Message* message) -> Message;
119
120#pragma endregion
121
122#pragma region protected_members
123
124protected:
126 Selector(const char* typeName);
127
128#pragma endregion
129
130#pragma region member_variables
131
132private:
133
134#pragma endregion
135
136#pragma region helper_functions
137
138#pragma endregion
139
140
141#pragma region static_variables
142
143#pragma endregion
144
145};
sys::Json Stream
Definition AudioObject.h:20
The base class for components, holding all of their shared All components should inherit from this.
nlohmann::json json
Definition Json.cpp:19
ComponentTypeEnum
This enum lists out every type of component we have.
Definition Component.h:39
Component(ComponentTypeEnum type, const char *typeName)
Definition Component.cpp:72
Definition Entity.h:41
std::string typeName
the typeName of a GameObject.
Definition GameObject.h:562
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:24
A menu that organizes its parents' children (in the node) either horizontally or vertically.
Definition Menu.h:41
An indicator that loops through a parents' nodes children and can "select" them on keypress.
Definition Selector.h:32
friend auto from_json(const json &j, Selector &s) -> void
Definition Selector.cpp:120
virtual auto receiveRightKeyPressed(const Message *message) -> Message
Definition Selector.cpp:271
auto highlight() -> void
Calls the highlight function on the currently hovered button.
Definition Selector.cpp:155
virtual auto linkMessages() -> void
Definition Selector.cpp:224
~Selector() override=default
auto select() -> void
Selects the button that the selector is hovering over.
Definition Selector.cpp:129
auto operator=(Selector &&other) noexcept -> Selector &=default
auto onEnterEngine() -> void override
hook that is called when a GameObject enters the Engine tree.
Definition Selector.cpp:70
auto undoHighlight() -> void
Calls the highlight function on the currently hovered button.
Definition Selector.cpp:163
auto moveWithoutHighlight(Entity *newParent) const -> void
Moves the selector without causing any highlighting.
Definition Selector.cpp:351
static auto bindLuaTypes(sol::state &lua) -> void
Definition Selector.h:35
virtual auto receiveLeftKeyPressed(const Message *message) -> Message
Definition Selector.cpp:255
Selector()
Definition Selector.cpp:42
auto operator=(const Selector &) -> Selector &=default
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Selector.cpp:108
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Selector.cpp:75
virtual auto isValidID(int id) -> bool
Virtual function used by FilteredSelector. Always returns true in Selector.
Definition Selector.cpp:219
static auto getEnum() -> ComponentTypeEnum
Definition Selector.h:36
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Selector.h:62
auto componentShowMenu() -> void override
Definition Selector.cpp:60
auto moveLeft() -> void
Moves the selector left one Entity inside the Menu it's within.
Definition Selector.cpp:190
virtual auto receiveDownKeyPressed(const Message *message) -> Message
Definition Selector.cpp:303
virtual auto receiveUpKeyPressed(const Message *message) -> Message
Definition Selector.cpp:287
auto moveUp() -> void
Moves the selector up one Entity inside the Menu it's within.
Definition Selector.cpp:170
auto moveRight() -> void
Moves the selector right one Entity inside the Menu it's within.
Definition Selector.cpp:200
auto moveDown() -> void
Moves the selector down one Entity inside the Menu it's within.
Definition Selector.cpp:180
friend auto to_json(json &j, const Selector &s) -> void
Definition Selector.cpp:113
auto load(const Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Selector.cpp:103
auto moveToNewParent(Entity *newParent) const -> void
Moves the selector while unhighlighting the old parent and highlighting the new one.
Definition Selector.cpp:330
virtual auto receiveSelectKeyPressed(const Message *message) -> Message
Definition Selector.cpp:319
auto onUpdate(float dt) -> void override
called once every frame.
Definition Selector.cpp:64
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Selector.h:53
Definition Message.h:35