diff --git a/plugins/dm.conversation/CommandEditor.cpp b/plugins/dm.conversation/CommandEditor.cpp index c6f4359e5b..a5a335de11 100644 --- a/plugins/dm.conversation/CommandEditor.cpp +++ b/plugins/dm.conversation/CommandEditor.cpp @@ -216,51 +216,11 @@ void CommandEditor::createArgumentWidgets(int commandTypeID) } // Setup the table with default spacings - typedef conversation::ConversationCommandInfo::ArgumentInfoList::const_iterator ArgumentIter; - - int index = 1; - - for (ArgumentIter i = cmdInfo.arguments.begin(); - i != cmdInfo.arguments.end(); ++i, ++index) + for (const conversation::ArgumentInfo& argInfo : cmdInfo.arguments) { - const conversation::ArgumentInfo& argInfo = *i; - - CommandArgumentItemPtr item; + CommandArgumentItemPtr item = createCommandArgumentItem(argInfo, argPanel); - switch (argInfo.type) - { - case conversation::ArgumentInfo::ARGTYPE_BOOL: - // Create a new bool argument item - item = CommandArgumentItemPtr(new BooleanArgument(argPanel, argInfo)); - break; - case conversation::ArgumentInfo::ARGTYPE_INT: - case conversation::ArgumentInfo::ARGTYPE_FLOAT: - case conversation::ArgumentInfo::ARGTYPE_STRING: - // Create a new string argument item - item = CommandArgumentItemPtr(new StringArgument(argPanel, argInfo)); - break; - case conversation::ArgumentInfo::ARGTYPE_VECTOR: - // Create a new string argument item - item = CommandArgumentItemPtr(new StringArgument(argPanel, argInfo)); - break; - case conversation::ArgumentInfo::ARGTYPE_SOUNDSHADER: - // Create a new sound shader argument item - item = CommandArgumentItemPtr(new SoundShaderArgument(argPanel, argInfo)); - break; - case conversation::ArgumentInfo::ARGTYPE_ACTOR: - // Create a new actor argument item - item = CommandArgumentItemPtr(new ActorArgument(argPanel, argInfo, _conversation.actors)); - break; - case conversation::ArgumentInfo::ARGTYPE_ENTITY: - // Create a new string argument item - item = CommandArgumentItemPtr(new StringArgument(argPanel, argInfo)); - break; - default: - rError() << "Unknown command argument type: " << argInfo.type << std::endl; - break; - }; - - if (item != NULL) + if (item) { _argumentItems.push_back(item); @@ -286,6 +246,45 @@ void CommandEditor::createArgumentWidgets(int commandTypeID) Fit(); } +CommandArgumentItemPtr CommandEditor::createCommandArgumentItem(const conversation::ArgumentInfo& argInfo, wxWindow* parent) +{ + // Unfortunately we don't have a type declaration for animation in the .def file (didn't think about that back then) + // so let's detect the "Anim" title of the argument and construct an animation picker in this case + if (argInfo.title == "Anim") + { + // TODO + } + + switch (argInfo.type) + { + case conversation::ArgumentInfo::ARGTYPE_BOOL: + // Create a new bool argument item + return std::make_shared(parent, argInfo); + case conversation::ArgumentInfo::ARGTYPE_INT: + case conversation::ArgumentInfo::ARGTYPE_FLOAT: + case conversation::ArgumentInfo::ARGTYPE_STRING: + // Create a new string argument item + return std::make_shared(parent, argInfo); + case conversation::ArgumentInfo::ARGTYPE_VECTOR: + // Create a new string argument item + return std::make_shared(parent, argInfo); + case conversation::ArgumentInfo::ARGTYPE_SOUNDSHADER: + // Create a new sound shader argument item + return std::make_shared(parent, argInfo); + case conversation::ArgumentInfo::ARGTYPE_ACTOR: + // Create a new actor argument item + return std::make_shared(parent, argInfo, _conversation.actors); + case conversation::ArgumentInfo::ARGTYPE_ENTITY: + // Create a new string argument item + return std::make_shared(parent, argInfo); + default: + rError() << "Unknown command argument type: " << argInfo.type << std::endl; + break; + }; + + return CommandArgumentItemPtr(); +} + void CommandEditor::onSave(wxCommandEvent& ev) { save(); diff --git a/plugins/dm.conversation/CommandEditor.h b/plugins/dm.conversation/CommandEditor.h index 49ac98ea53..f4becfc875 100644 --- a/plugins/dm.conversation/CommandEditor.h +++ b/plugins/dm.conversation/CommandEditor.h @@ -49,6 +49,8 @@ class CommandEditor : void onCancel(wxCommandEvent& ev); void onCommandTypeChange(wxCommandEvent& ev); + + CommandArgumentItemPtr createCommandArgumentItem(const conversation::ArgumentInfo& argInfo, wxWindow* parent); }; } // namespace ui