Navigation Menu

Skip to content

Commit

Permalink
Refactor CommandEditor and prepare for animation picking
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 25, 2016
1 parent 1853bfa commit bf4f4cc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 43 deletions.
85 changes: 42 additions & 43 deletions plugins/dm.conversation/CommandEditor.cpp
Expand Up @@ -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);

Expand All @@ -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<BooleanArgument>(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<StringArgument>(parent, argInfo);
case conversation::ArgumentInfo::ARGTYPE_VECTOR:
// Create a new string argument item
return std::make_shared<StringArgument>(parent, argInfo);
case conversation::ArgumentInfo::ARGTYPE_SOUNDSHADER:
// Create a new sound shader argument item
return std::make_shared<SoundShaderArgument>(parent, argInfo);
case conversation::ArgumentInfo::ARGTYPE_ACTOR:
// Create a new actor argument item
return std::make_shared<ActorArgument>(parent, argInfo, _conversation.actors);
case conversation::ArgumentInfo::ARGTYPE_ENTITY:
// Create a new string argument item
return std::make_shared<StringArgument>(parent, argInfo);
default:
rError() << "Unknown command argument type: " << argInfo.type << std::endl;
break;
};

return CommandArgumentItemPtr();
}

void CommandEditor::onSave(wxCommandEvent& ev)
{
save();
Expand Down
2 changes: 2 additions & 0 deletions plugins/dm.conversation/CommandEditor.h
Expand Up @@ -49,6 +49,8 @@ class CommandEditor :
void onCancel(wxCommandEvent& ev);

void onCommandTypeChange(wxCommandEvent& ev);

CommandArgumentItemPtr createCommandArgumentItem(const conversation::ArgumentInfo& argInfo, wxWindow* parent);
};

} // namespace ui

0 comments on commit bf4f4cc

Please sign in to comment.