PokeLeumas / savegame-manager-gx

Automatically exported from code.google.com/p/savegame-manager-gx
0 stars 0 forks source link

Changed the animation behavior of icons #144

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I changed the behavior of the Icon animation to more closely match that of the 
Wii's SaveManager it's more of an aesthetic but it's nice to have:

--- gui_banner.cpp.old  2011-12-12 21:26:12.586747075 -0800
+++ gui_banner.cpp  2011-12-12 21:13:21.026746591 -0800
@@ -169,6 +170,13 @@
 {
    if(!mem or len<8)
    return;
+   frameCnt = 0;
+   currentFrame = 1;
+   reverseAnim = false;
+   memcpy(&flags, mem+4, 4);
+   memcpy(&animSpeed, mem+8, 2);

    frameCnt = (int)MIN(((len - 0x60a0)/0x1200),MAXFRAMES);
    currentFrame = 0;
@@ -272,7 +280,21 @@
 void GuiSaveIcon::AdvanceFrame()
 {
    if(frameCnt<2)return;
-   if(++currentFrame>=frameCnt)currentFrame=0;
+
+   if (flags == BANNER_ICON_NOCPYBNC || flags == BANNER_ICON_BOUNCE)
+   {
+       if (reverseAnim)
+            currentFrame--;
+        else
+            currentFrame++;
+
+       if (currentFrame >= frameCnt - 1)
+            reverseAnim = true;
+        else if (currentFrame < 1)
+            reverseAnim = false;
+   }
+   else if(++currentFrame>=frameCnt)currentFrame=0;
+
 }

 bool  GuiSaveIcon::IsValid()
@@ -282,13 +304,14 @@

 void GuiSaveIcon::Draw()
 {
-   if(!filecheck ||!this->IsVisible())
+   if(!filecheck || !this->IsVisible())
        return;

    float currScale = this->GetScale();

-   counter++;
-   if (counter>=delay)
+   counter++;
+
+   if (counter>=(animSpeed >> (2 * GetFrame()) & 3) * delay && ((animSpeed & 3) 
!= 0 && ((animSpeed >> 1 * 2) & 3) != 0))
    {
        counter=0;
        this->AdvanceFrame();
@@ -299,4 +322,3 @@
    this->UpdateEffects();
 }

--- gui_banner.h.old    2011-12-12 21:25:36.866747053 -0800
+++ gui_banner.h    2011-12-12 21:06:56.386746349 -0800
@@ -10,7 +10,12 @@

 #include "gui.h"

-#define FRAMEDELAY 6
+#define FRAMEDELAY 5
+
+#define BANNER_ICON_NOCOPY 0x000001
+#define BANNER_ICON_BOUNCE 0x000010
+#define BANNER_ICON_LOOP   0x000000
+#define BANNER_ICON_NOCPYBNC (BANNER_ICON_BOUNCE | BANNER_ICON_NOCOPY)

 class GuiSaveBanner : public GuiImage
 {
@@ -87,7 +92,10 @@
 protected:
    void * memory[MAXFRAMES];
    bool filecheck;
+   bool reverseAnim;
    u32 tplfilesize;
+   int flags;
+   u16 animSpeed;
    u8 frameCnt;
    u8 currentFrame;
    u8 counter;
@@ -96,4 +104,3 @@
 };

 #endif /* _GuiTpl_H_ */
-
- 

Original issue reported on code.google.com by antidote.crk@gmail.com on 13 Dec 2011 at 5:36

GoogleCodeExporter commented 8 years ago
it's already added in sources for next rev.
thx for your work.

Original comment by dj_sk...@hotmail.com on 13 Dec 2011 at 10:49