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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
|
/*
viDOOM - level editor for DOOM
Copyright (C) 2000 Ian Cowburn (ianc@noddybox.demon.co.uk)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------
Editor global variable definitions
$Id$
*/
#ifndef _EDITVAR_H
#define _EDITVAR_H
#include "things.h"
#include "linedefs.h"
#include "wad.h"
#include "map.h"
#include "list.h"
#include "platgui.h"
#include "gui.h"
#include "mem.h"
#define MAXLEN 1024
/* ---------------------------------------- EDIT COLOURS
*/
#define GRIDCOL V_RGB(0x20,0x20,0x80)
#define LINECOL V_RGB(0xa0,0x9a,0x90)
#define SECTCOL V_RGB(0xc0,0x00,0x00)
#define VERTCOL V_RGB(0xff,0xff,0xff)
#define VERTBOXCOL V_RGB(0x60,0x60,0x60)
#define THINGCOL V_RGB(0xa0,0x10,0x10)
#define SELCOL V_RGB(0xff,0xff,0x00)
#define OVERCOL V_RGB(0xc0,0xc0,0x00)
#define TAGCOL V_RGB(0xff,0xe0,0xe0)
/* ---------------------------------------- EDIT TYPES
*/
#define SECTOR_MODE 0
#define LINEDEF_MODE 1
#define VERTEX_MODE 2
#define THING_MODE 3
#define MULTI_MODE 4
#define NEXT_MODE(m) ((m == MULTI_MODE) ? SECTOR_MODE : m+1)
#define PREV_MODE(m) ((m == SECTOR_MODE) ? MULTI_MODE : m-1)
extern char *edit_str[];
#define SELECT_NONE 0
#define SELECT_OVER 1
#define SELECT_SELECTED 2
typedef struct
{
int x,y;
} Point;
/* Edittable types of the lumps from the WAD
*/
typedef struct
{
Vertex v;
List l;
} EditVert;
typedef struct
{
int no;
Linedef l;
Sidedef *sr;
Sidedef *sl;
EditVert *v[2];
int min_x;
int min_y;
int max_x;
int max_y;
} EditLine;
typedef struct
{
int no;
Sector s;
int min_x;
int min_y;
int max_x;
int max_y;
List v;
List sr;
List sl;
List all;
} EditSect;
typedef struct
{
Thing t;
} EditThing;
typedef struct
{
int type;
int i;
int x,y;
} MultiObj;
typedef struct
{
int select;
void *data;
} Object;
typedef struct
{
int no;
char detail[128];
} ObjDesc;
/* ---------------------------------------- EDIT VARS
*/
extern void HandleMoveKey(GFXKey k,int check_mouse);
extern int edit_mode;
extern Map vertex;
extern Map linedef;
extern Map sidedef;
extern Map sector;
extern Map thing;
extern Map multimap;
extern int SCRW;
extern int SCRH;
extern int FH;
extern int scale;
extern int ox;
extern int oy;
extern GFXMouse ms;
extern int quit;
extern int agrid;
extern int current;
extern List selected;
extern int new_selection;
extern Thing ed_thing;
extern int draw_current_info;
/* ---------------------------------------- USED AS GENERIC FUNCTIONS AND VALUES
*/
/* Data in all these functions is the Object.data pointer
*/
extern int (*PositionOnObject)(int x, int y, void *data);
extern void (*SelectBox)(int x1, int y1, int x2, int y2);
extern void (*SelectByType)(void);
extern void (*DrawObject)(void *data, int selmode);
extern void (*DrawObjectInfo)(void);
extern void (*DrawObjectHeader)(void);
extern void (*MoveObject)(void);
extern void (*RotateObject)(double angle);
extern void (*ScaleObject)(double scale);
extern void (*SetTagObject)(int tag);
extern void (*LocateObject)(void *obj);
extern void (*ObjectMenu)(void);
extern void (*ObjectInsert)(void);
extern void (*ObjectDelete)(void);
extern void (*ObjectKey)(GFXKey k);
extern int (*ObjectHasTag)(void *obj, int tag);
extern void (*SetSelect)(int i, int mode);
extern ObjDesc *(*ObjectOverlaid)(int x,int y,int *no);
extern char *typename;
extern Map map;
/* ---------------------------------------- MENUS AND DIALOGS
*/
#define GUI_CANCEL -666
#define TM_TYPE 0
#define TM_MOVE 1
#define TM_DELETE 2
#define TM_ANGLE 3
#define TM_FLAGS 4
#define TM_INSERT 5
#define TM_UPPER_T_R 6
#define TM_MIDDLE_T_R 7
#define TM_LOWER_T_R 8
#define TM_OFFSET_R 9
#define TM_UPPER_T_L 10
#define TM_MIDDLE_T_L 11
#define TM_LOWER_T_L 12
#define TM_OFFSET_L 13
#define TM_FLOOR 14
#define TM_CEILING 15
#define TM_LIGHT 16
#define TM_TAG 17
#define TM_FLOOR_T 18
#define TM_CEILING_T 19
#define TM_SECTOR_R 20
#define TM_SECTOR_L 21
#define TM_CHAIN 22
#define TM_CHAIN_SECTOR 23
#define TM_ALIGN_R 24
#define TM_ALIGN_L 25
#define TM_SWAP_SIDES 26
#define TM_SPLIT_LINE 27
#define TM_MERGE 28
#define TM_SNAP 29
#define TM_STYLE 30
#define TM_TRACK_LINE 31
#define TM_STEPS 32
#define TM_RIGHT_SIDE 33
#define TM_LEFT_SIDE 34
#define TM_ADJUST_R 35
#define TM_ADJUST_L 36
#define TM_ROTATE 37
#define TM_SCALE 38
extern PLAT_MENU thing_popup[];
extern PLAT_RADIO thing_angle[];
extern PLAT_MENU vertex_popup[];
extern PLAT_MENU right_popup[];
extern PLAT_MENU left_popup[];
extern PLAT_MENU linedef_popup[];
extern PLAT_MENU sector_popup[];
extern PLAT_MENU multi_popup[];
#define NO_FIELDS(x) (sizeof(x)/sizeof(x[0]))
#define D_OFFSET_NO 2
#define D_OFFSET_OFFX 0
#define D_OFFSET_OFFY 1
extern PLAT_DIALOG offset_dialog[D_OFFSET_NO];
#define D_SECTORN_NO 1
#define D_SECTORN_SECNO 0
extern PLAT_DIALOG sectorn_dialog[D_OFFSET_NO];
#define D_COORD_NO 2
#define D_COORD_X 0
#define D_COORD_Y 1
extern PLAT_DIALOG coord_dialog[D_COORD_NO];
#define D_VERTEX_NO 2
#define D_VERTEX_FROM 0
#define D_VERTEX_TO 1
extern PLAT_DIALOG vertex_dialog[D_VERTEX_NO];
#define D_SECTOR_FL_NO 1
#define D_SECTOR_FLOOR 0
extern PLAT_DIALOG sector_fl_dialog[D_SECTOR_FL_NO];
#define D_SECTOR_CE_NO 1
#define D_SECTOR_CEILING 0
extern PLAT_DIALOG sector_ce_dialog[D_SECTOR_CE_NO];
#define D_SECTOR_LI_NO 1
#define D_SECTOR_LIGHT 0
extern PLAT_DIALOG sector_li_dialog[D_SECTOR_LI_NO];
#define D_SECTOR_VAL_NO 3
#define D_SVAL_LIGHT 0
#define D_SVAL_FLOOR 1
#define D_SVAL_CEILING 2
extern PLAT_DIALOG sector_val_dialog[D_SECTOR_VAL_NO];
#define D_TAG_NO 1
#define D_TAG 0
extern PLAT_DIALOG tag_dialog[D_TAG_NO];
#define D_SCALE_NO 1
#define D_SCALE 0
extern PLAT_DIALOG scale_dialog[D_SCALE_NO];
#define D_ROTATE_NO 1
#define D_ROTATE 0
extern PLAT_DIALOG rotate_dialog[D_ROTATE_NO];
#define D_OBJNO_NO 1
#define D_OBJNO 0
extern PLAT_DIALOG objno_dialog[D_OBJNO_NO];
#define D_NOSIDES_NO 1
#define D_NOSIDES 0
extern PLAT_DIALOG nosides_dialog[D_NOSIDES_NO];
/* ---------------------------------------- DRAWING TABLES
*/
extern Point t_arrow[8];
extern char *angle_str[8];
#define ANGLESTR(a) (angle_str[(((a)+22)/45%8)])
/* ---------------------------------------- MACROS
*/
#define PI_VAL 3.14159265358979323846
#define RAD(a) (PI_VAL/180.0*(a))
#define XToMap(x) (ox+((x)*scale))
#define YToMap(y) (oy-((y)*scale))
#define MapToX(x) (((x)-ox)/scale)
#define MapToY(y) ((oy-(y))/scale)
#define MapRect(x,y,w,h,c) \
GFX_rect(MapToX(x),MapToY(y),(w)/scale,(h)/scale,c)
#define MapLine(x1,y1,x2,y2,c) \
GFX_line(MapToX(x1),MapToY(y1),MapToX(x2),MapToY(y2),c)
#define MapLineD(l,c) GFX_line(MapToX((l)->v[0]->v.x), \
MapToY((l)->v[0]->v.y), \
MapToX((l)->v[1]->v.x), \
MapToY((l)->v[1]->v.y),c)
#define MapPlot(x,y,c) GFX_plot(MapToX(x),MapToY(y),c)
#define MapCircle(x,y,r,c) \
GFX_circle(MapToX(x),MapToY(y),(r)/scale,c)
#define BOXBOUND(tx,ty,x1,y1,x2,y2) \
(((tx)>=(x1))&&((tx)<=(x2))&&((ty)>=(y1))&&((ty)<=(y2)))
#define BOXBOUND_FUZZY(tx,ty,x1,y1,x2,y2,f) \
(((tx)>=(x1-(f)))&&((tx)<=(x2+(f)))&&((ty)>=(y1-(f)))&&((ty)<=(y2+(f))))
#define ROUGHLY(a,b) (((a)>=(b)-0.01)&&((a)<=(b)+0.01))
#define RADBOUND(tx,ty,x,y,r) \
(((tx)>=(x)-(r))&&((tx)<=(x)+(r))&& \
((ty)>=(y)-(r))&&((ty)<=(y)+(r)))
#define GETVERT(n) ((EditVert *)(((Object *)MapElem(vertex,(n)))->data))
#define VERTFROM(m,n) ((EditVert *)(((Object *)MapElem((m),(n)))->data))
#define GETLINE(n) ((EditLine *)(((Object *)MapElem(linedef,(n)))->data))
#define GETSIDE(n) ((Sidedef *)(((Object *)MapElem(sidedef,(n)))->data))
#define SIDEFROM(m,n) ((Sidedef *)(((Object *)MapElem((m),(n)))->data))
#define GETSECT(n) ((EditSect *)(((Object *)MapElem(sector,(n)))->data))
#define GETTHING(n) ((EditThing *)(((Object *)MapElem(thing,(n)))->data))
#define GETMULTI(n) ((MultiObj *)(((Object *)MapElem(multimap,(n)))->data))
#define YESNO(x) ((x) ? "Yes":"No")
/* ------------------------------ HELP PAGES
*/
extern char *general_help_keys[];
extern char *general_help_mouse;
extern char *mode_help[];
/* ------------------------------ FUNCTION PROTOTYPES FOR ALL EDIT ROUTINES
*/
void SectorCalcContaining(int no,EditSect *s);
void SectorCalcContainingAll(void);
int SnapX(int x);
int SnapY(int y);
int Len(int x1,int y1,int x2,int y2);
int LinesCross(int x1_1,int y1_1,int x1_2,int y1_2,
int x2_1,int y2_1,int x2_2,int y2_2);
int CalcTextureWidth(DirName u,DirName m,DirName l);
void LineCalcBounding(EditLine *l);
void SectorCalcBounding(EditSect *s);
int LineOnDisplay(EditLine *l);
int SectorOnDisplay(EditSect *s);
int PointOnDisplay(int x,int y,int r);
void DrawArrow(int x1,int y1,int x2,int y2,int c);
void DrawGrid(void);
void DrawMap(void);
void DrawHeader(void);
void FullRedraw(void);
void SetSelect_GENERIC(int i, int mode);
int TmpAddCurrent(void);
void ClearSelection(void);
void ClearSelectionLeaveCurrent(void);
void *SelHead(void);
int InIntList(List l, int i);
void IntListUniqAdd(List l, int i);
void IntListRm(List l, int i);
/* If set_class is TRUE then *type is set from the classes loaded in the
config file.
The floor and ceiling values are used to decide which if the lower, middle
and upper textures to ask for. If the selected linedef style is not two
sided these values are ignored anyway and only the middle one on the right
sidedef is requested.
*/
int GetLinedefValues(int set_class,
int r_floor,int l_floor,int r_ceiling,int l_ceiling,
int *type,int *flag,int *two,
DirName sr_upper,DirName sr_middle,DirName sr_lower,
DirName sl_upper,DirName sl_middle,DirName sl_lower);
/* This supercedes the above function when creating sectors.
THe floor, ceiling and light levels are in/out. The displayed dialog is
loaded with the values sent in and any changes are reflected on return.
The in_floor and in_ceiling values are used to decide which of the
lower, middle and upper textures set up. If the selected linedef style
is not two sided these values are ignored anyway and only the middle
one on the right sidedef is set to non-empty. When doing comparisons it
is assumed that the in_ values are on the left of the linedefs.
Note that for this routine rather than being individually requested the
linedef textures are obtained from the defined sector styles (unless there
are no sector styles). Style flags is also set to the flags for sector
style (unless there is no styles, in which case it's zero).
Note the the sector flags for the style indicating if just the inward
or outward facing sidedefs have the textures applied will be ignored, ie.
both the right and left texture values will have the style applied.
Returns FALSE if at any point the selections are cancelled.
*/
int GetSectorValues(int *line_type, int *line_flag, int *two_sided,
int *floor, int *ceiling, int *light,
int in_floor, int in_ceiling,
int *style_flags,
DirName floor_t, DirName ceiling_t,
DirName sr_upper, DirName sr_middle, DirName sr_lower,
DirName sl_upper, DirName sl_middle, DirName sl_lower);
void GenericCheckMouse(void);
int GetTexture(char *t,DirName d);
int GetFlat(char *t,DirName d);
int YesNo(char *fmt,...);
/* If draw is not NULL it will be used to draw the selection thing. Note that
the x an y coming into the draw will NOT be snapped. They can be updated
by the drawing mechanism if snapping is requried.
If key is not NULL any keys read will be passed to the key reoutine (after
being passed to HandleMoveKey()).
Finally if infobox is not NULL this function is used to draw the describing
infobox, rather than PickPoint()s default one. The prompt (p) PickPoint()
was called with will be passed to the infobox routine.
*/
int PickPoint(char *p,int *x,int *y,void (*draw)(int *x,int *y),
void (*key)(GFXKey k),
void (*infobox)(char *p));
void SetEditMode(int mode);
void HandleMoveKey(GFXKey k, int check_mouse);
void HandleKey(GFXKey k);
void HandleMouse(GFXMouse m);
void MergeWad(void);
void Rotate(int cx,int cy,int *x,int *y, double ang);
void Scale(int cx,int cy,int *x,int *y, double sc);
int PositionOnObject_VERTEX(int x,int y,void *data);
void SelectBox_VERTEX(int x1,int y1,int x2,int y2);
void SelectByType_VERTEX(void);
void DrawObject_VERTEX(void *data, int selmode);
void DrawObjectInfo_VERTEX(void);
void DrawObjectHeader_VERTEX(void);
void MoveObject_VERTEX(void);
void RotateObject_VERTEX(double angle);
void ScaleObject_VERTEX(double scale);
void SetTagObject_VERTEX(int tag);
void LocateObject_VERTEX(void *obj);
void ObjectInsert_VERTEX(void);
void ObjectDelete_VERTEX(void);
void ObjectMenu_VERTEX(void);
void ObjectKey_VERTEX(GFXKey k);
int ObjectHasTag_VERTEX(void *obj, int tag);
ObjDesc *ObjectOverlaid_VERTEX(int x,int y,int *no);
List TrackLinedef(int line_no);
void CheckMergeLinedef(EditVert *v);
int CreateNewLinedef(int from, int to,
int flags, int type, int tag, int two_sided,
int sr_ox, int sr_oy, int sr_sector,
DirName sr_upper, DirName sr_middle, DirName sr_lower,
int sl_ox, int sl_oy, int sl_sector,
DirName sl_upper, DirName sl_middle, DirName sl_lower);
int PositionOnObject_LINEDEF(int x,int y,void *data);
void SelectBox_LINEDEF(int x1,int y1,int x2,int y2);
void SelectByType_LINEDEF(void);
void DrawObject_LINEDEF(void *data, int selmode);
void DrawObjectInfo_LINEDEF(void);
void DrawObjectHeader_LINEDEF(void);
void MoveObject_LINEDEF(void);
void RotateObject_LINEDEF(double angle);
void ScaleObject_LINEDEF(double scale);
void SetTagObject_LINEDEF(int tag);
void LocateObject_LINEDEF(void *obj);
void ObjectInsert_LINEDEF(void);
void ObjectDelete_LINEDEF(void);
void ObjectMenu_LINEDEF(void);
void ObjectKey_LINEDEF(GFXKey k);
int ObjectHasTag_LINEDEF(void *obj, int tag);
ObjDesc *ObjectOverlaid_LINEDEF(int x,int y,int *no);
int PositionOnObject_THING(int x,int y,void *data);
void SelectBox_THING(int x1,int y1,int x2,int y2);
void SelectByType_THING(void);
void DrawObject_THING(void *data, int selmode);
void DrawObjectInfo_THING(void);
void DrawObjectHeader_THING(void);
void MoveObject_THING(void);
void RotateObject_THING(double angle);
void ScaleObject_THING(double scale);
void SetTagObject_THING(int tag);
void LocateObject_THING(void *obj);
void ObjectInsert_THING(void);
void ObjectDelete_THING(void);
void ObjectMenu_THING(void);
void ObjectKey_THING(GFXKey k);
int ObjectHasTag_THING(void *obj, int tag);
ObjDesc *ObjectOverlaid_THING(int x,int y,int *no);
/* Returns -1 if point not in a sector
*/
int SectorHoldingPoint(int x,int y);
/* Creates a sector for the list of vertex numbers, which is assumed to go
clockwise. Return is TRUE if operation completed, FALSE if cancelled.
*/
int CreateSector(List v);
int CreateUnboundSector(int special,int floor,int ceiling,int light,int tag,
DirName floor_t,DirName ceiling_t);
void SectorCalcContaining(int no,EditSect *s);
void SectorCalcContainingAll(void);
int PositionOnObject_SECTOR(int x,int y,void *data);
void SelectBox_SECTOR(int x1,int y1,int x2,int y2);
void SelectByType_SECTOR(void);
void DrawObject_SECTOR(void *data, int selmode);
void DrawObjectInfo_SECTOR(void);
void DrawObjectHeader_SECTOR(void);
void MoveObject_SECTOR(void);
void RotateObject_SECTOR(double angle);
void ScaleObject_SECTOR(double scale);
void SetTagObject_SECTOR(int tag);
void LocateObject_SECTOR(void *obj);
void ObjectInsert_SECTOR(void);
void ObjectDelete_SECTOR(void);
void ObjectMenu_SECTOR(void);
void ObjectKey_SECTOR(GFXKey k);
int ObjectHasTag_SECTOR(void *obj, int tag);
ObjDesc *ObjectOverlaid_SECTOR(int x,int y,int *no);
void GenerateMultiMap(void);
int PositionOnObject_MULTI(int x,int y,void *data);
void SelectBox_MULTI(int x1,int y1,int x2,int y2);
void SelectByType_MULTI(void);
void DrawObject_MULTI(void *data, int selmode);
void DrawObjectInfo_MULTI(void);
void DrawObjectHeader_MULTI(void);
void MoveObject_MULTI(void);
void RotateObject_MULTI(double angle);
void ScaleObject_MULTI(double scale);
void SetTagObject_MULTI(int tag);
void LocateObject_MULTI(void *obj);
void ObjectInsert_MULTI(void);
void ObjectDelete_MULTI(void);
void ObjectMenu_MULTI(void);
void ObjectKey_MULTI(GFXKey k);
int ObjectHasTag_MULTI(void *obj, int tag);
void SetSelect_MULTI(int i, int mode);
ObjDesc *ObjectOverlaid_MULTI(int x,int y,int *no);
#endif
/* END OF FILE */
|