From ecd387d33963ae80311924143b2f49eb29642e7f Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 2 Jan 2006 21:08:02 +0100 Subject: [PATCH] rnd-20060102-2-src * added cascaded element lists in the level editor --- ChangeLog | 1 + src/conftime.h | 2 +- src/editor.c | 67 ++++++++++++++++++++++++++++++-- src/game.c | 91 ++++++++++++++++++++++++++++++++++++++------ src/libgame/misc.c | 18 +++++---- src/libgame/system.h | 8 ++-- src/libgame/toons.c | 4 ++ src/screens.c | 12 ++++-- 8 files changed, 172 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0ed796e2..0cea0417 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * added option "use explosion from element" for player explosions 2005-12-30 + * added cascaded element lists in the level editor * added possibility for multiple CE changes per frame (experimental) 2005-12-28 diff --git a/src/conftime.h b/src/conftime.h index ff08dd9a..c917cfaf 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-01-02 02:52]" +#define COMPILE_DATE_STRING "[2006-01-02 21:04]" diff --git a/src/editor.c b/src/editor.c index e2735901..86e1901a 100644 --- a/src/editor.c +++ b/src/editor.c @@ -6233,6 +6233,32 @@ static int setSelectboxValue(int selectbox_id, int new_value) return new_index_value; } +static void setSelectboxSpecialActionVariablesIfNeeded() +{ + int i; + + /* change action mode and arg variables according to action type variable */ + for (i = 0; action_arg_options[i].value != -1; i++) + { + if (action_arg_options[i].value == custom_element_change.action_type) + { + int mode = action_arg_options[i].mode; + + /* only change if corresponding selectbox has changed */ + if (selectbox_info[ED_SELECTBOX_ID_ACTION_MODE].options != + action_arg_modes[mode]) + custom_element_change.action_mode = -1; + + /* only change if corresponding selectbox has changed */ + if (selectbox_info[ED_SELECTBOX_ID_ACTION_ARG].options != + action_arg_options[i].options) + custom_element_change.action_arg = -1; + + break; + } + } +} + static void setSelectboxSpecialActionOptions() { int i; @@ -6253,6 +6279,7 @@ static void setSelectboxSpecialActionOptions() action_arg_options[i].options); ModifyEditorSelectboxValue(ED_SELECTBOX_ID_ACTION_ARG, custom_element_change.action_arg); + break; } } } @@ -7938,7 +7965,18 @@ static void DrawPropertiesChange() DrawPropertiesChangeDrawingAreas(); } -static void DrawElementName(int x, int y, int element) +static void DrawEditorElementAnimation(int x, int y) +{ + int graphic = el2img(properties_element); + int frame = (ANIM_MODE(graphic) == ANIM_CE_VALUE ? + custom_element.ce_value_fixed_initial : + ANIM_MODE(graphic) == ANIM_CE_SCORE ? + custom_element.collect_score_initial : FrameCounter); + + DrawGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING); +} + +static void DrawEditorElementName(int x, int y, int element) { char *element_name = getElementInfoText(element); int font_nr = FONT_TEXT_1; @@ -8019,18 +8057,30 @@ static void DrawPropertiesWindow() "Element Settings", FONT_TITLE_1); #endif +#if 1 + FrameCounter = 0; /* restart animation frame counter */ +#endif + DrawElementBorder(SX + xstart * MINI_TILEX, SY + ystart * MINI_TILEY + MINI_TILEY / 2, TILEX, TILEY, FALSE); +#if 1 + DrawEditorElementAnimation(SX + xstart * MINI_TILEX, + SY + ystart * MINI_TILEY + MINI_TILEY / 2); +#else DrawGraphicAnimationExt(drawto, SX + xstart * MINI_TILEX, SY + ystart * MINI_TILEY + MINI_TILEY / 2, el2img(properties_element), -1, NO_MASKING); +#endif +#if 0 FrameCounter = 0; /* restart animation frame counter */ +#endif - DrawElementName((xstart + 3) * MINI_TILEX + 1, (ystart + 1) * MINI_TILEY + 1, - properties_element); + DrawEditorElementName((xstart + 3) * MINI_TILEX + 1, + (ystart + 1) * MINI_TILEY + 1, + properties_element); DrawPropertiesTabulatorGadgets(); @@ -9101,11 +9151,15 @@ static void HandleSelectboxGadgets(struct GadgetInfo *gi) { if (type_id == ED_SELECTBOX_ID_ACTION_TYPE) { - /* when changing action type, reset action mode and action arg */ + /* when changing action type, also check action mode and action arg */ if (value_old != value_new) { +#if 1 + setSelectboxSpecialActionVariablesIfNeeded(); +#else custom_element_change.action_mode = -1; custom_element_change.action_arg = -1; +#endif } DrawPropertiesChange(); @@ -9779,10 +9833,15 @@ void HandleLevelEditorIdle() if (!DelayReached(&action_delay, action_delay_value)) return; +#if 1 + DrawEditorElementAnimation(SX + xpos * TILEX, + SY + ypos * TILEY + MINI_TILEY / 2); +#else DrawGraphicAnimationExt(drawto, SX + xpos * TILEX, SY + ypos * TILEY + MINI_TILEY / 2, el2img(properties_element), -1, NO_MASKING); +#endif MarkTileDirty(xpos, ypos); MarkTileDirty(xpos, ypos + 1); diff --git a/src/game.c b/src/game.c index 55ffb998..88f19060 100644 --- a/src/game.c +++ b/src/game.c @@ -132,6 +132,8 @@ RND(element_info[e].ce_value_random_initial)) #define GET_CHANGE_DELAY(c) ( ((c)->delay_fixed * (c)->delay_frames) + \ RND((c)->delay_random * (c)->delay_frames)) +#define GET_CE_DELAY_VALUE(c) ( ((c)->delay_fixed) + \ + RND((c)->delay_random)) #define GET_TARGET_ELEMENT(e, ch) \ ((e) == EL_TRIGGER_ELEMENT ? (ch)->actual_trigger_element : \ @@ -1528,7 +1530,6 @@ static void InitGameEngine() i == EL_BD_BUTTERFLY ? EL_BD_DIAMOND : i == EL_SP_ELECTRON ? EL_SP_INFOTRON : i == EL_AMOEBA_TO_DIAMOND ? level.amoeba_content : - i == EL_YAMYAM ? EL_UNDEFINED : i == EL_WALL_EMERALD ? EL_EMERALD : i == EL_WALL_DIAMOND ? EL_DIAMOND : i == EL_WALL_BD_DIAMOND ? EL_BD_DIAMOND : @@ -3209,8 +3210,16 @@ void Explode(int ex, int ey, int phase, int mode) Store[x][y] = level.yamyam_content[game.yamyam_content_nr].e[xx][yy]; else if (element_info[center_element].content.e[xx][yy] != EL_EMPTY) Store[x][y] = element_info[center_element].content.e[xx][yy]; +#if 1 + /* needed because EL_BD_BUTTERFLY is not defined as "CAN_EXPLODE" + (killing EL_BD_BUTTERFLY with dynamite would result in BD diamond + otherwise) -- FIX THIS !!! */ + else if (!CAN_EXPLODE(element) && element != EL_BD_BUTTERFLY) + Store[x][y] = element_info[element].content.e[1][1]; +#else else if (!CAN_EXPLODE(element)) Store[x][y] = element_info[element].content.e[1][1]; +#endif else Store[x][y] = EL_EMPTY; #else @@ -4215,7 +4224,7 @@ inline static void TurnRoundExt(int x, int y) { static struct { - int x, y; + int dx, dy; } move_xy[] = { { 0, 0 }, @@ -4250,10 +4259,10 @@ inline static void TurnRoundExt(int x, int y) int right_dir = turn[old_move_dir].right; int back_dir = turn[old_move_dir].back; - int left_dx = move_xy[left_dir].x, left_dy = move_xy[left_dir].y; - int right_dx = move_xy[right_dir].x, right_dy = move_xy[right_dir].y; - int move_dx = move_xy[old_move_dir].x, move_dy = move_xy[old_move_dir].y; - int back_dx = move_xy[back_dir].x, back_dy = move_xy[back_dir].y; + int left_dx = move_xy[left_dir].dx, left_dy = move_xy[left_dir].dy; + int right_dx = move_xy[right_dir].dx, right_dy = move_xy[right_dir].dy; + int move_dx = move_xy[old_move_dir].dx, move_dy = move_xy[old_move_dir].dy; + int back_dx = move_xy[back_dir].dx, back_dy = move_xy[back_dir].dy; int left_x = x + left_dx, left_y = y + left_dy; int right_x = x + right_dx, right_y = y + right_dy; @@ -4406,8 +4415,8 @@ inline static void TurnRoundExt(int x, int y) else MovDir[x][y] = back_dir; - xx = x + move_xy[MovDir[x][y]].x; - yy = y + move_xy[MovDir[x][y]].y; + xx = x + move_xy[MovDir[x][y]].dx; + yy = y + move_xy[MovDir[x][y]].dy; if (!IN_LEV_FIELD(xx, yy) || (!IS_FREE(xx, yy) && !IS_FOOD_PIG(Feld[xx][yy]))) @@ -4434,8 +4443,8 @@ inline static void TurnRoundExt(int x, int y) else MovDir[x][y] = back_dir; - xx = x + move_xy[MovDir[x][y]].x; - yy = y + move_xy[MovDir[x][y]].y; + xx = x + move_xy[MovDir[x][y]].dx; + yy = y + move_xy[MovDir[x][y]].dy; if (!IN_LEV_FIELD_AND_IS_FREE(xx, yy)) MovDir[x][y] = old_move_dir; @@ -5794,7 +5803,11 @@ void ContinueMoving(int x, int y) MovDelay[newx][newy] = 0; +#if 1 + if (CAN_CHANGE_OR_HAS_ACTION(element)) +#else if (CAN_CHANGE(element)) +#endif { /* copy element change control values to new field */ ChangeDelay[newx][newy] = ChangeDelay[x][y]; @@ -6905,7 +6918,7 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) #else action_arg == CA_ARG_NUMBER_CE_VALUE ? ei->custom_value_initial : #endif - action_arg == CA_ARG_NUMBER_CE_DELAY ? GET_CHANGE_DELAY(change) : + action_arg == CA_ARG_NUMBER_CE_DELAY ? GET_CE_DELAY_VALUE(change) : action_arg == CA_ARG_NUMBER_LEVEL_TIME ? level_time_value : action_arg == CA_ARG_NUMBER_LEVEL_GEMS ? local_player->gems_still_needed : action_arg == CA_ARG_NUMBER_LEVEL_SCORE ? local_player->score : @@ -7717,6 +7730,29 @@ static boolean CheckElementChangeExt(int x, int y, change->actual_trigger_side = trigger_side; change->actual_trigger_ce_value = CustomValue[x][y]; + /* special case: trigger element not at (x,y) position for some events */ + if (check_trigger_element) + { + static struct + { + int dx, dy; + } move_xy[] = + { + { 0, 0 }, + { -1, 0 }, + { +1, 0 }, + { 0, 0 }, + { 0, -1 }, + { 0, 0 }, { 0, 0 }, { 0, 0 }, + { 0, +1 } + }; + + int xx = x + move_xy[MV_DIR_OPPOSITE(trigger_side)].dx; + int yy = y + move_xy[MV_DIR_OPPOSITE(trigger_side)].dy; + + change->actual_trigger_ce_value = CustomValue[xx][yy]; + } + if (change->can_change && !change_done) { ChangeDelay[x][y] = 1; @@ -8243,6 +8279,28 @@ void GameActions() if (graphic_info[graphic].anim_global_sync) GfxFrame[x][y] = FrameCounter; + else if (ANIM_MODE(graphic) == ANIM_CE_VALUE) + { + int old_gfx_frame = GfxFrame[x][y]; + + GfxFrame[x][y] = CustomValue[x][y]; + +#if 1 + if (GfxFrame[x][y] != old_gfx_frame) +#endif + DrawLevelGraphicAnimation(x, y, graphic); + } + else if (ANIM_MODE(graphic) == ANIM_CE_SCORE) + { + int old_gfx_frame = GfxFrame[x][y]; + + GfxFrame[x][y] = element_info[element].collect_score; + +#if 1 + if (GfxFrame[x][y] != old_gfx_frame) +#endif + DrawLevelGraphicAnimation(x, y, graphic); + } if (ANIM_MODE(graphic) == ANIM_RANDOM && IS_NEXT_FRAME(GfxFrame[x][y], graphic)) @@ -8273,6 +8331,11 @@ void GameActions() printf("::: ChangeDelay == %d\n", ChangeDelay[x][y]); #endif +#if 0 + if (element == EL_CUSTOM_255) + printf("::: ChangeDelay == %d\n", ChangeDelay[x][y]); +#endif + #if 1 ChangeElement(x, y, page); #else @@ -8356,6 +8419,12 @@ void GameActions() else if (IS_ANIMATED(graphic) && !IS_CHANGING(x, y)) DrawLevelGraphicAnimationIfNeeded(x, y, graphic); +#if 0 + if (element == EL_CUSTOM_255 || + element == EL_CUSTOM_256) + DrawLevelGraphicAnimation(x, y, graphic); +#endif + if (IS_BELT_ACTIVE(element)) PlayLevelSoundAction(x, y, ACTION_ACTIVE); diff --git a/src/libgame/misc.c b/src/libgame/misc.c index f0a282f1..bcd8197c 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1758,14 +1758,16 @@ int get_parameter_value(char *value_raw, char *suffix, int type) } else if (strcmp(suffix, ".anim_mode") == 0) { - result = (string_has_parameter(value, "none") ? ANIM_NONE : - string_has_parameter(value, "loop") ? ANIM_LOOP : - string_has_parameter(value, "linear") ? ANIM_LINEAR : - string_has_parameter(value, "pingpong") ? ANIM_PINGPONG : - string_has_parameter(value, "pingpong2") ? ANIM_PINGPONG2 : - string_has_parameter(value, "random") ? ANIM_RANDOM : - string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL : - string_has_parameter(value, "vertical") ? ANIM_VERTICAL : + result = (string_has_parameter(value, "none") ? ANIM_NONE : + string_has_parameter(value, "loop") ? ANIM_LOOP : + string_has_parameter(value, "linear") ? ANIM_LINEAR : + string_has_parameter(value, "pingpong") ? ANIM_PINGPONG : + string_has_parameter(value, "pingpong2") ? ANIM_PINGPONG2 : + string_has_parameter(value, "random") ? ANIM_RANDOM : + string_has_parameter(value, "ce_value") ? ANIM_CE_VALUE : + string_has_parameter(value, "ce_score") ? ANIM_CE_SCORE : + string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL : + string_has_parameter(value, "vertical") ? ANIM_VERTICAL : ANIM_DEFAULT); if (string_has_parameter(value, "reverse")) diff --git a/src/libgame/system.h b/src/libgame/system.h index 51746bc6..bc434d36 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -135,11 +135,13 @@ #define ANIM_PINGPONG (1 << 2) #define ANIM_PINGPONG2 (1 << 3) #define ANIM_RANDOM (1 << 4) -#define ANIM_REVERSE (1 << 5) +#define ANIM_CE_VALUE (1 << 5) +#define ANIM_CE_SCORE (1 << 6) +#define ANIM_REVERSE (1 << 7) /* values for special (non game element) animation modes */ -#define ANIM_HORIZONTAL (1 << 6) -#define ANIM_VERTICAL (1 << 7) +#define ANIM_HORIZONTAL (1 << 8) +#define ANIM_VERTICAL (1 << 9) #define ANIM_DEFAULT ANIM_LOOP diff --git a/src/libgame/toons.c b/src/libgame/toons.c index fec39073..6f4fd2f7 100644 --- a/src/libgame/toons.c +++ b/src/libgame/toons.c @@ -69,6 +69,10 @@ int getAnimationFrame(int num_frames, int delay, int mode, int start_frame, else frame = gfx.anim_random_frame % num_frames; } + else if (mode & (ANIM_CE_VALUE | ANIM_CE_SCORE)) + { + frame = sync_frame % num_frames; + } if (mode & ANIM_REVERSE) /* use reverse animation direction */ frame = num_frames - frame - 1; diff --git a/src/screens.c b/src/screens.c index b3732972..6a6a2e94 100644 --- a/src/screens.c +++ b/src/screens.c @@ -2043,14 +2043,18 @@ static struct TokenInfo setup_info_editor[] = #if 0 { TYPE_STRING, NULL, "Offer Special Elements:"}, #endif + +#if 0 +#else { TYPE_SWITCH, &setup.editor.el_boulderdash, "BoulderDash:" }, { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" }, - { TYPE_SWITCH, &setup.editor.el_emerald_mine_club,"E.M. Club:" }, - { TYPE_SWITCH, &setup.editor.el_more, "More:" }, + { TYPE_SWITCH, &setup.editor.el_emerald_mine_club,"E.M.C.:" }, + { TYPE_SWITCH, &setup.editor.el_more, "R'n'D:" }, { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" }, { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" }, - { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamd. Caves:" }, - { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX Boulderd.:" }, + { TYPE_SWITCH, &setup.editor.el_diamond_caves, "DC II:" }, + { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX BD:" }, +#endif { TYPE_SWITCH, &setup.editor.el_chars, "Characters:" }, { TYPE_SWITCH, &setup.editor.el_custom, "Custom:" }, { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" }, -- 2.34.1