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_ui_records_browser.hpp
Go to the documentation of this file.
1
11
12#ifndef ZOAPPUIRECORDSBROWSER_H
13#define ZOAPPUIRECORDSBROWSER_H
14
15#define GLM_ENABLE_EXPERIMENTAL
16#include <glm/gtx/string_cast.hpp>
17#include "ur_records.hpp"
18
19#include "toymaker/sim_system.hpp"
20
26class UrUIRecordsBrowser: public ToyMaker::SimObjectAspect<UrUIRecordsBrowser> {
27public:
28 enum class Mode {
29 BROWSE,
30 DETAIL,
31 };
32 UrUIRecordsBrowser(): ToyMaker::SimObjectAspect<UrUIRecordsBrowser>{0} {}
33 inline static std::string getSimObjectAspectTypeName() { return "UrUIRecordsBrowser"; }
34 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
35 std::shared_ptr<BaseSimObjectAspect> clone() const override;
36
37
38 void loadScene(const std::string& sceneResourceName);
39
40private:
41 Mode mMode { Mode::BROWSE };
42 uint32_t mPage {0};
43 std::vector<GameRecord> mFetchedRecords {};
44
45 void refreshRecords();
46 void onButtonClicked(const std::string& button);
47 void onActivated() override;
48
49 bool hasPage(uint32_t page) const;
50 void openPage(uint32_t page);
51
52 void openDetailedRecord(uint32_t entry);
53 void closeDetailedRecord();
54
55 bool onCancel(const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition);
56
57 std::weak_ptr<ToyMaker::FixedActionBinding> handleCancel { declareFixedActionBinding(
58 "General", "Cancel", [this](const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition) {
59 return this->onCancel(actionData, actionDefinition);
60 }
61 )};
62 std::weak_ptr<ToyMaker::FixedActionBinding> handlerLeftRelease {
64 "UI", "Untap", [this](const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition) {
65 return this->onCancel(actionData, actionDefinition);
66 }
67 )
68 };
69public:
71 *this, "ButtonClickedObserved",
72 [this](const std::string& button) { this->onButtonClicked(button); }
73 };
74};
75
76#endif
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
An object containing closely related methods and data, and exposing object lifecycle and application ...
Definition sim_system.hpp:956
void onActivated() override
Callback for when the aspect is activated (after it is attached to an active SimObject,...
Definition ur_ui_records_browser.cpp:21
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_records_browser.cpp:16
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
Contains aspect class definition for the records save system.