diff --git a/rootex/core/input/input_manager.cpp b/rootex/core/input/input_manager.cpp index 1133f7852..10037304f 100644 --- a/rootex/core/input/input_manager.cpp +++ b/rootex/core/input/input_manager.cpp @@ -491,6 +491,7 @@ void to_json(JSON::json& j, const InputScheme& s) { j["bools"] = s.bools; j["floats"] = s.floats; + j["active"] = s.isActive; } void from_json(const JSON::json& j, InputScheme& s) @@ -505,4 +506,5 @@ void from_json(const JSON::json& j, InputScheme& s) InputDescription id = floatInput; s.floats.push_back(id); } + s.isActive = j.value("active",false); } diff --git a/rootex/core/input/input_manager.h b/rootex/core/input/input_manager.h index 105a40332..1fa455364 100644 --- a/rootex/core/input/input_manager.h +++ b/rootex/core/input/input_manager.h @@ -40,6 +40,7 @@ struct InputScheme { Vector bools; Vector floats; + bool isActive; }; void to_json(JSON::json& j, const InputScheme& s); diff --git a/rootex/framework/scene.cpp b/rootex/framework/scene.cpp index cd4953770..9300a77f3 100644 --- a/rootex/framework/scene.cpp +++ b/rootex/framework/scene.cpp @@ -278,8 +278,17 @@ bool Scene::addChild(Ptr& child) if (findIt == m_ChildrenScenes.end()) { child->m_ParentScene = this; + if (getID() != ROOT_SCENE_ID && getName() != "EditorCamera" && getName() != "EditorGrid") + { + for (auto&& inputScheme : child->getSettings().inputSchemes) + { + m_Settings.inputSchemes.insert(inputScheme); + } + } m_ChildrenScenes.emplace_back(std::move(child)); ScriptSystem::GetSingleton()->addEnterScriptEntity(&m_ChildrenScenes.back()->getEntity()); + + } else { @@ -493,13 +502,15 @@ void SceneSettings::draw() ImGui::EndCombo(); } - ImGui::Text("Input Schemes"); + ImGui::Text("Input Schemes:"); + ImGui::Separator(); int i = 0; const String* inputSchemeToRemove = nullptr; for (auto& [name, inputScheme] : inputSchemes) { ImGui::PushID(i); - + ImGui::Text(name.c_str()); + ImGui::Checkbox("Active", &inputScheme.isActive); ImGui::SetNextItemWidth(ImGui::GetFontSize() * 100); if (ImGui::ListBoxHeader(name.c_str())) { @@ -549,10 +560,6 @@ void SceneSettings::draw() ImGui::ListBoxFooter(); } - if (ImGui::Button("Remove Scheme")) - { - inputSchemeToRemove = &name; - } static int type = 0; ImGui::Combo("Type", &type, "Bool\0Float\0"); @@ -573,8 +580,12 @@ void SceneSettings::draw() inputScheme.floats.push_back(inputDesc); } } - + if (ImGui::Button("Remove Scheme")) + { + inputSchemeToRemove = &name; + } ImGui::PopID(); + ImGui::Separator(); i++; } @@ -584,8 +595,6 @@ void SceneSettings::draw() startScheme = ""; } - ImGui::Separator(); - static String newSchemeName = "New Scheme"; ImGui::InputText("##New Scheme", &newSchemeName); ImGui::SameLine(); diff --git a/rootex/framework/systems/input_system.cpp b/rootex/framework/systems/input_system.cpp index 06260790d..8510b6752 100644 --- a/rootex/framework/systems/input_system.cpp +++ b/rootex/framework/systems/input_system.cpp @@ -55,7 +55,13 @@ bool InputSystem::initialize(const JSON::json& systemData) void InputSystem::setConfig(const SceneSettings& sceneSettings) { loadSchemes(sceneSettings.inputSchemes); - pushScheme(sceneSettings.startScheme); + for (auto&& inputScheme : sceneSettings.inputSchemes) + { + if (inputScheme.second.isActive) + { + pushScheme(inputScheme.first); + } + } } void InputSystem::update(float deltaMilliseconds)