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
ur_scene_view.hpp
Go to the documentation of this file.
1
11
12#ifndef ZOAPPURSCENEVIEW_H
13#define ZOAPPURSCENEVIEW_H
14
15#include <toymaker/engine/sim_system.hpp>
16#include <toymaker/engine/signals.hpp>
17#include <toymaker/engine/text_render.hpp>
18
19#include "board_locations.hpp"
21
23
24bool operator<(const UrPieceAnimationKey& one, const UrPieceAnimationKey& two);
25
35class UrSceneView: public ToyMaker::SimObjectAspect<UrSceneView> {
36public:
37 UrSceneView(): ToyMaker::SimObjectAspect<UrSceneView>{0} {}
38
39 inline static std::string getSimObjectAspectTypeName() { return "UrSceneView"; }
40 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
41 std::shared_ptr<BaseSimObjectAspect> clone() const override;
42
43 const GameOfUrModel& getModel() const;
44 const BoardLocations& getBoard() const;
45
46private:
47 enum class Mode {
48 GENERAL,
49 LAUNCH_POSITION_SELECTION,
50 TRANSITION,
51 };
52
53 std::map<PieceIdentity, std::string> mPieceModelMap {};
54 std::map<PieceIdentity, std::shared_ptr<ToyMaker::SceneNode>> mPieceNodeMap {};
55 std::weak_ptr<ToyMaker::SimObject> mGameOfUrController {};
56 std::weak_ptr<ToyMaker::SimObject> mGameOfUrBoard {};
57 std::priority_queue<UrPieceAnimationKey> mAnimationKeys {};
58 uint32_t mAnimationTimeMillis {};
59
60 std::string mControllerPath {};
61 Mode mMode { Mode::GENERAL };
62 PlayerID mControlledBy {};
63
64 void onControllerReady();
65
66 void onBoardClicked(glm::u8vec2 boardLocation);
67 void onLaunchPieceInitiated(PieceTypeID piece);
68 void onLaunchPieceCanceled();
69 void onMoveMade(const MoveResultData& moveResultData);
70
71 void onViewUpdateStarted();
72 void onControlInterface(PlayerID player);
73
74 void onActivated() override;
75 void variableUpdate(uint32_t variableStepMillis) override;
76
77public:
78 ToyMaker::SignalObserver<glm::u8vec2> mObserveBoardClicked {
79 *this, "BoardClickedObserved",
80 [this](glm::u8vec2 boardLocation) { this->onBoardClicked(boardLocation); }
81 };
82 ToyMaker::SignalObserver<PieceTypeID> mObserveLaunchPieceInitiated {
83 *this, "LaunchPieceInitiatedObserved",
84 [this](PieceTypeID pieceType) { this->onLaunchPieceInitiated(pieceType); }
85 };
86 ToyMaker::SignalObserver<> mObserveLaunchPieceCancelled {
87 *this, "LaunchPieceCanceledObserved",
88 [this]() { this->onLaunchPieceCanceled(); }
89 };
90 ToyMaker::SignalObserver<MoveResultData> mObserveMoveMade {
91 *this, "MoveMadeObserved",
92 [this](const MoveResultData& moveResultData) { this->onMoveMade(moveResultData); }
93 };
94 ToyMaker::SignalObserver<PlayerID> mObserveControlInterface {
95 *this, "ControlInterfaceObserved",
96 [this](PlayerID playerID) { this->onControlInterface(playerID); }
97 };
98
99 ToyMaker::Signal<PieceTypeID, glm::u8vec2> mSigLaunchPieceAttempted {
100 *this, "LaunchPieceAttempted"
101 };
102 ToyMaker::Signal<PieceIdentity> mSigMovePieceAttempted {
103 *this, "MovePieceAttempted"
104 };
105
106 ToyMaker::SignalObserver<> mObserveControllerReady {
107 *this, "ControllerReadyObserved",
108 [this]() {this->onControllerReady();}
109 };
110 ToyMaker::Signal<std::string> mSigViewSubscribed {*this, "ViewSubscribed"};
111
112 ToyMaker::SignalObserver<> mObserveViewUpdateStarted {
113 *this, "ViewUpdateStartedObserved",
114 [this](){ this->onViewUpdateStarted(); }
115 };
116 ToyMaker::Signal<std::string> mSigViewUpdateCompleted {
117 *this, "ViewUpdateCompleted"
118 };
119};
120
123 uint32_t mTime;
124 PieceIdentity mPieceIdentity;
125 ToyMaker::Placement mPlacement;
126 bool mRemove { false };
127};
128
129#endif
Contains the class responsible for mapping locations on the 3D game board model to their equivalent c...
The aspect responsible for mapping points on the 3D game board to their equivalent coordinates on the...
Definition board_locations.hpp:26
The data model representing one instance of Game of Ur.
Definition model.hpp:337
PieceTypeID
Enum listing the different types of pieces present in the game.
Definition piece_type_id.hpp:22
PlayerID
The two players playing the game, as known to GameOfUrModel.
Definition model.hpp:40
The class containing the interface to the data model for the whole game (Game of Ur).
Data returned by the GameOfUrModel when making a move, or querying possible moves.
Definition model.hpp:278
Data uniquely identifying a piece used in the game.
Definition piece.hpp:29
Definition ur_scene_view.hpp:122