2009-10-01 01:10:58 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* libwiigui
|
|
|
|
*
|
|
|
|
* Tantric 2009
|
|
|
|
*
|
|
|
|
* gui_filebrowser.cpp
|
|
|
|
*
|
|
|
|
* GUI class definitions
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "gui.h"
|
|
|
|
#include "prompts/filebrowser.h"
|
2010-09-19 22:25:12 +02:00
|
|
|
#include "settings/CSettings.h"
|
2010-09-26 10:33:43 +02:00
|
|
|
#include "themes/CTheme.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor for the GuiFileBrowser class.
|
|
|
|
*/
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiFileBrowser::GuiFileBrowser(int w, int h)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
width = w;
|
|
|
|
height = h;
|
|
|
|
selectedItem = 0;
|
|
|
|
selectable = true;
|
|
|
|
listChanged = true; // trigger an initial list update
|
|
|
|
triggerdisabled = false; // trigger disable
|
|
|
|
focus = 0; // allow focus
|
|
|
|
|
|
|
|
trigA = new GuiTrigger;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
trigHeldA = new GuiTrigger;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-26 10:33:43 +02:00
|
|
|
bgFileSelection = new GuiImageData(Resources::GetFile("bg_browser.png"), Resources::GetFileSize("bg_browser.png"));
|
2010-09-24 02:48:03 +02:00
|
|
|
bgFileSelectionImg = new GuiImage(bgFileSelection);
|
|
|
|
bgFileSelectionImg->SetParent(this);
|
|
|
|
bgFileSelectionImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
|
|
|
|
2010-09-26 10:33:43 +02:00
|
|
|
bgFileSelectionEntry = Resources::GetImageData("bg_browser_selection.png");
|
2010-11-13 23:34:53 +01:00
|
|
|
|
2010-09-26 10:33:43 +02:00
|
|
|
fileFolder = Resources::GetImageData("icon_folder.png");
|
2010-11-13 23:34:53 +01:00
|
|
|
|
2010-09-26 10:33:43 +02:00
|
|
|
scrollbar = Resources::GetImageData("scrollbar.png");
|
2010-09-24 02:48:03 +02:00
|
|
|
scrollbarImg = new GuiImage(scrollbar);
|
|
|
|
scrollbarImg->SetParent(this);
|
|
|
|
scrollbarImg->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
|
|
|
scrollbarImg->SetPosition(0, 2);
|
|
|
|
scrollbarImg->SetSkew(0, 0, 0, 0, 0, -30, 0, -30);
|
|
|
|
|
2010-09-26 10:33:43 +02:00
|
|
|
arrowDown = Resources::GetImageData("scrollbar_arrowdown.png");
|
2010-09-24 02:48:03 +02:00
|
|
|
arrowDownImg = new GuiImage(arrowDown);
|
2010-09-26 10:33:43 +02:00
|
|
|
arrowUp = Resources::GetImageData("scrollbar_arrowup.png");
|
2010-09-24 02:48:03 +02:00
|
|
|
arrowUpImg = new GuiImage(arrowUp);
|
2010-09-26 10:33:43 +02:00
|
|
|
scrollbarBox = Resources::GetImageData("scrollbar_box.png");
|
2010-09-24 02:48:03 +02:00
|
|
|
scrollbarBoxImg = new GuiImage(scrollbarBox);
|
|
|
|
|
|
|
|
arrowUpBtn = new GuiButton(arrowUpImg->GetWidth(), arrowUpImg->GetHeight());
|
|
|
|
arrowUpBtn->SetParent(this);
|
|
|
|
arrowUpBtn->SetImage(arrowUpImg);
|
|
|
|
arrowUpBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
|
|
|
arrowUpBtn->SetPosition(12, -12);
|
|
|
|
arrowUpBtn->SetSelectable(false);
|
|
|
|
arrowUpBtn->SetClickable(false);
|
|
|
|
arrowUpBtn->SetHoldable(true);
|
|
|
|
arrowUpBtn->SetTrigger(trigHeldA);
|
|
|
|
arrowUpBtn->SetSoundOver(btnSoundOver);
|
|
|
|
arrowUpBtn->SetSoundClick(btnSoundClick);
|
|
|
|
|
|
|
|
arrowDownBtn = new GuiButton(arrowDownImg->GetWidth(), arrowDownImg->GetHeight());
|
|
|
|
arrowDownBtn->SetParent(this);
|
|
|
|
arrowDownBtn->SetImage(arrowDownImg);
|
|
|
|
arrowDownBtn->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
|
|
|
|
arrowDownBtn->SetPosition(12, 12);
|
|
|
|
arrowDownBtn->SetSelectable(false);
|
|
|
|
arrowDownBtn->SetClickable(false);
|
|
|
|
arrowDownBtn->SetHoldable(true);
|
|
|
|
arrowDownBtn->SetTrigger(trigHeldA);
|
|
|
|
arrowDownBtn->SetSoundOver(btnSoundOver);
|
|
|
|
arrowDownBtn->SetSoundClick(btnSoundClick);
|
|
|
|
|
|
|
|
scrollbarBoxBtn = new GuiButton(scrollbarBoxImg->GetWidth(), scrollbarBoxImg->GetHeight());
|
|
|
|
scrollbarBoxBtn->SetParent(this);
|
|
|
|
scrollbarBoxBtn->SetImage(scrollbarBoxImg);
|
|
|
|
scrollbarBoxBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
|
|
|
scrollbarBoxBtn->SetPosition(-10, 0);
|
|
|
|
scrollbarBoxBtn->SetMinY(-10);
|
|
|
|
scrollbarBoxBtn->SetMaxY(156);
|
|
|
|
scrollbarBoxBtn->SetSelectable(false);
|
|
|
|
scrollbarBoxBtn->SetClickable(false);
|
|
|
|
scrollbarBoxBtn->SetHoldable(true);
|
|
|
|
scrollbarBoxBtn->SetTrigger(trigHeldA);
|
|
|
|
|
|
|
|
for (int i = 0; i < FILEBROWSERSIZE; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
fileListText[i] = new GuiText((char *) NULL, 20, ( GXColor )
|
|
|
|
{ 0, 0, 0, 0xff});
|
|
|
|
fileListText[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
|
|
|
fileListText[i]->SetPosition(5, 0);
|
|
|
|
fileListText[i]->SetMaxWidth(bgFileSelectionImg->GetWidth() - (arrowDownImg->GetWidth() + 20), DOTTED);
|
|
|
|
|
|
|
|
fileListTextOver[i] = new GuiText((char *) NULL, 20, ( GXColor )
|
|
|
|
{ 0, 0, 0, 0xff});
|
|
|
|
fileListTextOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
|
|
|
fileListTextOver[i]->SetPosition(5, 0);
|
|
|
|
fileListTextOver[i]->SetMaxWidth(bgFileSelectionImg->GetWidth() - (arrowDownImg->GetWidth() + 20),
|
|
|
|
SCROLL_HORIZONTAL);
|
|
|
|
|
|
|
|
fileListBg[i] = new GuiImage(bgFileSelectionEntry);
|
2010-09-19 01:16:05 +02:00
|
|
|
//fileListArchives[i] = new GuiImage(fileArchives);
|
|
|
|
//fileListDefault[i] = new GuiImage(fileDefault);
|
2010-09-24 02:48:03 +02:00
|
|
|
fileListFolder[i] = new GuiImage(fileFolder);
|
2010-09-19 01:16:05 +02:00
|
|
|
//fileListGFX[i] = new GuiImage(fileGFX);
|
|
|
|
//fileListPLS[i] = new GuiImage(filePLS);
|
|
|
|
//fileListSFX[i] = new GuiImage(fileSFX);
|
|
|
|
//fileListTXT[i] = new GuiImage(fileTXT);
|
|
|
|
//fileListXML[i] = new GuiImage(fileXML);
|
2010-09-24 02:48:03 +02:00
|
|
|
fileList[i] = new GuiButton(350, 30);
|
|
|
|
fileList[i]->SetParent(this);
|
|
|
|
fileList[i]->SetLabel(fileListText[i]);
|
|
|
|
fileList[i]->SetLabelOver(fileListTextOver[i]);
|
|
|
|
fileList[i]->SetImageOver(fileListBg[i]);
|
|
|
|
fileList[i]->SetPosition(2, 30 * i + 3);
|
|
|
|
fileList[i]->SetTrigger(trigA);
|
|
|
|
fileList[i]->SetRumble(false);
|
|
|
|
fileList[i]->SetSoundClick(btnSoundClick);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor for the GuiFileBrowser class.
|
|
|
|
*/
|
2010-02-09 11:59:55 +01:00
|
|
|
GuiFileBrowser::~GuiFileBrowser()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
delete arrowUpBtn;
|
|
|
|
delete arrowDownBtn;
|
|
|
|
delete scrollbarBoxBtn;
|
|
|
|
|
|
|
|
delete bgFileSelectionImg;
|
|
|
|
delete scrollbarImg;
|
|
|
|
delete arrowDownImg;
|
|
|
|
delete arrowUpImg;
|
|
|
|
delete scrollbarBoxImg;
|
|
|
|
|
|
|
|
delete bgFileSelection;
|
|
|
|
delete bgFileSelectionEntry;
|
|
|
|
//delete fileArchives;
|
|
|
|
//delete fileDefault;
|
|
|
|
delete fileFolder;
|
|
|
|
//delete fileGFX;
|
|
|
|
//delete filePLS;
|
|
|
|
//delete fileSFX;
|
|
|
|
//delete fileTXT;
|
|
|
|
//delete fileXML;
|
|
|
|
delete scrollbar;
|
|
|
|
delete arrowDown;
|
|
|
|
delete arrowUp;
|
|
|
|
delete scrollbarBox;
|
|
|
|
|
|
|
|
delete trigHeldA;
|
|
|
|
delete trigA;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < FILEBROWSERSIZE; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
delete fileListText[i];
|
|
|
|
delete fileListTextOver[i];
|
|
|
|
delete fileList[i];
|
|
|
|
delete fileListBg[i];
|
|
|
|
//delete fileListArchives[i];
|
|
|
|
//delete fileListDefault[i];
|
|
|
|
delete fileListFolder[i];
|
|
|
|
//delete fileListGFX[i];
|
|
|
|
//delete fileListPLS[i];
|
|
|
|
//delete fileListSFX[i];
|
|
|
|
//delete fileListTXT[i];
|
|
|
|
//delete fileListXML[i];
|
|
|
|
}
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiFileBrowser::SetFocus(int f)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
|
|
|
focus = f;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < FILEBROWSERSIZE; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
fileList[i]->ResetState();
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (f == 1) fileList[selectedItem]->SetState(STATE_SELECTED);
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiFileBrowser::DisableTriggerUpdate(bool set)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
|
|
|
triggerdisabled = set;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
void GuiFileBrowser::ResetState()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
|
|
|
state = STATE_DEFAULT;
|
|
|
|
stateChan = -1;
|
|
|
|
selectedItem = 0;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < FILEBROWSERSIZE; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
fileList[i]->ResetState();
|
|
|
|
}
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
void GuiFileBrowser::TriggerUpdate()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
|
|
|
listChanged = true;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw the button on screen
|
|
|
|
*/
|
2010-02-09 11:59:55 +01:00
|
|
|
void GuiFileBrowser::Draw()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!this->IsVisible()) return;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
bgFileSelectionImg->Draw();
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < FILEBROWSERSIZE; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
fileList[i]->Draw();
|
|
|
|
}
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
scrollbarImg->Draw();
|
|
|
|
arrowUpBtn->Draw();
|
|
|
|
arrowDownBtn->Draw();
|
|
|
|
scrollbarBoxBtn->Draw();
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
this->UpdateEffects();
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiFileBrowser::Update(GuiTrigger * t)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
if (state == STATE_DISABLED || !t || triggerdisabled) return;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
int position = 0;
|
|
|
|
int positionWiimote = 0;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
arrowUpBtn->Update(t);
|
|
|
|
arrowDownBtn->Update(t);
|
|
|
|
scrollbarBoxBtn->Update(t);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
// move the file listing to respond to wiimote cursor movement
|
2010-09-24 02:48:03 +02:00
|
|
|
if (scrollbarBoxBtn->GetState() == STATE_HELD && scrollbarBoxBtn->GetStateChan() == t->chan && t->wpad.ir.valid
|
|
|
|
&& browser->browserList.size() > FILEBROWSERSIZE)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
scrollbarBoxBtn->SetPosition(20, -10);
|
2010-09-19 01:16:05 +02:00
|
|
|
positionWiimote = t->wpad.ir.y - 60 - scrollbarBoxBtn->GetTop();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (positionWiimote < scrollbarBoxBtn->GetMinY())
|
2010-09-19 01:16:05 +02:00
|
|
|
positionWiimote = scrollbarBoxBtn->GetMinY();
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (positionWiimote > scrollbarBoxBtn->GetMaxY()) positionWiimote = scrollbarBoxBtn->GetMaxY();
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
browser->pageIndex = (positionWiimote * browser->browserList.size()) / 136.0 - selectedItem;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (browser->pageIndex <= 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
browser->pageIndex = 0;
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (browser->pageIndex + FILEBROWSERSIZE >= (int) browser->browserList.size())
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
browser->pageIndex = browser->browserList.size() - FILEBROWSERSIZE;
|
|
|
|
}
|
|
|
|
listChanged = true;
|
|
|
|
focus = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (arrowDownBtn->GetState() == STATE_HELD && arrowDownBtn->GetStateChan() == t->chan)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
t->wpad.btns_h |= WPAD_BUTTON_DOWN;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!this->IsFocused()) ((GuiWindow *) this->GetParent())->ChangeFocus(this);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (arrowUpBtn->GetState() == STATE_HELD && arrowUpBtn->GetStateChan() == t->chan)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
t->wpad.btns_h |= WPAD_BUTTON_UP;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!this->IsFocused()) ((GuiWindow *) this->GetParent())->ChangeFocus(this);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* // pad/joystick navigation
|
2010-09-24 02:48:03 +02:00
|
|
|
if(!focus)
|
|
|
|
{
|
|
|
|
goto endNavigation; // skip navigation
|
|
|
|
listChanged = false;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
if (t->Right())
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (browser->pageIndex < (int) browser->browserList.size() && browser->browserList.size() > FILEBROWSERSIZE)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
browser->pageIndex += FILEBROWSERSIZE;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (browser->pageIndex + FILEBROWSERSIZE >= (int) browser->browserList.size()) browser->pageIndex
|
|
|
|
= browser->browserList.size() - FILEBROWSERSIZE;
|
2010-09-19 01:16:05 +02:00
|
|
|
listChanged = true;
|
|
|
|
}
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (t->Left())
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (browser->pageIndex > 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
browser->pageIndex -= FILEBROWSERSIZE;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (browser->pageIndex < 0) browser->pageIndex = 0;
|
2010-09-19 01:16:05 +02:00
|
|
|
listChanged = true;
|
|
|
|
}
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (t->Down())
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (browser->pageIndex + selectedItem + 1 < (int) browser->browserList.size())
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (selectedItem == FILEBROWSERSIZE - 1)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
// move list down by 1
|
|
|
|
browser->pageIndex++;
|
|
|
|
listChanged = true;
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (fileList[selectedItem + 1]->IsVisible())
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
fileList[selectedItem]->ResetState();
|
2010-09-24 02:48:03 +02:00
|
|
|
fileList[++selectedItem]->SetState(STATE_SELECTED, t->chan);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (t->Up())
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (selectedItem == 0 && browser->pageIndex + selectedItem > 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
// move list up by 1
|
|
|
|
browser->pageIndex--;
|
|
|
|
listChanged = true;
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (selectedItem > 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
fileList[selectedItem]->ResetState();
|
2010-09-24 02:48:03 +02:00
|
|
|
fileList[--selectedItem]->SetState(STATE_SELECTED, t->chan);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//endNavigation:
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < FILEBROWSERSIZE; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (listChanged)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
bool haveselected = false;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (browser->pageIndex + i < (int) browser->browserList.size())
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (fileList[i]->GetState() == STATE_DISABLED) fileList[i]->SetState(STATE_DEFAULT);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (fileList[i]->GetState() == STATE_SELECTED) haveselected = true;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
fileList[i]->SetVisible(true);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
fileListText[i]->SetText(browser->browserList[browser->pageIndex + i].displayname);
|
|
|
|
fileListTextOver[i]->SetText(browser->browserList[browser->pageIndex + i].displayname);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (browser->browserList[browser->pageIndex + i].isdir) // directory
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
fileList[i]->SetIcon(fileListFolder[i]);
|
|
|
|
fileListText[i]->SetPosition(30, 0);
|
|
|
|
fileListTextOver[i]->SetPosition(30, 0);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
2010-09-24 02:48:03 +02:00
|
|
|
char *fileext = strrchr(browserList[browser.pageIndex+i].displayname, '.');
|
|
|
|
fileListText[i]->SetPosition(32,0);
|
|
|
|
fileListTextOver[i]->SetPosition(32,0);
|
|
|
|
if(fileext)
|
|
|
|
{
|
|
|
|
if(!strcasecmp(fileext, ".png") || !strcasecmp(fileext, ".jpg") || !strcasecmp(fileext, ".jpeg") ||
|
|
|
|
!strcasecmp(fileext, ".gif") || !strcasecmp(fileext, ".tga") || !strcasecmp(fileext, ".tpl") ||
|
|
|
|
!strcasecmp(fileext, ".bmp")) {
|
|
|
|
fileList[i]->SetIcon(fileListGFX[i]);
|
|
|
|
} else if(!strcasecmp(fileext, ".mp3") || !strcasecmp(fileext, ".ogg") || !strcasecmp(fileext, ".flac") ||
|
|
|
|
!strcasecmp(fileext, ".mpc") || !strcasecmp(fileext, ".m4a") || !strcasecmp(fileext, ".wav")) {
|
|
|
|
fileList[i]->SetIcon(fileListSFX[i]);
|
|
|
|
} else if(!strcasecmp(fileext, ".pls") || !strcasecmp(fileext, ".m3u")) {
|
|
|
|
fileList[i]->SetIcon(fileListPLS[i]);
|
|
|
|
} else if(!strcasecmp(fileext, ".txt")) {
|
|
|
|
fileList[i]->SetIcon(fileListTXT[i]);
|
|
|
|
} else if(!strcasecmp(fileext, ".xml")) {
|
|
|
|
fileList[i]->SetIcon(fileListXML[i]);
|
|
|
|
} else if(!strcasecmp(fileext, ".rar") || !strcasecmp(fileext, ".zip") ||
|
|
|
|
!strcasecmp(fileext, ".gz") || !strcasecmp(fileext, ".7z")) {
|
|
|
|
fileList[i]->SetIcon(fileListArchives[i]);
|
|
|
|
} else {
|
|
|
|
fileList[i]->SetIcon(fileListDefault[i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fileList[i]->SetIcon(fileListDefault[i]);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
fileList[i]->SetIcon(NULL);
|
|
|
|
fileListText[i]->SetPosition(10, 0);
|
|
|
|
fileListTextOver[i]->SetPosition(10, 0);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
fileList[i]->SetVisible(false);
|
|
|
|
fileList[i]->SetState(STATE_DISABLED);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!haveselected && browser->pageIndex < (int) browser->browserList.size()) fileList[i]->SetState(
|
|
|
|
STATE_SELECTED, t->chan);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (i != selectedItem && fileList[i]->GetState() == STATE_SELECTED)
|
2010-09-19 01:16:05 +02:00
|
|
|
fileList[i]->ResetState();
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (focus && i == selectedItem && fileList[i]->GetState() == STATE_DEFAULT) fileList[selectedItem]->SetState(
|
|
|
|
STATE_SELECTED, t->chan);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
int currChan = t->chan;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (t->wpad.ir.valid && !fileList[i]->IsInside(t->wpad.ir.x, t->wpad.ir.y)) t->chan = -1;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
fileList[i]->Update(t);
|
2010-09-19 01:16:05 +02:00
|
|
|
t->chan = currChan;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (fileList[i]->GetState() == STATE_SELECTED)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
selectedItem = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// update the location of the scroll box based on the position in the file list
|
2010-09-24 02:48:03 +02:00
|
|
|
if (positionWiimote > 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
position = positionWiimote; // follow wiimote cursor
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
position = 136 * (browser->pageIndex + FILEBROWSERSIZE / 2.0) / (browser->browserList.size() * 1.0);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (browser->pageIndex / (FILEBROWSERSIZE / 2.0) < 1)
|
2010-09-19 01:16:05 +02:00
|
|
|
position = -10;
|
2010-09-24 02:48:03 +02:00
|
|
|
else if ((browser->pageIndex + FILEBROWSERSIZE) / (FILEBROWSERSIZE * 1.0) >= (browser->browserList.size())
|
|
|
|
/ (FILEBROWSERSIZE * 1.0)) position = 156;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
scrollbarBoxBtn->SetPosition(12, position + 26);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
listChanged = false;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (updateCB) updateCB(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|