summaryrefslogtreecommitdiff
path: root/editvar.c
blob: 7ed4cb9140873d5f1cc6c43e23264a35afac1708 (plain)
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
/*

    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 varaiable definitions

    Note that the lindefs, vertices, etc here are copied from the WadMap
    loaded prior to editting.  They are then reconverted back to the WadMap
    for saving.


*/
static const char rcs_id[]="$Id$";

#include "config.h"
#include "globals.h"

#include "editvar.h"


/* ---------------------------------------- EDIT TYPES
*/

char		*edit_str[]={"Sector","Linedef","Vertex","Thing","Multimode"};


/* ---------------------------------------- EDIT VARS
*/

void		HandleMoveKey(GFXKey k,int check_mouse);

int		edit_mode=SECTOR_MODE;

Map		vertex=NULL;
Map		linedef=NULL;
Map		sidedef=NULL;
Map		sector=NULL;
Map		thing=NULL;
Map		multimap=NULL;
char		*mapinfo=NULL;
int		hexen_mode=FALSE;

char		*behavior=NULL;
int		behavior_size=0;
char		*scripts=NULL;
int		scripts_size=0;

int		SCRW;
int		SCRH;
int		FH;

int		scale=5;
int		ox;
int		oy;

GFXMouse	ms;

int		quit;

int		agrid;

int		current=-1;
List		selected=NULL;

/* This variable should be set to try by any actions in the generic object
   routines that have generated a new selection list.
*/
int		new_selection=FALSE;

/* Hardcoded values!!! Remove sometime
*/
Thing		ed_thing={0,0,0,1,0x07,0,0,0,{0,0,0,0,0}};

/* This variable stops the DrawObjectInfo() routine being called on redraws
*/
int		draw_current_info=TRUE;

/* ---------------------------------------- USED AS GENERIC FUNCTIONS AND VALUES
*/

/* Data in all these functions is the Object.data pointer
*/
int		(*PositionOnObject)(int x, int y, void *data);
void		(*SelectBox)(int x1, int y1, int x2, int y2);
void		(*SelectByType)(void);
void		(*DrawObject)(void *data, int selmode);
void		(*DrawObjectInfo)(void);
void		(*DrawObjectHeader)(void);
void		(*MoveObject)(void);
void		(*RotateObject)(double angle);
void		(*ScaleObject)(double scale);
void		(*SetTagObject)(int tag);
void		(*LocateObject)(void *obj);
void		(*ObjectMenu)(void);
void		(*ObjectInsert)(void);
void		(*ObjectDelete)(void);
void		(*ObjectKey)(GFXKey k);
int		(*ObjectHasTag)(void *obj, int tag);
void		(*SetSelect)(int i, int mode);
ObjDesc		*(*ObjectOverlaid)(int x,int y,int *no);

char		*typename;
Map		map;


/* ---------------------------------------- MENUS AND DIALOGS
*/
PLAT_MENU	thing_popup[]={
				{"Change type",TM_TYPE,NULL},
				{"Set type to value",TM_VAL,NULL},
				{"Change flags",TM_FLAGS,NULL},
				{"Change angle",TM_ANGLE,NULL},
				{"Snap selected things",TM_SNAP,NULL},
				{"Move",TM_MOVE,NULL},
				{"Delete",TM_DELETE,NULL},
				{NULL,GUI_CANCEL,NULL}
			      };

PLAT_MENU	thing_popup_hexen[]={
				{"Change type",TM_TYPE,NULL},
				{"Set type to value",TM_VAL,NULL},

				{"Change special action",TM_SPECIAL,NULL},
				{"Set special action to value",
							TM_SPECIAL_VAL,NULL},
				{"Change special action args",TM_ARGS,NULL},
				{"Clear special action args to zero",
								TM_ZERO,NULL},
				{"Set ranged special args",TM_ARGS_RANGE,NULL},
				{"Change flags",TM_FLAGS,NULL},
				{"Change angle",TM_ANGLE,NULL},
				{"Change angle to value",TM_ANGLE_VAL,NULL},
				{"Set Z postion",TM_Z_POS,NULL},
				{"Set thing ID",TM_THING_ID,NULL},
				{"Snap",TM_SNAP,NULL},
				{"Move",TM_MOVE,NULL},
				{"Delete",TM_DELETE,NULL},
				{NULL,GUI_CANCEL,NULL}
			      };

PLAT_MENU	vertex_popup[]={
				{"Chain selected vertices",TM_CHAIN,NULL},
				{"Chain selected vertices "
				    "into a sector",TM_CHAIN_SECTOR,NULL},
				{"Merge selected vertices",TM_MERGE,NULL},
				{"Snap",TM_SNAP,NULL},
				{"Move",TM_MOVE,NULL},
				{"Delete",TM_DELETE,NULL},
				{NULL,GUI_CANCEL,NULL}
			       };

PLAT_MENU	right_popup[]=
		    {
			{"Change upper texture",TM_UPPER_T_R,NULL},
			{"Change middle texture",TM_MIDDLE_T_R,NULL},
			{"Change lower texture",TM_LOWER_T_R,NULL},
			{"Change textures to any value",TM_TEXTURES_R},
			{"Change texture offset",TM_OFFSET_R,NULL},
			{"Adjust texture offset",TM_ADJUST_R,NULL},
			{"Change sector",TM_SECTOR_R,NULL},
			{"Align textures",TM_ALIGN_R,NULL},

			{NULL,GUI_CANCEL,NULL}
		    };

PLAT_MENU	left_popup[]=
		    {
			{"Change upper texture",TM_UPPER_T_L,NULL},
			{"Change middle texture",TM_MIDDLE_T_L,NULL},
			{"Change lower texture",TM_LOWER_T_L,NULL},
			{"Change textures to any value",TM_TEXTURES_L},
			{"Change texture offset",TM_OFFSET_L,NULL},
			{"Adjust texture offset",TM_ADJUST_L,NULL},
			{"Change sector",TM_SECTOR_L,NULL},
			{"Align textures",TM_ALIGN_L,NULL},

			{NULL,GUI_CANCEL,NULL}
		    };

PLAT_MENU	linedef_popup[]=
		    {
			{"Change linedef type",TM_TYPE,NULL},
			{"Set generalised linedef type",TM_GEN_TYPE,NULL},
			{"Set type to value",TM_VAL,NULL},
			{"Change linedef flags",TM_FLAGS,NULL},
			{"Swap sides",TM_SWAP_SIDES,NULL},
			{"Split line",TM_SPLIT_LINE,NULL},
			{"Select trail from this linedef",TM_TRACK_LINE,NULL},
			{"Join linedefs with steps",TM_STEPS,NULL},

			{"Right sidedef",0,right_popup},
			{"Left sidedef",0,left_popup},

			{"Change tag",TM_TAG,NULL},
			{"Move",TM_MOVE,NULL},
			{"Delete",TM_DELETE,NULL},
			{NULL,GUI_CANCEL,NULL}
		    };

PLAT_MENU	linedef_popup_hexen[]=
		    {
			{"Change special action",TM_SPECIAL,NULL},
			{"Set special action to value",TM_VAL,NULL},
			{"Change special action args",TM_ARGS,NULL},
			{"Clear special action args to zero",TM_ZERO,NULL},
			{"Set ranged special args",TM_ARGS_RANGE,NULL},
			{"Change linedef flags",TM_FLAGS,NULL},
			{"Swap sides",TM_SWAP_SIDES,NULL},
			{"Split line",TM_SPLIT_LINE,NULL},
			{"Select trail from this linedef",TM_TRACK_LINE,NULL},
			{"Join linedefs with steps",TM_STEPS,NULL},

			{"Right sidedef",0,right_popup},
			{"Left sidedef",0,left_popup},

			{"Move",TM_MOVE,NULL},
			{"Delete",TM_DELETE,NULL},
			{NULL,GUI_CANCEL,NULL}
		    };

PLAT_MENU	sector_popup[]=
		    {
			{"Change type",TM_TYPE,NULL},
			{"Change generalised type",TM_GEN_TYPE,NULL},
			{"Set type to value",TM_VAL,NULL},
			{"Change floor height",TM_FLOOR,NULL},
			{"Change ceiling height",TM_CEILING,NULL},
			{"Change light level",TM_LIGHT,NULL},
			{"Change tag",TM_TAG,NULL},
			{"Change floor",TM_FLOOR_T,NULL},
			{"Change ceiling",TM_CEILING_T,NULL},
			{"Paint sector in style",TM_STYLE,NULL},

			{"Move",TM_MOVE,NULL},
			{"Delete",TM_DELETE,NULL},
			{NULL,GUI_CANCEL,NULL}
		    };

PLAT_MENU	multi_popup[]=
		    {
			{"Snap",TM_SNAP,NULL},
			{"Rotate",TM_ROTATE,NULL},
			{"Scale",TM_SCALE,NULL},
			{"Move",TM_MOVE,NULL},
			{NULL,GUI_CANCEL,NULL}
		    };


PLAT_RADIO	thing_angle[]={
				{"N",90},
				{"NE",45},
				{"E",0},
				{"SE",315},
				{"S",270},
				{"SW",225},
				{"W",180},
				{"NW",135},
				{NULL,GUI_CANCEL}
			      };

PLAT_DIALOG	offset_dialog[D_OFFSET_NO]=
				{
				    {"X-offset",PLAT_DIAL_INTEGER,{0}},
				    {"Y-offset",PLAT_DIAL_INTEGER,{0}}
				};

PLAT_DIALOG	sectorn_dialog[D_OFFSET_NO]=
				{
				    {"Sector no",PLAT_DIAL_INTEGER,{0}},
				};

PLAT_DIALOG	coord_dialog[D_COORD_NO]=
				{
				    {"X",PLAT_DIAL_INTEGER,{0}},
				    {"Y",PLAT_DIAL_INTEGER,{0}}
				};

PLAT_DIALOG	vertex_dialog[D_VERTEX_NO]=
				{
				    {"Vertex from",PLAT_DIAL_INTEGER,{0}},
				    {"Vertex to",PLAT_DIAL_INTEGER,{0}}
				};

PLAT_DIALOG	sector_fl_dialog[D_SECTOR_FL_NO]=
				{
				    {"Floor height",PLAT_DIAL_INTEGER,{0}},
				};

PLAT_DIALOG	sector_ce_dialog[D_SECTOR_CE_NO]=
				{
				    {"Ceiling height",PLAT_DIAL_INTEGER,{0}},
				};

PLAT_DIALOG	sector_li_dialog[D_SECTOR_LI_NO]=
				{
				    {"Light level",PLAT_DIAL_INTEGER,{0}},
				};

PLAT_DIALOG	sector_val_dialog[D_SECTOR_VAL_NO]=
				{
				    {"Light level",PLAT_DIAL_INTEGER,{0}},
				    {"Floor height",PLAT_DIAL_INTEGER,{0}},
				    {"Ceiling height",PLAT_DIAL_INTEGER,{0}},
				};

PLAT_DIALOG	tag_dialog[D_TAG_NO]=
				{
				    {"Tag",PLAT_DIAL_INTEGER,{0}},
				};

PLAT_DIALOG	scale_dialog[D_SCALE_NO]=
				{
				    {"Scale",PLAT_DIAL_DOUBLE,{0}},
				};

PLAT_DIALOG	rotate_dialog[D_ROTATE_NO]=
				{
				    {"Angle",PLAT_DIAL_DOUBLE,{0}},
				};

PLAT_DIALOG	objno_dialog[D_OBJNO_NO]=
				{
				    {"Object number",PLAT_DIAL_INTEGER,{0}},
				};

PLAT_DIALOG	nosides_dialog[D_NOSIDES_NO]=
				{
				    {"Number of sides",PLAT_DIAL_INTEGER,{0}},
				};

PLAT_DIALOG      zcoord_dialog[D_COORD_NO]=
				{
				    {"Z co-ord",PLAT_DIAL_INTEGER,{0}},
				};


PLAT_DIALOG	l_range_dialog[D_L_RANGE_NO]=
				{
				    {"Starting light level",
				    		PLAT_DIAL_INTEGER,{0}},
				    {"Minimum light level",
				    		PLAT_DIAL_INTEGER,{0}},
				    {"Maximum light level",
				    		PLAT_DIAL_INTEGER,{0}},
				    {"Lighting adjustment",
				    		PLAT_DIAL_INTEGER,{0}},
				    {"Pulse",PLAT_DIAL_PICKLIST,{0}},
				};

PLAT_DIALOG	textures_dialog[D_TEXTURES_NO]=
				{
				    {"Upper",PLAT_DIAL_STRING,{0}},
				    {"Middle",PLAT_DIAL_STRING,{0}},
				    {"Lower",PLAT_DIAL_STRING,{0}},
				};


/* Generic yes/no dialog picklist array
*/
char 		*edit_dial_picklist_yes_no[2]={"No","Yes"};



/* ---------------------------------------- DRAWING TABLES
*/
Point		t_arrow[8]={{1,0},
			    {1,1},
			    {0,1},
			    {-1,1},
			    {-1,0},
			    {-1,-1},
			    {0,-1},
			    {1,-1}};

char		*angle_str[8]={"E","NE","N","NW","W","SW","S","SE"};


/* ---------------------------------------- HELP PAGES
*/
char		*general_help_keys[]=
		    {
		    "F1                  - general help                   |"
		    "F2                  - edit mode help                 |"
		    "Escape              - finish editting                |"
		    "Cursor keys         - move                           |"
		    "Shift + Cursor keys - move quickly                   |"
		    "Ctrl + Cursor keys  - move by one scale position     |"
		    "Page down/up        - zoom in/out                    |"
		    "Q/W                 - decrease/increase grid scale   |"
		    "G                   - grid lines on/off              |"
		    "X                   - grid snap on/off               |"
		    "Tab/Shift + Tab     - next/previous edit mode        |"
		    "V                   - VERTEX edit mode               |"
		    "L                   - LINEDEF edit mode              |"
		    "S                   - SECTOR edit mode               |"
		    "T                   - THING edit mode                |"
		    "C                   - MULTI edit mode                |"
		    "F9                  - deselect all                   |"
		    "Shift + F9          - invert selection               |"
		    "F10                 - select all                     |"
		    "Shift + F10         - select by type (if applicable) |"
		    "Ctrl + F10          - select one from a number of    |"
		    "                      overlaid objects               |"
		    "Alt + F10           - additionally select one        |"
		    "                      overlaid object                |"
		    "F11/Shift + F11     - locate next/previous selection ",

		    "Insert              - insert new object              |"
		    "Delete              - delete selected objects        |"
		    "Home                - LUMP menu (ZDoom only)         |"
		    "F3                  - merge a PWAD map               |"
		    "F4                  - move selected objects          |"
		    "F5                  - rotate selected objects        |"
		    "[                   - rotate 5 degrees left          |"
		    "]                   - rotate 5 degrees right         |"
		    "F6                  - scale selected objects         |"
		    "{                   - scale by 90%                   |"
		    "}                   - scale by 110%                  |"
		    "F7                  - set tag (if applicable)        |"
		    "Shift + F7          - select objects with tag        |"
		    "F8                  - locate by object number        |"
		    "Shift + F8          - locate and select object number|"
		    "R                   - redraw [useful if selected     |"
		    "                      sectors look unselected]       |"
		    "                                                     |"
		    "Note: Grid lock not honoured on rotate or scale      ",

		    NULL
		    };

char		*general_help_mouse=
	"Left button                - select object                     |"
	"Ctrl + Left button         - additionally select object        |"
	"Shift + Left button        - select objects in box             |"
	"Ctrl + Shift + Left button - additionally select objects in box|"
	"Right button               - pop-up object menu                |"
	"Middle button              - move selected objects             ";

char		*mode_help[]=
		    {
			/* SECTOR
			*/
			"M     - change sector move mode      |"
			"H     - toggle SECTOR tag highligting|"
			",     - decrease sector floor by 8   |"
			".     - increase sector floor by 8   |"
			"<     - decrease sector ceiling by 8 |"
			">     - increase sector ceiling by 8 |"
			"-     - decrease lighting level by 16|"
			"+     - increase lighting level by 16",

			/* LINEDEF
			*/
			"H     - toggle LINEDEF tag highligting     |"
			"F12   - perform checks for LINEDEF textures",

			/* VERTEX
			*/
			"F12   - remove vertices to bound to linedefs",

			/* THING
			*/
			",     - rotate THINGs angle anti-clockwise     |"
			".     - rotate THINGs angle clockwise          |"
			"<     - decrement THING Z co-ord (Hexen only)  |"
			">     - increment THING Z co-ord (Hexen only)  ",

			/* MULTI
			*/
			"No additional key functions"
		    };


/* END OF FILE */