diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 57e669d90a..a78094ce5f 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -47,6 +47,14 @@ static const int pxID_PadHandler_Keydown = 8030; // single for-loop to create them. static const int PluginMenuId_Interval = 0x10; +// ID and return code used for modal popups that have a custom button. +static const wxWindowID pxID_CUSTOM = wxID_LOWEST - 1; + +// Return code used by first time wizard if the dialog needs to be automatically recreated +// (assigned an arbitrary value) +static const wxWindowID pxID_RestartWizard = wxID_LOWEST - 100; + + // Forces the Interface to destroy the GS viewport window when the GS plugin is // destroyed. This has the side effect of forcing all plugins to close and re-open // along with the GS, since the GS viewport window handle will have changed. diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index 3aebe374f4..43f221600d 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -70,12 +70,29 @@ void Pcsx2App::WipeUserModeSettings() usermodefile.SetPath( usrlocaldir.ToString() ); ScopedPtr conf_usermode( OpenFileConfig( usermodefile.GetFullPath() ) ); - wxString groupname( wxsFormat( L"CWD.%08x", hashres ) ); + wxString groupname( pxsFmt( L"CWD.%08x", hashres ) ); Console.WriteLn( "(UserModeSettings) Removing entry:" ); Console.Indent().WriteLn( L"Path: %s\nHash:%s", cwd.c_str(), groupname.c_str() ); conf_usermode->DeleteGroup( groupname ); } +static void DoFirstTimeWizard() +{ + // first time startup, so give the user the choice of user mode: + while(true) + { + // PCSX2's FTWizard allows improptu restarting of the wizard without cancellation. This is + // typically used to change the user's language selection. + + FirstTimeWizard wiz( NULL ); + if( wiz.RunWizard( wiz.GetUsermodePage() ) ) break; + if (wiz.GetReturnCode() != pxID_RestartWizard) + throw Exception::StartupAborted( L"User canceled FirstTime Wizard." ); + + Console.WriteLn( Color_StrongBlack, "Restarting First Time Wizard!" ); + } +} + // User mode settings can't be stored in the CWD for two reasons: // (a) the user may not have permission to do so (most obvious) // (b) it would result in sloppy usermode.ini found all over a hard drive if people runs the @@ -135,10 +152,7 @@ void Pcsx2App::ReadUserModeSettings() } #endif - // first time startup, so give the user the choice of user mode: - FirstTimeWizard wiz( NULL ); - if( !wiz.RunWizard( wiz.GetUsermodePage() ) ) - throw Exception::StartupAborted( L"User canceled FirstTime Wizard." ); + DoFirstTimeWizard(); // Save user's new settings IniSaver saver( *conf_usermode ); @@ -159,14 +173,8 @@ void Pcsx2App::ReadUserModeSettings() if( !wxFile::Exists( GetSettingsFilename() ) ) { // user wiped their pcsx2.ini -- needs a reconfiguration via wizard! - // (we skip the first page since it's a usermode.ini thing) - - // Fixme : Skipping the first page is a bad idea, as it does a lot of file / directory checks on hitting Apply. - // If anything is missing, the first page prompts to fix it. - // If we skip this check, it's very likely that actions like creating Memory Cards will fail. - FirstTimeWizard wiz( NULL ); - if( !wiz.RunWizard( /*wiz.GetPostUsermodePage()*/ wiz.GetUsermodePage() ) ) - throw Exception::StartupAborted( L"User canceled Configuration Wizard." ); + + DoFirstTimeWizard(); // Save user's new settings IniSaver saver( *conf_usermode ); @@ -540,6 +548,10 @@ bool Pcsx2App::OnInit() g_Conf = new AppConfig(); wxInitAllImageHandlers(); + Console.WriteLn("Applying operating system default language..."); + //i18n_SetLanguage( wxLANGUAGE_DEFAULT ); + i18n_SetLanguage( wxLANGUAGE_CHINESE ); + Console.WriteLn("Command line parsing..."); if( !_parent::OnInit() ) return false; Console.WriteLn("Command line parsed!"); diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 1f2b48e565..21d9399b34 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -277,6 +277,12 @@ public: virtual void Printf(const wxChar* format, ...); }; +// EXTRAORDINARY HACK! wxWidgets does not provide a clean way of overriding the commandline options +// display dialog. The default one uses operating system built-in message/notice windows, which are +// appaling, ugly, and not at all suited to a large number of command line options. Fortunately, +// wxMessageOutputMessageBox::PrintF is only used in like two places, so we can just check for the +// commandline window using an identifier we know is contained in it, and then format our own window +// display. :D --air void pxMessageOutputMessageBox::Printf(const wxChar* format, ...) { using namespace pxSizerFlags; @@ -287,14 +293,16 @@ void pxMessageOutputMessageBox::Printf(const wxChar* format, ...) out.PrintfV(format, args); va_end(args); - int pos = out.Find( L"[IsoFile]" ); + FastFormatUnicode isoFormatted; + isoFormatted.Write( L"[%s]", _("IsoFile") ); + int pos = out.Find( isoFormatted ); if(pos == wxNOT_FOUND) { Msgbox::Alert( out ); return; } - pos += 9; // strlen of [IsoFile] + pos += isoFormatted.Length(); wxDialogWithHelpers popup( NULL, AddAppName(_("%s Commandline Options")) ); popup.SetMinWidth( 640 ); @@ -307,8 +315,8 @@ void pxMessageOutputMessageBox::Printf(const wxChar* format, ...) wxTE_READONLY | wxTE_MULTILINE | wxTE_RICH2 | wxHSCROLL ); - traceArea->SetDefaultStyle( wxTextAttr( wxNullColour, wxNullColour, pxGetFixedFont() ) ); - traceArea->SetFont( pxGetFixedFont() ); + traceArea->SetDefaultStyle( wxTextAttr( wxNullColour, wxNullColour, pxGetFixedFont(9) ) ); + traceArea->SetFont( pxGetFixedFont(9) ); int fonty = traceArea->GetCharHeight(); @@ -669,13 +677,7 @@ void AppApplySettings( const AppConfig* oldconf ) if( (oldconf == NULL) || (oldconf->LanguageCode.CmpNoCase(g_Conf->LanguageCode)) ) { wxDoNotLogInThisScope please; - if( !i18n_SetLanguage( g_Conf->LanguageId, g_Conf->LanguageCode ) ) - { - if( !i18n_SetLanguage( wxLANGUAGE_DEFAULT ) ) - { - i18n_SetLanguage( wxLANGUAGE_ENGLISH_US ); - } - } + i18n_SetLanguage( g_Conf->LanguageId, g_Conf->LanguageCode ); } CorePlugins.SetSettingsFolder( GetSettingsFolder().ToString() ); diff --git a/pcsx2/gui/Dialogs/FirstTimeWizard.cpp b/pcsx2/gui/Dialogs/FirstTimeWizard.cpp index b279c300c2..0aff33070a 100644 --- a/pcsx2/gui/Dialogs/FirstTimeWizard.cpp +++ b/pcsx2/gui/Dialogs/FirstTimeWizard.cpp @@ -175,6 +175,8 @@ FirstTimeWizard::FirstTimeWizard( wxWindow* parent ) Connect( wxEVT_WIZARD_PAGE_CHANGED, wxWizardEventHandler (FirstTimeWizard::OnPageChanged) ); Connect( wxEVT_WIZARD_PAGE_CHANGING, wxWizardEventHandler (FirstTimeWizard::OnPageChanging) ); Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler (FirstTimeWizard::OnDoubleClicked) ); + + Connect( pxID_RestartWizard, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( FirstTimeWizard::OnRestartWizard ) ); } FirstTimeWizard::~FirstTimeWizard() throw() @@ -182,6 +184,12 @@ FirstTimeWizard::~FirstTimeWizard() throw() } +void FirstTimeWizard::OnRestartWizard( wxCommandEvent& evt ) +{ + EndModal( pxID_RestartWizard ); + evt.Skip(); +} + static void _OpenConsole() { g_Conf->ProgLogBox.Visible = true; diff --git a/pcsx2/gui/Dialogs/ModalPopups.h b/pcsx2/gui/Dialogs/ModalPopups.h index 73a97fc6a0..025e9abdce 100644 --- a/pcsx2/gui/Dialogs/ModalPopups.h +++ b/pcsx2/gui/Dialogs/ModalPopups.h @@ -21,8 +21,6 @@ #include -static const wxWindowID pxID_CUSTOM = wxID_LOWEST - 1; - class FirstTimeWizard : public wxWizard { typedef wxWizard _parent; @@ -71,6 +69,8 @@ protected: virtual void OnPageChanging( wxWizardEvent& evt ); virtual void OnPageChanged( wxWizardEvent& evt ); virtual void OnDoubleClicked( wxCommandEvent& evt ); + + void OnRestartWizard( wxCommandEvent& evt ); }; diff --git a/pcsx2/gui/Panels/ConfigurationPanels.h b/pcsx2/gui/Panels/ConfigurationPanels.h index 64e73ea678..8bd9d28b56 100644 --- a/pcsx2/gui/Panels/ConfigurationPanels.h +++ b/pcsx2/gui/Panels/ConfigurationPanels.h @@ -109,6 +109,9 @@ namespace Panels void Apply(); void AppStatusEvent_OnSettingsApplied(); + + protected: + void OnApplyLanguage_Clicked( wxCommandEvent& evt ); }; // -------------------------------------------------------------------------------------- diff --git a/pcsx2/gui/Panels/MiscPanelStuff.cpp b/pcsx2/gui/Panels/MiscPanelStuff.cpp index ebc109a42c..c9c1c19c28 100644 --- a/pcsx2/gui/Panels/MiscPanelStuff.cpp +++ b/pcsx2/gui/Panels/MiscPanelStuff.cpp @@ -113,26 +113,32 @@ Panels::LanguageSelectionPanel::LanguageSelectionPanel( wxWindow* parent ) i18n_EnumeratePackages( m_langs ); int size = m_langs.size(); - int cursel = 0; - ScopedArray compiled( size ); //, L"Compiled Language Names" ); - wxString configLangName( wxLocale::GetLanguageName( wxLANGUAGE_DEFAULT ) ); + ScopedArray compiled( size ); for( int i=0; iSetToolTip(_("Make this language my default right now!")); + *this += Label(_("Select a language:")) | pxMiddle; *this += 5; *this += m_picker | pxSizerFlags::StdSpace(); + *this += 5; + *this += applyButton | pxSizerFlags::StdSpace(); - m_picker->SetSelection( cursel ); - //AppStatusEvent_OnSettingsApplied(); + Connect( pxID_RestartWizard, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( LanguageSelectionPanel::OnApplyLanguage_Clicked ) ); + + m_picker->SetSelection( 0 ); // always default to System Default +} + +void Panels::LanguageSelectionPanel::OnApplyLanguage_Clicked( wxCommandEvent& evt ) +{ + evt.Skip(); + Apply(); } void Panels::LanguageSelectionPanel::Apply() @@ -145,22 +151,29 @@ void Panels::LanguageSelectionPanel::Apply() wxString sel( m_picker->GetString( m_picker->GetSelection() ) ); g_Conf->LanguageCode = L"default"; // use this if no matches found + g_Conf->LanguageId = wxLANGUAGE_DEFAULT; int size = m_langs.size(); for( int i=0; iLanguageCode = m_langs[i].canonicalName; - g_Conf->LanguageId = m_langs[i].wxLangId; + if( i18n_SetLanguage( m_langs[i].wxLangId, m_langs[i].canonicalName ) ) + { + g_Conf->LanguageCode = m_langs[i].canonicalName; + g_Conf->LanguageId = m_langs[i].wxLangId; + } break; } } + } void Panels::LanguageSelectionPanel::AppStatusEvent_OnSettingsApplied() { - if (m_picker) + if (m_picker) { + m_picker->SetSelection( 0 ); // always default to System Default + if (g_Conf->LanguageCode.IsEmpty()) g_Conf->LanguageCode = L"default"; diff --git a/pcsx2/gui/i18n.cpp b/pcsx2/gui/i18n.cpp index 56a29e4c29..1c3b65878e 100644 --- a/pcsx2/gui/i18n.cpp +++ b/pcsx2/gui/i18n.cpp @@ -67,8 +67,8 @@ LangPackEnumeration::LangPackEnumeration() if (sysLang == wxLANGUAGE_UNKNOWN) sysLang = wxLANGUAGE_ENGLISH_US; - if (const wxLanguageInfo* info = wxLocale::GetLanguageInfo( sysLang )) - englishName += L" [" + i18n_GetBetterLanguageName(info) + L"]"; + //if (const wxLanguageInfo* info = wxLocale::GetLanguageInfo( sysLang )) + // englishName += L" [" + i18n_GetBetterLanguageName(info) + L"]"; } static void i18n_DoPackageCheck( wxLanguage wxLangId, LangPackList& langs ) @@ -177,7 +177,7 @@ bool i18n_SetLanguage( wxLanguage wxLangId, const wxString& langCode ) if (!info) Console.Warning( "Invalid language identifier (wxID=%d)", wxLangId ); - if (!langCode.IsEmpty()) + if (!langCode.IsEmpty() && (langCode.CmpNoCase(L"default")!=0)) { info = wxLocale::FindLanguageInfo(langCode); if (!info) @@ -186,12 +186,14 @@ bool i18n_SetLanguage( wxLanguage wxLangId, const wxString& langCode ) } if (!info) return false; + if (wxGetLocale() && (info->Language == wxGetLocale()->GetLanguage())) return true; + ScopedPtr locale( new wxLocale(info->Language) ); if( !locale->IsOk() ) { Console.Warning( L"SetLanguage: '%s' [%s] is not supported by the operating system", - locale->GetLocale(), locale->GetCanonicalName().c_str() + i18n_GetBetterLanguageName(info).c_str(), locale->GetCanonicalName().c_str() ); return false; } @@ -205,10 +207,14 @@ bool i18n_SetLanguage( wxLanguage wxLangId, const wxString& langCode ) } // English/US is built in, so no need to load MO/PO files. - if( pxIsEnglish(wxLangId) ) return true; + if( pxIsEnglish(wxLangId) ) + { + locale.DetachPtr(); + return true; + } - Console.WriteLn( Color_StrongBlack, L"Loading language translation databases for '%s' [%s]", - wxLocale::GetLanguageName( locale->GetLanguage() ).c_str(), locale->GetCanonicalName().c_str() + Console.WriteLn( L"Loading language translation databases for '%s' [%s]", + i18n_GetBetterLanguageName(info).c_str(), locale->GetCanonicalName().c_str() ); static const wxChar* dictFiles[] = @@ -224,14 +230,14 @@ bool i18n_SetLanguage( wxLanguage wxLangId, const wxString& langCode ) if (!dictFiles[i]) continue; if (!locale->AddCatalog(dictFiles[i])) - Console.Indent().WriteLn(Color_StrongYellow, "%s not found -- translation dictionary may be incomplete.", dictFiles[i]); + Console.Indent().WriteLn(Color_StrongYellow, "%ls not found -- translation dictionary may be incomplete.", dictFiles[i]); else foundone = true; } if (!foundone) { - Console.Warning("SetLanguage: Requested translation is not implemented yet, using English."); + Console.Warning("SetLanguage: Requested translation is not implemented yet."); return false; }