mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-12-27 04:01:52 +01:00
change the onscreen keyboard to filebrowser for custom paths
no button to create a new file and a little bug with the scrolling, but better than typing stuff in. added channel launcher. currently doesnt show the actual name, only the u32 and ID. also, it is only showing 0x00010001 channels, so no Mii, weather, or other crappy channels, just the good stuff. fixed bug that showed the MacOS hidden files as extra homebrew entries.
This commit is contained in:
parent
07366754c6
commit
19067967bc
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: David Jelinek (djelinek@hotmail.com) \n"
|
||||
"Language-Team: Last version on http://startgolf.tym.cz/czech.lang \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: Kin8\n"
|
||||
"Language-Team: Badablek, Amour, ikya, OuahOuah, dj_skual & Kin8\n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: Tusk\n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-20 20:00+0200\n"
|
||||
"Last-Translator: Cambo \n"
|
||||
"Language-Team: FoxeJoe & Cambo\n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: ziom666 (zadania_prog@vp.pl)\n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-20 16:40\n"
|
||||
"Last-Translator: Sky8000\n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: Kir\n"
|
||||
"Language-Team: Kir\n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-21 20:18+0200\n"
|
||||
"Last-Translator: Katsurou\n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
@ -4,7 +4,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: USB Loader GX\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-07-23 19:22+0200\n"
|
||||
"POT-Creation-Date: 2009-07-24 23:13-0400\n"
|
||||
"PO-Revision-Date: 2009-07-18 15:18+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
2
Makefile
2
Makefile
@ -28,7 +28,7 @@ INCLUDES := source
|
||||
|
||||
CFLAGS = -g -O2 -save-temps -Wall $(MACHDEP) $(INCLUDE)
|
||||
CXXFLAGS = -Xassembler -aln=$@.lst $(CFLAGS)
|
||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80c00000
|
||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80b00000
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
|
2
gui.pnps
2
gui.pnps
@ -1 +1 @@
|
||||
<pd><ViewState><e p="gui\source\mload" x="true"></e><e p="gui\source\settings" x="true"></e><e p="gui\source" x="true"></e><e p="gui\source\images" x="false"></e><e p="gui\source\libwbfs" x="true"></e><e p="gui\source\libwiigui" x="true"></e><e p="gui\source\patches" x="true"></e><e p="gui\source\prompts" x="true"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="true"></e><e p="gui\source\network" x="true"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="true"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="true"></e></ViewState></pd>
|
||||
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\images" x="false"></e><e p="gui\source\libwbfs" x="true"></e><e p="gui\source\libwiigui" x="false"></e><e p="gui\source\patches" x="false"></e><e p="gui\source\prompts" x="true"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="true"></e><e p="gui\source\network" x="false"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="false"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="true"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="true"></e></ViewState></pd>
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "language/gettext.h"
|
||||
#include "libwiigui/gui.h"
|
||||
#include "prompts/TitleBrowser.h"
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "prompts/ProgressWindow.h"
|
||||
#include "homebrewboot/HomebrewFiles.h"
|
||||
@ -104,6 +105,10 @@ int MenuHomebrewBrowse()
|
||||
|
||||
snprintf(imgPath, sizeof(imgPath), "%swifi1.png", CFG.theme_path);
|
||||
GuiImageData wifiImgData(imgPath, wifi1_png);
|
||||
|
||||
snprintf(imgPath, sizeof(imgPath), "%sbrowser.png", CFG.theme_path);
|
||||
GuiImageData channelImgData(imgPath, browser_png);
|
||||
|
||||
|
||||
GuiImage background(&bgData);
|
||||
|
||||
@ -294,6 +299,17 @@ int MenuHomebrewBrowse()
|
||||
wifiBtn.SetEffectGrow();
|
||||
wifiBtn.SetAlpha(80);
|
||||
wifiBtn.SetTrigger(&trigA);
|
||||
|
||||
GuiImage channelBtnImg(&channelImgData);
|
||||
channelBtnImg.SetWidescreen(CFG.widescreen);
|
||||
GuiButton channelBtn(channelBtnImg.GetWidth(), channelBtnImg.GetHeight());
|
||||
channelBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
channelBtn.SetPosition(425, 400);
|
||||
channelBtn.SetImage(&channelBtnImg);
|
||||
channelBtn.SetSoundOver(&btnSoundOver);
|
||||
channelBtn.SetSoundClick(&btnClick);
|
||||
channelBtn.SetEffectGrow();
|
||||
channelBtn.SetTrigger(&trigA);
|
||||
|
||||
|
||||
GuiWindow w(screenwidth, screenheight);
|
||||
@ -385,6 +401,7 @@ int MenuHomebrewBrowse()
|
||||
w.Append(&backBtn);
|
||||
w.Append(&homo);
|
||||
w.Append(&wifiBtn);
|
||||
w.Append(&channelBtn);
|
||||
w.Append(&GoRightBtn);
|
||||
w.Append(&GoLeftBtn);
|
||||
|
||||
@ -835,7 +852,19 @@ int MenuHomebrewBrowse()
|
||||
CloseConnection();
|
||||
ResumeNetworkWait();
|
||||
}
|
||||
|
||||
|
||||
else if(channelBtn.GetState() == STATE_CLICKED) {
|
||||
w.SetState(STATE_DISABLED);
|
||||
//10001 are the channels that are installed as channels, not including shop channel/mii channel etc
|
||||
u32 num = 0x00010001;
|
||||
TitleBrowser(num);
|
||||
//if they didn't boot a channel reset this window
|
||||
w.SetState(STATE_DEFAULT);
|
||||
channelBtn.ResetState();
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(IsNetworkInit()) {
|
||||
wifiBtn.SetAlpha(255);
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ bool HomebrewFiles::LoadPath(const char * folderpath)
|
||||
temp[i] = filename[strlen(filename)-4+i];
|
||||
}
|
||||
|
||||
if(strncasecmp(temp, ".dol", 4) == 0 || strncasecmp(temp, ".elf", 4) == 0
|
||||
&& filecount < MAXHOMEBREWS) {
|
||||
if((strncasecmp(temp, ".dol", 4) == 0 || strncasecmp(temp, ".elf", 4) == 0)
|
||||
&& filecount < MAXHOMEBREWS && filename[0]!='.') {
|
||||
|
||||
strncpy(FileInfo[filecount].FilePath, folderpath, sizeof(FileInfo[filecount].FilePath));
|
||||
strncpy(FileInfo[filecount].FileName, filename, sizeof(FileInfo[filecount].FileName));
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.0 KiB |
@ -9,7 +9,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "gui.h"
|
||||
#include "filebrowser.h"
|
||||
#include "prompts/filebrowser.h"
|
||||
|
||||
#define FILEBROWSERSIZE 8
|
||||
/**
|
||||
@ -46,7 +46,8 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
||||
scrollbarImg = new GuiImage(scrollbar);
|
||||
scrollbarImg->SetParent(this);
|
||||
scrollbarImg->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||
scrollbarImg->SetPosition(0, 30);
|
||||
scrollbarImg->SetPosition(0, 2);
|
||||
scrollbarImg->SetSkew(0,0,0,0,0,-30,0,-30);
|
||||
|
||||
arrowDown = new GuiImageData(scrollbar_arrowdown_png);
|
||||
arrowDownImg = new GuiImage(arrowDown);
|
||||
@ -59,6 +60,7 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
||||
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);
|
||||
@ -70,6 +72,7 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
||||
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);
|
||||
@ -81,8 +84,8 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
||||
scrollbarBoxBtn->SetParent(this);
|
||||
scrollbarBoxBtn->SetImage(scrollbarBoxImg);
|
||||
scrollbarBoxBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||
scrollbarBoxBtn->SetMinY(0);
|
||||
scrollbarBoxBtn->SetMaxY(136);
|
||||
scrollbarBoxBtn->SetMinY(-10);
|
||||
scrollbarBoxBtn->SetMaxY(156);
|
||||
scrollbarBoxBtn->SetSelectable(false);
|
||||
scrollbarBoxBtn->SetClickable(false);
|
||||
scrollbarBoxBtn->SetHoldable(true);
|
||||
@ -103,7 +106,7 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
||||
fileListBg[i] = new GuiImage(bgFileSelectionEntry);
|
||||
fileListFolder[i] = new GuiImage(fileFolder);
|
||||
|
||||
fileList[i] = new GuiButton(512,30);
|
||||
fileList[i] = new GuiButton(350,30);
|
||||
fileList[i]->SetParent(this);
|
||||
fileList[i]->SetLabel(fileListText[i]);
|
||||
fileList[i]->SetLabelOver(fileListTextOver[i]);
|
||||
@ -228,7 +231,7 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
browser.numEntries > FILEBROWSERSIZE
|
||||
)
|
||||
{
|
||||
scrollbarBoxBtn->SetPosition(0,0);
|
||||
scrollbarBoxBtn->SetPosition(20,-10);
|
||||
positionWiimote = t->wpad.ir.y - 60 - scrollbarBoxBtn->GetTop();
|
||||
|
||||
if(positionWiimote < scrollbarBoxBtn->GetMinY())
|
||||
@ -236,7 +239,7 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
else if(positionWiimote > scrollbarBoxBtn->GetMaxY())
|
||||
positionWiimote = scrollbarBoxBtn->GetMaxY();
|
||||
|
||||
browser.pageIndex = (positionWiimote * browser.numEntries)/136.0 - selectedItem;
|
||||
browser.pageIndex = (positionWiimote * browser.numEntries)/166.0 - selectedItem;
|
||||
|
||||
if(browser.pageIndex <= 0)
|
||||
{
|
||||
@ -248,6 +251,8 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
}
|
||||
listChanged = true;
|
||||
focus = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(arrowDownBtn->GetState() == STATE_HELD && arrowDownBtn->GetStateChan() == t->chan)
|
||||
@ -255,12 +260,14 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
t->wpad.btns_h |= WPAD_BUTTON_DOWN;
|
||||
if(!this->IsFocused())
|
||||
((GuiWindow *)this->GetParent())->ChangeFocus(this);
|
||||
|
||||
}
|
||||
else if(arrowUpBtn->GetState() == STATE_HELD && arrowUpBtn->GetStateChan() == t->chan)
|
||||
{
|
||||
t->wpad.btns_h |= WPAD_BUTTON_UP;
|
||||
if(!this->IsFocused())
|
||||
((GuiWindow *)this->GetParent())->ChangeFocus(this);
|
||||
|
||||
}
|
||||
|
||||
// pad/joystick navigation
|
||||
@ -385,15 +392,15 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
}
|
||||
else
|
||||
{
|
||||
position = 136*(browser.pageIndex + FILEBROWSERSIZE/2.0) / (browser.numEntries*1.0);
|
||||
position = -10+(166*(browser.pageIndex + FILEBROWSERSIZE/2.0) / (browser.numEntries*1.0));
|
||||
|
||||
if(browser.pageIndex/(FILEBROWSERSIZE/2.0) < 1)
|
||||
position = 0;
|
||||
position = -10;
|
||||
else if((browser.pageIndex+FILEBROWSERSIZE)/(FILEBROWSERSIZE*1.0) >= (browser.numEntries)/(FILEBROWSERSIZE*1.0))
|
||||
position = 136;
|
||||
position = 156;
|
||||
}
|
||||
|
||||
scrollbarBoxBtn->SetPosition(0,position+36);
|
||||
scrollbarBoxBtn->SetPosition(12,position+26);
|
||||
|
||||
listChanged = false;
|
||||
|
||||
|
@ -25,7 +25,9 @@
|
||||
#include "homebrewboot/HomebrewBrowse.h"
|
||||
#include "homebrewboot/BootHomebrew.h"
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "prompts/filebrowser.h"
|
||||
#include "prompts/ProgressWindow.h"
|
||||
#include "prompts/TitleBrowser.h"
|
||||
#include "prompts/gameinfo.h"
|
||||
#include "mload/mload.h"
|
||||
#include "patches/patchcode.h"
|
||||
@ -472,7 +474,7 @@ int MenuDiscList()
|
||||
homebrewBtnImg.SetWidescreen(CFG.widescreen);
|
||||
GuiButton homebrewBtn(homebrewBtnImg.GetWidth(), homebrewBtnImg.GetHeight());
|
||||
homebrewBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
homebrewBtn.SetPosition(425, 400);
|
||||
homebrewBtn.SetPosition(THEME.homebrew_x,THEME.homebrew_y);
|
||||
homebrewBtn.SetImage(&homebrewBtnImg);
|
||||
homebrewBtn.SetSoundOver(&btnSoundOver);
|
||||
homebrewBtn.SetSoundClick(&btnClick);
|
||||
@ -618,7 +620,6 @@ int MenuDiscList()
|
||||
{
|
||||
w.Append(&gamecntTxt);
|
||||
}
|
||||
|
||||
w.Append(&sdcardBtn);
|
||||
w.Append(&poweroffBtn);
|
||||
w.Append(&gameInfo);
|
||||
|
194
source/prompts/TitleBrowser.cpp
Normal file
194
source/prompts/TitleBrowser.cpp
Normal file
@ -0,0 +1,194 @@
|
||||
/****************************************************************************
|
||||
* TitleBrowser
|
||||
* USB Loader GX 2009
|
||||
*
|
||||
* TitleBrowser.cpp
|
||||
***************************************************************************/
|
||||
#include "language/gettext.h"
|
||||
#include "libwiigui/gui.h"
|
||||
#include "libwiigui/gui_customoptionbrowser.h"
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "filelist.h"
|
||||
#include "settings/cfg.h"
|
||||
#include "sys.h"
|
||||
#include "menu.h"
|
||||
|
||||
#include "../wad/title.h"
|
||||
|
||||
/*** Extern functions ***/
|
||||
extern void ResumeGui();
|
||||
extern void HaltGui();
|
||||
|
||||
/*** Extern variables ***/
|
||||
extern GuiWindow * mainWindow;
|
||||
extern u8 shutdown;
|
||||
extern u8 reset;
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* TitleBrowser- opens a browser with a list of installed Titles
|
||||
* relies on code from any title deleter.
|
||||
*********************************************************************************/
|
||||
int TitleBrowser(u32 type)
|
||||
{
|
||||
|
||||
u32 num_titles;
|
||||
u32 titles[100] ATTRIBUTE_ALIGN(32);
|
||||
s32 ret = -1;
|
||||
|
||||
|
||||
// Get count of titles of our requested type
|
||||
ret = getTitles_TypeCount(type, &num_titles);
|
||||
if (ret < 0){
|
||||
//printf("\tError! Can't get count of titles! (ret = %d)\n", ret);
|
||||
//exit(1);
|
||||
}
|
||||
|
||||
// Die if we can't handle this many
|
||||
if (num_titles > 100){
|
||||
//printf("\tError! Too many titles! (%u)\n", num_titles);
|
||||
//exit(1);
|
||||
}
|
||||
|
||||
// Get titles of our requested type
|
||||
ret = getTitles_Type(type, titles, num_titles);
|
||||
if (ret < 0){
|
||||
//printf("\tError! Can't get list of titles! (ret = %d)\n", ret);
|
||||
//exit(1);
|
||||
}
|
||||
|
||||
|
||||
customOptionList options3(num_titles);
|
||||
//write the titles on the option browser
|
||||
u32 i = 0;
|
||||
while (i < num_titles){
|
||||
|
||||
char name[256];
|
||||
char text[15];
|
||||
//set the title's name, number, ID to text
|
||||
sprintf(text, "%s", titleText(type, titles[i]));
|
||||
getTitle_Name(name, TITLE_ID(type, titles[i]), text);
|
||||
|
||||
//set the text to the option browser
|
||||
options3.SetName(i, "%s",name);
|
||||
options3.SetValue(i, "%s (%08x)",text,titles[i]);
|
||||
|
||||
//move on to the next title
|
||||
i++;
|
||||
}
|
||||
|
||||
bool exit = false;
|
||||
|
||||
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume);
|
||||
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume);
|
||||
|
||||
char imgPath[100];
|
||||
|
||||
snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
|
||||
GuiImageData btnOutline(imgPath, button_dialogue_box_png);
|
||||
snprintf(imgPath, sizeof(imgPath), "%sgamesettings_background.png", CFG.theme_path);
|
||||
GuiImageData settingsbg(imgPath, settings_background_png);
|
||||
|
||||
GuiTrigger trigA;
|
||||
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
||||
GuiTrigger trigHome;
|
||||
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
|
||||
GuiTrigger trigB;
|
||||
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
|
||||
|
||||
GuiText titleTxt("Title Launcher", 28, (GXColor){0, 0, 0, 255});
|
||||
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
titleTxt.SetPosition(12,40);
|
||||
titleTxt.SetMaxWidth(356, GuiText::SCROLL);
|
||||
|
||||
GuiImage settingsbackground(&settingsbg);
|
||||
GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight());
|
||||
settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
settingsbackgroundbtn.SetPosition(0, 0);
|
||||
settingsbackgroundbtn.SetImage(&settingsbackground);
|
||||
|
||||
GuiText cancelBtnTxt(tr("Back"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
|
||||
GuiImage cancelBtnImg(&btnOutline);
|
||||
if (Settings.wsprompt == yes){
|
||||
cancelBtnTxt.SetWidescreen(CFG.widescreen);
|
||||
cancelBtnImg.SetWidescreen(CFG.widescreen);
|
||||
}
|
||||
GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, &btnClick,1);
|
||||
cancelBtn.SetScale(0.9);
|
||||
cancelBtn.SetLabel(&cancelBtnTxt);
|
||||
cancelBtn.SetTrigger(&trigB);
|
||||
|
||||
u8 scrollbaron = 0;
|
||||
if(num_titles > 9)
|
||||
scrollbaron = 1;
|
||||
|
||||
GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, CFG.theme_path, "bg_options_gamesettings.png", bg_options_settings_png, num_titles>9?1:0, 200);
|
||||
optionBrowser3.SetPosition(0, 90);
|
||||
optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
|
||||
HaltGui();
|
||||
GuiWindow w(screenwidth, screenheight);
|
||||
w.Append(&settingsbackgroundbtn);
|
||||
w.Append(&titleTxt);
|
||||
w.Append(&cancelBtn);
|
||||
w.Append(&optionBrowser3);
|
||||
|
||||
mainWindow->Append(&w);
|
||||
|
||||
ResumeGui();
|
||||
|
||||
while(!exit)
|
||||
{
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
if(shutdown == 1)
|
||||
Sys_Shutdown();
|
||||
if(reset == 1)
|
||||
Sys_Reboot();
|
||||
|
||||
ret = optionBrowser3.GetClickedOption();
|
||||
|
||||
if(ret > -1) {//if a click happened
|
||||
char name[256];
|
||||
char text[15];
|
||||
|
||||
sprintf(text, "%s", titleText(type, titles[ret]));
|
||||
getTitle_Name(name, TITLE_ID(type, titles[ret]), text);
|
||||
|
||||
char temp[100];
|
||||
//prompt to boot selected title
|
||||
snprintf(temp, sizeof(temp), "%s : %s",text,name);
|
||||
int choice = WindowPrompt("Boot?", temp, tr("OK"), tr("Cancel"));
|
||||
if(choice) {//if they say yes
|
||||
|
||||
WII_Initialize();
|
||||
WII_LaunchTitle(TITLE_ID(type,titles[ret]));
|
||||
//this really shouldn't be needed because the title will be booted
|
||||
exit = true;
|
||||
break;
|
||||
}
|
||||
else{
|
||||
//if they said no to booting the title
|
||||
ret = -1;
|
||||
optionBrowser3.ResetState();
|
||||
}
|
||||
}
|
||||
|
||||
if (cancelBtn.GetState() == STATE_CLICKED)
|
||||
{
|
||||
//break the loop and end the function
|
||||
exit = true;
|
||||
ret = -10;
|
||||
}
|
||||
}
|
||||
|
||||
HaltGui();
|
||||
mainWindow->Remove(&w);
|
||||
ResumeGui();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
15
source/prompts/TitleBrowser.h
Normal file
15
source/prompts/TitleBrowser.h
Normal file
@ -0,0 +1,15 @@
|
||||
/****************************************************************************
|
||||
* TitleBrowser
|
||||
* USB Loader GX 2009
|
||||
*
|
||||
* TitleBrowser.h
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _TITLEBROWSER_H_
|
||||
#define _TITLEBROWSER_H_
|
||||
|
||||
///opens a window with a custom option browser in it populated with
|
||||
//! type is the type of chnnel to put in the list
|
||||
int TitleBrowser(u32 type);
|
||||
|
||||
#endif
|
@ -1,225 +1,239 @@
|
||||
/****************************************************************************
|
||||
* libwiigui Template
|
||||
/****************************************************************************
|
||||
* libwiigui Template
|
||||
* Tantric 2009
|
||||
*
|
||||
* modified by dimok
|
||||
*
|
||||
* filebrowser.cpp
|
||||
*
|
||||
* Generic file routines - reading, writing, browsing
|
||||
***************************************************************************/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <sys/dir.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "filebrowser.h"
|
||||
#include "menu.h"
|
||||
|
||||
BROWSERINFO browser;
|
||||
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
|
||||
|
||||
/****************************************************************************
|
||||
* ResetBrowser()
|
||||
* Clears the file browser memory, and allocates one initial entry
|
||||
***************************************************************************/
|
||||
void ResetBrowser()
|
||||
{
|
||||
browser.numEntries = 0;
|
||||
browser.selIndex = 0;
|
||||
browser.pageIndex = 0;
|
||||
|
||||
// Clear any existing values
|
||||
if(browserList != NULL)
|
||||
{
|
||||
free(browserList);
|
||||
browserList = NULL;
|
||||
}
|
||||
// set aside space for 1 entry
|
||||
browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY));
|
||||
memset(browserList, 0, sizeof(BROWSERENTRY));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* UpdateDirName()
|
||||
* Update curent directory name for file browser
|
||||
***************************************************************************/
|
||||
int UpdateDirName()
|
||||
{
|
||||
int size=0;
|
||||
char * test;
|
||||
char temp[1024];
|
||||
|
||||
/* current directory doesn't change */
|
||||
if (strcmp(browserList[browser.selIndex].filename,".") == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/* go up to parent directory */
|
||||
else if (strcmp(browserList[browser.selIndex].filename,"..") == 0)
|
||||
{
|
||||
/* determine last subdirectory namelength */
|
||||
sprintf(temp,"%s",browser.dir);
|
||||
test = strtok(temp,"/");
|
||||
while (test != NULL)
|
||||
{
|
||||
size = strlen(test);
|
||||
test = strtok(NULL,"/");
|
||||
}
|
||||
|
||||
/* remove last subdirectory name */
|
||||
size = strlen(browser.dir) - size - 1;
|
||||
browser.dir[size] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
/* Open a directory */
|
||||
else
|
||||
{
|
||||
/* test new directory namelength */
|
||||
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) < MAXPATHLEN)
|
||||
{
|
||||
/* update current directory name */
|
||||
sprintf(browser.dir, "%s/%s",browser.dir, browserList[browser.selIndex].filename);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* FileSortCallback
|
||||
*
|
||||
* Quick sort callback to sort file entries with the following order:
|
||||
* .
|
||||
* ..
|
||||
* <dirs>
|
||||
* <files>
|
||||
***************************************************************************/
|
||||
int FileSortCallback(const void *f1, const void *f2)
|
||||
{
|
||||
/* Special case for implicit directories */
|
||||
if(((BROWSERENTRY *)f1)->filename[0] == '.' || ((BROWSERENTRY *)f2)->filename[0] == '.')
|
||||
{
|
||||
if(strcmp(((BROWSERENTRY *)f1)->filename, ".") == 0) { return -1; }
|
||||
if(strcmp(((BROWSERENTRY *)f2)->filename, ".") == 0) { return 1; }
|
||||
if(strcmp(((BROWSERENTRY *)f1)->filename, "..") == 0) { return -1; }
|
||||
if(strcmp(((BROWSERENTRY *)f2)->filename, "..") == 0) { return 1; }
|
||||
}
|
||||
|
||||
/* If one is a file and one is a directory the directory is first. */
|
||||
if(((BROWSERENTRY *)f1)->isdir && !(((BROWSERENTRY *)f2)->isdir)) return -1;
|
||||
if(!(((BROWSERENTRY *)f1)->isdir) && ((BROWSERENTRY *)f2)->isdir) return 1;
|
||||
|
||||
return stricmp(((BROWSERENTRY *)f1)->filename, ((BROWSERENTRY *)f2)->filename);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Browse subdirectories
|
||||
**************************************************************************/
|
||||
int
|
||||
ParseDirectory()
|
||||
{
|
||||
DIR_ITER *dir = NULL;
|
||||
char fulldir[MAXPATHLEN];
|
||||
char filename[MAXPATHLEN];
|
||||
struct stat filestat;
|
||||
|
||||
// reset browser
|
||||
ResetBrowser();
|
||||
|
||||
// open the directory
|
||||
sprintf(fulldir, "%s%s", browser.rootdir, browser.dir); // add currentDevice to path
|
||||
dir = diropen(fulldir);
|
||||
|
||||
// if we can't open the dir, try opening the root dir
|
||||
if (dir == NULL)
|
||||
{
|
||||
sprintf(browser.dir,"/");
|
||||
dir = diropen(browser.rootdir);
|
||||
if (dir == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// index files/folders
|
||||
int entryNum = 0;
|
||||
|
||||
while(dirnext(dir,filename,&filestat) == 0)
|
||||
{
|
||||
if(strcmp(filename,".") != 0)
|
||||
{
|
||||
BROWSERENTRY * newBrowserList = (BROWSERENTRY *)realloc(browserList, (entryNum+1) * sizeof(BROWSERENTRY));
|
||||
|
||||
if(!newBrowserList) // failed to allocate required memory
|
||||
{
|
||||
ResetBrowser();
|
||||
entryNum = -1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
browserList = newBrowserList;
|
||||
}
|
||||
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
|
||||
strncpy(browserList[entryNum].filename, filename, MAXJOLIET);
|
||||
|
||||
if(strcmp(filename,"..") == 0)
|
||||
{
|
||||
sprintf(browserList[entryNum].displayname, "..");
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(browserList[entryNum].displayname, filename); // crop name for display
|
||||
}
|
||||
|
||||
browserList[entryNum].length = filestat.st_size;
|
||||
browserList[entryNum].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
||||
|
||||
entryNum++;
|
||||
}
|
||||
}
|
||||
|
||||
// close directory
|
||||
dirclose(dir);
|
||||
|
||||
// Sort the file list
|
||||
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
|
||||
|
||||
browser.numEntries = entryNum;
|
||||
return entryNum;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* BrowserChangeFolder
|
||||
*
|
||||
* Update current directory and set new entry list if directory has changed
|
||||
***************************************************************************/
|
||||
int BrowserChangeFolder()
|
||||
{
|
||||
if(!UpdateDirName())
|
||||
return -1;
|
||||
|
||||
ParseDirectory();
|
||||
|
||||
return browser.numEntries;
|
||||
* modified by dimok
|
||||
*
|
||||
* filebrowser.cpp
|
||||
*
|
||||
* Generic file routines - reading, writing, browsing
|
||||
***************************************************************************/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <sys/dir.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "filebrowser.h"
|
||||
#include "menu.h"
|
||||
|
||||
#include "language/gettext.h"
|
||||
#include "PromptWindows.h"
|
||||
#include "libwiigui/gui.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*** Extern variables ***/
|
||||
extern GuiWindow * mainWindow;
|
||||
extern u8 shutdown;
|
||||
extern u8 reset;
|
||||
|
||||
/*** Extern functions ***/
|
||||
extern void ResumeGui();
|
||||
extern void HaltGui();
|
||||
|
||||
BROWSERINFO browser;
|
||||
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
|
||||
|
||||
/****************************************************************************
|
||||
* ResetBrowser()
|
||||
* Clears the file browser memory, and allocates one initial entry
|
||||
***************************************************************************/
|
||||
void ResetBrowser()
|
||||
{
|
||||
browser.numEntries = 0;
|
||||
browser.selIndex = 0;
|
||||
browser.pageIndex = 0;
|
||||
|
||||
// Clear any existing values
|
||||
if(browserList != NULL)
|
||||
{
|
||||
free(browserList);
|
||||
browserList = NULL;
|
||||
}
|
||||
// set aside space for 1 entry
|
||||
browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY));
|
||||
memset(browserList, 0, sizeof(BROWSERENTRY));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* BrowseDevice
|
||||
* Displays a list of files on the selected device
|
||||
***************************************************************************/
|
||||
int BrowseDevice(int device)
|
||||
{
|
||||
/****************************************************************************
|
||||
* UpdateDirName()
|
||||
* Update curent directory name for file browser
|
||||
***************************************************************************/
|
||||
int UpdateDirName()
|
||||
{
|
||||
int size=0;
|
||||
char * test;
|
||||
char temp[1024];
|
||||
|
||||
/* current directory doesn't change */
|
||||
if (strcmp(browserList[browser.selIndex].filename,".") == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/* go up to parent directory */
|
||||
else if (strcmp(browserList[browser.selIndex].filename,"..") == 0)
|
||||
{
|
||||
/* determine last subdirectory namelength */
|
||||
sprintf(temp,"%s",browser.dir);
|
||||
test = strtok(temp,"/");
|
||||
while (test != NULL)
|
||||
{
|
||||
size = strlen(test);
|
||||
test = strtok(NULL,"/");
|
||||
}
|
||||
|
||||
/* remove last subdirectory name */
|
||||
size = strlen(browser.dir) - size - 1;
|
||||
browser.dir[size] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
/* Open a directory */
|
||||
else
|
||||
{
|
||||
/* test new directory namelength */
|
||||
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) < MAXPATHLEN)
|
||||
{
|
||||
/* update current directory name */
|
||||
sprintf(browser.dir, "%s/%s",browser.dir, browserList[browser.selIndex].filename);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* FileSortCallback
|
||||
*
|
||||
* Quick sort callback to sort file entries with the following order:
|
||||
* .
|
||||
* ..
|
||||
* <dirs>
|
||||
* <files>
|
||||
***************************************************************************/
|
||||
int FileSortCallback(const void *f1, const void *f2)
|
||||
{
|
||||
/* Special case for implicit directories */
|
||||
if(((BROWSERENTRY *)f1)->filename[0] == '.' || ((BROWSERENTRY *)f2)->filename[0] == '.')
|
||||
{
|
||||
if(strcmp(((BROWSERENTRY *)f1)->filename, ".") == 0) { return -1; }
|
||||
if(strcmp(((BROWSERENTRY *)f2)->filename, ".") == 0) { return 1; }
|
||||
if(strcmp(((BROWSERENTRY *)f1)->filename, "..") == 0) { return -1; }
|
||||
if(strcmp(((BROWSERENTRY *)f2)->filename, "..") == 0) { return 1; }
|
||||
}
|
||||
|
||||
/* If one is a file and one is a directory the directory is first. */
|
||||
if(((BROWSERENTRY *)f1)->isdir && !(((BROWSERENTRY *)f2)->isdir)) return -1;
|
||||
if(!(((BROWSERENTRY *)f1)->isdir) && ((BROWSERENTRY *)f2)->isdir) return 1;
|
||||
|
||||
return stricmp(((BROWSERENTRY *)f1)->filename, ((BROWSERENTRY *)f2)->filename);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Browse subdirectories
|
||||
**************************************************************************/
|
||||
int
|
||||
ParseDirectory()
|
||||
{
|
||||
DIR_ITER *dir = NULL;
|
||||
char fulldir[MAXPATHLEN];
|
||||
char filename[MAXPATHLEN];
|
||||
struct stat filestat;
|
||||
|
||||
// reset browser
|
||||
ResetBrowser();
|
||||
|
||||
// open the directory
|
||||
sprintf(fulldir, "%s%s", browser.rootdir, browser.dir); // add currentDevice to path
|
||||
dir = diropen(fulldir);
|
||||
|
||||
// if we can't open the dir, try opening the root dir
|
||||
if (dir == NULL)
|
||||
{
|
||||
sprintf(browser.dir,"/");
|
||||
dir = diropen(browser.rootdir);
|
||||
if (dir == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// index files/folders
|
||||
int entryNum = 0;
|
||||
|
||||
while(dirnext(dir,filename,&filestat) == 0)
|
||||
{
|
||||
if(strcmp(filename,".") != 0)
|
||||
{
|
||||
BROWSERENTRY * newBrowserList = (BROWSERENTRY *)realloc(browserList, (entryNum+1) * sizeof(BROWSERENTRY));
|
||||
|
||||
if(!newBrowserList) // failed to allocate required memory
|
||||
{
|
||||
ResetBrowser();
|
||||
entryNum = -1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
browserList = newBrowserList;
|
||||
}
|
||||
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
|
||||
strncpy(browserList[entryNum].filename, filename, MAXJOLIET);
|
||||
|
||||
if(strcmp(filename,"..") == 0)
|
||||
{
|
||||
sprintf(browserList[entryNum].displayname, "..");
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(browserList[entryNum].displayname, filename); // crop name for display
|
||||
}
|
||||
|
||||
browserList[entryNum].length = filestat.st_size;
|
||||
browserList[entryNum].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
||||
|
||||
entryNum++;
|
||||
}
|
||||
}
|
||||
|
||||
// close directory
|
||||
dirclose(dir);
|
||||
|
||||
// Sort the file list
|
||||
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
|
||||
|
||||
browser.numEntries = entryNum;
|
||||
return entryNum;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* BrowserChangeFolder
|
||||
*
|
||||
* Update current directory and set new entry list if directory has changed
|
||||
***************************************************************************/
|
||||
int BrowserChangeFolder()
|
||||
{
|
||||
if(!UpdateDirName())
|
||||
return -1;
|
||||
|
||||
ParseDirectory();
|
||||
|
||||
return browser.numEntries;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* BrowseDevice
|
||||
* Displays a list of files on the selected device
|
||||
***************************************************************************/
|
||||
int BrowseDevice(int device)
|
||||
{
|
||||
sprintf(browser.dir, "/");
|
||||
switch(device)
|
||||
{
|
||||
@ -229,7 +243,190 @@ int BrowseDevice(int device)
|
||||
case USB:
|
||||
sprintf(browser.rootdir, "USB:");
|
||||
break;
|
||||
}
|
||||
ParseDirectory(); // Parse root directory
|
||||
return browser.numEntries;
|
||||
}
|
||||
}
|
||||
ParseDirectory(); // Parse root directory
|
||||
return browser.numEntries;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* MenuBrowseDevice
|
||||
***************************************************************************/
|
||||
|
||||
int BrowseDevice(char * var, int force)
|
||||
{
|
||||
|
||||
int result=-1;
|
||||
int i;
|
||||
char currentdir[90];
|
||||
int curDivice = -1;
|
||||
int forced =force;
|
||||
|
||||
if(forced>-1){
|
||||
if(BrowseDevice(forced) > 0)
|
||||
{
|
||||
curDivice = forced;
|
||||
goto main;
|
||||
}
|
||||
}
|
||||
|
||||
else if((!strcasecmp(bootDevice, "USB:"))&&(BrowseDevice(USB) > 0))
|
||||
{
|
||||
curDivice = USB;
|
||||
goto main;
|
||||
}
|
||||
else if((!strcasecmp(bootDevice, "SD:"))&&(BrowseDevice(SD) > 0))
|
||||
{
|
||||
curDivice = SD;
|
||||
goto main;
|
||||
}
|
||||
else {
|
||||
WindowPrompt(tr("Error"),0,tr("Ok"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
main:
|
||||
int menu = MENU_NONE;
|
||||
|
||||
/*
|
||||
GuiText titleTxt("Browse Files", 28, (GXColor){0, 0, 0, 230});
|
||||
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
titleTxt.SetPosition(70,20);
|
||||
*/
|
||||
GuiTrigger trigA;
|
||||
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
||||
GuiTrigger trigB;
|
||||
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
|
||||
|
||||
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume);
|
||||
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume);
|
||||
|
||||
GuiImageData btnOutline(button_dialogue_box_png);
|
||||
GuiText ExitBtnTxt("Cancel", 24, (GXColor){0, 0, 0, 255});
|
||||
GuiImage ExitBtnImg(&btnOutline);
|
||||
if (Settings.wsprompt == yes){
|
||||
ExitBtnTxt.SetWidescreen(CFG.widescreen);
|
||||
ExitBtnImg.SetWidescreen(CFG.widescreen);
|
||||
}GuiButton ExitBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
|
||||
ExitBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
|
||||
ExitBtn.SetPosition(-55, -35);
|
||||
ExitBtn.SetLabel(&ExitBtnTxt);
|
||||
ExitBtn.SetImage(&ExitBtnImg);
|
||||
ExitBtn.SetTrigger(&trigA);
|
||||
ExitBtn.SetTrigger(&trigB);
|
||||
ExitBtn.SetEffectGrow();
|
||||
|
||||
GuiText okBtnTxt(tr("Ok"), 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
GuiImage okBtnImg(&btnOutline);
|
||||
if (Settings.wsprompt == yes){
|
||||
okBtnTxt.SetWidescreen(CFG.widescreen);
|
||||
okBtnImg.SetWidescreen(CFG.widescreen);
|
||||
}
|
||||
GuiButton okBtn(&okBtnImg,&okBtnImg, 0, 4, 45, -35, &trigA, &btnSoundOver, &btnClick,1);
|
||||
okBtn.SetLabel(&okBtnTxt);
|
||||
|
||||
GuiFileBrowser fileBrowser(396, 248);
|
||||
fileBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
fileBrowser.SetPosition(0, 120);
|
||||
|
||||
GuiImageData Address(addressbar_textbox_png);
|
||||
snprintf(currentdir, sizeof(currentdir), "%s%s", browser.rootdir, browser.dir);
|
||||
GuiText AdressText(currentdir, 20, (GXColor) {0, 0, 0, 255});
|
||||
AdressText.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
AdressText.SetPosition(20, 0);
|
||||
AdressText.SetMaxWidth(Address.GetWidth()-40, GuiText::SCROLL);
|
||||
GuiImage AdressbarImg(&Address);
|
||||
GuiButton Adressbar(Address.GetWidth(), Address.GetHeight());
|
||||
Adressbar.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
Adressbar.SetPosition(0, fileBrowser.GetTop()-45);
|
||||
Adressbar.SetImage(&AdressbarImg);
|
||||
Adressbar.SetLabel(&AdressText);
|
||||
|
||||
//save var in case they cancel and return it to them
|
||||
snprintf(currentdir, sizeof(currentdir), "%s", var);
|
||||
sprintf(var,"%s", browser.rootdir);
|
||||
|
||||
HaltGui();
|
||||
GuiWindow w(screenwidth, screenheight);
|
||||
w.Append(&ExitBtn);
|
||||
// w.Append(&titleTxt);
|
||||
w.Append(&fileBrowser);
|
||||
w.Append(&Adressbar);
|
||||
w.Append(&okBtn);
|
||||
// w.Append(&deviceBtn);//i got codedump when i tried to make an extra button so i took this one out for now till i find the dump
|
||||
mainWindow->Append(&w);
|
||||
ResumeGui();
|
||||
|
||||
while(menu == MENU_NONE)
|
||||
{
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
if(shutdown == 1)
|
||||
Sys_Shutdown();
|
||||
|
||||
if(reset == 1)
|
||||
Sys_Reboot();
|
||||
|
||||
for(i=0; i<PAGESIZE; i++)
|
||||
{
|
||||
if(fileBrowser.fileList[i]->GetState() == STATE_CLICKED)
|
||||
{
|
||||
fileBrowser.fileList[i]->ResetState();
|
||||
// check corresponding browser entry
|
||||
if(browserList[browser.selIndex].isdir)
|
||||
{
|
||||
if(BrowserChangeFolder())
|
||||
{
|
||||
fileBrowser.ResetState();
|
||||
fileBrowser.fileList[0]->SetState(STATE_SELECTED);
|
||||
fileBrowser.TriggerUpdate();
|
||||
sprintf(var,"%s", browser.rootdir);
|
||||
int len=strlen(browser.rootdir);
|
||||
for (unsigned int i=len;i<strlen(browser.rootdir)+strlen(browser.dir);i++)
|
||||
{
|
||||
var[i]=browser.dir[i-(len-1)];
|
||||
}
|
||||
AdressText.SetTextf("%s", var);
|
||||
} else {
|
||||
menu = MENU_DISCLIST;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
mainWindow->SetState(STATE_DISABLED);
|
||||
mainWindow->SetState(STATE_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ExitBtn.GetState() == STATE_CLICKED)
|
||||
{
|
||||
snprintf(var,sizeof(currentdir),"%s", currentdir);
|
||||
break;
|
||||
}
|
||||
if(okBtn.GetState() == STATE_CLICKED)
|
||||
{
|
||||
/*int e=0;
|
||||
for(unsigned int d=0;d<strlen(var);d++)
|
||||
{
|
||||
if (d!=3)
|
||||
{
|
||||
currentdir[e]=var[d];
|
||||
e++;
|
||||
}
|
||||
}*/
|
||||
//snprintf(var,sizeof(currentdir),"%s", currentdir);
|
||||
//snprintf(var,sizeof(var),"%s%s", browser.rootdir, browser.dir);
|
||||
result = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
HaltGui();
|
||||
mainWindow->Remove(&w);
|
||||
ResumeGui();
|
||||
|
||||
//}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -51,5 +51,6 @@ void ResetBrowser();
|
||||
int ParseDirectory();
|
||||
int BrowserChangeFolder();
|
||||
int BrowseDevice(int device);
|
||||
int BrowseDevice(char * var, int force =-1);
|
||||
|
||||
#endif
|
@ -9,6 +9,7 @@
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "prompts/DiscBrowser.h"
|
||||
#include "settings/SettingsPrompts.h"
|
||||
#include "prompts/filebrowser.h"
|
||||
#include "cheats/cheatmenu.h"
|
||||
#include "fatmounter.h"
|
||||
#include "menu.h"
|
||||
@ -976,7 +977,7 @@ int MenuSettings()
|
||||
w.Remove(&optionBrowser2);
|
||||
w.Remove(&backBtn);
|
||||
char entered[20] = "";
|
||||
int result = OnScreenKeyboard(entered, 20,0);
|
||||
int result = OnScreenKeyboard(entered, 20,0);
|
||||
w.Append(&optionBrowser2);
|
||||
w.Append(&backBtn);
|
||||
if ( result == 1 ) {
|
||||
@ -1278,7 +1279,8 @@ int MenuSettings()
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.covers_path, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered,43,0);
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
w.Append(&optionBrowser2);
|
||||
w.Append(&backBtn);
|
||||
if ( result == 1 )
|
||||
@ -1304,7 +1306,8 @@ int MenuSettings()
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.disc_path, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered, 43,0);
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered, 43,0);
|
||||
w.Append(&optionBrowser2);
|
||||
w.Append(&backBtn);
|
||||
if ( result == 1 )
|
||||
@ -1330,7 +1333,8 @@ int MenuSettings()
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, CFG.theme_path, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered, 43,0);
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered, 43,0);
|
||||
HaltGui();
|
||||
w.RemoveAll();
|
||||
if ( result == 1 )
|
||||
@ -1387,7 +1391,8 @@ int MenuSettings()
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.titlestxt_path, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered,43,0);
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
w.Append(&optionBrowser2);
|
||||
w.Append(&backBtn);
|
||||
if ( result == 1 )
|
||||
@ -1418,7 +1423,8 @@ int MenuSettings()
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.update_path, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered,43,0);
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
w.Append(&optionBrowser2);
|
||||
w.Append(&backBtn);
|
||||
if ( result == 1 )
|
||||
@ -1440,7 +1446,8 @@ int MenuSettings()
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.Cheatcodespath, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered,43,0);
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
w.Append(&optionBrowser2);
|
||||
w.Append(&backBtn);
|
||||
if ( result == 1 )
|
||||
@ -1462,7 +1469,8 @@ int MenuSettings()
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.TxtCheatcodespath, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered,43,0);
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
w.Append(&optionBrowser2);
|
||||
w.Append(&backBtn);
|
||||
if ( result == 1 )
|
||||
@ -1484,7 +1492,8 @@ int MenuSettings()
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.dolpath, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered,43,0);
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
w.Append(&optionBrowser2);
|
||||
w.Append(&backBtn);
|
||||
if ( result == 1 )
|
||||
@ -1510,7 +1519,8 @@ int MenuSettings()
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.homebrewapps_path, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered,43,0);
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
w.Append(&optionBrowser2);
|
||||
w.Append(&backBtn);
|
||||
if ( result == 1 )
|
||||
|
@ -1,134 +0,0 @@
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "language/gettext.h"
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "libwiigui/gui.h"
|
||||
#include "filebrowser.h"
|
||||
#include "menu.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*** Extern variables ***/
|
||||
extern GuiWindow * mainWindow;
|
||||
extern u8 shutdown;
|
||||
extern u8 reset;
|
||||
|
||||
/*** Extern functions ***/
|
||||
extern void ResumeGui();
|
||||
extern void HaltGui();
|
||||
|
||||
/****************************************************************************
|
||||
* MenuBrowseDevice
|
||||
***************************************************************************/
|
||||
int MenuBrowseDevice()
|
||||
{
|
||||
int i;
|
||||
char currentdir[50];
|
||||
|
||||
// populate initial directory listing
|
||||
if(BrowseDevice(SD) <= 0)
|
||||
{
|
||||
int choice = WindowPrompt("Error",
|
||||
"Unable to load device.",
|
||||
"Retry",
|
||||
"Change Settings");
|
||||
|
||||
if(choice) {
|
||||
return MENU_DISCLIST;
|
||||
}
|
||||
}
|
||||
|
||||
int menu = MENU_NONE;
|
||||
|
||||
GuiText titleTxt("Browse Files", 28, (GXColor){0, 0, 0, 230});
|
||||
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
titleTxt.SetPosition(70,20);
|
||||
|
||||
GuiTrigger trigA;
|
||||
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
||||
GuiTrigger trigPlus;
|
||||
trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
|
||||
GuiTrigger trigMinus;
|
||||
trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
|
||||
|
||||
GuiFileBrowser fileBrowser(552, 248);
|
||||
fileBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
fileBrowser.SetPosition(0, 100);
|
||||
|
||||
GuiImageData btnOutline(button_dialogue_box_png);
|
||||
GuiText ExitBtnTxt("Exit", 24, (GXColor){0, 0, 0, 255});
|
||||
GuiImage ExitBtnImg(&btnOutline);
|
||||
GuiButton ExitBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
|
||||
ExitBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
|
||||
ExitBtn.SetPosition(100, -35);
|
||||
ExitBtn.SetLabel(&ExitBtnTxt);
|
||||
ExitBtn.SetImage(&ExitBtnImg);
|
||||
ExitBtn.SetTrigger(&trigA);
|
||||
ExitBtn.SetEffectGrow();
|
||||
|
||||
GuiImageData Address(addressbar_textbox_png);
|
||||
snprintf(currentdir, sizeof(currentdir), "%s%s", browser.rootdir, browser.dir);
|
||||
GuiText AdressText(currentdir, 20, (GXColor) {0, 0, 0, 255});
|
||||
AdressText.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
AdressText.SetPosition(20, 0);
|
||||
AdressText.SetMaxWidth(Address.GetWidth()-40, GuiText::SCROLL);
|
||||
GuiImage AdressbarImg(&Address);
|
||||
GuiButton Adressbar(Address.GetWidth(), Address.GetHeight());
|
||||
Adressbar.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
Adressbar.SetPosition(60, fileBrowser.GetTop()-45);
|
||||
Adressbar.SetImage(&AdressbarImg);
|
||||
Adressbar.SetLabel(&AdressText);
|
||||
|
||||
HaltGui();
|
||||
GuiWindow w(screenwidth, screenheight);
|
||||
w.Append(&ExitBtn);
|
||||
w.Append(&titleTxt);
|
||||
w.Append(&fileBrowser);
|
||||
w.Append(&Adressbar);
|
||||
mainWindow->Append(&w);
|
||||
ResumeGui();
|
||||
|
||||
while(menu == MENU_NONE)
|
||||
{
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
if(shutdown == 1)
|
||||
Sys_Shutdown();
|
||||
|
||||
if(reset == 1)
|
||||
Sys_Reboot();
|
||||
|
||||
for(i=0; i<PAGESIZE; i++)
|
||||
{
|
||||
if(fileBrowser.fileList[i]->GetState() == STATE_CLICKED)
|
||||
{
|
||||
fileBrowser.fileList[i]->ResetState();
|
||||
// check corresponding browser entry
|
||||
if(browserList[browser.selIndex].isdir)
|
||||
{
|
||||
if(BrowserChangeFolder())
|
||||
{
|
||||
fileBrowser.ResetState();
|
||||
fileBrowser.fileList[0]->SetState(STATE_SELECTED);
|
||||
fileBrowser.TriggerUpdate();
|
||||
AdressText.SetTextf("%s%s", browser.rootdir, browser.dir);
|
||||
} else {
|
||||
menu = MENU_DISCLIST;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
mainWindow->SetState(STATE_DISABLED);
|
||||
mainWindow->SetState(STATE_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ExitBtn.GetState() == STATE_CLICKED)
|
||||
menu = MENU_DISCLIST;
|
||||
}
|
||||
HaltGui();
|
||||
mainWindow->Remove(&w);
|
||||
ResumeGui();
|
||||
|
||||
return menu;
|
||||
}
|
@ -2,9 +2,14 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <gccore.h>
|
||||
#include <ogcsys.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "../settings/cfg.h"
|
||||
#include "fatmounter.h"
|
||||
|
||||
#define MAX_TITLES 256
|
||||
|
||||
|
||||
s32 Title_GetList(u64 **outbuf, u32 *outlen)
|
||||
@ -254,3 +259,458 @@ out:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------
|
||||
taken from anytitledeleter
|
||||
name.c -- functions for determining the name of a title
|
||||
|
||||
Copyright (C) 2009 MrClick
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
// Max number of entries in the database
|
||||
#define MAX_DB 1024
|
||||
|
||||
// Max name length
|
||||
#define MAX_LINE 80
|
||||
|
||||
// Contains all title ids (e.g.: "HAC")
|
||||
static char **__db_i;
|
||||
// Contains all title names (e.g.: "Mii Channel")
|
||||
static char **__db;
|
||||
// Contains the number of entries in the database
|
||||
static u32 __db_cnt = 0;
|
||||
|
||||
s32 loadDatabase(){
|
||||
FILE *fdb;
|
||||
|
||||
char dbfile[100];
|
||||
snprintf(dbfile,sizeof(dbfile),"SD:/database.txt");
|
||||
// Init SD card access, open database file and check if it worked
|
||||
//fatInitDefault();
|
||||
SDCard_Init();
|
||||
fdb = fopen(dbfile, "r");
|
||||
if (fdb == NULL)
|
||||
return -1;
|
||||
|
||||
// Allocate memory for the database
|
||||
__db_i = calloc(MAX_DB, sizeof(char*));
|
||||
__db = calloc(MAX_DB, sizeof(char*));
|
||||
|
||||
// Define the line buffer. Each line in the db file will be stored here first
|
||||
char line[MAX_LINE];
|
||||
line[sizeof(line)] = 0;
|
||||
|
||||
// Generic char buffer and counter variable
|
||||
char byte;
|
||||
u32 i = 0;
|
||||
|
||||
// Read each character from the file
|
||||
do {
|
||||
byte = fgetc(fdb);
|
||||
// In case a line was longer than MAX_LINE
|
||||
if (i == -1){
|
||||
// Read bytes till a new line is hit
|
||||
if (byte == 0x0A)
|
||||
i = 0;
|
||||
// In case were still good with the line length
|
||||
} else {
|
||||
// Add the new byte to the line buffer
|
||||
line[i] = byte;
|
||||
i++;
|
||||
// When a new line is hit or MAX_LINE is reached
|
||||
if (byte == 0x0A || i == sizeof(line) - 1) {
|
||||
// Terminate finished line to create a string
|
||||
line[i] = 0;
|
||||
// When the line is not a comment or not to short
|
||||
if (line[0] != '#' && i > 5){
|
||||
|
||||
// Allocate and copy title id to database
|
||||
__db_i[__db_cnt] = calloc(4, sizeof(char*));
|
||||
memcpy(__db_i[__db_cnt], line, 3);
|
||||
__db_i[__db_cnt][3] = 0;
|
||||
// Allocate and copy title name to database
|
||||
__db[__db_cnt] = calloc(i - 4, sizeof(char*));
|
||||
memcpy(__db[__db_cnt], line + 4, i - 4);
|
||||
__db[__db_cnt][i - 5] = 0;
|
||||
|
||||
// Check that the next line does not overflow the database
|
||||
__db_cnt++;
|
||||
if (__db_cnt == MAX_DB)
|
||||
break;
|
||||
}
|
||||
// Set routine to ignore all bytes in the line when MAX_LINE is reached
|
||||
if (byte == 0x0A) i = 0; else i = -1;
|
||||
}
|
||||
}
|
||||
} while (!feof(fdb));
|
||||
|
||||
// Close database file; we are done with it
|
||||
fclose(fdb);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void freeDatabase(){
|
||||
u32 i = 0;
|
||||
for(; i < __db_cnt; i++){
|
||||
free(__db_i[i]);
|
||||
free(__db[i]);
|
||||
}
|
||||
free(__db_i);
|
||||
free(__db);
|
||||
}
|
||||
|
||||
|
||||
s32 getDatabaseCount(){
|
||||
return __db_cnt;
|
||||
}
|
||||
|
||||
s32 __convertWiiString(char *str, u8 *data, u32 cnt){
|
||||
u32 i = 0;
|
||||
for(; i < cnt; data += 2){
|
||||
u16 *chr = (u16*)data;
|
||||
if (*chr == 0)
|
||||
break;
|
||||
// ignores all but ASCII characters
|
||||
else if (*chr >= 0x20 && *chr <= 0x7E)
|
||||
str[i] = *chr;
|
||||
else
|
||||
str[i] = '.';
|
||||
i++;
|
||||
}
|
||||
str[i] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 getNameDB(char* name, char* id){
|
||||
// Return fixed values for special entries
|
||||
if (strncmp(id, "IOS", 3) == 0){
|
||||
sprintf(name, "Operating System %s", id);
|
||||
return 0;
|
||||
}
|
||||
if (strncmp(id, "MIOS", 3) == 0){
|
||||
sprintf(name, "Gamecube Compatibility Layer");
|
||||
return 0;
|
||||
}
|
||||
if (strncmp(id, "SYSMENU", 3) == 0){
|
||||
sprintf(name, "System Menu");
|
||||
return 0;
|
||||
}
|
||||
if (strncmp(id, "BC", 2) == 0){
|
||||
sprintf(name, "BC");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create an ? just in case the function aborts prematurely
|
||||
sprintf(name, "?");
|
||||
|
||||
u32 i;
|
||||
u8 db_found = 0;
|
||||
// Compare each id in the database to the title id
|
||||
for (i = 0; i < __db_cnt; i++)
|
||||
if (strncmp(id, __db_i[i], 3) == 0){
|
||||
db_found = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (db_found == 0)
|
||||
// Return -1 if no mathcing entry was found
|
||||
return -1;
|
||||
else {
|
||||
// Get name from database once a matching id was found
|
||||
sprintf(name, __db[i]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
s32 getNameBN(char* name, u64 id){
|
||||
// Terminate the name string just in case the function exits prematurely
|
||||
name[0] = 0;
|
||||
|
||||
// Create a string containing the absolute filename
|
||||
char file[256] __attribute__ ((aligned (32)));
|
||||
sprintf(file, "/title/%08x/%08x/data/banner.bin", (u32)(id >> 32), (u32)id);
|
||||
|
||||
// Bring the Wii into the title's userspace
|
||||
if (ES_SetUID(id) < 0){
|
||||
// Should that fail repeat after setting permissions to system menu mode
|
||||
// Identify_SysMenu();
|
||||
// if (ES_SetUID(id) < 0)
|
||||
// return -1;
|
||||
}
|
||||
|
||||
// Try to open file
|
||||
s32 fh = ISFS_Open(file, ISFS_OPEN_READ);
|
||||
|
||||
// If a title does not have a banner.bin bail out
|
||||
if (fh == -106)
|
||||
return -2;
|
||||
|
||||
// If it fails try to open again after identifying as SU
|
||||
if (fh == -102){
|
||||
// Identify_SU();
|
||||
// fh = ISFS_Open(file, ISFS_OPEN_READ);
|
||||
}
|
||||
// If the file won't open
|
||||
else if (fh < 0)
|
||||
return fh;
|
||||
|
||||
// Seek to 0x20 where the name is stored
|
||||
ISFS_Seek(fh, 0x20, 0);
|
||||
|
||||
// Read a chunk of 256 bytes from the banner.bin
|
||||
u8 *data = memalign(32, 0x100);
|
||||
if (ISFS_Read(fh, data, 0x100) < 0){
|
||||
ISFS_Close(fh);
|
||||
free(data);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
||||
// Prepare the strings that will contain the name of the title
|
||||
char name1[0x41] __attribute__ ((aligned (32)));
|
||||
char name2[0x41] __attribute__ ((aligned (32)));
|
||||
name1[0x40] = 0;
|
||||
name2[0x40] = 0;
|
||||
|
||||
__convertWiiString(name1, data + 0x00, 0x40);
|
||||
__convertWiiString(name2, data + 0x40, 0x40);
|
||||
free(data);
|
||||
|
||||
// Assemble name
|
||||
sprintf(name, "%s", name1);
|
||||
if (strlen(name2) > 1)
|
||||
sprintf(name, "%s (%s)", name, name2);
|
||||
|
||||
// Close the banner.bin
|
||||
ISFS_Close(fh);
|
||||
|
||||
// Job well done
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
s32 getName00(char* name, u64 id){
|
||||
// Create a string containing the absolute filename
|
||||
char file[256] __attribute__ ((aligned (32)));
|
||||
sprintf(file, "/title/%08x/%08x/content/00000000.app", (u32)(id >> 32), (u32)id);
|
||||
|
||||
s32 fh = ISFS_Open(file, ISFS_OPEN_READ);
|
||||
|
||||
|
||||
|
||||
// If the title does not have 00000000.app bail out
|
||||
if (fh == -106)
|
||||
return fh;
|
||||
|
||||
// In case there is some problem with the permission
|
||||
if (fh == -102){
|
||||
// Identify as super user
|
||||
// Identify_SU();
|
||||
// fh = ISFS_Open(file, ISFS_OPEN_READ);
|
||||
}
|
||||
else if (fh < 0)
|
||||
return fh;
|
||||
|
||||
// Jump to start of the name entries
|
||||
ISFS_Seek(fh, 0x9C, 0);
|
||||
|
||||
// Read a chunk of 0x22 * 0x2B bytes from 00000000.app
|
||||
u8 *data = memalign(32, 2048);
|
||||
s32 r = ISFS_Read(fh, data, 0x22 * 0x2B);
|
||||
//printf("%s %d\n", file, r);wait_anyKey();
|
||||
if (r < 0){
|
||||
ISFS_Close(fh);
|
||||
free(data);
|
||||
return -4;
|
||||
}
|
||||
|
||||
// Take the entries apart
|
||||
char str[0x22][0x2B];
|
||||
u8 i = 0;
|
||||
// Convert the entries to ASCII strings
|
||||
for(; i < 0x22; i++)
|
||||
__convertWiiString(str[i], data + (i * 0x2A), 0x2A);
|
||||
|
||||
// Clean up
|
||||
ISFS_Close(fh);
|
||||
free(data);
|
||||
|
||||
// Assemble name
|
||||
// Only the English name is returned
|
||||
// There are 6 other language names in the str array
|
||||
sprintf(name, "%s", str[2]);
|
||||
if (strlen(str[3]) > 1)
|
||||
sprintf(name, "%s (%s)", name, str[3]);
|
||||
|
||||
// Job well done
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
s32 printContent(u64 tid){
|
||||
char dir[256] __attribute__ ((aligned (32)));
|
||||
sprintf(dir, "/title/%08x/%08x/content", (u32)(tid >> 32), (u32)tid);
|
||||
|
||||
u32 num = 64;
|
||||
|
||||
static char list[8000] __attribute__((aligned(32)));
|
||||
|
||||
ISFS_ReadDir(dir, list, &num);
|
||||
|
||||
char *ptr = list;
|
||||
u8 br = 0;
|
||||
for (; strlen(ptr) > 0; ptr += strlen(ptr) + 1){
|
||||
printf(" %-12.12s", ptr);
|
||||
br++; if (br == 4) { br = 0; printf("\n"); }
|
||||
}
|
||||
if (br != 0)
|
||||
printf("\n");
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
s32 getTitle_Name(char* name, u64 id, char *tid){
|
||||
char buf[256] __attribute__ ((aligned (32)));
|
||||
|
||||
s32 r = -1;
|
||||
// Determine the title's name database/banner/00000000.app
|
||||
r = getNameDB(buf, tid);
|
||||
if (r < 0)
|
||||
r = getNameBN(buf, id);
|
||||
if (r < 0)
|
||||
r = getName00(buf, id);
|
||||
|
||||
switch (r){
|
||||
// In case a name was found in the database
|
||||
case 0: sprintf(name, "%s", buf);
|
||||
break;
|
||||
// In case a name was found in the banner.bin
|
||||
case 1: sprintf(name, "*%s*", buf);
|
||||
break;
|
||||
// In case a name was found in the 00000000.app
|
||||
case 2: sprintf(name, "+%s+", buf);
|
||||
break;
|
||||
// In case no proper name was found return a ?
|
||||
default: sprintf(name, "Unknown Title");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *titleText(u32 kind, u32 title){
|
||||
static char text[10];
|
||||
|
||||
if (kind == 1){
|
||||
// If we're dealing with System Titles, use custom names
|
||||
switch (title){
|
||||
case 1:
|
||||
strcpy(text, "BOOT2");
|
||||
break;
|
||||
case 2:
|
||||
strcpy(text, "SYSMENU");
|
||||
break;
|
||||
case 0x100:
|
||||
strcpy(text, "BC");
|
||||
break;
|
||||
case 0x101:
|
||||
strcpy(text, "MIOS");
|
||||
break;
|
||||
default:
|
||||
sprintf(text, "IOS%u", title);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Otherwise, just convert the title to ASCII
|
||||
int i =32, j = 0;
|
||||
do {
|
||||
u8 temp;
|
||||
i -= 8;
|
||||
temp = (title >> i) & 0x000000FF;
|
||||
if (temp < 32 || temp > 126)
|
||||
text[j] = '.';
|
||||
else
|
||||
text[j] = temp;
|
||||
j++;
|
||||
} while (i > 0);
|
||||
text[4] = 0;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------
|
||||
from any title deleter
|
||||
titles.c -- functions for grabbing all titles of a certain type
|
||||
|
||||
Copyright (C) 2008 tona
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
u32 __titles_init = 0;
|
||||
u32 __num_titles;
|
||||
static u64 __title_list[MAX_TITLES] ATTRIBUTE_ALIGN(32);
|
||||
|
||||
s32 __getTitles() {
|
||||
s32 ret;
|
||||
ret = ES_GetNumTitles(&__num_titles);
|
||||
if (ret <0)
|
||||
return ret;
|
||||
if (__num_titles > MAX_TITLES)
|
||||
return -1;
|
||||
ret = ES_GetTitles(__title_list, __num_titles);
|
||||
if (ret <0)
|
||||
return ret;
|
||||
__titles_init = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 getTitles_TypeCount(u32 type, u32 *count) {
|
||||
s32 ret = 0;
|
||||
u32 type_count;
|
||||
if (!__titles_init)
|
||||
ret = __getTitles();
|
||||
if (ret <0)
|
||||
return ret;
|
||||
int i;
|
||||
type_count = 0;
|
||||
for (i=0; i < __num_titles; i++) {
|
||||
u32 upper;
|
||||
upper = __title_list[i] >> 32;
|
||||
if(upper == type)
|
||||
type_count++;
|
||||
}
|
||||
*count = type_count;
|
||||
return ret;
|
||||
}
|
||||
|
||||
s32 getTitles_Type(u32 type, u32 *titles, u32 count) {
|
||||
s32 ret = 0;
|
||||
u32 type_count;
|
||||
if (!__titles_init)
|
||||
ret = __getTitles();
|
||||
if (ret <0)
|
||||
return ret;
|
||||
int i;
|
||||
type_count = 0;
|
||||
for (i=0; type_count < count && i < __num_titles; i++) {
|
||||
u32 upper, lower;
|
||||
upper = __title_list[i] >> 32;
|
||||
lower = __title_list[i] & 0xFFFFFFFF;
|
||||
if(upper == type) {
|
||||
titles[type_count]=lower;
|
||||
type_count++;
|
||||
}
|
||||
}
|
||||
if (type_count < count)
|
||||
return -2;
|
||||
__titles_init = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,25 @@
|
||||
/*-------------------------------------------------------------
|
||||
from any title deleter and wad manager 1.4
|
||||
title.h --
|
||||
|
||||
Copyright (C) 2008 tona and/or waninkoko
|
||||
-------------------------------------------------------------*/
|
||||
#include <gccore.h>
|
||||
#include <ogcsys.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <fat.h>
|
||||
#include <malloc.h>
|
||||
|
||||
// Turn upper and lower into a full title ID
|
||||
#define TITLE_ID(x,y) (((u64)(x) << 32) | (y))
|
||||
// Get upper or lower half of a title ID
|
||||
#define TITLE_UPPER(x) ((u32)((x) >> 32))
|
||||
// Turn upper and lower into a full title ID
|
||||
#define TITLE_LOWER(x) ((u32)(x))
|
||||
|
||||
#define MAX_TITLES 100
|
||||
|
||||
#ifndef _TITLE_H_
|
||||
#define _TITLE_H_
|
||||
|
||||
@ -16,6 +38,39 @@ s32 Title_GetVersion(u64, u16 *);
|
||||
s32 Title_GetSysVersion(u64, u64 *);
|
||||
s32 Title_GetSize(u64, u32 *);
|
||||
s32 Title_GetIOSVersions(u8 **, u32 *);
|
||||
|
||||
// Load the database from SD card
|
||||
s32 loadDatabase();
|
||||
|
||||
// Free the database on exit
|
||||
void freeDatabase();
|
||||
|
||||
// Get the number of entries in the database
|
||||
s32 getDatabaseCount();
|
||||
|
||||
// Get the name of a title
|
||||
s32 getTitle_Name(char *name, u64 id, char *tid);
|
||||
|
||||
// Get the name of a title from the database located on the SD card
|
||||
s32 getNameDB(char *name, char* id);
|
||||
|
||||
// Get the name of a title from its banner.bin in NAND
|
||||
s32 getNameBN(char *name, u64 id);
|
||||
|
||||
// Get the name of a title from its 00000000.app in NAND
|
||||
s32 getName00(char *name, u64 id);
|
||||
|
||||
// Get string representation of lower title id
|
||||
char *titleText(u32 kind, u32 title);
|
||||
|
||||
// Converts a 16 bit Wii string to a printable 8 bit string
|
||||
s32 __convertWiiString(char *str, u8 *data, u32 cnt);
|
||||
|
||||
// Get the number of titles on the Wii of a given type
|
||||
s32 getTitles_TypeCount(u32 type, u32 *count);
|
||||
|
||||
// Get the list of titles of this type
|
||||
s32 getTitles_Type(u32 type, u32 *titles, u32 count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user