12#ifndef ZOAPPURUIVIEW_H
13#define ZOAPPURUIVIEW_H
15#include "toymaker/sim_system.hpp"
16#include "toymaker/signals.hpp"
17#include "toymaker/text_render.hpp"
32 inline static std::string getSimObjectAspectTypeName() {
return "UrUIView"; }
33 static std::shared_ptr<BaseSimObjectAspect> create(
const nlohmann::json& jsonAspectProperties);
34 std::shared_ptr<BaseSimObjectAspect>
clone()
const override;
42 SWALLOW=PieceTypeID::SWALLOW,
43 STORMBIRD=PieceTypeID::STORMBIRD,
44 RAVEN=PieceTypeID::RAVEN,
45 ROOSTER=PieceTypeID::ROOSTER,
46 EAGLE=PieceTypeID::EAGLE,
57 std::weak_ptr<ToyMaker::SimObject> mGameOfUrController {};
58 std::string mControllerPath {};
60 Mode mMode { Mode::INTERACT };
61 std::vector<std::reference_wrapper<UIText>> mUpdatedTextElements {};
62 uint32_t mAnimationTimeMillis { 0 };
63 uint32_t mBlinkLengthMillis { 2500 };
64 uint32_t mBlinkPeriodMillis { 400 };
66 static const std::map<std::string, Buttons> kButtonEnumMap;
68 void onControllerReady();
70 void updateText(
const std::string& path,
const std::string& text);
71 void reactivateControls();
73 void onButtonClicked(
const std::string& button);
78 void onViewUpdateStarted();
80 void onControlInterface(
PlayerID playerID);
83 std::shared_ptr<ToyMaker::SimObject> getLaunchButton(
PieceTypeID pieceTypeID,
PlayerID player);
84 std::shared_ptr<ToyMaker::SceneNode> getPlayerPanel(
PlayerID player);
85 std::shared_ptr<ToyMaker::SimObject> getEndTurnButton();
89 return this->onCancel(actionData, actionDefinition);
94 *
this,
"ButtonClickedObserved",
95 [
this](
const std::string& button) { this->onButtonClicked(button); }
99 *
this,
"PhaseUpdatedObserved",
100 [
this](
GamePhaseData phaseData) { this->onPhaseUpdated(phaseData); }
103 *
this,
"ScoreUpdatedObserved",
104 [
this](
GameScoreData scoreData) { this->onScoreUpdated(scoreData); }
107 *
this,
"PlayerUpdatedObserved",
108 [
this](
PlayerData playerData) { this->onPlayerUpdated(playerData); }
111 *
this,
"DiceUpdatedObserved",
112 [
this](
DiceData diceData) { this->onDiceUpdated(diceData); }
115 *
this,
"MoveMadeObserved",
120 *
this,
"ControlInterfaceObserved",
121 [
this](
PlayerID playerID) { this->onControlInterface(playerID); }
130 *
this,
"ControllerReadyObserved",
131 [
this]() {this->onControllerReady();}
136 *
this,
"ViewUpdateStartedObserved",
137 [
this](){ this->onViewUpdateStarted(); }
140 *
this,
"ViewUpdateCompleted"
The class containing the interface to the data model for the whole game (Game of Ur).
The data model representing one instance of Game of Ur.
Definition model.hpp:337
std::weak_ptr< FixedActionBinding > declareFixedActionBinding(const std::string &context, const std::string &action, std::function< bool(const ActionData &, const ActionDefinition &)>)
Binds some method (or any function) present on this object to an action generated by the InputManager...
Definition sim_system.cpp:219
A SignalObserver object, which can subscribe to Signals matching its data signature and receive signa...
Definition signals.hpp:412
A Signal object, designed to emit signals matching some data signature to be received by all the Sign...
Definition signals.hpp:323
An object containing closely related methods and data, and exposing object lifecycle and application ...
Definition sim_system.hpp:956
void variableUpdate(uint32_t timeStep) override
Overriding this allows an aspect to respond to variable updates.
Definition ur_ui_view.cpp:262
void onActivated() override
Callback for when the aspect is activated (after it is attached to an active SimObject,...
Definition ur_ui_view.cpp:36
std::shared_ptr< BaseSimObjectAspect > clone() const override
A method which must be overridden to specify how a new aspect should be constructed as a copy of this...
Definition ur_ui_view.cpp:24
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
Data returned by GameOfUrModel when queried for dice related information.
Definition model.hpp:192
Data returned by GameOfUrModel when queried about the current phase of the game.
Definition model.hpp:112
Data returned by GameOfUrModel when queried for scores.
Definition model.hpp:151
Data returned by the GameOfUrModel when making a move, or querying possible moves.
Definition model.hpp:278
Data returned by GameOfUrModel when queried about a player.
Definition model.hpp:229
The definition of a single action, including whether it represents state or change,...
Definition input_data.hpp:511
A union that may contain any one of SimpleActionData, OneAxisActionData, TwoAxisActionData,...
Definition input_data.hpp:721