diff options
author | Ian C <ianc@noddybox.co.uk> | 2011-06-09 13:46:28 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2011-06-09 13:46:28 +0000 |
commit | a9022b5972dc49d86f617a27940fafe9c4d0e7e7 (patch) | |
tree | 61405aa4ade91ed1057f863ddf118ceb38e14f8e /editgui.c |
Initial import of (very old) vidoom sources.
Diffstat (limited to 'editgui.c')
-rw-r--r-- | editgui.c | 519 |
1 files changed, 519 insertions, 0 deletions
diff --git a/editgui.c b/editgui.c new file mode 100644 index 0000000..c5f8e58 --- /dev/null +++ b/editgui.c @@ -0,0 +1,519 @@ +/* + + 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 + + ------------------------------------------------------------------------- + + General editor GUI routines + +*/ +static const char rcs_id[]="$Id$"; + +#include "config.h" +#include "globals.h" + +#include "editvar.h" +#include "texture.h" +#include "sectors.h" +#include "specials.h" + +#include <stdarg.h> + +#define TXTPMT(lr,ulm) "Pick " ulm " texture for " lr " sidedef" + + +/* ---------------------------------------- GUI FUNCTIONS +*/ +int GetTexture(char *t,DirName d) +{ + int f; + + VIDOOM_TRACE; + + if ((f=GUI_image_picklist(t,texture_picklist,TXT_PICKDEFVAL)) + !=TXT_PICKDEFVAL) + { + strcpy(d,texture_picklist[f].text); + return(TRUE); + } + else + return(FALSE); +} + + +int GetFlat(char *t,DirName d) +{ + int f; + + VIDOOM_TRACE; + + if ((f=GUI_image_picklist(t,flat_picklist,TXT_PICKDEFVAL)) + !=TXT_PICKDEFVAL) + { + strcpy(d,flat_picklist[f].text); + return(TRUE); + } + else + return(FALSE); +} + + + +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) + +{ + VIDOOM_TRACE; + + if (set_class) + { + if (hexen_mode) + { + if ((*type=SelectSpecial())==SPECIAL_NULLID) + return(FALSE); + } + else + { + if ((*type=SelectLinedef())==LINEDEF_NULLID) + return(FALSE); + } + } + else + *type=0; + + if (ChooseLinedefType(flag,two)) + { + if (*two) + { + if (r_floor<l_floor) + { + if (!GetTexture(TXTPMT("RIGHT","LOWER"),sr_lower)) + return(FALSE); + } + else + strcpy(sr_lower,empty_texture); + + if (r_ceiling>l_ceiling) + { + if (!GetTexture(TXTPMT("RIGHT","UPPER"),sr_upper)) + return(FALSE); + } + else + strcpy(sr_upper,empty_texture); + + if (ask_middle_on_2sided) + { + if (!GetTexture(TXTPMT("RIGHT","MIDDLE"),sr_middle)) + return(FALSE); + } + else + strcpy(sr_middle,empty_texture); + + if (l_floor<r_floor) + { + if (!GetTexture(TXTPMT("LEFT","LOWER"),sl_lower)) + return(FALSE); + } + else + strcpy(sl_lower,empty_texture); + + if (l_ceiling>r_ceiling) + { + if (!GetTexture(TXTPMT("LEFT","UPPER"),sl_upper)) + return(FALSE); + } + else + strcpy(sl_upper,empty_texture); + + if (ask_middle_on_2sided) + { + if (!GetTexture(TXTPMT("LEFT","MIDDLE"),sl_middle)) + return(FALSE); + } + else + strcpy(sl_middle,empty_texture); + } + else + { + strcpy(sr_upper,empty_texture); + strcpy(sr_lower,empty_texture); + + if (!GetTexture("Pick MIDDLE texture for RIGHT sidedef",sr_middle)) + return(FALSE); + } + + return(TRUE); + } + + return(FALSE); +} + + +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) +{ + VIDOOM_TRACE; + + if (hexen_mode) + { + if ((*line_type=SelectSpecial())==SPECIAL_NULLID) + return(FALSE); + } + else + { + if ((*line_type=SelectLinedef())==LINEDEF_NULLID) + return(FALSE); + } + + sector_val_dialog[D_SVAL_LIGHT].data.i=*light; + sector_val_dialog[D_SVAL_FLOOR].data.i=*floor; + sector_val_dialog[D_SVAL_CEILING].data.i=*ceiling; + + if (!GUI_dialog("Values for sector",D_SECTOR_VAL_NO,sector_val_dialog)) + return(FALSE); + + *floor=sector_val_dialog[D_SVAL_FLOOR].data.i; + *ceiling=sector_val_dialog[D_SVAL_CEILING].data.i; + *light=sector_val_dialog[D_SVAL_LIGHT].data.i; + + if (!ChooseLinedefType(line_flag,two_sided)) + return(FALSE); + + if (NoSectorStyles()) + { + if (!ChooseSectorStyle(style_flags,sr_upper,sr_middle,sr_lower, + floor_t,ceiling_t)) + return(FALSE); + + if (*two_sided) + { + strcpy(sl_upper,sr_upper); + strcpy(sl_middle,sr_middle); + strcpy(sl_lower,sr_lower); + + if (*floor>=in_floor) + strcpy(sr_lower,empty_texture); + + if (*ceiling<=in_ceiling) + strcpy(sr_upper,empty_texture); + + if (!ask_middle_on_2sided) + strcpy(sr_middle,empty_texture); + + if (in_floor>=*floor) + strcpy(sl_lower,empty_texture); + + if (in_ceiling<=*ceiling) + strcpy(sl_upper,empty_texture); + + if (!ask_middle_on_2sided) + strcpy(sl_middle,empty_texture); + } + else + { + strcpy(sr_upper,empty_texture); + strcpy(sr_lower,empty_texture); + } + } + else + { + *style_flags=0; + + if (!GetFlat("Choose floor texture",floor_t)) + return(FALSE); + + if (!GetFlat("Choose ceiling texture",ceiling_t)) + return(FALSE); + + if (*two_sided) + { + if (*floor<in_floor) + { + if (!GetTexture(TXTPMT("RIGHT","LOWER"),sr_lower)) + return(FALSE); + } + else + strcpy(sr_lower,empty_texture); + + if (*ceiling>in_ceiling) + { + if (!GetTexture(TXTPMT("RIGHT","UPPER"),sr_upper)) + return(FALSE); + } + else + strcpy(sr_upper,empty_texture); + + if (ask_middle_on_2sided) + { + if (!GetTexture(TXTPMT("RIGHT","MIDDLE"),sr_middle)) + return(FALSE); + } + else + strcpy(sr_middle,empty_texture); + + if (in_floor<*floor) + { + if (!GetTexture(TXTPMT("LEFT","LOWER"),sl_lower)) + return(FALSE); + } + else + strcpy(sl_lower,empty_texture); + + if (in_ceiling>*ceiling) + { + if (!GetTexture(TXTPMT("LEFT","UPPER"),sl_upper)) + return(FALSE); + } + else + strcpy(sl_upper,empty_texture); + + if (ask_middle_on_2sided) + { + if (!GetTexture(TXTPMT("LEFT","MIDDLE"),sl_middle)) + return(FALSE); + } + else + strcpy(sl_middle,empty_texture); + } + else + { + strcpy(sr_upper,empty_texture); + strcpy(sr_lower,empty_texture); + + if (!GetTexture("Pick MIDDLE texture for RIGHT sidedef",sr_middle)) + return(FALSE); + } + } + + return(TRUE); +} + + +int PickPoint(char *p, int *x, int *y, void (*draw)(int *x,int *y), + void (*key)(GFXKey k), + void (*infobox)(char *p)) +{ + GFXEvent e; + int cx,cy; + int done; + int cancel; + + VIDOOM_TRACE; + + draw_current_info=FALSE; + FullRedraw(); + + done=FALSE; + cancel=FALSE; + + cx=XToMap(ms.x); + cy=YToMap(ms.y); + + GFX_set_XOR_mode(); + + if (draw) + draw(&cx,&cy); + else + { + cx=SnapX(cx); + cy=SnapY(cy); + GFX_line(0,MapToY(cy),SCRW-1,MapToY(cy),WHITE); + GFX_line(MapToX(cx),0,MapToX(cx),SCRH-1,WHITE); + } + + GFX_clear_XOR_mode(); + + if (infobox) + infobox(p); + else + GuiDrawInfoBox(p,GUI_FLUSH_RIGHT,GUI_FLUSH_LOWER,TRUE, + "Press button to select point|Press ESC to cancel"); + + GFX_redraw(); + + while(!done) + { + GFX_await_input_full(&e); + + switch(e.type) + { + case GFX_MOUSE_EVENT: + + GFX_set_XOR_mode(); + + if (draw) + draw(&cx,&cy); + else + { + GFX_line(0,MapToY(cy),SCRW-1,MapToY(cy),WHITE); + GFX_line(MapToX(cx),0,MapToX(cx),SCRH-1,WHITE); + } + + GFX_clear_XOR_mode(); + + memcpy(&ms,&e.mouse,sizeof(e.mouse)); + + if (ms.b) + { + done=TRUE; + GFX_bounce(); + } + + DrawHeader(); + cx=XToMap(ms.x); + cy=YToMap(ms.y); + + GFX_set_XOR_mode(); + + if (draw) + draw(&cx,&cy); + else + { + cx=SnapX(cx); + cy=SnapY(cy); + GFX_line(0,MapToY(cy),SCRW-1,MapToY(cy),WHITE); + GFX_line(MapToX(cx),0,MapToX(cx),SCRH-1,WHITE); + } + + GFX_clear_XOR_mode(); + + if (infobox) + infobox(p); + else + GuiDrawInfoBox(p,GUI_FLUSH_RIGHT,GUI_FLUSH_LOWER,TRUE, + "Press button to select point|Press ESC to cancel"); + + GFX_redraw(); + + break; + + case GFX_KEY_EVENT: + GFX_set_XOR_mode(); + + if (draw) + draw(&cx,&cy); + else + { + GFX_line(0,MapToY(cy),SCRW-1,MapToY(cy),WHITE); + GFX_line(MapToX(cx),0,MapToX(cx),SCRH-1,WHITE); + } + + GFX_clear_XOR_mode(); + + HandleMoveKey(e.key,FALSE); + cx=SnapX(XToMap(ms.x)); + cy=SnapY(YToMap(ms.y)); + + if (key) + key(e.key); + + GFX_set_XOR_mode(); + + if (draw) + draw(&cx,&cy); + else + { + GFX_line(0,MapToY(cy),SCRW-1,MapToY(cy),WHITE); + GFX_line(MapToX(cx),0,MapToX(cx),SCRH-1,WHITE); + } + + GFX_clear_XOR_mode(); + + if (infobox) + infobox(p); + else + GuiDrawInfoBox(p,GUI_FLUSH_RIGHT,GUI_FLUSH_LOWER,TRUE, + "Press button to select point|Press ESC to cancel"); + + GFX_redraw(); + + if (e.key.code==GFX_ESC) + { + done=TRUE; + cancel=TRUE; + } + + break; + + default: + break; + } + } + + draw_current_info=TRUE; + FullRedraw(); + + *x=cx; + *y=cy; + + return(!cancel); +} + + +int YesNo(char *fmt,...) +{ + static char s[512]; + va_list va; + + va_start(va,fmt); + vsprintf(s,fmt,va); + va_end(va); + + return(GUI_yesno(s)); +} + + +int YesNoAll(char *fmt,...) +{ + static char s[512]; + va_list va; + + va_start(va,fmt); + vsprintf(s,fmt,va); + va_end(va); + + return(GUI_yesno_all(s)); +} + + +int GetNumber(char *prompt, int *val) +{ + PLAT_DIALOG d[1]; + int ret; + + d[0].text="Value (prefix with 0x for hex)"; + d[0].type=PLAT_DIAL_STRING; + sprintf(d[0].data.s,"%d",*val); + + if ((ret=GUI_dialog(prompt,1,d))) + *val=ATOI(d[0].data.s); + + return(ret); +} + + +/* END OF FILE */ |