diff --git a/source/libwiigui/gui.h b/source/libwiigui/gui.h index eead7dfb..524535e7 100644 --- a/source/libwiigui/gui.h +++ b/source/libwiigui/gui.h @@ -306,6 +306,9 @@ class GuiElement //!Considers alpha, alphaDyn, and the parent element's GetAlpha() value //!\return alpha int GetAlpha(); + //!Gets the element's AngleDyn value + //!\return alpha + float GetAngleDyn(); //!Sets the element's scale //!\param s scale (1 is 100%) void SetScale(float s); @@ -339,7 +342,9 @@ class GuiElement //!\param circles Circleamount in degree ike 180 for 1/2 circle or 720 for 2 circles //!\param r Circle Radius in pixel //!\param startdegree Degree where to start circling - void SetEffect(int e, int speed, int circles, int r, int startdegree); + //!\param anglespeedset Set the speed of Angle rotating make 1 for same speed as Circlespeed + //! or 0.5 for half the speed of the circlingspeed. Turn Anglecircling off by 0 to this param. + void SetEffect(int e, int speed, int circles, int r, int startdegree, f32 anglespeedset); //!Sets an effect to be enabled on wiimote cursor over //!\param e Effect to enable //!\param a Amount of the effect (usage varies on effect) @@ -423,6 +428,8 @@ class GuiElement int changervar; //!< Changervariable for some stuff int alpha; //!< Element alpha value (0-255) f32 scale; //!< Element scale (1 = 100%) + f32 angleDyn; //!< AngleDyn for EFFECT_GOROUND + f32 anglespeed; //!GetAngleDyn(); + + return a; +} + void GuiElement::SetScale(float s) { LOCK(this); @@ -415,7 +431,7 @@ int GuiElement::GetEffect() return effects; } -void GuiElement::SetEffect(int eff, int speed, int circles, int r, int startdegree) { +void GuiElement::SetEffect(int eff, int speed, int circles, int r, int startdegree, f32 anglespeedset) { if(eff & EFFECT_GOROUND) { xoffsetDyn = 0; //!position of circle in x @@ -423,6 +439,8 @@ void GuiElement::SetEffect(int eff, int speed, int circles, int r, int startdegr Radius = r; //!Radius of the circle degree = startdegree*PI/180;//!for example -90 (°) to start at top of circle circleamount = circles; //!circleamoutn in degrees for example 360 for 1 circle + angleDyn = 0.0; //!this is used by the code to calc the angle + anglespeed = anglespeedset; //!This is anglespeed depending on circle speed 1 is same speed and 0.5 half speed } effects |= eff; effectAmount = speed; //!Circlespeed @@ -489,6 +507,8 @@ void GuiElement::StopEffect() scaleDyn = 1; frequency = 0; changervar = 0; + angleDyn = 0; + anglespeed = 0.0; } void GuiElement::UpdateEffects() @@ -578,24 +598,31 @@ void GuiElement::UpdateEffects() //!< check out gui.h for info if(abs(frequency) < PI*circleamount/180) { + angleDyn = (frequency+degree) * 180/PI * anglespeed; frequency += effectAmount*0.001; + xoffsetDyn = (int)(Radius*cos(frequency+degree)); yoffsetDyn = (int)(Radius*sin(frequency+degree)); } else { - //fly back to the middle - if(xoffsetDyn < 0) - xoffsetDyn += frequency*100; - else xoffsetDyn = 0; - if(xoffsetDyn > 0) - xoffsetDyn -= frequency*100; + + //Angle go back to start value (has to be 0.0001 when near 0 but not 0 so that the if state goes through) + //value 0.0001 isnt noticeable that's why i chose it. + angleDyn = degree* 180/PI * anglespeed +0.0001; + //Reset Angle to 0 + //angleDyn = 0.0001; + + //fly back to the middle tolerance to 0 is +- 10pixel + if(xoffsetDyn < -10) + xoffsetDyn += abs(effectAmount)*0.1; + else if(xoffsetDyn > 10) + xoffsetDyn -= abs(effectAmount)*0.1; else xoffsetDyn = 0; - if(yoffsetDyn < 0) - yoffsetDyn += frequency*100; - else yoffsetDyn = 0; - if(yoffsetDyn > 0) - yoffsetDyn -= frequency*100; + if(yoffsetDyn < -10) + yoffsetDyn += abs(effectAmount)*0.1; + else if(yoffsetDyn > 10) + yoffsetDyn -= abs(effectAmount)*0.1; else yoffsetDyn = 0; if(xoffsetDyn == 0 && yoffsetDyn == 0) { diff --git a/source/libwiigui/gui_image.cpp b/source/libwiigui/gui_image.cpp index 3271e27a..1faf7a45 100644 --- a/source/libwiigui/gui_image.cpp +++ b/source/libwiigui/gui_image.cpp @@ -234,6 +234,11 @@ void GuiImage::Draw() float currScale = this->GetScale(); int currLeft = this->GetLeft(); + float currAngleDyn = this->GetAngleDyn(); + + if(currAngleDyn) + imageangle = currAngleDyn; + if(tile > 0) { for(int i=0; i