List Serialization and Editor for Scripts #193

Merged
Pycorax merged 21 commits from SP3-6-ArraySerialization into main 2022-11-13 11:58:06 +08:00
1 changed files with 20 additions and 2 deletions
Showing only changes of commit d6764b4551 - Show all commits

View File

@ -181,7 +181,12 @@ namespace SHADE
SHEditorUI::Text(Convert::ToNative(field->Name));
SHEditorUI::SameLine();
SHEditorUI::Button("+");
if (SHEditorUI::Button("+"))
{
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)
@ -195,7 +200,14 @@ namespace SHADE
registerUndoListChangeAction(listType, iList, i, obj, oldObj);
}
SHEditorUI::SameLine();
SHEditorUI::Button("-");
if (SHEditorUI::Button("-"))
{
System::Object^ obj = iList[i];
iList->RemoveAt(i);
registerUndoListRemoveAction(listType, iList, i, obj);
SHEditorUI::PopID();
break;
}
SHEditorUI::PopID();
}
SHEditorUI::Unindent();
@ -367,6 +379,9 @@ namespace SHADE
return;
actionStack.Add(gcnew ListElementAddCommand(list, index, data));
// Inform the C++ Undo-Redo stack
SHCommandManager::RegisterCommand(std::reinterpret_pointer_cast<SHBaseCommand>(std::make_shared<SHCLICommand>()));
}
void Editor::registerUndoListRemoveAction(System::Type^ type, System::Collections::IList^ list, int index, System::Object^ data)
@ -375,6 +390,9 @@ namespace SHADE
return;
actionStack.Add(gcnew ListElementRemoveCommand(list, index, data));
// Inform the C++ Undo-Redo stack
SHCommandManager::RegisterCommand(std::reinterpret_pointer_cast<SHBaseCommand>(std::make_shared<SHCLICommand>()));
}
generic<typename Attribute>