added tooltips to gamegrid with game titles

This commit is contained in:
giantpune 2009-06-15 13:25:47 +00:00
parent a34eae2528
commit f3443c0ae8
4 changed files with 87 additions and 7 deletions

View File

@ -853,6 +853,8 @@ class GuiButton : public GuiElement
//!Sets the button's Tooltip on over //!Sets the button's Tooltip on over
//!\param tt Pointer to GuiElement object, x & y Positioning, h & v Align //!\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(GuiElement* tt, int x, int y, int h=ALIGN_RIGHT, int v=ALIGN_TOP);
void RemoveToolTip();
//!Constantly called to draw the GuiButton //!Constantly called to draw the GuiButton
void Draw(); void Draw();
void DrawTooltip(); void DrawTooltip();

View File

@ -245,6 +245,12 @@ void GuiButton::SetToolTip(GuiElement* tt, int x, int y, int h_align, int v_alig
} }
} }
void GuiButton::RemoveToolTip()
{
LOCK(this);
toolTip = NULL;
}
void GuiButton::RemoveSoundOver() void GuiButton::RemoveSoundOver()
{ {
LOCK(this); LOCK(this);
@ -335,7 +341,6 @@ void GuiButton::ScrollIsOn(int f)
LOCK(this); LOCK(this);
scrollison = f; scrollison = f;
} }
void GuiButton::Update(GuiTrigger * t) void GuiButton::Update(GuiTrigger * t)
{ {
LOCK(this); LOCK(this);
@ -492,3 +497,4 @@ void GuiButton::Update(GuiTrigger * t)
if(updateCB) if(updateCB)
updateCB(this); updateCB(this);
} }

View File

@ -14,6 +14,7 @@
#include "../settings/cfg.h" #include "../settings/cfg.h"
#include "../prompts/PromptWindows.h" #include "../prompts/PromptWindows.h"
#include "../language/language.h" #include "../language/language.h"
#include "../menu.h"
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
@ -38,6 +39,9 @@ u8 goback=0;
int goLeft = 0, goRight=0; int goLeft = 0, goRight=0;
char debugbuffer[100]; char debugbuffer[100];
int c; int c;
int selectedOld=0;
int wait=0,wait1=0;
bool isover=false;
/** /**
* Constructor for the GuiGamegrid class. * Constructor for the GuiGamegrid class.
@ -108,10 +112,10 @@ GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int count, const char
btnLeft->SetTrigger(trigMinus); btnLeft->SetTrigger(trigMinus);
btnLeft->SetEffectGrow(); btnLeft->SetEffectGrow();
debugTxt = new GuiText("fag", 14, (GXColor){0,0,0, 255}); /*debugTxt = new GuiText("fag", 14, (GXColor){0,0,0, 255});
debugTxt->SetParent(this); debugTxt->SetParent(this);
debugTxt->SetAlignment(2,5); debugTxt->SetAlignment(2,5);
debugTxt->SetPosition(0,180); debugTxt->SetPosition(0,180);*/
btnRightImg = new GuiImage(imgRight); btnRightImg = new GuiImage(imgRight);
@ -139,6 +143,16 @@ GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int count, const char
btnRowDown->SetTrigger(trig1); btnRowDown->SetTrigger(trig1);
// titleTxt = new GuiText("test");
titleTT = new GuiTooltip("test");
titleTT->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTT->SetPosition(-100,0);
// if (Settings.wsprompt == yes)
// installBtnTT.SetWidescreen(CFG.widescreen);
//if (count>0){ //if (count>0){
gameIndex = new int[pagesize]; gameIndex = new int[pagesize];
@ -146,6 +160,7 @@ GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int count, const char
bob = new int[pagesize]; bob = new int[pagesize];
coverImg = new GuiImage * [gameCnt]; coverImg = new GuiImage * [gameCnt];
cover = new GuiImageData * [gameCnt]; cover = new GuiImageData * [gameCnt];
//titleTxt = new GuiText * [gameCnt];
for(int i=0; i<pagesize; i++) { for(int i=0; i<pagesize; i++) {
bob[i]=i; bob[i]=i;
@ -179,6 +194,9 @@ GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int count, const char
if (rows==2)coverImg[i]->SetScale(.6);//these are the numbers for 2 rows if (rows==2)coverImg[i]->SetScale(.6);//these are the numbers for 2 rows
else if (rows==3)coverImg[i]->SetScale(.26);//these are the numbers for 3 rows else if (rows==3)coverImg[i]->SetScale(.26);//these are the numbers for 3 rows
//titleTxt[i] = new GuiText(get_title(&gameList[i]), 20, (GXColor){0,0,0, 0xff});
} }
for(int i=0; i < pagesize; i++) { for(int i=0; i < pagesize; i++) {
@ -470,8 +488,6 @@ int GuiGameGrid::GetSelectedOption()
} }
return found; return found;
} }
/**************************************************************************** /****************************************************************************
* FindMenuItem * FindMenuItem
* *
@ -523,12 +539,18 @@ void GuiGameGrid::Draw()
btnRowUp->Draw(); btnRowUp->Draw();
btnRowDown->Draw(); btnRowDown->Draw();
//debugTxt->Draw(); //debugTxt->Draw();
if ((wait>75)&&(Settings.tooltips == TooltipsOn))
titleTT->Draw();
this->UpdateEffects(); this->UpdateEffects();
} }
} }
/** /**
* Change the number of rows * Change the number of rows
*/ */
@ -741,7 +763,7 @@ void GuiGameGrid::Update(GuiTrigger * t)
// for debugging // for debugging
//snprintf(debugbuffer, sizeof(debugbuffer), "count: %i listOffset: %i", count,listOffset); //snprintf(debugbuffer, sizeof(debugbuffer), "count: %i listOffset: %i", count,listOffset);
//debugTxt->SetText(debugbuffer); //debugTxt->SetText(debugbuffer);
// debugTxt->Draw(); //debugTxt->Draw();
btnRight->Update(t); btnRight->Update(t);
btnLeft->Update(t); btnLeft->Update(t);
@ -1295,6 +1317,53 @@ void GuiGameGrid::Update(GuiTrigger * t)
} }
} }
int ttoffset=0;
if (rows==1)ttoffset=70;
if (rows==2)ttoffset=35;
char titlebuffer[50];
int selected = this->GetSelectedOption();
//3 different loops here with different alignment for tooltips
//depending on where on the screen the game is
for(int i=0; i < (pagesize/3); i++) {
game[i]->RemoveToolTip();
if (game[bob[i]]->GetState()==STATE_SELECTED)
{
game[bob[i]]->SetToolTip(titleTT,ttoffset,0,0,5);
}
}
for(int i=(pagesize/3); i < (2* pagesize/3); i++) {
game[i]->RemoveToolTip();
if (game[bob[i]]->GetState()==STATE_SELECTED)
{
game[bob[i]]->SetToolTip(titleTT,0,0,2,5);
isover=true;
}
}
for(int i=(2* pagesize/3); i < pagesize; i++) {
game[i]->RemoveToolTip();
if (game[bob[i]]->GetState()==STATE_SELECTED)
{
game[bob[i]]->SetToolTip(titleTT,-ttoffset,0,1,5);
}
}
snprintf(titlebuffer, sizeof(titlebuffer), "%s",get_title(&gameList[this->GetSelectedOption()]));
if (selected!=selectedOld){
delete titleTT;
titleTT = new GuiTooltip(titlebuffer);
wait=0;wait1=0;
}
selectedOld=selected;
if (wait1==0){wait++;if(wait>500)wait1=1;}//500 *2 is the time that the tooltips stay on screen
if ((wait1==1)&&(wait>-1)){wait--;}
//snprintf(debugbuffer, sizeof(debugbuffer), "faggot %i %s", GetOverImage(t),get_title(&gameList[this->GetSelectedOption()]));
//debugTxt->SetText(debugbuffer);
if ((btnRowUp->GetState() == STATE_CLICKED)&&(c>0)) { if ((btnRowUp->GetState() == STATE_CLICKED)&&(c>0)) {
if ((rows==1)&&(gameCnt>=16))this->ChangeRows(2); if ((rows==1)&&(gameCnt>=16))this->ChangeRows(2);
else if ((rows==2)&&(gameCnt>=42))this->ChangeRows(3); else if ((rows==2)&&(gameCnt>=42))this->ChangeRows(3);

View File

@ -53,6 +53,9 @@ class GuiGameGrid : public GuiElement
GuiImageData * imgLeft; GuiImageData * imgLeft;
GuiImageData * imgRight; GuiImageData * imgRight;
GuiTooltip * titleTT;
GuiSound * btnSoundOver; GuiSound * btnSoundOver;
GuiSound * btnSoundClick; GuiSound * btnSoundClick;
GuiTrigger * trigA; GuiTrigger * trigA;