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;
@ -97,6 +97,14 @@ GuiGameCarousel::GuiGameCarousel(int w, int h, struct discHdr * l, int count, co
btnRight->SetEffectGrow();
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];
@ -137,7 +145,9 @@ GuiGameCarousel::~GuiGameCarousel()
delete trigPlus;
delete trigMinus;
delete btnSoundClick;
delete btnSoundOver;
delete btnSoundOver;
delete ttgame;
delete gamename;
for(int i=0; i<pagesize; i++) {
delete game[i];
@ -150,7 +160,9 @@ GuiGameCarousel::~GuiGameCarousel()
void GuiGameCarousel::SetFocus(int f)
{
LOCK(this);
LOCK(this);
if(!gameCnt) return;
focus = f;
for(int i=0; i<pagesize; i++)
@ -241,18 +253,29 @@ int GuiGameCarousel::FindMenuItem(int currentItem, int direction)
void GuiGameCarousel::Draw()
{
LOCK(this);
if(!this->IsVisible())
if(!this->IsVisible() || !gameCnt)
return;
int next = listOffset;
for(int i=0; i<pagesize; i++) {
if(next >= 0) {
game[i]->SetImage(ImageBuffer(i));
game[i]->Draw();
next = this->FindMenuItem(next, 1);
} 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();
@ -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())) {
@ -298,11 +321,13 @@ void GuiGameCarousel::Update(GuiTrigger * t)
int next = listOffset;
for(int i=0; i<pagesize; i++) {
if(next >= 0) {
if(next >= 0) {
if(game[i]->GetState() == STATE_DISABLED) {
game[i]->SetVisible(true);
game[i]->SetState(STATE_DEFAULT);
}
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;
}
}
///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
/// 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;

File diff suppressed because it is too large Load Diff

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,15 +413,15 @@ void GuiImage::Draw()
float currAngleDyn = this->GetAngleDyn();
if(currAngleDyn)
imageangle = currAngleDyn;
if(currAngleDyn && parentangle)
imageangle = currAngleDyn;
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

@ -16,40 +16,40 @@ static GuiImageData tooltipRight(tooltip_right_png);
/**
* Constructor for the GuiTooltip class.
*/
* Constructor for the GuiTooltip class.
*/
GuiTooltip::GuiTooltip(const char *t)
:
leftImage(&tooltipLeft), tileImage(&tooltipTile), rightImage(&tooltipRight)
{
text = NULL;
height = leftImage.GetHeight();
leftImage.SetParent(this);
tileImage.SetParent(this);
rightImage.SetParent(this);
leftImage.SetParent(this);
tileImage.SetParent(this);
rightImage.SetParent(this);
leftImage.SetParentAngle(false);
tileImage.SetParentAngle(false);
rightImage.SetParentAngle(false);
SetText(t);
}
/*
* Destructor for the GuiTooltip class.
*/
*/
GuiTooltip::~GuiTooltip()
{
if(text) delete text;
if(text) delete text;
}
float GuiTooltip::GetScale()
{
float s = scale * scaleDyn;
// if(parentElement)
// s *= parentElement->GetScale();
return s;
}
/* !Sets the text of the GuiTooltip element
* !\param t Text
/* !Sets the text of the GuiTooltip element
* !\param t Text
*/
void GuiTooltip::SetText(const char * t)
{
@ -62,13 +62,13 @@ void GuiTooltip::SetText(const char * t)
int tile_cnt = 0;
if(t && (text = new GuiText(t, 22, (GXColor){0, 0, 0, 255})))
{
text->SetParent(this);
text->SetParent(this);
tile_cnt = (text->GetTextWidth()-12) /tileImage.GetWidth();
if(tile_cnt < 0) tile_cnt = 0;
}
tileImage.SetPosition(leftImage.GetWidth(), 0);
tileImage.SetPosition(leftImage.GetWidth(), 0);
tileImage.SetTile(tile_cnt);
rightImage.SetPosition(leftImage.GetWidth() + tile_cnt * tileImage.GetWidth(), 0);
rightImage.SetPosition(leftImage.GetWidth() + tile_cnt * tileImage.GetWidth(), 0);
width = leftImage.GetWidth() + tile_cnt * tileImage.GetWidth() + rightImage.GetWidth();
}
@ -79,11 +79,11 @@ void GuiTooltip::SetWidescreen(bool){}
void GuiTooltip::Draw()
{
LOCK(this);
if(!this->IsVisible()) return;
if(!this->IsVisible()) return;
leftImage.Draw();
tileImage.Draw();
rightImage.Draw();
leftImage.Draw();
tileImage.Draw();
rightImage.Draw();
if(text) text->Draw();
this->UpdateEffects();

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();