Some changes to the Carousel:

*Added a ToolTip
*Added GameName under the covers
*Fixed Crash with no Favorites in list.

NOTE: I'll add a better coming out effect for the covers, for now there is only a slow big ZoomOut which isnt too bad either.
This commit is contained in:
dimok321 2009-08-01 14:42:12 +00:00
parent 97b0ffc1f5
commit d5fb3ff33f
10 changed files with 444 additions and 404 deletions

File diff suppressed because one or more lines are too long

View File

@ -378,7 +378,7 @@ class GuiElement
//!Sets the element's position
//!\param x X coordinate
//!\param y Y coordinate
void SetPosition(int x, int y);
void SetPosition(int x, int y, int z = 0);
//!Updates the element's effects (dynamic values)
//!Called by Draw(), used for animation purposes
void UpdateEffects();
@ -427,6 +427,7 @@ class GuiElement
int height; //!< Element height
int xoffset; //!< Element X offset
int yoffset; //!< Element Y offset
int zoffset; //!< Element Z offset
int ymin; //!< Element's min Y offset allowed
int ymax; //!< Element's max Y offset allowed
int xmin; //!< Element's min X offset allowed
@ -638,6 +639,8 @@ class GuiImage : public GuiElement
void SetPixel(int x, int y, GXColor color);
//!Sets the image to grayscale
void SetGrayscale(void);
//!Set/disable the use of parentelement angle (default true)
void SetParentAngle(bool a);
//!Directly modifies the image data to create a color-striped effect
//!Alters the RGB values by the specified amount
//!\param s Amount to increment/decrement the RGB values in the image
@ -648,7 +651,6 @@ class GuiImage : public GuiElement
void SetStripe(int s);
s32 z;
void SetSkew(int XX1, int YY1,int XX2, int YY2,int XX3, int YY3,int XX4, int YY4);
int xx1;
int yy1;
int xx2;
@ -672,6 +674,7 @@ class GuiImage : public GuiElement
int tile; //!< Number of times to draw (tile) the image horizontally
int stripe; //!< Alpha value (0-255) to apply a stripe effect to the texture
short widescreen; //added
bool parentangle;
};
//!Display, manage, and manipulate text in the GUI
@ -874,7 +877,7 @@ class GuiButton : public GuiElement
//!Constantly called to draw the GuiButtons ToolTip
//!Sets the button's Tooltip on over
//!\param tt Pointer to GuiElement object, x & y Positioning, h & v Align
void SetToolTip(GuiElement* tt, int x, int y, int h=ALIGN_RIGHT, int v=ALIGN_TOP);
void SetToolTip(GuiTooltip* tt, int x, int y, int h=ALIGN_RIGHT, int v=ALIGN_TOP);
void RemoveToolTip();
//!Constantly called to draw the GuiButton
@ -895,7 +898,7 @@ class GuiButton : public GuiElement
GuiImage * iconOver; //!< Button icon for STATE_SELECTED
GuiImage * iconHold; //!< Button icon for STATE_HELD
GuiImage * iconClick; //!< Button icon for STATE_CLICKED
GuiElement *toolTip;
GuiTooltip *toolTip;
time_t time1, time2;//!< Tooltip timeconstants
GuiText * label[3]; //!< Label(s) to display (default)
GuiText * labelOver[3]; //!< Label(s) to display for STATE_SELECTED

View File

@ -232,7 +232,7 @@ void GuiButton::SetSoundClick(GuiSound * snd)
soundClick = snd;
}
void GuiButton::SetToolTip(GuiElement* tt, int x, int y, int h_align, int v_align)
void GuiButton::SetToolTip(GuiTooltip* tt, int x, int y, int h_align, int v_align)
{
LOCK(this);
if(tt)

View File

@ -18,6 +18,7 @@ GuiElement::GuiElement()
{
xoffset = 0;
yoffset = 0;
zoffset = 0;
xmin = 0;
xmax = 0;
ymin = 0;
@ -705,11 +706,12 @@ void GuiElement::SetUpdateCallback(UpdateCallback u)
updateCB = u;
}
void GuiElement::SetPosition(int xoff, int yoff)
void GuiElement::SetPosition(int xoff, int yoff, int zoff)
{
LOCK(this);
xoffset = xoff;
yoffset = yoff;
zoffset = zoff;
}
void GuiElement::SetAlignment(int hor, int vert)

View File

@ -37,9 +37,9 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int count, co
gameCnt = count;
gameList = l;
pagesize = (gameCnt < PAGESIZE) ? gameCnt : PAGESIZE;
listOffset = (offset == 0) ? this->FindMenuItem(-1, 1) : offset;
listOffset = 0;
selectable = true;
selectedItem = selected - offset;
selectedItem = 0;
if (selectedItem==0)selectedItem=(pagesize+1)/2;
focus = 1; // allow focus
firstPic = 0;
@ -98,6 +98,14 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int count, co
ResumeBufferThread(listOffset);
ttgame = new GuiTooltip(" ");
gamename = new GuiText(" ", 18, (GXColor) {THEME.info_r, THEME.info_g, THEME.info_b, 255});
gamename->SetParent(this);
gamename->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
gamename->SetPosition(0, 330);
gamename->SetMaxWidth(280, GuiText::DOTTED);
gameIndex = new int[pagesize];
game = new GuiButton * [pagesize];
@ -138,6 +146,8 @@ GuiGameCarousel::~GuiGameCarousel()
delete trigMinus;
delete btnSoundClick;
delete btnSoundOver;
delete ttgame;
delete gamename;
for(int i=0; i<pagesize; i++) {
delete game[i];
@ -151,6 +161,8 @@ GuiGameCarousel::~GuiGameCarousel()
void GuiGameCarousel::SetFocus(int f)
{
LOCK(this);
if(!gameCnt) return;
focus = f;
for(int i=0; i<pagesize; i++)
@ -241,7 +253,7 @@ int GuiGameCarousel::FindMenuItem(int currentItem, int direction)
void GuiGameCarousel::Draw()
{
LOCK(this);
if(!this->IsVisible())
if(!this->IsVisible() || !gameCnt)
return;
int next = listOffset;
@ -254,6 +266,17 @@ void GuiGameCarousel::Draw()
} else break;
}
//!Draw tooltip after the Images to have it on top
for(int i=0; i<pagesize; i++) {
if(next >= 0) {
if(Settings.tooltips == TooltipsOn)
game[i]->DrawTooltip();
next = this->FindMenuItem(next, 1);
} else break;
}
gamename->Draw();
if(gameCnt > pagesize) {
btnRight->Draw();
btnLeft->Draw();
@ -266,7 +289,7 @@ void GuiGameCarousel::Draw()
void GuiGameCarousel::Update(GuiTrigger * t)
{
LOCK(this);
if(state == STATE_DISABLED || !t)
if(state == STATE_DISABLED || !t || !gameCnt)
return;
if(!(game[0]->GetEffect() || game[0]->GetEffectOnOver())) {
@ -302,7 +325,9 @@ void GuiGameCarousel::Update(GuiTrigger * t)
if(game[i]->GetState() == STATE_DISABLED) {
game[i]->SetVisible(true);
game[i]->SetState(STATE_DEFAULT);
game[i]->RemoveToolTip();
}
game[i]->SetEffectOnOver(EFFECT_SCALE, 1, 130);
gameIndex[i] = next;
next = this->FindMenuItem(next, 1);
} else {
@ -313,7 +338,7 @@ void GuiGameCarousel::Update(GuiTrigger * t)
if(focus) {
if(i != selectedItem && game[i]->GetState() == STATE_SELECTED)
game[i]->ResetState();
else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT);
else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT)
game[selectedItem]->SetState(STATE_SELECTED, t->chan);
}
game[i]->Update(t);
@ -324,10 +349,22 @@ void GuiGameCarousel::Update(GuiTrigger * t)
if(game[i]->GetState() == STATE_CLICKED) {
clickedItem = i;
}
}
// navigation
///Tooltip stuff
struct discHdr *header = &gameList[this->GetSelectedOption()];
ttgame->SetText(get_title(header));
game[selectedItem]->SetToolTip(ttgame, 0, 0);
ttgame->SetPosition(0, 20);
if(selectedItem < PAGESIZE/2+1)
ttgame->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
else
ttgame->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
///GameText
gamename->SetText(get_title(header));
/// navigation
if(!focus || gameCnt <= pagesize || (game[0]->GetEffect() && game[pagesize-1]->GetEffect()))
return; // skip navigation

View File

@ -35,6 +35,10 @@ class GuiGameCarousel : public GuiElement
GuiButton ** game;
GuiTooltip * ttgame;
GuiText * gamename;
GuiButton * btnRight;
GuiButton * btnLeft;

View File

@ -132,26 +132,16 @@ GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int count, const char
btnRowDown->SetPosition(0,0);
btnRowDown->SetTrigger(trig1);
// titleTxt = new GuiText("test");
titleTT = new GuiTooltip("test");
titleTT = new GuiTooltip(" ");
titleTT->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTT->SetPosition(-100,0);
titleTT->SetAlpha(THEME.tooltipAlpha);
// if (Settings.wsprompt == yes)
// installBtnTT.SetWidescreen(CFG.widescreen);
//if (count>0){
gameIndex = new int[pagesize];
game = new GuiButton * [pagesize];
bob = new int[pagesize];
coverImg = new GuiImage * [gameCnt];
cover = new GuiImageData * [gameCnt];
//titleTxt = new GuiText * [gameCnt];
for(int i=0; i<pagesize; i++) {
bob[i]=i;
@ -160,7 +150,7 @@ GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int count, const char
char ID[4];
char IDfull[7];
int n = gameCnt>pagesize?gameCnt:pagesize;
//for(int i=0; i < gameCnt; i++) {
for(int i=0; i < n; i++) {
struct discHdr *header = &gameList[i];

View File

@ -41,6 +41,7 @@ GuiImage::GuiImage(GuiImageData * img)
tile = -1;
stripe = 0;
widescreen = 0;
parentangle = true;
xx1 = 0;
yy1 = 0;
xx2 = 0;
@ -61,6 +62,7 @@ GuiImage::GuiImage(u8 * img, int w, int h)
tile = -1;
stripe = 0;
widescreen = 0;
parentangle = true;
xx1 = 0;
yy1 = 0;
xx2 = 0;
@ -81,6 +83,7 @@ GuiImage::GuiImage(int w, int h, GXColor c)
tile = -1;
stripe = 0;
widescreen = 0;
parentangle = true;
xx1 = 0;
yy1 = 0;
xx2 = 0;
@ -126,6 +129,7 @@ GuiImage::GuiImage(GuiImage &srcimage)
tile = -1;
stripe = 0;
widescreen = 0;
parentangle = true;
xx1 = 0;
yy1 = 0;
xx2 = 0;
@ -155,6 +159,7 @@ GuiImage::GuiImage(GuiImage *srcimage)
tile = -1;
stripe = 0;
widescreen = 0;
parentangle = true;
xx1 = 0;
yy1 = 0;
xx2 = 0;
@ -184,6 +189,7 @@ GuiImage &GuiImage::operator=(GuiImage &srcimage)
tile = -1;
stripe = 0;
widescreen = 0;
parentangle = true;
xx1 = 0;
yy1 = 0;
xx2 = 0;
@ -260,6 +266,11 @@ void GuiImage::SetWidescreen(bool w)
LOCK(this);
widescreen = w;
}
void GuiImage::SetParentAngle(bool a)
{
LOCK(this);
parentangle = a;
}
GXColor GuiImage::GetPixel(int x, int y)
{
@ -402,7 +413,7 @@ void GuiImage::Draw()
float currAngleDyn = this->GetAngleDyn();
if(currAngleDyn)
if(currAngleDyn && parentangle)
imageangle = currAngleDyn;
@ -410,7 +421,7 @@ void GuiImage::Draw()
if(tile > 0)
{
for(int i=0; i<tile; i++)
Menu_DrawImg(currLeft+width*i, this->GetTop(), 0, width, height, image, imageangle, widescreen ? currScale*0.80 : currScale, currScale, this->GetAlpha(), xx1,yy1,xx2,yy2,xx3,yy3,xx4,yy4);
Menu_DrawImg(currLeft+width*i, this->GetTop(), zoffset, width, height, image, imageangle, widescreen ? currScale*0.80 : currScale, currScale, this->GetAlpha(), xx1,yy1,xx2,yy2,xx3,yy3,xx4,yy4);
}
else
{
@ -418,7 +429,7 @@ void GuiImage::Draw()
if(scale != 1)
currLeft = currLeft - width/2 + (width*scale)/2;
Menu_DrawImg(currLeft, this->GetTop(), 0, width, height, image, imageangle, widescreen ? currScale*0.80 : currScale, currScale, this->GetAlpha(), xx1,yy1,xx2,yy2,xx3,yy3,xx4,yy4);
Menu_DrawImg(currLeft, this->GetTop(), zoffset, width, height, image, imageangle, widescreen ? currScale*0.80 : currScale, currScale, this->GetAlpha(), xx1,yy1,xx2,yy2,xx3,yy3,xx4,yy4);
}
if(stripe > 0)

View File

@ -27,6 +27,9 @@ leftImage(&tooltipLeft), tileImage(&tooltipTile), rightImage(&tooltipRight)
leftImage.SetParent(this);
tileImage.SetParent(this);
rightImage.SetParent(this);
leftImage.SetParentAngle(false);
tileImage.SetParentAngle(false);
rightImage.SetParentAngle(false);
SetText(t);
}
@ -42,9 +45,6 @@ float GuiTooltip::GetScale()
{
float s = scale * scaleDyn;
// if(parentElement)
// s *= parentElement->GetScale();
return s;
}

View File

@ -669,10 +669,6 @@ int MenuDiscList() {
ResumeGui();
while (menu == MENU_NONE) {
if (idiotFlag==1) {
@ -825,9 +821,6 @@ int MenuDiscList() {
}
}
else if (sdcardBtn.GetState() == STATE_CLICKED) {
SDCard_deInit();
SDCard_Init();