+2004-08-07
+ * fixed bug in gadget code which caused reset of CEs in level editor
+ (example: pressing 'b' [grab brush] on CE config page erased values)
+ (solution: check if gadgets in ClickOnGadget() are really mapped)
+
+2004-07-29
+ * fixed maze runner style CEs to use the configured move delay value
+
+2004-06-27
+ * added Aaron Davidson's tutorial level set to the "Tutorials" section
+
2004-06-20
* fixed engine change that broke 3.0.8 levels like "Walpurgis Gardens"
* fixed the above fix because it broke level set "machine" (*sigh*)
-#define COMPILE_DATE_STRING "[2004-06-21 01:39]"
+#define COMPILE_DATE_STRING "[2004-08-07 15:46]"
undo_buffer_position = -1;
undo_buffer_steps = -1;
CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
+
+ level.changed = FALSE;
}
static void DrawEditModeWindow()
static boolean LevelChanged()
{
- boolean level_changed = FALSE;
+ boolean field_changed = FALSE;
int x, y;
+ if (leveldir_current->readonly)
+ return FALSE;
+
for (y = 0; y < lev_fieldy; y++)
for (x = 0; x < lev_fieldx; x++)
if (Feld[x][y] != level.field[x][y])
- level_changed = TRUE;
+ field_changed = TRUE;
- return level_changed;
+ return (level.changed || field_changed);
}
static boolean LevelContainsPlayer()
boolean player_found = FALSE;
int x, y;
+ return TRUE; /* !!! CURRENTLY DEACTIVATED !!! */
+
for (y = 0; y < lev_fieldy; y++)
for (x = 0; x < lev_fieldx; x++)
if (Feld[x][y] == EL_PLAYER_1 ||
element_old = (IS_CUSTOM_ELEMENT(element_new) ?
EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP);
copy_mode = GADGET_ID_CUSTOM_COPY_TO;
+
+ level.changed = TRUE;
}
else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new))
{
return FALSE;
}
+ else
+ {
+ level.changed = TRUE;
+ }
if (copy_mode == GADGET_ID_CUSTOM_COPY_FROM)
{
/* mark that this custom element has been modified */
custom_element.modified_settings = TRUE;
+ level.changed = TRUE;
if (level.use_custom_template)
{
/* mark that this group element has been modified */
element_info[element].modified_settings = TRUE;
+ level.changed = TRUE;
}
static void CopyClassicElementPropertiesToGame(int element)
DrawLevelText(start_sx, sy + 1, 0, TEXT_SETCURSOR);
else
DrawLevelText(0, 0, 0, TEXT_END);
+
+ level.changed = TRUE;
}
break;
SetBorderElement();
if (BorderElement != last_border_element)
DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+
+ level.changed = TRUE;
}
static void RandomPlacement(int new_element)
for (y = 0; y < lev_fieldy; y++)
if (free_position[x][y])
Feld[x][y] = new_element;
-
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
- CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
-
- return;
}
-
- while (num_elements > 0)
+ else
{
- x = RND(lev_fieldx);
- y = RND(lev_fieldy);
-
- /* don't place element at the same position twice */
- if (free_position[x][y])
+ while (num_elements > 0)
{
- free_position[x][y] = FALSE;
- Feld[x][y] = new_element;
- num_elements--;
+ x = RND(lev_fieldx);
+ y = RND(lev_fieldy);
+
+ /* don't place element at the same position twice */
+ if (free_position[x][y])
+ {
+ free_position[x][y] = FALSE;
+ Feld[x][y] = new_element;
+ num_elements--;
+ }
}
}
{
if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
ModifyEditorCounter(counter_id, *counter_value);
+
return;
}
}
else
ModifyEditorCounter(counter_id, *counter_value + step);
+ if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
+ {
+ LoadLevel(level_nr);
+ TapeErase();
+ ResetUndoBuffer();
+ DrawEditModeWindow();
+
+ return;
+ }
+
switch (counter_id)
{
case ED_COUNTER_ID_ELEMENT_CONTENT:
lev_fieldy = level.fieldy;
break;
- case ED_COUNTER_ID_SELECT_LEVEL:
- LoadLevel(level_nr);
- TapeErase();
- ResetUndoBuffer();
- DrawEditModeWindow();
- break;
-
default:
break;
}
(counter_id >= ED_COUNTER_ID_CHANGE_FIRST &&
counter_id <= ED_COUNTER_ID_CHANGE_LAST))
CopyElementPropertiesToGame(properties_element);
+
+ level.changed = TRUE;
}
static void HandleTextInputGadgets(struct GadgetInfo *gi)
ModifyEditorElementList(); /* update changed button info text */
}
+
+ level.changed = TRUE;
}
static void HandleTextAreaGadgets(struct GadgetInfo *gi)
int type_id = gi->custom_type_id;
strcpy(textarea_info[type_id].value, gi->textarea.value);
+
+ level.changed = TRUE;
}
static void HandleSelectboxGadgets(struct GadgetInfo *gi)
(type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
type_id <= ED_SELECTBOX_ID_CHANGE_LAST) ||
(type_id == ED_SELECTBOX_ID_GROUP_CHOICE_MODE))
+ {
CopyElementPropertiesToGame(properties_element);
+
+ level.changed = TRUE;
+ }
}
static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
setElementChangeInfoToDefaults(ei->change);
DrawPropertiesWindow();
+
+ level.changed = TRUE;
}
else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
custom_element.num_change_pages > MIN_CHANGE_PAGES)
setElementChangePages(ei, ei->num_change_pages - 1);
DrawPropertiesWindow();
+
+ level.changed = TRUE;
}
}
element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0] =
ei->change_page[current_change_page];
else if (type_id == ED_GRAPHICBUTTON_ID_PASTE_CHANGE_PAGE)
+ {
ei->change_page[current_change_page] =
element_info[EL_INTERNAL_CLIPBOARD_CHANGE].change_page[0];
+ level.changed = TRUE;
+ }
+
DrawPropertiesWindow();
}
}
{
*radiobutton_info[gi->custom_type_id].value =
radiobutton_info[gi->custom_type_id].checked_value;
+
+ level.changed = TRUE;
}
static void HandleCheckbuttons(struct GadgetInfo *gi)
DrawEditModeWindow();
}
+
+ level.changed = TRUE;
}
static void HandleControlButtons(struct GadgetInfo *gi)
for (x = 0; x < MAX_LEV_FIELDX; x++)
for (y = 0; y < MAX_LEV_FIELDY; y++)
Feld[x][y] = (button == 1 ? EL_EMPTY : new_element);
+
CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
break;
}
- if (!LevelContainsPlayer)
+ if (!LevelContainsPlayer())
Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
else
{
if (new_level)
Request("Level saved !", REQ_CONFIRM);
+
+ level.changed = FALSE;
}
break;
case GADGET_ID_TEST:
- if (!LevelContainsPlayer)
+ if (!LevelContainsPlayer())
Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
else
{
level->no_valid_file = FALSE;
+ level->changed = FALSE;
+
if (leveldir_current == NULL) /* only when dumping level */
return;
}
/* initialize "can_explode" field for old levels which did not store this */
+ /* !!! CHECK THIS -- "<= 3,1,0,0" IS PROBABLY WRONG !!! */
if (level->game_version <= VERSION_IDENT(3,1,0,0))
{
for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++)
}
}
+ /* correct previously hard-coded move delay values for maze runner style */
+ if (level->game_version < VERSION_IDENT(3,1,1,0))
+ {
+ for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++)
+ {
+ int element = EL_CUSTOM_START + i;
+
+ if (element_info[element].move_pattern & MV_MAZE_RUNNER_STYLE)
+ {
+ /* previously hard-coded and therefore ignored */
+ element_info[element].move_delay_fixed = 9;
+ element_info[element].move_delay_random = 0;
+ }
+ }
+ }
+
#if 0
/* set default push delay values (corrected since version 3.0.7-1) */
if (level->game_version < VERSION_IDENT(3,0,7,1))
#define USE_NEW_SP_SLIPPERY TRUE * USE_NEW_STUFF * 1
#define USE_NEW_RANDOMIZE TRUE * USE_NEW_STUFF * 1
-#define USE_PUSH_BUGFIX TRUE * 1
+#define USE_PUSH_BUGFIX TRUE * USE_NEW_STUFF * 1
/* for DigField() */
#define DF_NO_PUSH 0
MovDir[x][y] = new_move_dir;
if (old_move_dir != new_move_dir)
+ {
+#if 1
+ MovDelay[x][y] = GET_NEW_MOVE_DELAY(element);
+#else
MovDelay[x][y] = 9;
+#endif
+ }
}
}
case GDI_NUMBER_VALUE:
gi->textinput.number_value = va_arg(ap, long);
sprintf(gi->textinput.value, "%d", gi->textinput.number_value);
+ strcpy(gi->textinput.last_value, gi->textinput.value);
gi->textinput.cursor_position = strlen(gi->textinput.value);
break;
{
gi->textinput.number_value = gi->textinput.number_min;
sprintf(gi->textinput.value, "%d", gi->textinput.number_value);
+ strcpy(gi->textinput.last_value, gi->textinput.value);
}
break;
{
gi->textinput.number_value = gi->textinput.number_max;
sprintf(gi->textinput.value, "%d", gi->textinput.number_value);
+ strcpy(gi->textinput.last_value, gi->textinput.value);
}
break;
max_textsize = MIN(gi->textinput.size, MAX_GADGET_TEXTSIZE - 1);
strncpy(gi->textinput.value, va_arg(ap, char *), max_textsize);
+ strcpy(gi->textinput.last_value, gi->textinput.value);
+
gi->textinput.value[max_textsize] = '\0';
gi->textinput.cursor_position = strlen(gi->textinput.value);
/* same tag also used for other gadget definitions */
strcpy(gi->textbutton.value, gi->textinput.value);
strcpy(gi->textarea.value, gi->textinput.value);
+ strcpy(gi->textarea.last_value, gi->textinput.value);
}
break;
gi->textinput.size = max_textsize;
gi->textinput.value[max_textsize] = '\0';
+ strcpy(gi->textinput.last_value, gi->textinput.value);
/* same tag also used for other gadget definitions */
- strcpy(gi->textbutton.value, gi->textinput.value);
- gi->textbutton.size = gi->textinput.size;
+
+ gi->textarea.size = max_textsize;
+ gi->textarea.value[max_textsize] = '\0';
+ strcpy(gi->textarea.last_value, gi->textinput.value);
+
+ gi->textbutton.size = max_textsize;
+ gi->textbutton.value[max_textsize] = '\0';
+
gi->selectbox.size = gi->textinput.size;
}
break;
void ClickOnGadget(struct GadgetInfo *gi, int button)
{
+ if (!gi->mapped)
+ return;
+
/* simulate releasing mouse button over last gadget, if still pressed */
if (button_status)
HandleGadgets(-1, -1, 0);
button != 0 && !motion_status && new_gi != last_gi)
#endif
{
- CheckRangeOfNumericInputGadget(last_gi); /* in case of numeric gadget */
+ struct GadgetInfo *gi = last_gi;
+ boolean gadget_changed = (gi->event_mask & GD_EVENT_TEXT_LEAVING);
+
+ /* check if text gadget has changed its value */
+ if (gi->type & GD_TYPE_TEXT_INPUT)
+ {
+ CheckRangeOfNumericInputGadget(gi);
- DrawGadget(last_gi, DG_UNPRESSED, last_gi->direct_draw);
+ if (strcmp(gi->textinput.value, gi->textinput.last_value) != 0)
+ strcpy(gi->textinput.last_value, gi->textinput.value);
+ else
+ gadget_changed = FALSE;
+ }
+
+ /* selectbox does not change its value when closed by clicking outside */
+ if (gi->type & GD_TYPE_SELECTBOX)
+ gadget_changed = FALSE;
+
+ DrawGadget(gi, DG_UNPRESSED, gi->direct_draw);
- last_gi->event.type = GD_EVENT_TEXT_LEAVING;
+ gi->event.type = GD_EVENT_TEXT_LEAVING;
- if (last_gi->event_mask & GD_EVENT_TEXT_LEAVING)
- last_gi->callback_action(last_gi);
+#if 1
+ if (gadget_changed && !(gi->type & GD_TYPE_SELECTBOX))
+ gi->callback_action(gi);
+#else
+ if (gi->event_mask & GD_EVENT_TEXT_LEAVING)
+ gi->callback_action(gi);
+#endif
last_gi = NULL;
if (gadget_released_inside)
{
boolean deactivate_gadget = TRUE;
+ boolean gadget_changed = TRUE;
if (gi->type & GD_TYPE_SELECTBOX)
{
#if 1
if (mouse_released_where_pressed ||
!gadget_released_inside_select_area) /* selectbox stays open */
+ {
deactivate_gadget = FALSE;
+ gadget_changed = FALSE;
+ }
#else
if (gadget_released_inside_select_line ||
gadget_released_off_borders) /* selectbox stays open */
+ {
deactivate_gadget = FALSE;
+ gadget_changed = FALSE;
+ }
#endif
- else
+ else if (gi->selectbox.index != gi->selectbox.current_index)
gi->selectbox.index = gi->selectbox.current_index;
+ else
+ gadget_changed = FALSE;
}
if (deactivate_gadget &&
gi->state = GD_BUTTON_UNPRESSED;
gi->event.type = GD_EVENT_RELEASED;
+#if 1
+ if ((gi->event_mask & GD_EVENT_RELEASED) && gadget_changed)
+ {
+ gi->callback_action(gi);
+ }
+#else
if ((gi->event_mask & GD_EVENT_RELEASED) && deactivate_gadget)
gi->callback_action(gi);
+#endif
}
if (gadget_released_off_borders)
if (key == KSYM_Return) /* valid for both text input and selectbox */
{
+ boolean gadget_changed = (gi->event_mask & GD_EVENT_TEXT_RETURN);
+
if (gi->type & GD_TYPE_TEXT_INPUT)
+ {
CheckRangeOfNumericInputGadget(gi);
+
+ if (strcmp(gi->textinput.value, gi->textinput.last_value) != 0)
+ strcpy(gi->textinput.last_value, gi->textinput.value);
+ else
+ gadget_changed = FALSE;
+ }
else if (gi->type & GD_TYPE_SELECTBOX)
- gi->selectbox.index = gi->selectbox.current_index;
+ {
+ if (gi->selectbox.index != gi->selectbox.current_index)
+ gi->selectbox.index = gi->selectbox.current_index;
+ else
+ gadget_changed = FALSE;
+ }
if (gi->type & GD_TYPE_TEXT_AREA)
{
last_gi = NULL;
}
+#if 1
+ if (gadget_changed)
+ gi->callback_action(gi);
+#else
if (gi->event_mask & GD_EVENT_TEXT_RETURN)
gi->callback_action(gi);
+#endif
}
else if (gi->type & GD_TYPE_TEXT_INPUT) /* only valid for text input */
{
struct GadgetTextInput
{
char value[MAX_GADGET_TEXTSIZE]; /* text string in input field */
+ char last_value[MAX_GADGET_TEXTSIZE]; /* last text string in input field */
int cursor_position; /* actual text cursor position */
int number_value; /* integer value, if numeric */
int number_min; /* minimal allowed numeric value */
struct GadgetTextArea
{
char value[MAX_GADGET_TEXTSIZE]; /* text string in input field */
+ char last_value[MAX_GADGET_TEXTSIZE]; /* last text string in input field */
int cursor_position; /* actual text cursor position */
int cursor_x; /* actual x cursor position */
int cursor_y; /* actual y cursor position */
void RemapAllGadgets();
boolean anyTextGadgetActive();
+
void ClickOnGadget(struct GadgetInfo *, int);
boolean HandleGadgets(int, int, int);
boolean use_custom_template; /* use custom properties from template file */
boolean no_valid_file; /* set when level file missing or invalid */
+
+ boolean changed; /* set when level was changed in the editor */
};
struct TapeInfo