X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=969aad79e6f72a4688bcdea75d87b3e7bc96a212;hb=516fafe7ee088155d156e0f36f165a0d557d2bde;hp=dd757b0560755526e7be89a91d8c4904b0e49673;hpb=720b0a62c8af0585e9517ed7a98ea336304c02e4;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index dd757b05..969aad79 100644 --- a/src/editor.c +++ b/src/editor.c @@ -366,9 +366,10 @@ #define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0) #define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1) +#define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2) /* selectbox identifiers */ -#define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 2) +#define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3) #define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 0) #define GADGET_ID_CUSTOM_CONSISTENCY (GADGET_ID_SELECTBOX_FIRST + 1) @@ -512,8 +513,9 @@ /* values for text input gadgets */ #define ED_TEXTINPUT_ID_LEVEL_NAME 0 #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1 +#define ED_TEXTINPUT_ID_ELEMENT_NAME 2 -#define ED_NUM_TEXTINPUT 2 +#define ED_NUM_TEXTINPUT 3 #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR @@ -881,6 +883,13 @@ static struct MAX_LEVEL_AUTHOR_LEN, level.author, "Author" + }, + { + 5 * MINI_TILEX, 5 * MINI_TILEY - ED_BORDER_SIZE, + GADGET_ID_ELEMENT_NAME, + MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */ + custom_element.description, + NULL } }; @@ -890,7 +899,6 @@ static struct ValueTextInfo options_access_type[] = { EP_PASSABLE, "pass" }, { -1, NULL } }; -static int value_access_type = 0; static struct ValueTextInfo options_access_layer[] = { @@ -899,7 +907,6 @@ static struct ValueTextInfo options_access_layer[] = { EP_ACCESSIBLE_UNDER, "under" }, { -1, NULL } }; -static int value_access_layer = 0; static struct ValueTextInfo options_walk_to_action[] = { @@ -908,7 +915,6 @@ static struct ValueTextInfo options_walk_to_action[] = { EP_PUSHABLE, "pushable" }, { -1, NULL } }; -static int value_walk_to_action = 0; static struct ValueTextInfo options_move_pattern[] = { @@ -955,7 +961,6 @@ static struct ValueTextInfo options_smash_targets[] = { EP_CAN_SMASH_EVERYTHING, "everything" }, { -1, NULL } }; -static int value_smash_targets = 0; static struct ValueTextInfo options_deadliness[] = { @@ -964,7 +969,6 @@ static struct ValueTextInfo options_deadliness[] = { EP_DONT_TOUCH, "touching" }, { -1, NULL } }; -static int value_deadliness = 0; static struct ValueTextInfo options_consistency[] = { @@ -972,7 +976,6 @@ static struct ValueTextInfo options_consistency[] = { EP_INDESTRUCTIBLE, "indestructible" }, { -1, NULL } }; -static int value_consistency = 0; static struct ValueTextInfo options_time_units[] = { @@ -988,7 +991,6 @@ static struct ValueTextInfo options_change_player_action[] = { CE_PUSHED_BY_PLAYER, "pushed" }, { -1, NULL } }; -static int value_change_player_action = 0; static struct ValueTextInfo options_change_collide_action[] = { @@ -997,7 +999,6 @@ static struct ValueTextInfo options_change_collide_action[] = { CE_SMASHED, "when smashed" }, { -1, NULL } }; -static int value_change_collide_action = 0; static struct ValueTextInfo options_change_other_action[] = { @@ -1010,7 +1011,6 @@ static struct ValueTextInfo options_change_other_action[] = { CE_OTHER_GETS_COLLECTED, "player collects" }, { -1, NULL } }; -static int value_change_other_action = 0; static struct ValueTextInfo options_change_power[] = { @@ -1037,7 +1037,7 @@ static struct GADGET_ID_CUSTOM_ACCESS_TYPE, -1, options_access_type, - &value_access_type, + &custom_element.access_type, "player can", NULL, "type of access to this field" }, { @@ -1045,7 +1045,7 @@ static struct GADGET_ID_CUSTOM_ACCESS_LAYER, -1, options_access_layer, - &value_access_layer, + &custom_element.access_layer, NULL, NULL, "layer of access for this field" }, { @@ -1053,7 +1053,7 @@ static struct GADGET_ID_CUSTOM_WALK_TO_ACTION, -1, options_walk_to_action, - &value_walk_to_action, + &custom_element.walk_to_action, NULL, NULL, "diggable/collectible/pushable" }, { @@ -1085,7 +1085,7 @@ static struct GADGET_ID_CUSTOM_SMASH_TARGETS, -1, options_smash_targets, - &value_smash_targets, + &custom_element.smash_targets, "can smash", NULL, "elements that can be smashed" }, { @@ -1093,7 +1093,7 @@ static struct GADGET_ID_CUSTOM_DEADLINESS, -1, options_deadliness, - &value_deadliness, + &custom_element.deadliness, "deadly when", NULL, "deadliness of element" }, { @@ -1101,7 +1101,7 @@ static struct GADGET_ID_CUSTOM_CONSISTENCY, -1, options_consistency, - &value_consistency, + &custom_element.consistency, NULL, "explodes to:", "consistency/destructibility" }, @@ -1120,7 +1120,7 @@ static struct GADGET_ID_CHANGE_PLAYER_ACTION, -1, options_change_player_action, - &value_change_player_action, + &custom_element.change_player_action, NULL, "by player", "type of player contact" }, { @@ -1128,7 +1128,7 @@ static struct GADGET_ID_CHANGE_COLLIDE_ACTION, -1, options_change_collide_action, - &value_change_collide_action, + &custom_element.change_collide_action, NULL, NULL, "change after impact or smash" }, { @@ -1136,7 +1136,7 @@ static struct GADGET_ID_CHANGE_OTHER_ACTION, -1, options_change_other_action, - &value_change_other_action, + &custom_element.change_other_action, NULL, "element:", "type of other element action" }, { @@ -1287,10 +1287,6 @@ static struct } }; -static boolean can_explode_by_fire = FALSE; -static boolean can_explode_smashed = FALSE; -static boolean can_explode_impact = FALSE; - static struct { int x, y; @@ -1388,19 +1384,19 @@ static struct { ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(13), GADGET_ID_CUSTOM_EXPLODE_FIRE, - &can_explode_by_fire, + &custom_element.can_explode_by_fire, "by fire", "element can explode by fire/explosion" }, { ED_SETTINGS_XPOS(7), ED_SETTINGS_YPOS(13), GADGET_ID_CUSTOM_EXPLODE_SMASH, - &can_explode_smashed, + &custom_element.can_explode_smashed, "smashed", "element can explode when smashed" }, { ED_SETTINGS_XPOS(13), ED_SETTINGS_YPOS(13), GADGET_ID_CUSTOM_EXPLODE_IMPACT, - &can_explode_impact, + &custom_element.can_explode_impact, "impact", "element can explode on impact" }, @@ -2388,7 +2384,9 @@ static char *getElementInfoText(int element) if (element < NUM_FILE_ELEMENTS) { - if (element_info[element].custom_description != NULL) + if (strlen(element_info[element].description) > 0) + info_text = element_info[element].description; + else if (element_info[element].custom_description != NULL) info_text = element_info[element].custom_description; else if (element_info[element].editor_description != NULL) info_text = element_info[element].editor_description; @@ -3435,9 +3433,12 @@ static void MapTextInputGadget(int id) int x = textinput_info[id].x + xoffset_above; int y = textinput_info[id].y + yoffset_above; - sprintf(infotext, "%s:", textinput_info[id].infotext); - infotext[max_infotext_len] = '\0'; - DrawTextF(x, y, FONT_TEXT_1, infotext); + if (textinput_info[id].infotext) + { + sprintf(infotext, "%s:", textinput_info[id].infotext); + infotext[max_infotext_len] = '\0'; + DrawTextF(x, y, FONT_TEXT_1, infotext); + } ModifyGadget(level_editor_gadget[textinput_info[id].gadget_id], GDI_TEXT_VALUE, textinput_info[id].value, GDI_END); @@ -3632,88 +3633,88 @@ static void CopyCustomElementPropertiesToEditor(int element) /* ---------- element settings: configure (custom elements) ------------- */ /* set accessible layer selectbox help value */ - value_access_type = + custom_element.access_type = (IS_WALKABLE(element) ? EP_WALKABLE : IS_PASSABLE(element) ? EP_PASSABLE : - value_access_type); - value_access_layer = + custom_element.access_type); + custom_element.access_layer = (IS_ACCESSIBLE_OVER(element) ? EP_ACCESSIBLE_OVER : IS_ACCESSIBLE_INSIDE(element) ? EP_ACCESSIBLE_INSIDE : IS_ACCESSIBLE_UNDER(element) ? EP_ACCESSIBLE_UNDER : - value_access_layer); + custom_element.access_layer); custom_element_properties[EP_ACCESSIBLE] = (IS_ACCESSIBLE_OVER(element) || IS_ACCESSIBLE_INSIDE(element) || IS_ACCESSIBLE_UNDER(element)); /* set walk-to-object action selectbox help value */ - value_walk_to_action = + custom_element.walk_to_action = (IS_DIGGABLE(element) ? EP_DIGGABLE : IS_COLLECTIBLE(element) ? EP_COLLECTIBLE : IS_PUSHABLE(element) ? EP_PUSHABLE : - value_walk_to_action); + custom_element.walk_to_action); custom_element_properties[EP_WALK_TO_OBJECT] = (IS_DIGGABLE(element) || IS_COLLECTIBLE(element) || IS_PUSHABLE(element)); /* set smash targets selectbox help value */ - value_smash_targets = + custom_element.smash_targets = (CAN_SMASH_EVERYTHING(element) ? EP_CAN_SMASH_EVERYTHING : CAN_SMASH_ENEMIES(element) ? EP_CAN_SMASH_ENEMIES : CAN_SMASH_PLAYER(element) ? EP_CAN_SMASH_PLAYER : - value_smash_targets); + custom_element.smash_targets); custom_element_properties[EP_CAN_SMASH] = (CAN_SMASH_EVERYTHING(element) || CAN_SMASH_ENEMIES(element) || CAN_SMASH_PLAYER(element)); /* set deadliness selectbox help value */ - value_deadliness = + custom_element.deadliness = (DONT_TOUCH(element) ? EP_DONT_TOUCH : DONT_COLLIDE_WITH(element) ? EP_DONT_COLLIDE_WITH : DONT_RUN_INTO(element) ? EP_DONT_RUN_INTO : - value_deadliness); + custom_element.deadliness); custom_element_properties[EP_DEADLY] = (DONT_TOUCH(element) || DONT_COLLIDE_WITH(element) || DONT_RUN_INTO(element)); /* set consistency selectbox help value */ - value_consistency = + custom_element.consistency = (IS_INDESTRUCTIBLE(element) ? EP_INDESTRUCTIBLE : CAN_EXPLODE(element) ? EP_CAN_EXPLODE : - value_consistency); + custom_element.consistency); custom_element_properties[EP_EXPLODE_RESULT] = (IS_INDESTRUCTIBLE(element) || CAN_EXPLODE(element)); /* special case: sub-settings dependent from main setting */ - if (CAN_EXPLODE(element)) - { - can_explode_by_fire = CAN_EXPLODE_BY_FIRE(element); - can_explode_smashed = CAN_EXPLODE_SMASHED(element); - can_explode_impact = CAN_EXPLODE_IMPACT(element); - }; + if (CAN_EXPLODE_BY_FIRE(element)) + custom_element.can_explode_by_fire = TRUE; + if (CAN_EXPLODE_SMASHED(element)) + custom_element.can_explode_smashed = TRUE; + if (CAN_EXPLODE_IMPACT(element)) + custom_element.can_explode_impact = TRUE; /* ---------- element settings: advanced (custom elements) --------------- */ /* set change by player selectbox help value */ - value_change_player_action = + custom_element.change_player_action = (HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER : HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER : HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER : - value_change_player_action); + custom_element.change_player_action); /* set change by collision selectbox help value */ - value_change_collide_action = + custom_element.change_collide_action = (HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED : HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT : HAS_CHANGE_EVENT(element, CE_COLLISION) ? CE_COLLISION : - value_change_collide_action); + custom_element.change_collide_action); /* set change by other element action selectbox help value */ - value_change_other_action = + custom_element.change_other_action = (HAS_CHANGE_EVENT(element, CE_OTHER_GETS_COLLECTED) ? CE_OTHER_GETS_COLLECTED : HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PUSHED) ? CE_OTHER_GETS_PUSHED : HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PRESSED) ? CE_OTHER_GETS_PRESSED : @@ -3721,12 +3722,13 @@ static void CopyCustomElementPropertiesToEditor(int element) HAS_CHANGE_EVENT(element, CE_OTHER_IS_EXPLODING) ? CE_OTHER_IS_EXPLODING : HAS_CHANGE_EVENT(element, CE_OTHER_IS_CHANGING) ? CE_OTHER_IS_CHANGING : HAS_CHANGE_EVENT(element, CE_OTHER_IS_TOUCHING) ? CE_OTHER_IS_TOUCHING : - value_change_other_action); + custom_element.change_other_action); } static void CopyCustomElementPropertiesToGame(int element) { int i; + int access_type_and_layer; element_info[properties_element] = custom_element; @@ -3739,30 +3741,31 @@ static void CopyCustomElementPropertiesToGame(int element) custom_element_properties[EP_PASSABLE_OVER] = FALSE; custom_element_properties[EP_PASSABLE_INSIDE] = FALSE; custom_element_properties[EP_PASSABLE_UNDER] = FALSE; - custom_element_properties[((value_access_type == EP_WALKABLE ? - EP_WALKABLE_OVER : EP_PASSABLE_OVER) + - (value_access_layer - EP_ACCESSIBLE_OVER))] = + access_type_and_layer = ((custom_element.access_type == EP_WALKABLE ? + EP_WALKABLE_OVER : EP_PASSABLE_OVER) + + (custom_element.access_layer - EP_ACCESSIBLE_OVER)); + custom_element_properties[access_type_and_layer] = custom_element_properties[EP_ACCESSIBLE]; /* set walk-to-object property from checkbox and selectbox */ custom_element_properties[EP_DIGGABLE] = FALSE; custom_element_properties[EP_COLLECTIBLE] = FALSE; custom_element_properties[EP_PUSHABLE] = FALSE; - custom_element_properties[value_walk_to_action] = + custom_element_properties[custom_element.walk_to_action] = custom_element_properties[EP_WALK_TO_OBJECT]; /* set smash property from checkbox and selectbox */ custom_element_properties[EP_CAN_SMASH_PLAYER] = FALSE; custom_element_properties[EP_CAN_SMASH_ENEMIES] = FALSE; custom_element_properties[EP_CAN_SMASH_EVERYTHING] = FALSE; - custom_element_properties[value_smash_targets] = + custom_element_properties[custom_element.smash_targets] = custom_element_properties[EP_CAN_SMASH]; /* set deadliness property from checkbox and selectbox */ custom_element_properties[EP_DONT_RUN_INTO] = FALSE; custom_element_properties[EP_DONT_COLLIDE_WITH] = FALSE; custom_element_properties[EP_DONT_TOUCH] = FALSE; - custom_element_properties[value_deadliness] = + custom_element_properties[custom_element.deadliness] = custom_element_properties[EP_DEADLY]; /* set consistency property from checkbox and selectbox */ @@ -3771,15 +3774,18 @@ static void CopyCustomElementPropertiesToGame(int element) custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = FALSE; custom_element_properties[EP_CAN_EXPLODE_SMASHED] = FALSE; custom_element_properties[EP_CAN_EXPLODE_IMPACT] = FALSE; - custom_element_properties[value_consistency] = + custom_element_properties[custom_element.consistency] = custom_element_properties[EP_EXPLODE_RESULT]; /* special case: sub-settings dependent from main setting */ if (custom_element_properties[EP_CAN_EXPLODE]) { - custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = can_explode_by_fire; - custom_element_properties[EP_CAN_EXPLODE_SMASHED] = can_explode_smashed; - custom_element_properties[EP_CAN_EXPLODE_IMPACT] = can_explode_impact; + custom_element_properties[EP_CAN_EXPLODE_BY_FIRE] = + custom_element.can_explode_by_fire; + custom_element_properties[EP_CAN_EXPLODE_SMASHED] = + custom_element.can_explode_smashed; + custom_element_properties[EP_CAN_EXPLODE_IMPACT] = + custom_element.can_explode_impact; } /* ---------- element settings: advanced (custom elements) --------------- */ @@ -3788,14 +3794,14 @@ static void CopyCustomElementPropertiesToGame(int element) custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE; custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE; custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE; - custom_element_change_events[value_change_player_action] = + custom_element_change_events[custom_element.change_player_action] = custom_element_change_events[CE_BY_PLAYER]; /* set collision change event from checkbox and selectbox */ custom_element_change_events[CE_COLLISION] = FALSE; custom_element_change_events[CE_IMPACT] = FALSE; custom_element_change_events[CE_SMASHED] = FALSE; - custom_element_change_events[value_change_collide_action] = + custom_element_change_events[custom_element.change_collide_action] = custom_element_change_events[CE_BY_COLLISION]; /* set other element action change event from checkbox and selectbox */ @@ -3806,7 +3812,7 @@ static void CopyCustomElementPropertiesToGame(int element) custom_element_change_events[CE_OTHER_GETS_PRESSED] = FALSE; custom_element_change_events[CE_OTHER_GETS_PUSHED] = FALSE; custom_element_change_events[CE_OTHER_GETS_COLLECTED] = FALSE; - custom_element_change_events[value_change_other_action] = + custom_element_change_events[custom_element.change_other_action] = custom_element_change_events[CE_BY_OTHER]; for (i=0; i < NUM_ELEMENT_PROPERTIES; i++) @@ -4528,19 +4534,9 @@ static void DrawPropertiesTabulatorGadgets() int gd_y = gd->y + gd_gi->height - 1; Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y); int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO; -#if 1 int id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG; -#else - int id_last = ED_TEXTBUTTON_ID_PROPERTIES_INFO; -#endif int i; -#if 0 - /* draw additional "configure" tabulator for configurable elements */ - if (checkPropertiesConfig()) - id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG; -#endif - /* draw additional "advanced" tabulator for custom elements */ if (IS_CUSTOM_ELEMENT(properties_element)) id_last = ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED; @@ -4829,6 +4825,9 @@ static void DrawPropertiesConfig() /* draw drawing area gadgets */ DrawCustomContentArea(); + + /* draw text input gadgets */ + MapTextInputGadget(ED_TEXTINPUT_ID_ELEMENT_NAME); } } @@ -4928,12 +4927,6 @@ static void DrawPropertiesWindow() !IS_CUSTOM_ELEMENT(properties_element)) edit_mode_properties = ED_MODE_PROPERTIES_CONFIG; -#if 0 - if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG && - !checkPropertiesConfig()) - edit_mode_properties = ED_MODE_PROPERTIES_INFO; -#endif - if (IS_CUSTOM_ELEMENT(properties_element)) CopyCustomElementPropertiesToEditor(properties_element); @@ -5707,6 +5700,8 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) ModifyEditorElementList(); RedrawDrawingElements(); + DrawPropertiesAdvancedDrawingAreas(); + FrameCounter = 0; /* restart animation frame counter */ } else if (id == GADGET_ID_CUSTOM_CONTENT) @@ -5926,7 +5921,16 @@ static void HandleCounterButtons(struct GadgetInfo *gi) static void HandleTextInputGadgets(struct GadgetInfo *gi) { - strcpy(textinput_info[gi->custom_type_id].value, gi->text.value); + int type_id = gi->custom_type_id; + + strcpy(textinput_info[type_id].value, gi->text.value); + + if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME) + { + CopyCustomElementPropertiesToGame(properties_element); + + ModifyEditorElementList(); /* update changed button info text */ + } } static void HandleSelectboxGadgets(struct GadgetInfo *gi)