From: Holger Schemel Date: Sat, 7 Apr 2007 20:52:49 +0000 (+0200) Subject: rnd-20070407-4-src X-Git-Tag: 3.2.4^2~39 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=531605e2e684de4c30a4e9927f9c5107f468b163;p=rocksndiamonds.git rnd-20070407-4-src * added game panel control to display arbitrary elements on game panel --- diff --git a/ChangeLog b/ChangeLog index 7a1ef5d8..89ccb10c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ 2007-04-07 + * added game panel control to display arbitrary elements on game panel * added game panel control to display custom element score (globally unique for identical custom elements) either as value or as element * added ".draw_masked" and ".draw_order" to game panel control drawing diff --git a/src/conf_gfx.c b/src/conf_gfx.c index f15b8c1d..71791701 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -5925,6 +5925,55 @@ struct ConfigInfo image_config[] = { "game.panel.gravity_state.draw_masked", "true" }, { "game.panel.gravity_state.draw_order", "0" }, + { "game.panel.element_1.x", "-1" }, + { "game.panel.element_1.y", "-1" }, + { "game.panel.element_1.tile_size", "16" }, + { "game.panel.element_1.element", "custom_1" }, + { "game.panel.element_1.draw_masked", "false" }, + { "game.panel.element_1.draw_order", "0" }, + { "game.panel.element_2.x", "-1" }, + { "game.panel.element_2.y", "-1" }, + { "game.panel.element_2.tile_size", "16" }, + { "game.panel.element_2.element", "custom_1" }, + { "game.panel.element_2.draw_masked", "false" }, + { "game.panel.element_2.draw_order", "0" }, + { "game.panel.element_3.x", "-1" }, + { "game.panel.element_3.y", "-1" }, + { "game.panel.element_3.tile_size", "16" }, + { "game.panel.element_3.element", "custom_1" }, + { "game.panel.element_3.draw_masked", "false" }, + { "game.panel.element_3.draw_order", "0" }, + { "game.panel.element_4.x", "-1" }, + { "game.panel.element_4.y", "-1" }, + { "game.panel.element_4.tile_size", "16" }, + { "game.panel.element_4.element", "custom_1" }, + { "game.panel.element_4.draw_masked", "false" }, + { "game.panel.element_4.draw_order", "0" }, + { "game.panel.element_5.x", "-1" }, + { "game.panel.element_5.y", "-1" }, + { "game.panel.element_5.tile_size", "16" }, + { "game.panel.element_5.element", "custom_1" }, + { "game.panel.element_5.draw_masked", "false" }, + { "game.panel.element_5.draw_order", "0" }, + { "game.panel.element_6.x", "-1" }, + { "game.panel.element_6.y", "-1" }, + { "game.panel.element_6.tile_size", "16" }, + { "game.panel.element_6.element", "custom_1" }, + { "game.panel.element_6.draw_masked", "false" }, + { "game.panel.element_6.draw_order", "0" }, + { "game.panel.element_7.x", "-1" }, + { "game.panel.element_7.y", "-1" }, + { "game.panel.element_7.tile_size", "16" }, + { "game.panel.element_7.element", "custom_1" }, + { "game.panel.element_7.draw_masked", "false" }, + { "game.panel.element_7.draw_order", "0" }, + { "game.panel.element_8.x", "-1" }, + { "game.panel.element_8.y", "-1" }, + { "game.panel.element_8.tile_size", "16" }, + { "game.panel.element_8.element", "custom_1" }, + { "game.panel.element_8.draw_masked", "false" }, + { "game.panel.element_8.draw_order", "0" }, + { "game.panel.ce_score_1.x", "-1" }, { "game.panel.ce_score_1.y", "-1" }, { "game.panel.ce_score_1.align", "left" }, diff --git a/src/conf_var.c b/src/conf_var.c index 57d32a7d..799331dc 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -3624,6 +3624,198 @@ struct TokenIntPtrInfo image_config_vars[] = "game.panel.gravity_state.draw_order", &game.panel.gravity_state.sort_priority }, + { + "game.panel.element_1.x", + &game.panel.element[0].x + }, + { + "game.panel.element_1.y", + &game.panel.element[0].y + }, + { + "game.panel.element_1.tile_size", + &game.panel.element[0].size + }, + { + "game.panel.element_1.element", + &game.panel.element[0].id + }, + { + "game.panel.element_1.draw_masked", + &game.panel.element[0].draw_masked + }, + { + "game.panel.element_1.draw_order", + &game.panel.element[0].sort_priority + }, + { + "game.panel.element_2.x", + &game.panel.element[1].x + }, + { + "game.panel.element_2.y", + &game.panel.element[1].y + }, + { + "game.panel.element_2.tile_size", + &game.panel.element[1].size + }, + { + "game.panel.element_2.element", + &game.panel.element[1].id + }, + { + "game.panel.element_2.draw_masked", + &game.panel.element[1].draw_masked + }, + { + "game.panel.element_2.draw_order", + &game.panel.element[1].sort_priority + }, + { + "game.panel.element_3.x", + &game.panel.element[2].x + }, + { + "game.panel.element_3.y", + &game.panel.element[2].y + }, + { + "game.panel.element_3.tile_size", + &game.panel.element[2].size + }, + { + "game.panel.element_3.element", + &game.panel.element[2].id + }, + { + "game.panel.element_3.draw_masked", + &game.panel.element[2].draw_masked + }, + { + "game.panel.element_3.draw_order", + &game.panel.element[2].sort_priority + }, + { + "game.panel.element_4.x", + &game.panel.element[3].x + }, + { + "game.panel.element_4.y", + &game.panel.element[3].y + }, + { + "game.panel.element_4.tile_size", + &game.panel.element[3].size + }, + { + "game.panel.element_4.element", + &game.panel.element[3].id + }, + { + "game.panel.element_4.draw_masked", + &game.panel.element[3].draw_masked + }, + { + "game.panel.element_4.draw_order", + &game.panel.element[3].sort_priority + }, + { + "game.panel.element_5.x", + &game.panel.element[4].x + }, + { + "game.panel.element_5.y", + &game.panel.element[4].y + }, + { + "game.panel.element_5.tile_size", + &game.panel.element[4].size + }, + { + "game.panel.element_5.element", + &game.panel.element[4].id + }, + { + "game.panel.element_5.draw_masked", + &game.panel.element[4].draw_masked + }, + { + "game.panel.element_5.draw_order", + &game.panel.element[4].sort_priority + }, + { + "game.panel.element_6.x", + &game.panel.element[5].x + }, + { + "game.panel.element_6.y", + &game.panel.element[5].y + }, + { + "game.panel.element_6.tile_size", + &game.panel.element[5].size + }, + { + "game.panel.element_6.element", + &game.panel.element[5].id + }, + { + "game.panel.element_6.draw_masked", + &game.panel.element[5].draw_masked + }, + { + "game.panel.element_6.draw_order", + &game.panel.element[5].sort_priority + }, + { + "game.panel.element_7.x", + &game.panel.element[6].x + }, + { + "game.panel.element_7.y", + &game.panel.element[6].y + }, + { + "game.panel.element_7.tile_size", + &game.panel.element[6].size + }, + { + "game.panel.element_7.element", + &game.panel.element[6].id + }, + { + "game.panel.element_7.draw_masked", + &game.panel.element[6].draw_masked + }, + { + "game.panel.element_7.draw_order", + &game.panel.element[6].sort_priority + }, + { + "game.panel.element_8.x", + &game.panel.element[7].x + }, + { + "game.panel.element_8.y", + &game.panel.element[7].y + }, + { + "game.panel.element_8.tile_size", + &game.panel.element[7].size + }, + { + "game.panel.element_8.element", + &game.panel.element[7].id + }, + { + "game.panel.element_8.draw_masked", + &game.panel.element[7].draw_masked + }, + { + "game.panel.element_8.draw_order", + &game.panel.element[7].sort_priority + }, { "game.panel.ce_score_1.x", &game.panel.ce_score[0].x diff --git a/src/conftime.h b/src/conftime.h index a22a5e5b..0cc17aa2 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2007-04-07 19:50" +#define COMPILE_DATE_STRING "2007-04-07 22:49" diff --git a/src/game.c b/src/game.c index 0d748e5b..3f6ec77b 100644 --- a/src/game.c +++ b/src/game.c @@ -200,27 +200,35 @@ #define GAME_PANEL_MAGIC_WALL 66 #define GAME_PANEL_MAGIC_WALL_TIME 67 #define GAME_PANEL_GRAVITY_STATE 68 -#define GAME_PANEL_CE_SCORE_1 69 -#define GAME_PANEL_CE_SCORE_2 70 -#define GAME_PANEL_CE_SCORE_3 71 -#define GAME_PANEL_CE_SCORE_4 72 -#define GAME_PANEL_CE_SCORE_5 73 -#define GAME_PANEL_CE_SCORE_6 74 -#define GAME_PANEL_CE_SCORE_7 75 -#define GAME_PANEL_CE_SCORE_8 76 -#define GAME_PANEL_CE_SCORE_1_ELEMENT 77 -#define GAME_PANEL_CE_SCORE_2_ELEMENT 78 -#define GAME_PANEL_CE_SCORE_3_ELEMENT 79 -#define GAME_PANEL_CE_SCORE_4_ELEMENT 80 -#define GAME_PANEL_CE_SCORE_5_ELEMENT 81 -#define GAME_PANEL_CE_SCORE_6_ELEMENT 82 -#define GAME_PANEL_CE_SCORE_7_ELEMENT 83 -#define GAME_PANEL_CE_SCORE_8_ELEMENT 84 -#define GAME_PANEL_PLAYER_NAME 85 -#define GAME_PANEL_LEVEL_NAME 86 -#define GAME_PANEL_LEVEL_AUTHOR 87 - -#define NUM_GAME_PANEL_CONTROLS 88 +#define GAME_PANEL_ELEMENT_1 69 +#define GAME_PANEL_ELEMENT_2 70 +#define GAME_PANEL_ELEMENT_3 71 +#define GAME_PANEL_ELEMENT_4 72 +#define GAME_PANEL_ELEMENT_5 73 +#define GAME_PANEL_ELEMENT_6 74 +#define GAME_PANEL_ELEMENT_7 75 +#define GAME_PANEL_ELEMENT_8 76 +#define GAME_PANEL_CE_SCORE_1 77 +#define GAME_PANEL_CE_SCORE_2 78 +#define GAME_PANEL_CE_SCORE_3 79 +#define GAME_PANEL_CE_SCORE_4 80 +#define GAME_PANEL_CE_SCORE_5 81 +#define GAME_PANEL_CE_SCORE_6 82 +#define GAME_PANEL_CE_SCORE_7 83 +#define GAME_PANEL_CE_SCORE_8 84 +#define GAME_PANEL_CE_SCORE_1_ELEMENT 85 +#define GAME_PANEL_CE_SCORE_2_ELEMENT 86 +#define GAME_PANEL_CE_SCORE_3_ELEMENT 87 +#define GAME_PANEL_CE_SCORE_4_ELEMENT 88 +#define GAME_PANEL_CE_SCORE_5_ELEMENT 89 +#define GAME_PANEL_CE_SCORE_6_ELEMENT 90 +#define GAME_PANEL_CE_SCORE_7_ELEMENT 91 +#define GAME_PANEL_CE_SCORE_8_ELEMENT 92 +#define GAME_PANEL_PLAYER_NAME 93 +#define GAME_PANEL_LEVEL_NAME 94 +#define GAME_PANEL_LEVEL_AUTHOR 95 + +#define NUM_GAME_PANEL_CONTROLS 96 struct GamePanelOrderInfo { @@ -240,6 +248,7 @@ struct GamePanelControlInfo int value, last_value; int frame, last_frame; int gfx_frame; + int gfx_random; }; static struct GamePanelControlInfo game_panel_controls[] = @@ -589,6 +598,46 @@ static struct GamePanelControlInfo game_panel_controls[] = &game.panel.gravity_state, TYPE_STRING, }, + { + GAME_PANEL_ELEMENT_1, + &game.panel.element[0], + TYPE_ELEMENT, + }, + { + GAME_PANEL_ELEMENT_2, + &game.panel.element[1], + TYPE_ELEMENT, + }, + { + GAME_PANEL_ELEMENT_3, + &game.panel.element[2], + TYPE_ELEMENT, + }, + { + GAME_PANEL_ELEMENT_4, + &game.panel.element[3], + TYPE_ELEMENT, + }, + { + GAME_PANEL_ELEMENT_5, + &game.panel.element[4], + TYPE_ELEMENT, + }, + { + GAME_PANEL_ELEMENT_6, + &game.panel.element[5], + TYPE_ELEMENT, + }, + { + GAME_PANEL_ELEMENT_7, + &game.panel.element[6], + TYPE_ELEMENT, + }, + { + GAME_PANEL_ELEMENT_8, + &game.panel.element[7], + TYPE_ELEMENT, + }, { GAME_PANEL_CE_SCORE_1, &game.panel.ce_score[0], @@ -869,6 +918,8 @@ static struct GamePanelControlInfo game_panel_controls[] = static void CreateField(int, int, int); +static void ResetGfxAnimation(int, int); + static void SetPlayerWaiting(struct PlayerInfo *, boolean); static void AdvanceFrameAndPlayerCounters(int); @@ -2123,21 +2174,21 @@ void UpdateGameControlValues() game_panel_controls[GAME_PANEL_GRAVITY_STATE].value = game.gravity; #endif + for (i = 0; i < NUM_PANEL_ELEMENTS; i++) + game_panel_controls[GAME_PANEL_ELEMENT_1 + i].value = + (IS_DRAWABLE_ELEMENT(game.panel.element[i].id) ? + game.panel.element[i].id : EL_UNDEFINED); + for (i = 0; i < NUM_PANEL_CE_SCORE; i++) - { - if (IS_CUSTOM_ELEMENT(game.panel.ce_score[i].id)) - { - int ce_score = element_info[game.panel.ce_score[i].id].collect_score; + game_panel_controls[GAME_PANEL_CE_SCORE_1 + i].value = + (IS_CUSTOM_ELEMENT(game.panel.ce_score[i].id) ? + element_info[game.panel.ce_score[i].id].collect_score : 0); - game_panel_controls[GAME_PANEL_CE_SCORE_1 + i].value = ce_score; - game_panel_controls[GAME_PANEL_CE_SCORE_1_ELEMENT + i].value = ce_score; - } - else - { - game_panel_controls[GAME_PANEL_CE_SCORE_1 + i].value = 0; - game_panel_controls[GAME_PANEL_CE_SCORE_1_ELEMENT + i].value = 0; - } - } + for (i = 0; i < NUM_PANEL_CE_SCORE; i++) + game_panel_controls[GAME_PANEL_CE_SCORE_1_ELEMENT + i].value = + (IS_CUSTOM_ELEMENT(game.panel.ce_score_element[i].id) ? + element_info[game.panel.ce_score_element[i].id].collect_score : + EL_UNDEFINED); game_panel_controls[GAME_PANEL_PLAYER_NAME].value = 0; game_panel_controls[GAME_PANEL_LEVEL_NAME].value = 0; @@ -2149,13 +2200,35 @@ void UpdateGameControlValues() if (gpc->type == TYPE_ELEMENT) { + int last_anim_random_frame = gfx.anim_random_frame; + int element = gpc->value; + int graphic = el2panelimg(element); + if (gpc->value != gpc->last_value) + { gpc->gfx_frame = 0; + gpc->gfx_random = INIT_GFX_RANDOM(); + } else + { gpc->gfx_frame++; + if (ANIM_MODE(graphic) == ANIM_RANDOM && + IS_NEXT_FRAME(gpc->gfx_frame, graphic)) + gpc->gfx_random = INIT_GFX_RANDOM(); + } + + if (ANIM_MODE(graphic) == ANIM_RANDOM) + gfx.anim_random_frame = gpc->gfx_random; + + if (ANIM_MODE(graphic) == ANIM_CE_SCORE) + gpc->gfx_frame = element_info[element].collect_score; + gpc->frame = getGraphicAnimationFrame(el2panelimg(gpc->value), gpc->gfx_frame); + + if (ANIM_MODE(graphic) == ANIM_RANDOM) + gfx.anim_random_frame = last_anim_random_frame; } } } @@ -3568,6 +3641,8 @@ void InitGame() emulate_sp = FALSE; InitField(x, y, TRUE); + + ResetGfxAnimation(x, y); } InitBeltMovement(); diff --git a/src/game.h b/src/game.h index 739c51af..ac2496e1 100644 --- a/src/game.h +++ b/src/game.h @@ -26,6 +26,7 @@ #define NUM_BELT_PARTS 3 #define NUM_PANEL_INVENTORY 8 +#define NUM_PANEL_ELEMENTS 8 #define NUM_PANEL_CE_SCORE 8 #if 1 @@ -73,6 +74,7 @@ struct GamePanelInfo struct TextPosInfo magic_wall; struct TextPosInfo magic_wall_time; struct TextPosInfo gravity_state; + struct TextPosInfo element[NUM_PANEL_ELEMENTS]; struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE]; struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE]; struct TextPosInfo player_name; diff --git a/src/main.h b/src/main.h index 1e62cc61..1b877e7e 100644 --- a/src/main.h +++ b/src/main.h @@ -625,6 +625,18 @@ #define IS_OBSOLETE(e) HAS_PROPERTY(e, EP_OBSOLETE) /* special macros used in game engine */ +#define IS_FILE_ELEMENT(e) ((e) >= 0 && \ + (e) <= NUM_FILE_ELEMENTS) + +#define IS_DRAWABLE_ELEMENT(e) ((e) >= 0 && \ + (e) <= NUM_DRAWABLE_ELEMENTS) + +#define IS_RUNTIME_ELEMENT(e) ((e) >= 0 && \ + (e) <= NUM_RUNTIME_ELEMENTS) + +#define IS_VALID_ELEMENT(e) ((e) >= 0 && \ + (e) <= MAX_NUM_ELEMENTS) + #define IS_CUSTOM_ELEMENT(e) ((e) >= EL_CUSTOM_START && \ (e) <= EL_CUSTOM_END) @@ -1526,8 +1538,10 @@ #define EL_EMC_DRIPPER_ACTIVE (EL_FIRST_RUNTIME_REAL + 70) #define EL_EMC_SPRING_BUMPER_ACTIVE (EL_FIRST_RUNTIME_REAL + 71) +#define NUM_DRAWABLE_ELEMENTS (EL_FIRST_RUNTIME_REAL + 72) + /* "unreal" (and therefore not drawable) runtime elements */ -#define EL_FIRST_RUNTIME_UNREAL (EL_FIRST_RUNTIME_REAL + 72) +#define EL_FIRST_RUNTIME_UNREAL (NUM_DRAWABLE_ELEMENTS) #define EL_BLOCKED (EL_FIRST_RUNTIME_UNREAL + 0) #define EL_EXPLOSION (EL_FIRST_RUNTIME_UNREAL + 1)