16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 12:29:18 +02:00

Editor settings for New/Legacy camera controll

This commit is contained in:
2026-06-16 23:53:01 +02:00
parent 1aac9b4e76
commit 3bed2212d7
9 changed files with 178 additions and 12 deletions

View File

@@ -12,6 +12,7 @@ http://mozilla.org/MPL/2.0/.
#include "application/editoruilayer.h"
#include "application/application.h"
#include "editor/editorSettings.hpp"
#include "utilities/Globals.h"
#include "simulation/simulation.h"
#include "simulation/simulationtime.h"
@@ -32,7 +33,8 @@ http://mozilla.org/MPL/2.0/.
// Static member initialization
TCamera editor_mode::Camera;
bool editor_mode::m_focus_active = false;
bool editor_mode::m_change_history = true;
bool editor_mode::m_change_history = false;
bool editor_mode::m_settings_open = false;
namespace
{
@@ -72,6 +74,7 @@ editor_ui *editor_mode::ui() const
bool editor_mode::init()
{
EditorSettings.load();
Camera.Init({0, 15, 0}, {glm::radians(-30.0), glm::radians(180.0), 0}, nullptr);
return m_input.init();
}
@@ -464,14 +467,36 @@ bool editor_mode::update()
simulation::is_ready = true;
// --- ImGui: Editor History Window & Settings ---
// --- ImGui: Editor Settings & History windows ---
if(m_settings_open)
render_settings();
if(!m_change_history) return true;
render_change_history();
return true;
}
void editor_mode::render_settings()
{
ImGui::Begin("Editor Settings", &m_settings_open, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::TextUnformatted("Camera movement");
const char *schemes[] = {"WSAD (new)", "Arrows (legacy)"};
int current = (EditorSettings.movement() == editorSettings::movement_scheme::legacy) ? 1 : 0;
if (ImGui::Combo("##movement_scheme", &current, schemes, IM_ARRAYSIZE(schemes)))
{
EditorSettings.movement(current == 1 ? editorSettings::movement_scheme::legacy
: editorSettings::movement_scheme::wsad);
m_input.keyboard.apply_scheme();
EditorSettings.save();
}
ImGui::End();
}
void editor_mode::update_camera(double const Deltatime)
{
// account for keyboard-driven motion

View File

@@ -51,6 +51,8 @@ class editor_mode : public application_mode
static TCamera& get_camera() { return Camera; }
static bool change_history() { return m_change_history; }
static void set_change_history(bool enabled) { m_change_history = enabled; }
static bool settings_open() { return m_settings_open; }
static void set_settings_open(bool enabled) { m_settings_open = enabled; }
private:
// types
struct editormode_input
@@ -125,6 +127,7 @@ class editor_mode : public application_mode
bool mouseHold{false};
float kMaxPlacementDistance = 200.0f;
static bool m_change_history;
static bool m_settings_open;
// UI/history settings
int m_max_history_size{200};
@@ -143,4 +146,5 @@ class editor_mode : public application_mode
// clear history/redo pointers that reference the given node (prevent dangling pointers)
void nullify_history_pointers(scene::basic_node *node);
void render_change_history();
void render_settings();
};

View File

@@ -571,12 +571,17 @@ void ui_layer::render_menu_contents()
GfxRenderer->Debug_Ui_State(ret);
}
if(EditorModeFlag){
ImGui::MenuItem("Hierarchy", nullptr, &m_editor_hierarchy);
ImGui::MenuItem("Hierarchy", nullptr, &m_editor_hierarchy);
bool change_history_enabled = editor_mode::change_history();
if (ImGui::MenuItem("Change History", nullptr, &change_history_enabled))
{
editor_mode::set_change_history(change_history_enabled);
}
bool settings_open = editor_mode::settings_open();
if (ImGui::MenuItem("Editor Settings", nullptr, &settings_open))
{
editor_mode::set_settings_open(settings_open);
}
}
ImGui::EndMenu();
}