added global animation class "pointer" for animation at mouse position
authorHolger Schemel <info@artsoft.org>
Mon, 18 Mar 2019 22:57:46 +0000 (23:57 +0100)
committerHolger Schemel <info@artsoft.org>
Mon, 18 Mar 2019 22:57:46 +0000 (23:57 +0100)
The animation's x and y position values are used to set the animation
position relative to the mouse pointer position when using this class.

src/anim.c

index 9d1f0b5c734dc75200cc077ff88d826051ceb443..2ebf520f79d793a365b5acdedfbdc77a5ea263e5 100644 (file)
@@ -828,7 +828,8 @@ static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part
   int viewport_height;
   boolean changed = FALSE;
 
-  if (part->last_anim_status == global.anim_status)
+  if (part->last_anim_status == global.anim_status &&
+      part->control_info.class != get_hash_from_key("pointer"))
     return FALSE;
 
   part->last_anim_status = global.anim_status;
@@ -845,6 +846,15 @@ static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part
 
     part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_2;
   }
+  else if (part->control_info.class == get_hash_from_key("pointer"))
+  {
+    viewport_x = gfx.mouse_x + part->control_info.x;
+    viewport_y = gfx.mouse_y + part->control_info.y;
+    viewport_width  = part->graphic_info.width;
+    viewport_height = part->graphic_info.height;
+
+    part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_2;
+  }
   else if (part->control_info.class == get_hash_from_key("door_1"))
   {
     viewport_x = DX;
@@ -1256,10 +1266,13 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part,
       part->step_yoffset = 0;
     }
 
-    if (c->x != ARG_UNDEFINED_VALUE)
-      part->x = c->x;
-    if (c->y != ARG_UNDEFINED_VALUE)
-      part->y = c->y;
+    if (part->control_info.class != get_hash_from_key("pointer"))
+    {
+      if (c->x != ARG_UNDEFINED_VALUE)
+       part->x = c->x;
+      if (c->y != ARG_UNDEFINED_VALUE)
+       part->y = c->y;
+    }
 
     if (c->position == POS_LAST &&
        anim->last_x > -g->width  && anim->last_x < part->viewport_width &&