/[pcsx2_0.9.7]/trunk/pcsx2/gui/Panels/MiscPanelStuff.cpp
ViewVC logotype

Contents of /trunk/pcsx2/gui/Panels/MiscPanelStuff.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 2 months ago) by william
File size: 6490 byte(s)
re-commit (had local access denied errors when committing)
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #include "PrecompiledHeader.h"
17 #include "App.h"
18 #include "ConfigurationPanels.h"
19
20 #include "Dialogs/ConfigurationDialog.h"
21
22 #include "ps2/BiosTools.h"
23
24 #include <wx/stdpaths.h>
25
26 using namespace Dialogs;
27 using namespace pxSizerFlags;
28
29 // --------------------------------------------------------------------------------------
30 // DocsFolderPickerPanel
31 // --------------------------------------------------------------------------------------
32 Panels::DocsFolderPickerPanel::DocsFolderPickerPanel( wxWindow* parent, bool isFirstTime )
33 : BaseApplicableConfigPanel( parent, wxVERTICAL, _("Usermode Selection") )
34 {
35 const wxString usermodeExplained( pxE( "!Panel:Usermode:Explained",
36 L"Please select your preferred default location for PCSX2 user-level documents below "
37 L"(includes memory cards, screenshots, settings, and savestates). "
38 L"These folder locations can be overridden at any time using the Core Settings panel."
39 ) );
40
41 const wxString usermodeWarning( pxE( "!Panel:Usermode:Warning",
42 L"You can change the preferred default location for PCSX2 user-level documents here "
43 L"(includes memory cards, screenshots, settings, and savestates). "
44 L"This option only affects Standard Paths which are set to use the installation default value."
45 ) );
46
47 const RadioPanelItem UsermodeOptions[] =
48 {
49 RadioPanelItem(
50 _("User Documents (recommended)"),
51 _("Location: ") + PathDefs::GetDocuments(DocsFolder_User).ToString()
52 ),
53
54 RadioPanelItem(
55 _("Custom folder:"),
56 wxEmptyString,
57 _("This setting may require administration privileges from your operating system, depending on how your system is configured.")
58 )
59 };
60
61 m_radio_UserMode = new pxRadioPanel( this, UsermodeOptions );
62 m_radio_UserMode->SetPaddingHoriz( m_radio_UserMode->GetPaddingVert() + 4 );
63 m_radio_UserMode->Realize();
64 if( pxStaticText* woot = m_radio_UserMode->GetSubText(0) ) woot->Unwrapped(); // wrapping sucks for path names!
65
66 m_dirpicker_custom = new DirPickerPanel( this, FolderId_Documents, AddAppName(_("Select a document root for %s")) );
67
68 *this += Heading( isFirstTime ? usermodeExplained : usermodeWarning );
69 *this += m_radio_UserMode | StdExpand();
70 *this += m_dirpicker_custom | pxExpand.Border( wxLEFT, StdPadding + m_radio_UserMode->GetIndentation() );
71 *this += 4;
72
73 Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(DocsFolderPickerPanel::OnRadioChanged) );
74 }
75
76 DocsModeType Panels::DocsFolderPickerPanel::GetDocsMode() const
77 {
78 return (DocsModeType) m_radio_UserMode->GetSelection();
79 }
80
81 void Panels::DocsFolderPickerPanel::Apply()
82 {
83 DocsFolderMode = (DocsModeType) m_radio_UserMode->GetSelection();
84 CustomDocumentsFolder = m_dirpicker_custom->GetPath();
85 }
86
87 void Panels::DocsFolderPickerPanel::AppStatusEvent_OnSettingsApplied()
88 {
89 if( m_radio_UserMode ) m_radio_UserMode->SetSelection( DocsFolderMode );
90 if( m_dirpicker_custom ) m_dirpicker_custom->Enable( DocsFolderMode == DocsFolder_Custom );
91 }
92
93 void Panels::DocsFolderPickerPanel::OnRadioChanged( wxCommandEvent& evt )
94 {
95 evt.Skip();
96
97 if( !m_radio_UserMode ) return;
98
99 if( m_dirpicker_custom )
100 m_dirpicker_custom->Enable( m_radio_UserMode->GetSelection() == (int)DocsFolder_Custom );
101
102 if( pxStaticText* woot = m_radio_UserMode->GetSubText(0) )
103 woot->Enable( m_radio_UserMode->GetSelection() == (int)DocsFolder_User );
104 }
105
106 // --------------------------------------------------------------------------------------
107 // LanguageSelectionPanel
108 // --------------------------------------------------------------------------------------
109 Panels::LanguageSelectionPanel::LanguageSelectionPanel( wxWindow* parent )
110 : BaseApplicableConfigPanel( parent, wxHORIZONTAL )
111 {
112 m_picker = NULL;
113 i18n_EnumeratePackages( m_langs );
114
115 int size = m_langs.size();
116 ScopedArray<wxString> compiled( size );
117
118 for( int i=0; i<size; ++i )
119 compiled[i].Printf( L"%s", m_langs[i].englishName.c_str() );
120
121 m_picker = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
122 size, compiled.GetPtr(), wxCB_READONLY | wxCB_SORT );
123
124 wxButton* applyButton = new wxButton( this, pxID_RestartWizard, _("Apply") );
125 applyButton->SetToolTip(_("Make this language my default right now!"));
126
127 *this += Label(_("Select a language:")) | pxMiddle;
128 *this += 5;
129 *this += m_picker | pxSizerFlags::StdSpace();
130 *this += 5;
131 *this += applyButton | pxSizerFlags::StdSpace();
132
133 Connect( pxID_RestartWizard, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( LanguageSelectionPanel::OnApplyLanguage_Clicked ) );
134
135 m_picker->SetSelection( 0 ); // always default to System Default
136 }
137
138 void Panels::LanguageSelectionPanel::OnApplyLanguage_Clicked( wxCommandEvent& evt )
139 {
140 evt.Skip();
141 Apply();
142 }
143
144 void Panels::LanguageSelectionPanel::Apply()
145 {
146 if( !m_picker ) return;
147
148 // The combo box's order is sorted and may not match our m_langs order, so
149 // we have to do a string comparison to find a match:
150
151 wxString sel( m_picker->GetString( m_picker->GetSelection() ) );
152
153 g_Conf->LanguageCode = L"default"; // use this if no matches found
154 g_Conf->LanguageId = wxLANGUAGE_DEFAULT;
155 int size = m_langs.size();
156 for( int i=0; i<size; ++i )
157 {
158 if( m_langs[i].englishName == sel )
159 {
160 if( i18n_SetLanguage( m_langs[i].wxLangId, m_langs[i].canonicalName ) )
161 {
162 g_Conf->LanguageCode = m_langs[i].canonicalName;
163 g_Conf->LanguageId = m_langs[i].wxLangId;
164 }
165 break;
166 }
167 }
168
169 }
170
171 void Panels::LanguageSelectionPanel::AppStatusEvent_OnSettingsApplied()
172 {
173 if (m_picker)
174 {
175 m_picker->SetSelection( 0 ); // always default to System Default
176
177 if (g_Conf->LanguageCode.IsEmpty())
178 g_Conf->LanguageCode = L"default";
179
180 for (uint i=0; i<m_langs.size(); ++i)
181 {
182 if (0==m_langs[i].canonicalName.CmpNoCase(g_Conf->LanguageCode))
183 {
184 m_picker->SetSelection( i );
185 }
186 }
187 }
188 }

  ViewVC Help
Powered by ViewVC 1.1.22