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
UrUIView Class Reference

The aspect class for the UI layer of the game scene. More...

#include <ur_ui_view.hpp>

Inheritance diagram for UrUIView:
ToyMaker::SimObjectAspect< UrUIView > ToyMaker::BaseSimObjectAspect ToyMaker::SignalTracker ToyMaker::IActionHandler

Public Member Functions

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 one.
 
void onActivated () override
 Callback for when the aspect is activated (after it is attached to an active SimObject, or if the SimObject it was attached to has just been activated)
 
void variableUpdate (uint32_t timeStep) override
 Overriding this allows an aspect to respond to variable updates.
 
const GameOfUrModelgetModel () const
 
- Public Member Functions inherited from ToyMaker::BaseSimObjectAspect
virtual ~BaseSimObjectAspect ()=default
 Destroys this object.
 
virtual void simulationUpdate (uint32_t simStepMillis)
 Overriding this allows an aspect to respond to simulation updates.
 
bool handleAction (const ActionData &actionData, const ActionDefinition &actionDefinition) override final
 Pipes an action received from the InputManager via our SimObject to all that action's handler methods on this aspect.
 
ViewportNodegetLocalViewport ()
 Returns the closest ancestor viewport to this node, if one exists (which it should, since this shouldn't be called until this aspect is attached to an active SimObject).
 
- Public Member Functions inherited from ToyMaker::SignalTracker
 SignalTracker ()
 Constructs a new SignalTracker object.
 
 SignalTracker (const SignalTracker &other)
 Constructs a new SignalTracker.
 
SignalTrackeroperator= (const SignalTracker &other)
 Copy assignment operator.
 
 SignalTracker (SignalTracker &&other)
 Moves resources from another SignalTracker into this one, invalidating them from the other.
 
SignalTrackeroperator= (SignalTracker &&other)
 Moves resources from another SignalTracker into this one, destroying this tracker's resources in the process.
 
void connect (const std::string &theirSignal, const std::string &ourObserver, SignalTracker &other)
 Method that connects one of this objects SignalObservers to another tracker's Signal.
 

Static Public Member Functions

static std::string getSimObjectAspectTypeName ()
 
static std::shared_ptr< BaseSimObjectAspect > create (const nlohmann::json &jsonAspectProperties)
 

Public Attributes

ToyMaker::SignalObserver< const std::string & > mObserveButtonClicked
 
ToyMaker::SignalObserver< GamePhaseDatamObservePhaseUpdated
 
ToyMaker::SignalObserver< GameScoreDatamObserveScoreUpdated
 
ToyMaker::SignalObserver< PlayerDatamObservePlayerUpdated
 
ToyMaker::SignalObserver< DiceDatamObserveDiceUpdated
 
ToyMaker::SignalObserver< MoveResultDatamObserveMoveMade
 
ToyMaker::SignalObserver< PlayerIDmObserveControlInterface
 
ToyMaker::Signal mSigDiceRollAttempted { *this, "DiceRollAttempted" }
 
ToyMaker::Signal mSigNextTurnAttempted { *this, "NextTurnAttempted" }
 
ToyMaker::Signal< PieceTypeIDmSigLaunchPieceInitiated { *this, "LaunchPieceInitiated" }
 
ToyMaker::Signal mSigLaunchPieceCanceled { *this, "LaunchPieceCanceled" }
 
ToyMaker::SignalObserver mObserveControllerReady
 
ToyMaker::Signal< std::string > mSigViewSubscribed {*this, "ViewSubscribed"}
 
ToyMaker::SignalObserver mObserveViewUpdateStarted
 
ToyMaker::Signal< std::string > mSigViewUpdateCompleted
 

Private Types

enum  Buttons {
  SWALLOW =PieceTypeID::SWALLOW , STORMBIRD =PieceTypeID::STORMBIRD , RAVEN =PieceTypeID::RAVEN , ROOSTER =PieceTypeID::ROOSTER ,
  EAGLE =PieceTypeID::EAGLE , NEXT_TURN , DICE
}
 
enum class  Mode { INTERACT , TRANSITION }
 

Private Member Functions

void onControllerReady ()
 
void updateText (const std::string &path, const std::string &text)
 
void reactivateControls ()
 
void onButtonClicked (const std::string &button)
 
void onPhaseUpdated (GamePhaseData phase)
 
void onScoreUpdated (GameScoreData score)
 
void onPlayerUpdated (PlayerData player)
 
void onDiceUpdated (DiceData dice)
 
void onViewUpdateStarted ()
 
void onMoveMade (MoveResultData moveData)
 
void onControlInterface (PlayerID playerID)
 
bool onCancel (const ToyMaker::ActionData &actionData, const ToyMaker::ActionDefinition &actionDefinition)
 
std::shared_ptr< ToyMaker::SimObjectgetLaunchButton (PieceTypeID pieceTypeID, PlayerID player)
 
std::shared_ptr< ToyMaker::SceneNodegetPlayerPanel (PlayerID player)
 
std::shared_ptr< ToyMaker::SimObjectgetEndTurnButton ()
 

Private Attributes

std::weak_ptr< ToyMaker::SimObjectmGameOfUrController {}
 
std::string mControllerPath {}
 
PlayerID mControlledBy {}
 
Mode mMode { Mode::INTERACT }
 
std::vector< std::reference_wrapper< UIText > > mUpdatedTextElements {}
 
uint32_t mAnimationTimeMillis { 0 }
 
uint32_t mBlinkLengthMillis { 2500 }
 
uint32_t mBlinkPeriodMillis { 400 }
 
std::weak_ptr< ToyMaker::FixedActionBindinghandleCancel
 

Static Private Attributes

static const std::map< std::string, Buttons > kButtonEnumMap
 

Additional Inherited Members

- Protected Member Functions inherited from ToyMaker::SimObjectAspect< UrUIView >
 SimObjectAspect (int explicitlyInitializeMe)
 
- Protected Member Functions inherited from ToyMaker::BaseSimObjectAspect
 BaseSimObjectAspect (const BaseSimObjectAspect &other)=delete
 
 BaseSimObjectAspect (BaseSimObjectAspect &&other)=delete
 
SimObjectgetSimObject ()
 Returns the sim object that this aspect is attached to.
 
template<typename TComponent>
void addComponent (const TComponent &component)
 Adds a component of some type to the underlying entity.
 
template<typename TComponent>
bool hasComponent ()
 Tests whether a component of some specific type is present on the object.
 
template<typename TComponent>
void updateComponent (const TComponent &component)
 Updates the value of a component belonging to this object to a new one.
 
template<typename TComponent>
TComponent getComponent (const float simulationProgress=1.f) const
 Gets the value of a component belonging to this object.
 
template<typename TComponent>
void removeComponent ()
 Removes a component of some type belonging to the underlying SimObject.
 
void addAspect (const nlohmann::json &jsonAspectProperties)
 Adds a new aspect to the underlying SimObject constructed based on its properties in JSON.
 
void addAspect (const BaseSimObjectAspect &aspect)
 Adds a new aspect to the underlying SimObject copied from an already existing aspect.
 
template<typename TSimObjectAspect>
bool hasAspect () const
 Tests whether an aspect of a particular type is attached to the underlying SimObject.
 
bool hasAspect (const std::string &aspectType) const
 Tests whether an aspect of a particular type is attached to the underlying SimObject.
 
template<typename TSimObjectAspect>
TSimObjectAspect & getAspect ()
 Gets an aspect of a particular type belonging to the underlying SimObject.
 
BaseSimObjectAspectgetAspect (const std::string &aspectType)
 Gets (a base class reference to) an aspect of a particular type belonging to the underlying SimObject.
 
template<typename TSimObjectAspect>
void removeAspect ()
 Removes an aspect from the underlying SimObject.
 
void addOrReplaceAspect (const BaseSimObjectAspect &aspect)
 Adds or replaces an aspect on the underlying SimObject with a new aspect constructed as a copy of another.
 
void addOrReplaceAspect (const nlohmann::json &jsonAspectProperties)
 Adds or replaces an aspect on the underlying SimObject with a new aspect constructed from its JSON description.
 
std::weak_ptr< FixedActionBindingdeclareFixedActionBinding (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.
 
EntityID getEntityID () const
 Gets the ID of the ECSWorld Entity belonging to our SimObject.
 
std::weak_ptr< ECSWorldgetWorld () const
 Gets a weak reference to the ECSWorld to which our SimObject's entity belongs.
 
- Static Protected Member Functions inherited from ToyMaker::BaseSimObjectAspect
template<typename TSimObjectAspectDerived>
static void registerAspect ()
 Registers an implementation of an aspect with the SimSystem.
 

Detailed Description

The aspect class for the UI layer of the game scene.

Converts UI interactions into game actions sent to the active player controller. Partially displays information about the current state of the game, as reported by the game data model or UrController.

Member Function Documentation

◆ clone()

std::shared_ptr< ToyMaker::BaseSimObjectAspect > UrUIView::clone ( ) const
overridevirtual

A method which must be overridden to specify how a new aspect should be constructed as a copy of this one.

Returns
std::shared_ptr<BaseSimObjectAspect> The newly constructed aspect.

Implements ToyMaker::BaseSimObjectAspect.

◆ onActivated()

void UrUIView::onActivated ( )
overridevirtual

Callback for when the aspect is activated (after it is attached to an active SimObject, or if the SimObject it was attached to has just been activated)

Reimplemented from ToyMaker::BaseSimObjectAspect.

◆ variableUpdate()

void UrUIView::variableUpdate ( uint32_t variableStepMillis)
overridevirtual

Overriding this allows an aspect to respond to variable updates.

Parameters
variableStepMillisThe time since the execution of the last frame, in milliseconds.
See also
SceneSystem::variableStep

Reimplemented from ToyMaker::BaseSimObjectAspect.

Member Data Documentation

◆ handleCancel

std::weak_ptr<ToyMaker::FixedActionBinding> UrUIView::handleCancel
private
Initial value:
"General", "Cancel", [this](const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition) {
return this->onCancel(actionData, actionDefinition);
}
)}
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
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

◆ kButtonEnumMap

const std::map< std::string, UrUIView::Buttons > UrUIView::kButtonEnumMap
staticprivate
Initial value:
{
{"swallow", UrUIView::Buttons::SWALLOW},
{"storm_bird", UrUIView::Buttons::STORMBIRD},
{"raven", UrUIView::Buttons::RAVEN},
{"rooster", UrUIView::Buttons::ROOSTER},
{"eagle", UrUIView::Buttons::EAGLE},
{"dice_roll", UrUIView::Buttons::DICE},
{"next_turn", UrUIView::Buttons::NEXT_TURN},
}

◆ mObserveButtonClicked

ToyMaker::SignalObserver<const std::string&> UrUIView::mObserveButtonClicked
Initial value:
{
*this, "ButtonClickedObserved",
[this](const std::string& button) { this->onButtonClicked(button); }
}

◆ mObserveControlInterface

ToyMaker::SignalObserver<PlayerID> UrUIView::mObserveControlInterface
Initial value:
{
*this, "ControlInterfaceObserved",
[this](PlayerID playerID) { this->onControlInterface(playerID); }
}
PlayerID
The two players playing the game, as known to GameOfUrModel.
Definition model.hpp:40

◆ mObserveControllerReady

ToyMaker::SignalObserver UrUIView::mObserveControllerReady
Initial value:
{
*this, "ControllerReadyObserved",
[this]() {this->onControllerReady();}
}

◆ mObserveDiceUpdated

ToyMaker::SignalObserver<DiceData> UrUIView::mObserveDiceUpdated
Initial value:
{
*this, "DiceUpdatedObserved",
[this](DiceData diceData) { this->onDiceUpdated(diceData); }
}
Data returned by GameOfUrModel when queried for dice related information.
Definition model.hpp:192

◆ mObserveMoveMade

ToyMaker::SignalObserver<MoveResultData> UrUIView::mObserveMoveMade
Initial value:
{
*this, "MoveMadeObserved",
[this](MoveResultData moveData) { this->onMoveMade(moveData); }
}
Data returned by the GameOfUrModel when making a move, or querying possible moves.
Definition model.hpp:278

◆ mObservePhaseUpdated

ToyMaker::SignalObserver<GamePhaseData> UrUIView::mObservePhaseUpdated
Initial value:
{
*this, "PhaseUpdatedObserved",
[this](GamePhaseData phaseData) { this->onPhaseUpdated(phaseData); }
}
Data returned by GameOfUrModel when queried about the current phase of the game.
Definition model.hpp:112

◆ mObservePlayerUpdated

ToyMaker::SignalObserver<PlayerData> UrUIView::mObservePlayerUpdated
Initial value:
{
*this, "PlayerUpdatedObserved",
[this](PlayerData playerData) { this->onPlayerUpdated(playerData); }
}
Data returned by GameOfUrModel when queried about a player.
Definition model.hpp:229

◆ mObserveScoreUpdated

ToyMaker::SignalObserver<GameScoreData> UrUIView::mObserveScoreUpdated
Initial value:
{
*this, "ScoreUpdatedObserved",
[this](GameScoreData scoreData) { this->onScoreUpdated(scoreData); }
}
Data returned by GameOfUrModel when queried for scores.
Definition model.hpp:151

◆ mObserveViewUpdateStarted

ToyMaker::SignalObserver UrUIView::mObserveViewUpdateStarted
Initial value:
{
*this, "ViewUpdateStartedObserved",
[this](){ this->onViewUpdateStarted(); }
}

◆ mSigViewUpdateCompleted

ToyMaker::Signal<std::string> UrUIView::mSigViewUpdateCompleted
Initial value:
{
*this, "ViewUpdateCompleted"
}

The documentation for this class was generated from the following files: