From 5708e14a0e3b63e50fdbc3f15b2cd9377869f7a3 Mon Sep 17 00:00:00 2001
From: Shawn Hoffman <godisgovernment@gmail.com>
Date: Mon, 19 Jan 2009 01:30:54 +0000
Subject: [PATCH] don't fool with sysconf if you're booting a gc game, and add
 back ability to double click on initial gamelistitem in order to add a
 GCMPath.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1922 8ced0084-cf51-0410-be5f-012b33b47a6e
---
 Source/Core/DolphinWX/Src/BootManager.cpp  | 81 +++++++++++-----------
 Source/Core/DolphinWX/Src/GameListCtrl.cpp | 25 +++++--
 2 files changed, 61 insertions(+), 45 deletions(-)

diff --git a/Source/Core/DolphinWX/Src/BootManager.cpp b/Source/Core/DolphinWX/Src/BootManager.cpp
index 4118aab853..aa023e05df 100644
--- a/Source/Core/DolphinWX/Src/BootManager.cpp
+++ b/Source/Core/DolphinWX/Src/BootManager.cpp
@@ -141,54 +141,57 @@ bool BootCore(const std::string& _rFilename)
 		ini.Get("Core", "OptimizeQuantizers", &StartUp.bOptimizeQuantizers, StartUp.bOptimizeQuantizers);
 		ini.Get("Core", "TLBHack", &StartUp.iTLBHack, StartUp.iTLBHack);
 
-		// ------------------------------------------------
-		// Update SYSCONF with game specific settings
-		// ----------------
-		bool bEnableProgressiveScan, bEnableWideScreen;
-		//bRefreshList = false;
-		FILE* pStream; // file handle
-		u8 m_SYSCONF[0x4000]; // SYSCONF file
-		u16 IPL_PGS = 0x17CC; // pregressive scan
-		u16 IPL_AR = 0x04D9; // widescreen
-		std::string FullSYSCONFPath = FULL_WII_USER_DIR "shared2/sys/SYSCONF";
-
-		// Load Wii SYSCONF
-		pStream = NULL;
-		pStream = fopen(FullSYSCONFPath.c_str(), "rb");
-		if (pStream != NULL)
+		if (StartUp.bWii)
 		{
-			fread(m_SYSCONF, 1, 0x4000, pStream);
-			fclose(pStream);
+			// ------------------------------------------------
+			// Update SYSCONF with game specific settings
+			// ----------------
+			bool bEnableProgressiveScan, bEnableWideScreen;
+			//bRefreshList = false;
+			FILE* pStream; // file handle
+			u8 m_SYSCONF[0x4000]; // SYSCONF file
+			u16 IPL_PGS = 0x17CC; // pregressive scan
+			u16 IPL_AR = 0x04D9; // widescreen
+			std::string FullSYSCONFPath = FULL_WII_USER_DIR "shared2/sys/SYSCONF";
 
-			//wxMessageBox(wxString::Format(": %02x", m_SYSCONF[IPL_AR]));
-
-			ini.Get("Core", "EnableProgressiveScan", &bEnableProgressiveScan, m_SYSCONF[IPL_PGS] != 0);
-			ini.Get("Core", "EnableWideScreen", &bEnableWideScreen, m_SYSCONF[IPL_AR] != 0);
-
-			m_SYSCONF[IPL_PGS] = bEnableProgressiveScan;
-			m_SYSCONF[IPL_AR] = bEnableWideScreen;
-
-			//wxMessageBox(wxString::Format(": %02x", m_SYSCONF[IPL_AR]));
-
-			// Enable custom Wii SYSCONF settings by saving the file to shared2
+			// Load Wii SYSCONF
 			pStream = NULL;
-			pStream = fopen(FullSYSCONFPath.c_str(), "wb");
+			pStream = fopen(FullSYSCONFPath.c_str(), "rb");
 			if (pStream != NULL)
 			{
-				fwrite(m_SYSCONF, 1, 0x4000, pStream);
+				fread(m_SYSCONF, 1, 0x4000, pStream);
 				fclose(pStream);
-			}	
+
+				//wxMessageBox(wxString::Format(": %02x", m_SYSCONF[IPL_AR]));
+
+				ini.Get("Core", "EnableProgressiveScan", &bEnableProgressiveScan, m_SYSCONF[IPL_PGS] != 0);
+				ini.Get("Core", "EnableWideScreen", &bEnableWideScreen, m_SYSCONF[IPL_AR] != 0);
+
+				m_SYSCONF[IPL_PGS] = bEnableProgressiveScan;
+				m_SYSCONF[IPL_AR] = bEnableWideScreen;
+
+				//wxMessageBox(wxString::Format(": %02x", m_SYSCONF[IPL_AR]));
+
+				// Enable custom Wii SYSCONF settings by saving the file to shared2
+				pStream = NULL;
+				pStream = fopen(FullSYSCONFPath.c_str(), "wb");
+				if (pStream != NULL)
+				{
+					fwrite(m_SYSCONF, 1, 0x4000, pStream);
+					fclose(pStream);
+				}	
+				else
+				{
+					PanicAlert("Could not write to %s", FullSYSCONFPath.c_str());
+				}	
+
+			}
 			else
 			{
-				PanicAlert("Could not write to %s", FullSYSCONFPath.c_str());
-			}	
-			
+				PanicAlert("Could not read %s", FullSYSCONFPath.c_str());
+			}
+			// ---------
 		}
-		else
-		{
-			PanicAlert("Could not read %s", FullSYSCONFPath.c_str());
-		}
-		// ---------
 	}
 	// ==============
 
diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp
index 061dd30ef8..bf425275e7 100644
--- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp
+++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp
@@ -106,7 +106,7 @@ void CGameListCtrl::BrowseForDirectory()
 	wxGetHomeDir(&dirHome);
 
 	// browse
-	wxDirDialog dialog(this, _("Browse directory"), dirHome, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
+	wxDirDialog dialog(this, _("Browse for a directory to add"), dirHome, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
 
 	if (dialog.ShowModal() == wxID_OK)
 	{
@@ -549,15 +549,28 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
 
 const GameListItem * CGameListCtrl::GetSelectedISO()
 {
-	long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); 
-	if (item == -1)
+	if (m_ISOFiles.size() == 0)
+	{
+		// There are no detected games, so add a GCMPath
+		BrowseForDirectory();
 		return 0;
+	}
 	else
 	{
-		if (GetSelectedItemCount() > 1)
-			SetItemState(item, 0, wxLIST_STATE_SELECTED);
+		long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); 
+		if (item == -1) // -1 means the selection is bogus, not a gamelistitem
+			return 0;
+		else
+		{
+			// Here is a little workaround for multiselections:
+			// when > 1 item is selected, return info on the first one
+			// and deselect it so the next time GetSelectedISO() is called,
+			// the next item's info is returned
+			if (GetSelectedItemCount() > 1)
+				SetItemState(item, 0, wxLIST_STATE_SELECTED);
 
-		return &m_ISOFiles[GetItemData(item)];
+			return &m_ISOFiles[GetItemData(item)];
+		}
 	}
 }