From 21c022542fa71df577d52abb8dcee1eb53da694e Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Sun, 12 Dec 2010 07:43:21 +0000 Subject: [PATCH] Minor i18n-related bugfixes. * "Browse" option in recent iso menu should translate now. * Dialogs and config panels remember their positions more reliably (when using X or alt-F4 to close PCSX2, for example). * Preliminary language selector dialog (available in debug builds only). Will finish it up later. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4088 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Utilities/wxGuiTools.h | 2 ++ common/src/Utilities/wxHelpers.cpp | 9 +++++++-- pcsx2/gui/App.h | 1 + pcsx2/gui/AppInit.cpp | 2 -- pcsx2/gui/AppRes.cpp | 4 ++-- pcsx2/gui/Dialogs/ConfigurationDialog.h | 20 ++++++++++++++++++ pcsx2/gui/Dialogs/SysConfigDialog.cpp | 10 +++++++++ pcsx2/gui/MainFrame.cpp | 27 +++++++++++++++++++++++++ pcsx2/gui/MainFrame.h | 3 +++ pcsx2/gui/MainMenuClicks.cpp | 5 +++++ pcsx2/gui/i18n.cpp | 6 ++---- 11 files changed, 79 insertions(+), 10 deletions(-) diff --git a/common/include/Utilities/wxGuiTools.h b/common/include/Utilities/wxGuiTools.h index 51940ce6b1..1a07be0ff6 100644 --- a/common/include/Utilities/wxGuiTools.h +++ b/common/include/Utilities/wxGuiTools.h @@ -522,6 +522,7 @@ public: // -------------------------------------------------------------------------------------- class wxDialogWithHelpers : public wxDialog { + typedef wxDialog _parent; DECLARE_DYNAMIC_CLASS_NO_COPY(wxDialogWithHelpers) protected: @@ -541,6 +542,7 @@ public: virtual void SmartCenterFit(); virtual int ShowModal(); virtual bool Show( bool show=true ); + virtual bool Destroy(); // Must return the same thing as GetNameStatic; a name ideal for use in uniquely // identifying dialogs. (this version is the 'instance' version, which is called diff --git a/common/src/Utilities/wxHelpers.cpp b/common/src/Utilities/wxHelpers.cpp index d70d173c54..b032d31ba7 100644 --- a/common/src/Utilities/wxHelpers.cpp +++ b/common/src/Utilities/wxHelpers.cpp @@ -274,13 +274,13 @@ pxStaticText& wxDialogWithHelpers::Heading( const wxString& label ) return *new pxStaticHeading( this, label ); } -void wxDialogWithHelpers::OnCloseWindow( wxCloseEvent& evt ) +bool wxDialogWithHelpers::Destroy() { // Save the dialog position if the dialog is named... // FIXME : This doesn't get called if the app is exited by alt-f4'ing the main app window. // ... not sure how to fix that yet. I could register a list of open windows into wxAppWithHelpers // that systematically get closed. Seems like work, maybe later. --air - + if( wxConfigBase* cfg = IsIconized() ? NULL : wxConfigBase::Get( false ) ) { const wxString dlgName( GetDialogName() ); @@ -300,6 +300,11 @@ void wxDialogWithHelpers::OnCloseWindow( wxCloseEvent& evt ) } } + return _parent::Destroy(); +} + +void wxDialogWithHelpers::OnCloseWindow( wxCloseEvent& evt ) +{ if( !IsModal() ) Destroy(); evt.Skip(); } diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index a78094ce5f..d92e35e947 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -117,6 +117,7 @@ enum MenuIdentifiers MenuId_Config_AppSettings, MenuId_Config_GameDatabase, MenuId_Config_BIOS, + MenuId_Config_Language, // Plugin ID order is important. Must match the order in tbl_PluginInfo. MenuId_Config_GS, diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index 952d28882a..b6b5ab67ad 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -581,8 +581,6 @@ bool Pcsx2App::OnInit() InitDefaultGlobalAccelerators(); delete wxLog::SetActiveTarget( new pxLogConsole() ); - m_RecentIsoList = new RecentIsoList(); - #ifdef __WXMSW__ pxDwm_Load(); #endif diff --git a/pcsx2/gui/AppRes.cpp b/pcsx2/gui/AppRes.cpp index 0b98987759..2ecc32f317 100644 --- a/pcsx2/gui/AppRes.cpp +++ b/pcsx2/gui/AppRes.cpp @@ -80,13 +80,13 @@ pxAppResources::~pxAppResources() throw() {} wxMenu& Pcsx2App::GetRecentIsoMenu() { - pxAssert( !!m_RecentIsoList->Menu ); + if (!m_RecentIsoList) m_RecentIsoList = new RecentIsoList(); return *m_RecentIsoList->Menu; } RecentIsoManager& Pcsx2App::GetRecentIsoManager() { - pxAssert( !!m_RecentIsoList->Manager ); + if (!m_RecentIsoList) m_RecentIsoList = new RecentIsoList(); return *m_RecentIsoList->Manager; } diff --git a/pcsx2/gui/Dialogs/ConfigurationDialog.h b/pcsx2/gui/Dialogs/ConfigurationDialog.h index e12f36c637..09e652cdf8 100644 --- a/pcsx2/gui/Dialogs/ConfigurationDialog.h +++ b/pcsx2/gui/Dialogs/ConfigurationDialog.h @@ -89,6 +89,26 @@ namespace Dialogs virtual wxString& GetConfSettingsTabName() const { return g_Conf->SysSettingsTabName; } }; + // -------------------------------------------------------------------------------------- + // LanguageSelectionDialog + // -------------------------------------------------------------------------------------- + class LanguageSelectionDialog : public BaseConfigurationDialog + { + public: + virtual ~LanguageSelectionDialog() throw() {} + LanguageSelectionDialog(wxWindow* parent=NULL); + static wxString GetNameStatic() { return L"LanguageSelector"; } + wxString GetDialogName() const { return GetNameStatic(); } + + protected: + virtual wxString& GetConfSettingsTabName() const + { + pxFailDev("Language selector does not have a listbook or settings tab."); + static wxString fail; + return fail; + } + }; + // -------------------------------------------------------------------------------------- // McdConfigDialog // -------------------------------------------------------------------------------------- diff --git a/pcsx2/gui/Dialogs/SysConfigDialog.cpp b/pcsx2/gui/Dialogs/SysConfigDialog.cpp index 283a766ee8..a1979995db 100644 --- a/pcsx2/gui/Dialogs/SysConfigDialog.cpp +++ b/pcsx2/gui/Dialogs/SysConfigDialog.cpp @@ -106,3 +106,13 @@ Dialogs::ComponentsConfigDialog::ComponentsConfigDialog(wxWindow* parent) if( wxGetApp().Overrides.HasPluginsOverride() ) wxGetApp().PostMethod( CheckPluginsOverrides ); } + +Dialogs::LanguageSelectionDialog::LanguageSelectionDialog(wxWindow *parent) + : BaseConfigurationDialog( parent, AddAppName(_("Language Selector - %s")), 400 ) +{ + ScopedBusyCursor busy( Cursor_ReallyBusy ); + + *this += new Panels::LanguageSelectionPanel( this ) | pxCenter; + + wxDialogWithHelpers::AddOkCancel( NULL, false ); +} \ No newline at end of file diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index a797d6a216..bc52eca23b 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -61,6 +61,29 @@ void MainEmuFrame::UpdateIsoSrcSelection() // exists ? Path::GetFilename(g_Conf->CurrentIso).c_str() : _("Empty") ) ); } +bool MainEmuFrame::Destroy() +{ + // Sigh: wxWidgets doesn't issue Destroy() calls for children windows when the parent + // is destroyed (it just deletes them, quite suddenly). So let's do it for them, since + // our children have configuration stuff they like to do when they're closing. + + for ( + wxWindowList::const_iterator + i = wxTopLevelWindows.begin(), + end = wxTopLevelWindows.end(); + i != end; ++i + ) + { + wxTopLevelWindow * const win = wx_static_cast(wxTopLevelWindow *, *i); + if (win == this) continue; + if (win->GetParent() != this) continue; + + win->Destroy(); + } + + return _parent::Destroy(); +} + // ------------------------------------------------------------------------ // MainFrame OnEvent Handlers // ------------------------------------------------------------------------ @@ -157,6 +180,7 @@ void MainEmuFrame::ConnectMenus() ConnectMenu( MenuId_Config_AppSettings, Menu_WindowSettings_Click ); ConnectMenu( MenuId_Config_GameDatabase,Menu_GameDatabase_Click ); ConnectMenu( MenuId_Config_BIOS, Menu_SelectPluginsBios_Click ); + ConnectMenu( MenuId_Config_Language, Menu_Language_Click ); ConnectMenu( MenuId_Config_ResetAll, Menu_ResetAllSettings_Click ); ConnectMenu( MenuId_Config_Multitap0Toggle, Menu_MultitapToggle_Click ); @@ -424,7 +448,10 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) m_menuConfig.Append(MenuId_Config_McdSettings, _("&Memory cards") ); m_menuConfig.Append(MenuId_Config_BIOS, _("&Plugin/BIOS Selector") ); if (IsDebugBuild) + { m_menuConfig.Append(MenuId_Config_GameDatabase, _("Game Database Editor") ); + m_menuConfig.Append(MenuId_Config_Language, _("Language...") ); + } m_menuConfig.AppendSeparator(); diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h index fda813e5df..323eadc02d 100644 --- a/pcsx2/gui/MainFrame.h +++ b/pcsx2/gui/MainFrame.h @@ -145,6 +145,8 @@ public: void UpdateIsoSrcSelection(); void RemoveCdvdMenu(); void EnableMenuItem( int id, bool enable ); + + bool Destroy(); protected: void DoGiveHelp(const wxString& text, bool show); @@ -166,6 +168,7 @@ protected: void Menu_WindowSettings_Click(wxCommandEvent &event); void Menu_GSSettings_Click(wxCommandEvent &event); void Menu_SelectPluginsBios_Click(wxCommandEvent &event); + void Menu_Language_Click(wxCommandEvent &event); void Menu_ResetAllSettings_Click(wxCommandEvent &event); void Menu_IsoBrowse_Click(wxCommandEvent &event); diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 129266a6e5..eb398ce339 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -72,6 +72,11 @@ void MainEmuFrame::Menu_SelectPluginsBios_Click(wxCommandEvent &event) AppOpenDialog( this ); } +void MainEmuFrame::Menu_Language_Click(wxCommandEvent &event) +{ + //AppOpenDialog( this ); + LanguageSelectionDialog(this).ShowModal(); +} static void WipeSettings() { diff --git a/pcsx2/gui/i18n.cpp b/pcsx2/gui/i18n.cpp index 1c3b65878e..f52c4b9836 100644 --- a/pcsx2/gui/i18n.cpp +++ b/pcsx2/gui/i18n.cpp @@ -75,9 +75,6 @@ static void i18n_DoPackageCheck( wxLanguage wxLangId, LangPackList& langs ) { if( i18n_IsLegacyLanguageId( wxLangId ) ) return; - //if( !wxLocale::IsAvailable( wxLangId ) ) - // return; - // note: wx preserves the current locale for us, so creating a new locale and deleting // will not affect program status. ScopedPtr locale( new wxLocale( wxLangId, wxLOCALE_CONV_ENCODING ) ); @@ -86,7 +83,8 @@ static void i18n_DoPackageCheck( wxLanguage wxLangId, LangPackList& langs ) // matching logic, which will bypass the catalog loader for all english-based dialects, and // (wrongly) enumerate a bunch of locales that don't actually exist. - if( locale->IsOk() && locale->AddCatalog( L"pcsx2_Main", wxLANGUAGE_UNKNOWN, NULL ) ) + if ((locale->GetLanguage() == wxLANGUAGE_ENGLISH_US) || + (locale->IsOk() && locale->AddCatalog( L"pcsx2_Main", wxLANGUAGE_UNKNOWN, NULL )) ) langs.push_back( LangPackEnumeration( wxLangId ) ); }