scriptlist: added remove method

Dieser Commit ist enthalten in:
Reinder Feenstra 2021-09-16 23:23:00 +02:00
Ursprung f9565ed519
Commit 8dfd87a738
2 geänderte Dateien mit 12 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -38,6 +38,13 @@ ScriptList::ScriptList(Object& _parent, const std::string& parentPropertyName) :
return std::shared_ptr<Script>();
return Script::create(world, world->getUniqueId("script"));
}}
, remove{*this, "remove",
[this](const std::shared_ptr<Script>& script)
{
if(containsObject(script))
script->destroy();
assert(!containsObject(script));
}}
{
auto world = getWorld(&_parent);
const bool editable = world && contains(world->state.value(), WorldState::Edit);
@ -45,6 +52,10 @@ ScriptList::ScriptList(Object& _parent, const std::string& parentPropertyName) :
Attributes::addDisplayName(add, DisplayName::List::add);
Attributes::addEnabled(add, editable);
m_interfaceItems.add(add);
Attributes::addDisplayName(remove, DisplayName::List::remove);
Attributes::addEnabled(remove, editable);
m_interfaceItems.add(remove);
}
TableModelPtr ScriptList::getModel()

Datei anzeigen

@ -39,6 +39,7 @@ class ScriptList : public ObjectList<Script>
CLASS_ID("lua.script_list")
::Method<std::shared_ptr<Script>()> add;
::Method<void(const std::shared_ptr<Script>&)> remove;
ScriptList(Object& _parent, const std::string& parentPropertyName);