List Serialization and Editor for Scripts #193
|
@ -75,7 +75,7 @@ namespace SHADE
|
|||
|
||||
bool SHEditorUI::BeginMenu(const std::string& label)
|
||||
{
|
||||
return ImGui::BeginMenu(label.data());
|
||||
return ImGui::BeginMenu(label.data());
|
||||
}
|
||||
|
||||
bool SHEditorUI::BeginMenu(const std::string& label, const char* icon)
|
||||
|
@ -143,7 +143,7 @@ namespace SHADE
|
|||
|
||||
bool SHEditorUI::Selectable(const std::string& label)
|
||||
{
|
||||
return ImGui::Selectable(label.data());
|
||||
return ImGui::Selectable(label.data());
|
||||
}
|
||||
|
||||
bool SHEditorUI::Selectable(const std::string& label, const char* icon)
|
||||
|
@ -165,8 +165,10 @@ namespace SHADE
|
|||
if (isHovered)
|
||||
*isHovered = ImGui::IsItemHovered();
|
||||
ImGui::SameLine();
|
||||
return ImGui::InputInt("##", &value,
|
||||
1, 10,
|
||||
return ImGui::DragInt("##", &value, 0.001f,
|
||||
std::numeric_limits<int>::min(),
|
||||
std::numeric_limits<int>::max(),
|
||||
"%d",
|
||||
ImGuiInputTextFlags_EnterReturnsTrue);
|
||||
}
|
||||
bool SHEditorUI::InputUnsignedInt(const std::string& label, unsigned int& value, bool* isHovered)
|
||||
|
@ -190,31 +192,22 @@ namespace SHADE
|
|||
if (isHovered)
|
||||
*isHovered = ImGui::IsItemHovered();
|
||||
ImGui::SameLine();
|
||||
return ImGui::InputFloat("##", &value,
|
||||
0.1f, 1.0f, "%.3f",
|
||||
return ImGui::DragFloat("##", &value, 0.001f,
|
||||
std::numeric_limits<float>::lowest(),
|
||||
std::numeric_limits<float>::max(),
|
||||
"%.3f",
|
||||
ImGuiInputTextFlags_EnterReturnsTrue);
|
||||
}
|
||||
bool SHEditorUI::InputDouble(const std::string& label, double& value, bool* isHovered)
|
||||
{
|
||||
ImGui::Text(label.c_str());
|
||||
if (isHovered)
|
||||
*isHovered = ImGui::IsItemHovered();
|
||||
ImGui::SameLine();
|
||||
return ImGui::InputDouble("##", &value,
|
||||
0.1, 1.0, "%.3f",
|
||||
ImGuiInputTextFlags_EnterReturnsTrue);
|
||||
float val = value;
|
||||
const bool CHANGED = InputFloat(label, val, isHovered);
|
||||
if (CHANGED)
|
||||
{
|
||||
value = static_cast<double>(val);
|
||||
}
|
||||
return CHANGED;
|
||||
}
|
||||
bool SHEditorUI::InputAngle(const std::string& label, double& value, bool* isHovered)
|
||||
{
|
||||
ImGui::Text(label.c_str());
|
||||
if (isHovered)
|
||||
*isHovered = ImGui::IsItemHovered();
|
||||
ImGui::SameLine();
|
||||
return ImGui::InputDouble("##", &value,
|
||||
1.0, 45.0, "%.3f",
|
||||
ImGuiInputTextFlags_EnterReturnsTrue);
|
||||
}
|
||||
|
||||
bool SHEditorUI::InputSlider(const std::string& label, int min, int max, int& value, bool* isHovered /*= nullptr*/)
|
||||
{
|
||||
ImGui::Text(label.c_str());
|
||||
|
|
|
@ -219,17 +219,6 @@ namespace SHADE
|
|||
/// <returns>True if the value was changed.</returns>
|
||||
static bool InputDouble(const std::string& label, double& value, bool* isHovered = nullptr);
|
||||
/// <summary>
|
||||
/// Creates a decimal field widget for double input with increments of higher
|
||||
/// steps meant for angle variables.
|
||||
/// <br/>
|
||||
/// Wraps up ImGui::InputDouble().
|
||||
/// </summary>
|
||||
/// <param name="label">Label used to identify this widget.</param>
|
||||
/// <param name="value">Reference to the variable to store the result.</param>
|
||||
/// <param name="isHovered>If set, stores the hover state of this widget.</param>
|
||||
/// <returns>True if the value was changed.</returns>
|
||||
static bool InputAngle(const std::string& label, double& value, bool* isHovered = nullptr);
|
||||
/// <summary>
|
||||
/// Creates an int slider field widget for double input.
|
||||
/// <br/>
|
||||
/// Wraps up ImGui::SliderInt().
|
||||
|
|
|
@ -178,39 +178,36 @@ namespace SHADE
|
|||
RangeAttribute^ rangeAttrib = hasAttribute<RangeAttribute^>(field);
|
||||
System::Collections::IList^ iList = safe_cast<System::Collections::IList^>(field->GetValue(object));
|
||||
|
||||
SHEditorUI::Text(Convert::ToNative(field->Name));
|
||||
SHEditorUI::SameLine();
|
||||
|
||||
if (SHEditorUI::Button("+"))
|
||||
if (SHEditorUI::CollapsingHeader(Convert::ToNative(field->Name)))
|
||||
{
|
||||
System::Object^ obj = System::Activator::CreateInstance(listType);
|
||||
iList->Add(obj);
|
||||
registerUndoListAddAction(listType, iList, iList->Count - 1, obj);
|
||||
}
|
||||
|
||||
SHEditorUI::Indent();
|
||||
for (int i = 0; i < iList->Count; ++i)
|
||||
{
|
||||
SHEditorUI::PushID(i);
|
||||
System::Object^ obj = iList[i];
|
||||
System::Object^ oldObj = iList[i];
|
||||
if (renderFieldEditor(std::to_string(i), obj, rangeAttrib))
|
||||
if (SHEditorUI::Button("Add Item"))
|
||||
{
|
||||
iList[i] = obj;
|
||||
registerUndoListChangeAction(listType, iList, i, obj, oldObj);
|
||||
System::Object^ obj = System::Activator::CreateInstance(listType);
|
||||
iList->Add(obj);
|
||||
registerUndoListAddAction(listType, iList, iList->Count - 1, obj);
|
||||
}
|
||||
SHEditorUI::SameLine();
|
||||
if (SHEditorUI::Button("-"))
|
||||
for (int i = 0; i < iList->Count; ++i)
|
||||
{
|
||||
SHEditorUI::PushID(i);
|
||||
System::Object^ obj = iList[i];
|
||||
iList->RemoveAt(i);
|
||||
registerUndoListRemoveAction(listType, iList, i, obj);
|
||||
System::Object^ oldObj = iList[i];
|
||||
if (renderFieldEditor(std::to_string(i), obj, rangeAttrib))
|
||||
{
|
||||
iList[i] = obj;
|
||||
registerUndoListChangeAction(listType, iList, i, obj, oldObj);
|
||||
}
|
||||
SHEditorUI::SameLine();
|
||||
if (SHEditorUI::Button("-"))
|
||||
{
|
||||
System::Object^ obj = iList[i];
|
||||
iList->RemoveAt(i);
|
||||
registerUndoListRemoveAction(listType, iList, i, obj);
|
||||
SHEditorUI::PopID();
|
||||
break;
|
||||
}
|
||||
SHEditorUI::PopID();
|
||||
break;
|
||||
}
|
||||
SHEditorUI::PopID();
|
||||
}
|
||||
SHEditorUI::Unindent();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue