/
DifficultyEditor.h
100 lines (75 loc) · 2.62 KB
/
DifficultyEditor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#pragma once
#include <string>
#include <memory>
#include "DifficultySettings.h"
#include "wxutil/XmlResourceBasedWidget.h"
class wxPanel;
class wxTextCtrl;
class wxChoice;
class wxButton;
class wxStaticText;
class wxComboBox;
namespace wxutil { class TreeView; }
namespace ui
{
/**
* greebo: A Difficulty Editor provides the front-end for editing a
* set of Difficulty Settings (e.g. "Easy" setting). The actual
* data is stored in a DifficultySettings instance.
*/
class DifficultyEditor :
public wxEvtHandler,
private wxutil::XmlResourceBasedWidget
{
// The actual settings we're working with
difficulty::DifficultySettingsPtr _settings;
// GtkNotebook-related widgets
wxPanel* _editor;
wxutil::TreeView* _settingsView;
// The classname dropdown entry field
wxComboBox* _classCombo;
wxTextCtrl* _spawnArgEntry;
wxTextCtrl* _argumentEntry;
wxChoice* _appTypeCombo;
wxButton* _saveSettingButton;
wxButton* _deleteSettingButton;
wxButton* _createSettingButton;
wxButton* _refreshButton;
// A label containing notes to the user
wxStaticText* _noteText;
// Mutex for avoiding loopbacks
bool _updateActive;
public:
/**
* greebo: Pass the label string and the difficulty settings object to the
* constructor. The DifficultySettings should be populated first.
*/
DifficultyEditor(wxWindow* parent,
const difficulty::DifficultySettingsPtr& settings);
// Returns the actual editor widget (contains all controls and views)
wxWindow* getWidget();
private:
// Creates the widgets
void populateWindow();
// Returns the ID of the selected setting (or -1) if no valid setting is selected
int getSelectedSettingId();
// Loads the data from the treeview selection into the editor widgets
void updateEditorWidgets();
// Prepares the widgets for addition of a new setting
void createSetting();
// Saves the setting data from the widgets to the DifficultySettings object
void saveSetting();
// Removes the setting selected in the treeview
void deleteSetting();
// Highlights the setting (according to the given <id>) in the treeview
void selectSettingById(int id);
// Callback for treeview selection changes
void onSettingSelectionChange(wxDataViewEvent& ev);
void onSettingCreate(wxCommandEvent& ev);
void onSettingSave(wxCommandEvent& ev);
void onSettingDelete(wxCommandEvent& ev);
void onRefresh(wxCommandEvent& ev);
void onAppTypeChange(wxCommandEvent& ev);
};
typedef std::shared_ptr<DifficultyEditor> DifficultyEditorPtr;
} // namespace ui