2009-10-01 01:10:58 +02:00
|
|
|
#include <gccore.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "language/gettext.h"
|
2010-12-18 14:20:45 +01:00
|
|
|
#include "language/UpdateLanguage.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
#include "prompts/PromptWindows.h"
|
|
|
|
#include "prompts/ProgressWindow.h"
|
2011-06-14 19:53:19 +02:00
|
|
|
#include "GUI/gui.h"
|
|
|
|
#include "GUI/gui_optionbrowser.h"
|
2010-09-19 22:25:12 +02:00
|
|
|
#include "settings/CSettings.h"
|
2011-01-07 23:42:03 +01:00
|
|
|
#include "settings/GameTitles.h"
|
2010-09-24 19:58:56 +02:00
|
|
|
#include "themes/CTheme.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
#include "network/URL_List.h"
|
2010-09-25 08:54:27 +02:00
|
|
|
#include "FileOperations/fileops.h"
|
|
|
|
#include "FileOperations/DirList.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
#include "main.h"
|
2010-02-15 00:22:52 +01:00
|
|
|
#include "prompts/filebrowser.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
#include "sys.h"
|
2010-02-15 00:22:52 +01:00
|
|
|
#include "menu/menus.h"
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
/*** Extern variables ***/
|
|
|
|
extern u8 shutdown;
|
|
|
|
extern u8 reset;
|
|
|
|
|
2009-10-01 01:10:58 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* MenuOGG
|
|
|
|
***************************************************************************/
|
2010-02-15 00:22:52 +01:00
|
|
|
bool MenuBackgroundMusic()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
bool ret = false;
|
|
|
|
int result = -1;
|
2012-05-06 12:59:58 +02:00
|
|
|
char entered[1024];
|
|
|
|
strlcpy(entered, Settings.ogg_path, sizeof(entered));
|
2011-07-26 00:28:22 +02:00
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
// Check the OGG path.
|
|
|
|
if (entered[0] == 0 )
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
// OGG path is empty.
|
|
|
|
strlcpy(entered, Settings.BootDevice, sizeof(entered));
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char * pathptr = strrchr( entered, '/' );
|
|
|
|
if ( pathptr )
|
|
|
|
{
|
|
|
|
pathptr++;
|
|
|
|
int choice = WindowPrompt( tr( "Playing Music:" ), pathptr, tr( "Play Previous" ), tr( "Play Next" ), tr( "Change Play Path" ), tr( "Cancel" ) );
|
|
|
|
if ( choice == 1 )
|
|
|
|
{
|
|
|
|
return bgMusic->PlayPrevious();
|
|
|
|
}
|
|
|
|
else if ( choice == 2 )
|
|
|
|
{
|
|
|
|
return bgMusic->PlayNext();
|
|
|
|
}
|
|
|
|
else if ( choice == 3 )
|
|
|
|
{
|
|
|
|
pathptr[0] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(entered, Settings.BootDevice, sizeof(entered));
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
result = BrowseDevice( entered, sizeof( entered ), FB_DEFAULT );
|
|
|
|
|
|
|
|
if ( result )
|
|
|
|
{
|
|
|
|
if ( !bgMusic->Load( entered ) )
|
|
|
|
{
|
|
|
|
WindowPrompt( tr( "Not supported format!" ), tr( "Loading standard music." ), tr( "OK" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = true;
|
|
|
|
bgMusic->Play();
|
|
|
|
bgMusic->SetVolume( Settings.volume );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* MenuLanguageSelect
|
|
|
|
***************************************************************************/
|
2010-09-19 01:16:05 +02:00
|
|
|
int MenuLanguageSelect()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
int cnt = 0;
|
|
|
|
int ret = 0, choice = 0;
|
|
|
|
int returnhere = 0;
|
|
|
|
|
|
|
|
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
|
|
|
|
GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
char fullpath[150];
|
2011-07-26 00:28:22 +02:00
|
|
|
DirList Dir(Settings.languagefiles_path, ".lang");
|
|
|
|
|
2012-05-06 12:59:58 +02:00
|
|
|
// Check if a language is specified.
|
|
|
|
if (Settings.language_path[0] == 0)
|
|
|
|
strlcpy(fullpath, tr( "Default" ), sizeof(fullpath));
|
2011-07-26 00:28:22 +02:00
|
|
|
else
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(fullpath, Settings.languagefiles_path, sizeof(fullpath));
|
2011-07-26 00:28:22 +02:00
|
|
|
|
|
|
|
GuiText titleTxt( fullpath, 24, ( GXColor ) {0, 0, 0, 255} );
|
2012-05-06 12:59:58 +02:00
|
|
|
titleTxt.SetAlignment( ALIGN_CENTER, ALIGN_MIDDLE );
|
2011-07-26 00:28:22 +02:00
|
|
|
titleTxt.SetPosition( 0, 0 );
|
|
|
|
GuiButton pathBtn( 300, 50 );
|
2012-05-06 12:59:58 +02:00
|
|
|
pathBtn.SetAlignment( ALIGN_CENTER, ALIGN_TOP );
|
2011-07-26 00:28:22 +02:00
|
|
|
pathBtn.SetPosition( 0, 28 );
|
|
|
|
pathBtn.SetLabel( &titleTxt );
|
|
|
|
pathBtn.SetSoundOver( btnSoundOver );
|
|
|
|
pathBtn.SetSoundClick( btnSoundClick2 );
|
|
|
|
pathBtn.SetTrigger( &trigA );
|
|
|
|
pathBtn.SetEffectGrow();
|
|
|
|
|
|
|
|
GuiImage oggmenubackground( &settingsbg );
|
|
|
|
oggmenubackground.SetAlignment( ALIGN_LEFT, ALIGN_TOP );
|
|
|
|
oggmenubackground.SetPosition( 0, 0 );
|
|
|
|
|
|
|
|
GuiText backBtnTxt( tr( "Back" ) , 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
|
|
|
|
backBtnTxt.SetMaxWidth( btnOutline.GetWidth() - 30 );
|
|
|
|
GuiImage backBtnImg( &btnOutline );
|
|
|
|
if ( Settings.wsprompt == ON )
|
|
|
|
{
|
|
|
|
backBtnTxt.SetWidescreen( Settings.widescreen );
|
|
|
|
backBtnImg.SetWidescreen( Settings.widescreen );
|
|
|
|
}
|
|
|
|
GuiButton backBtn( btnOutline.GetWidth(), btnOutline.GetHeight() );
|
2012-05-06 12:59:58 +02:00
|
|
|
backBtn.SetAlignment( ALIGN_CENTER, ALIGN_TOP );
|
2011-07-26 00:28:22 +02:00
|
|
|
backBtn.SetPosition( -190, 400 );
|
|
|
|
backBtn.SetLabel( &backBtnTxt );
|
|
|
|
backBtn.SetImage( &backBtnImg );
|
|
|
|
backBtn.SetSoundOver( btnSoundOver );
|
|
|
|
backBtn.SetSoundClick( btnSoundClick2 );
|
|
|
|
backBtn.SetTrigger( &trigA );
|
|
|
|
backBtn.SetTrigger( &trigB );
|
|
|
|
backBtn.SetEffectGrow();
|
|
|
|
|
|
|
|
GuiText defaultBtnTxt( tr( "Default" ) , 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
|
|
|
|
defaultBtnTxt.SetMaxWidth( btnOutline.GetWidth() - 30 );
|
|
|
|
GuiImage defaultBtnImg( &btnOutline );
|
|
|
|
if ( Settings.wsprompt == ON )
|
|
|
|
{
|
|
|
|
defaultBtnTxt.SetWidescreen( Settings.widescreen );
|
|
|
|
defaultBtnImg.SetWidescreen( Settings.widescreen );
|
|
|
|
}
|
|
|
|
GuiButton defaultBtn( btnOutline.GetWidth(), btnOutline.GetHeight() );
|
2012-05-06 12:59:58 +02:00
|
|
|
defaultBtn.SetAlignment( ALIGN_CENTER, ALIGN_TOP );
|
2011-07-26 00:28:22 +02:00
|
|
|
defaultBtn.SetPosition( 190, 400 );
|
|
|
|
defaultBtn.SetLabel( &defaultBtnTxt );
|
|
|
|
defaultBtn.SetImage( &defaultBtnImg );
|
|
|
|
defaultBtn.SetSoundOver( btnSoundOver );
|
|
|
|
defaultBtn.SetSoundClick( btnSoundClick2 );
|
|
|
|
defaultBtn.SetTrigger( &trigA );
|
|
|
|
defaultBtn.SetEffectGrow();
|
|
|
|
|
|
|
|
GuiText updateBtnTxt( tr( "Update Files" ) , 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
|
|
|
|
updateBtnTxt.SetMaxWidth( btnOutline.GetWidth() - 30 );
|
|
|
|
GuiImage updateBtnImg( &btnOutline );
|
|
|
|
if ( Settings.wsprompt == ON )
|
|
|
|
{
|
|
|
|
updateBtnTxt.SetWidescreen( Settings.widescreen );
|
|
|
|
updateBtnImg.SetWidescreen( Settings.widescreen );
|
|
|
|
}
|
|
|
|
GuiButton updateBtn( btnOutline.GetWidth(), btnOutline.GetHeight() );
|
2012-05-06 12:59:58 +02:00
|
|
|
updateBtn.SetAlignment( ALIGN_CENTER, ALIGN_TOP );
|
2011-07-26 00:28:22 +02:00
|
|
|
updateBtn.SetPosition( 0, 400 );
|
|
|
|
updateBtn.SetLabel( &updateBtnTxt );
|
|
|
|
updateBtn.SetImage( &updateBtnImg );
|
|
|
|
updateBtn.SetSoundOver( btnSoundOver );
|
|
|
|
updateBtn.SetSoundClick( btnSoundClick2 );
|
|
|
|
updateBtn.SetTrigger( &trigA );
|
|
|
|
updateBtn.SetEffectGrow();
|
|
|
|
|
|
|
|
OptionList options2;
|
|
|
|
|
|
|
|
for ( cnt = 0; cnt < Dir.GetFilecount(); cnt++ )
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
if(!Dir.GetFilename( cnt ))
|
|
|
|
continue;
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
char filename[64];
|
|
|
|
strlcpy( filename, Dir.GetFilename( cnt ), sizeof( filename ) );
|
|
|
|
char *dot = strchr( filename, '.' );
|
|
|
|
if ( dot ) *dot = '\0';
|
|
|
|
options2.SetName( cnt, "%s", filename );
|
|
|
|
options2.SetValue( cnt, NULL );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
GuiOptionBrowser optionBrowser4( 396, 280, &options2, "bg_options_settings.png");
|
|
|
|
optionBrowser4.SetPosition( 0, 90 );
|
2012-05-06 12:59:58 +02:00
|
|
|
optionBrowser4.SetAlignment( ALIGN_CENTER, ALIGN_TOP );
|
2011-07-26 00:28:22 +02:00
|
|
|
|
|
|
|
HaltGui();
|
|
|
|
GuiWindow w( screenwidth, screenheight );
|
|
|
|
w.Append( &oggmenubackground );
|
|
|
|
w.Append( &pathBtn );
|
|
|
|
w.Append( &backBtn );
|
|
|
|
w.Append( &defaultBtn );
|
|
|
|
w.Append( &updateBtn );
|
|
|
|
w.Append( &optionBrowser4 );
|
|
|
|
mainWindow->Append( &w );
|
|
|
|
|
|
|
|
w.SetEffect( EFFECT_FADE, 20 );
|
|
|
|
ResumeGui();
|
|
|
|
|
|
|
|
while ( w.GetEffect() > 0 ) usleep( 50 );
|
|
|
|
|
|
|
|
while ( !returnhere )
|
|
|
|
{
|
2010-12-26 18:02:14 +01:00
|
|
|
usleep(100);
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
if ( shutdown == 1 )
|
|
|
|
Sys_Shutdown();
|
|
|
|
else if ( reset == 1 )
|
|
|
|
Sys_Reboot();
|
|
|
|
|
|
|
|
else if ( backBtn.GetState() == STATE_CLICKED )
|
|
|
|
{
|
|
|
|
backBtn.ResetState();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ( defaultBtn.GetState() == STATE_CLICKED )
|
|
|
|
{
|
|
|
|
choice = WindowPrompt( tr( "Loading standard language." ), 0, tr( "OK" ), tr( "Cancel" ) );
|
|
|
|
if ( choice == 1 )
|
|
|
|
{
|
|
|
|
Settings.LoadLanguage(NULL, CONSOLE_DEFAULT);
|
|
|
|
Settings.Save();
|
|
|
|
returnhere = 2;
|
|
|
|
}
|
|
|
|
defaultBtn.ResetState();
|
|
|
|
//optionBrowser4.SetFocus(1); // commented out to prevent crash
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ( updateBtn.GetState() == STATE_CLICKED )
|
|
|
|
{
|
|
|
|
choice = WindowPrompt( tr( "Update all Language Files" ), tr( "Do you wish to update/download all language files?" ), tr( "OK" ), tr( "Cancel" ) );
|
|
|
|
if ( choice == 1 )
|
|
|
|
{
|
|
|
|
if (IsNetworkInit() || NetworkInitPrompt())
|
|
|
|
{
|
|
|
|
if(DownloadAllLanguageFiles() > 0)
|
|
|
|
WindowPrompt(tr("Update successfull"), 0, tr("OK"));
|
|
|
|
returnhere = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateBtn.ResetState();
|
|
|
|
//optionBrowser4.SetFocus(1); // commented out to prevent crash
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ( pathBtn.GetState() == STATE_CLICKED )
|
|
|
|
{
|
|
|
|
w.Remove( &optionBrowser4 );
|
|
|
|
w.Remove( &backBtn );
|
|
|
|
w.Remove( &pathBtn );
|
|
|
|
w.Remove( &defaultBtn );
|
|
|
|
char entered[43] = "";
|
|
|
|
strlcpy( entered, Settings.languagefiles_path, sizeof( entered ) );
|
|
|
|
int result = OnScreenKeyboard( entered, 43, 0 );
|
|
|
|
w.Append( &optionBrowser4 );
|
|
|
|
w.Append( &pathBtn );
|
|
|
|
w.Append( &backBtn );
|
|
|
|
w.Append( &defaultBtn );
|
|
|
|
if (result == 1)
|
|
|
|
{
|
|
|
|
if (entered[strlen(entered)-1] != '/')
|
|
|
|
strcat (entered, "/");
|
|
|
|
snprintf(Settings.languagefiles_path, sizeof(Settings.languagefiles_path), entered);
|
|
|
|
WindowPrompt(tr("Languagepath changed."), 0, tr("OK"));
|
|
|
|
}
|
|
|
|
pathBtn.ResetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = optionBrowser4.GetClickedOption();
|
|
|
|
|
|
|
|
if (ret >= 0)
|
|
|
|
{
|
|
|
|
choice = WindowPrompt( tr( "Do you want to change language?" ), 0, tr( "Yes" ), tr( "Cancel" ) );
|
|
|
|
if (choice == 1)
|
|
|
|
{
|
|
|
|
char newLangPath[150];
|
|
|
|
snprintf(Settings.languagefiles_path, sizeof( Settings.languagefiles_path ), "%s", Dir.GetFilepath(ret));
|
|
|
|
char * ptr = strrchr(Settings.languagefiles_path, '/');
|
|
|
|
if(ptr) ptr[1] = 0;
|
|
|
|
snprintf(newLangPath, sizeof(newLangPath), "%s", Dir.GetFilepath(ret));
|
|
|
|
if (!CheckFile(newLangPath))
|
|
|
|
{
|
|
|
|
WindowPrompt(tr("File not found."), tr("Loading standard language."), tr("OK"));
|
|
|
|
Settings.LoadLanguage(NULL, CONSOLE_DEFAULT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Settings.LoadLanguage(newLangPath);
|
|
|
|
}
|
|
|
|
Settings.Save();
|
|
|
|
returnhere = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
w.SetEffect( EFFECT_FADE, -20 );
|
|
|
|
while ( w.GetEffect() > 0 ) usleep( 50 );
|
|
|
|
|
|
|
|
HaltGui();
|
|
|
|
mainWindow->Remove( &w );
|
|
|
|
ResumeGui();
|
|
|
|
|
|
|
|
return returnhere;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|