mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-03 18:15:06 +01:00
7bccfd2b17
*Removed the console loading screen (no more console at all) *Complete rework of device handle. You need to reset all your custom paths for this rev. *Support for writing images/settings/... on any writable partition (FAT/NTFS/EXT). (Theoretically you can run the loader from NTFS only without the need of any other partition or SD if run from new forwarder channel, for example) *Support for Primary/Logical partitions and GUID Partition Table (GPT) Forwarder Channel in last revision was not using IOS58 (not sure about AHBPROT) Here a corrected version (thx to Cyan): http://www.mediafire.com/?a9y3ywqcm4v3lz3
132 lines
4.5 KiB
C++
132 lines
4.5 KiB
C++
#include <unistd.h>
|
|
|
|
#include "menus.h"
|
|
#include "usbloader/usbstorage2.h"
|
|
#include "usbloader/utils.h"
|
|
#include "usbloader/wbfs.h"
|
|
#include "libwiigui/gui_customoptionbrowser.h"
|
|
#include "Controls/DeviceHandler.hpp"
|
|
#include "themes/CTheme.h"
|
|
|
|
/****************************************************************************
|
|
* SelectPartitionMenu
|
|
***************************************************************************/
|
|
int SelectPartitionMenu()
|
|
{
|
|
bool ExitSelect = false;
|
|
OptionList options;
|
|
|
|
u32 counter = 0;
|
|
int choice = -1;
|
|
int ret = -1;
|
|
|
|
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
|
|
|
|
//create the partitionlist
|
|
for (int cnt = 0; cnt < usbHandle->GetPartitionCount(); cnt++)
|
|
{
|
|
/* Calculate size in gigabytes */
|
|
f32 size = usbHandle->GetSize(cnt) / GB_SIZE;
|
|
|
|
if (size)
|
|
{
|
|
options.SetName(counter, "%s %d %s: ", tr( "Partition" ), cnt + 1, usbHandle->GetFSName(cnt));
|
|
options.SetValue(counter, "%.2fGB", size);
|
|
}
|
|
else
|
|
{
|
|
options.SetName(counter, "%s %d:", tr( "Partition" ), cnt + 1);
|
|
options.SetValue(counter, tr( "Can't be formatted" ));
|
|
}
|
|
counter++;
|
|
}
|
|
|
|
GuiImageData btnpwroff(Resources::GetFile("wiimote_poweroff.png"), Resources::GetFileSize("wiimote_poweroff.png"));
|
|
GuiImageData btnpwroffOver(Resources::GetFile("wiimote_poweroff_over.png"), Resources::GetFileSize("wiimote_poweroff_over.png"));
|
|
GuiImageData btnhome(Resources::GetFile("menu_button.png"), Resources::GetFileSize("menu_button.png"));
|
|
GuiImageData btnhomeOver(Resources::GetFile("menu_button_over.png"), Resources::GetFileSize("menu_button_over.png"));
|
|
GuiImageData battery(Resources::GetFile("battery.png"), Resources::GetFileSize("battery.png"));
|
|
GuiImageData batteryBar(Resources::GetFile("battery_bar.png"), Resources::GetFileSize("battery_bar.png"));
|
|
GuiImageData batteryRed(Resources::GetFile("battery_red.png"), Resources::GetFileSize("battery_red.png"));
|
|
GuiImageData batteryBarRed(Resources::GetFile("battery_bar_red.png"), Resources::GetFileSize("battery_bar_red.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);
|
|
|
|
GuiImage poweroffBtnImg(&btnpwroff);
|
|
GuiImage poweroffBtnImgOver(&btnpwroffOver);
|
|
poweroffBtnImg.SetWidescreen(Settings.widescreen);
|
|
poweroffBtnImgOver.SetWidescreen(Settings.widescreen);
|
|
GuiButton poweroffBtn(&poweroffBtnImg, &poweroffBtnImgOver, 0, 3,
|
|
thInt("576 - power off btn pos x"), thInt("355 - power off btn pos y"),
|
|
&trigA, btnSoundOver, btnSoundClick2, 1);
|
|
GuiImage exitBtnImg(&btnhome);
|
|
GuiImage exitBtnImgOver(&btnhomeOver);
|
|
exitBtnImg.SetWidescreen(Settings.widescreen);
|
|
exitBtnImgOver.SetWidescreen(Settings.widescreen);
|
|
GuiButton exitBtn(&exitBtnImg, &exitBtnImgOver, 0, 3,
|
|
thInt("489 - home menu btn pos x"), thInt("371 - home menu btn pos y"),
|
|
&trigA, btnSoundOver, btnSoundClick2, 1);
|
|
exitBtn.SetTrigger(&trigHome);
|
|
|
|
GuiCustomOptionBrowser optionBrowser(396, 280, &options, "bg_options_settings.png");
|
|
optionBrowser.SetPosition(0, 40);
|
|
optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
|
|
|
HaltGui();
|
|
GuiWindow w(screenwidth, screenheight);
|
|
w.Append(&poweroffBtn);
|
|
w.Append(&exitBtn);
|
|
|
|
mainWindow->Append(&w);
|
|
mainWindow->Append(&optionBrowser);
|
|
|
|
ResumeGui();
|
|
|
|
while (!ExitSelect)
|
|
{
|
|
VIDEO_WaitVSync();
|
|
|
|
if (shutdown)
|
|
Sys_Shutdown();
|
|
if (reset)
|
|
Sys_Reboot();
|
|
|
|
ret = optionBrowser.GetClickedOption();
|
|
|
|
if (ret >= 0)
|
|
{
|
|
if (usbHandle->GetSize(ret))
|
|
{
|
|
choice = ret;
|
|
ExitSelect = true;
|
|
}
|
|
}
|
|
|
|
if (poweroffBtn.GetState() == STATE_CLICKED)
|
|
{
|
|
choice = WindowPrompt(tr( "Shutdown System" ), tr( "Are you sure?" ), tr( "Yes" ), tr( "No" ));
|
|
if (choice == 1)
|
|
Sys_Shutdown();
|
|
|
|
}
|
|
else if (exitBtn.GetState() == STATE_CLICKED)
|
|
{
|
|
choice = WindowPrompt(tr( "Return to Wii Menu" ), tr( "Are you sure?" ), tr( "Yes" ), tr( "No" ));
|
|
if (choice == 1)
|
|
Sys_LoadMenu();
|
|
}
|
|
}
|
|
|
|
HaltGui();
|
|
|
|
mainWindow->Remove(&optionBrowser);
|
|
mainWindow->Remove(&w);
|
|
ResumeGui();
|
|
|
|
return choice;
|
|
}
|
|
|