From: Holger Schemel Date: Sun, 10 Jun 2018 21:21:00 +0000 (+0200) Subject: added event actions (active screen elements) for global animations X-Git-Tag: 4.1.1.0~136 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=a97d51220232bd25cc77bddb2c655fb521ccf519;p=rocksndiamonds.git added event actions (active screen elements) for global animations This change adds more event actions to the "anim_event_action" option for clickable global animations, this time adding active screen elements (currently limited to a selection of screen elements in the main menu). For example, you can now use: global.anim_1.part_1.MAIN.anim_event: click global.anim_1.part_1.MAIN.anim_event_action: menu.button_game When clicking this global animation (on the main menu screen), the game will be started (by triggering the "start game" menu button). To dump a list of all available event actions for global animations, blindly type the "cheat mode" style shortcut ":dump-event-actions" or ":dea" in the main menu. --- diff --git a/src/anim.c b/src/anim.c index 0043a3e9..a38a1c3d 100644 --- a/src/anim.c +++ b/src/anim.c @@ -1450,7 +1450,8 @@ static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *part) if (anim_event_action == -1) return FALSE; - return DoGadgetAction(anim_event_action); + return (DoGadgetAction(anim_event_action) || + DoScreenAction(anim_event_action)); } static void InitGlobalAnim_Clickable() diff --git a/src/events.c b/src/events.c index 22cfdcd1..b21f3706 100644 --- a/src/events.c +++ b/src/events.c @@ -1762,11 +1762,12 @@ static void HandleKeysSpecial(Key key) } /* special key shortcuts for all game modes */ - if (is_string_suffix(cheat_input, ":dump-gadget-ids") || - is_string_suffix(cheat_input, ":dgi") || - is_string_suffix(cheat_input, ":DGI")) + if (is_string_suffix(cheat_input, ":dump-event-actions") || + is_string_suffix(cheat_input, ":dea") || + is_string_suffix(cheat_input, ":DEA")) { DumpGadgetIdentifiers(); + DumpScreenIdentifiers(); } } diff --git a/src/screens.c b/src/screens.c index 89b9d3d4..80c10ca9 100644 --- a/src/screens.c +++ b/src/screens.c @@ -8308,3 +8308,50 @@ static void HandleScreenGadgets(struct GadgetInfo *gi) break; } } + +void DumpScreenIdentifiers() +{ + int i; + + Print("Active screen elements on current screen:\n"); + + for (i = 0; main_controls[i].nr != -1; i++) + { + struct MainControlInfo *mci = &main_controls[i]; + + if (mci->button_graphic != -1) + { + char *token = getTokenFromImageID(mci->button_graphic); + + Print("- '%s'\n", token); + } + } + + Print("Done.\n"); +} + +boolean DoScreenAction(int image_id) +{ + int i; + + if (game_status != GAME_MODE_MAIN) + return FALSE; + + for (i = 0; main_controls[i].nr != -1; i++) + { + struct MainControlInfo *mci = &main_controls[i]; + struct MenuPosInfo *pos = mci->pos_button; + + if (mci->button_graphic == image_id) + { + int x = mSX + pos->x; + int y = mSY + pos->y; + + HandleMainMenu(x, y, 0, 0, MB_MENU_CHOICE); + + return TRUE; + } + } + + return FALSE; +} diff --git a/src/screens.h b/src/screens.h index 418c41f4..f314fb3b 100644 --- a/src/screens.h +++ b/src/screens.h @@ -42,4 +42,7 @@ void FreeScreenGadgets(); void setHideRelatedSetupEntries(); +void DumpScreenIdentifiers(void); +boolean DoScreenAction(int); + #endif /* SCREENS_H */