From a6e8cf77120ad2601b878278bc750fd695c6fbbd Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 27 Jan 1999 01:52:00 +0100 Subject: [PATCH] rnd-19990127-1 --- src/buttons.c | 12 +- src/buttons.h | 3 +- src/editor.c | 490 ++++++++++++++++++++++++++++++-------------------- src/files.c | 11 +- src/game.c | 12 +- src/main.h | 7 +- src/screens.c | 3 +- 7 files changed, 314 insertions(+), 224 deletions(-) diff --git a/src/buttons.c b/src/buttons.c index 9c19a36a..e63a2b2d 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -2273,14 +2273,19 @@ void RemapAllGadgets() MultiMapGadgets(MULTIMAP_ALL | MULTIMAP_REMAP); } -void ClickOnGadget(struct GadgetInfo *gi) +boolean anyTextGadgetActive() +{ + return (last_gi && last_gi->type & GD_TYPE_TEXTINPUT && last_gi->mapped); +} + +void ClickOnGadget(struct GadgetInfo *gi, int button) { /* simulate releasing mouse button over last gadget, if still pressed */ if (button_status) HandleGadgets(-1, -1, 0); /* simulate pressing mouse button over specified gadget */ - HandleGadgets(gi->x, gi->y, 1); + HandleGadgets(gi->x, gi->y, button); /* simulate releasing mouse button over specified gadget */ HandleGadgets(gi->x, gi->y, 0); @@ -2325,8 +2330,7 @@ void HandleGadgets(int mx, int my, int button) last_my = my; /* special treatment for text and number input gadgets */ - if (last_gi && last_gi->type & GD_TYPE_TEXTINPUT && last_gi->mapped && - button != 0 && !motion_status) + if (anyTextGadgetActive() && button != 0 && !motion_status) { struct GadgetInfo *gi = last_gi; diff --git a/src/buttons.h b/src/buttons.h index 9ef1acec..fcd23247 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -435,7 +435,8 @@ void UnmapGadget(struct GadgetInfo *); void UnmapAllGadgets(); void RemapAllGadgets(); -void ClickOnGadget(struct GadgetInfo *); +boolean anyTextGadgetActive(); +void ClickOnGadget(struct GadgetInfo *, int); void HandleGadgets(int, int, int); void HandleGadgetsKeyInput(KeySym); diff --git a/src/editor.c b/src/editor.c index a5a57ee9..067759db 100644 --- a/src/editor.c +++ b/src/editor.c @@ -94,21 +94,18 @@ #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \ ED_ELEMENTLIST_BUTTONS_VERT) -/* values for element properties window */ -#define ED_PROPERTIES_XPOS (TILEX - MINI_TILEX/2) - -/* values for level information window */ -#define ED_LEVELINFO_XPOS (TILEX - MINI_TILEX/2) -#define ED_LEVELINFO_YPOS (TILEY - MINI_TILEY/2) +/* values for the setting windows */ +#define ED_SETTINGS_XPOS MINI_TILEX +#define ED_SETTINGS_YPOS MINI_TILEY +#define ED_SETTINGS2_YPOS (ED_SETTINGS_YPOS + 12 * TILEY) /* values for counter gadgets */ -#define ED_COUNT_VALUE_XOFFSET 5 -#define ED_COUNT_VALUE_YOFFSET 3 -#define ED_COUNT_ELEM_SCORE_XPOS ED_PROPERTIES_XPOS +#define ED_COUNT_ELEM_SCORE_XPOS ED_SETTINGS_XPOS #define ED_COUNT_ELEM_SCORE_YPOS (14 * MINI_TILEY) -#define ED_COUNT_ELEM_CONTENT_XPOS ED_PROPERTIES_XPOS +#define ED_COUNT_ELEM_CONTENT_XPOS ED_SETTINGS_XPOS #define ED_COUNT_ELEM_CONTENT_YPOS (17 * MINI_TILEY) -#define ED_COUNTER_YSTART (ED_LEVELINFO_YPOS + 3 * TILEY) + +#define ED_COUNTER_YSTART (ED_SETTINGS_YPOS + 2 * TILEY) #define ED_COUNTER_YDISTANCE (3 * MINI_TILEY) #define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \ n * ED_COUNTER_YDISTANCE) @@ -150,13 +147,13 @@ #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS -#define ED_CHECKBUTTON_UNCHECKED_YPOS ED_BUTTON_MINUS_YPOS +#define ED_CHECKBUTTON_UNCHECKED_YPOS (ED_BUTTON_MINUS_YPOS + 22) #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS -#define ED_CHECKBUTTON_CHECKED_YPOS ED_BUTTON_PLUS_YPOS +#define ED_CHECKBUTTON_CHECKED_YPOS (ED_BUTTON_PLUS_YPOS + 22) -/* control button identifiers */ #define GADGET_ID_NONE -1 +/* drawing toolbox buttons */ #define GADGET_ID_SINGLE_ITEMS 0 #define GADGET_ID_CONNECTED_ITEMS 1 #define GADGET_ID_LINE 2 @@ -238,11 +235,12 @@ #define GADGET_ID_ELEMENTLIST_FIRST 66 #define GADGET_ID_ELEMENTLIST_LAST 105 -/* checkbuttons for level settings */ +/* buttons for level settings */ #define GADGET_ID_RANDOM_PERCENTAGE 106 #define GADGET_ID_RANDOM_QUANTITY 107 +#define GADGET_ID_DOUBLE_SPEED 108 -#define NUM_EDITOR_GADGETS 108 +#define NUM_EDITOR_GADGETS 109 /* radio button numbers */ #define RADIO_NR_NONE 0 @@ -254,10 +252,13 @@ #define ED_COUNTER_ID_ELEM_CONTENT 1 #define ED_COUNTER_ID_LEVEL_XSIZE 2 #define ED_COUNTER_ID_LEVEL_YSIZE 3 -#define ED_COUNTER_ID_LEVEL_RANDOM 4 -#define ED_COUNTER_ID_LEVEL_COLLECT 5 -#define ED_COUNTER_ID_LEVEL_TIMELIMIT 6 -#define ED_COUNTER_ID_LEVEL_TIMESCORE 7 +#define ED_COUNTER_ID_LEVEL_COLLECT 4 +#define ED_COUNTER_ID_LEVEL_TIMELIMIT 5 +#define ED_COUNTER_ID_LEVEL_TIMESCORE 6 +#define ED_COUNTER_ID_LEVEL_RANDOM 7 + +#define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE +#define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM #define ED_NUM_COUNTERBUTTONS 8 @@ -281,13 +282,21 @@ #define ED_TEXTINPUT_ID_LEVEL_NAME 0 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1 +#define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME +#define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR + #define ED_NUM_TEXTINPUT 2 /* values for checkbutton gadgets */ -#define ED_CHECKBUTTON_PERCENTAGE 0 -#define ED_CHECKBUTTON_QUANTITY 1 +#define ED_CHECKBUTTON_DOUBLE_SPEED 0 -#define ED_NUM_CHECKBUTTONS 2 +#define ED_NUM_CHECKBUTTONS 1 + +/* values for radiobutton gadgets */ +#define ED_RADIOBUTTON_PERCENTAGE 0 +#define ED_RADIOBUTTON_QUANTITY 1 + +#define ED_NUM_RADIOBUTTONS 2 /* values for CopyLevelToUndoBuffer() */ #define UNDO_IMMEDIATE 0 @@ -347,7 +356,7 @@ static struct int gadget_id_down, gadget_id_up; int gadget_id_text; int **counter_value; - char *infotext; + char *infotext_above, *infotext_right; } counterbutton_info[ED_NUM_COUNTERBUTTONS] = { { @@ -356,7 +365,7 @@ static struct GADGET_ID_ELEM_SCORE_DOWN, GADGET_ID_ELEM_SCORE_UP, GADGET_ID_ELEM_SCORE_TEXT, &gadget_elem_score_value, - "element score" + "element score", NULL }, { ED_COUNT_ELEM_CONTENT_XPOS, ED_COUNT_ELEM_CONTENT_YPOS, @@ -364,55 +373,55 @@ static struct GADGET_ID_ELEM_CONTENT_DOWN, GADGET_ID_ELEM_CONTENT_UP, GADGET_ID_ELEM_CONTENT_TEXT, &gadget_elem_content_value, - "element content" + "element content", NULL }, { - ED_LEVELINFO_XPOS, ED_COUNTER_YPOS(0), + ED_SETTINGS_XPOS, ED_COUNTER_YPOS(2), MIN_LEV_FIELDX, MAX_LEV_FIELDX, GADGET_ID_LEVEL_XSIZE_DOWN, GADGET_ID_LEVEL_XSIZE_UP, GADGET_ID_LEVEL_XSIZE_TEXT, &gadget_level_xsize_value, - "playfield width" + "playfield size", "width", }, { - ED_LEVELINFO_XPOS, ED_COUNTER_YPOS(1), + ED_SETTINGS_XPOS + 2 * DXSIZE, ED_COUNTER_YPOS(2), MIN_LEV_FIELDY, MAX_LEV_FIELDY, GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP, GADGET_ID_LEVEL_YSIZE_TEXT, &gadget_level_ysize_value, - "playfield height" - }, - { - ED_LEVELINFO_XPOS, ED_COUNTER_YPOS(2), - 1, 100, - GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP, - GADGET_ID_LEVEL_RANDOM_TEXT, - &gadget_level_random_value, - "random elements" + NULL, "height", }, { - ED_LEVELINFO_XPOS, ED_COUNTER_YPOS(3), + ED_SETTINGS_XPOS, ED_COUNTER_YPOS(3), 0, 999, GADGET_ID_LEVEL_COLLECT_DOWN, GADGET_ID_LEVEL_COLLECT_UP, GADGET_ID_LEVEL_COLLECT_TEXT, &gadget_level_collect_value, - "number of emeralds to collect" + "number of emeralds to collect", NULL }, { - ED_LEVELINFO_XPOS, ED_COUNTER_YPOS(4), + ED_SETTINGS_XPOS, ED_COUNTER_YPOS(4), 0, 999, GADGET_ID_LEVEL_TIMELIMIT_DOWN, GADGET_ID_LEVEL_TIMELIMIT_UP, GADGET_ID_LEVEL_TIMELIMIT_TEXT, &gadget_level_timelimit_value, - "time available to solve level" + "time available to solve level", "(0 => no time limit)" }, { - ED_LEVELINFO_XPOS, ED_COUNTER_YPOS(5), + ED_SETTINGS_XPOS, ED_COUNTER_YPOS(5), 0, 255, GADGET_ID_LEVEL_TIMESCORE_DOWN, GADGET_ID_LEVEL_TIMESCORE_UP, GADGET_ID_LEVEL_TIMESCORE_TEXT, &gadget_level_timescore_value, - "score for each 10 seconds left" + "score for each 10 seconds left", NULL + }, + { + ED_SETTINGS_XPOS, ED_COUNTER_YPOS(8), + 1, 100, + GADGET_ID_LEVEL_RANDOM_DOWN, GADGET_ID_LEVEL_RANDOM_UP, + GADGET_ID_LEVEL_RANDOM_TEXT, + &gadget_level_random_value, + "random elements", "in" } }; @@ -420,21 +429,24 @@ static struct { int x, y; int gadget_id; + int size; char *value; char *infotext; } textinput_info[ED_NUM_TEXTINPUT] = { { - ED_LEVELINFO_XPOS, ED_COUNTER_YPOS(6), + ED_SETTINGS_XPOS, ED_COUNTER_YPOS(0), GADGET_ID_LEVEL_NAME, + MAX_LEVEL_NAME_LEN, level.name, - "Level Title" + "Title" }, { - ED_LEVELINFO_XPOS, ED_COUNTER_YPOS(7), + ED_SETTINGS_XPOS, ED_COUNTER_YPOS(1), GADGET_ID_LEVEL_AUTHOR, + MAX_LEVEL_AUTHOR_LEN, level.author, - "Level Author" + "Author" } }; @@ -474,13 +486,13 @@ static struct ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_ALT_YPOS, ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_YPOS, GADGET_ID_ELEMENTLIST_UP, - "scroll element list up" + "scroll element list up ('Page Up')" }, { ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_ALT_YPOS, ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_YPOS, GADGET_ID_ELEMENTLIST_DOWN, - "scroll element list down" + "scroll element list down ('Page Down')" } }; @@ -527,21 +539,37 @@ static struct int *value; int checked_value; char *text, *infotext; -} checkbutton_info[ED_NUM_CHECKBUTTONS] = +} radiobutton_info[ED_NUM_RADIOBUTTONS] = { { - ED_LEVELINFO_XPOS + 160, ED_COUNTER_YPOS(2), + ED_SETTINGS_XPOS + 160, ED_COUNTER_YPOS(8), GADGET_ID_RANDOM_PERCENTAGE, RADIO_NR_RANDOM_ELEMENTS, &random_placement_method, RANDOM_USE_PERCENTAGE, - "percentage", "use percentage for random elements" + "percentage", "use percentage for random elements" }, { - ED_LEVELINFO_XPOS + 340, ED_COUNTER_YPOS(2), + ED_SETTINGS_XPOS + 340, ED_COUNTER_YPOS(8), GADGET_ID_RANDOM_QUANTITY, RADIO_NR_RANDOM_ELEMENTS, &random_placement_method, RANDOM_USE_QUANTITY, - "quantity", "use quantity for random elements" + "quantity", "use quantity for random elements" + } +}; + +static struct +{ + int x, y; + int gadget_id; + boolean *value; + char *text, *infotext; +} checkbutton_info[ED_NUM_CHECKBUTTONS] = +{ + { + ED_SETTINGS_XPOS, ED_COUNTER_YPOS(6) - MINI_TILEY, + GADGET_ID_DOUBLE_SPEED, + &level.double_speed, + "double speed movement", "set movement speed of player" } }; @@ -592,7 +620,7 @@ static int undo_buffer_steps = 0; static int edit_mode; -static int counter_xsize = DXSIZE + 20; +static int counter_xsize = DXSIZE + FONT2_XSIZE - 2 * ED_GADGET_DISTANCE; int element_shift = 0; @@ -1384,7 +1412,7 @@ static void CreateTextInputGadgets() GDI_Y, SY + textinput_info[i].y, GDI_TYPE, GD_TYPE_TEXTINPUT_ALPHANUMERIC, GDI_TEXT_VALUE, textinput_info[i].value, - GDI_TEXT_SIZE, 30, + GDI_TEXT_SIZE, textinput_info[i].size, GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y, GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y, GDI_DESIGN_BORDER, ED_BORDER_SIZE, @@ -1459,32 +1487,55 @@ static void CreateScrollbarGadgets() static void CreateCheckbuttonGadgets() { + Pixmap gd_pixmap = pix[PIX_DOOR]; + struct GadgetInfo *gi; + unsigned long event_mask; + int gd_x1, gd_x2, gd_x3, gd_x4, gd_y1, gd_y2; + boolean checked; int i; - /* create toolbox buttons */ - for (i=0; i