diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
commit | 6352e8e3196f78388b6c771073f9e03eaa612673 (patch) | |
tree | e23772f79a7fbc41bc9108951e9e136857484bf4 /source/game/StarCodex.cpp | |
parent | 6741a057e5639280d85d0f88ba26f000baa58f61 (diff) |
everything everywhere
all at once
Diffstat (limited to 'source/game/StarCodex.cpp')
-rw-r--r-- | source/game/StarCodex.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/source/game/StarCodex.cpp b/source/game/StarCodex.cpp new file mode 100644 index 0000000..c184724 --- /dev/null +++ b/source/game/StarCodex.cpp @@ -0,0 +1,71 @@ +#include "StarCodex.hpp" +#include "StarJsonExtra.hpp" + +namespace Star { + +Codex::Codex(Json const& config, String const& directory) { + m_directory = directory; + m_id = config.getString("id"); + m_species = config.getString("species", "other"); + m_title = config.getString("title"); + m_description = config.getString("description", ""); + m_icon = config.getString("icon"); + m_pages = jsonToStringList(config.get("contentPages")); + m_itemConfig = config.get("itemConfig", Json()); +} + +Json Codex::toJson() const { + auto result = JsonObject{ + {"id", m_id}, + {"species", m_species}, + {"title", m_title}, + {"description", m_description}, + {"icon", m_icon}, + {"contentPages", jsonFromStringList(m_pages)}, + {"itemConfig", m_itemConfig}}; + return result; +} + +String Codex::id() const { + return m_id; +} + +String Codex::species() const { + return m_species; +} + +String Codex::title() const { + return m_title; +} + +String Codex::description() const { + return m_description; +} + +String Codex::icon() const { + return m_icon; +} + +String Codex::page(size_t pageNum) const { + if (pageNum < m_pages.size()) + return m_pages[pageNum]; + return ""; +} + +List<String> Codex::pages() const { + return m_pages; +} + +size_t Codex::pageCount() const { + return m_pages.size(); +} + +Json Codex::itemConfig() const { + return m_itemConfig; +} + +String Codex::directory() const { + return m_directory; +} + +} |