-
Notifications
You must be signed in to change notification settings - Fork 3
/
ZEd.h
364 lines (291 loc) · 6.96 KB
/
ZEd.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
#ifndef __ZED_H
#define __ZED_H
#include "configfile.h"
#include "GameConfig.h"
#include "Level.h"
#include "View2D.h"
#include "Infobars.h"
#include "doomerrors.h"
#define ZED_CAPTION "ZEd 2.2"
wxString GetConfigDir();
// Global commands
enum
{
CMD_START=300,
CMD_NEW=CMD_START,
CMD_OPEN,
CMD_SELECTIWAD,
CMD_PREFERENCES,
CMD_CHANGECONFIG,
CMD_SAVE,
CMD_SAVEAS,
CMD_ENABLESDCOMPRESSION,
CMD_ALWAYSSAVEASTEXT,
CMD_LISTTHINGSINPWAD,
CMD_LISTLINETYPESINPWAD,
CMD_LISTUNUSEDTEXTURES,
CMD_LISTUSEDTEXTURES,
CMD_UNDO,
CMD_REDO,
CMD_COPY,
CMD_CUT,
CMD_PASTE,
CMD_DELETE,
CMD_CLEAR,
CMD_DELETEUNUSEDVERTICES,
CMD_DELETEUNUSEDSECTORS,
CMD_REMOVEZEROLINES,
CMD_EDITACS,
CMD_EDITFS,
CMD_EDITCONV,
CMD_EDITFSGLOBAL,
CMD_ZOOMIN,
CMD_ZOOMOUT,
CMD_CENTERVIEW,
CMD_GOTOOBJECT,
CMD_DOSNAPTOGRID,
CMD_SNAPTOGRID,
CMD_AUTOGRID,
CMD_SHOWGRID,
CMD_HIGHLIGHTGRID,
CMD_SETGRID,
CMD_CHANGEGRID,
CMD_SIDEMARKERS,
CMD_LISTTEXTURES,
CMD_LISTLINETYPES,
CMD_LISTTHINGS,
CMD_ITEMSTATISTICS,
CMD_LISTTAGS,
CMD_INSERTRECT,
CMD_INSERTPOLY,
CMD_LINEDRAW,
CMD_CURVE,
CMD_FINDTHINGBYTYPE,
CMD_FINDTHINGBYTID,
CMD_FINDTHINGBYSPECIAL,
CMD_CHANGETHINGTYPE,
CMD_MARKTHINGSWITHTAG,
CMD_FINDLDBYTEXTURE,
CMD_FINDLDBYTYPE,
CMD_FINDLDBYTAG,
CMD_FINDLDBYTID,
CMD_FINDLDBYLINEID,
CMD_FINDSECBYTEXTURE,
CMD_FINDSECBYTYPE,
CMD_FINDSECBYTAG,
CMD_FINDTHINGBYCURRENTTID,
CMD_FINDLINEBYCURRENTTAG,
CMD_FINDLINEBYCURRENTTID,
CMD_FINDLINEBYCURRENTLINEID,
CMD_FINDSECTORBYCURRENTTAG,
CMD_FINDNEXT,
CMD_RENAMETEX,
CMD_MODE_THINGS,
CMD_MODE_LINEDEFS,
CMD_MODE_SECTORS,
CMD_MODE_VERTICES,
CMD_STATISTICS,
CMD_SECTORCLOSED,
CMD_SECTORCLOSED2,
CMD_XREF,
CMD_MISSINGTEX,
CMD_TEXNAMES,
CMD_CHECKALL,
CMD_CHECKALL2,
CMD_CHECKALLPWAD,
CMD_CHECKALLPWADP,
CMD_CHECKTEXPWAD,
CMD_TAG,
CMD_INSERT,
CMD_INSERTCLOSE,
CMD_INSERT_MENU,
CMD_NEXT,
CMD_NEXTJUMP,
CMD_NEXTSPC,
CMD_NEXTSPCJUMP,
CMD_PREV,
CMD_PREVJUMP,
CMD_PREVSPC,
CMD_PREVSPCJUMP,
CMD_PROP,
CMD_REDUCE,
CMD_COPYPROP,
CMD_PASTEPROP,
CMD_ROTATE,
CMD_ROTATE90L,
CMD_ROTATE90R,
CMD_ROTATE180,
CMD_MIRROR_H,
CMD_MIRROR_V,
CMD_DELJOIN,
CMD_MERGE,
CMD_JOIN,
CMD_SPLITSECTOR,
CMD_LINEDRAWATVERT,
CMD_LINESFROMVERTS,
CMD_DELETEUNUSED,
CMD_MAKEDOOR,
CMD_MAKELIFT,
CMD_DISTFLOOR,
CMD_DISTCEIL,
CMD_DISTLIGHT,
CMD_RAISEFLOOR8,
CMD_RAISECEIL8,
CMD_LOWERFLOOR8,
CMD_LOWERCEIL8,
CMD_RAISELIGHT,
CMD_LOWERLIGHT,
CMD_SELECTTHINGSINSECTORS,
CMD_SELECTLINESFROMSECTORS,
CMD_SELECTVERTFROMSECTORS,
CMD_SPLITLD,
CMD_SPLITLDSEC,
CMD_JOINSEC,
CMD_DELSD_JOINSEC,
CMD_FLIP,
CMD_SWAP,
CMD_DEL2ND,
CMD_ALIGNX1,
CMD_ALIGNX2,
CMD_ALIGNX3,
CMD_ALIGNX4,
CMD_ALIGNX5,
CMD_ALIGNX6,
CMD_ALIGNX7,
CMD_ALIGNX8,
CMD_ALIGNY,
CMD_UNSELECTONE,
CMD_UNSELECTTWO,
CMD_SELECTVERTICESFROMLINES,
CMD_RELOAD,
CMD_PRINT,
CMD_CLOSE,
CMD_FIND,
CMD_REPLACE,
CMD_SELECTALL,
CMD_COMPILE,
CMD_TAB,
CMD_NUMCOMMANDS
};
extern wxString CurrentConfig;
extern ConfigManager confman;
extern FConfigFile config;
extern CLevel * CurrentLevel;
class DirectorySaver
{
private:
wxString m_olddir;
wxString m_configkey;
const char * m_thisdir;
public:
const char * Dir() const { return m_thisdir; }
DirectorySaver(const char * key);
~DirectorySaver();
};
// Define a new frame
class ZEdFrame : public wxFrame
{
public:
wxStatusBar * m_statusbar;
wxToolBar * m_toolbar;
C2DMapview * m_view;
wxMenuBar * m_MainMenu;
wxMenu * m_ThingMenu;
wxMenu * m_VertexMenu;
wxMenu * m_SectorMenu;
wxMenu * m_LineMenu;
ThingBar * m_ThingBar;
LineBar * m_LineBar;
SectorBar * m_SectorBar;
VertexBar * m_VertexBar;
wxWindow * m_CurrentBar;
ZEdFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, const long style);
~ZEdFrame();
void InitToolBar(wxToolBar* toolBar);
bool ProcessEvent(wxEvent & event);
void OnSize(wxSizeEvent& event);
void OnAbout(wxCommandEvent& event);
void OnOpen(wxCommandEvent& event);
void OnSelectIWAD(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);
void OnClose(wxCloseEvent& event);
void SetStatusBarText(const char * text);
void SetCoordinates(int x, int y);
void SetInfoBar(wxWindow * bar);
DECLARE_EVENT_TABLE()
};
class ZEdApp : public wxApp
{
ZEdFrame * frame;
public:
bool OnInit();
int OnExit();
void LoadConfig();
void SaveConfig();
ZEdFrame * GetFrame() const { return frame; }
};
DECLARE_APP(ZEdApp)
class SpinCtrlWithModify : public wxSpinCtrl
{
bool ismodified;
public:
SpinCtrlWithModify(wxWindow* parent, wxWindowID id = -1, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_ARROW_KEYS, int _min = 0, int _max = 100, int initial = 0, const wxString& name = _T("wxSpinCtrl"))
: wxSpinCtrl(parent, id, value, pos, size, style, _min, _max, initial, name), ismodified(0)
{
}
bool IsModified() const { return ismodified; }
virtual bool ProcessEvent(wxEvent& event);
};
enum
{
S_CONTROL=1,
S_SHIFT=2,
S_ALT=4
};
enum
{
MODE_2D,
MODE_3D
};
int GetCommandFromKey(int mode, int vk, int shift);
void SetDefaultBindings();
void RefreshAccelerator(int command);
// Global functions to invoke the various dialogs.
// This way I can keep the class definitions local to the implementation
QWORD RunWADManager(wxWindow * parent);
wxString RunWADLibrary(wxWindow * parent);
void RunIWADSelect(wxWindow * parent);
bool GetRotation(wxWindow * parent, wxRealPoint * res);
bool Get2Numbers(wxWindow * parent, const char * caption, const char * t1, const char * t2, int min1, int max1, int min2, int max2, wxPoint * res);
bool Get2Floats(wxWindow * parent, const char * caption, const char * t1, const char * t2, double min1, double max1, double min2, double max2, wxRealPoint * res);
bool GetGrid(wxWindow * parent, wxPoint * res);
void DisplayText(wxWindow * parent, const char * caption, wxString text);
int GetGenericType(wxWindow * parent, int initial, int which);
int EditThing(wxWindow * parent, CLevel * level, CThing * thing);
int EditLine(wxWindow * parent, CLevel * level, CLine * line);
int EditSector(wxWindow * parent, CLevel * level, CSector * sector);
int SelectTexture(wxWindow * parent, tx_namespace nspace);
int GetSpecialArg(wxWindow * parent, int value, const wxString & name);
inline wxPen * GetPen(wxColour & color, int width = 1, int style = wxSOLID)
{
return wxThePenList->FindOrCreatePen(color, width, style);
}
inline unsigned ComputeDist( int dx, int dy)
{
return (unsigned) (hypot( (double) dx, (double) dy) + 0.5);
}
inline double ComputeDist(double dx, double dy)
{
return hypot( dx, dy);
}
double distance(double x1, double y1, double x2, double y2);
double distance_to_line(double x1, double y1, double x2, double y2, double vx, double vy);
bool determine_line_side(float x1, float y1, float x2, float y2, float x, float y);
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif