*Added simultanious angle change to EFFECT_GOROUND (to test click on carousellbtn)

This commit is contained in:
dimok321 2009-05-27 17:16:36 +00:00
parent b2e780567e
commit 94a8ccc7c1
4 changed files with 66 additions and 27 deletions

View File

@ -306,6 +306,9 @@ class GuiElement
//!Considers alpha, alphaDyn, and the parent element's GetAlpha() value //!Considers alpha, alphaDyn, and the parent element's GetAlpha() value
//!\return alpha //!\return alpha
int GetAlpha(); int GetAlpha();
//!Gets the element's AngleDyn value
//!\return alpha
float GetAngleDyn();
//!Sets the element's scale //!Sets the element's scale
//!\param s scale (1 is 100%) //!\param s scale (1 is 100%)
void SetScale(float s); 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 circles Circleamount in degree ike 180 for 1/2 circle or 720 for 2 circles
//!\param r Circle Radius in pixel //!\param r Circle Radius in pixel
//!\param startdegree Degree where to start circling //!\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 //!Sets an effect to be enabled on wiimote cursor over
//!\param e Effect to enable //!\param e Effect to enable
//!\param a Amount of the effect (usage varies on effect) //!\param a Amount of the effect (usage varies on effect)
@ -423,6 +428,8 @@ class GuiElement
int changervar; //!< Changervariable for some stuff int changervar; //!< Changervariable for some stuff
int alpha; //!< Element alpha value (0-255) int alpha; //!< Element alpha value (0-255)
f32 scale; //!< Element scale (1 = 100%) f32 scale; //!< Element scale (1 = 100%)
f32 angleDyn; //!< AngleDyn for EFFECT_GOROUND
f32 anglespeed; //!<Anglespeedvariable for EFFECT_GOROUND
int alphaDyn; //!< Element alpha, dynamic (multiplied by alpha value for blending/fading effects) int alphaDyn; //!< Element alpha, dynamic (multiplied by alpha value for blending/fading effects)
f32 scaleDyn; //!< Element scale, dynamic (multiplied by alpha value for blending/fading effects) f32 scaleDyn; //!< Element scale, dynamic (multiplied by alpha value for blending/fading effects)
bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event

View File

@ -53,11 +53,13 @@ GuiElement::GuiElement()
effectsOver = 0; effectsOver = 0;
effectAmountOver = 0; effectAmountOver = 0;
effectTargetOver = 0; effectTargetOver = 0;
frequency = 0; frequency = 0.0;
changervar = 0; changervar = 0;
degree = -90*PI/180; degree = -90*PI/180;
circleamount = 360; circleamount = 360;
Radius = 150; Radius = 150;
angleDyn = 0.0;
anglespeed = 0.0;
// default alignment - align to top left // default alignment - align to top left
alignmentVert = ALIGN_TOP; alignmentVert = ALIGN_TOP;
@ -133,6 +135,7 @@ int GuiElement::GetTop()
if(effects & (EFFECT_SLIDE_IN | EFFECT_SLIDE_OUT | EFFECT_GOROUND | EFFECT_ROCK_VERTICLE)) if(effects & (EFFECT_SLIDE_IN | EFFECT_SLIDE_OUT | EFFECT_GOROUND | EFFECT_ROCK_VERTICLE))
pTop += yoffsetDyn; pTop += yoffsetDyn;
switch(alignmentVert) switch(alignmentVert)
{ {
case ALIGN_TOP: case ALIGN_TOP:
@ -269,6 +272,19 @@ int GuiElement::GetAlpha()
return a; return a;
} }
float GuiElement::GetAngleDyn()
{
float a = 0.0;
if(angleDyn)
a = angleDyn;
if(parentElement && !angleDyn)
a = parentElement->GetAngleDyn();
return a;
}
void GuiElement::SetScale(float s) void GuiElement::SetScale(float s)
{ {
LOCK(this); LOCK(this);
@ -415,7 +431,7 @@ int GuiElement::GetEffect()
return effects; 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) { if(eff & EFFECT_GOROUND) {
xoffsetDyn = 0; //!position of circle in x 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 Radius = r; //!Radius of the circle
degree = startdegree*PI/180;//!for example -90 (°) to start at top of 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 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; effects |= eff;
effectAmount = speed; //!Circlespeed effectAmount = speed; //!Circlespeed
@ -489,6 +507,8 @@ void GuiElement::StopEffect()
scaleDyn = 1; scaleDyn = 1;
frequency = 0; frequency = 0;
changervar = 0; changervar = 0;
angleDyn = 0;
anglespeed = 0.0;
} }
void GuiElement::UpdateEffects() void GuiElement::UpdateEffects()
@ -578,24 +598,31 @@ void GuiElement::UpdateEffects()
//!< check out gui.h for info //!< check out gui.h for info
if(abs(frequency) < PI*circleamount/180) { if(abs(frequency) < PI*circleamount/180) {
angleDyn = (frequency+degree) * 180/PI * anglespeed;
frequency += effectAmount*0.001; frequency += effectAmount*0.001;
xoffsetDyn = (int)(Radius*cos(frequency+degree)); xoffsetDyn = (int)(Radius*cos(frequency+degree));
yoffsetDyn = (int)(Radius*sin(frequency+degree)); yoffsetDyn = (int)(Radius*sin(frequency+degree));
} else { } else {
//fly back to the middle
if(xoffsetDyn < 0) //Angle go back to start value (has to be 0.0001 when near 0 but not 0 so that the if state goes through)
xoffsetDyn += frequency*100; //value 0.0001 isnt noticeable that's why i chose it.
else xoffsetDyn = 0; angleDyn = degree* 180/PI * anglespeed +0.0001;
if(xoffsetDyn > 0) //Reset Angle to 0
xoffsetDyn -= frequency*100; //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; else xoffsetDyn = 0;
if(yoffsetDyn < 0) if(yoffsetDyn < -10)
yoffsetDyn += frequency*100; yoffsetDyn += abs(effectAmount)*0.1;
else yoffsetDyn = 0; else if(yoffsetDyn > 10)
if(yoffsetDyn > 0) yoffsetDyn -= abs(effectAmount)*0.1;
yoffsetDyn -= frequency*100;
else yoffsetDyn = 0; else yoffsetDyn = 0;
if(xoffsetDyn == 0 && yoffsetDyn == 0) { if(xoffsetDyn == 0 && yoffsetDyn == 0) {

View File

@ -234,6 +234,11 @@ void GuiImage::Draw()
float currScale = this->GetScale(); float currScale = this->GetScale();
int currLeft = this->GetLeft(); int currLeft = this->GetLeft();
float currAngleDyn = this->GetAngleDyn();
if(currAngleDyn)
imageangle = currAngleDyn;
if(tile > 0) if(tile > 0)
{ {
for(int i=0; i<tile; i++) for(int i=0; i<tile; i++)

View File

@ -3152,19 +3152,19 @@ static int MenuDiscList()
VIDEO_WaitVSync (); VIDEO_WaitVSync ();
if(carosselleBtn.GetState() == STATE_CLICKED) { if(carosselleBtn.GetState() == STATE_CLICKED) {
carosselleBtn.SetEffect(EFFECT_GOROUND, 80, 180, 50, -45); carosselleBtn.SetEffect(EFFECT_GOROUND, 80, 180, 50, -45, 1);
countBtn.SetEffect(EFFECT_GOROUND, -80, 180, 50, -45); countBtn.SetEffect(EFFECT_GOROUND, -80, 180, 50, -45, 1);
abcBtn.SetEffect(EFFECT_GOROUND, 80, 180, 50, -45); abcBtn.SetEffect(EFFECT_GOROUND, 80, 180, 50, -45, 1);
favoriteBtn.SetEffect(EFFECT_GOROUND, -80, 360, 50, -45); favoriteBtn.SetEffect(EFFECT_GOROUND, -80, 360, 50, -45, 1);
wiiBtn.SetEffect(EFFECT_GOROUND, 80, 180, 150, 180); wiiBtn.SetEffect(EFFECT_GOROUND, 80, 180, 150, 180, 1);
poweroffBtn.SetEffect(EFFECT_GOROUND, -80, 360, 150, 50); poweroffBtn.SetEffect(EFFECT_GOROUND, -80, 360, 150, 50, 1);
sdcardBtn.SetEffect(EFFECT_GOROUND, 80, 360, 150, 80); sdcardBtn.SetEffect(EFFECT_GOROUND, 80, 360, 150, 80, 1);
poweroffBtn.SetEffect(EFFECT_GOROUND, -80, 360, 60, 180); poweroffBtn.SetEffect(EFFECT_GOROUND, -80, 360, 60, 180, 1);
settingsBtn.SetEffect(EFFECT_GOROUND, 80, 360, 200, 180); settingsBtn.SetEffect(EFFECT_GOROUND, 80, 360, 200, 180, 1);
homeBtn.SetEffect(EFFECT_GOROUND, 80, 360, 200, 180); homeBtn.SetEffect(EFFECT_GOROUND, 80, 360, 200, 180, 1);
installBtn.SetEffect(EFFECT_GOROUND, -80, 360, 60, -90); installBtn.SetEffect(EFFECT_GOROUND, -80, 360, 60, -90, 1);
gridBtn.SetEffect(EFFECT_GOROUND, -80, 360, 50, 0); gridBtn.SetEffect(EFFECT_GOROUND, -80, 360, 50, 0, 1);
DownloadBtn.SetEffect(EFFECT_GOROUND, 160, 720, 300, 0); DownloadBtn.SetEffect(EFFECT_GOROUND, 100, 720, 300, 0, 1);
carosselleBtn.ResetState(); carosselleBtn.ResetState();
} }