Added double, bool string

This commit is contained in:
Antoine Pilote
2024-08-13 21:42:20 -04:00
parent 9733e9651a
commit 44cb6f7325
2 changed files with 65 additions and 4 deletions

View File

@@ -3,6 +3,7 @@
#include <src/Scene/Components/NetScriptComponent.h>
#include <src/Core/FileSystem.h>
#include <src/Scripting/ScriptingEngineNet.h>
#include <src/Scene/Entities/ImGuiHelper.h>
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<double>(field.Value);
const std::string sliderName = "##" + field.Name + "slider";
ImGui::DragFloat(sliderName.c_str(), &currentValue);
field.Value = (double)currentValue;
}
if (field.Type == Nuake::NetScriptExposedVarType::Bool)
{
if (!field.Value.has_value())
{
field.Value = field.DefaultValue;
}
bool currentValue = std::any_cast<bool>(field.Value);
const std::string sliderName = "##" + field.Name + "slider";
ImGui::Checkbox(sliderName.c_str(), &currentValue);
field.Value = currentValue;
}
if (field.Type == Nuake::NetScriptExposedVarType::String)
{
if (!field.Value.has_value())
{
field.Value = field.DefaultValue;
}
std::string currentValue = std::any_cast<std::string>(field.Value);
const std::string sliderName = "##" + field.Name + "slider";
ImGui::InputText(sliderName.c_str(), &currentValue);
field.Value = currentValue;
}
ImGui::TableNextColumn();
}
}