palette_common.h

main 305 lines · 8.4 KB Raw
Alex Alex Commit Map Editor 18/10/2026 23:40
1//////////////////////////////////////////////////////////////////////
2// This file is part of Remere's Map Editor
3//////////////////////////////////////////////////////////////////////
4// Remere's Map Editor is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Remere's Map Editor is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//////////////////////////////////////////////////////////////////////
17
18#ifndef RME_PALETTE_COMMONS_H_
19#define RME_PALETTE_COMMONS_H_
20
21#include "main.h"
22
23#include "dcbutton.h"
24#include "tileset.h"
25#include "gui_ids.h"
26#include "common_windows.h"
27
28class GUI;
29class BrushButton;
30class TilesetCategory;
31class BrushSizePanel;
32class BrushPalettePanel;
33class PaletteWindow;
34
35typedef TilesetCategoryType PaletteType;
36
37class BrushButton : public ItemToggleButton {
38public:
39 BrushButton(wxWindow* parent, Brush* brush, RenderSize, uint32_t id = wxID_ANY);
40 BrushButton(wxWindow* parent, Brush* brush, RenderSize, EditorSprite* espr, uint32_t id = wxID_ANY);
41 virtual ~BrushButton();
42
43 Brush* brush;
44
45 void OnKey(wxKeyEvent& event);
46
47 DECLARE_EVENT_TABLE()
48};
49
50class PalettePanel : public wxPanel {
51public:
52 PalettePanel(wxWindow* parent, wxWindowID id = wxID_ANY, long style = wxTAB_TRAVERSAL);
53 ~PalettePanel();
54
55 // Interface
56 // Flushes this panel and consequent views will feature reloaded data
57 virtual void InvalidateContents();
58 // Loads the currently displayed page
59 virtual void LoadCurrentContents();
60 // Loads all content in this panel
61 virtual void LoadAllContents();
62
63 PaletteWindow* GetParentPalette() const;
64 virtual wxString GetName() const;
65 virtual PaletteType GetType() const;
66
67 // Add a tool panel!
68 virtual void AddToolPanel(PalettePanel* panel);
69 // Sets the style for this toolbar and child toolabrs
70 virtual void SetToolbarIconSize(bool large_icons);
71
72 // Select the first brush
73 virtual void SelectFirstBrush();
74 // Returns the currently selected brush (First brush if panel is not loaded)
75 virtual Brush* GetSelectedBrush() const;
76 // Returns the currently selected brush size
77 virtual int GetSelectedBrushSize() const;
78 // Select the brush in the parameter, this only changes the look of the panel
79 virtual bool SelectBrush(const Brush* whatbrush);
80
81 virtual void DeselectAll() { }
82
83 // Updates the palette window to use the current brush size
84 virtual void OnUpdateBrushSize(BrushShape shape, int size);
85 // Called when this page is about to be displayed
86 virtual void OnSwitchIn();
87 // Called when this page is hidden
88 virtual void OnSwitchOut();
89 // Called sometimes
90 virtual void OnUpdate();
91 // When the palette should do a delayed refresh (necessary for multiple palettes)
92 void OnRefreshTimer(wxTimerEvent&);
93
94 void RefreshOtherPalettes();
95
96protected:
97 typedef std::vector<PalettePanel*> ToolBarList;
98 ToolBarList tool_bars;
99 wxTimer refresh_timer;
100 int last_brush_size;
101
102 DECLARE_EVENT_TABLE();
103};
104
105class ZoneBrushPanel : public PalettePanel {
106public:
107 ZoneBrushPanel(wxWindow* parent);
108 ~ZoneBrushPanel() { }
109
110 // Interface
111 // Flushes this panel and consequent views will feature reloaded data
112 void InvalidateContents();
113 // Loads the currently displayed page
114 void LoadCurrentContents();
115 // Loads all content in this panel
116 void LoadAllContents();
117
118 // Returns the currently selected brush (First brush if panel is not loaded)
119 Brush* GetSelectedBrush() const;
120 // Select the brush in the parameter, this only changes the look of the panel
121 bool SelectBrush(const Brush* whatbrush);
122
123 wxString GetName() const;
124 void SetToolbarIconSize(bool large);
125 void OnZoneIdChange(wxCommandEvent& WXUNUSED(event));
126
127 // Called when this page is displayed
128 void OnSwitchIn();
129
130 // wxWidgets event handling
131 void OnClickZoneBrushButton(wxCommandEvent& event);
132 void DeselectAll();
133
134protected:
135 bool loaded;
136 bool large_icons;
137
138 BrushButton* zoneButton;
139 wxSpinCtrl* zoneIdSpin;
140
141 DECLARE_EVENT_TABLE()
142};
143
144class BrushSizePanel : public PalettePanel {
145public:
146 BrushSizePanel(wxWindow* parent);
147 ~BrushSizePanel() { }
148
149 // Interface
150 // Flushes this panel and consequent views will feature reloaded data
151 void InvalidateContents();
152 // Loads the currently displayed page
153 void LoadCurrentContents();
154 // Loads all content in this panel
155 void LoadAllContents();
156
157 wxString GetName() const;
158 void SetToolbarIconSize(bool large);
159
160 // Updates the palette window to use the current brush size
161 void OnUpdateBrushSize(BrushShape shape, int size);
162 // Called when this page is displayed
163 void OnSwitchIn();
164
165 // wxWidgets event handling
166 void OnClickSquareBrush(wxCommandEvent& event);
167 void OnClickCircleBrush(wxCommandEvent& event);
168
169 void OnClickBrushSize(int which);
170 void OnClickBrushSize0(wxCommandEvent& event) {
171 OnClickBrushSize(0);
172 }
173 void OnClickBrushSize1(wxCommandEvent& event) {
174 OnClickBrushSize(1);
175 }
176 void OnClickBrushSize2(wxCommandEvent& event) {
177 OnClickBrushSize(2);
178 }
179 void OnClickBrushSize4(wxCommandEvent& event) {
180 OnClickBrushSize(4);
181 }
182 void OnClickBrushSize6(wxCommandEvent& event) {
183 OnClickBrushSize(6);
184 }
185 void OnClickBrushSize8(wxCommandEvent& event) {
186 OnClickBrushSize(8);
187 }
188 void OnClickBrushSize11(wxCommandEvent& event) {
189 OnClickBrushSize(11);
190 }
191
192protected:
193 bool loaded;
194 bool large_icons;
195
196 DCButton* brushshapeSquareButton;
197 DCButton* brushshapeCircleButton;
198
199 DCButton* brushsize0Button;
200 DCButton* brushsize1Button;
201 DCButton* brushsize2Button;
202 DCButton* brushsize4Button;
203 DCButton* brushsize6Button;
204 DCButton* brushsize8Button;
205 DCButton* brushsize11Button;
206
207 DECLARE_EVENT_TABLE()
208};
209
210class BrushToolPanel : public PalettePanel {
211public:
212 BrushToolPanel(wxWindow* parent);
213 ~BrushToolPanel();
214
215 // Interface
216 // Flushes this panel and consequent views will feature reloaded data
217 void InvalidateContents();
218 // Loads the currently displayed page
219 void LoadCurrentContents();
220 // Loads all content in this panel
221 void LoadAllContents();
222
223 wxString GetName() const;
224 void SetToolbarIconSize(bool large);
225
226 // Returns the currently selected brush (First brush if panel is not loaded)
227 Brush* GetSelectedBrush() const;
228 // Select the brush in the parameter, this only changes the look of the panel
229 bool SelectBrush(const Brush* whatbrush);
230
231 // Called when this page is displayed
232 void OnSwitchIn();
233
234 // wxWidgets event handling
235 void OnClickGravelButton(wxCommandEvent& event);
236 void OnClickEraserButton(wxCommandEvent& event);
237 // ----
238 void OnClickNormalDoorButton(wxCommandEvent& event);
239 void OnClickLockedDoorButton(wxCommandEvent& event);
240 void OnClickMagicDoorButton(wxCommandEvent& event);
241 void OnClickQuestDoorButton(wxCommandEvent& event);
242 void OnClickHatchDoorButton(wxCommandEvent& event);
243 void OnClickWindowDoorButton(wxCommandEvent& event);
244 void OnClickNormalAltDoorButton(wxCommandEvent& event);
245 void OnClickArchwayDoorButton(wxCommandEvent& event);
246 // ----
247 void OnClickPZBrushButton(wxCommandEvent& event);
248 void OnClickNOPVPBrushButton(wxCommandEvent& event);
249 void OnClickNoLogoutBrushButton(wxCommandEvent& event);
250 void OnClickPVPZoneBrushButton(wxCommandEvent& event);
251 // ----
252 void OnClickLockDoorCheckbox(wxCommandEvent& event);
253
254public:
255 void DeselectAll();
256
257 bool loaded;
258 bool large_icons;
259
260 BrushButton* optionalBorderButton;
261 BrushButton* eraserButton;
262 // ----
263 BrushButton* normalDoorButton;
264 BrushButton* lockedDoorButton;
265 BrushButton* magicDoorButton;
266 BrushButton* questDoorButton;
267 BrushButton* hatchDoorButton;
268 BrushButton* windowDoorButton;
269 BrushButton* normalDoorAltButton;
270 BrushButton* archwayDoorButton;
271 // ----
272 BrushButton* pzBrushButton;
273 BrushButton* nopvpBrushButton;
274 BrushButton* nologBrushButton;
275 BrushButton* pvpzoneBrushButton;
276
277 wxCheckBox* lockDoorCheckbox;
278
279 DECLARE_EVENT_TABLE()
280};
281
282class BrushThicknessPanel : public PalettePanel {
283public:
284 BrushThicknessPanel(wxWindow* parent);
285 ~BrushThicknessPanel();
286
287 // Interface
288 wxString GetName() const;
289
290 // Called when this page is displayed
291 void OnSwitchIn();
292
293 // wxWidgets event handling
294 void OnScroll(wxScrollEvent& event);
295 void OnClickCustomThickness(wxCommandEvent& event);
296
297public:
298 wxSlider* slider;
299 wxCheckBox* use_button;
300
301 DECLARE_EVENT_TABLE()
302};
303
304#endif
305
Top