/* 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 ------------------------------------------------------------------------- Handles definition and storage of the supported THINGS */ static const char rcs_id[]="$Id$"; #include "config.h" #include "globals.h" #include "platgui.h" #include "gfx.h" #include "linedefs.h" #include "mem.h" #include "list.h" #include "map.h" /* ---------------------------------------- TYPES AND VARS */ typedef struct { char *name; } LineClass; typedef struct { int class; int id; char *name; } LineInfo; typedef struct { char *name; int id; int two; } LineDefault; static int no_classes=0; static Map line_class=NULL; static List line_list=NULL; static Map line_def=NULL; static PLAT_PICKLIST **picklist=NULL; static PLAT_MENU *line_menu=NULL; static char *line_flags[17]= {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; static char line_flags_sh[16]= {'?','?','?','?','?','?','?','?', '?','?','?','?','?','?','?','?'}; static int line_flags_max=-1; static char **line_def_plist=NULL; /* ---------------------------------------- PRIVATE FUNCTIONS */ static PLAT_PICKLIST *LinedefPicklist(int class) { LineInfo *li; Iterator i; int no; int f; if (picklist[class]) return(picklist[class]); else { no=0; i=ListIterator(line_list); while(i) { li=IteratorData(i); if (li->class==class) no++; i=IteratorNext(i); } picklist[class]=Grab(sizeof(PLAT_PICKLIST)*(no+1)); i=ListIterator(line_list); f=0; while(i) { li=IteratorData(i); if (li->class==class) { picklist[class][f].text=li->name; picklist[class][f].client_index=li->id; f++; } i=IteratorNext(i); } picklist[class][f].text=NULL; return(picklist[class]); } } /* ---------------------------------------- EXPORTED FUNCTIONS */ void LinedefNewClass(char *class) { LineClass c; if (!line_class) line_class=MapNew(sizeof(LineClass)); c.name=Strdup(class); MapAdd(line_class,no_classes++,&c); } void LinedefAdd(char *class,char *name,int id) { LineInfo *li; int i_class; int f; if (!line_list) line_list=ListNew(sizeof(LineInfo)); i_class=-1; for(f=0;fname,class)) i_class=f; } if (i_class==-1) i_class=0; li=Grab(sizeof(LineInfo)); li->class=i_class; li->name=Strdup(name); li->id=id; ListAppend(line_list,li); } int SelectLinedef(void) { int class; int f; int x,y; if (!line_menu) { line_menu=Grab(sizeof(PLAT_MENU)*(no_classes+1)); picklist=Grab(sizeof(PLAT_PICKLIST *)*(no_classes+1)); for(f=0;fname; line_menu[f].client_index=f; } for(f=0;fid==id) { IteratorClear(i); return(li->name); } i=IteratorNext(i); } return("UNKNOWN"); } char *LinedefClass(int id) { LineInfo *li; LineClass *lc; Iterator i; if (no_classes==0) return("NO CLASSES!"); i=ListIterator(line_list); while(i) { li=IteratorData(i); if (li->id==id) { IteratorClear(i); lc=MapElem(line_class,li->class); return(lc->name); } i=IteratorNext(i); } return("UNKNOWN"); } void LinedefFlag(int bit,char *s,char sh) { line_flags[bit]=Strdup(s); line_flags_sh[bit]=sh; if (bit>line_flags_max) line_flags_max=bit; } char **LinedefFlagArray(void) { return(line_flags); } char *LinedefFlagText(int flags) { static char s[32]; int b; char *p; s[0]=0; p=s; for(b=line_flags_max;b>=0;b--) { if (flags&(1<name; } line_def_plist[MapSize(line_def)]=NULL; } f=GUI_picklist("LINEDEF TYPE",line_def_plist); if (f!=-1) { l=MapElem(line_def,f); *flag=l->id; *two=l->two; return(TRUE); } else return(FALSE); } /* END OF FILE */