summaryrefslogtreecommitdiff
path: root/editgui.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2011-06-09 13:57:32 +0000
committerIan C <ianc@noddybox.co.uk>2011-06-09 13:57:32 +0000
commit0f12083fdb14ae813e419500918b95cb83070586 (patch)
tree93f855836faede895a4c37d12dcc46a8c5fbb835 /editgui.c
Added copies of old numbered releases.0.01
Diffstat (limited to 'editgui.c')
-rw-r--r--editgui.c470
1 files changed, 470 insertions, 0 deletions
diff --git a/editgui.c b/editgui.c
new file mode 100644
index 0000000..afb922d
--- /dev/null
+++ b/editgui.c
@@ -0,0 +1,470 @@
+/*
+
+ 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 <stdarg.h>
+
+#define TXTPMT(lr,ulm) "Pick " ulm " texture for " lr " sidedef"
+
+
+/* ---------------------------------------- GUI FUNCTIONS
+*/
+int GetTexture(char *t,DirName d)
+{
+ int f;
+
+ 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;
+
+ 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)
+
+{
+ TRACE;
+
+ if (set_class)
+ {
+ 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)
+{
+ TRACE;
+
+ 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;
+
+ 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;
+
+ 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));
+}
+
+
+/* END OF FILE */