/* 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; /* ---------------------------------------- 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 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 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); 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); 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); /* 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); 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); #endif /* END OF FILE */