aboutsummaryrefslogtreecommitdiff
path: root/source/30-game/Level.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-06-03 22:58:28 -0700
committerrtk0c <[email protected]>2022-06-03 22:58:28 -0700
commit8510a85f79f706b93982b4e398b187b5f77081dd (patch)
tree996c27f54f748d940f58454f7ef1e1570d1a31d5 /source/30-game/Level.hpp
parentbd07ae3f4e1bcdedc3e373460671ca9713a03de5 (diff)
Changeset: 61 [BUGGED] Move object kind enums to use generated ToString and FromStrong
The old mechanism rely on a specific prefix to Ires and GameObject string representations, but the generator currently leaves the enum value. Therefore all editor (e.g. drag & drop) and IO (e.g. ires loading) mechanisms are broken.
Diffstat (limited to 'source/30-game/Level.hpp')
-rw-r--r--source/30-game/Level.hpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/source/30-game/Level.hpp b/source/30-game/Level.hpp
index c1170a3..9114a64 100644
--- a/source/30-game/Level.hpp
+++ b/source/30-game/Level.hpp
@@ -1,8 +1,10 @@
#pragma once
+#include "EditorCore.hpp"
#include "GameObject.hpp"
-#include "RcPtr.hpp"
-#include "Uid.hpp"
+
+#include <RcPtr.hpp>
+#include <Uid.hpp>
#include <robin_hood.h>
#include <filesystem>
@@ -20,6 +22,7 @@ private:
struct InstanciationEntry;
LevelManager* mMan;
+ Uid mUid;
std::vector<InstanciationEntry> mEntries;
public:
@@ -27,6 +30,12 @@ public:
~Level();
void Instanciate(GameObject* relRoot) const;
+
+ LevelManager* GetLinkedLevelManager() const { return mMan; }
+ const Uid& GetUid() const { return mUid; }
+
+ // Editor stuff
+ void ShowInstanciationEntries(IEditor& editor);
};
class LevelManager {
@@ -34,12 +43,16 @@ public:
static inline LevelManager* instance = nullptr;
public: // NOTE: public for the editor; actual game components should not modify the map using this
+ // TODO maybe cut this struct to only the first RcPtr<Level> field in release mode?
struct LoadableObject {
RcPtr<Level> level; // TODO make weak pointer
std::filesystem::path filePath;
// NOTE: these fields are only loaded in dev mode
std::string name;
std::string description;
+
+ // Editor book keeping fields
+ bool edited = false;
};
// We want pointer stability here for the editor (inspector object)
robin_hood::unordered_node_map<Uid, LoadableObject> mObjByUid;
@@ -54,8 +67,16 @@ public:
/// Send the given level to be loaded on another thread
void PrepareLevel(const Uid& uid);
- // These should only be used by the editor
+ /// Create and add a new level object with the given uid.
+ /// Should only be used by the editor.
LoadableObject& AddLevel(const Uid& uid);
+ /// Should only be used by the editor.
+ void SaveLevel(const Uid& uid) const;
+ /// Should only be used by the editor.
+ void SaveLevel(const Uid& uid, const std::filesystem::path& path) const;
+
+private:
+ void SaveLevelImpl(const LoadableObject& obj, const std::filesystem::path& path) const;
};
class LevelWrapperObject : public GameObject {