2009-05-03 20:53:31 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* libwiigui
|
|
|
|
*
|
|
|
|
* gui_gamebrowser.cpp
|
|
|
|
*
|
|
|
|
* GUI class definitions
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "gui.h"
|
|
|
|
#include "../wpad.h"
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "gui_gamebrowser.h"
|
2009-05-05 04:56:01 +02:00
|
|
|
#include "../cfg.h"
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-05-13 07:41:49 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <sstream>
|
|
|
|
|
2009-05-03 20:53:31 +02:00
|
|
|
#define GAMESELECTSIZE 30
|
|
|
|
extern const int vol;
|
2009-05-13 07:41:49 +02:00
|
|
|
int txtscroll = 0;
|
2009-05-03 20:53:31 +02:00
|
|
|
/**
|
|
|
|
* Constructor for the GuiGameBrowser class.
|
|
|
|
*/
|
|
|
|
GuiGameBrowser::GuiGameBrowser(int w, int h, struct discHdr * l, int gameCnt, const char *themePath, const u8 *imagebg, int selected, int offset)
|
|
|
|
{
|
|
|
|
width = w;
|
|
|
|
height = h;
|
|
|
|
this->gameCnt = gameCnt;
|
2009-05-22 01:32:32 +02:00
|
|
|
gameList = l;
|
|
|
|
pagesize = THEME.pagesize;
|
|
|
|
scrollbaron = (gameCnt > pagesize) ? 1 : 0;
|
2009-05-03 20:53:31 +02:00
|
|
|
selectable = true;
|
|
|
|
listOffset = (offset == 0) ? this->FindMenuItem(-1, 1) : offset;
|
|
|
|
selectedItem = selected - offset;
|
2009-05-22 01:32:32 +02:00
|
|
|
focus = 1; // allow focus
|
2009-05-03 20:53:31 +02:00
|
|
|
char imgPath[100];
|
|
|
|
|
|
|
|
trigA = new GuiTrigger;
|
|
|
|
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
|
|
|
trigHeldA = new GuiTrigger;
|
|
|
|
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A, PAD_BUTTON_A);
|
|
|
|
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM, vol);
|
|
|
|
|
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sbg_options.png", themePath);
|
|
|
|
bgGames = new GuiImageData(imgPath, imagebg);
|
|
|
|
|
|
|
|
bgGameImg = new GuiImage(bgGames);
|
|
|
|
bgGameImg->SetParent(this);
|
|
|
|
bgGameImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
2009-05-23 00:36:55 +02:00
|
|
|
|
|
|
|
maxTextWidth = bgGameImg->GetWidth() - 24 - 4;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sbg_options_entry.png", themePath);
|
|
|
|
bgGamesEntry = new GuiImageData(imgPath, bg_options_entry_png);
|
2009-05-22 20:22:23 +02:00
|
|
|
|
2009-05-03 20:53:31 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sscrollbar.png", themePath);
|
|
|
|
scrollbar = new GuiImageData(imgPath, scrollbar_png);
|
|
|
|
scrollbarImg = new GuiImage(scrollbar);
|
|
|
|
scrollbarImg->SetParent(this);
|
|
|
|
scrollbarImg->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
|
|
|
scrollbarImg->SetPosition(0, 4);
|
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
maxTextWidth -= scrollbarImg->GetWidth() + 4;
|
|
|
|
|
2009-05-03 20:53:31 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowdown.png", themePath);
|
|
|
|
arrowDown = new GuiImageData(imgPath, scrollbar_arrowdown_png);
|
|
|
|
arrowDownImg = new GuiImage(arrowDown);
|
|
|
|
arrowDownOver = new GuiImageData(imgPath, scrollbar_arrowdown_png);
|
|
|
|
arrowDownOverImg = new GuiImage(arrowDownOver);
|
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowup.png", themePath);
|
|
|
|
arrowUp = new GuiImageData(imgPath, scrollbar_arrowup_png);
|
|
|
|
arrowUpImg = new GuiImage(arrowUp);
|
|
|
|
arrowUpOver = new GuiImageData(imgPath, scrollbar_arrowup_png);
|
|
|
|
arrowUpOverImg = new GuiImage(arrowUpOver);
|
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sscrollbar_box.png", themePath);
|
|
|
|
scrollbarBox = new GuiImageData(imgPath, scrollbar_box_png);
|
|
|
|
scrollbarBoxImg = new GuiImage(scrollbarBox);
|
|
|
|
scrollbarBoxOver = new GuiImageData(imgPath, scrollbar_box_png);
|
|
|
|
scrollbarBoxOverImg = new GuiImage(scrollbarBoxOver);
|
|
|
|
|
|
|
|
arrowUpBtn = new GuiButton(arrowUpImg->GetWidth(), arrowUpImg->GetHeight());
|
|
|
|
arrowUpBtn->SetParent(this);
|
|
|
|
arrowUpBtn->SetImage(arrowUpImg);
|
|
|
|
arrowUpBtn->SetImageOver(arrowUpOverImg);
|
|
|
|
arrowUpBtn->SetImageHold(arrowUpOverImg);
|
|
|
|
arrowUpBtn->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
|
|
|
arrowUpBtn->SetPosition(width/2-18+7,-18);
|
|
|
|
arrowUpBtn->SetSelectable(false);
|
|
|
|
arrowUpBtn->SetTrigger(trigA);
|
|
|
|
arrowUpBtn->SetEffectOnOver(EFFECT_SCALE, 50, 130);
|
|
|
|
arrowUpBtn->SetSoundClick(btnSoundClick);
|
|
|
|
|
|
|
|
arrowDownBtn = new GuiButton(arrowDownImg->GetWidth(), arrowDownImg->GetHeight());
|
|
|
|
arrowDownBtn->SetParent(this);
|
|
|
|
arrowDownBtn->SetImage(arrowDownImg);
|
|
|
|
arrowDownBtn->SetImageOver(arrowDownOverImg);
|
|
|
|
arrowDownBtn->SetImageHold(arrowDownOverImg);
|
|
|
|
arrowDownBtn->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
|
|
|
|
arrowDownBtn->SetPosition(width/2-18+7,18);
|
|
|
|
arrowDownBtn->SetSelectable(false);
|
|
|
|
arrowDownBtn->SetTrigger(trigA);
|
|
|
|
arrowDownBtn->SetEffectOnOver(EFFECT_SCALE, 50, 130);
|
|
|
|
arrowDownBtn->SetSoundClick(btnSoundClick);
|
|
|
|
|
|
|
|
scrollbarBoxBtn = new GuiButton(scrollbarBoxImg->GetWidth(), scrollbarBoxImg->GetHeight());
|
|
|
|
scrollbarBoxBtn->SetParent(this);
|
|
|
|
scrollbarBoxBtn->SetImage(scrollbarBoxImg);
|
|
|
|
scrollbarBoxBtn->SetImageOver(scrollbarBoxOverImg);
|
|
|
|
scrollbarBoxBtn->SetImageHold(scrollbarBoxOverImg);
|
|
|
|
scrollbarBoxBtn->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
|
|
|
scrollbarBoxBtn->SetSelectable(false);
|
|
|
|
scrollbarBoxBtn->SetEffectOnOver(EFFECT_SCALE, 50, 120);
|
2009-05-22 20:22:23 +02:00
|
|
|
scrollbarBoxBtn->SetMinY(0);
|
2009-05-03 20:53:31 +02:00
|
|
|
scrollbarBoxBtn->SetMaxY(height-30);
|
|
|
|
scrollbarBoxBtn->SetHoldable(true);
|
|
|
|
scrollbarBoxBtn->SetTrigger(trigHeldA);
|
|
|
|
|
|
|
|
gameIndex = new int[pagesize];
|
|
|
|
game = new GuiButton * [pagesize];
|
|
|
|
gameTxt = new GuiText * [pagesize];
|
2009-05-23 00:36:55 +02:00
|
|
|
gameTxtOver = new GuiText * [pagesize];
|
2009-05-03 20:53:31 +02:00
|
|
|
gameBg = new GuiImage * [pagesize];
|
|
|
|
|
|
|
|
for(int i=0; i < pagesize; i++)
|
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
gameTxt[i] = new GuiText(get_title(&gameList[i]), 20, (GXColor){THEME.gameText_r, THEME.gameText_g, THEME.gameText_b, 0xff});
|
2009-05-03 20:53:31 +02:00
|
|
|
gameTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
|
|
|
gameTxt[i]->SetPosition(24,0);
|
2009-05-23 00:36:55 +02:00
|
|
|
gameTxt[i]->SetMaxWidth(maxTextWidth, GuiText::DOTTED);
|
|
|
|
|
|
|
|
|
|
|
|
gameTxtOver[i] = new GuiText(get_title(&gameList[i]), 20, (GXColor){THEME.gameText_r, THEME.gameText_g, THEME.gameText_b, 0xff});
|
|
|
|
gameTxtOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
|
|
|
gameTxtOver[i]->SetPosition(24,0);
|
|
|
|
gameTxtOver[i]->SetMaxWidth(maxTextWidth, GuiText::SCROLL);
|
|
|
|
|
2009-05-03 20:53:31 +02:00
|
|
|
gameBg[i] = new GuiImage(bgGamesEntry);
|
|
|
|
|
|
|
|
game[i] = new GuiButton(width-28,GAMESELECTSIZE);
|
|
|
|
game[i]->SetParent(this);
|
|
|
|
game[i]->SetLabel(gameTxt[i]);
|
2009-05-23 00:36:55 +02:00
|
|
|
game[i]->SetLabelOver(gameTxtOver[i]);
|
2009-05-03 20:53:31 +02:00
|
|
|
game[i]->SetImageOver(gameBg[i]);
|
|
|
|
game[i]->SetPosition(5,GAMESELECTSIZE*i+4);
|
|
|
|
game[i]->SetRumble(false);
|
|
|
|
game[i]->SetTrigger(trigA);
|
|
|
|
game[i]->SetSoundClick(btnSoundClick);
|
2009-05-23 00:36:55 +02:00
|
|
|
|
|
|
|
gameIndex[i] = i;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor for the GuiGameBrowser class.
|
|
|
|
*/
|
|
|
|
GuiGameBrowser::~GuiGameBrowser()
|
|
|
|
{
|
|
|
|
delete arrowUpBtn;
|
|
|
|
delete arrowDownBtn;
|
|
|
|
delete scrollbarBoxBtn;
|
|
|
|
delete scrollbarImg;
|
|
|
|
delete arrowDownImg;
|
|
|
|
delete arrowDownOverImg;
|
|
|
|
delete arrowUpImg;
|
|
|
|
delete arrowUpOverImg;
|
|
|
|
delete scrollbarBoxImg;
|
|
|
|
delete scrollbarBoxOverImg;
|
|
|
|
delete scrollbar;
|
|
|
|
delete arrowDown;
|
|
|
|
delete arrowDownOver;
|
|
|
|
delete arrowUp;
|
|
|
|
delete arrowUpOver;
|
|
|
|
delete scrollbarBox;
|
|
|
|
delete scrollbarBoxOver;
|
2009-05-22 20:31:51 +02:00
|
|
|
delete bgGameImg;
|
2009-05-03 20:53:31 +02:00
|
|
|
delete bgGames;
|
|
|
|
delete bgGamesEntry;
|
|
|
|
|
|
|
|
delete trigA;
|
|
|
|
delete btnSoundClick;
|
|
|
|
|
|
|
|
// delete optionBg;
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
{
|
|
|
|
delete gameTxt[i];
|
2009-05-23 00:36:55 +02:00
|
|
|
delete gameTxtOver[i];
|
2009-05-03 20:53:31 +02:00
|
|
|
delete gameBg[i];
|
|
|
|
delete game[i];
|
|
|
|
}
|
|
|
|
delete [] gameIndex;
|
|
|
|
delete [] game;
|
|
|
|
delete [] gameTxt;
|
2009-05-23 00:36:55 +02:00
|
|
|
delete [] gameTxtOver;
|
2009-05-03 20:53:31 +02:00
|
|
|
delete [] gameBg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiGameBrowser::SetFocus(int f)
|
|
|
|
{
|
2009-05-07 00:36:28 +02:00
|
|
|
LOCK(this);
|
2009-05-03 20:53:31 +02:00
|
|
|
focus = f;
|
|
|
|
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
game[i]->ResetState();
|
|
|
|
|
|
|
|
if(f == 1)
|
|
|
|
game[selectedItem]->SetState(STATE_SELECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiGameBrowser::ResetState()
|
|
|
|
{
|
2009-05-07 00:36:28 +02:00
|
|
|
LOCK(this);
|
2009-05-03 20:53:31 +02:00
|
|
|
if(state != STATE_DISABLED)
|
|
|
|
{
|
|
|
|
state = STATE_DEFAULT;
|
|
|
|
stateChan = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
{
|
|
|
|
game[i]->ResetState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int GuiGameBrowser::GetOffset()
|
|
|
|
{
|
|
|
|
return listOffset;
|
|
|
|
}
|
|
|
|
int GuiGameBrowser::GetClickedOption()
|
|
|
|
{
|
|
|
|
int found = -1;
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
{
|
|
|
|
if(game[i]->GetState() == STATE_CLICKED)
|
|
|
|
{
|
|
|
|
game[i]->SetState(STATE_SELECTED);
|
|
|
|
found = gameIndex[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GuiGameBrowser::GetSelectedOption()
|
2009-05-22 01:32:32 +02:00
|
|
|
{
|
2009-05-03 20:53:31 +02:00
|
|
|
int found = -1;
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
{
|
|
|
|
if(game[i]->GetState() == STATE_SELECTED)
|
|
|
|
{
|
|
|
|
game[i]->SetState(STATE_SELECTED);
|
|
|
|
found = gameIndex[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* FindMenuItem
|
|
|
|
*
|
|
|
|
* Help function to find the next visible menu item on the list
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
int GuiGameBrowser::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 GuiGameBrowser::Draw()
|
|
|
|
{
|
2009-05-07 00:36:28 +02:00
|
|
|
LOCK(this);
|
2009-05-03 20:53:31 +02:00
|
|
|
if(!this->IsVisible())
|
|
|
|
return;
|
|
|
|
|
|
|
|
bgGameImg->Draw();
|
|
|
|
|
|
|
|
int next = listOffset;
|
|
|
|
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
{
|
|
|
|
if(next >= 0)
|
|
|
|
{
|
|
|
|
game[i]->Draw();
|
|
|
|
next = this->FindMenuItem(next, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(scrollbaron == 1) {
|
|
|
|
scrollbarImg->Draw();
|
|
|
|
arrowUpBtn->Draw();
|
|
|
|
arrowDownBtn->Draw();
|
|
|
|
scrollbarBoxBtn->Draw();
|
|
|
|
}
|
|
|
|
this->UpdateEffects();
|
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
void GuiGameBrowser::UpdateListEntries()
|
|
|
|
{
|
|
|
|
int next = listOffset;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
gameTxt[i]->SetText(get_title(&gameList[next]));
|
|
|
|
gameTxt[i]->SetPosition(24, 0);
|
|
|
|
gameTxtOver[i]->SetText(get_title(&gameList[next]));
|
|
|
|
gameTxtOver[i]->SetPosition(24, 0);
|
|
|
|
|
|
|
|
gameIndex[i] = next;
|
|
|
|
next = this->FindMenuItem(next, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
game[i]->SetVisible(false);
|
|
|
|
game[i]->SetState(STATE_DISABLED);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
2009-05-03 20:53:31 +02:00
|
|
|
|
|
|
|
void GuiGameBrowser::Update(GuiTrigger * t)
|
|
|
|
{
|
2009-05-07 00:36:28 +02:00
|
|
|
LOCK(this);
|
2009-05-03 20:53:31 +02:00
|
|
|
if(state == STATE_DISABLED || !t)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int next, prev;
|
2009-05-23 00:36:55 +02:00
|
|
|
int old_listOffset = listOffset;
|
2009-05-03 20:53:31 +02:00
|
|
|
static int position2;
|
|
|
|
// scrolldelay affects how fast the list scrolls
|
|
|
|
// when the arrows are clicked
|
|
|
|
float scrolldelay = 3.5;
|
2009-05-15 22:35:08 +02:00
|
|
|
|
2009-05-03 20:53:31 +02:00
|
|
|
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<pagesize; i++)
|
|
|
|
{
|
|
|
|
if(next >= 0)
|
|
|
|
next = this->FindMenuItem(next, 1);
|
|
|
|
|
2009-05-22 01:32:32 +02:00
|
|
|
if(focus)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
|
|
|
if(i != selectedItem && game[i]->GetState() == STATE_SELECTED)
|
|
|
|
game[i]->ResetState();
|
|
|
|
else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT)
|
|
|
|
game[selectedItem]->SetState(STATE_SELECTED, t->chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
game[i]->Update(t);
|
|
|
|
|
|
|
|
if(game[i]->GetState() == STATE_SELECTED)
|
|
|
|
{
|
|
|
|
selectedItem = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// pad/joystick navigation
|
2009-05-22 01:32:32 +02:00
|
|
|
if(!focus)
|
2009-05-03 20:53:31 +02:00
|
|
|
return; // skip navigation
|
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
if (scrollbaron == 1)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
if (t->Down() ||
|
|
|
|
arrowDownBtn->GetState() == STATE_CLICKED || ////////////////////////////////////////////down
|
|
|
|
arrowDownBtn->GetState() == STATE_HELD)
|
|
|
|
{
|
2009-05-03 20:53:31 +02:00
|
|
|
|
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
next = this->FindMenuItem(gameIndex[selectedItem], 1);
|
|
|
|
|
|
|
|
if(next >= 0)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
if(selectedItem == pagesize-1)
|
|
|
|
{
|
|
|
|
// move list down by 1
|
|
|
|
listOffset = this->FindMenuItem(listOffset, 1);
|
|
|
|
// UpdateEntries();
|
|
|
|
}
|
|
|
|
else if(game[selectedItem+1]->IsVisible())
|
|
|
|
{
|
|
|
|
game[selectedItem]->ResetState();
|
|
|
|
game[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
|
|
|
|
selectedItem++;
|
|
|
|
}
|
|
|
|
scrollbarBoxBtn->Draw();
|
|
|
|
usleep(10000 * scrolldelay);
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
WPAD_ScanPads();
|
|
|
|
u8 cnt, buttons = NULL;
|
|
|
|
/* Get pressed buttons */
|
|
|
|
for (cnt = 0; cnt < 4; cnt++)
|
|
|
|
buttons |= WPAD_ButtonsHeld(cnt);
|
|
|
|
if (buttons == WPAD_BUTTON_A)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
arrowDownBtn->ResetState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(t->Up() ||
|
|
|
|
arrowUpBtn->GetState() == STATE_CLICKED || ////////////////////////////////////////////up
|
|
|
|
arrowUpBtn->GetState() == STATE_HELD)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
prev = this->FindMenuItem(gameIndex[selectedItem], -1);
|
|
|
|
|
|
|
|
if(prev >= 0)
|
|
|
|
{
|
|
|
|
if(selectedItem == 0)
|
|
|
|
{
|
|
|
|
// move list up by 1
|
|
|
|
listOffset = prev;
|
|
|
|
// UpdateEntries();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
game[selectedItem]->ResetState();
|
|
|
|
game[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)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
arrowUpBtn->ResetState();
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
WPAD_ScanPads();
|
2009-05-23 00:36:55 +02:00
|
|
|
u8 cnt, buttons = NULL;/////////////////////////////////////////////////////scroll by holding B and tilt wiimote
|
|
|
|
int position1 = 0;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
position1 = t->wpad.ir.y;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
if (position2 == 0 && position1 > 0)
|
|
|
|
{
|
|
|
|
position2 = position1;
|
|
|
|
}
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
for (cnt = 0; cnt < 4; cnt++)
|
|
|
|
buttons |= WPAD_ButtonsHeld(cnt);
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
if (buttons == WPAD_BUTTON_B && position1 > 0)
|
|
|
|
{
|
|
|
|
scrollbarBoxBtn->ScrollIsOn(1);
|
|
|
|
if (position2 > position1)
|
|
|
|
{
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
prev = this->FindMenuItem(gameIndex[selectedItem], -1);
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
if(prev >= 0)
|
|
|
|
{
|
|
|
|
if(selectedItem == 0)
|
|
|
|
{
|
|
|
|
// move list up by 1
|
|
|
|
listOffset = prev;
|
|
|
|
// UpdateEntries();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
game[selectedItem]->ResetState();
|
|
|
|
game[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
|
|
|
|
selectedItem--;
|
|
|
|
}
|
|
|
|
scrollbarBoxBtn->Draw();
|
|
|
|
usleep(10000 * scrolldelay);
|
2009-05-03 20:53:31 +02:00
|
|
|
|
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
}
|
2009-05-03 20:53:31 +02:00
|
|
|
|
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
else if (position2 < position1)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
next = this->FindMenuItem(gameIndex[selectedItem], 1);
|
|
|
|
|
|
|
|
if(next >= 0)
|
|
|
|
{
|
|
|
|
if(selectedItem == pagesize-1)
|
|
|
|
{
|
|
|
|
// move list down by 1
|
|
|
|
listOffset = this->FindMenuItem(listOffset, 1);
|
|
|
|
// UpdateEntries();
|
|
|
|
}
|
|
|
|
else if(game[selectedItem+1]->IsVisible())
|
|
|
|
{
|
|
|
|
game[selectedItem]->ResetState();
|
|
|
|
game[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
|
|
|
|
selectedItem++;
|
|
|
|
}
|
|
|
|
scrollbarBoxBtn->Draw();
|
|
|
|
usleep(10000 * scrolldelay);
|
|
|
|
}
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
else if (!buttons)
|
|
|
|
{
|
|
|
|
scrollbarBoxBtn->ScrollIsOn(0);
|
|
|
|
position2 = 0;
|
|
|
|
}
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
if(scrollbarBoxBtn->GetState() == STATE_HELD &&/////////////////////allow dragging of scrollbar box
|
|
|
|
scrollbarBoxBtn->GetStateChan() == t->chan &&
|
|
|
|
t->wpad.ir.valid && gameCnt > pagesize)
|
|
|
|
{
|
|
|
|
scrollbarBoxBtn->SetPosition(width/2-18+7,0);
|
|
|
|
//int position = t->wpad.ir.y - 50 - scrollbarBoxBtn->GetTop();
|
|
|
|
int position = t->wpad.ir.y - 32 - scrollbarBoxBtn->GetTop();
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
//listOffset = (position * gameCnt)/237 - selectedItem;
|
|
|
|
listOffset = (position * gameCnt)/(25.2 * pagesize) - selectedItem;
|
|
|
|
// UpdateEntries();
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
if(listOffset <= 0)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
listOffset = 0;
|
|
|
|
// UpdateEntries();
|
|
|
|
selectedItem = 0;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
else if(listOffset+pagesize >= gameCnt)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
listOffset = gameCnt - pagesize;
|
|
|
|
// UpdateEntries();
|
|
|
|
selectedItem = pagesize-1;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
//int positionbar = 237*(listOffset + selectedItem) / gameCnt;
|
2009-05-12 09:02:17 +02:00
|
|
|
int positionbar = (25.2 * pagesize)*(listOffset + selectedItem) / gameCnt;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
if(positionbar > (24 * pagesize))//if(positionbar > 216)
|
|
|
|
positionbar = (24 * pagesize);//positionbar = 216;
|
2009-05-03 20:53:31 +02:00
|
|
|
scrollbarBoxBtn->SetPosition(width/2-18+7, positionbar+8);
|
|
|
|
|
|
|
|
|
2009-05-23 00:36:55 +02:00
|
|
|
if(t->Right())/////////////////////////////////////////////////////skip pagesize # of games if right is pressed
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
if(listOffset < gameCnt && gameCnt > pagesize)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
listOffset =listOffset+ pagesize;
|
|
|
|
if(listOffset+pagesize >= gameCnt)
|
|
|
|
listOffset = gameCnt-pagesize;
|
|
|
|
// UpdateEntries();
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
}
|
|
|
|
else if(t->Left())
|
|
|
|
{
|
|
|
|
if(listOffset > 0)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
listOffset =listOffset- pagesize;
|
|
|
|
if(listOffset < 0)
|
|
|
|
listOffset = 0;
|
|
|
|
// UpdateEntries();
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
else
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
if(t->Down())/////////////////////////////////////////////////////if there isn't a scrollbar and down is pressed
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
next = this->FindMenuItem(gameIndex[selectedItem], 1);
|
|
|
|
|
|
|
|
if(next >= 0)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
if(selectedItem == pagesize-1)
|
|
|
|
{
|
|
|
|
// move list down by 1
|
|
|
|
listOffset = this->FindMenuItem(listOffset, 1);
|
|
|
|
// UpdateEntries();
|
|
|
|
}
|
|
|
|
else if(game[selectedItem+1]->IsVisible())
|
|
|
|
{
|
|
|
|
game[selectedItem]->ResetState();
|
|
|
|
game[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
|
|
|
|
selectedItem++;
|
|
|
|
}
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
}
|
|
|
|
else if(t->Up())///////////////////////////////////////////////////up
|
|
|
|
{
|
|
|
|
prev = this->FindMenuItem(gameIndex[selectedItem], -1);
|
|
|
|
|
|
|
|
if(prev >= 0)
|
2009-05-03 20:53:31 +02:00
|
|
|
{
|
2009-05-23 00:36:55 +02:00
|
|
|
if(selectedItem == 0)
|
|
|
|
{
|
|
|
|
// move list up by 1
|
|
|
|
listOffset = prev;
|
|
|
|
// UpdateEntries();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
game[selectedItem]->ResetState();
|
|
|
|
game[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
|
|
|
|
selectedItem--;
|
|
|
|
}
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-05-23 00:36:55 +02:00
|
|
|
if(old_listOffset != listOffset)
|
|
|
|
UpdateListEntries();
|
|
|
|
|
2009-05-03 20:53:31 +02:00
|
|
|
if(updateCB)
|
|
|
|
updateCB(this);
|
2009-05-21 20:26:01 +02:00
|
|
|
}
|
|
|
|
|
2009-05-21 10:56:23 +02:00
|
|
|
void GuiGameBrowser::Reload(struct discHdr * l, int count)
|
|
|
|
{
|
|
|
|
LOCK(this);
|
2009-05-21 20:26:01 +02:00
|
|
|
gameList = l;
|
|
|
|
gameCnt = count;
|
2009-05-22 01:32:32 +02:00
|
|
|
scrollbaron = (gameCnt > pagesize) ? 1 : 0;
|
2009-05-21 20:26:01 +02:00
|
|
|
selectedItem = 0;
|
2009-05-21 10:56:23 +02:00
|
|
|
listOffset = 0;
|
2009-05-23 00:36:55 +02:00
|
|
|
UpdateListEntries();
|
2009-05-21 10:56:23 +02:00
|
|
|
|
|
|
|
for(int i=0; i<pagesize; i++)
|
|
|
|
game[i]->ResetState();
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|