* Fixed command line help display for non-english (invoked via --help)
 * Startup/wizard now uses default operating system language when possible.
 * Added a language 'Apply' button to the first time wizard, which applies new translations immediately.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4082 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-12-11 01:03:10 +00:00
parent 41fc6feaf7
commit 6f289bedaf
8 changed files with 100 additions and 48 deletions

View File

@ -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.

View File

@ -70,12 +70,29 @@ void Pcsx2App::WipeUserModeSettings()
usermodefile.SetPath( usrlocaldir.ToString() );
ScopedPtr<wxFileConfig> 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!");

View File

@ -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() );

View File

@ -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;

View File

@ -21,8 +21,6 @@
#include <wx/wizard.h>
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 );
};

View File

@ -109,6 +109,9 @@ namespace Panels
void Apply();
void AppStatusEvent_OnSettingsApplied();
protected:
void OnApplyLanguage_Clicked( wxCommandEvent& evt );
};
// --------------------------------------------------------------------------------------

View File

@ -113,26 +113,32 @@ Panels::LanguageSelectionPanel::LanguageSelectionPanel( wxWindow* parent )
i18n_EnumeratePackages( m_langs );
int size = m_langs.size();
int cursel = 0;
ScopedArray<wxString> compiled( size ); //, L"Compiled Language Names" );
wxString configLangName( wxLocale::GetLanguageName( wxLANGUAGE_DEFAULT ) );
ScopedArray<wxString> compiled( size );
for( int i=0; i<size; ++i )
{
compiled[i].Printf( L"%s", m_langs[i].englishName.c_str() ); //, xltNames[i].c_str() );
if( m_langs[i].englishName == configLangName )
cursel = i;
}
compiled[i].Printf( L"%s", m_langs[i].englishName.c_str() );
m_picker = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
size, compiled.GetPtr(), wxCB_READONLY | wxCB_SORT );
wxButton* applyButton = new wxButton( this, pxID_RestartWizard, _("Apply") );
applyButton->SetToolTip(_("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; i<size; ++i )
{
if( m_langs[i].englishName == sel )
{
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)
{
m_picker->SetSelection( 0 ); // always default to System Default
if (g_Conf->LanguageCode.IsEmpty())
g_Conf->LanguageCode = L"default";

View File

@ -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<wxLocale> 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;
}