mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-22 19:29:18 +01:00
**Changes
*Fixed effect GOROUND so that it doesn't cause alignment issues anymore (the format for this effect is very different than it originally was, if you plan on using it for something, look at the documentation in gui.h. *Major revamp of gui_gamecarousel (everything is awesome and perfect, except it still can't launch games, and thus it is still not in the gui). **gui_gamecarousel Notes: *You can use the same technique as last time to test the carousel (except I recommend adding startat and offset to the line since I added support for it). *I realized not everyone will agree for my choice of curvature and spacing for the games on the carousel, so I made them variable. At the top of gui_gamecarousel.cpp are a bunch of definitions that set up these values. *SCALE determines the size of the game boxes. *DEG_OFFSET is the number of degrees between the boxes (remember, changing the RADIUS will affect the linear distance each degree represents). *RADIUS determines the curvature of the arc (higher radius makes it less curved). *IN_SPEED determines the speed at which the boxes come in (higher number makes it faster). *SHFIT_SPEED determines the speed at which the boxes move when you turn the carousel. *PAGESIZE determines how many boxes are drawn (remember, the number of visible boxes is determined by DEG_OFFSET and RADIUS, with the default values you can see 7). *Everything eles (the animations, position of the movement buttons, etc.) is automatically determined from these values (my 8th grade math teacher was right, trig isn't totally worthless), so you shouldn't need to change anything at all, except the aforementioned values (or the b0rken game launching code). *If you find a set of values you think looks better than mine, post a picture and the list of values in an issue or on IRC. *These will probably become theamable at some point, but I figure we should get this added to the gui first (I was hoping to do it tonight, but some stuff came up, and I need to go to bed). Wow I write really long commit notes.
This commit is contained in:
parent
0c2898ac21
commit
cf1a8fb5a0
@ -346,7 +346,7 @@ class GuiElement
|
|||||||
//! or 0.5 for half the speed of the circlingspeed. Turn Anglecircling off by 0 to this param.
|
//! or 0.5 for half the speed of the circlingspeed. Turn Anglecircling off by 0 to this param.
|
||||||
//!\param center_x x co-ordinate of the center of circle.
|
//!\param center_x x co-ordinate of the center of circle.
|
||||||
//!\param center_y y co-ordinate of the center of circle.
|
//!\param center_y y co-ordinate of the center of circle.
|
||||||
void SetEffect(int e, int speed, int circles, int r, int startdegree, f32 anglespeedset, int center_x, int center_y);
|
void SetEffect(int e, int speed, f32 circles, int r, f32 startdegree, f32 anglespeedset, int center_x, int center_y);
|
||||||
//!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)
|
||||||
@ -359,6 +359,9 @@ class GuiElement
|
|||||||
//!Gets the current element effects
|
//!Gets the current element effects
|
||||||
//!\return element effects
|
//!\return element effects
|
||||||
int GetEffect();
|
int GetEffect();
|
||||||
|
//!Gets the current element on over effects
|
||||||
|
//!\return element on over effects
|
||||||
|
int GetEffectOnOver();
|
||||||
//!Checks whether the specified coordinates are within the element's boundaries
|
//!Checks whether the specified coordinates are within the element's boundaries
|
||||||
//!\param x X coordinate
|
//!\param x X coordinate
|
||||||
//!\param y Y coordinate
|
//!\param y Y coordinate
|
||||||
@ -427,7 +430,8 @@ class GuiElement
|
|||||||
f32 degree; //!< Degree where to start for EFFECT_GOROUND enter it in ° like 60°
|
f32 degree; //!< Degree where to start for EFFECT_GOROUND enter it in ° like 60°
|
||||||
f32 frequency; //!< Speed for EFFECT_GOROUND || can also be negative for other direction
|
f32 frequency; //!< Speed for EFFECT_GOROUND || can also be negative for other direction
|
||||||
int Radius; //!< The radius in which the Element goes round for EFFECT_GOROUND
|
int Radius; //!< The radius in which the Element goes round for EFFECT_GOROUND
|
||||||
int circleamount; //!< Circleamount for the EFFECT_GOROUND effect
|
f32 circleamount; //!< Circleamount for the EFFECT_GOROUND effect
|
||||||
|
f32 xoffsetDynFloat; //!< Integer sucks float is need by some parts
|
||||||
f32 yoffsetDynFloat; //!< Integer sucks float is need by some parts
|
f32 yoffsetDynFloat; //!< Integer sucks float is need by some parts
|
||||||
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)
|
||||||
|
@ -53,13 +53,13 @@ GuiElement::GuiElement()
|
|||||||
effectsOver = 0;
|
effectsOver = 0;
|
||||||
effectAmountOver = 0;
|
effectAmountOver = 0;
|
||||||
effectTargetOver = 0;
|
effectTargetOver = 0;
|
||||||
frequency = 0.0;
|
frequency = 0.0f;
|
||||||
changervar = 0;
|
changervar = 0;
|
||||||
degree = -90*PI/180;
|
degree = -90.0f;
|
||||||
circleamount = 360;
|
circleamount = 360.0f;
|
||||||
Radius = 150;
|
Radius = 150;
|
||||||
angleDyn = 0.0;
|
angleDyn = 0.0f;
|
||||||
anglespeed = 0.0;
|
anglespeed = 0.0f;
|
||||||
|
|
||||||
// default alignment - align to top left
|
// default alignment - align to top left
|
||||||
alignmentVert = ALIGN_TOP;
|
alignmentVert = ALIGN_TOP;
|
||||||
@ -431,18 +431,24 @@ int GuiElement::GetEffect()
|
|||||||
return effects;
|
return effects;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiElement::SetEffect(int eff, int speed, int circles, int r, int startdegree, f32 anglespeedset, int center_x, int center_y) {
|
int GuiElement::GetEffectOnOver()
|
||||||
|
{
|
||||||
|
LOCK(this);
|
||||||
|
return effectsOver;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiElement::SetEffect(int eff, int speed, f32 circles, int r, f32 startdegree, f32 anglespeedset, int center_x, int center_y) {
|
||||||
|
|
||||||
if(eff & EFFECT_GOROUND) {
|
if(eff & EFFECT_GOROUND) {
|
||||||
xoffsetDyn = 0; //!position of circle in x
|
xoffsetDyn = 0; //!position of circle in x
|
||||||
yoffsetDyn = 0; //!position of circle in y
|
yoffsetDyn = 0; //!position of circle in y
|
||||||
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; //!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.0f; //!this is used by the code to calc the angle
|
angleDyn = 0.0f; //!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
|
anglespeed = anglespeedset; //!This is anglespeed depending on circle speed 1 is same speed and 0.5 half speed
|
||||||
temp_xoffset = center_x; //!position of center in x
|
temp_xoffset = center_x; //!position of center in x
|
||||||
temp_yoffset = center_y; //!position of center in y
|
temp_yoffset = center_y; //!position of center in y
|
||||||
}
|
}
|
||||||
effects |= eff;
|
effects |= eff;
|
||||||
effectAmount = speed; //!Circlespeed
|
effectAmount = speed; //!Circlespeed
|
||||||
@ -498,7 +504,7 @@ void GuiElement::SetEffectGrow()
|
|||||||
|
|
||||||
void GuiElement::StopEffect()
|
void GuiElement::StopEffect()
|
||||||
{
|
{
|
||||||
xoffsetDyn = 0;
|
xoffsetDyn = 0;
|
||||||
yoffsetDyn = 0;
|
yoffsetDyn = 0;
|
||||||
effects = 0;
|
effects = 0;
|
||||||
effectsOver = 0;
|
effectsOver = 0;
|
||||||
@ -507,10 +513,10 @@ void GuiElement::StopEffect()
|
|||||||
effectTarget = 0;
|
effectTarget = 0;
|
||||||
effectTargetOver = 0;
|
effectTargetOver = 0;
|
||||||
scaleDyn = 1;
|
scaleDyn = 1;
|
||||||
frequency = 0;
|
frequency = 0.0f;
|
||||||
changervar = 0;
|
changervar = 0;
|
||||||
angleDyn = 0;
|
//angleDyn = 0.0f;
|
||||||
anglespeed = 0.0;
|
anglespeed = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiElement::UpdateEffects()
|
void GuiElement::UpdateEffects()
|
||||||
@ -596,24 +602,23 @@ void GuiElement::UpdateEffects()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(effects & EFFECT_GOROUND) {
|
if(effects & EFFECT_GOROUND) {
|
||||||
|
|
||||||
//!< check out gui.h for info
|
//!< check out gui.h for info
|
||||||
xoffset = temp_xoffset;
|
xoffset = temp_xoffset;
|
||||||
yoffset = temp_yoffset;
|
yoffset = temp_yoffset;
|
||||||
|
if(fabs(frequency) < circleamount) {
|
||||||
if(fabs(frequency) < PI*((f32) circleamount)/180.0f) {
|
angleDyn = (frequency+degree+90.0f) * anglespeed;
|
||||||
|
xoffsetDyn = (int) lround(((f32) Radius)*cos((frequency+degree)*PI/180.0f));
|
||||||
angleDyn = ((frequency+degree) * 180.0f/PI + 90.0f) * anglespeed;
|
yoffsetDyn = (int) lround(((f32) Radius)*sin((frequency+degree)*PI/180.0f));
|
||||||
frequency += effectAmount*0.001f;
|
frequency += ((f32) effectAmount)*0.01f;
|
||||||
|
|
||||||
xoffsetDyn = (int)(Radius*cos(frequency+degree));
|
|
||||||
yoffsetDyn = (int)(Radius*sin(frequency+degree));
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
effects = 0;
|
f32 temp_frequency = ((effectAmount<0)?-1.0f:1.0f)*circleamount;
|
||||||
frequency = 0;
|
angleDyn = (temp_frequency+degree+90.0f) * anglespeed;
|
||||||
|
xoffsetDyn = (int) lround(((f32) Radius)*cos((temp_frequency+degree)*PI/180.0f));
|
||||||
|
yoffsetDyn = (int) lround(((f32) Radius)*sin((temp_frequency+degree)*PI/180.0f));
|
||||||
xoffset += xoffsetDyn;
|
xoffset += xoffsetDyn;
|
||||||
yoffset += yoffsetDyn;
|
yoffset += yoffsetDyn;
|
||||||
|
effects ^= EFFECT_GOROUND;
|
||||||
|
frequency = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,16 @@
|
|||||||
#include "../cfg.h"
|
#include "../cfg.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#define GAMESELECTSIZE 30
|
#define SCALE 0.8f
|
||||||
|
#define DEG_OFFSET 7
|
||||||
|
#define RADIUS 780
|
||||||
|
#define IN_SPEED 175
|
||||||
|
#define SHIFT_SPEED 100
|
||||||
|
#define PAGESIZE 9
|
||||||
|
|
||||||
extern const int vol;
|
extern const int vol;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,14 +35,12 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int gameCnt,
|
|||||||
height = h;
|
height = h;
|
||||||
this->gameCnt = gameCnt;
|
this->gameCnt = gameCnt;
|
||||||
gameList = l;
|
gameList = l;
|
||||||
pagesize = 7;
|
pagesize = (gameCnt < PAGESIZE) ? gameCnt : PAGESIZE;
|
||||||
changed = 0;
|
|
||||||
selectable = true;
|
|
||||||
listOffset = (offset == 0) ? this->FindMenuItem(-1, 1) : offset;
|
listOffset = (offset == 0) ? this->FindMenuItem(-1, 1) : offset;
|
||||||
|
selectable = true;
|
||||||
selectedItem = selected - offset;
|
selectedItem = selected - offset;
|
||||||
focus = 1; // allow focus
|
focus = 1; // allow focus
|
||||||
firstPic = 0;
|
firstPic = 0;
|
||||||
speed = 50000;
|
|
||||||
char imgPath[100];
|
char imgPath[100];
|
||||||
|
|
||||||
trigA = new GuiTrigger;
|
trigA = new GuiTrigger;
|
||||||
@ -58,10 +63,12 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int gameCnt,
|
|||||||
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path);
|
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path);
|
||||||
imgRight = new GuiImageData(imgPath, startgame_arrow_right_png);
|
imgRight = new GuiImageData(imgPath, startgame_arrow_right_png);
|
||||||
|
|
||||||
|
int btnHeight = (int) lround(sqrt(RADIUS*RADIUS - 90000)-RADIUS-50);
|
||||||
|
|
||||||
btnLeftImg = new GuiImage(imgLeft);
|
btnLeftImg = new GuiImage(imgLeft);
|
||||||
btnLeft = new GuiButton(imgLeft->GetWidth(), imgLeft->GetHeight());
|
btnLeft = new GuiButton(imgLeft->GetWidth(), imgLeft->GetHeight());
|
||||||
btnLeft->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
btnLeft->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||||
btnLeft->SetPosition(20, -100);
|
btnLeft->SetPosition(20, btnHeight);
|
||||||
btnLeft->SetParent(this);
|
btnLeft->SetParent(this);
|
||||||
btnLeft->SetImage(btnLeftImg);
|
btnLeft->SetImage(btnLeftImg);
|
||||||
btnLeft->SetSoundOver(btnSoundOver);
|
btnLeft->SetSoundOver(btnSoundOver);
|
||||||
@ -74,7 +81,7 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int gameCnt,
|
|||||||
btnRight = new GuiButton(imgRight->GetWidth(), imgRight->GetHeight());
|
btnRight = new GuiButton(imgRight->GetWidth(), imgRight->GetHeight());
|
||||||
btnRight->SetParent(this);
|
btnRight->SetParent(this);
|
||||||
btnRight->SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
|
btnRight->SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
|
||||||
btnRight->SetPosition(-20, -100);
|
btnRight->SetPosition(-20, btnHeight);
|
||||||
btnRight->SetImage(btnRightImg);
|
btnRight->SetImage(btnRightImg);
|
||||||
btnRight->SetSoundOver(btnSoundOver);
|
btnRight->SetSoundOver(btnSoundOver);
|
||||||
btnRight->SetTrigger(trigA);
|
btnRight->SetTrigger(trigA);
|
||||||
@ -86,9 +93,9 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int gameCnt,
|
|||||||
game = new GuiButton * [pagesize];
|
game = new GuiButton * [pagesize];
|
||||||
coverImg = new GuiImage * [pagesize];
|
coverImg = new GuiImage * [pagesize];
|
||||||
cover = new GuiImageData * [pagesize];
|
cover = new GuiImageData * [pagesize];
|
||||||
bob = new int[7];
|
bob = new int[pagesize];
|
||||||
|
|
||||||
for(int i=0; i<7; i++) {
|
for(int i=0; i<pagesize; i++) {
|
||||||
bob[i]=i;
|
bob[i]=i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +103,7 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int gameCnt,
|
|||||||
char IDfull[7];
|
char IDfull[7];
|
||||||
for(int i=0; i < pagesize; i++) {
|
for(int i=0; i < pagesize; i++) {
|
||||||
|
|
||||||
struct discHdr *header = &gameList[i];
|
struct discHdr *header = &gameList[(listOffset+i)%gameCnt];
|
||||||
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
|
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
|
||||||
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
|
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
|
||||||
|
|
||||||
@ -117,7 +124,7 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int gameCnt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
coverImg[i] = new GuiImage(cover[i]);
|
coverImg[i] = new GuiImage(cover[i]);
|
||||||
coverImg[i]->SetScale(0.8);
|
coverImg[i]->SetScale(SCALE);
|
||||||
coverImg[i]->SetWidescreen(CFG.widescreen);
|
coverImg[i]->SetWidescreen(CFG.widescreen);
|
||||||
game[i] = new GuiButton(122,244);
|
game[i] = new GuiButton(122,244);
|
||||||
game[i]->SetParent(this);
|
game[i]->SetParent(this);
|
||||||
@ -127,7 +134,7 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int gameCnt,
|
|||||||
game[i]->SetRumble(false);
|
game[i]->SetRumble(false);
|
||||||
game[i]->SetTrigger(trigA);
|
game[i]->SetTrigger(trigA);
|
||||||
game[i]->SetSoundClick(btnSoundClick);
|
game[i]->SetSoundClick(btnSoundClick);
|
||||||
game[i]->SetEffect(EFFECT_GOROUND, -50, 49, 780, 298+7*i, 1, 0, 740);
|
game[i]->SetEffect(EFFECT_GOROUND, IN_SPEED, 90-(pagesize-2*i-1)*DEG_OFFSET/2, RADIUS, 180, 1, 0, RADIUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +177,7 @@ void GuiGameCarousel::SetFocus(int f)
|
|||||||
game[i]->ResetState();
|
game[i]->ResetState();
|
||||||
|
|
||||||
if(f == 1)
|
if(f == 1)
|
||||||
game[selectedItem]->SetState(STATE_SELECTED);
|
game[bob[selectedItem]]->SetState(STATE_SELECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -190,7 +197,7 @@ void GuiGameCarousel::ResetState()
|
|||||||
|
|
||||||
int GuiGameCarousel::GetOffset()
|
int GuiGameCarousel::GetOffset()
|
||||||
{
|
{
|
||||||
return changed;
|
return listOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -198,9 +205,9 @@ int GuiGameCarousel::GetClickedOption()
|
|||||||
{
|
{
|
||||||
int found = -1;
|
int found = -1;
|
||||||
for(int i=0; i<pagesize; i++) {
|
for(int i=0; i<pagesize; i++) {
|
||||||
if(game[i]->GetState() == STATE_CLICKED) {
|
if(game[bob[i]]->GetState() == STATE_CLICKED) {
|
||||||
game[i]->SetState(STATE_SELECTED);
|
game[bob[i]]->SetState(STATE_SELECTED);
|
||||||
found = changed+i;
|
found = listOffset+i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,9 +219,9 @@ int GuiGameCarousel::GetSelectedOption()
|
|||||||
{
|
{
|
||||||
int found = -1;
|
int found = -1;
|
||||||
for(int i=0; i<pagesize; i++) {
|
for(int i=0; i<pagesize; i++) {
|
||||||
if(game[i]->GetState() == STATE_SELECTED) {
|
if(game[bob[i]]->GetState() == STATE_SELECTED) {
|
||||||
game[i]->SetState(STATE_SELECTED);
|
game[bob[i]]->SetState(STATE_SELECTED);
|
||||||
found = changed+i;
|
found = listOffset+i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,7 +240,10 @@ int GuiGameCarousel::FindMenuItem(int currentItem, int direction)
|
|||||||
int nextItem = currentItem + direction;
|
int nextItem = currentItem + direction;
|
||||||
|
|
||||||
if(nextItem < 0 || nextItem >= gameCnt)
|
if(nextItem < 0 || nextItem >= gameCnt)
|
||||||
return -1;
|
if(gameCnt <= pagesize)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
nextItem = (nextItem < 0) ? nextItem + gameCnt : nextItem - gameCnt;
|
||||||
|
|
||||||
if(strlen(get_title(&gameList[nextItem])) > 0)
|
if(strlen(get_title(&gameList[nextItem])) > 0)
|
||||||
return nextItem;
|
return nextItem;
|
||||||
@ -260,8 +270,11 @@ void GuiGameCarousel::Draw()
|
|||||||
} else break;
|
} else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
btnRight->Draw();
|
if(gameCnt > pagesize) {
|
||||||
btnLeft->Draw();
|
btnRight->Draw();
|
||||||
|
btnLeft->Draw();
|
||||||
|
}
|
||||||
|
|
||||||
this->UpdateEffects();
|
this->UpdateEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,8 +285,8 @@ void GuiGameCarousel::Update(GuiTrigger * t)
|
|||||||
if(state == STATE_DISABLED || !t)
|
if(state == STATE_DISABLED || !t)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(game[0]->GetEffect() == 0) {
|
if(!(game[0]->GetEffect() || game[0]->GetEffectOnOver())) {
|
||||||
for(int i=0; i<7; i++) {
|
for(int i=0; i<pagesize; i++) {
|
||||||
game[i]->SetEffectGrow();
|
game[i]->SetEffectGrow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,89 +302,112 @@ void GuiGameCarousel::Update(GuiTrigger * t)
|
|||||||
|
|
||||||
for(int i=0; i<pagesize; i++) {
|
for(int i=0; i<pagesize; i++) {
|
||||||
if(next >= 0) {
|
if(next >= 0) {
|
||||||
if(game[i]->GetState() == STATE_DISABLED) {
|
if(game[bob[i]]->GetState() == STATE_DISABLED) {
|
||||||
game[i]->SetVisible(true);
|
game[bob[i]]->SetVisible(true);
|
||||||
game[i]->SetState(STATE_DEFAULT);
|
game[bob[i]]->SetState(STATE_DEFAULT);
|
||||||
}
|
}
|
||||||
gameIndex[i] = next;
|
gameIndex[i] = next;
|
||||||
next = this->FindMenuItem(next, 1);
|
next = this->FindMenuItem(next, 1);
|
||||||
} else {
|
} else {
|
||||||
game[i]->SetVisible(false);
|
game[bob[i]]->SetVisible(false);
|
||||||
game[i]->SetState(STATE_DISABLED);
|
game[bob[i]]->SetState(STATE_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(focus) {
|
if(focus) {
|
||||||
if(i != selectedItem && game[i]->GetState() == STATE_SELECTED)
|
if(i != selectedItem && game[bob[i]]->GetState() == STATE_SELECTED)
|
||||||
game[i]->ResetState();
|
game[bob[i]]->ResetState();
|
||||||
else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT);
|
else if(i == selectedItem && game[bob[i]]->GetState() == STATE_DEFAULT);
|
||||||
game[selectedItem]->SetState(STATE_SELECTED, t->chan);
|
game[bob[selectedItem]]->SetState(STATE_SELECTED, t->chan);
|
||||||
}
|
}
|
||||||
game[i]->Update(t);
|
game[bob[i]]->Update(t);
|
||||||
|
|
||||||
if(game[i]->GetState() == STATE_SELECTED) {
|
if(game[bob[i]]->GetState() == STATE_SELECTED) {
|
||||||
selectedItem = i;
|
selectedItem = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// navigation
|
// navigation
|
||||||
if(!focus)
|
if(!focus || game[0]->GetEffect() || gameCnt <= pagesize)
|
||||||
return; // skip navigation
|
return; // skip navigation
|
||||||
|
|
||||||
if (t->Left() || btnLeft->GetState() == STATE_CLICKED) {
|
if (t->Left() || btnLeft->GetState() == STATE_CLICKED) {
|
||||||
changed++;
|
WPAD_ScanPads();
|
||||||
if (changed > (gameCnt-1))
|
u16 buttons = 0;
|
||||||
changed=0;
|
for(int i=0; i<4; i++)
|
||||||
|
buttons |= WPAD_ButtonsHeld(i);
|
||||||
|
if(!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_MINUS) || t->Left())) {
|
||||||
|
btnLeft->ResetState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i<pagesize; i++) {
|
||||||
|
game[i]->StopEffect();
|
||||||
|
}
|
||||||
|
listOffset++;
|
||||||
|
if (listOffset > (gameCnt-1))
|
||||||
|
listOffset=0;
|
||||||
firstPic++;
|
firstPic++;
|
||||||
if (firstPic>6)
|
if (firstPic > (pagesize-1))
|
||||||
firstPic=0;
|
firstPic=0;
|
||||||
|
|
||||||
for (int i=0; i<7; i++) {
|
for (int i=0; i<pagesize; i++) {
|
||||||
bob[i] = (firstPic+i < 7) ? firstPic+i : firstPic+i-7;
|
bob[i] = (firstPic+i)%pagesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = (changed+7 < gameCnt) ? changed+7 : changed+7-gameCnt;
|
struct discHdr *header = &gameList[(listOffset + pagesize-1) % gameCnt];
|
||||||
struct discHdr *header = &gameList[index];
|
|
||||||
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
|
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
|
||||||
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
|
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
|
||||||
delete cover[bob[6]];
|
delete cover[bob[pagesize-1]];
|
||||||
snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, IDfull); //Load full id image
|
snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, IDfull); //Load full id image
|
||||||
cover[bob[6]] = new GuiImageData(imgPath,0);
|
cover[bob[pagesize-1]] = new GuiImageData(imgPath,0);
|
||||||
if (!cover[bob[6]]->GetImage()) {
|
if (!cover[bob[pagesize-1]]->GetImage()) {
|
||||||
delete cover[bob[6]];
|
delete cover[bob[pagesize-1]];
|
||||||
snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, ID); //Load short id image
|
snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, ID); //Load short id image
|
||||||
cover[bob[6]] = new GuiImageData(imgPath, 0);
|
cover[bob[pagesize-1]] = new GuiImageData(imgPath, 0);
|
||||||
if (!cover[bob[6]]->GetImage()) {
|
if (!cover[bob[pagesize-1]]->GetImage()) {
|
||||||
delete cover[bob[6]];
|
delete cover[bob[pagesize-1]];
|
||||||
snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.covers_path); //Load no image
|
snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.covers_path); //Load no image
|
||||||
cover[bob[6]] = new GuiImageData(imgPath, nocover_png);
|
cover[bob[pagesize-1]] = new GuiImageData(imgPath, nocover_png);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete coverImg[bob[6]];
|
delete coverImg[bob[pagesize-1]];
|
||||||
coverImg[bob[6]] = new GuiImage(cover[bob[6]]);
|
coverImg[bob[pagesize-1]] = new GuiImage(cover[bob[pagesize-1]]);
|
||||||
coverImg[bob[6]]->SetScale(0.8);
|
coverImg[bob[pagesize-1]]->SetScale(SCALE);
|
||||||
coverImg[bob[6]]->SetWidescreen(CFG.widescreen);
|
coverImg[bob[pagesize-1]]->SetWidescreen(CFG.widescreen);
|
||||||
game[bob[6]]->SetImage(coverImg[bob[6]]);
|
game[bob[pagesize-1]]->SetImage(coverImg[bob[pagesize-1]]);
|
||||||
|
game[bob[pagesize-1]]->SetPosition(0, RADIUS);
|
||||||
|
|
||||||
for (int i=0; i<7; i++) {
|
for (int i=0; i<pagesize; i++) {
|
||||||
game[bob[i]]->SetEffect(EFFECT_GOROUND, -50, 7, 780, 256+7*i, 1, 0, 740);
|
//game[bob[i]]->SetEffect(EFFECT_GOROUND, -125, 7, 780, 256+7*i, 1, 0, 740);
|
||||||
|
game[bob[i]]->SetEffect(EFFECT_GOROUND, -SHIFT_SPEED, DEG_OFFSET, RADIUS, 270-(pagesize-2*i-3)*DEG_OFFSET/2, 1, 0, RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
btnLeft->ResetState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(t->Right() || btnRight->GetState() == STATE_CLICKED) {
|
else if(t->Right() || btnRight->GetState() == STATE_CLICKED) {
|
||||||
changed--;
|
WPAD_ScanPads();
|
||||||
if (changed<0)
|
u16 buttons = 0;
|
||||||
changed=(gameCnt-1);
|
for(int i=0; i<4; i++)
|
||||||
firstPic--;
|
buttons |= WPAD_ButtonsHeld(i);
|
||||||
if (firstPic<0)
|
if(!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_PLUS) || t->Right())) {
|
||||||
firstPic=6;
|
btnRight->ResetState();
|
||||||
|
return;
|
||||||
for(int i=0; i<7; i++) {
|
|
||||||
bob[i] = (firstPic+i < 7) ? firstPic+i : firstPic+i-7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct discHdr *header = &gameList[changed];
|
for(int i=0; i<pagesize; i++) {
|
||||||
|
game[i]->StopEffect();
|
||||||
|
}
|
||||||
|
listOffset--;
|
||||||
|
if (listOffset<0)
|
||||||
|
listOffset=(gameCnt-1);
|
||||||
|
firstPic--;
|
||||||
|
if (firstPic<0)
|
||||||
|
firstPic=(pagesize-1);
|
||||||
|
|
||||||
|
for(int i=0; i<pagesize; i++) {
|
||||||
|
bob[i] = (firstPic+i)%pagesize;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct discHdr *header = &gameList[listOffset];
|
||||||
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
|
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
|
||||||
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
|
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
|
||||||
delete cover[bob[0]];
|
delete cover[bob[0]];
|
||||||
@ -389,15 +425,15 @@ void GuiGameCarousel::Update(GuiTrigger * t)
|
|||||||
}
|
}
|
||||||
delete coverImg[bob[0]];
|
delete coverImg[bob[0]];
|
||||||
coverImg[bob[0]] = new GuiImage(cover[bob[0]]);
|
coverImg[bob[0]] = new GuiImage(cover[bob[0]]);
|
||||||
coverImg[bob[0]]->SetScale(0.8);
|
coverImg[bob[0]]->SetScale(SCALE);
|
||||||
coverImg[bob[0]]->SetWidescreen(CFG.widescreen);
|
coverImg[bob[0]]->SetWidescreen(CFG.widescreen);
|
||||||
game[bob[0]]->SetImage(coverImg[bob[0]]);
|
game[bob[0]]->SetImage(coverImg[bob[0]]);
|
||||||
|
game[bob[0]]->SetPosition(0, RADIUS);
|
||||||
|
|
||||||
for(int i=0; i<7; i++) {
|
for(int i=0; i<pagesize; i++) {
|
||||||
game[bob[i]]->SetEffect(EFFECT_GOROUND, 50, 7, 780, 242+7*i, 1, 0, 740);
|
//game[bob[i]]->SetEffect(EFFECT_GOROUND, 125, 7, 780, 242+7*i, 1, 0, 740);
|
||||||
|
game[bob[i]]->SetEffect(EFFECT_GOROUND, SHIFT_SPEED, DEG_OFFSET, RADIUS, 270-(pagesize-2*i+1)*DEG_OFFSET/2, 1, 0, RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
btnRight->ResetState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(updateCB)
|
if(updateCB)
|
||||||
@ -408,23 +444,24 @@ void GuiGameCarousel::Update(GuiTrigger * t)
|
|||||||
void GuiGameCarousel::Reload(struct discHdr * l, int count)
|
void GuiGameCarousel::Reload(struct discHdr * l, int count)
|
||||||
{
|
{
|
||||||
LOCK(this);
|
LOCK(this);
|
||||||
gameList = l;
|
|
||||||
gameCnt = count;
|
gameCnt = count;
|
||||||
changed=0;
|
gameList = l;
|
||||||
selectedItem = 0;
|
pagesize = (gameCnt < PAGESIZE) ? gameCnt : PAGESIZE;
|
||||||
listOffset = 0;
|
listOffset = this->FindMenuItem(-1, 1);
|
||||||
|
selectedItem = 0 + listOffset;
|
||||||
|
focus = 1;
|
||||||
firstPic = 0;
|
firstPic = 0;
|
||||||
|
char imgPath[100];
|
||||||
|
|
||||||
for(int i=0; i<7; i++) {
|
for(int i=0; i<pagesize; i++) {
|
||||||
bob[i]=i;
|
bob[i]=i;
|
||||||
}
|
}
|
||||||
|
|
||||||
char ID[4];
|
char ID[4];
|
||||||
char IDfull[7];
|
char IDfull[7];
|
||||||
char imgPath[100];
|
|
||||||
for(int i=0; i < pagesize; i++) {
|
for(int i=0; i < pagesize; i++) {
|
||||||
|
|
||||||
struct discHdr *header = &gameList[i];
|
struct discHdr *header = &gameList[(listOffset+i)%gameCnt];
|
||||||
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
|
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
|
||||||
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
|
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
|
||||||
|
|
||||||
@ -445,7 +482,7 @@ void GuiGameCarousel::Reload(struct discHdr * l, int count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
coverImg[i] = new GuiImage(cover[i]);
|
coverImg[i] = new GuiImage(cover[i]);
|
||||||
coverImg[i]->SetScale(0.8);
|
coverImg[i]->SetScale(SCALE);
|
||||||
coverImg[i]->SetWidescreen(CFG.widescreen);
|
coverImg[i]->SetWidescreen(CFG.widescreen);
|
||||||
game[i] = new GuiButton(122,244);
|
game[i] = new GuiButton(122,244);
|
||||||
game[i]->SetParent(this);
|
game[i]->SetParent(this);
|
||||||
@ -455,6 +492,7 @@ void GuiGameCarousel::Reload(struct discHdr * l, int count)
|
|||||||
game[i]->SetRumble(false);
|
game[i]->SetRumble(false);
|
||||||
game[i]->SetTrigger(trigA);
|
game[i]->SetTrigger(trigA);
|
||||||
game[i]->SetSoundClick(btnSoundClick);
|
game[i]->SetSoundClick(btnSoundClick);
|
||||||
game[i]->SetEffect(EFFECT_GOROUND, -50, 49, 780, 305+7*i, 1, 0, 740);
|
game[i]->SetEffect(EFFECT_GOROUND, IN_SPEED, 180-(pagesize-2*i-1)*DEG_OFFSET/2, RADIUS, 180, 1, 0, RADIUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ class GuiGameCarousel : public GuiElement
|
|||||||
int listOffset;
|
int listOffset;
|
||||||
int scrollbaron;
|
int scrollbaron;
|
||||||
int pagesize;
|
int pagesize;
|
||||||
int changed;
|
|
||||||
int firstPic;
|
int firstPic;
|
||||||
int speed;
|
int speed;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user