Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
board_locations.hpp
Go to the documentation of this file.
1
11
12#ifndef ZOAPPBOARDLOCATIONS_H
13#define ZOAPPBOARDLOCATIONS_H
14
15#include <toymaker/engine/sim_system.hpp>
16#include <toymaker/builtins/interface_pointer_callback.hpp>
17
18
24class BoardLocations: public ToyMaker::SimObjectAspect<BoardLocations>, public ToyMaker::ILeftClickable, public ToyMaker::IHoverable {
25public:
26
32 inline static std::string getSimObjectAspectTypeName() { return "BoardLocations"; }
33
49 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
50
56 std::shared_ptr<BaseSimObjectAspect> clone() const override;
57
62 ToyMaker::Signal<glm::u8vec2> mSigBoardClicked { *this, "BoardClicked" };
63
69 ToyMaker::Signal<glm::u8vec2> mSigBoardHovered { *this, "BoardHovered" };
70
77 glm::uvec2 boardPointToGridIndices (glm::vec2 point) const;
78
85 glm::vec4 gridIndicesToBoardPoint(glm::u8vec2 gridIndices) const;
86
87private:
95 bool onPointerLeftClick(glm::vec4 clickLocation) override;
96
101 inline bool onPointerEnter(glm::vec4 hoverLocation) override {
102 return false;
103 }
104
113 bool onPointerHover(glm::vec4 hoverLocation) override;
114
121 bool onPointerLeave() override;
122
130 inline bool onPointerLeftRelease(glm::vec4 clickLocation) override { (void)clickLocation;/*prevent unused parameter warnings*/ return false; }
131
136 BoardLocations(): SimObjectAspect<BoardLocations>{0} {}
137
142 std::array<uint8_t, 3> mRowLengths {4, 12, 4};
143};
144
145#endif
static std::string getSimObjectAspectTypeName()
Gets the aspect type string associated with this class.
Definition board_locations.hpp:32
bool onPointerLeave() override
Responds to pointer leave events by reporting them to subscribed event observers.
Definition board_locations.cpp:35
std::shared_ptr< BaseSimObjectAspect > clone() const override
Uses this aspect's data to construct a new aspect.
Definition board_locations.cpp:44
bool onPointerLeftRelease(glm::vec4 clickLocation) override
Responds to a full left click by emitting mSigBoardClicked with the clicked location's equivalent gam...
Definition board_locations.hpp:130
ToyMaker::Signal< glm::u8vec2 > mSigBoardHovered
The event emitted signalling to the 3D viewport controller that a location on the board was hovered o...
Definition board_locations.hpp:69
ToyMaker::Signal< glm::u8vec2 > mSigBoardClicked
The event emitted signalling to the 3D viewport controller that a location on the board was clicked.
Definition board_locations.hpp:62
static std::shared_ptr< BaseSimObjectAspect > create(const nlohmann::json &jsonAspectProperties)
Constructs this aspect from its JSON description.
Definition board_locations.cpp:39
bool onPointerLeftClick(glm::vec4 clickLocation) override
Responds to left click events by logging them to the console, translating the location of the click t...
Definition board_locations.cpp:8
glm::uvec2 boardPointToGridIndices(glm::vec2 point) const
Given the 2D coordinates of a point relative to the top surface of the board, returns the equivalent ...
Definition board_locations.cpp:48
BoardLocations()
Constructs a new Board Locations object.
Definition board_locations.hpp:136
std::array< uint8_t, 3 > mRowLengths
The lengths of the 3 rows of the game board representing the number of valid houses on it.
Definition board_locations.hpp:142
bool onPointerEnter(glm::vec4 hoverLocation) override
Unused pointer hover callback.
Definition board_locations.hpp:101
bool onPointerHover(glm::vec4 hoverLocation) override
Responds to pointer enter events by reporting them to subscribed event observers.
Definition board_locations.cpp:21
glm::vec4 gridIndicesToBoardPoint(glm::u8vec2 gridIndices) const
Translates game board data model grid coordinates to their real world 3D coordinates equivalent.
Definition board_locations.cpp:63