Author Topic: "Transition Effect" not working  (Read 1051 times)

Alright so you know RTB's message notification pop-up?  Well I'm not exactly doing the same but it's something similar.
I've tried finding out how Ephi did it by looking in RTB's code but I had no luck of finding it, I probably didn't look hard enough so I figured I'd try making one out of scratch.

Code: [Select]
function STWGUI::doTabEffect(%this,%message)
{
if(isObject(STW_NotifyTab))
{
STW_NotifyTab.delete();
}

%res = getRes();
%width = getWord(%res,0);
%height = getWord(%res,1) - getSubStr(getWord(%res,1),0,1)/10;
%pos = %width SPC %height;
%maxChars = 30;
%beginText = "<just:center><color:FFFFFF>";
%message = %beginText @ %message;
%textPos = "8 20";

if(strLen(%message) > %maxChars)
{
%textPos = "8 10";
}

new GuiSwatchCtrl(STW_NotifyTab)
{
profile = "GuiDefaultProfile";
horizSizing = "relative";
vertSizing = "relative";
position = %pos;
extent = "200 50";
minExtent = "8 2";
enabled = "1";
visible = "1";
clipToParent = "1";
color = "50 50 50 150";

new GuiMLTextCtrl(STW_NotifyTab_Text)
{
profile = "GuiMLTextProfile";
horizSizing = "relative";
vertSizing = "relative";
position = %textPos;
extent = "184 14";
minExtent = "8 2";
enabled = "1";
visible = "1";
clipToParent = "1";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "-1";
text = %message;
maxBitmapHeight = "-1";
selectable = "1";
autoResize = "1";
};
};

%startPosX = %width; //the pos to start the tab effect
%endPosX = getWord(getCenterPos(STW_NotifyTab.getextent()),0); //the pos to stop the tab effect
%RestPos = %startPosX - %endPosX; //the amount to divide/subtract to center the tab
%rate = mFloatLength(%restPos / 10,0); //no decimals
%rateSched = 100; //0.1 seconds 10 * 0.1 = 1 | 1 second for the whole effect
echo(%startPosX SPC %endPosX SPC %restPos SPC %rate SPC %rateSched);

PlayGui.add(STW_NotifyTab);

for(%i = 1; %i < 6; %i++)
{
STWGUI.schedule(%rateSched,"setTabXPos",%rate*%i);
echo(%rate*%i);
}

STW_NotifyTab.schedule(2000,"delete");
}

function STWGUI::setTabXPos(%this,%pos)
{
if(isObject(STW_NotifyTab))
{
STW_NotifyTab.position = %pos SPC getWord(STW_NotifyTab.getposition(),1)-10;
}
}

function getCenterPos(%ext)
{
%testtab = new GuiSwatchCtrl()
{
profile = "GuiDefaultProfile";
horizSizing = "center";
vertSizing = "center";
position = "0 0";
extent = %ext;
minExtent = "8 2";
enabled = "1";
visible = "0";
clipToParent = "1";
color = "0 0 0 0";
};

MainMenuGui.add(%testtab);

%testTab.center();
%tabPos = %testTab.getposition();
%testTab.delete();

return %tabPos;
}

Basically what I want it to do is move the tab to the center of the screen on the bottom but in a transitioning way instead of doing guiname.CenterX();
This just sets it about 200 away from the ending position and doesn't do a transition effect - I'm not sure if I'm just incompetent or if it's something that can't be done this way.

I've spent hours on this and I haven't gotten it to work.  What I've also thought of doing is using an animated bitmap control then just have a swatch control become visible after the animated bitmap control is done doing it's thing but then I'd also have to adjust the extent of the animated bitmap control depending on the persons window resolution.

Code: [Select]
for(%i = 1; %i < 6; %i++)
{
STWGUI.schedule(%rateSched,"setTabXPos",%rate*%i);
echo(%rate*%i);
}
All these schedules will end at the same time, resulting in a instant teleport if all the other code works.

RTB Code:
Code: [Select]
//- GuiControl::shift (moves a gui in the X or Y)
function GuiControl::shift(%this,%x,%y)
{
   %this.position = vectorAdd(%this.position,%x SPC %y);
}

//- GuiControl::conditionalShiftY (shifts all controls >= %position by %amount in the Y)
function GuiControl::conditionalShiftY(%this,%position,%amount)
{
   for(%i=0;%i<%this.getCount();%i++)
   {
      %control = %this.getObject(%i);
      if(getWord(%control.position,1) >= %position)
         %control.shift(0,%amount);
   }
}

//- RTBCC_Notification::step (plays a step through the animation)
function RTBCC_Notification::step(%this)
{
   if(%this.state $= "left")
   {
      if(getWord(%this.window.position,0) <= 0)
      {
         if(%this.holdTime < 0)
         {
            %this.window.position = "0 0";
            %this.state = "done";
            return;
         }
         %this.window.position = "0 0";
         %this.state = "wait";
         %this.moveAnim = %this.schedule(%this.holdTime,"step");
         return;
      }
      %this.window.position = vectorSub(%this.window.position,"10 0");
      %this.moveAnim = %this.schedule(10,"step");
   }
   else if(%this.state $= "wait")
   {
      %this.state = "right";
      %this.step();
   }
   else if(%this.state $= "right")
   {
      if(getWord(%this.window.position,0) >= getWord(%this.canvas.extent,0))
      {
         %this.window.position = getWord(%this.canvas.extent,0) SPC "0";
         %this.state = "done";
         %this.step();
         return;
      }
      %this.window.position = vectorAdd(%this.window.position,"10 0");
      %this.moveAnim = %this.schedule(10,"step");
   }
   else if(%this.state $= "done")
   {
      %y = getWord(%this.canvas.position,1);
      %this.canvas.delete();

      for(%i=0;%i<RTBCC_NotificationManager.getCount();%i++)
      {
         %notification = RTBCC_NotificationManager.getObject(%i);
         if(!isObject(%notification.canvas))
            continue;
         if(getWord(%notification.canvas.position,1) < %y)
            %notification.canvas.shift(0,50);
      }
      %this.delete();
   }
}

Code: [Select]
for(%i = 1; %i < 6; %i++)
{
STWGUI.schedule(%rateSched,"setTabXPos",%rate*%i);
echo(%rate*%i);
}
All these schedules will end at the same time, resulting in a instant teleport if all the other code works.
Ah, now I see.
RTB Code:
-snip-
Yeah... like I said I didn't look hard enough.
Thanks.