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
18#include <toymaker/engine/sim_system.hpp>
19
20#include "ur_records.hpp"
21
22
28class UrUIRecordsBrowser: public ToyMaker::SimObjectAspect<UrUIRecordsBrowser> {
29public:
30 enum class Mode {
31 BROWSE,
32 DETAIL,
33 };
34 UrUIRecordsBrowser(): ToyMaker::SimObjectAspect<UrUIRecordsBrowser>{0} {}
35 inline static std::string getSimObjectAspectTypeName() { return "UrUIRecordsBrowser"; }
36 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
37 std::shared_ptr<BaseSimObjectAspect> clone() const override;
38
39
40 void loadScene(const std::string& sceneResourceName);
41
42private:
43 Mode mMode { Mode::BROWSE };
44 uint32_t mPage {0};
45 std::vector<GameRecord> mFetchedRecords {};
46
47 void refreshRecords();
48 void onButtonClicked(const std::string& button);
49 void onActivated() override;
50
51 bool hasPage(uint32_t page) const;
52 void openPage(uint32_t page);
53
54 void openDetailedRecord(uint32_t entry);
55 void closeDetailedRecord();
56
57 bool onCancel(const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition);
58
59 std::weak_ptr<ToyMaker::FixedActionBinding> handleCancel { declareFixedActionBinding(
60 "General", "Cancel", [this](const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition) {
61 return this->onCancel(actionData, actionDefinition);
62 }
63 )};
64 std::weak_ptr<ToyMaker::FixedActionBinding> handlerLeftRelease {
65 declareFixedActionBinding(
66 "UI", "Untap", [this](const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition) {
67 return this->onCancel(actionData, actionDefinition);
68 }
69 )
70 };
71public:
72 ToyMaker::SignalObserver<const std::string&> mObserveButtonClicked {
73 *this, "ButtonClickedObserved",
74 [this](const std::string& button) { this->onButtonClicked(button); }
75 };
76};
77
78#endif
Contains aspect class definition for the records save system.