| 494 | } |
| 495 | |
| 496 | void ConversationEditor::onAddCommand(wxCommandEvent& ev) |
| 497 | { |
| 498 | conversation::Conversation& conv = _conversation; // shortcut |
| 499 | |
| 500 | // Create a new command |
| 501 | conversation::ConversationCommandPtr command(new conversation::ConversationCommand); |
| 502 | |
| 503 | // Construct a command editor (blocks on construction) |
| 504 | CommandEditor* editor = new CommandEditor(this, *command, conv); |
| 505 | |
| 506 | if (editor->ShowModal() == wxID_OK) |
| 507 | { |
| 508 | // The user hit ok, insert the command, find the first free index |
| 509 | int index = 1; |
| 510 | while (conv.commands.find(index) != conv.commands.end()) |
| 511 | { |
| 512 | index++; |
| 513 | } |
| 514 | |
| 515 | // Insert the command at the new location |
| 516 | conv.commands[index] = command; |
| 517 | |
| 518 | updateWidgets(); |
| 519 | } |
| 520 | |
| 521 | editor->Destroy(); |
| 522 | } |
| 523 | |
| 524 | void ConversationEditor::onEditCommand(wxCommandEvent& ev) |
| 525 | { |