2009-11-02 23:15:28 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Theme_Downloader
|
|
|
|
* USB Loader GX 2009
|
|
|
|
*
|
|
|
|
* Theme downloader for USB Loader GX
|
|
|
|
*
|
|
|
|
* Theme_Downloader.cpp
|
|
|
|
***************************************************************************/
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "language/gettext.h"
|
|
|
|
#include "libwiigui/gui.h"
|
|
|
|
#include "prompts/PromptWindows.h"
|
|
|
|
#include "prompts/ProgressWindow.h"
|
2009-12-12 19:04:35 +01:00
|
|
|
#include "homebrewboot/HomebrewBrowse.h"
|
2009-11-02 23:15:28 +01:00
|
|
|
#include "network/networkops.h"
|
|
|
|
#include "themes/Theme_List.h"
|
2010-09-24 19:58:56 +02:00
|
|
|
#include "themes/CTheme.h"
|
2009-11-02 23:15:28 +01:00
|
|
|
#include "menu.h"
|
|
|
|
#include "filelist.h"
|
|
|
|
#include "listfiles.h"
|
|
|
|
#include "sys.h"
|
|
|
|
#include "network/http.h"
|
|
|
|
#include "ZipFile.h"
|
2009-12-13 11:20:11 +01:00
|
|
|
#include "gecko.h"
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-01-19 11:48:50 +01:00
|
|
|
/*** Extern functions ***/
|
|
|
|
extern void ResumeGui();
|
|
|
|
extern void HaltGui();
|
|
|
|
|
2009-11-02 23:15:28 +01:00
|
|
|
/*** Extern variables ***/
|
|
|
|
extern GuiWindow * mainWindow;
|
|
|
|
extern GuiSound * bgMusic;
|
|
|
|
extern GuiImage * bgImg;
|
2010-01-19 11:48:50 +01:00
|
|
|
extern u8 shutdown;
|
|
|
|
extern u8 reset;
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
int DownloadTheme(const char *url, const char *title)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!url) return 0;
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
char filename[255];
|
2010-09-24 02:48:03 +02:00
|
|
|
memset(filename, 0, sizeof(filename));
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
int filesize = download_request(url, (char *) &filename);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (filesize <= 0)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
WindowPrompt(tr( "Download request failed." ), 0, tr( "OK" ));
|
2009-12-28 17:05:16 +01:00
|
|
|
return 0;
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
char path[300];
|
|
|
|
char filepath[300];
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(path, sizeof(path), "%s%s", Settings.theme_downloadpath, title);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
subfoldercreate(path);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(filepath, sizeof(filepath), "%s/%s", path, filename);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
FILE *file = fopen(filepath, "wb");
|
|
|
|
if (!file)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
WindowPrompt(tr( "Download failed." ), tr( "Can't create file" ), tr( "OK" ));
|
2009-12-28 17:05:16 +01:00
|
|
|
return 0;
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 done = 0;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
int blocksize = 1024 * 5;
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2009-12-12 19:04:35 +01:00
|
|
|
u8 *buffer = new u8[blocksize];
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
while (done < (u32) filesize)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if ((u32) blocksize > filesize - done) blocksize = filesize - done;
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
ShowProgress(tr( "Downloading file" ), 0, (char*) filename, done, filesize, true);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
int ret = network_read(buffer, blocksize);
|
|
|
|
if (ret < 0)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
free(buffer);
|
|
|
|
fclose(file);
|
|
|
|
remove(path);
|
2009-11-02 23:15:28 +01:00
|
|
|
ProgressStop();
|
2010-09-24 02:48:03 +02:00
|
|
|
WindowPrompt(tr( "Download failed." ), tr( "Transfer failed." ), tr( "OK" ));
|
2009-12-28 17:05:16 +01:00
|
|
|
return 0;
|
2010-02-09 11:59:55 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (ret == 0) break;
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
fwrite(buffer, 1, blocksize, file);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
done += ret;
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
delete[] buffer;
|
|
|
|
fclose(file);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
ProgressStop();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (done != (u32) filesize)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
remove(filepath);
|
|
|
|
WindowPrompt(tr( "Download failed." ), tr( "Connection lost..." ), tr( "OK" ));
|
2009-12-28 17:05:16 +01:00
|
|
|
return 0;
|
2009-12-12 19:04:35 +01:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
ZipFile zipfile(filepath);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
int result = zipfile.ExtractAll(path);
|
|
|
|
if (result)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
remove(filepath);
|
|
|
|
int choice = WindowPrompt(tr( "Successfully extracted theme." ), tr( "Do you want to apply it now?" ),
|
|
|
|
tr( "Yes" ), tr( "No" ));
|
|
|
|
if (choice)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-12-28 17:05:16 +01:00
|
|
|
char real_themepath[1024];
|
2010-09-24 02:48:03 +02:00
|
|
|
sprintf(real_themepath, "%s", Settings.theme_path);
|
|
|
|
if (SearchFile(path, "GXtheme.cfg", real_themepath) == true)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
char *ptr = strrchr(real_themepath, '/');
|
|
|
|
if (ptr)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-12-28 17:05:16 +01:00
|
|
|
ptr++;
|
|
|
|
ptr[0] = '\0';
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(Settings.theme_path, sizeof(Settings.theme_path), "%s", real_themepath);
|
2010-09-19 22:25:12 +02:00
|
|
|
Settings.Save();
|
|
|
|
Settings.Load();
|
2009-12-28 17:05:16 +01:00
|
|
|
result = 2;
|
2010-02-09 11:59:55 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else WindowPrompt(tr( "ERROR: Can't set up theme." ), tr( "GXtheme.cfg not found in any subfolder." ),
|
|
|
|
tr( "OK" ));
|
2009-12-28 17:05:16 +01:00
|
|
|
}
|
2010-02-09 11:59:55 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else WindowPrompt(tr( "Failed to extract." ), tr( "Unsupported format, try to extract manually." ), tr( "OK" ));
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
static int Theme_Prompt(const char *title, const char *author, GuiImageData *thumbimageData, const char *downloadlink)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
gprintf("\nTheme_Prompt(%s ,%s, <DATA>, %s)", title, author, downloadlink);
|
2009-11-02 23:15:28 +01:00
|
|
|
bool leave = false;
|
2009-12-28 17:05:16 +01:00
|
|
|
int result = 0;
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
|
2010-09-19 01:16:05 +02:00
|
|
|
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
|
2010-09-19 01:16:05 +02:00
|
|
|
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
char imgPath[100];
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", Settings.theme_path);
|
|
|
|
GuiImageData btnOutline(imgPath, button_dialogue_box_png);
|
|
|
|
snprintf(imgPath, sizeof(imgPath), "%stheme_dialogue_box.png", Settings.theme_path);
|
|
|
|
GuiImageData dialogBox(imgPath, theme_dialogue_box_png);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiImage dialogBoxImg(&dialogBox);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiWindow promptWindow(dialogBox.GetWidth(), dialogBox.GetHeight());
|
|
|
|
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
|
|
|
promptWindow.SetPosition(0, -10);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
GuiTrigger trigA;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
2009-11-02 23:15:28 +01:00
|
|
|
GuiTrigger trigB;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
GuiText titleTxt(tr( "Theme Title:" ), 18, Theme.prompttext);
|
2010-09-24 02:48:03 +02:00
|
|
|
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
|
|
|
titleTxt.SetPosition(230, 30);
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
GuiText titleTxt2(title, 18, Theme.prompttext);
|
2010-09-24 02:48:03 +02:00
|
|
|
titleTxt2.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
|
|
|
titleTxt2.SetPosition(230, 50);
|
|
|
|
titleTxt2.SetMaxWidth(dialogBox.GetWidth() - 220, WRAP);
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
GuiText authorTxt(tr( "Author:" ), 18, Theme.prompttext);
|
2010-09-24 02:48:03 +02:00
|
|
|
authorTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
|
|
|
authorTxt.SetPosition(230, 100);
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
GuiText authorTxt2(author, 18, Theme.prompttext);
|
2010-09-24 02:48:03 +02:00
|
|
|
authorTxt2.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
|
|
|
authorTxt2.SetPosition(230, 120);
|
|
|
|
authorTxt2.SetMaxWidth(dialogBox.GetWidth() - 220, DOTTED);
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
GuiText downloadBtnTxt(tr( "Download" ), 22, Theme.prompttext);
|
2010-09-24 02:48:03 +02:00
|
|
|
downloadBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
|
|
|
|
GuiImage downloadBtnImg(&btnOutline);
|
|
|
|
if (Settings.wsprompt == yes)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
downloadBtnTxt.SetWidescreen(Settings.widescreen);
|
|
|
|
downloadBtnImg.SetWidescreen(Settings.widescreen);
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiButton downloadBtn(&downloadBtnImg, &downloadBtnImg, ALIGN_RIGHT, ALIGN_TOP, -5, 170, &trigA, &btnSoundOver,
|
|
|
|
btnClick2, 1);
|
|
|
|
downloadBtn.SetLabel(&downloadBtnTxt);
|
|
|
|
downloadBtn.SetScale(0.9);
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
GuiText backBtnTxt(tr( "Back" ), 22, Theme.prompttext);
|
2010-09-24 02:48:03 +02:00
|
|
|
backBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
|
|
|
|
GuiImage backBtnImg(&btnOutline);
|
|
|
|
if (Settings.wsprompt == yes)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
backBtnTxt.SetWidescreen(Settings.widescreen);
|
|
|
|
backBtnImg.SetWidescreen(Settings.widescreen);
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiButton backBtn(&backBtnImg, &backBtnImg, ALIGN_RIGHT, ALIGN_TOP, -5, 220, &trigA, &btnSoundOver, btnClick2, 1);
|
|
|
|
backBtn.SetLabel(&backBtnTxt);
|
|
|
|
backBtn.SetTrigger(&trigB);
|
|
|
|
backBtn.SetScale(0.9);
|
|
|
|
|
|
|
|
GuiImage ThemeImage(thumbimageData);
|
|
|
|
ThemeImage.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
|
|
|
ThemeImage.SetPosition(20, 10);
|
|
|
|
ThemeImage.SetScale(0.8);
|
|
|
|
|
|
|
|
ThemeImage.SetScale(0.8);
|
|
|
|
|
|
|
|
promptWindow.Append(&dialogBoxImg);
|
|
|
|
promptWindow.Append(&ThemeImage);
|
|
|
|
promptWindow.Append(&titleTxt);
|
|
|
|
promptWindow.Append(&titleTxt2);
|
|
|
|
promptWindow.Append(&authorTxt);
|
|
|
|
promptWindow.Append(&authorTxt2);
|
|
|
|
promptWindow.Append(&downloadBtn);
|
|
|
|
promptWindow.Append(&backBtn);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
HaltGui();
|
2010-09-24 02:48:03 +02:00
|
|
|
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
|
|
|
|
mainWindow->SetState(STATE_DISABLED);
|
|
|
|
mainWindow->Append(&promptWindow);
|
|
|
|
mainWindow->ChangeFocus(&promptWindow);
|
2009-11-02 23:15:28 +01:00
|
|
|
ResumeGui();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
while (!leave)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-11-02 23:15:28 +01:00
|
|
|
VIDEO_WaitVSync();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (shutdown == 1)
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_Shutdown();
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (reset == 1) Sys_Reboot();
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (downloadBtn.GetState() == STATE_CLICKED)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
int choice = WindowPrompt(tr( "Do you want to download this theme?" ), title, tr( "Yes" ), tr( "Cancel" ));
|
|
|
|
if (choice)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
result = DownloadTheme(downloadlink, title);
|
|
|
|
if (result == 2) leave = true;
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
mainWindow->SetState(STATE_DISABLED);
|
|
|
|
promptWindow.SetState(STATE_DEFAULT);
|
|
|
|
mainWindow->ChangeFocus(&promptWindow);
|
2009-11-02 23:15:28 +01:00
|
|
|
downloadBtn.ResetState();
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (backBtn.GetState() == STATE_CLICKED)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-11-02 23:15:28 +01:00
|
|
|
leave = true;
|
|
|
|
backBtn.ResetState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
|
|
|
|
while (promptWindow.GetEffect() > 0)
|
|
|
|
usleep(50);
|
2009-11-02 23:15:28 +01:00
|
|
|
HaltGui();
|
2010-09-24 02:48:03 +02:00
|
|
|
mainWindow->Remove(&promptWindow);
|
|
|
|
mainWindow->SetState(STATE_DEFAULT);
|
2009-11-02 23:15:28 +01:00
|
|
|
ResumeGui();
|
2009-12-28 17:05:16 +01:00
|
|
|
|
|
|
|
return result;
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
int Theme_Downloader()
|
|
|
|
{
|
2009-11-02 23:15:28 +01:00
|
|
|
int pagesize = 4;
|
|
|
|
int menu = MENU_NONE;
|
|
|
|
bool listchanged = false;
|
|
|
|
|
2009-12-13 11:20:11 +01:00
|
|
|
char THEME_LINK[70];
|
2010-09-24 02:48:03 +02:00
|
|
|
sprintf(THEME_LINK, "http://wii.spiffy360.com/themes.php?xml=1&category=1&adult=%d", Settings.godmode);
|
2009-12-13 11:20:11 +01:00
|
|
|
//gprintf("\nTHEME_LINK: %s", THEME_LINK);
|
2009-12-12 19:04:35 +01:00
|
|
|
//const char THEME_LINK_ADULT[70] = "http://wii.spiffy360.com/themes.php?xml=1&category=1&adult=1";
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
/*** Sound Variables ***/
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
|
2010-09-19 01:16:05 +02:00
|
|
|
// because destroy GuiSound must wait while sound playing is finished, we use a global sound
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!btnClick2) btnClick2 = new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
|
2010-09-19 01:16:05 +02:00
|
|
|
// GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiSound btnClick1(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
/*** Image Variables ***/
|
|
|
|
char imgPath[150];
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", Settings.theme_path);
|
|
|
|
GuiImageData btnOutline(imgPath, button_dialogue_box_png);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%stheme_box.png", Settings.theme_path);
|
|
|
|
GuiImageData theme_box_Data(imgPath, theme_box_png);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", Settings.theme_path);
|
|
|
|
GuiImageData bgData(imgPath, settings_background_png);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", Settings.theme_path);
|
|
|
|
GuiImageData arrow_left(imgPath, startgame_arrow_left_png);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", Settings.theme_path);
|
|
|
|
GuiImageData arrow_right(imgPath, startgame_arrow_right_png);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%sWifi_btn.png", Settings.theme_path);
|
|
|
|
GuiImageData wifiImgData(imgPath, Wifi_btn_png);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(imgPath, sizeof(imgPath), "%spageindicator.png", Settings.theme_path);
|
|
|
|
GuiImageData PageindicatorImgData(imgPath, pageindicator_png);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiImage background(&bgData);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
/*** Trigger Variables ***/
|
|
|
|
GuiTrigger trigA;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
2009-11-02 23:15:28 +01:00
|
|
|
GuiTrigger trigHome;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
|
2009-11-02 23:15:28 +01:00
|
|
|
GuiTrigger trigB;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
|
2009-11-02 23:15:28 +01:00
|
|
|
GuiTrigger trigL;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);
|
2009-11-02 23:15:28 +01:00
|
|
|
GuiTrigger trigR;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
|
2009-11-02 23:15:28 +01:00
|
|
|
GuiTrigger trigMinus;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
|
2009-11-02 23:15:28 +01:00
|
|
|
GuiTrigger trigPlus;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiText titleTxt(tr( "Theme Downloader" ), 28, ( GXColor )
|
|
|
|
{ 0, 0, 0, 255});
|
|
|
|
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
|
|
|
titleTxt.SetPosition(0, 40);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
GuiImageData *ImageData[pagesize];
|
|
|
|
GuiImage *Image[pagesize];
|
|
|
|
GuiImage *theme_box_img[pagesize];
|
|
|
|
GuiButton *MainButton[pagesize];
|
|
|
|
GuiText *MainButtonTxt[pagesize];
|
2010-09-24 19:58:56 +02:00
|
|
|
Theme_List *ThemeList = NULL;
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
/*** Buttons ***/
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < pagesize; i++)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-11-02 23:15:28 +01:00
|
|
|
ImageData[i] = NULL;
|
|
|
|
Image[i] = NULL;
|
|
|
|
MainButtonTxt[i] = NULL;
|
2010-09-24 02:48:03 +02:00
|
|
|
theme_box_img[i] = new GuiImage(&theme_box_Data);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
MainButton[i] = new GuiButton(theme_box_Data.GetWidth(), theme_box_Data.GetHeight());
|
|
|
|
MainButton[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
|
|
|
MainButton[i]->SetSoundOver(&btnSoundOver);
|
|
|
|
MainButton[i]->SetSoundClick(&btnClick1);
|
|
|
|
MainButton[i]->SetImage(theme_box_img[i]);
|
2009-11-02 23:15:28 +01:00
|
|
|
MainButton[i]->SetEffectGrow();
|
2010-09-24 02:48:03 +02:00
|
|
|
MainButton[i]->SetTrigger(&trigA);
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Positions ***/
|
2010-09-24 02:48:03 +02:00
|
|
|
MainButton[0]->SetPosition(90, 75);
|
|
|
|
MainButton[1]->SetPosition(340, 75);
|
|
|
|
MainButton[2]->SetPosition(90, 230);
|
|
|
|
MainButton[3]->SetPosition(340, 230);
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
GuiText backBtnTxt(tr( "Back" ), 22, Theme.prompttext);
|
2010-09-24 02:48:03 +02:00
|
|
|
backBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
|
|
|
|
GuiImage backBtnImg(&btnOutline);
|
|
|
|
if (Settings.wsprompt == yes)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
backBtnTxt.SetWidescreen(Settings.widescreen);
|
|
|
|
backBtnImg.SetWidescreen(Settings.widescreen);
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiButton backBtn(&backBtnImg, &backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, btnClick2, 1);
|
|
|
|
backBtn.SetLabel(&backBtnTxt);
|
|
|
|
backBtn.SetTrigger(&trigB);
|
|
|
|
|
|
|
|
GuiButton HomeBtn(1, 1);
|
|
|
|
HomeBtn.SetTrigger(&trigHome);
|
|
|
|
|
|
|
|
GuiImage GoLeftImg(&arrow_left);
|
|
|
|
GuiButton GoLeftBtn(GoLeftImg.GetWidth(), GoLeftImg.GetHeight());
|
|
|
|
GoLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
|
|
|
GoLeftBtn.SetPosition(25, -25);
|
|
|
|
GoLeftBtn.SetImage(&GoLeftImg);
|
|
|
|
GoLeftBtn.SetSoundOver(&btnSoundOver);
|
|
|
|
GoLeftBtn.SetSoundClick(btnClick2);
|
2009-11-02 23:15:28 +01:00
|
|
|
GoLeftBtn.SetEffectGrow();
|
2010-09-24 02:48:03 +02:00
|
|
|
GoLeftBtn.SetTrigger(&trigA);
|
|
|
|
GoLeftBtn.SetTrigger(&trigL);
|
|
|
|
GoLeftBtn.SetTrigger(&trigMinus);
|
|
|
|
|
|
|
|
GuiImage GoRightImg(&arrow_right);
|
|
|
|
GuiButton GoRightBtn(GoRightImg.GetWidth(), GoRightImg.GetHeight());
|
|
|
|
GoRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
|
|
|
|
GoRightBtn.SetPosition(-25, -25);
|
|
|
|
GoRightBtn.SetImage(&GoRightImg);
|
|
|
|
GoRightBtn.SetSoundOver(&btnSoundOver);
|
|
|
|
GoRightBtn.SetSoundClick(btnClick2);
|
2009-11-02 23:15:28 +01:00
|
|
|
GoRightBtn.SetEffectGrow();
|
2010-09-24 02:48:03 +02:00
|
|
|
GoRightBtn.SetTrigger(&trigA);
|
|
|
|
GoRightBtn.SetTrigger(&trigR);
|
|
|
|
GoRightBtn.SetTrigger(&trigPlus);
|
|
|
|
|
|
|
|
GuiImage PageindicatorImg(&PageindicatorImgData);
|
|
|
|
GuiText PageindicatorTxt((char *) NULL, 22, ( GXColor )
|
|
|
|
{ 0, 0, 0, 255});
|
|
|
|
GuiButton PageIndicatorBtn(PageindicatorImg.GetWidth(), PageindicatorImg.GetHeight());
|
|
|
|
PageIndicatorBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
|
|
|
PageIndicatorBtn.SetPosition(110, 400);
|
|
|
|
PageIndicatorBtn.SetImage(&PageindicatorImg);
|
|
|
|
PageIndicatorBtn.SetLabel(&PageindicatorTxt);
|
|
|
|
PageIndicatorBtn.SetSoundOver(&btnSoundOver);
|
|
|
|
PageIndicatorBtn.SetSoundClick(&btnClick1);
|
|
|
|
PageIndicatorBtn.SetTrigger(&trigA);
|
2009-11-02 23:15:28 +01:00
|
|
|
PageIndicatorBtn.SetEffectGrow();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiImage wifiImg(&wifiImgData);
|
|
|
|
if (Settings.wsprompt == yes)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
wifiImg.SetWidescreen(Settings.widescreen);
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight());
|
|
|
|
wifiBtn.SetImage(&wifiImg);
|
|
|
|
wifiBtn.SetPosition(500, 400);
|
|
|
|
wifiBtn.SetSoundOver(&btnSoundOver);
|
|
|
|
wifiBtn.SetSoundClick(&btnClick1);
|
2009-11-02 23:15:28 +01:00
|
|
|
wifiBtn.SetEffectGrow();
|
2010-09-24 02:48:03 +02:00
|
|
|
wifiBtn.SetTrigger(&trigA);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
GuiWindow w(screenwidth, screenheight);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
HaltGui();
|
2010-09-24 02:48:03 +02:00
|
|
|
w.Append(&background);
|
|
|
|
mainWindow->Append(&w);
|
2009-11-02 23:15:28 +01:00
|
|
|
ResumeGui();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!IsNetworkInit()) NetworkInitPrompt();
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
char url[300];
|
|
|
|
int currentpage = 1;
|
|
|
|
int currenttheme = 0;
|
2009-12-12 19:04:35 +01:00
|
|
|
|
|
|
|
HaltGui();
|
|
|
|
w.RemoveAll();
|
2010-09-24 02:48:03 +02:00
|
|
|
w.Append(&background);
|
|
|
|
w.Append(&titleTxt);
|
|
|
|
w.Append(&backBtn);
|
|
|
|
w.Append(&GoLeftBtn);
|
|
|
|
w.Append(&GoRightBtn);
|
|
|
|
w.Append(&PageIndicatorBtn);
|
|
|
|
w.Append(&wifiBtn);
|
|
|
|
w.Append(&HomeBtn);
|
2009-12-12 19:04:35 +01:00
|
|
|
ResumeGui();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
ShowProgress(tr( "Downloading Page List:" ), "", (char *) tr( "Please wait..." ), 0, pagesize);
|
2009-12-12 19:04:35 +01:00
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
ThemeList = new Theme_List(THEME_LINK);
|
2009-12-12 19:04:35 +01:00
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
int ThemesOnPage = ThemeList->GetThemeCount();
|
2009-12-12 19:04:35 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!ThemesOnPage)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
WindowPrompt(tr( "No themes found on the site." ), 0, "OK");
|
2009-12-12 19:04:35 +01:00
|
|
|
menu = MENU_SETTINGS;
|
|
|
|
}
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
while (menu == MENU_NONE)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-11-02 23:15:28 +01:00
|
|
|
HaltGui();
|
|
|
|
w.RemoveAll();
|
2010-09-24 02:48:03 +02:00
|
|
|
w.Append(&background);
|
|
|
|
w.Append(&titleTxt);
|
|
|
|
w.Append(&backBtn);
|
|
|
|
w.Append(&GoLeftBtn);
|
|
|
|
w.Append(&GoRightBtn);
|
|
|
|
w.Append(&PageIndicatorBtn);
|
|
|
|
w.Append(&wifiBtn);
|
|
|
|
w.Append(&HomeBtn);
|
2009-11-02 23:15:28 +01:00
|
|
|
ResumeGui();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
sprintf(url, "%i", currentpage);
|
|
|
|
PageindicatorTxt.SetText(url);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2009-12-12 19:04:35 +01:00
|
|
|
int n = 0;
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = currenttheme; (i < (currenttheme + pagesize)); i++)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 19:58:56 +02:00
|
|
|
ShowProgress(tr( "Downloading image:" ), 0, (char *) ThemeList->GetThemeTitle(i), n, pagesize);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (MainButtonTxt[n]) delete MainButtonTxt[n];
|
|
|
|
if (ImageData[n]) delete ImageData[n];
|
|
|
|
if (Image[n]) delete Image[n];
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2009-12-12 19:04:35 +01:00
|
|
|
MainButtonTxt[n] = NULL;
|
|
|
|
ImageData[n] = NULL;
|
|
|
|
Image[n] = NULL;
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (i < ThemesOnPage)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 19:58:56 +02:00
|
|
|
MainButtonTxt[n] = new GuiText(ThemeList->GetThemeTitle(i), 18, ( GXColor )
|
2010-09-24 02:48:03 +02:00
|
|
|
{ 0, 0, 0, 255});
|
|
|
|
MainButtonTxt[n]->SetAlignment(ALIGN_CENTER, ALIGN_TOP);
|
|
|
|
MainButtonTxt[n]->SetPosition(0, 10);
|
|
|
|
MainButtonTxt[n]->SetMaxWidth(theme_box_Data.GetWidth() - 10, DOTTED);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
sprintf(url, "%s", ThemeList->GetImageLink(i));
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2009-12-12 19:04:35 +01:00
|
|
|
char filepath[300];
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(filepath, sizeof(filepath), "%s/tmp/%s.jpg", Settings.theme_downloadpath,
|
2010-09-24 19:58:56 +02:00
|
|
|
ThemeList->GetThemeTitle(i));
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
FILE * storefile = fopen(filepath, "rb");
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!storefile)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
struct block file = downloadfile(url);
|
2009-12-12 19:04:35 +01:00
|
|
|
char storepath[300];
|
2010-09-24 02:48:03 +02:00
|
|
|
snprintf(storepath, sizeof(storepath), "%s/tmp/", Settings.theme_downloadpath);
|
|
|
|
subfoldercreate(storepath);
|
|
|
|
if (file.data)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
storefile = fopen(filepath, "wb");
|
|
|
|
fwrite(file.data, 1, file.size, storefile);
|
|
|
|
fclose(storefile);
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
ImageData[n] = new GuiImageData(file.data, file.size);
|
|
|
|
free(file.data);
|
2010-02-09 11:59:55 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
fseek(storefile, 0, SEEK_END);
|
|
|
|
u32 filesize = ftell(storefile);
|
|
|
|
u8 *buffer = (u8*) malloc(filesize);
|
|
|
|
rewind(storefile);
|
|
|
|
fread(buffer, 1, filesize, storefile);
|
|
|
|
fclose(storefile);
|
|
|
|
ImageData[n] = new GuiImageData(buffer, filesize);
|
|
|
|
free(buffer);
|
2009-12-12 19:04:35 +01:00
|
|
|
buffer = NULL;
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
Image[n] = new GuiImage(ImageData[n]);
|
|
|
|
Image[n]->SetScale(0.4);
|
|
|
|
Image[n]->SetPosition(50, -45);
|
|
|
|
MainButton[n]->SetIcon(Image[n]);
|
|
|
|
MainButton[n]->SetLabel(MainButtonTxt[n]);
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
2009-12-12 19:04:35 +01:00
|
|
|
n++;
|
|
|
|
}
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2009-12-12 19:04:35 +01:00
|
|
|
ProgressStop();
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2009-12-12 19:04:35 +01:00
|
|
|
HaltGui();
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < pagesize; i++)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (MainButtonTxt[i]) w.Append(MainButton[i]);
|
2009-12-12 19:04:35 +01:00
|
|
|
}
|
|
|
|
ResumeGui();
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2009-12-12 19:04:35 +01:00
|
|
|
listchanged = false;
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
while (!listchanged)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
VIDEO_WaitVSync();
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (shutdown == 1)
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_Shutdown();
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (reset == 1)
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_Reboot();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (wifiBtn.GetState() == STATE_CLICKED)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-12-12 19:04:35 +01:00
|
|
|
Initialize_Network();
|
|
|
|
wifiBtn.ResetState();
|
2010-02-09 11:59:55 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (backBtn.GetState() == STATE_CLICKED)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-12-12 19:04:35 +01:00
|
|
|
listchanged = true;
|
|
|
|
menu = MENU_SETTINGS;
|
|
|
|
backBtn.ResetState();
|
|
|
|
break;
|
2010-02-09 11:59:55 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (GoRightBtn.GetState() == STATE_CLICKED)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-12-12 19:04:35 +01:00
|
|
|
listchanged = true;
|
|
|
|
currenttheme += pagesize;
|
|
|
|
currentpage++;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (currenttheme >= ThemesOnPage)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-12-12 19:04:35 +01:00
|
|
|
currentpage = 1;
|
|
|
|
currenttheme = 0;
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
2009-12-12 19:04:35 +01:00
|
|
|
GoRightBtn.ResetState();
|
2010-02-09 11:59:55 +01:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (GoLeftBtn.GetState() == STATE_CLICKED)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-12-12 19:04:35 +01:00
|
|
|
listchanged = true;
|
|
|
|
currenttheme -= pagesize;
|
|
|
|
currentpage--;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (currenttheme < 0)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
currentpage = roundup((ThemesOnPage + 1.0f) / pagesize);
|
2010-09-19 01:16:05 +02:00
|
|
|
currenttheme = currentpage * pagesize - pagesize;
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
2009-12-12 19:04:35 +01:00
|
|
|
GoLeftBtn.ResetState();
|
|
|
|
}
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < pagesize; i++)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (MainButton[i]->GetState() == STATE_CLICKED)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 19:58:56 +02:00
|
|
|
snprintf(url, sizeof(url), "%s", ThemeList->GetDownloadLink(currenttheme + i));
|
|
|
|
int ret = Theme_Prompt(ThemeList->GetThemeTitle(currenttheme + i), ThemeList->GetThemeAuthor(currenttheme
|
2010-09-24 02:48:03 +02:00
|
|
|
+ i), ImageData[i], url);
|
2009-12-12 19:04:35 +01:00
|
|
|
MainButton[i]->ResetState();
|
2010-09-24 02:48:03 +02:00
|
|
|
if (ret == 2)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2009-12-28 17:05:16 +01:00
|
|
|
listchanged = true;
|
|
|
|
menu = MENU_THEMEDOWNLOADER;
|
|
|
|
}
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
w.SetEffect(EFFECT_FADE, -20);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
while (w.GetEffect() > 0)
|
|
|
|
usleep(100);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
HaltGui();
|
2010-09-24 02:48:03 +02:00
|
|
|
mainWindow->Remove(&w);
|
2009-11-02 23:15:28 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < pagesize; i++)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (MainButton[i]) delete MainButton[i];
|
|
|
|
if (theme_box_img[i]) delete theme_box_img[i];
|
|
|
|
if (ImageData[i]) delete ImageData[i];
|
|
|
|
if (Image[i]) delete Image[i];
|
|
|
|
if (MainButtonTxt[i]) delete MainButtonTxt[i];
|
2009-11-02 23:15:28 +01:00
|
|
|
}
|
|
|
|
|
2010-09-24 19:58:56 +02:00
|
|
|
if (ThemeList) delete ThemeList;
|
|
|
|
ThemeList = NULL;
|
2009-11-02 23:15:28 +01:00
|
|
|
|
|
|
|
ResumeGui();
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|