Debian Codegraph @

plugins/dm.conversation/ConversationEditor.h

raw
1 #pragma once
2
3 #include "wxutil/dialog/DialogBase.h"
4 #include "wxutil/XmlResourceBasedWidget.h"
5 #include "wxutil/dataview/TreeView.h"
6 #include <map>
7
8 #include "Conversation.h"
9
10 class wxButton;
11
12 namespace ui
13 {
14
15 class ConversationEditor :
16 public wxutil::DialogBase,
17 private wxutil::XmlResourceBasedWidget
18 {
19 private:
20 struct ActorListColumns :
21 public wxutil::TreeModel::ColumnRecord
22 {
23 ActorListColumns() :
24 actorNumber(add(wxutil::TreeModel::Column::Integer)),
25 displayName(add(wxutil::TreeModel::Column::String))
26 {}
27
28 wxutil::TreeModel::Column actorNumber; // actor number
29 wxutil::TreeModel::Column displayName; // display name
30 };
31
32 ActorListColumns _actorColumns;
33 wxutil::TreeModel::Ptr _actorStore;
34 wxutil::TreeView* _actorView;
35
36 struct CommandListColumns :
37 public wxutil::TreeModel::ColumnRecord
38 {
39 CommandListColumns() :
40 cmdNumber(add(wxutil::TreeModel::Column::Integer)),
41 actorName(add(wxutil::TreeModel::Column::String)),
42 sentence(add(wxutil::TreeModel::Column::String)),
43 wait(add(wxutil::TreeModel::Column::String))
44 {}
45
46 wxutil::TreeModel::Column cmdNumber; // cmd number
47 wxutil::TreeModel::Column actorName; // actor name
48 wxutil::TreeModel::Column sentence; // sentence
49 wxutil::TreeModel::Column wait; // wait yes/no
50 };
51
52 CommandListColumns _commandColumns;
53 wxutil::TreeModel::Ptr _commandStore;
54 wxutil::TreeView* _commandView;
55
56 wxDataViewItem _currentActor;
57 wxDataViewItem _currentCommand;
58
59 wxButton* _addActorButton;
60 wxButton* _delActorButton;
61 wxButton* _validateActorsButton;
62
63 wxButton* _addCmdButton;
64 wxButton* _delCmdButton;
65 wxButton* _editCmdButton;
66 wxButton* _moveUpCmdButton;
67 wxButton* _moveDownCmdButton;
68
69 // The conversation we're editing (the working copy)
70 conversation::Conversation _conversation;
71
72 // The actual conversation, where the changes will be saved to on "OK"
73 conversation::Conversation& _targetConversation;
74
75 // Mutex to avoid callback loops
76 bool _updateInProgress;
77
78 public:
79 ConversationEditor(wxWindow* parent, conversation::Conversation& conversation);
80
81 private:
82 void save();
83
84 void populateWindow();
85
86 // Fills the conversation values into the widgets
87 void updateWidgets();
88 void updateCommandList();
89 void updateCmdActionSensitivity(bool hasSelection);
90
91 // Move the currently selected command about the given delta
92 // (-1 is one upwards, +1 is one position downards)
93 void moveSelectedCommand(int delta);
94
95 // Highlight the command with the given index
96 void selectCommand(int index);
97
98 void onSave(wxCommandEvent& ev);
99 void onCancel(wxCommandEvent& ev);
100
101 void onMaxPlayCountEnabled(wxCommandEvent& ev);
102
103 void onActorSelectionChanged(wxDataViewEvent& ev);
104 void onCommandSelectionChanged(wxDataViewEvent& ev);
105
106 void onAddActor(wxCommandEvent& ev);
107 void onDeleteActor(wxCommandEvent& ev);
108 void onValidateActors(wxCommandEvent& ev);
109 void onActorEdited(wxDataViewEvent& ev);
110
111 void onAddCommand(wxCommandEvent& ev);
112 void onEditCommand(wxCommandEvent& ev);
113 void onMoveUpCommand(wxCommandEvent& ev);
114 void onMoveDownCommand(wxCommandEvent& ev);
115 void onDeleteCommand(wxCommandEvent& ev);
116
117 std::string removeMarkup(const std::string& input);
118 };
119
120 } // namespace ui