From: Holger Schemel Date: Thu, 2 Feb 2017 00:45:20 +0000 (+0100) Subject: added option to 'editor' tab to use level template for new levels X-Git-Tag: 4.0.0.2~6 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d275633f8688c5ea2846b1fe063e07bbe3ea53b0;p=rocksndiamonds.git added option to 'editor' tab to use level template for new levels --- diff --git a/src/editor.c b/src/editor.c index 2798beec..d1e3badd 100644 --- a/src/editor.c +++ b/src/editor.c @@ -674,18 +674,19 @@ #define GADGET_ID_CUSTOM_USE_GRAPHIC (GADGET_ID_CHECKBUTTON_FIRST + 44) #define GADGET_ID_CUSTOM_USE_TEMPLATE_1 (GADGET_ID_CHECKBUTTON_FIRST + 45) #define GADGET_ID_CUSTOM_USE_TEMPLATE_2 (GADGET_ID_CHECKBUTTON_FIRST + 46) -#define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 47) -#define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 48) -#define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 49) -#define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 50) -#define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 51) -#define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 52) -#define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 53) -#define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 54) -#define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 55) +#define GADGET_ID_CUSTOM_USE_TEMPLATE_3 (GADGET_ID_CHECKBUTTON_FIRST + 47) +#define GADGET_ID_CUSTOM_CAN_CHANGE (GADGET_ID_CHECKBUTTON_FIRST + 48) +#define GADGET_ID_CHANGE_USE_CONTENT (GADGET_ID_CHECKBUTTON_FIRST + 49) +#define GADGET_ID_CHANGE_USE_EXPLOSION (GADGET_ID_CHECKBUTTON_FIRST + 50) +#define GADGET_ID_CHANGE_ONLY_COMPLETE (GADGET_ID_CHECKBUTTON_FIRST + 51) +#define GADGET_ID_CHANGE_USE_RANDOM (GADGET_ID_CHECKBUTTON_FIRST + 52) +#define GADGET_ID_CHANGE_HAS_ACTION (GADGET_ID_CHECKBUTTON_FIRST + 53) +#define GADGET_ID_CHANGE_DELAY (GADGET_ID_CHECKBUTTON_FIRST + 54) +#define GADGET_ID_CHANGE_BY_DIRECT_ACT (GADGET_ID_CHECKBUTTON_FIRST + 55) +#define GADGET_ID_CHANGE_BY_OTHER_ACT (GADGET_ID_CHECKBUTTON_FIRST + 56) /* gadgets for buttons in element list */ -#define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 56) +#define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 57) #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \ ED_NUM_ELEMENTLIST_BUTTONS - 1) @@ -874,63 +875,64 @@ /* values for checkbutton gadgets */ #define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 0 #define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2 1 -#define ED_CHECKBUTTON_ID_STICK_ELEMENT 2 -#define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 3 -#define ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE 4 -#define ED_CHECKBUTTON_ID_USE_SPRING_BUG 5 -#define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 6 -#define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 7 -#define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 8 -#define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 9 -#define ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN 10 -#define ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING 11 -#define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 12 -#define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 13 -#define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 14 -#define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 15 -#define ED_CHECKBUTTON_ID_SHIFTED_RELOCATION 16 -#define ED_CHECKBUTTON_ID_LAZY_RELOCATION 17 -#define ED_CHECKBUTTON_ID_USE_START_ELEMENT 18 -#define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 19 -#define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 20 -#define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 21 -#define ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY 22 -#define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 23 -#define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 24 -#define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 25 -#define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 26 -#define ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP 27 -#define ED_CHECKBUTTON_ID_ENVELOPE_CENTERED 28 -#define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 29 -#define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 30 -#define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 31 -#define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 32 -#define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 33 -#define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 34 -#define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 35 -#define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 36 -#define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 37 -#define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 38 -#define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 39 -#define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 40 -#define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 41 -#define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 42 -#define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 43 -#define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 44 -#define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 45 -#define ED_CHECKBUTTON_ID_CHANGE_DELAY 46 -#define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 47 -#define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 48 -#define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 49 -#define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 50 -#define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 51 -#define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 52 -#define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 53 - -#define ED_NUM_CHECKBUTTONS 54 +#define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3 2 +#define ED_CHECKBUTTON_ID_STICK_ELEMENT 3 +#define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 4 +#define ED_CHECKBUTTON_ID_EM_EXPLODES_BY_FIRE 5 +#define ED_CHECKBUTTON_ID_USE_SPRING_BUG 6 +#define ED_CHECKBUTTON_ID_USE_TIME_ORB_BUG 7 +#define ED_CHECKBUTTON_ID_RANDOM_BALL_CONTENT 8 +#define ED_CHECKBUTTON_ID_INITIAL_BALL_STATE 9 +#define ED_CHECKBUTTON_ID_GROW_INTO_DIGGABLE 10 +#define ED_CHECKBUTTON_ID_AUTO_EXIT_SOKOBAN 11 +#define ED_CHECKBUTTON_ID_CONTINUOUS_SNAPPING 12 +#define ED_CHECKBUTTON_ID_BLOCK_SNAP_FIELD 13 +#define ED_CHECKBUTTON_ID_BLOCK_LAST_FIELD 14 +#define ED_CHECKBUTTON_ID_SP_BLOCK_LAST_FIELD 15 +#define ED_CHECKBUTTON_ID_INSTANT_RELOCATION 16 +#define ED_CHECKBUTTON_ID_SHIFTED_RELOCATION 17 +#define ED_CHECKBUTTON_ID_LAZY_RELOCATION 18 +#define ED_CHECKBUTTON_ID_USE_START_ELEMENT 19 +#define ED_CHECKBUTTON_ID_USE_ARTWORK_ELEMENT 20 +#define ED_CHECKBUTTON_ID_USE_EXPLOSION_ELEMENT 21 +#define ED_CHECKBUTTON_ID_INITIAL_GRAVITY 22 +#define ED_CHECKBUTTON_ID_USE_INITIAL_INVENTORY 23 +#define ED_CHECKBUTTON_ID_CAN_PASS_TO_WALKABLE 24 +#define ED_CHECKBUTTON_ID_CAN_FALL_INTO_ACID 25 +#define ED_CHECKBUTTON_ID_CAN_MOVE_INTO_ACID 26 +#define ED_CHECKBUTTON_ID_DONT_COLLIDE_WITH 27 +#define ED_CHECKBUTTON_ID_ENVELOPE_AUTOWRAP 28 +#define ED_CHECKBUTTON_ID_ENVELOPE_CENTERED 29 +#define ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC 30 +#define ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_1 31 +#define ED_CHECKBUTTON_ID_CUSTOM_ACCESSIBLE 32 +#define ED_CHECKBUTTON_ID_CUSTOM_GRAV_REACHABLE 33 +#define ED_CHECKBUTTON_ID_CUSTOM_USE_LAST_VALUE 34 +#define ED_CHECKBUTTON_ID_CUSTOM_WALK_TO_OBJECT 35 +#define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 36 +#define ED_CHECKBUTTON_ID_CUSTOM_CAN_MOVE 37 +#define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 38 +#define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 39 +#define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 40 +#define ED_CHECKBUTTON_ID_CUSTOM_DEADLY 41 +#define ED_CHECKBUTTON_ID_CUSTOM_CAN_EXPLODE 42 +#define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_FIRE 43 +#define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_SMASH 44 +#define ED_CHECKBUTTON_ID_CUSTOM_EXPLODE_IMPACT 45 +#define ED_CHECKBUTTON_ID_CUSTOM_CAN_CHANGE 46 +#define ED_CHECKBUTTON_ID_CHANGE_DELAY 47 +#define ED_CHECKBUTTON_ID_CHANGE_BY_DIRECT_ACT 48 +#define ED_CHECKBUTTON_ID_CHANGE_BY_OTHER_ACT 49 +#define ED_CHECKBUTTON_ID_CHANGE_USE_EXPLOSION 50 +#define ED_CHECKBUTTON_ID_CHANGE_USE_CONTENT 51 +#define ED_CHECKBUTTON_ID_CHANGE_ONLY_COMPLETE 52 +#define ED_CHECKBUTTON_ID_CHANGE_USE_RANDOM 53 +#define ED_CHECKBUTTON_ID_CHANGE_HAS_ACTION 54 + +#define ED_NUM_CHECKBUTTONS 55 #define ED_CHECKBUTTON_ID_EDITOR_FIRST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED -#define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_2 +#define ED_CHECKBUTTON_ID_EDITOR_LAST ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3 #define ED_CHECKBUTTON_ID_CUSTOM1_FIRST ED_CHECKBUTTON_ID_CUSTOM_USE_GRAPHIC #define ED_CHECKBUTTON_ID_CUSTOM1_LAST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE @@ -2640,7 +2642,7 @@ static struct ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(3), GADGET_ID_SAVE_AS_TEMPLATE_2, GADGET_ID_NONE, -1, "Save", - "Template to use for new levels:", NULL, "this level as level template", + "Template for new levels and CE/GE:", NULL, "this level as level template", "Save current settings as new template" }, { @@ -2825,6 +2827,13 @@ static struct NULL, "use template for custom elements", "use template for custom properties" }, + { + ED_LEVEL_SETTINGS_XPOS(0), ED_LEVEL_SETTINGS_YPOS(5), + GADGET_ID_CUSTOM_USE_TEMPLATE_3, GADGET_ID_NONE, + &setup.editor.use_template_for_new_levels, + NULL, + "use template for new levels", "use template for level properties" + }, /* ---------- element settings: configure (various elements) ------------- */ @@ -11675,6 +11684,38 @@ static void HandleCheckbuttons(struct GadgetInfo *gi) DrawEditModeWindow(); } + else if (type_id == ED_CHECKBUTTON_ID_CUSTOM_USE_TEMPLATE_3) + { + if (setup.editor.use_template_for_new_levels && + !fileExists(getGlobalLevelTemplateFilename())) + { + Request("No level template found!", REQ_CONFIRM); + + return; + } + + if (setup.editor.use_template_for_new_levels && + level.changed && + !Request("Discard level and load template?", REQ_ASK)) + { + return; + } + + if (!setup.editor.use_template_for_new_levels && + level.changed && + !Request("Discard level and use empty level?", REQ_ASK)) + { + return; + } + + LoadLevel(level_nr); + LoadScore(level_nr); + + TapeErase(); + + ResetUndoBuffer(); + DrawEditModeWindow(); + } /* do not mark level as modified for certain non-level-changing gadgets */ if ((type_id >= ED_CHECKBUTTON_ID_EDITOR_FIRST && diff --git a/src/files.c b/src/files.c index 4cdb8199..4370cba4 100644 --- a/src/files.c +++ b/src/files.c @@ -3193,6 +3193,9 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, Error(ERR_WARN, "cannot read level '%s' -- using empty level", filename); + if (!setup.editor.use_template_for_new_levels) + return; + /* if level file not found, try to initialize level data from template */ filename = getGlobalLevelTemplateFilename(); @@ -8390,6 +8393,8 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->editor.show_element_token = FALSE; + si->editor.use_template_for_new_levels = TRUE; + si->shortcut.save_game = DEFAULT_KEY_SAVE_GAME; si->shortcut.load_game = DEFAULT_KEY_LOAD_GAME; si->shortcut.toggle_pause = DEFAULT_KEY_TOGGLE_PAUSE; diff --git a/src/libgame/system.h b/src/libgame/system.h index 6816b0ca..4a54de87 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -983,6 +983,8 @@ struct SetupEditorInfo boolean el_by_type; boolean show_element_token; + + boolean use_template_for_new_levels; }; struct SetupEditorCascadeInfo