Fixed editing intermdiate list values not working

This commit is contained in:
Kah Wei 2022-11-11 22:59:45 +08:00
parent dfc03839db
commit 2d2cc532a5
2 changed files with 6 additions and 8 deletions

View File

@ -174,7 +174,7 @@ namespace SHADE
// Any List // Any List
if (field->FieldType->IsGenericType && field->FieldType->GetGenericTypeDefinition() == System::Collections::Generic::List<int>::typeid->GetGenericTypeDefinition()) if (field->FieldType->IsGenericType && field->FieldType->GetGenericTypeDefinition() == System::Collections::Generic::List<int>::typeid->GetGenericTypeDefinition())
{ {
/* System::Type^ listType = field->FieldType->GenericTypeArguments[0]; System::Type^ listType = field->FieldType->GenericTypeArguments[0];
RangeAttribute^ rangeAttrib = hasAttribute<RangeAttribute^>(field); RangeAttribute^ rangeAttrib = hasAttribute<RangeAttribute^>(field);
System::Collections::IList^ iList = safe_cast<System::Collections::IList^>(field->GetValue(object)); System::Collections::IList^ iList = safe_cast<System::Collections::IList^>(field->GetValue(object));
@ -185,15 +185,17 @@ namespace SHADE
SHEditorUI::Indent(); SHEditorUI::Indent();
for (int i = 0; i < iList->Count; ++i) for (int i = 0; i < iList->Count; ++i)
{ {
SHEditorUI::PushID(i);
System::Object^ obj = iList[i]; System::Object^ obj = iList[i];
if (renderFieldInInspector(std::to_string(i), obj, rangeAttrib)) if (renderFieldEditor(std::to_string(i), obj, rangeAttrib))
{ {
iList[i] = obj; iList[i] = obj;
} }
SHEditorUI::SameLine(); SHEditorUI::SameLine();
SHEditorUI::Button("-"); SHEditorUI::Button("-");
SHEditorUI::PopID();
} }
SHEditorUI::Unindent();*/ SHEditorUI::Unindent();
} }
else else
{ {

View File

@ -86,11 +86,7 @@ namespace SHADE
{ {
if (object->GetType()->IsSubclassOf(Enum::typeid)) if (object->GetType()->IsSubclassOf(Enum::typeid))
{ {
int managedVal = safe_cast<int>(object); renderEnumEditor(fieldName, object, isHovered);
if (renderFieldEditorInternal<int, int>(fieldName, &managedVal, fieldEditor, isHovered, rangeAttrib))
{
object = managedVal;
}
return true; return true;
} }
} }