| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "ce/ComponentEditor.h" |
| 4 |
#include "DifficultyPanel.h" |
| 5 |
#include "Objective.h" |
| 6 |
|
| 7 |
#include <map> |
| 8 |
#include <vector> |
| 9 |
#include <memory> |
| 10 |
#include <string> |
| 11 |
|
| 12 |
#include "wxutil/XmlResourceBasedWidget.h" |
| 13 |
#include "wxutil/dialog/DialogBase.h" |
| 14 |
#include "wxutil/dataview/TreeView.h" |
| 15 |
#include <sigc++/connection.h> |
| 16 |
|
| 17 |
class wxChoice; |
| 18 |
class wxTextCtrl; |
| 19 |
class wxPanel; |
| 20 |
|
| 21 |
namespace objectives |
| 22 |
{ |
| 23 |
|
| 24 |
/** |
| 25 |
* Dialog for displaying and editing the properties and components (conditions) |
| 26 |
* attached to a particular objective. |
| 27 |
*/ |
| 28 |
class ComponentsDialog : |
| 29 |
public wxutil::DialogBase, |
| 30 |
private wxutil::XmlResourceBasedWidget |
| 31 |
{ |
| 32 |
private: |
| 33 |
// The objective we are editing |
| 34 |
Objective& _objective; |
| 35 |
|
| 36 |
struct ComponentListColumns : |
| 37 |
public wxutil::TreeModel::ColumnRecord |
| 38 |
{ |
| 39 |
ComponentListColumns() : |
| 40 |
index(add(wxutil::TreeModel::Column::Integer)), |
| 41 |
description(add(wxutil::TreeModel::Column::String)) |
| 42 |
{} |
| 43 |
|
| 44 |
wxutil::TreeModel::Column index; |
| 45 |
wxutil::TreeModel::Column description; |
| 46 |
}; |
| 47 |
|
| 48 |
// List store for the components |
| 49 |
ComponentListColumns _columns; |
| 50 |
wxutil::TreeModel::Ptr _componentList; |
| 51 |
wxutil::TreeView* _componentView; |
| 52 |
|
| 53 |
// Currently-active ComponentEditor (if any) |
| 54 |
ce::ComponentEditorPtr _componentEditor; |
| 55 |
|
| 56 |
// The widgets needed for editing the difficulty levels |
| 57 |
std::unique_ptr<DifficultyPanel> _diffPanel; |
| 58 |
|
| 59 |
// Working set of components we're editing (get written to the objective |
| 60 |
// as soon as the "Save" button is pressed. |
| 61 |
Objective::ComponentMap _components; |
| 62 |
|
| 63 |
// TRUE while the widgets are populated to disable callbacks |
| 64 |
bool _updateMutex; |
| 65 |
|
| 66 |
wxTextCtrl* _objDescriptionEntry; |
| 67 |
wxChoice* _objStateCombo; |
| 68 |
wxTextCtrl* _enablingObjs; |
| 69 |
wxTextCtrl* _successLogic; |
| 70 |
wxTextCtrl* _failureLogic; |
| 71 |
|
| 72 |
wxTextCtrl* _completionScript; |
| 73 |
wxTextCtrl* _failureScript; |
| 74 |
wxTextCtrl* _completionTarget; |
| 75 |
wxTextCtrl* _failureTarget; |
| 76 |
|
| 77 |
wxCheckBox* _objMandatoryFlag; |
| 78 |
wxCheckBox* _objIrreversibleFlag; |
| 79 |
wxCheckBox* _objOngoingFlag; |
| 80 |
wxCheckBox* _objVisibleFlag; |
| 81 |
|
| 82 |
wxPanel* _editPanel; |
| 83 |
wxChoice* _typeCombo; |
| 84 |
|
| 85 |
wxCheckBox* _stateFlag; |
| 86 |
wxCheckBox* _irreversibleFlag; |
| 87 |
wxCheckBox* _invertedFlag; |
| 88 |
wxCheckBox* _playerResponsibleFlag; |
| 89 |
|
| 90 |
wxPanel* _compEditorPanel; |
| 91 |
|
| 92 |
sigc::connection _componentChanged; |
| 93 |
|
| 94 |
bool _updateNeeded; |
| 95 |
|
| 96 |
private: |
| 97 |
// Construction helpers |
| 98 |
void setupObjectiveEditPanel(); |
| 99 |
void createListView(); |
| 100 |
void setupEditPanel(); |
| 101 |
|
| 102 |
// Populate the list of components from the Objective's component map |
| 103 |
void populateComponents(); |
| 104 |
|
| 105 |
// Updates the list store contents without removing any components |
| 106 |
void updateComponents(); |
| 107 |
|
| 108 |
// Populate the edit panel widgets with the specified component number |
| 109 |
void populateEditPanel(int index); |
| 110 |
|
| 111 |
// Populate the objective properties |
| 112 |
void populateObjectiveEditPanel(); |
| 113 |
|
| 114 |
// Get the index of the selected Component, or -1 if there is no selection |
| 115 |
int getSelectedIndex(); |
| 116 |
|
| 117 |
// Change the active ComponentEditor |
| 118 |
void changeComponentEditor(Component& compToEdit); |
| 119 |
|
| 120 |
// If there is a ComponentEditor, write its contents to the Component |
| 121 |
void checkWriteComponent(); |
| 122 |
|
| 123 |
// Writes the data from the widgets to the data structures |
| 124 |
void save(); |
| 125 |
|
| 126 |
// callbacks |
| 127 |
void _onDelete(); |
| 128 |
void handleSelectionChange(); |
| 129 |
void _onSelectionChanged(wxDataViewEvent& ev); |
| 130 |
void _onCompToggleChanged(wxCommandEvent& ev); |
| 131 |
|
| 132 |
void _onAddComponent(wxCommandEvent& ev); |
| 133 |
void _onDeleteComponent(wxCommandEvent& ev); |
| 134 |
|
| 135 |
void handleTypeChange(); |
| 136 |
void _onTypeChanged(wxCommandEvent& ev); |
| 137 |
void _onApplyComponentChanges(); |
| 138 |
|
| 139 |
void _onComponentChanged(); |
| 140 |
|
| 141 |
public: |
| 142 |
|
| 143 |
/** |
| 144 |
* Constructor creates widgets. |
| 145 |
* |
| 146 |
* @param parent |
| 147 |
* The parent window for which this dialog should be a transient. |
| 148 |
* |
| 149 |
* @param objective |
| 150 |
* The Objective object for which conditions should be displayed and edited. |
| 151 |
*/ |
| 152 |
ComponentsDialog(wxWindow* parent, Objective& objective); |
| 153 |
|
| 154 |
// Override DialogBase |
| 155 |
int ShowModal(); |
| 156 |
|
| 157 |
// Destructor performs cleanup |
| 158 |
~ComponentsDialog(); |
| 159 |
}; |
| 160 |
|
| 161 |
} // namespace |