diff --git a/Editor/src/ComponentsPanel/NetScriptPanel.cpp b/Editor/src/ComponentsPanel/NetScriptPanel.cpp index b1a23f62..ae4a4cfe 100644 --- a/Editor/src/ComponentsPanel/NetScriptPanel.cpp +++ b/Editor/src/ComponentsPanel/NetScriptPanel.cpp @@ -3,6 +3,7 @@ #include #include #include +#include void NetScriptPanel::Draw(Nuake::Entity entity) { @@ -138,6 +139,46 @@ void NetScriptPanel::Draw(Nuake::Entity entity) field.Value = currentValue; } + if (field.Type == Nuake::NetScriptExposedVarType::Double) + { + if (!field.Value.has_value()) + { + field.Value = field.DefaultValue; + } + + float currentValue = (float)std::any_cast(field.Value); + const std::string sliderName = "##" + field.Name + "slider"; + ImGui::DragFloat(sliderName.c_str(), ¤tValue); + field.Value = (double)currentValue; + } + + if (field.Type == Nuake::NetScriptExposedVarType::Bool) + { + if (!field.Value.has_value()) + { + field.Value = field.DefaultValue; + } + + bool currentValue = std::any_cast(field.Value); + const std::string sliderName = "##" + field.Name + "slider"; + ImGui::Checkbox(sliderName.c_str(), ¤tValue); + field.Value = currentValue; + } + + if (field.Type == Nuake::NetScriptExposedVarType::String) + { + if (!field.Value.has_value()) + { + field.Value = field.DefaultValue; + } + + std::string currentValue = std::any_cast(field.Value); + const std::string sliderName = "##" + field.Name + "slider"; + ImGui::InputText(sliderName.c_str(), ¤tValue); + + field.Value = currentValue; + } + ImGui::TableNextColumn(); } } diff --git a/Nuake/src/Scripting/ScriptingEngineNet.cpp b/Nuake/src/Scripting/ScriptingEngineNet.cpp index 8bf9e1a5..b321b422 100644 --- a/Nuake/src/Scripting/ScriptingEngineNet.cpp +++ b/Nuake/src/Scripting/ScriptingEngineNet.cpp @@ -207,6 +207,14 @@ namespace Nuake { varType = ExposedVarTypes::Double; } + else if (typeName == "System.String") + { + varType = ExposedVarTypes::String; + } + else if (typeName == "System.Boolean") + { + varType = ExposedVarTypes::Bool; + } exposedVar.Type = varType; @@ -284,7 +292,12 @@ namespace Nuake } case ExposedVarTypes::String: { - exposedVar.Value = classInstance.GetFieldValue(varName); + exposedVar.Value = std::string(classInstance.GetFieldValue(varName)); + break; + } + case ExposedVarTypes::Bool: + { + exposedVar.Value = (bool)classInstance.GetFieldValue(varName); break; } case ExposedVarTypes::Entity: @@ -295,12 +308,19 @@ namespace Nuake } } - - // Override with user values set in the editor. for (auto& exposedVarUserValue : component.ExposedVar) { - classInstance.SetFieldValue(exposedVarUserValue.Name, exposedVarUserValue.Value); + if (exposedVarUserValue.Type == NetScriptExposedVarType::String) + { + std::string stringValue = std::any_cast(exposedVarUserValue.Value); + Coral::String coralString = Coral::String::New(stringValue); + classInstance.SetFieldValue(exposedVarUserValue.Name, coralString); + } + else + { + classInstance.SetFieldValue(exposedVarUserValue.Name, exposedVarUserValue.Value); + } } m_EntityToManagedObjects.emplace(entity.GetID(), classInstance);