save ui settings & toggle ui

This commit is contained in:
Asuro
2025-03-31 18:12:23 +02:00
parent ae069c4949
commit 12c546b6dc
8 changed files with 42 additions and 5 deletions

BIN
assets/textures/concrete_tile.png LFS Normal file

Binary file not shown.

View File

@@ -17,6 +17,12 @@ namespace Game
Game, Game,
}; };
enum class InteractionMode
{
Walk,
ReadTablet,
};
struct Time struct Time
{ {
double Now = 0.0; double Now = 0.0;
@@ -44,6 +50,7 @@ namespace Game
float WalkYRot = 0.0f; float WalkYRot = 0.0f;
CameraMode CameraM = CameraMode::Freefly; CameraMode CameraM = CameraMode::Freefly;
InputMode InputM = InputMode::Game; InputMode InputM = InputMode::Game;
InteractionMode InteractionM = InteractionMode::Walk;
float MouseSensitivity = 1.0f; float MouseSensitivity = 1.0f;
float MovementSpeed = 10.0f; float MovementSpeed = 10.0f;
SavedPlayerConfig Config; SavedPlayerConfig Config;

View File

@@ -91,7 +91,8 @@ namespace Game
void UpdatePlayerInputMode() void UpdatePlayerInputMode()
{ {
bool IsGaming = GetInstance().Player.InputM == InputMode::Game; 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(); auto& IO = ImGui::GetIO();
IO.ConfigFlags = FlagBool(IO.ConfigFlags, ImGuiConfigFlags_NoMouse | ImGuiConfigFlags_NoKeyboard, IsGaming); IO.ConfigFlags = FlagBool(IO.ConfigFlags, ImGuiConfigFlags_NoMouse | ImGuiConfigFlags_NoKeyboard, IsGaming);
GameRendering::Get().UIVisible = IsGaming ? UIVisibilityState::Game : UIVisibilityState::Debug; GameRendering::Get().UIVisible = IsGaming ? UIVisibilityState::Game : UIVisibilityState::Debug;
@@ -179,6 +180,13 @@ namespace Game
} }
TabletHandle = UIQuads.New(); TabletHandle = UIQuads.New();
UpdatePlayerInputMode(); UpdatePlayerInputMode();
{
Deserializer d;
d.Init("game/data/static/uiconfig.dat", "UICO");
d.ReadT(GetInstance().Player.Config.TabletRenderData);
d.Finish();
}
} }
void Level::Update() void Level::Update()
@@ -241,6 +249,13 @@ namespace Game
bx::mtxRotateXYZ(player.PlayerCamTransform.Rotation.M, player.WalkXRot, player.WalkYRot, 0.0f); 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 // UI Tablet
if (IsValid(TabletHandle)) if (IsValid(TabletHandle))
{ {
@@ -300,7 +315,10 @@ namespace Game
Cubes.Render(models, materials, textures); Cubes.Render(models, materials, textures);
Tests.Render(models, materials, textures); Tests.Render(models, materials, textures);
PuzzleTiles.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() void Cube::Setup()

View File

@@ -1,3 +1,4 @@
#include "../gen/Def.h"
#include "Gen.h" #include "Gen.h"
#include "Global.h" #include "Global.h"
#include "Instance.h" #include "Instance.h"
@@ -6,7 +7,6 @@
#include "Tools.h" #include "Tools.h"
#include "bx/filepath.h" #include "bx/filepath.h"
#include "bx/math.h"
#include "bx/timer.h" #include "bx/timer.h"
#include <imgui.h> #include <imgui.h>
#include <tracy/Tracy.hpp> #include <tracy/Tracy.hpp>
@@ -233,7 +233,13 @@ namespace Tools
ImGui::Separator(); ImGui::Separator();
ImGui::Text("Game Tablet"); 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(); ImGui::Separator();

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
src/textures/concrete_tile.ktx LFS Normal file

Binary file not shown.