From 12c546b6dcac9b208d1fae15a079e5faecf7e9d9 Mon Sep 17 00:00:00 2001 From: Asuro Date: Mon, 31 Mar 2025 18:12:23 +0200 Subject: [PATCH] save ui settings & toggle ui --- assets/textures/concrete_tile.png | 3 +++ src/game/Instance.h | 7 +++++++ src/game/Level.cpp | 22 ++++++++++++++++++++-- src/game/Tools.cpp | 10 ++++++++-- src/game/data/puzzles/0.pzl | 2 +- src/game/data/static/puzzle.dat | Bin 1856 -> 1856 bytes src/game/data/static/uiconfig.dat | Bin 0 -> 281 bytes src/textures/concrete_tile.ktx | 3 +++ 8 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 assets/textures/concrete_tile.png create mode 100644 src/game/data/static/uiconfig.dat create mode 100644 src/textures/concrete_tile.ktx diff --git a/assets/textures/concrete_tile.png b/assets/textures/concrete_tile.png new file mode 100644 index 0000000..8283c18 --- /dev/null +++ b/assets/textures/concrete_tile.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a7490fa430a16abbd27972442a3bb000f07d5d7a9be57ace9d07be91b3d3c4b +size 3396975 diff --git a/src/game/Instance.h b/src/game/Instance.h index afbcb07..f1deecb 100644 --- a/src/game/Instance.h +++ b/src/game/Instance.h @@ -17,6 +17,12 @@ namespace Game Game, }; + enum class InteractionMode + { + Walk, + ReadTablet, + }; + struct Time { double Now = 0.0; @@ -44,6 +50,7 @@ namespace Game float WalkYRot = 0.0f; CameraMode CameraM = CameraMode::Freefly; InputMode InputM = InputMode::Game; + InteractionMode InteractionM = InteractionMode::Walk; float MouseSensitivity = 1.0f; float MovementSpeed = 10.0f; SavedPlayerConfig Config; diff --git a/src/game/Level.cpp b/src/game/Level.cpp index a8e9c51..e6628d2 100644 --- a/src/game/Level.cpp +++ b/src/game/Level.cpp @@ -91,7 +91,8 @@ namespace Game void UpdatePlayerInputMode() { bool IsGaming = GetInstance().Player.InputM == InputMode::Game; - SDL_SetWindowRelativeMouseMode(GetShared().Window.SDLWindow, IsGaming); + bool captureMouse = IsGaming && GetInstance().Player.InteractionM == InteractionMode::Walk; + SDL_SetWindowRelativeMouseMode(GetShared().Window.SDLWindow, captureMouse); auto& IO = ImGui::GetIO(); IO.ConfigFlags = FlagBool(IO.ConfigFlags, ImGuiConfigFlags_NoMouse | ImGuiConfigFlags_NoKeyboard, IsGaming); GameRendering::Get().UIVisible = IsGaming ? UIVisibilityState::Game : UIVisibilityState::Debug; @@ -179,6 +180,13 @@ namespace Game } TabletHandle = UIQuads.New(); UpdatePlayerInputMode(); + + { + Deserializer d; + d.Init("game/data/static/uiconfig.dat", "UICO"); + d.ReadT(GetInstance().Player.Config.TabletRenderData); + d.Finish(); + } } void Level::Update() @@ -241,6 +249,13 @@ namespace Game bx::mtxRotateXYZ(player.PlayerCamTransform.Rotation.M, player.WalkXRot, player.WalkYRot, 0.0f); } + if (GetKeyPressedNow(ScanCode::SPACE)) + { + player.InteractionM = player.InteractionM == InteractionMode::ReadTablet ? InteractionMode::Walk + : InteractionMode::ReadTablet; + UpdatePlayerInputMode(); + } + // UI Tablet if (IsValid(TabletHandle)) { @@ -300,7 +315,10 @@ namespace Game Cubes.Render(models, materials, textures); Tests.Render(models, materials, textures); PuzzleTiles.Render(models, materials, textures); - UIQuads.Render(models, materials, textures); + if (player.InteractionM == InteractionMode::ReadTablet) + { + UIQuads.Render(models, materials, textures); + } } void Cube::Setup() diff --git a/src/game/Tools.cpp b/src/game/Tools.cpp index 3c34698..f4a8f5b 100644 --- a/src/game/Tools.cpp +++ b/src/game/Tools.cpp @@ -1,3 +1,4 @@ +#include "../gen/Def.h" #include "Gen.h" #include "Global.h" #include "Instance.h" @@ -6,7 +7,6 @@ #include "Tools.h" #include "bx/filepath.h" -#include "bx/math.h" #include "bx/timer.h" #include #include @@ -233,7 +233,13 @@ namespace Tools ImGui::Separator(); ImGui::Text("Game Tablet"); - Tools::EntityDataSettings(player.Config.TabletRenderData); + if (Tools::EntityDataSettings(player.Config.TabletRenderData)) + { + Serializer s; + s.Init("game/data/static/uiconfig.dat", "UICO"); + s.WriteT(player.Config.TabletRenderData); + s.Finish(); + } ImGui::Separator(); diff --git a/src/game/data/puzzles/0.pzl b/src/game/data/puzzles/0.pzl index ac2cf50..c830284 100644 --- a/src/game/data/puzzles/0.pzl +++ b/src/game/data/puzzles/0.pzl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bdfe3c22160d79809d814dabf3e4ce06e2d217ca7c1075d9f502bf6c55a348ce +oid sha256:88cd38410c6f79e39d6df42c48b599a5b1ce93aef1d27112d3daf9881dad0df4 size 5820 diff --git a/src/game/data/static/puzzle.dat b/src/game/data/static/puzzle.dat index 7255bf7a07e54af5cc692bbc408d64de4df88347..c497acec0ad002ad7fe3e3e896fdcd64ad53688b 100644 GIT binary patch delta 24 gcmX@WcYtq#6B{$bo+ux)jSUmnCN@}17GO630BF4j`Tzg` delta 24 gcmX@WcYtq#6B`r5o+ux)jSUmnCN@}17GO630BEcS`2YX_ diff --git a/src/game/data/static/uiconfig.dat b/src/game/data/static/uiconfig.dat new file mode 100644 index 0000000000000000000000000000000000000000..0c714de5a2f58c075b10db624e8f448e1a6b6bab GIT binary patch literal 281 zcmWIbboMXLmD$U{z`!8D2qMvOgFOQS41?rAY!Ho%Nf9GOEwUXTHo9JPJ~lP@#6bEX U802+E24>C_Rd$BeYlA`<0YLl{3IG5A literal 0 HcmV?d00001 diff --git a/src/textures/concrete_tile.ktx b/src/textures/concrete_tile.ktx new file mode 100644 index 0000000..0133de3 --- /dev/null +++ b/src/textures/concrete_tile.ktx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d77fb232f3d7b9d2570e1cefd6c7c2bb81b91eaefd528b5fb550c54fae3ad1b1 +size 16777284