save ui settings & toggle ui
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 <imgui.h>
|
||||
#include <tracy/Tracy.hpp>
|
||||
@@ -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();
|
||||
|
||||
|
||||
BIN
src/game/data/puzzles/0.pzl
LFS
BIN
src/game/data/puzzles/0.pzl
LFS
Binary file not shown.
Binary file not shown.
BIN
src/game/data/static/uiconfig.dat
Normal file
BIN
src/game/data/static/uiconfig.dat
Normal file
Binary file not shown.
Reference in New Issue
Block a user