From e6a201917aa6f7e39cedc29c89aeac6df61e1aee Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Fri, 14 May 2010 18:15:27 +0000 Subject: [PATCH] * Added Refresh button to the bios selector. * Added some brevity info to the Bios Selector screen during first time wizard. * NSIS: Added IsUserAdmin script; not used quite yet (see diff comments) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3004 96395faa-99c1-11dd-bbfe-3dabce05a288 --- nsis/IsUserAdmin.nsi | 53 ++++++++++++++++++++++++++ nsis/pcsx2_installer_script.nsi | 40 +++++++++++++------ pcsx2/gui/Dialogs/FirstTimeWizard.cpp | 10 +++++ pcsx2/gui/Panels/BiosSelectorPanel.cpp | 44 ++++++++++++--------- pcsx2/gui/Panels/ConfigurationPanels.h | 4 +- 5 files changed, 119 insertions(+), 32 deletions(-) create mode 100644 nsis/IsUserAdmin.nsi diff --git a/nsis/IsUserAdmin.nsi b/nsis/IsUserAdmin.nsi new file mode 100644 index 0000000000..fee1c81eb0 --- /dev/null +++ b/nsis/IsUserAdmin.nsi @@ -0,0 +1,53 @@ +; Author: Lilla (lilla@earthlink.net) 2003-06-13 +; function IsUserAdmin uses plugin \NSIS\PlusgIns\UserInfo.dll +; This function is based upon code in \NSIS\Contrib\UserInfo\UserInfo.nsi +; This function was tested under NSIS 2 beta 4 (latest CVS as of this writing). +; +; Usage: +; Call IsUserAdmin +; Pop $R0 ; at this point $R0 is "true" or "false" +; +Function IsUserAdmin + Push $R0 + Push $R1 + Push $R2 + + ClearErrors + UserInfo::GetName + IfErrors Win9x + Pop $R1 + UserInfo::GetAccountType + Pop $R2 + + StrCmp $R2 "Admin" 0 Continue + + ; Observation: I get here when running Win98SE. (Lilla) + ; The functions UserInfo.dll looks for are there on Win98 too, + ; but just don't work. So UserInfo.dll, knowing that admin isn't required + ; on Win98, returns admin anyway. (per kichik) + ; MessageBox MB_OK 'User "$R1" is in the Administrators group' + StrCpy $R0 "true" + Goto Done + + Continue: + ; You should still check for an empty string because the functions + ; UserInfo.dll looks for may not be present on Windows 95. (per kichik) + StrCmp $R2 "" Win9x + StrCpy $R0 "false" + ;MessageBox MB_OK 'User "$R1" is in the "$R2" group' + Goto Done + + Win9x: + ; comment/message below is by UserInfo.nsi author: + ; This one means you don't need to care about admin or + ; not admin because Windows 9x doesn't either + ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!" + StrCpy $R0 "true" + + Done: + ;MessageBox MB_OK 'User= "$R1" AccountType= "$R2" IsUserAdmin= "$R0"' + + Pop $R2 + Pop $R1 + Exch $R0 +FunctionEnd \ No newline at end of file diff --git a/nsis/pcsx2_installer_script.nsi b/nsis/pcsx2_installer_script.nsi index 5a5d9fa1f2..896ede3bb2 100644 --- a/nsis/pcsx2_installer_script.nsi +++ b/nsis/pcsx2_installer_script.nsi @@ -88,6 +88,19 @@ AllowRootDirInstall true XPStyle on +; [TODO] / FIXME !! +; We need to detect the user's accessibility mode in order to select the right shell context. If the +; user is an admin, Windows7 and Vista will DEFAULT to an "all" shell context (installing shortcuts for all +; users), even if we don't want it to (which causes the uninstaller to fail!) +; If the user is not an admin, setting Shell Context to all will cause the installer to fail because the +; user won't have permission enough to install it at all (sigh). +; +; Solution! Detect the user's permission level, and install accordingly. I've included a script to do +; the detection in IsUserAdmin.nsh (untested, dunno if it compiles with latest NSIS). Now we just +; need to include it and call it, etc. :) + +SetShellVarContext all + ; Request application privileges for Windows Vista (shouldn't be needed anymore! -- air) ;RequestExecutionLevel admin @@ -246,17 +259,15 @@ Section "DirectX Web Setup (recommended)" SEC_DIRECTX ;SectionIn RO - SetOutPath "$TEMP" - File "dxwebsetup.exe" - DetailPrint "Running DirectX Web Setup..." - ExecWait '"$TEMP\dxwebsetup.exe" /Q' $DirectXSetupError + SetOutPath "$TEMP" + File "dxwebsetup.exe" + DetailPrint "Running DirectX Web Setup..." + ExecWait '"$TEMP\dxwebsetup.exe" /Q' $DirectXSetupError DetailPrint "Finished DirectX Web Setup" - Delete "$TEMP\dxwebsetup.exe" - - SetOutPath "$INSTDIR" - -SectionEnd + Delete "$TEMP\dxwebsetup.exe" + +SectionEnd ;-------------------------------- @@ -276,9 +287,9 @@ Function .onInstSuccess FunctionEnd -; ------------------------------------------- -; Uninstaller Section -; ------------------------------------------- +; --------------------------------------------------- +; Uninstaller Section +; --------------------------------------------------- ; ------------------------------------- ; Safe directory deletion code. :) @@ -345,6 +356,11 @@ Section "Un.Basic Removal (removes only files installed by this package) ${APP_N Call un.removeShorties + ; Use $TEMP as the out dir when removing directories, since NSIS won't let us remove the + ; "current" directory. + + SetOutPath "$TEMP" + ; And remove the various install dir(s) but only if they're clean of user content: StrCpy $0 "$INSTDIR\patches" Call un.DeleteDirIfEmpty diff --git a/pcsx2/gui/Dialogs/FirstTimeWizard.cpp b/pcsx2/gui/Dialogs/FirstTimeWizard.cpp index 8c62fffb0c..e18c8a4f06 100644 --- a/pcsx2/gui/Dialogs/FirstTimeWizard.cpp +++ b/pcsx2/gui/Dialogs/FirstTimeWizard.cpp @@ -152,6 +152,16 @@ FirstTimeWizard::FirstTimeWizard( wxWindow* parent ) m_page_plugins += m_panel_PluginSel | StdExpand(); m_page_bios += m_panel_BiosSel | StdExpand(); + // Temporary tutorial message for the BIOS, needs proof-reading!! + m_page_bios += 12; + m_page_bios += new pxStaticHeading( &m_page_bios, + pxE( ".Wizard:Bios:Tutorial", + L"PCSX2 requires a *legal* copy of the PS2 BIOS in order to run games.\n" + L"You cannot use a copy obtained from a friend or the internet.\n" + L"You must dump the BIOS from your *own* Playstation 2 console." + ) + ); + // Assign page indexes as client data m_page_usermode .SetClientData( (void*)0 ); m_page_plugins .SetClientData( (void*)1 ); diff --git a/pcsx2/gui/Panels/BiosSelectorPanel.cpp b/pcsx2/gui/Panels/BiosSelectorPanel.cpp index f7daa63f7b..5866931117 100644 --- a/pcsx2/gui/Panels/BiosSelectorPanel.cpp +++ b/pcsx2/gui/Panels/BiosSelectorPanel.cpp @@ -24,6 +24,8 @@ #include #include +using namespace pxSizerFlags; + // ===================================================================================================== // BaseSelectorPanel // ===================================================================================================== @@ -84,23 +86,29 @@ void Panels::BaseSelectorPanel::OnFolderChanged( wxFileDirPickerEvent& evt ) // ===================================================================================================== Panels::BiosSelectorPanel::BiosSelectorPanel( wxWindow* parent, int idealWidth ) : BaseSelectorPanel( parent ) - , m_ComboBox( *new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_SORT | wxLB_NEEDED_SB ) ) - , m_FolderPicker( *new DirPickerPanel( this, FolderId_Bios, - _("BIOS Search Path:"), // static box label - _("Select folder with PS2 BIOS roms") // dir picker popup label - ) ) { if( idealWidth != wxDefaultCoord ) m_idealWidth = idealWidth; - m_ComboBox.SetFont( wxFont( m_ComboBox.GetFont().GetPointSize()+1, wxFONTFAMILY_MODERN, wxNORMAL, wxNORMAL, false, L"Lucida Console" ) ); - m_ComboBox.SetMinSize( wxSize( wxDefaultCoord, std::max( m_ComboBox.GetMinSize().GetHeight(), 96 ) ) ); + m_ComboBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_SORT | wxLB_NEEDED_SB ); + m_FolderPicker = new DirPickerPanel( this, FolderId_Bios, + _("BIOS Search Path:"), // static box label + _("Select folder with PS2 BIOS roms") // dir picker popup label + ); - m_FolderPicker.SetStaticDesc( _("Click the Browse button to select a different folder where PCSX2 will look for PS2 BIOS roms.") ); + m_ComboBox->SetFont( wxFont( m_ComboBox->GetFont().GetPointSize()+1, wxFONTFAMILY_MODERN, wxNORMAL, wxNORMAL, false, L"Lucida Console" ) ); + m_ComboBox->SetMinSize( wxSize( wxDefaultCoord, std::max( m_ComboBox->GetMinSize().GetHeight(), 96 ) ) ); + + m_FolderPicker->SetStaticDesc( _("Click the Browse button to select a different folder where PCSX2 will look for PS2 BIOS roms.") ); + + wxButton* refreshButton = new wxButton( this, wxID_ANY, _("Refresh list") ); *this += Text(_("Select a BIOS rom:")); - *this += m_ComboBox | pxSizerFlags::StdExpand(); - *this += 6; - *this += m_FolderPicker | pxSizerFlags::StdExpand(); + *this += m_ComboBox | StdExpand(); + *this += refreshButton | pxBorder(wxLEFT, StdPadding); + *this += 8; + *this += m_FolderPicker | StdExpand(); + + Connect( refreshButton->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BaseSelectorPanel::OnRefresh) ); } Panels::BiosSelectorPanel::~BiosSelectorPanel() throw () @@ -109,7 +117,7 @@ Panels::BiosSelectorPanel::~BiosSelectorPanel() throw () void Panels::BiosSelectorPanel::Apply() { - int sel = m_ComboBox.GetSelection(); + int sel = m_ComboBox->GetSelection(); if( sel == wxNOT_FOUND ) { throw Exception::CannotApplySettings( this, @@ -124,7 +132,7 @@ void Panels::BiosSelectorPanel::Apply() ); } - g_Conf->BaseFilenames.Bios = (*m_BiosList)[(int)m_ComboBox.GetClientData(sel)]; + g_Conf->BaseFilenames.Bios = (*m_BiosList)[(int)m_ComboBox->GetClientData(sel)]; } void Panels::BiosSelectorPanel::AppStatusEvent_OnSettingsApplied() @@ -139,8 +147,8 @@ bool Panels::BiosSelectorPanel::ValidateEnumerationStatus() // occurs during file enumeration. ScopedPtr bioslist( new wxArrayString() ); - if( m_FolderPicker.GetPath().Exists() ) - wxDir::GetAllFiles( m_FolderPicker.GetPath().ToString(), bioslist, L"*.*", wxDIR_FILES ); + if( m_FolderPicker->GetPath().Exists() ) + wxDir::GetAllFiles( m_FolderPicker->GetPath().ToString(), bioslist, L"*.*", wxDIR_FILES ); if( !m_BiosList || (*bioslist != *m_BiosList) ) validated = false; @@ -154,7 +162,7 @@ void Panels::BiosSelectorPanel::DoRefresh() { if( !m_BiosList ) return; - m_ComboBox.Clear(); + m_ComboBox->Clear(); wxFileName right( g_Conf->FullpathToBios() ); right.MakeAbsolute(); @@ -163,12 +171,12 @@ void Panels::BiosSelectorPanel::DoRefresh() { wxString description; if( !IsBIOS((*m_BiosList)[i], description) ) continue; - int sel = m_ComboBox.Append( description, (void*)i ); + int sel = m_ComboBox->Append( description, (void*)i ); wxFileName left( (*m_BiosList)[i] ); left.MakeAbsolute(); if( left == right ) - m_ComboBox.SetSelection( sel ); + m_ComboBox->SetSelection( sel ); } } diff --git a/pcsx2/gui/Panels/ConfigurationPanels.h b/pcsx2/gui/Panels/ConfigurationPanels.h index 3fa9aff610..a5406fa6f6 100644 --- a/pcsx2/gui/Panels/ConfigurationPanels.h +++ b/pcsx2/gui/Panels/ConfigurationPanels.h @@ -397,8 +397,8 @@ namespace Panels { protected: ScopedPtr m_BiosList; - wxListBox& m_ComboBox; - DirPickerPanel& m_FolderPicker; + wxListBox* m_ComboBox; + DirPickerPanel* m_FolderPicker; public: BiosSelectorPanel( wxWindow* parent, int idealWidth=wxDefaultCoord );