2009-05-25 14:10:34 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* libwiigui
|
|
|
|
*
|
|
|
|
* gui_gamebrowser.cpp
|
|
|
|
*
|
|
|
|
* GUI class definitions
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "gui.h"
|
|
|
|
#include "../wpad.h"
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "gui_gamegrid.h"
|
|
|
|
#include "../cfg.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#define GAMESELECTSIZE 30
|
|
|
|
extern const int vol;
|
2009-05-25 19:59:28 +02:00
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
/**
|
|
|
|
* Constructor for the GuiGameGrid class.
|
|
|
|
*/
|
|
|
|
GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int gameCnt, const char *themePath, const u8 *imagebg, int selected, int offset)
|
|
|
|
{
|
|
|
|
width = 640;
|
|
|
|
height = h;
|
|
|
|
this->gameCnt = gameCnt;
|
|
|
|
gameList = l;
|
|
|
|
pagesize = 8;
|
2009-05-25 15:31:48 +02:00
|
|
|
changed = 0;
|
2009-05-25 14:10:34 +02:00
|
|
|
scrollbaron = (gameCnt > pagesize) ? 1 : 0;
|
|
|
|
selectable = true;
|
|
|
|
listOffset = (offset == 0) ? this->FindMenuItem(-1, 1) : offset;
|
|
|
|
selectedItem = selected - offset;
|
|
|
|
focus = 1; // allow focus
|
|
|
|
char imgPath[100];
|
|
|
|
|
|
|
|
trigA = new GuiTrigger;
|
|
|
|
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
|
|
|
trigHeldA = new GuiTrigger;
|
|
|
|
trigL = new GuiTrigger;
|
|
|
|
trigL->SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);
|
|
|
|
trigR = new GuiTrigger;
|
|
|
|
trigR->SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
|
|
|
|
trigPlus = new GuiTrigger;
|
|
|
|
trigPlus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
|
|
|
|
trigMinus = new GuiTrigger;
|
|
|
|
trigMinus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
|
|
|
|
|
2009-05-25 19:59:28 +02:00
|
|
|
btnSoundClick = new GuiSound(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, vol);
|
|
|
|
btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM, vol);
|
2009-05-25 15:31:48 +02:00
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path);
|
|
|
|
imgLeft = new GuiImageData(imgPath, startgame_arrow_left_png);
|
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path);
|
|
|
|
imgRight = new GuiImageData(imgPath, startgame_arrow_right_png);
|
2009-05-25 15:31:48 +02:00
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
btnLeftImg = new GuiImage(imgLeft);
|
|
|
|
btnLeft = new GuiButton(imgLeft->GetWidth(), imgLeft->GetHeight());
|
|
|
|
btnLeft->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
|
|
|
btnLeft->SetPosition(20, -30);
|
|
|
|
btnLeft->SetParent(this);
|
|
|
|
btnLeft->SetImage(btnLeftImg);
|
|
|
|
btnLeft->SetSoundOver(btnSoundOver);
|
2009-05-25 19:59:28 +02:00
|
|
|
btnLeft->SetSoundClick(btnSoundClick);
|
2009-05-25 14:10:34 +02:00
|
|
|
btnLeft->SetTrigger(trigA);
|
|
|
|
btnLeft->SetTrigger(trigL);
|
|
|
|
btnLeft->SetTrigger(trigMinus);
|
|
|
|
btnLeft->SetEffectGrow();
|
|
|
|
|
|
|
|
btnRightImg = new GuiImage(imgRight);
|
|
|
|
btnRight = new GuiButton(imgRight->GetWidth(), imgRight->GetHeight());
|
|
|
|
btnRight->SetParent(this);
|
|
|
|
btnRight->SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
|
|
|
|
btnRight->SetPosition(-20, -30);
|
|
|
|
btnRight->SetImage(btnRightImg);
|
|
|
|
btnRight->SetSoundOver(btnSoundOver);
|
2009-05-25 19:59:28 +02:00
|
|
|
btnRight->SetSoundClick(btnSoundClick);
|
2009-05-25 14:10:34 +02:00
|
|
|
btnRight->SetTrigger(trigA);
|
|
|
|
btnRight->SetTrigger(trigR);
|
|
|
|
btnRight->SetTrigger(trigPlus);
|
|
|
|
btnRight->SetEffectGrow();
|
|
|
|
|
|
|
|
gameIndex = new int[pagesize];
|
|
|
|
game = new GuiButton * [pagesize];
|
|
|
|
coverImg = new GuiImage * [pagesize];
|
|
|
|
cover = new GuiImageData * [pagesize];
|
|
|
|
|
|
|
|
char ID[4];
|
|
|
|
char IDfull[7];
|
2009-05-25 15:31:48 +02:00
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
for(int i=0; i < pagesize; i++)
|
|
|
|
{
|
2009-05-25 15:31:48 +02:00
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
struct discHdr *header = &gameList[i];
|
|
|
|
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(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, IDfull);
|
|
|
|
cover[i] = new GuiImageData(imgPath,0); //load short id
|
|
|
|
if (!cover[i]->GetImage()) //if could not load the short id image
|
|
|
|
{
|
|
|
|
delete cover[i];
|
2009-05-25 15:31:48 +02:00
|
|
|
cover[i] = NULL;
|
2009-05-25 14:10:34 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, ID);
|
|
|
|
cover[i] = new GuiImageData(imgPath, 0); //load full id image
|
|
|
|
if (!cover[i]->GetImage())
|
|
|
|
{
|
|
|
|
delete cover[i];
|
2009-05-25 15:31:48 +02:00
|
|
|
cover[i] = NULL;
|
2009-05-25 14:10:34 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.covers_path);
|
|
|
|
cover[i] = new GuiImageData(imgPath, nocover_png); //load no image
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
coverImg[i] = new GuiImage(cover[i]);
|
|
|
|
coverImg[i]->SetWidescreen(CFG.widescreen);
|
|
|
|
coverImg[i]->SetScale(0.6);
|
|
|
|
|
|
|
|
game[i] = new GuiButton(coverImg[i]->GetWidth()*.45,coverImg[i]->GetHeight()*.7);
|
|
|
|
game[i]->SetParent(this);
|
|
|
|
game[i]->SetAlignment(ALIGN_TOP,ALIGN_LEFT);
|
|
|
|
game[i]->SetImage(coverImg[i]);
|
|
|
|
coverImg[i]->SetParent(game[i]);
|
|
|
|
coverImg[i]->SetPosition(-10,-35);
|
|
|
|
if (i<4)game[i]->SetPosition(117+i*110,25);
|
|
|
|
if (i>3)game[i]->SetPosition(117+(i-4)*110,185);
|
|
|
|
game[i]->SetRumble(false);
|
|
|
|
game[i]->SetTrigger(trigA);
|
2009-05-25 19:59:28 +02:00
|
|
|
game[i]->SetSoundOver(btnSoundOver);
|
2009-05-25 14:10:34 +02:00
|
|
|
game[i]->SetSoundClick(btnSoundClick);
|
|
|
|
game[i]->SetEffectGrow();
|
2009-05-25 15:31:48 +02:00
|
|
|
game[i]->SetVisible(true);
|
2009-05-25 19:59:28 +02:00
|
|
|
game[i]->SetClickable(true);
|
|
|
|
coverImg[i]->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
|
|
|
|
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) {
|
|
|
|
game[i]->SetVisible(false);
|
|
|
|
game[i]->SetClickable(false);
|
|
|
|
}
|
2009-05-25 14:10:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor for the GuiGameGrid class.
|
|
|
|
*/
|
|
|
|
GuiGameGrid::~GuiGameGrid()
|
|
|
|
{
|
2009-05-25 15:31:48 +02:00
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
delete imgRight;
|
|
|
|
delete imgLeft;
|
|
|
|
delete btnLeftImg;
|
|
|
|
delete btnRightImg;
|
|
|
|
delete btnRight;
|
|
|
|
delete btnLeft;
|
|
|
|
|
|
|
|
delete trigA;
|
|
|
|
delete btnSoundClick;
|
|
|
|
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
{
|
2009-05-25 15:31:48 +02:00
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
delete game[i];
|
|
|
|
delete coverImg[i];
|
|
|
|
delete cover[i];
|
|
|
|
}
|
|
|
|
delete [] gameIndex;
|
|
|
|
delete [] game;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiGameGrid::SetFocus(int f)
|
|
|
|
{
|
|
|
|
LOCK(this);
|
|
|
|
focus = f;
|
|
|
|
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
game[i]->ResetState();
|
|
|
|
|
|
|
|
if(f == 1)
|
|
|
|
game[selectedItem]->SetState(STATE_SELECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiGameGrid::ResetState()
|
|
|
|
{
|
|
|
|
LOCK(this);
|
|
|
|
if(state != STATE_DISABLED)
|
|
|
|
{
|
|
|
|
state = STATE_DEFAULT;
|
|
|
|
stateChan = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
{
|
|
|
|
game[i]->ResetState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int GuiGameGrid::GetOffset()
|
|
|
|
{
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
int GuiGameGrid::GetClickedOption()
|
|
|
|
{
|
|
|
|
int found = -1;
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
{
|
|
|
|
if(game[i]->GetState() == STATE_CLICKED)
|
|
|
|
{
|
|
|
|
game[i]->SetState(STATE_SELECTED);
|
|
|
|
found = changed+i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GuiGameGrid::GetSelectedOption()
|
2009-05-25 15:31:48 +02:00
|
|
|
{
|
2009-05-25 14:10:34 +02:00
|
|
|
int found = -1;
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
{
|
|
|
|
if(game[i]->GetState() == STATE_SELECTED)
|
|
|
|
{
|
|
|
|
game[i]->SetState(STATE_SELECTED);
|
|
|
|
found = changed+i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* FindMenuItem
|
|
|
|
*
|
|
|
|
* Help function to find the next visible menu item on the list
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
int GuiGameGrid::FindMenuItem(int currentItem, int direction)
|
|
|
|
{
|
|
|
|
int nextItem = currentItem + direction;
|
|
|
|
|
|
|
|
if(nextItem < 0 || nextItem >= gameCnt)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if(strlen(get_title(&gameList[nextItem])) > 0)
|
|
|
|
return nextItem;
|
|
|
|
else
|
|
|
|
return FindMenuItem(nextItem, direction);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw the button on screen
|
|
|
|
*/
|
|
|
|
void GuiGameGrid::Draw()
|
|
|
|
{
|
|
|
|
LOCK(this);
|
|
|
|
if(!this->IsVisible())
|
|
|
|
return;
|
|
|
|
|
|
|
|
int next = listOffset;
|
|
|
|
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
{
|
|
|
|
if(next >= 0)
|
|
|
|
{
|
|
|
|
game[i]->Draw();
|
|
|
|
next = this->FindMenuItem(next, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
btnRight->Draw();
|
|
|
|
btnLeft->Draw();
|
|
|
|
this->UpdateEffects();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiGameGrid::Update(GuiTrigger * t)
|
|
|
|
{
|
|
|
|
LOCK(this);
|
|
|
|
if(state == STATE_DISABLED || !t)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int next; //prev;
|
2009-05-25 15:31:48 +02:00
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
btnRight->Update(t);
|
|
|
|
btnLeft->Update(t);
|
|
|
|
|
|
|
|
next = listOffset;
|
2009-05-25 15:31:48 +02:00
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
char ID[4];
|
|
|
|
char IDfull[7];
|
|
|
|
char imgPath[100];
|
|
|
|
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
{
|
|
|
|
if(next >= 0)
|
|
|
|
{
|
|
|
|
if(game[i]->GetState() == STATE_DISABLED)
|
|
|
|
{
|
|
|
|
game[i]->SetVisible(true);
|
|
|
|
game[i]->SetState(STATE_DEFAULT);
|
|
|
|
}
|
|
|
|
gameIndex[i] = next;
|
|
|
|
next = this->FindMenuItem(next, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
game[i]->SetVisible(false);
|
|
|
|
game[i]->SetState(STATE_DISABLED);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(focus)
|
|
|
|
{
|
|
|
|
if(i != selectedItem && game[i]->GetState() == STATE_SELECTED)
|
|
|
|
game[i]->ResetState();
|
|
|
|
else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT)
|
2009-05-25 19:59:28 +02:00
|
|
|
game[selectedItem]->SetState(STATE_SELECTED, t->chan);
|
2009-05-25 14:10:34 +02:00
|
|
|
}
|
|
|
|
game[i]->Update(t);
|
|
|
|
|
|
|
|
if(game[i]->GetState() == STATE_SELECTED)
|
|
|
|
{
|
|
|
|
selectedItem = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// pad/joystick navigation
|
|
|
|
if(!focus)
|
|
|
|
return; // skip navigation
|
|
|
|
|
2009-05-25 19:59:28 +02:00
|
|
|
if ((t->Right() || btnRight->GetState() == STATE_CLICKED)) {
|
2009-05-25 14:10:34 +02:00
|
|
|
|
|
|
|
changed += pagesize;
|
2009-05-25 15:31:48 +02:00
|
|
|
if (changed>gameCnt-1)
|
|
|
|
changed=0;
|
|
|
|
|
|
|
|
for(int i=0; i<pagesize; i++) {
|
|
|
|
|
|
|
|
if(coverImg[i]) {
|
|
|
|
delete coverImg[i];
|
|
|
|
coverImg[i] = NULL;
|
|
|
|
}
|
|
|
|
if(cover[i]) {
|
|
|
|
delete cover[i];
|
|
|
|
cover[i] = NULL;
|
|
|
|
}
|
|
|
|
struct discHdr *header = &gameList[i+changed];
|
|
|
|
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(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, IDfull);
|
|
|
|
cover[i] = new GuiImageData(imgPath,0); //load short id
|
2009-05-25 14:10:34 +02:00
|
|
|
if (!cover[i]->GetImage()) //if could not load the short id image
|
|
|
|
{
|
|
|
|
delete cover[i];
|
2009-05-25 15:31:48 +02:00
|
|
|
cover[i] = NULL;
|
2009-05-25 14:10:34 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, ID);
|
|
|
|
cover[i] = new GuiImageData(imgPath, 0); //load full id image
|
|
|
|
if (!cover[i]->GetImage())
|
|
|
|
{
|
|
|
|
delete cover[i];
|
2009-05-25 15:31:48 +02:00
|
|
|
cover[i] = NULL;
|
2009-05-25 14:10:34 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.covers_path);
|
|
|
|
cover[i] = new GuiImageData(imgPath, nocover_png); //load no image
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
coverImg[i] = new GuiImage(cover[i]);
|
|
|
|
coverImg[i]->SetWidescreen(CFG.widescreen);
|
|
|
|
coverImg[i]->SetScale(0.6);
|
|
|
|
coverImg[i]->SetParent(game[i]);
|
2009-05-25 15:31:48 +02:00
|
|
|
coverImg[i]->SetPosition(-10,-35);
|
2009-05-25 14:10:34 +02:00
|
|
|
game[i]->SetImage(coverImg[i]);
|
2009-05-25 15:31:48 +02:00
|
|
|
game[i]->SetVisible(true);
|
2009-05-25 19:59:28 +02:00
|
|
|
game[i]->SetClickable(true);
|
|
|
|
coverImg[i]->SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 65);
|
|
|
|
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) {
|
|
|
|
game[i]->SetVisible(false);
|
|
|
|
game[i]->SetClickable(false);
|
|
|
|
}
|
2009-05-25 15:31:48 +02:00
|
|
|
}
|
|
|
|
btnRight->ResetState();
|
2009-05-25 14:10:34 +02:00
|
|
|
|
2009-05-25 15:31:48 +02:00
|
|
|
} else if((t->Left() || btnLeft->GetState() == STATE_CLICKED)){
|
2009-05-25 14:10:34 +02:00
|
|
|
|
2009-05-25 15:31:48 +02:00
|
|
|
changed -= pagesize;
|
|
|
|
if (changed < 0)
|
|
|
|
changed=gameCnt-(gameCnt%8);
|
2009-05-25 14:10:34 +02:00
|
|
|
|
2009-05-25 15:31:48 +02:00
|
|
|
for(int i=0; i<pagesize; i++) {
|
2009-05-25 14:10:34 +02:00
|
|
|
coverImg[i]->SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 65);
|
|
|
|
|
2009-05-25 15:31:48 +02:00
|
|
|
if(coverImg[i]) {
|
|
|
|
delete coverImg[i];
|
|
|
|
coverImg[i] = NULL;
|
|
|
|
}
|
|
|
|
if(cover[i]) {
|
|
|
|
delete cover[i];
|
|
|
|
cover[i] = NULL;
|
|
|
|
}
|
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
struct discHdr *header = &gameList[i+changed];
|
|
|
|
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]);
|
2009-05-25 15:31:48 +02:00
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, IDfull);
|
|
|
|
cover[i] = new GuiImageData(imgPath,0); //load short id
|
|
|
|
if (!cover[i]->GetImage()) //if could not load the short id image
|
|
|
|
{
|
|
|
|
delete cover[i];
|
2009-05-25 15:31:48 +02:00
|
|
|
cover[i] = NULL;
|
2009-05-25 14:10:34 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, ID);
|
|
|
|
cover[i] = new GuiImageData(imgPath, 0); //load full id image
|
|
|
|
if (!cover[i]->GetImage())
|
|
|
|
{
|
|
|
|
delete cover[i];
|
2009-05-25 15:31:48 +02:00
|
|
|
cover[i] = NULL;
|
2009-05-25 14:10:34 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.covers_path);
|
|
|
|
cover[i] = new GuiImageData(imgPath, nocover_png); //load no image
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
coverImg[i] = new GuiImage(cover[i]);
|
|
|
|
coverImg[i]->SetWidescreen(CFG.widescreen);
|
|
|
|
coverImg[i]->SetScale(0.6);
|
|
|
|
coverImg[i]->SetParent(game[i]);
|
2009-05-25 15:31:48 +02:00
|
|
|
coverImg[i]->SetPosition(-10,-35);
|
|
|
|
game[i]->ResetState();
|
|
|
|
game[i]->SetVisible(true);
|
2009-05-25 14:10:34 +02:00
|
|
|
game[i]->SetImage(coverImg[i]);
|
2009-05-25 19:59:28 +02:00
|
|
|
game[i]->SetClickable(true);
|
|
|
|
coverImg[i]->SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 65);
|
|
|
|
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) {
|
2009-05-25 15:31:48 +02:00
|
|
|
game[i]->SetVisible(false);
|
2009-05-25 19:59:28 +02:00
|
|
|
game[i]->SetClickable(false);
|
2009-05-25 14:10:34 +02:00
|
|
|
}
|
2009-05-25 19:59:28 +02:00
|
|
|
}
|
2009-05-25 14:10:34 +02:00
|
|
|
btnLeft->ResetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(updateCB)
|
|
|
|
updateCB(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiGameGrid::Reload(struct discHdr * l, int count)
|
|
|
|
{
|
|
|
|
LOCK(this);
|
|
|
|
gameList = l;
|
|
|
|
gameCnt = count;
|
|
|
|
changed=0;
|
|
|
|
scrollbaron = (gameCnt > pagesize) ? 1 : 0;
|
|
|
|
selectedItem = 0;
|
|
|
|
listOffset = 0;
|
|
|
|
char ID[4];
|
|
|
|
char IDfull[7];
|
|
|
|
char imgPath[100];
|
|
|
|
|
2009-05-25 19:59:28 +02:00
|
|
|
for(int i=0; i<pagesize; i++) {
|
2009-05-25 14:10:34 +02:00
|
|
|
|
2009-05-25 15:31:48 +02:00
|
|
|
if(coverImg[i]) {
|
|
|
|
delete coverImg[i];
|
|
|
|
coverImg[i] = NULL;
|
|
|
|
}
|
|
|
|
if(cover[i]) {
|
|
|
|
delete cover[i];
|
|
|
|
cover[i] = NULL;
|
|
|
|
}
|
|
|
|
|
2009-05-25 14:10:34 +02:00
|
|
|
struct discHdr *header = &gameList[i+changed];
|
2009-05-25 15:31:48 +02:00
|
|
|
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(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, IDfull);
|
|
|
|
cover[i] = new GuiImageData(imgPath,0); //load short id
|
2009-05-25 14:10:34 +02:00
|
|
|
if (!cover[i]->GetImage()) //if could not load the short id image
|
|
|
|
{
|
|
|
|
delete cover[i];
|
2009-05-25 15:31:48 +02:00
|
|
|
cover[i] = NULL;
|
2009-05-25 14:10:34 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, ID);
|
|
|
|
cover[i] = new GuiImageData(imgPath, 0); //load full id image
|
|
|
|
if (!cover[i]->GetImage())
|
|
|
|
{
|
|
|
|
delete cover[i];
|
2009-05-25 15:31:48 +02:00
|
|
|
cover[i] = NULL;
|
2009-05-25 14:10:34 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.covers_path);
|
|
|
|
cover[i] = new GuiImageData(imgPath, nocover_png); //load no image
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
coverImg[i] = new GuiImage(cover[i]);
|
|
|
|
coverImg[i]->SetWidescreen(CFG.widescreen);
|
|
|
|
coverImg[i]->SetScale(0.6);
|
|
|
|
coverImg[i]->SetParent(game[i]);
|
2009-05-25 15:31:48 +02:00
|
|
|
coverImg[i]->SetPosition(-10,-35);
|
|
|
|
game[i]->ResetState();
|
|
|
|
game[i]->SetVisible(true);
|
2009-05-25 14:10:34 +02:00
|
|
|
game[i]->SetImage(coverImg[i]);
|
2009-05-25 19:59:28 +02:00
|
|
|
game[i]->SetClickable(true);
|
|
|
|
coverImg[i]->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
|
|
|
|
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) {
|
|
|
|
game[i]->SetVisible(false);
|
|
|
|
game[i]->SetClickable(false);
|
|
|
|
}
|
|
|
|
}
|
2009-05-25 14:10:34 +02:00
|
|
|
}
|