added support for opening URLs for global animation event actions
authorHolger Schemel <info@artsoft.org>
Sat, 9 Apr 2022 09:10:19 +0000 (11:10 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 9 Apr 2022 09:10:19 +0000 (11:10 +0200)
src/anim.c
src/files.c
src/init.c
src/libgame/image.h
src/main.c
src/main.h

index c3948745602ad2cbbfeb5ac56ee6a575b4a47717..a08b813e53019d3e94879d5fa4e5eb599f5a044f 100644 (file)
@@ -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)
index 1e185c2396e22093f82ec3a18f80bb0421fb9911..d113c6ad0f9b9733b9f9d5303e9f1336c7bdc4e4 100644 (file)
@@ -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;
 
index 541f075008729a4f5adf2c00c64632ca3d0eff16..dbba5f1250154305c8c1412d8ab0255326a72907 100644 (file)
@@ -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++)
index cf95a106b44c21f09c7cf263a9d7efb99b6fa184..9be07c5be1fe8a1bd6ab263fd19212dbce39b733 100644 (file)
@@ -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   : \
index 0788345993944f363825f4ca4744ae852812f5b8..7ebbee1fbe199c0d917d071dd0c37262af7e1a26 100644 (file)
@@ -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;
 
 
 // ----------------------------------------------------------------------------
index f3e757126a43e06115932f01563fb4b010f1d4bd..797a3350f8243f933cd9f081ae60a94c32618e02 100644 (file)
@@ -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[];