*Rewritten the whole Homebrew Launcher (HBC menu) to a class. Using now the new settings standard too. Only Titles browser left.

*Fixed several gui_customoptionbrowser issues
*Fixed missing background on title browser
This commit is contained in:
dimok321 2010-11-14 15:19:42 +00:00
parent fa11a745d6
commit 1ee6897ef5
25 changed files with 623 additions and 1241 deletions

File diff suppressed because one or more lines are too long

View File

@ -76,7 +76,7 @@ int CheatMenu(const char * gameID)
case 1:
int cntcheats = c.getCnt();
OptionList cheatslst;
GuiCustomOptionBrowser chtBrowser(400, 280, &cheatslst, "bg_options_settings.png", 1, 90);
GuiCustomOptionBrowser chtBrowser(400, 280, &cheatslst, "bg_options_settings.png");
chtBrowser.SetPosition(0, 90);
chtBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
chtBrowser.SetClickable(true);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,389 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include "HomebrewBrowser.hpp"
#include "themes/CTheme.h"
#include "prompts/PromptWindows.h"
#include "language/gettext.h"
#include "network/networkops.h"
#include "utils/minizip/miniunz.h"
#include "usbloader/utils.h"
#include "prompts/TitleBrowser.h"
#include "homebrewboot/BootHomebrew.h"
#include "prompts/ProgressWindow.h"
#include "wstring.hpp"
#include "HomebrewXML.h"
extern u32 infilesize;
extern u32 uncfilesize;
extern char wiiloadVersion[2];
HomebrewBrowser::HomebrewBrowser()
: FlyingButtonsMenu(tr( "Homebrew Launcher" ))
{
HomebrewList = new HomebrewFiles(Settings.homebrewapps_path);
if (IsNetworkInit())
ResumeNetworkWait();
wifiNotSet = true;
wifiImgData = Resources::GetImageData("Wifi_btn.png");
wifiToolTip = new GuiTooltip(" ");
wifiImg = new GuiImage(wifiImgData);
wifiBtn = new GuiButton(wifiImgData->GetWidth(), wifiImgData->GetHeight());
wifiBtn->SetImage(wifiImg);
wifiBtn->SetPosition(300, 400);
wifiBtn->SetSoundOver(btnSoundOver);
wifiBtn->SetSoundClick(btnSoundClick);
wifiBtn->SetEffectGrow();
wifiBtn->SetAlpha(80);
wifiBtn->SetTrigger(trigA);
Append(wifiBtn);
channelImgData = Resources::GetImageData("Channel_btn.png");
channelBtnImg = new GuiImage(channelImgData);
channelBtnImg->SetWidescreen(Settings.widescreen);
channelBtn = new GuiButton(channelBtnImg->GetWidth(), channelBtnImg->GetHeight());
channelBtn->SetPosition(240, 400);
channelBtn->SetImage(channelBtnImg);
channelBtn->SetSoundOver(btnSoundOver);
channelBtn->SetSoundClick(btnSoundClick2);
channelBtn->SetEffectGrow();
channelBtn->SetTrigger(trigA);
Append(channelBtn);
MainButtonDesc.resize(HomebrewList->GetFilecount());
MainButtonDescOver.resize(HomebrewList->GetFilecount());
for(u32 i = 0; i < 4; ++i)
{
IconImgData[i] = NULL;
IconImg[i] = NULL;
}
for(int i = 0; i < HomebrewList->GetFilecount(); ++i)
{
MainButtonDesc[i] = new GuiText((char *) NULL, 18, (GXColor) {0, 0, 0, 255});
MainButtonDesc[i]->SetMaxWidth(MainButtonImgData->GetWidth() - 150, DOTTED);
MainButtonDesc[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButtonDesc[i]->SetPosition(148, 15);
MainButtonDescOver[i] = new GuiText((char *) NULL, 18, (GXColor) {0, 0, 0, 255});
MainButtonDescOver[i]->SetMaxWidth(MainButtonImgData->GetWidth() - 150, SCROLL_HORIZONTAL);
MainButtonDescOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButtonDescOver[i]->SetPosition(148, 15);
}
SetupMainButtons();
}
HomebrewBrowser::~HomebrewBrowser()
{
HaltGui();
delete HomebrewList;
Remove(wifiBtn);
delete wifiImgData;
delete wifiImg;
delete wifiToolTip;
delete wifiBtn;
Remove(channelBtn);
delete channelImgData;
delete channelBtnImg;
delete channelBtn;
for(u32 i = 0; i < MainButtonDesc.size(); ++i)
{
delete MainButtonDesc[i];
delete MainButtonDescOver[i];
MainButton[i]->SetLabel(NULL, 1);
MainButton[i]->SetLabelOver(NULL, 1);
}
if (IsNetworkInit())
HaltNetworkThread();
}
void HomebrewBrowser::AddMainButtons()
{
HaltGui();
for(u32 i = 0; i < 4; ++i)
{
if(IconImgData[i])
delete IconImgData[i];
if(IconImg[i])
delete IconImg[i];
IconImgData[i] = NULL;
IconImg[i] = NULL;
}
for(u32 i = 0; i < MainButton.size(); ++i)
MainButton[i]->SetIcon(NULL);
char iconpath[200];
int FirstItem = currentPage*DISPLAY_BUTTONS;
for(int i = FirstItem, n = 0; i < (int) MainButton.size() && i < FirstItem+DISPLAY_BUTTONS; ++i, ++n)
{
snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewList->GetFilepath(i));
IconImgData[n] = new GuiImageData(iconpath);
IconImg[n] = new GuiImage(IconImgData[n]);
IconImg[n]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
IconImg[n]->SetPosition(12, 0);
IconImg[n]->SetScale(0.95);
MainButton[i]->SetIcon(IconImg[n]);
}
FlyingButtonsMenu::AddMainButtons();
}
void HomebrewBrowser::SetupMainButtons()
{
HomebrewXML MetaXML;
char metapath[200];
for(int i = 0; i < HomebrewList->GetFilecount(); ++i)
{
const char * HomebrewName = NULL;
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewList->GetFilepath(i));
if (MetaXML.LoadHomebrewXMLData(metapath) > 0)
{
HomebrewName = MetaXML.GetName();
MainButtonDesc[i]->SetText(MetaXML.GetShortDescription());
MainButtonDescOver[i]->SetText(MetaXML.GetShortDescription());
}
else
{
const char * shortpath = strrchr(HomebrewList->GetFilename(i), '/');
if(shortpath)
{
snprintf(metapath, sizeof(metapath), "%s/%s", shortpath, HomebrewList->GetFilename(i));
HomebrewName = metapath;
}
else
HomebrewName = HomebrewList->GetFilename(i);
MainButtonDesc[i]->SetText(" ");
MainButtonDescOver[i]->SetText(" ");
}
SetMainButton(i, HomebrewName, MainButtonImgData, MainButtonImgOverData);
MainButtonTxt[i]->SetFontSize(18);
MainButtonTxt[i]->SetMaxWidth(MainButtonImgData->GetWidth() - 150, DOTTED);
MainButtonTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButtonTxt[i]->SetPosition(148, -12);
MainButton[i]->SetLabel(MainButtonDesc[i], 1);
MainButton[i]->SetLabelOver(MainButtonDescOver[i], 1);
}
}
int HomebrewBrowser::MainLoop()
{
if (IsNetworkInit() && wifiNotSet)
{
wifiToolTip->SetText(GetNetworkIP());
wifiBtn->SetAlpha(255);
wifiBtn->SetToolTip(wifiToolTip, 0, -50, 0, 5);
wifiNotSet = false;
}
if(wifiBtn->GetState() == STATE_CLICKED)
{
ResumeNetworkWait();
wifiBtn->ResetState();
}
else if(channelBtn->GetState() == STATE_CLICKED)
{
SetState(STATE_DISABLED);
TitleBrowser();
SetState(STATE_DEFAULT);
channelBtn->ResetState();
}
else if (infilesize > 0)
{
int menu = ReceiveFile();
if(menu != MENU_NONE)
return menu;
CloseConnection();
ResumeNetworkWait();
}
return FlyingButtonsMenu::MainLoop();
}
//! Callback for MainButton clicked
void HomebrewBrowser::MainButtonClicked(int button)
{
HomebrewXML MetaXML;
char metapath[200];
snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewList->GetFilepath(button));
MetaXML.LoadHomebrewXMLData(metapath);
u64 filesize = HomebrewList->GetFilesize(button);
wString HomebrewName(MainButtonTxt[button]->GetText());
int choice = HBCWindowPrompt(HomebrewName.toUTF8().c_str(), MetaXML.GetCoder(), MetaXML.GetVersion(),
MetaXML.GetReleasedate(), MetaXML.GetLongDescription(), IconImgData[button % 4], filesize);
if (choice == 1)
{
char homebrewpath[200];
snprintf(homebrewpath, sizeof(homebrewpath), "%s%s", HomebrewList->GetFilepath(button), HomebrewList->GetFilename(button));
BootHomebrew(homebrewpath);
}
}
int HomebrewBrowser::ReceiveFile()
{
char filesizetxt[50];
char temp[50];
u32 filesize = 0;
if (infilesize < MB_SIZE)
snprintf(filesizetxt, sizeof(filesizetxt), tr( "Incoming file %0.2fKB" ), infilesize / KB_SIZE);
else snprintf(filesizetxt, sizeof(filesizetxt), tr( "Incoming file %0.2fMB" ), infilesize / MB_SIZE);
snprintf(temp, sizeof(temp), tr( "Load file from: %s ?" ), GetIncommingIP());
int choice = WindowPrompt(filesizetxt, temp, tr( "OK" ), tr( "Cancel" ));
if (choice == 0)
return MENU_NONE;
u32 read = 0;
int len = NETWORKBLOCKSIZE;
filesize = infilesize;
u8 * buffer = (u8 *) malloc(infilesize);
if(!buffer)
{
WindowPrompt(tr( "Not enough memory." ), 0, tr( "OK" ));
return MENU_NONE;
}
bool error = false;
while (read < infilesize)
{
ShowProgress(tr( "Receiving file from:" ), GetIncommingIP(), NULL, read, infilesize, true);
if (infilesize - read < (u32) len)
len = infilesize - read;
else len = NETWORKBLOCKSIZE;
int result = network_read(buffer+read, len);
if (result < 0)
{
WindowPrompt(tr( "Error while transfering data." ), 0, tr( "OK" ));
free(buffer);
return MENU_NONE;
}
if (!result)
{
break;
}
read += result;
}
char filename[101];
network_read((u8*) &filename, 100);
// Do we need to unzip this thing?
if (wiiloadVersion[0] > 0 || wiiloadVersion[1] > 4)
{
// We need to unzip...
if (buffer[0] == 'P' && buffer[1] == 'K' && buffer[2] == 0x03 && buffer[3] == 0x04)
{
// It's a zip file, unzip to the apps directory
// Zip archive, ask for permission to install the zip
char zippath[255];
sprintf((char *) &zippath, "%s%s", Settings.homebrewapps_path, filename);
FILE *fp = fopen(zippath, "wb");
if (!fp)
{
WindowPrompt(tr( "Error writing the data." ), 0, tr( "OK" ));
return MENU_NONE;
}
fwrite(buffer, 1, infilesize, fp);
fclose(fp);
free(buffer);
buffer = NULL;
// Now unzip the zip file...
unzFile uf = unzOpen(zippath);
if (uf == NULL)
{
WindowPrompt(tr( "Error while opening the zip." ), 0, tr( "OK" ));
return MENU_NONE;
}
extractZip(uf, 0, 1, 0, Settings.homebrewapps_path);
unzCloseCurrentFile(uf);
remove(zippath);
WindowPrompt(tr( "Success:" ),
tr( "Uploaded ZIP file installed to homebrew directory." ), tr( "OK" ));
// Reload this menu here...
return MENU_HOMEBREWBROWSE;
}
else if (uncfilesize != 0) // if uncfilesize == 0, it's not compressed
{
// It's compressed, uncompress
u8 *unc = (u8 *) malloc(uncfilesize);
uLongf f = uncfilesize;
error = uncompress(unc, &f, buffer, infilesize) != Z_OK;
uncfilesize = f;
filesize = uncfilesize;
free(buffer);
buffer = unc;
}
}
CopyHomebrewMemory(buffer, 0, filesize);
free(buffer);
ProgressStop();
if (error || read != infilesize || strcasestr(filename, ".dol") || strcasestr(filename, ".elf"))
{
WindowPrompt(tr( "Error:" ), tr( "No data could be read." ), tr( "OK" ));
FreeHomebrewBuffer();
return MENU_NONE;
}
CloseConnection();
AddBootArgument(filename);
return BootHomebrewFromMem();
}

View File

@ -0,0 +1,63 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef HOMEBREWBROWSER_HPP_
#define HOMEBREWBROWSER_HPP_
#include "settings/menus/FlyingButtonsMenu.hpp"
#include "HomebrewFiles.h"
#define DISPLAY_BUTTONS 4
class HomebrewBrowser : public FlyingButtonsMenu
{
public:
HomebrewBrowser();
~HomebrewBrowser();
virtual int MainLoop();
protected:
void MainButtonClicked(int index);
int ReceiveFile();
virtual void CreateSettingsMenu(int index) { MainButtonClicked(index); };
virtual void DeleteSettingsMenu() { };
virtual void SetupMainButtons();
virtual void AddMainButtons();
HomebrewFiles * HomebrewList;
GuiImageData * IconImgData[DISPLAY_BUTTONS];
GuiImage * IconImg[DISPLAY_BUTTONS];
std::vector<GuiText *> MainButtonDesc;
std::vector<GuiText *> MainButtonDescOver;
bool wifiNotSet;
GuiTooltip * wifiToolTip;
GuiImageData * wifiImgData;
GuiImage * wifiImg;
GuiButton * wifiBtn;
GuiImageData * channelImgData;
GuiImage * channelBtnImg;
GuiButton * channelBtn;
};
#endif

View File

@ -115,11 +115,6 @@ unsigned int HomebrewFiles::GetFilesize(int ind)
else return FileInfo[ind].FileSize;
}
int HomebrewFiles::GetFilecount()
{
return filecount;
}
static int ListCompare(const void *a, const void *b)
{
FileInfos *ab = (FileInfos*) a;

View File

@ -35,7 +35,7 @@ class HomebrewFiles
//!\param list index
unsigned int GetFilesize(int index);
//! Get the filecount of the whole list
int GetFilecount();
int GetFilecount() { return filecount; };
//! Sort list by filepath
void SortList();
protected:

View File

@ -13,16 +13,6 @@
#define ENTRIE_SIZE 8192
/* Initializes a new instance of the HomebrewXML class. */
HomebrewXML::HomebrewXML()
{
}
/* Finalizes an instance of the HomebrewXML class. */
HomebrewXML::~HomebrewXML()
{
}
/* qparam filename Filepath of the XML file */
int HomebrewXML::LoadHomebrewXMLData(const char* filename)
{

View File

@ -10,8 +10,8 @@
class HomebrewXML
{
public:
HomebrewXML();
~HomebrewXML();
HomebrewXML() { };
HomebrewXML(const char* filename) { LoadHomebrewXMLData(filename); };
int LoadHomebrewXMLData(const char* filename);

View File

@ -22,17 +22,17 @@
/**
* Constructor for the GuiCustomOptionBrowser class.
*/
GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, OptionList * l, const char * custombg, int scrollon, int col2)
GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, OptionList * l, const char * custombg)
{
width = w;
height = h;
options = l;
scrollbaron = scrollon;
selectable = true;
listOffset = this->FindMenuItem(-1, 1);
selectedItem = 0;
focus = 1; // allow focus
coL2 = col2;
coL2 = 50;
scrollbaron = false;
listOffset = 0;
trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
@ -105,17 +105,17 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, OptionList * l, con
for (int i = 0; i < PAGESIZE; i++)
{
optionTxt[i] = new GuiText(options->GetName(i), 20, Theme.settingstext);
optionTxt[i] = new GuiText((wchar_t *) NULL, 20, Theme.settingstext);
optionTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
optionTxt[i]->SetPosition(24, 0);
optionTxt[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2 + 24), DOTTED);
optionBg[i] = new GuiImage(bgOptionsEntry);
optionVal[i] = new GuiText((char *) NULL, 20, Theme.settingstext);
optionVal[i] = new GuiText((wchar_t *) NULL, 20, Theme.settingstext);
optionVal[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
optionValOver[i] = new GuiText((char *) NULL, 20, Theme.settingstext);
optionValOver[i] = new GuiText((wchar_t *) NULL, 20, Theme.settingstext);
optionValOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
optionBtn[i] = new GuiButton(width - 28, GAMESELECTSIZE);
@ -128,9 +128,7 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, OptionList * l, con
optionBtn[i]->SetRumble(false);
optionBtn[i]->SetTrigger(trigA);
optionBtn[i]->SetSoundClick(btnSoundClick);
}
UpdateListEntries();
}
/**
@ -199,31 +197,28 @@ void GuiCustomOptionBrowser::ResetState()
int GuiCustomOptionBrowser::GetClickedOption()
{
int found = -1;
for (int i = 0; i < PAGESIZE; i++)
{
if (optionBtn[i]->GetState() == STATE_CLICKED)
{
optionBtn[i]->SetState(STATE_SELECTED);
found = optionIndex[i];
break;
return optionIndex[i];
}
}
return found;
return -1;
}
int GuiCustomOptionBrowser::GetSelectedOption()
{
int found = -1;
for (int i = 0; i < PAGESIZE; i++)
{
if (optionBtn[i]->GetState() == STATE_SELECTED)
{
found = optionIndex[i];
break;
return optionIndex[i];
}
}
return found;
return -1;
}
void GuiCustomOptionBrowser::SetClickable(bool enable)
@ -234,11 +229,6 @@ void GuiCustomOptionBrowser::SetClickable(bool enable)
}
}
void GuiCustomOptionBrowser::SetScrollbar(int enable)
{
scrollbaron = enable;
}
void GuiCustomOptionBrowser::SetOffset(int optionnumber)
{
listOffset = optionnumber;
@ -259,7 +249,8 @@ int GuiCustomOptionBrowser::FindMenuItem(int currentItem, int direction)
if (strlen(options->GetName(nextItem)) > 0)
return nextItem;
else return FindMenuItem(nextItem, direction);
return FindMenuItem(nextItem, direction);
}
/**
@ -283,7 +274,7 @@ void GuiCustomOptionBrowser::Draw()
else break;
}
if (scrollbaron == 1)
if (PAGESIZE < options->GetLength())
{
scrollbarImg->Draw();
arrowUpBtn->Draw();
@ -295,6 +286,7 @@ void GuiCustomOptionBrowser::Draw()
void GuiCustomOptionBrowser::UpdateListEntries()
{
LOCK(this);
scrollbaron = options->GetLength() > PAGESIZE;
if (listOffset < 0) listOffset = this->FindMenuItem(-1, 1);
int next = listOffset;
@ -324,7 +316,10 @@ void GuiCustomOptionBrowser::UpdateListEntries()
optionBtn[i]->SetState(STATE_DISABLED);
}
}
if (coL2 < (24 + maxNameWidth + 16)) coL2 = 24 + maxNameWidth + 16;
if (coL2 < (24 + maxNameWidth + 16))
coL2 = 24 + maxNameWidth + 16;
for (int i = 0; i < PAGESIZE; i++)
{
if (optionBtn[i]->GetState() != STATE_DISABLED)
@ -340,18 +335,12 @@ void GuiCustomOptionBrowser::UpdateListEntries()
void GuiCustomOptionBrowser::Update(GuiTrigger * t)
{
int next, prev, lang = options->GetLength();
if (state == STATE_DISABLED || !t) return;
if (options->IsChanged())
{
coL2 = 0;
UpdateListEntries();
}
int next, prev, length = options->GetLength();
int old_listOffset = listOffset;
if (scrollbaron == 1)
if (length < PAGESIZE)
{
// update the location of the scroll box based on the position in the option list
arrowUpBtn->Update(t);
@ -359,11 +348,14 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
scrollbarBoxBtn->Update(t);
}
if(options->IsChanged())
UpdateListEntries();
next = listOffset;
u32 buttonshold = ButtonsHold();
if (buttonshold != WPAD_BUTTON_UP && buttonshold != WPAD_BUTTON_DOWN)
if (!(t->wpad.btns_h & WPAD_BUTTON_UP || t->wpad.btns_h & WPAD_BUTTON_DOWN ||
t->wpad.btns_h & WPAD_CLASSIC_BUTTON_UP || t->wpad.btns_h & WPAD_CLASSIC_BUTTON_DOWN ||
t->pad.btns_h & PAD_BUTTON_UP || t->pad.btns_h & PAD_BUTTON_DOWN))
{
for (int i = 0; i < PAGESIZE; i++)
{
@ -432,104 +424,106 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
}
}
if (scrollbaron == 1)
if (!scrollbaron)
return;
if (arrowDownBtn->GetState() == STATE_CLICKED || arrowDownBtn->GetState() == STATE_HELD)
{
if (arrowDownBtn->GetState() == STATE_CLICKED || arrowDownBtn->GetState() == STATE_HELD)
next = this->FindMenuItem(optionIndex[selectedItem], 1);
if (next >= 0)
{
next = this->FindMenuItem(optionIndex[selectedItem], 1);
if (next >= 0)
if (selectedItem == PAGESIZE - 1)
{
if (selectedItem == PAGESIZE - 1)
{
// move list down by 1
listOffset = this->FindMenuItem(listOffset, 1);
}
else if (optionBtn[selectedItem + 1]->IsVisible())
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem + 1]->SetState(STATE_SELECTED, t->chan);
selectedItem++;
}
scrollbarBoxBtn->Draw();
usleep(35000);
// move list down by 1
listOffset = this->FindMenuItem(listOffset, 1);
}
if (buttonshold != WPAD_BUTTON_A)
else if (optionBtn[selectedItem + 1]->IsVisible())
{
arrowDownBtn->ResetState();
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem + 1]->SetState(STATE_SELECTED, t->chan);
selectedItem++;
}
scrollbarBoxBtn->Draw();
usleep(35000);
}
else if (arrowUpBtn->GetState() == STATE_CLICKED || arrowUpBtn->GetState() == STATE_HELD)
if (!(t->wpad.btns_h & WPAD_BUTTON_A || t->wpad.btns_h & WPAD_CLASSIC_BUTTON_A ||
t->pad.btns_h & PAD_BUTTON_A))
{
prev = this->FindMenuItem(optionIndex[selectedItem], -1);
if (prev >= 0)
{
if (selectedItem == 0)
{
// move list up by 1
listOffset = prev;
}
else
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem - 1]->SetState(STATE_SELECTED, t->chan);
selectedItem--;
}
scrollbarBoxBtn->Draw();
usleep(35000);
}
if (buttonshold != WPAD_BUTTON_A)
{
arrowUpBtn->ResetState();
}
arrowDownBtn->ResetState();
}
}
else if (arrowUpBtn->GetState() == STATE_CLICKED || arrowUpBtn->GetState() == STATE_HELD)
{
prev = this->FindMenuItem(optionIndex[selectedItem], -1);
if (scrollbarBoxBtn->GetState() == STATE_HELD && scrollbarBoxBtn->GetStateChan() == t->chan && t->wpad.ir.valid
&& options->GetLength() > PAGESIZE)
if (prev >= 0)
{
scrollbarBoxBtn->SetPosition(width / 2 - 18 + 7, 0);
int position = t->wpad.ir.y - 50 - scrollbarBoxBtn->GetTop();
listOffset = (position * lang) / 180 - selectedItem;
if (listOffset <= 0)
if (selectedItem == 0)
{
listOffset = 0;
selectedItem = 0;
// move list up by 1
listOffset = prev;
}
else if (listOffset + PAGESIZE >= lang)
else
{
listOffset = lang - PAGESIZE;
selectedItem = PAGESIZE - 1;
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem - 1]->SetState(STATE_SELECTED, t->chan);
selectedItem--;
}
scrollbarBoxBtn->Draw();
usleep(35000);
}
int positionbar = 237 * (listOffset + selectedItem) / lang;
if (positionbar > 216) positionbar = 216;
scrollbarBoxBtn->SetPosition(width / 2 - 18 + 7, positionbar + 8);
if (t->Right())
if (!(t->wpad.btns_h & WPAD_BUTTON_A || t->wpad.btns_h & WPAD_CLASSIC_BUTTON_A ||
t->pad.btns_h & PAD_BUTTON_A))
{
if (listOffset < lang && lang > PAGESIZE)
{
listOffset = listOffset + PAGESIZE;
if (listOffset + PAGESIZE >= lang) listOffset = lang - PAGESIZE;
}
}
else if (t->Left())
{
if (listOffset > 0)
{
listOffset = listOffset - PAGESIZE;
if (listOffset < 0) listOffset = 0;
}
arrowUpBtn->ResetState();
}
}
if (old_listOffset != listOffset) UpdateListEntries();
if (scrollbarBoxBtn->GetState() == STATE_HELD && scrollbarBoxBtn->GetStateChan() == t->chan && t->wpad.ir.valid
&& options->GetLength() > PAGESIZE)
{
scrollbarBoxBtn->SetPosition(width / 2 - 18 + 7, 0);
int position = t->wpad.ir.y - 50 - scrollbarBoxBtn->GetTop();
listOffset = (position * length) / 180 - selectedItem;
if (listOffset <= 0)
{
listOffset = 0;
selectedItem = 0;
}
else if (listOffset + PAGESIZE >= length)
{
listOffset = length - PAGESIZE;
selectedItem = PAGESIZE - 1;
}
}
int positionbar = 237 * (listOffset + selectedItem) / length;
if (positionbar > 216) positionbar = 216;
scrollbarBoxBtn->SetPosition(width / 2 - 18 + 7, positionbar + 8);
if (t->Right())
{
if (listOffset < length && length > PAGESIZE)
{
listOffset = listOffset + PAGESIZE;
if (listOffset + PAGESIZE >= length) listOffset = length - PAGESIZE;
}
}
else if (t->Left())
{
if (listOffset > 0)
{
listOffset = listOffset - PAGESIZE;
if (listOffset < 0) listOffset = 0;
}
}
if (old_listOffset != listOffset)
UpdateListEntries();
if (updateCB) updateCB(this);
}

View File

@ -8,13 +8,12 @@
class GuiCustomOptionBrowser: public GuiElement
{
public:
GuiCustomOptionBrowser(int w, int h, OptionList * l, const char * background, int scrollbar, int col2);
GuiCustomOptionBrowser(int w, int h, OptionList * l, const char * background);
~GuiCustomOptionBrowser();
int FindMenuItem(int c, int d);
int GetClickedOption();
int GetSelectedOption();
void SetClickable(bool enable);
void SetScrollbar(int enable);
void SetOffset(int optionnumber);
void ResetState();
void SetFocus(int f);
@ -25,7 +24,7 @@ class GuiCustomOptionBrowser: public GuiElement
int selectedItem;
int listOffset;
int coL2;
int scrollbaron;
bool scrollbaron;
OptionList * options;
int optionIndex[PAGESIZE];

View File

@ -97,7 +97,7 @@ void HaltGui()
// wait for thread to finish
while (!LWP_ThreadIsSuspended(guithread))
usleep(50);
usleep(100);
}
/****************************************************************************

View File

@ -71,7 +71,7 @@ int SelectPartitionMenu()
1);
exitBtn.SetTrigger(&trigHome);
GuiCustomOptionBrowser optionBrowser(396, 280, &options, "bg_options_settings.png", 0, 10);
GuiCustomOptionBrowser optionBrowser(396, 280, &options, "bg_options_settings.png");
optionBrowser.SetPosition(0, 40);
optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);

View File

@ -132,10 +132,7 @@ int DiscBrowse(const char * GameID, char * alternatedname, int alternatedname_si
cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB);
u8 scrollbaron = 0;
if (dolfilecount > 9) scrollbaron = 1;
GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, "bg_options_gamesettings.png", dolfilecount > 9 ? 1 : 0, 200);
GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, "bg_options_gamesettings.png");
optionBrowser3.SetPosition(0, 90);
optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);

View File

@ -422,7 +422,7 @@ void WindowCredits()
creditsWindow.SetEffect(EFFECT_FADE, -30);
while (creditsWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&creditsWindow);
mainWindow->SetState(STATE_DEFAULT);
@ -766,7 +766,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
@ -1068,16 +1068,16 @@ int WindowExitPrompt()
}
homeout->Play();
while (btn1.GetEffect() > 0)
usleep(50);
usleep(100);
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
homein->Stop();
delete homein;
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
while (homeout->IsPlaying() > 0)
usleep(50);
usleep(100);
homeout->Stop();
delete homeout;
ResumeGui();
@ -1415,7 +1415,7 @@ int GameWindowPrompt()
nameTxt.SetEffect(EFFECT_FADE, -17);
ResumeGui();
while (nameTxt.GetEffect() > 0 || diskImg.GetBetaRotateEffect())
usleep(50);
usleep(100);
HaltGui();
diskImg.SetImage(diskCover);
diskImg.SetBeta(90);
@ -1439,7 +1439,7 @@ int GameWindowPrompt()
nameTxt.SetEffect(EFFECT_FADE, -17);
ResumeGui();
while (nameTxt.GetEffect() > 0 || diskImg.GetBetaRotateEffect())
usleep(50);
usleep(100);
HaltGui();
diskImg.SetImage(diskCover);
diskImg.SetBeta(270);
@ -1486,7 +1486,7 @@ int GameWindowPrompt()
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
mainWindow->SetState(STATE_DEFAULT);
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
ResumeGui();
@ -1696,7 +1696,7 @@ int GameWindowPrompt()
}
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
if (changed != 3 && changed != 4) // changed==3 or changed==4 --> only Halt the GUI
{
@ -1853,7 +1853,7 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
@ -1927,7 +1927,7 @@ int FormatingPartition(const char *title, partitionEntry *entry)
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
@ -2035,7 +2035,7 @@ bool SearchMissingImages(int choice2)
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
@ -2148,7 +2148,7 @@ bool NetworkInitPrompt()
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
@ -3112,7 +3112,7 @@ int ProgressUpdateWindow()
}
// promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
//while(promptWindow.GetEffect() > 0) usleep(50);
//while(promptWindow.GetEffect() > 0) usleep(100);
HaltGui();
//mainWindow->Remove(&promptWindow);
@ -3503,7 +3503,7 @@ int ProgressUpdateWindow()
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
@ -3657,7 +3657,7 @@ int CodeDownload(const char *id)
}
exit: promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
@ -3679,16 +3679,8 @@ char * GetMissingFiles()
* presenting a user with a choice of up to 2 Buttons.
*
***************************************************************************/
/* <name>
<coder>
<version>
<release_date>
<short_description>
<long_description>
SD:/APPS/FTPII/ICON.PNG*/
int HBCWindowPrompt(const char *name, const char *coder, const char *version, const char *release_date,
const char *long_description, const char *iconPath, u64 filesize)
const char *long_description, GuiImageData * iconImgData, u64 filesize)
{
int choice = -1;
@ -3741,21 +3733,9 @@ int HBCWindowPrompt(const char *name, const char *coder, const char *version, co
arrowDownBtn.SetEffectOnOver(EFFECT_SCALE, 50, 130);
arrowDownBtn.SetSoundClick(btnSoundClick2);
GuiImageData *iconData = NULL;
GuiImage *iconImg = NULL;
char imgPath[150];
snprintf(imgPath, sizeof(imgPath), "%s", iconPath);
bool iconExist = CheckFile(imgPath);
if (iconExist)
{
//! This does not crash even if there is no file
iconData = new GuiImageData(imgPath);
iconImg = new GuiImage(iconData);
iconImg->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
iconImg->SetPosition(45, 10);
}
GuiImage *iconImg = new GuiImage(iconImgData);
iconImg->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
iconImg->SetPosition(45, 10);
GuiImage dialogBoxImg(&dialogBox);
dialogBoxImg.SetSkew(0, -80, 0, -80, 0, 50, 0, 50);
@ -3910,11 +3890,14 @@ int HBCWindowPrompt(const char *name, const char *coder, const char *version, co
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
ResumeGui();
delete iconImg;
return choice;
}

View File

@ -8,6 +8,7 @@
#ifndef _PROMPTWINDOWS_H_
#define _PROMPTWINDOWS_H_
#include "libwiigui/gui.h"
#include "usbloader/partition_usbloader.h"
int WindowPrompt(const char *title, const char *msg = NULL, const char * btn1Label = NULL, const char * btn2Label =
@ -28,6 +29,6 @@ char * GetMissingFiles();
int WindowScreensaver();
int CodeDownload(const char *id);
int HBCWindowPrompt(const char *name, const char *coder, const char *version, const char *release_date,
const char *long_description, const char *iconPath, u64 filesize);
const char *long_description, GuiImageData * iconImgData, u64 filesize);
#endif

View File

@ -150,10 +150,7 @@ bool TitleSelector(char output[])
cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB);
u8 scrollbaron = 0;
if (num_titles + 1 > 9) scrollbaron = 1;
GuiCustomOptionBrowser optionBrowser4(396, 280, &options4, "bg_options_settings.png", scrollbaron, 200);
GuiCustomOptionBrowser optionBrowser4(396, 280, &options4, "bg_options_settings.png");
optionBrowser4.SetPosition(0, 90);
optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@ -381,10 +378,7 @@ int TitleBrowser()
cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB);
u8 scrollbaron = 0;
if (total + 1 > 9) scrollbaron = 1;
GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, "bg_options_gamesettings.png", scrollbaron, 200);
GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, "bg_options_settings.png");
optionBrowser3.SetPosition(0, 90);
optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);

View File

@ -963,7 +963,7 @@ int showGameInfo(char *ID)
{
gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100);
while (gameinfoWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&gameinfoWindow);
mainWindow->SetState(STATE_DEFAULT);
@ -1045,7 +1045,7 @@ int showGameInfo(char *ID)
{
gameinfoWindow2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100);
while (gameinfoWindow2.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&gameinfoWindow2);
mainWindow->SetState(STATE_DEFAULT);

View File

@ -91,7 +91,6 @@ class CSettings
char dolpath[150];
char update_path[150];
char homebrewapps_path[150];
char selected_homebrew[200];
char Cheatcodespath[100];
char TxtCheatcodespath[100];
char BcaCodepath[100];

View File

@ -204,7 +204,7 @@ int MenuLanguageSelect()
scrollon = 1;
}
GuiCustomOptionBrowser optionBrowser4( 396, 280, &options2, "bg_options_settings.png", scrollon, 10 );
GuiCustomOptionBrowser optionBrowser4( 396, 280, &options2, "bg_options_settings.png");
optionBrowser4.SetPosition( 0, 90 );
optionBrowser4.SetAlignment( ALIGN_CENTRE, ALIGN_TOP );

View File

@ -265,6 +265,7 @@ void FlyingButtonsMenu::ShowMenu()
titleTxt = new GuiText(MenuTitle.c_str(), 28, ( GXColor ) {0, 0, 0, 255});
titleTxt->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt->SetPosition(0, 40);
titleTxt->SetMaxWidth(310, SCROLL_HORIZONTAL);
Append(titleTxt);
GoLeftImg = new GuiImage(arrow_left);

View File

@ -35,18 +35,18 @@ class FlyingButtonsMenu : public GuiWindow
public:
FlyingButtonsMenu(const char * menu_title);
~FlyingButtonsMenu();
int MainLoop();
void HideMenu();
void ShowMenu();
virtual int MainLoop();
virtual void HideMenu();
virtual void ShowMenu();
protected:
virtual void CreateSettingsMenu(int index) { };
virtual void DeleteSettingsMenu() { };
virtual void SetupMainButtons() { };
void AddMainButtons();
void ShowButtonsEffects(int effect, int effect_speed);
void SlideButtons(int slide_direction);
void SetPageIndicators();
void SetMainButton(int position, const char * ButtonText, GuiImageData * imageData, GuiImageData * imageOver);
virtual void AddMainButtons();
virtual void ShowButtonsEffects(int effect, int effect_speed);
virtual void SlideButtons(int slide_direction);
virtual void SetPageIndicators();
virtual void SetMainButton(int position, const char * ButtonText, GuiImageData * imageData, GuiImageData * imageOver);
int currentPage;
int returnMenu;

View File

@ -58,13 +58,14 @@ SettingsMenu::SettingsMenu(const char * title, OptionList * opts, int returnTo)
Append(backBtn);
}
optionBrowser = new GuiCustomOptionBrowser(396, 280, Options, "bg_options_settings.png", 0, 150);
optionBrowser = new GuiCustomOptionBrowser(396, 280, Options, "bg_options_settings.png");
optionBrowser->SetPosition(0, 90);
optionBrowser->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt = new GuiText(title, 28, (GXColor) {0, 0, 0, 255});
titleTxt->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt->SetPosition(0, 40);
titleTxt->SetMaxWidth(310, SCROLL_HORIZONTAL);
Append(optionBrowser);
Append(titleTxt);

View File

@ -171,6 +171,7 @@ RecourceFile Resources::RecourceFiles[] =
{"lock_gray.png", lock_gray_png, lock_gray_png_size, NULL, 0},
{"unlock.png", unlock_png, unlock_png_size, NULL, 0},
{"unlock_gray.png", unlock_gray_png, unlock_gray_png_size, NULL, 0},
{"Channel_btn.png", Channel_btn_png, Channel_btn_png_size, NULL, 0},
{NULL, NULL, 0, NULL, 0}
};

View File

@ -253,7 +253,7 @@ static int Theme_Prompt(const char *title, const char *author, GuiImageData *thu
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0)
usleep(50);
usleep(100);
HaltGui();
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
@ -576,7 +576,7 @@ int Theme_Downloader()
currentpage--;
if (currenttheme < 0)
{
currentpage = roundup((ThemesOnPage + 1.0f) / pagesize);
currentpage = ceil((ThemesOnPage + 1.0f) / pagesize);
currenttheme = currentpage * pagesize - pagesize;
}
GoLeftBtn.ResetState();