summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 3fe793f..cc975c7 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -6,9 +6,45 @@ GameSettings pkeSettings{};
const uint64_t consoleBufferCount = 30;
const uint64_t consoleLineLength = 128;
+const char *levelName = "demo-level";
+
char consoleBuffer[consoleBufferCount][consoleLineLength];
long consoleBufferIndex = 0;
+void SerializeEntityType(void *TODO, const EntityType &et) {
+ char handleStr[19] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' };
+ snprintf(handleStr, 19, "0x%016lX",static_cast<EntityHandle_T>(et.entityHandle));
+ // TODO
+}
+
+void SaveSceneFile(const char *sceneFilePath) {
+ // TODO init file
+
+ for (long i = 0; i < GlobalEntityTypes.Count(); ++i) {
+ const auto &et = GlobalEntityTypes[i];
+ const CompGrBinds *grBinds = ECS_GetGrBinds(et.entityHandle);
+ // TODO ignore if no instances
+ if (grBinds == nullptr) {
+ continue;
+ }
+ SerializeEntityType(nullptr, et); // TODO
+ }
+
+ std::ofstream f(sceneFilePath, std::ios::out);
+ // TODO write to file
+ f.flush();
+ f.close();
+}
+
+void ParseSceneFile(const char *sceneFilePath) {
+ AssetHandle sceneAH = AM_Register(sceneFilePath);
+ const Asset *sceneAsset = AM_Get(sceneAH);
+
+ // TODO
+
+ AM_Destroy(sceneAH);
+}
+
void Game_Tick(double delta) {
/*
* ECS_Tick() gets called first because it updates the public
@@ -103,11 +139,26 @@ void RecordImGuiEntityList() {
ImGui::End();
}
+void RecordImGuiSceneEditor() {
+
+ {
+ if (!ImGui::Begin("SceneEditorEntityTypes", &pkeSettings.editorSettings.isShowingSceneEditor)) {
+ ImGui::End();
+ return;
+ }
+ if (ImGui::Button("Save")) {
+ SaveSceneFile("test.yaml");
+ }
+ ImGui::End();
+ }
+}
+
void RecordImGuiEditor() {
if (pkeSettings.isShowingEditor) {
RecordImGuiEditorWrapper();
RecordImGuiConsole();
RecordImGuiEntityList();
+ RecordImGuiSceneEditor();
}
}