From: Holger Schemel Date: Sat, 9 Apr 2022 09:10:19 +0000 (+0200) Subject: added support for opening URLs for global animation event actions X-Git-Tag: 4.3.2.0~30 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=368684d4c5e2a59cbea8c5e35171f3fe008b844f;p=rocksndiamonds.git added support for opening URLs for global animation event actions --- diff --git a/src/anim.c b/src/anim.c index c3948745..a08b813e 100644 --- a/src/anim.c +++ b/src/anim.c @@ -1766,7 +1766,10 @@ static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *part) if (event_action == ANIM_EVENT_ACTION_NONE) return FALSE; - PushUserEvent(USEREVENT_ANIM_EVENT_ACTION, event_action, 0); + if (event_action < MAX_IMAGE_FILES) + PushUserEvent(USEREVENT_ANIM_EVENT_ACTION, event_action, 0); + else + OpenURLFromHash(anim_url_hash, event_action); // check if further actions are allowed to be executed if (part->control_info.style & STYLE_MULTIPLE_ACTIONS) diff --git a/src/files.c b/src/files.c index 1e185c23..d113c6ad 100644 --- a/src/files.c +++ b/src/files.c @@ -11487,6 +11487,18 @@ static int get_anim_action_parameter_value(char *token) result = -(int)key; } + if (result == -1) + { + if (isURL(token)) + { + result = get_hash_from_key(token); // unsigned int => int + result = ABS(result); // may be negative now + result += (result < MAX_IMAGE_FILES ? MAX_IMAGE_FILES : 0); + + setHashEntry(anim_url_hash, int2str(result, 0), token); + } + } + if (result == -1) result = ANIM_EVENT_ACTION_NONE; diff --git a/src/init.c b/src/init.c index 541f0750..dbba5f12 100644 --- a/src/init.c +++ b/src/init.c @@ -4912,6 +4912,9 @@ static void InitGlobal(void) global_anim_info[i].token_name = global_anim_name_info[i].token_name; } + // create hash to store URLs for global animations + anim_url_hash = newSetupFileHash(); + // create hash from image config list image_config_hash = newSetupFileHash(); for (i = 0; image_config[i].token != NULL; i++) diff --git a/src/libgame/image.h b/src/libgame/image.h index cf95a106..9be07c5b 100644 --- a/src/libgame/image.h +++ b/src/libgame/image.h @@ -49,6 +49,9 @@ // this bitmap pointer points to the bitmap with default image size #define IMG_BITMAP_STANDARD IMG_BITMAP_32x32 +// maximum number of statically and dynamically defined image files +#define MAX_IMAGE_FILES 1000000 + #define GET_BITMAP_ID_FROM_TILESIZE(x) ((x) == 1 ? IMG_BITMAP_1x1 : \ (x) == 2 ? IMG_BITMAP_2x2 : \ diff --git a/src/main.c b/src/main.c index 07883459..7ebbee1f 100644 --- a/src/main.c +++ b/src/main.c @@ -178,6 +178,7 @@ SetupFileHash *element_token_hash = NULL; SetupFileHash *graphic_token_hash = NULL; SetupFileHash *font_token_hash = NULL; SetupFileHash *hide_setup_hash = NULL; +SetupFileHash *anim_url_hash = NULL; // ---------------------------------------------------------------------------- diff --git a/src/main.h b/src/main.h index f3e75712..797a3350 100644 --- a/src/main.h +++ b/src/main.h @@ -3906,6 +3906,7 @@ extern SetupFileHash *element_token_hash; extern SetupFileHash *graphic_token_hash; extern SetupFileHash *font_token_hash; extern SetupFileHash *hide_setup_hash; +extern SetupFileHash *anim_url_hash; extern struct ConfigTypeInfo image_config_suffix[]; extern struct ConfigTypeInfo sound_config_suffix[]; extern struct ConfigTypeInfo music_config_suffix[];