*add scrolling Text to the GuiCostomOptionBrowser (now shown full Paths)

*add GuiText::SetTextf(format, ...); Set formatet text like printf
This commit is contained in:
ardi@ist-einmalig.de 2009-05-29 13:20:28 +00:00
parent cf1a8fb5a0
commit a5ec5c9d63
8 changed files with 710 additions and 663 deletions

View File

@ -439,14 +439,17 @@ void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) {
*/ */
int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) { int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) {
if (format & FTGX_JUSTIFY_LEFT ) { switch(format & FTGX_JUSTIFY_MASK)
return 0; {
} case FTGX_JUSTIFY_LEFT:
else if (format & FTGX_JUSTIFY_CENTER ) { return 0;
return -(width >> 1);
} default:
else if (format & FTGX_JUSTIFY_RIGHT ) { case FTGX_JUSTIFY_CENTER:
return -width; return -(width >> 1);
case FTGX_JUSTIFY_RIGHT:
return -width;
} }
return 0; return 0;

View File

@ -201,7 +201,7 @@ int subfoldercheck(char * directory);
//Astidof - Begin of modification //Astidof - Begin of modification
enum { enum {
ConsoleLangDefault, ConsoleLangDefault=0,
jap, jap,
eng, eng,
ger, ger,
@ -211,21 +211,25 @@ enum {
dut, dut,
schin, schin,
tchin, tchin,
kor kor,
settings_language_max // always the last entry
}; };
enum { enum {
systemdefault, systemdefault=0,
discdefault, discdefault,
patch, patch,
pal50, pal50,
pal60, pal60,
ntsc ntsc,
settings_video_max // always the last entry
}; };
enum { enum {
off, off=0,
on, on,
settings_off_on_max // always the last entry
}; };
enum { enum {
@ -233,40 +237,45 @@ enum {
GameRegion, GameRegion,
Both, Both,
Neither, Neither,
settings_sinfo_max // always the last entry
}; };
enum { enum {
i249, i249=0,
i222, i222,
}; };
enum { enum {
ios249, ios249=0,
ios222, ios222,
settings_cios_max // always the last entry
}; };
enum { enum {
hr12, hr12=0,
hr24, hr24,
Off, Off,
settings_clock_max // always the last entry
}; };
enum { enum {
all, all=0,
pcount, pcount,
}; };
enum { enum {
RumbleOff, RumbleOff=0,
RumbleOn, RumbleOn,
settings_rumble_max // always the last entry
}; };
enum { enum {
TooltipsOff, TooltipsOff=0,
TooltipsOn, TooltipsOn,
settings_tooltips_max // always the last entry
}; };
enum { enum {
v10, v10=0,
v20, v20,
v30, v30,
v40, v40,
@ -277,27 +286,35 @@ enum {
v90, v90,
v100, v100,
v0, v0,
settings_volume_max // always the last entry
}; };
enum { enum {
no, no=0,
yes, yes,
sysmenu, sysmenu,
wtf, wtf,
disk3d, disk3d,
settings_xflip_max // always the last entry
}; };
enum { enum {
us, us=0,
dvorak, dvorak,
euro, euro,
azerty, azerty,
settings_keyset_max // always the last entry
}; };
enum { enum {
list, list,
grid, grid,
carousel, carousel,
}; };
enum {
scrollDefault,
scrollMarquee,
settings_scrolleffect_max // always the last entry
};
struct SSettings { struct SSettings {
int video; int video;
int language; int language;

View File

@ -659,6 +659,7 @@ class GuiText : public GuiElement
//!Sets the text of the GuiText element //!Sets the text of the GuiText element
//!\param t Text //!\param t Text
void SetText(const char * t); void SetText(const char * t);
void SetTextf(const char *format, ...) __attribute__((format(printf,2,3)));
//!Sets up preset values to be used by GuiText(t) //!Sets up preset values to be used by GuiText(t)
//!Useful when printing multiple text elements, all with the same attributes set //!Useful when printing multiple text elements, all with the same attributes set
//!\param sz Font size //!\param sz Font size

View File

@ -15,8 +15,68 @@
#define GAMESELECTSIZE 30 #define GAMESELECTSIZE 30
static int scrollbaron = 0;
int coL2; customOptionList::customOptionList(int size)
{
name = new char * [size];
value = new char * [size];
for (int i = 0; i < size; i++)
{
name[i] = 0;
value[i] = 0;
}
length = size;
changed = false;
}
customOptionList::~customOptionList()
{
for (int i = 0; i < length; i++)
{
free(name[i]);
free(value[i]);
}
delete [] name;
delete [] value;
}
void customOptionList::SetName(int i, const char *format, ...)
{
if(i >= 0 && i < length)
{
if(name[i]) free(name[i]);
name[i] = 0;
va_list va;
va_start(va, format);
vasprintf(&name[i], format, va);
va_end(va);
changed = true;
}
}
void customOptionList::SetValue(int i, const char *format, ...)
{
if(i >= 0 && i < length)
{
char *tmp=0;
va_list va;
va_start(va, format);
vasprintf(&tmp, format, va);
va_end(va);
if(tmp)
{
if(value[i] && !strcmp(tmp, value[i]))
free(tmp);
else
{
free(value[i]);
value[i] = tmp;
changed = true;
}
}
}
}
//int vol; //int vol;
extern const int vol; extern const int vol;
/** /**
@ -27,7 +87,7 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
width = w; width = w;
height = h; height = h;
options = l; options = l;
size = ((l->length > PAGESIZE)? PAGESIZE: l->length); size = ((l->GetLength() > PAGESIZE)? PAGESIZE: l->GetLength());
scrollbaron = scrollon; scrollbaron = scrollon;
selectable = true; selectable = true;
listOffset = this->FindMenuItem(-1, 1); listOffset = this->FindMenuItem(-1, 1);
@ -115,13 +175,14 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
optionIndex = new int[size]; optionIndex = new int[size];
optionVal = new GuiText * [size]; optionVal = new GuiText * [size];
optionValOver = new GuiText * [size];
optionBtn = new GuiButton * [size]; optionBtn = new GuiButton * [size];
optionTxt = new GuiText * [size]; optionTxt = new GuiText * [size];
optionBg = new GuiImage * [size]; optionBg = new GuiImage * [size];
for(int i=0; i < size; i++) for(int i=0; i < size; i++)
{ {
optionTxt[i] = new GuiText(options->name[i], 20, (GXColor){0, 0, 0, 0xff}); optionTxt[i] = new GuiText(options->GetName(i), 20, (GXColor){0, 0, 0, 0xff});
optionTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); optionTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
optionTxt[i]->SetPosition(24,0); optionTxt[i]->SetPosition(24,0);
@ -129,12 +190,15 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
optionVal[i] = new GuiText(NULL, 20, (GXColor){0, 0, 0, 0xff}); optionVal[i] = new GuiText(NULL, 20, (GXColor){0, 0, 0, 0xff});
optionVal[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); optionVal[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
optionVal[i]->SetPosition(250,0);
optionValOver[i] = new GuiText(NULL, 20, (GXColor){0, 0, 0, 0xff});
optionValOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
optionBtn[i] = new GuiButton(width,GAMESELECTSIZE);//(width-28,GAMESELECTSIZE); optionBtn[i] = new GuiButton(width,GAMESELECTSIZE);//(width-28,GAMESELECTSIZE);
optionBtn[i]->SetParent(this); optionBtn[i]->SetParent(this);
optionBtn[i]->SetLabel(optionTxt[i], 0); optionBtn[i]->SetLabel(optionTxt[i], 0);
optionBtn[i]->SetLabel(optionVal[i], 1); optionBtn[i]->SetLabel(optionVal[i], 1);
optionBtn[i]->SetLabelOver(optionValOver[i], 1);
optionBtn[i]->SetImageOver(optionBg[i]); optionBtn[i]->SetImageOver(optionBg[i]);
optionBtn[i]->SetPosition(10,GAMESELECTSIZE*i+4); optionBtn[i]->SetPosition(10,GAMESELECTSIZE*i+4);
optionBtn[i]->SetRumble(false); optionBtn[i]->SetRumble(false);
@ -142,6 +206,7 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
optionBtn[i]->SetSoundClick(btnSoundClick); optionBtn[i]->SetSoundClick(btnSoundClick);
} }
UpdateListEntries();
} }
/** /**
@ -180,23 +245,18 @@ GuiCustomOptionBrowser::~GuiCustomOptionBrowser()
{ {
delete optionTxt[i]; delete optionTxt[i];
delete optionVal[i]; delete optionVal[i];
delete optionValOver[i];
delete optionBg[i]; delete optionBg[i];
delete optionBtn[i]; delete optionBtn[i];
} }
delete [] optionIndex; delete [] optionIndex;
delete [] optionVal; delete [] optionVal;
delete [] optionValOver;
delete [] optionBtn; delete [] optionBtn;
delete [] optionTxt; delete [] optionTxt;
delete [] optionBg; delete [] optionBg;
} }
void GuiCustomOptionBrowser::SetCol2Position(int x)
{
LOCK(this);
for(int i = 0; i < size; i++)
optionVal[i]->SetPosition(x,0);
}
void GuiCustomOptionBrowser::SetFocus(int f) void GuiCustomOptionBrowser::SetFocus(int f)
{ {
LOCK(this); LOCK(this);
@ -263,10 +323,10 @@ int GuiCustomOptionBrowser::FindMenuItem(int currentItem, int direction)
{ {
int nextItem = currentItem + direction; int nextItem = currentItem + direction;
if(nextItem < 0 || nextItem >= options->length) if(nextItem < 0 || nextItem >= options->GetLength())
return -1; return -1;
if(strlen(options->name[nextItem]) > 0) if(strlen(options->GetName(nextItem)) > 0)
return nextItem; return nextItem;
else else
return FindMenuItem(nextItem, direction); return FindMenuItem(nextItem, direction);
@ -304,31 +364,12 @@ void GuiCustomOptionBrowser::Draw()
} }
this->UpdateEffects(); this->UpdateEffects();
} }
void GuiCustomOptionBrowser::UpdateListEntries()
void GuiCustomOptionBrowser::Update(GuiTrigger * t)
{ {
LOCK(this); if(listOffset<0) listOffset = this->FindMenuItem(-1, 1);
int next, prev, lang = options->length; int next = listOffset;
if(state == STATE_DISABLED || !t)
return;
// scrolldelay affects how fast the list scrolls
// when the arrows are clicked
float scrolldelay = 3.5;
if (scrollbaron == 1) {
// update the location of the scroll box based on the position in the option list
arrowUpBtn->Update(t);
arrowDownBtn->Update(t);
scrollbarBoxBtn->Update(t);
}
next = listOffset;
int maxNameWidth = 0;
for(int i=0; i < size; i++) for(int i=0; i < size; i++)
{ {
if(next >= 0) if(next >= 0)
@ -339,9 +380,11 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
optionBtn[i]->SetState(STATE_DEFAULT); optionBtn[i]->SetState(STATE_DEFAULT);
} }
optionTxt[i]->SetText(options->name[next]); optionTxt[i]->SetText(options->GetName(next));
optionVal[i]->SetText(options->value[next]); if(maxNameWidth < optionTxt[i]->GetTextWidth())
optionVal[i]->SetPosition(coL2, 0); maxNameWidth = optionTxt[i]->GetTextWidth();
optionVal[i]->SetText(options->GetValue(next));
optionValOver[i]->SetText(options->GetValue(next));
optionIndex[i] = next; optionIndex[i] = next;
next = this->FindMenuItem(next, 1); next = this->FindMenuItem(next, 1);
@ -351,6 +394,52 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
optionBtn[i]->SetVisible(false); optionBtn[i]->SetVisible(false);
optionBtn[i]->SetState(STATE_DISABLED); optionBtn[i]->SetState(STATE_DISABLED);
} }
}
if(coL2 < (24+maxNameWidth+16))
coL2 = 24+maxNameWidth+16;
for(int i=0; i < size; i++)
{
if(optionBtn[i]->GetState() != STATE_DISABLED)
{
optionVal[i]->SetPosition(coL2,0);
optionVal[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), GuiText::DOTTED);
optionValOver[i]->SetPosition(coL2,0);
optionValOver[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), GuiText::SCROLL);
}
}
}
void GuiCustomOptionBrowser::Update(GuiTrigger * t)
{
LOCK(this);
int next, prev, lang = options->GetLength();
if(state == STATE_DISABLED || !t)
return;
if(options->IsChanged())
UpdateListEntries();
int old_listOffset = listOffset;
// scrolldelay affects how fast the list scrolls
// when the arrows are clicked
float scrolldelay = 3.5;
if (scrollbaron == 1)
{
// update the location of the scroll box based on the position in the option list
arrowUpBtn->Update(t);
arrowDownBtn->Update(t);
scrollbarBoxBtn->Update(t);
}
next = listOffset;
for(int i=0; i < size; i++)
{
if(next >= 0)
next = this->FindMenuItem(next, 1);
if(focus) if(focus)
{ {
@ -374,171 +463,174 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
if(!focus) if(!focus)
return; // skip navigation return; // skip navigation
if (scrollbaron == 1) { if (scrollbaron == 1)
if (t->Down() ||
arrowDownBtn->GetState() == STATE_CLICKED || ////////////////////////////////////////////down
arrowDownBtn->GetState() == STATE_HELD)
{ {
next = this->FindMenuItem(optionIndex[selectedItem], 1); if (t->Down() ||
arrowDownBtn->GetState() == STATE_CLICKED || ////////////////////////////////////////////down
if(next >= 0) arrowDownBtn->GetState() == STATE_HELD)
{ {
if(selectedItem == size-1)
next = this->FindMenuItem(optionIndex[selectedItem], 1);
if(next >= 0)
{ {
// move list down by 1 if(selectedItem == size-1)
listOffset = this->FindMenuItem(listOffset, 1); {
// move list down by 1
listOffset = this->FindMenuItem(listOffset, 1);
}
else if(optionBtn[selectedItem+1]->IsVisible())
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
selectedItem++;
}
scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay);
} }
else if(optionBtn[selectedItem+1]->IsVisible()) WPAD_ScanPads();
u8 cnt, buttons = NULL;
/* Get pressed buttons */
for (cnt = 0; cnt < 4; cnt++)
buttons |= WPAD_ButtonsHeld(cnt);
if (buttons == WPAD_BUTTON_A)
{ {
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
selectedItem++;
}
scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay);
}WPAD_ScanPads();
u8 cnt, buttons = NULL;
/* Get pressed buttons */
for (cnt = 0; cnt < 4; cnt++)
buttons |= WPAD_ButtonsHeld(cnt);
if (buttons == WPAD_BUTTON_A) {
} else {
arrowDownBtn->ResetState();
}
}
else if(t->Up() ||
arrowUpBtn->GetState() == STATE_CLICKED || ////////////////////////////////////////////up
arrowUpBtn->GetState() == STATE_HELD)
{
prev = this->FindMenuItem(optionIndex[selectedItem], -1);
if(prev >= 0)
{
if(selectedItem == 0)
{
// move list up by 1
listOffset = prev;
} }
else else
{ {
optionBtn[selectedItem]->ResetState(); arrowDownBtn->ResetState();
optionBtn[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
selectedItem--;
} }
scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay);
}WPAD_ScanPads();
u8 cnt, buttons = NULL;
/* Get pressed buttons */
for (cnt = 0; cnt < 4; cnt++)
buttons |= WPAD_ButtonsHeld(cnt);
if (buttons == WPAD_BUTTON_A) {
} else {
arrowUpBtn->ResetState();
}
}
if(scrollbarBoxBtn->GetState() == STATE_HELD &&
scrollbarBoxBtn->GetStateChan() == t->chan &&
t->wpad.ir.valid && options->length > size)
{
scrollbarBoxBtn->SetPosition(width/2-18+7,0);
int position = t->wpad.ir.y - 50 - scrollbarBoxBtn->GetTop();
listOffset = (position * lang)/180 - selectedItem;
if(listOffset <= 0)
{
listOffset = 0;
selectedItem = 0;
} }
else if(listOffset+size >= lang) else if(t->Up() ||
arrowUpBtn->GetState() == STATE_CLICKED || ////////////////////////////////////////////up
arrowUpBtn->GetState() == STATE_HELD)
{ {
listOffset = lang-size; prev = this->FindMenuItem(optionIndex[selectedItem], -1);
selectedItem = size-1;
if(prev >= 0)
{
if(selectedItem == 0)
{
// move list up by 1
listOffset = prev;
}
else
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
selectedItem--;
}
scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay);
}
WPAD_ScanPads();
u8 cnt, buttons = NULL;
/* Get pressed buttons */
for (cnt = 0; cnt < 4; cnt++)
buttons |= WPAD_ButtonsHeld(cnt);
if (buttons == WPAD_BUTTON_A)
{
}
else
{
arrowUpBtn->ResetState();
}
} }
} if(scrollbarBoxBtn->GetState() == STATE_HELD &&
int positionbar = 237*(listOffset + selectedItem) / lang; scrollbarBoxBtn->GetStateChan() == t->chan &&
t->wpad.ir.valid && options->GetLength() > size)
{
scrollbarBoxBtn->SetPosition(width/2-18+7,0);
int position = t->wpad.ir.y - 50 - scrollbarBoxBtn->GetTop();
if(positionbar > 216) listOffset = (position * lang)/180 - selectedItem;
positionbar = 216;
if(listOffset <= 0)
{
listOffset = 0;
selectedItem = 0;
}
else if(listOffset+size >= lang)
{
listOffset = lang-size;
selectedItem = size-1;
}
}
int positionbar = 237*(listOffset + selectedItem) / lang;
if(positionbar > 216)
positionbar = 216;
scrollbarBoxBtn->SetPosition(width/2-18+7, positionbar+8); scrollbarBoxBtn->SetPosition(width/2-18+7, positionbar+8);
if(t->Right()) if(t->Right())
{
if(listOffset < lang && lang > size)
{ {
listOffset =listOffset+ size; if(listOffset < lang && lang > size)
if(listOffset+size >= lang)
listOffset = lang-size;
}
}
else if(t->Left())
{
if(listOffset > 0)
{
listOffset =listOffset- size;
if(listOffset < 0)
listOffset = 0;
}
}
} else {
if(t->Down())
{
next = this->FindMenuItem(optionIndex[selectedItem], 1);
if(next >= 0)
{
if(selectedItem == size-1)
{ {
// move list down by 1 listOffset =listOffset+ size;
listOffset = this->FindMenuItem(listOffset, 1); if(listOffset+size >= lang)
} listOffset = lang-size;
else if(optionBtn[selectedItem+1]->IsVisible())
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
selectedItem++;
} }
} }
} else if(t->Left())
else if(t->Up())
{
prev = this->FindMenuItem(optionIndex[selectedItem], -1);
if(prev >= 0)
{ {
if(selectedItem == 0) if(listOffset > 0)
{ {
// move list up by 1 listOffset =listOffset- size;
listOffset = prev; if(listOffset < 0)
} listOffset = 0;
else
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
selectedItem--;
} }
} }
}
} }
else
{
if(t->Down())
{
next = this->FindMenuItem(optionIndex[selectedItem], 1);
if(next >= 0)
{
if(selectedItem == size-1)
{
// move list down by 1
listOffset = this->FindMenuItem(listOffset, 1);
}
else if(optionBtn[selectedItem+1]->IsVisible())
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
selectedItem++;
}
}
}
else if(t->Up())
{
prev = this->FindMenuItem(optionIndex[selectedItem], -1);
if(prev >= 0)
{
if(selectedItem == 0)
{
// move list up by 1
listOffset = prev;
}
else
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
selectedItem--;
}
}
}
}
if(old_listOffset != listOffset)
UpdateListEntries();
if(updateCB) if(updateCB)
updateCB(this); updateCB(this);
} }

View File

@ -1,31 +1,33 @@
#include "gui.h" #include "gui.h"
extern int SetValue(int i, const char *format, ...) __attribute__((format(printf,2,3)));
class customOptionList { class customOptionList {
public: public:
customOptionList(int size) { customOptionList(int size);
name = new char * [size]; ~customOptionList();
value = new char * [size]; void SetName(int i, const char *format, ...) __attribute__((format (printf, 3, 4)));
for (int i = 0; i < size; i++) const char *GetName(int i)
{ {
name[i] = new char[40]; if(i >= 0 && i < length && name[i])
value[i] = new char[40]; return name[i];
} else
length = size; return "";
}; }
~customOptionList(){ void SetValue(int i, const char *format, ...) __attribute__((format (printf, 3, 4)));
for (int i = 0; i < length; i++) const char *GetValue(int i)
{ {
delete [] name[i]; if(i >= 0 && i < length && value[i])
delete [] value[i]; return value[i];
} else
delete [] name; return "";
delete [] value; }
}; int GetLength() { return length; }
bool IsChanged() { bool ret = changed; changed = false; return ret;}
public: private:
int length; int length;
char ** name; char ** name;
char ** value; char ** value;
bool changed;
}; };
//!Display a list of menu options //!Display a list of menu options
@ -34,7 +36,6 @@ class GuiCustomOptionBrowser : public GuiElement
public: public:
GuiCustomOptionBrowser(int w, int h, customOptionList * l, const char * themePath, const char *custombg, const u8 *imagebg, int scrollbar, int col2); GuiCustomOptionBrowser(int w, int h, customOptionList * l, const char * themePath, const char *custombg, const u8 *imagebg, int scrollbar, int col2);
~GuiCustomOptionBrowser(); ~GuiCustomOptionBrowser();
void SetCol2Position(int x);
int FindMenuItem(int c, int d); int FindMenuItem(int c, int d);
int GetClickedOption(); int GetClickedOption();
int GetSelectedOption(); int GetSelectedOption();
@ -42,16 +43,20 @@ class GuiCustomOptionBrowser : public GuiElement
void SetFocus(int f); void SetFocus(int f);
void Draw(); void Draw();
void Update(GuiTrigger * t); void Update(GuiTrigger * t);
GuiText ** optionVal;
protected: protected:
void UpdateListEntries();
int selectedItem; int selectedItem;
int listOffset; int listOffset;
int size; int size;
int coL2;
int scrollbaron;
customOptionList * options; customOptionList * options;
int * optionIndex; int * optionIndex;
GuiButton ** optionBtn; GuiButton ** optionBtn;
GuiText ** optionTxt; GuiText ** optionTxt;
GuiText ** optionVal;
GuiText ** optionValOver;
GuiImage ** optionBg; GuiImage ** optionBg;
GuiButton * arrowUpBtn; GuiButton * arrowUpBtn;

View File

@ -313,27 +313,26 @@ void GuiGameBrowser::UpdateListEntries()
int next = listOffset; int next = listOffset;
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[i]->GetState() == STATE_DISABLED) game[i]->SetVisible(true);
{ game[i]->SetState(STATE_DEFAULT);
game[i]->SetVisible(true); }
game[i]->SetState(STATE_DEFAULT); gameTxt[i]->SetText(get_title(&gameList[next]));
} gameTxt[i]->SetPosition(24, 0);
gameTxt[i]->SetText(get_title(&gameList[next])); gameTxtOver[i]->SetText(get_title(&gameList[next]));
gameTxt[i]->SetPosition(24, 0); gameTxtOver[i]->SetPosition(24, 0);
gameTxtOver[i]->SetText(get_title(&gameList[next]));
gameTxtOver[i]->SetPosition(24, 0);
gameIndex[i] = next; gameIndex[i] = next;
next = this->FindMenuItem(next, 1); next = this->FindMenuItem(next, 1);
} }
else else
{ {
game[i]->SetVisible(false); game[i]->SetVisible(false);
game[i]->SetState(STATE_DISABLED); game[i]->SetState(STATE_DISABLED);
} }
// }
} }
} }
@ -437,7 +436,6 @@ void GuiGameBrowser::Update(GuiTrigger * t)
{ {
// move list up by 1 // move list up by 1
listOffset = prev; listOffset = prev;
// UpdateEntries();
} }
else else
{ {
@ -500,10 +498,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
} }
scrollbarBoxBtn->Draw(); scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay); usleep(10000 * scrolldelay);
} }
} }
else if (position2 < position1) else if (position2 < position1)
{ {
@ -603,7 +598,6 @@ void GuiGameBrowser::Update(GuiTrigger * t)
{ {
// move list down by 1 // move list down by 1
listOffset = this->FindMenuItem(listOffset, 1); listOffset = this->FindMenuItem(listOffset, 1);
// UpdateEntries();
} }
else if(game[selectedItem+1]->IsVisible()) else if(game[selectedItem+1]->IsVisible())
{ {
@ -623,7 +617,6 @@ void GuiGameBrowser::Update(GuiTrigger * t)
{ {
// move list up by 1 // move list up by 1
listOffset = prev; listOffset = prev;
// UpdateEntries();
} }
else else
{ {

View File

@ -94,6 +94,18 @@ void GuiText::SetText(const char * t)
scrollPos2 = 0; scrollPos2 = 0;
scrollDelay = 0; scrollDelay = 0;
} }
void GuiText::SetTextf(const char *format, ...)
{
char *tmp=0;
va_list va;
va_start(va, format);
if((vasprintf(&tmp, format, va)>=0) && tmp)
{
this->SetText(tmp);
free(tmp);
}
va_end(va);
}
void GuiText::SetPresets(int sz, GXColor c, int w, int wrap, u16 s, int h, int v) void GuiText::SetPresets(int sz, GXColor c, int w, int wrap, u16 s, int h, int v)
{ {
@ -178,6 +190,9 @@ void GuiText::SetFont(FreeTypeGX *f)
int GuiText::GetTextWidth() int GuiText::GetTextWidth()
{ {
LOCK(this); LOCK(this);
if(!text)
return 0;
int newSize = size*this->GetScale(); int newSize = size*this->GetScale();
if(newSize != currentSize || currentWidescreen != widescreen) if(newSize != currentSize || currentWidescreen != widescreen)

File diff suppressed because it is too large Load Diff