fixed the iso list refreshing (no more 10 times battalion wars shuffle :P ) and did some cleanup of the option to cache the iso's or not (which is now automatically anyway) and i see no reason why it should ever be optional o.O

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1062 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
daco65 2008-11-03 17:18:35 +00:00
parent caa9a0bf2b
commit 5507cc7b95
6 changed files with 55 additions and 242 deletions

View File

@ -73,7 +73,6 @@ void SConfig::SaveSettings()
ini.Set("Core", "DVDRoot", m_LocalCoreStartupParameter.m_strDVDRoot); ini.Set("Core", "DVDRoot", m_LocalCoreStartupParameter.m_strDVDRoot);
ini.Set("Core", "OptimizeQuantizers", m_LocalCoreStartupParameter.bOptimizeQuantizers); ini.Set("Core", "OptimizeQuantizers", m_LocalCoreStartupParameter.bOptimizeQuantizers);
ini.Set("Core", "EnableCheats", m_LocalCoreStartupParameter.bEnableCheats); ini.Set("Core", "EnableCheats", m_LocalCoreStartupParameter.bEnableCheats);
ini.Set("Core", "EnableIsoCache",m_LocalCoreStartupParameter.bEnableIsoCache);
ini.Set("Core", "SelectedLanguage", m_LocalCoreStartupParameter.SelectedLanguage); ini.Set("Core", "SelectedLanguage", m_LocalCoreStartupParameter.SelectedLanguage);
ini.Set("Core", "RunCompareServer", m_LocalCoreStartupParameter.bRunCompareServer); ini.Set("Core", "RunCompareServer", m_LocalCoreStartupParameter.bRunCompareServer);
ini.Set("Core", "RunCompareClient", m_LocalCoreStartupParameter.bRunCompareClient); ini.Set("Core", "RunCompareClient", m_LocalCoreStartupParameter.bRunCompareClient);
@ -131,7 +130,6 @@ void SConfig::LoadSettings()
ini.Get("Core", "DVDRoot", &m_LocalCoreStartupParameter.m_strDVDRoot); ini.Get("Core", "DVDRoot", &m_LocalCoreStartupParameter.m_strDVDRoot);
ini.Get("Core", "OptimizeQuantizers", &m_LocalCoreStartupParameter.bOptimizeQuantizers, true); ini.Get("Core", "OptimizeQuantizers", &m_LocalCoreStartupParameter.bOptimizeQuantizers, true);
ini.Get("Core", "EnableCheats", &m_LocalCoreStartupParameter.bEnableCheats, false); ini.Get("Core", "EnableCheats", &m_LocalCoreStartupParameter.bEnableCheats, false);
ini.Get("Core", "EnableIsoCache", &m_LocalCoreStartupParameter.bEnableIsoCache, false);
ini.Get("Core", "SelectedLanguage", &m_LocalCoreStartupParameter.SelectedLanguage, 0); ini.Get("Core", "SelectedLanguage", &m_LocalCoreStartupParameter.SelectedLanguage, 0);
ini.Get("Core", "RunCompareServer", &m_LocalCoreStartupParameter.bRunCompareServer, false); ini.Get("Core", "RunCompareServer", &m_LocalCoreStartupParameter.bRunCompareServer, false);
ini.Get("Core", "RunCompareClient", &m_LocalCoreStartupParameter.bRunCompareClient, false); ini.Get("Core", "RunCompareClient", &m_LocalCoreStartupParameter.bRunCompareClient, false);

View File

@ -36,7 +36,6 @@ EVT_CHECKBOX(ID_LOCKTHREADS, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_OPTIMIZEQUANTIZERS, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_OPTIMIZEQUANTIZERS, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_IDLESKIP, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_IDLESKIP, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_ENABLECHEATS, CConfigMain::CoreSettingsChanged) EVT_CHECKBOX(ID_ENABLECHEATS, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_ENABLEISOCACHE, CConfigMain::CoreSettingsChanged)
EVT_CHOICE(ID_GC_SRAM_LNG, CConfigMain::GCSettingsChanged) EVT_CHOICE(ID_GC_SRAM_LNG, CConfigMain::GCSettingsChanged)
EVT_CHOICE(ID_WII_BT_BAR, CConfigMain::WiiSettingsChanged) EVT_CHOICE(ID_WII_BT_BAR, CConfigMain::WiiSettingsChanged)
EVT_CHECKBOX(ID_WII_IPL_SSV, CConfigMain::WiiSettingsChanged) EVT_CHECKBOX(ID_WII_IPL_SSV, CConfigMain::WiiSettingsChanged)
@ -128,8 +127,6 @@ void CConfigMain::CreateGUIControls()
SkipIdle->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle); SkipIdle->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle);
EnableCheats = new wxCheckBox(GeneralPage, ID_ENABLECHEATS, wxT("Enable cheats"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); EnableCheats = new wxCheckBox(GeneralPage, ID_ENABLECHEATS, wxT("Enable cheats"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
EnableCheats->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats); EnableCheats->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats);
EnableIsoCache = new wxCheckBox(GeneralPage, ID_ENABLEISOCACHE, wxT("Enable Iso Caching"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
EnableIsoCache->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableIsoCache);
sbAdvanced = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Advanced Settings")); sbAdvanced = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Advanced Settings"));
AllwaysHLEBIOS = new wxCheckBox(GeneralPage, ID_ALLWAYS_HLEBIOS, wxT("HLE the BIOS all the time"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); AllwaysHLEBIOS = new wxCheckBox(GeneralPage, ID_ALLWAYS_HLEBIOS, wxT("HLE the BIOS all the time"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
@ -145,7 +142,6 @@ void CConfigMain::CreateGUIControls()
sbBasic->Add(UseDualCore, 0, wxALL, 5); sbBasic->Add(UseDualCore, 0, wxALL, 5);
sbBasic->Add(SkipIdle, 0, wxALL, 5); sbBasic->Add(SkipIdle, 0, wxALL, 5);
sbBasic->Add(EnableCheats, 0, wxALL, 5); sbBasic->Add(EnableCheats, 0, wxALL, 5);
sbBasic->Add(EnableIsoCache, 0, wxALL,5);
sGeneral->Add(sbBasic, 0, wxEXPAND|wxALL, 5); sGeneral->Add(sbBasic, 0, wxEXPAND|wxALL, 5);
sGeneral->AddStretchSpacer(); sGeneral->AddStretchSpacer();
@ -371,9 +367,6 @@ void CConfigMain::CoreSettingsChanged(wxCommandEvent& event)
case ID_ENABLECHEATS: case ID_ENABLECHEATS:
SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats = EnableCheats->IsChecked(); SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats = EnableCheats->IsChecked();
break; break;
case ID_ENABLEISOCACHE:
SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableIsoCache = EnableIsoCache->IsChecked();
break;
} }
} }

View File

@ -84,7 +84,6 @@ class CConfigMain
wxCheckBox* OptimizeQuantizers; wxCheckBox* OptimizeQuantizers;
wxCheckBox* SkipIdle; wxCheckBox* SkipIdle;
wxCheckBox* EnableCheats; wxCheckBox* EnableCheats;
wxCheckBox* EnableIsoCache;
wxArrayString arrayStringFor_GCSystemLang; wxArrayString arrayStringFor_GCSystemLang;
wxStaticText* GCSystemLangText; wxStaticText* GCSystemLangText;
wxChoice* GCSystemLang; wxChoice* GCSystemLang;

View File

@ -169,8 +169,9 @@ CFrame::CFrame(wxFrame* parent,
CPluginManager::GetInstance().ScanForPlugins(this); CPluginManager::GetInstance().ScanForPlugins(this);
m_GameListCtrl->Update(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableIsoCache); //if we are ever going back to optional iso caching:
//m_GameListCtrl->Update(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableIsoCache);
m_GameListCtrl->Update();
//sizerPanel->SetSizeHints(m_Panel); //sizerPanel->SetSizeHints(m_Panel);
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN,
@ -447,7 +448,7 @@ void CFrame::OnRefresh(wxCommandEvent& WXUNUSED (event))
{ {
if (m_GameListCtrl) if (m_GameListCtrl)
{ {
m_GameListCtrl->Update(false); m_GameListCtrl->Update();
} }
} }
@ -457,7 +458,7 @@ void CFrame::OnConfigMain(wxCommandEvent& WXUNUSED (event))
CConfigMain ConfigMain(this); CConfigMain ConfigMain(this);
ConfigMain.ShowModal(); ConfigMain.ShowModal();
if (ConfigMain.bRefreshList) if (ConfigMain.bRefreshList)
m_GameListCtrl->Update(false); m_GameListCtrl->Update();
} }

View File

@ -116,11 +116,11 @@ void CGameListCtrl::BrowseForDirectory()
std::string(dialog.GetPath().ToAscii()) std::string(dialog.GetPath().ToAscii())
); );
SConfig::GetInstance().SaveSettings(); SConfig::GetInstance().SaveSettings();
Update(false); Update();
} }
} }
void CGameListCtrl::Update(bool loadcache) void CGameListCtrl::Update()
{ {
if (m_imageListSmall) if (m_imageListSmall)
{ {
@ -130,7 +130,7 @@ void CGameListCtrl::Update(bool loadcache)
Hide(); Hide();
ScanForISOs(loadcache); ScanForISOs();
ClearAll(); ClearAll();
@ -332,236 +332,58 @@ void CGameListCtrl::SetBackgroundColor()
} }
} }
void CGameListCtrl::ScanForISOs(bool loadcache) void CGameListCtrl::ScanForISOs()
{ {
#if 0
FILE * cacheFile;
bool scanISO = true;
if (loadcache)
{
scanISO = false;
if ((cacheFile = fopen("DolphinWx.cache", "rb")) == NULL)
{
scanISO = true;
if ((cacheFile = fopen("DolphinWx.cache", "wb")) == NULL)
{
PanicAlert("Unable to make or open the dolphin iso cache: is the directory write protected?");
}
}
}
else
{
if ((cacheFile = fopen("DolphinWx.cache", "wb")) == NULL)
{
// Normally the file should be made when it is opened so if it can't open the file it's
// write protected or something is stopping us from writing
PanicAlert("Unable to make or open the dolphin iso cache: is the directory write protected?");
}
}
m_ISOFiles.clear(); m_ISOFiles.clear();
CFileSearch::XStringVector Directories(SConfig::GetInstance().m_ISOFolder);
if (!scanISO) CFileSearch::XStringVector Extensions;
Extensions.push_back("*.iso");
Extensions.push_back("*.gcm");
Extensions.push_back("*.gcz");
CFileSearch FileSearch(Extensions, Directories);
const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();
if (rFilenames.size() > 0)
{ {
// TODO: complete cache loading here. this means ADDING THE BANNER >_< wxProgressDialog dialog(_T("Scanning for ISOs"),
char buffer[257]; _T("Scanning..."),
char temp[257]; rFilenames.size(), // range
std::string filename = " "; this, // parent
GameListItem ISOFile(filename.c_str()); wxPD_APP_MODAL |
// Looping every line of the file // wxPD_AUTO_HIDE | -- try this as well
while (fgets(buffer, 256, cacheFile) != NULL) wxPD_ELAPSED_TIME |
wxPD_ESTIMATED_TIME |
wxPD_REMAINING_TIME |
wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small
);
dialog.CenterOnParent();
for (u32 i = 0; i < rFilenames.size(); i++)
{ {
strncpy(temp, "", 257); std::string FileName;
int i = 0; SplitPath(rFilenames[i], NULL, &FileName, NULL);
switch (buffer[0])
{
/*
! = file name
I = Game ID
N = Game Name
D = Description
C = Country
O = company
S = file size
V = Volume Size
*/
case '!':
while (i < 256)
{
if (buffer[1+i] != '\n')
temp[i] = buffer[1+i];
i++;
}
filename = temp;
ISOFile.m_FileName = filename.c_str();
break;
case 'I':
memcpy(temp, &buffer[1], 6);
ISOFile.m_UniqueID = temp;
break;
case 'N':
while (i < 257)
{
if (buffer[1+i] != '\n')
temp[i] = buffer[1+i];
i++;
}
ISOFile.m_Name = temp;
break;
case 'D':
while (i < 257)
{
if (buffer[1+i] != '\n')
temp[i] = buffer[1+i];
i++;
}
ISOFile.m_Description = temp;
break;
case 'O':
while (i < 257)
{
if (buffer[1+i] != '\n')
temp[i] = buffer[1+i];
i++;
}
ISOFile.m_Company = temp;
break;
case 'C':
memcpy(temp, &buffer[1], 3);
ISOFile.m_Country = (DiscIO::IVolume::ECountry) atoi(temp);
break;
case 'S':
memcpy(temp, &buffer[1], 11);
ISOFile.m_FileSize = atoll(temp);
break;
case 'V':
memcpy(temp, &buffer[1], 11);
ISOFile.m_VolumeSize = atoll(temp);
break;
case 'B':
memcpy(temp, &buffer[1], 1);
if (temp[0] == '1')
ISOFile.m_BlobCompressed = true;
else if (temp[0] == '0')
ISOFile.m_BlobCompressed = false;
else
PanicAlert("unknown Compressed value %c", temp[1]);
break;
case '$':
if (ISOFile.GetFileName().c_str() != NULL)
{
// TODO: it would be good to check if the iso is valid but this would mean adding
// the banner cache and fixing the ISOFile declaration to have the right file name
// from the start (not " " but the Filename from the '!' case)
/*
if (ISOFile.IsValid())
{
//PanicAlert("pushing %s in stack...",ISOFile.GetFileName().c_str());
m_ISOFiles.push_back(ISOFile);
}
else
PanicAlert("Invalid ISO file %s", ISOFile.GetFileName().c_str());
*/
// TODO: stick the banners in 1 file ;_;
strcpy(temp, "GameIni\\");
strcpy(&temp[8], ISOFile.GetUniqueID().c_str());
strcpy(&temp[14], ".png");
if (fopen(temp, "rb"))
{
ISOFile.m_Image.LoadFile(temp, wxBITMAP_TYPE_PNG);
}
else
{
// Don't worry about it, the no_banner_png was saved before.
}
m_ISOFiles.push_back(ISOFile); wxString msg;
} char tempstring[128];
break; sprintf(tempstring,"Scanning %s", FileName.c_str());
default: msg = wxString::FromAscii(tempstring);
PanicAlert("Unknown Cache line Found:\n%s", buffer);
break;
}
}
}
else
#endif
{ bool Cont = dialog.Update(i, msg);
CFileSearch::XStringVector Directories(SConfig::GetInstance().m_ISOFolder);
CFileSearch::XStringVector Extensions; if (!Cont)
Extensions.push_back("*.iso");
Extensions.push_back("*.gcm");
Extensions.push_back("*.gcz");
CFileSearch FileSearch(Extensions, Directories);
const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();
if (rFilenames.size() > 0)
{
wxProgressDialog dialog(_T("Scanning for ISOs"),
_T("Scanning..."),
rFilenames.size(), // range
this, // parent
wxPD_APP_MODAL |
// wxPD_AUTO_HIDE | -- try this as well
wxPD_ELAPSED_TIME |
wxPD_ESTIMATED_TIME |
wxPD_REMAINING_TIME |
wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small
);
dialog.CenterOnParent();
for (u32 i = 0; i < rFilenames.size(); i++)
{ {
std::string FileName; break;
SplitPath(rFilenames[i], NULL, &FileName, NULL);
wxString msg;
char tempstring[128];
sprintf(tempstring,"Scanning %s", FileName.c_str());
msg = wxString::FromAscii(tempstring);
bool Cont = dialog.Update(i, msg);
if (!Cont)
{
break;
}
GameListItem ISOFile(rFilenames[i]);
if (ISOFile.IsValid())
{
#if 0
if(cacheFile)
{
fseek(cacheFile, 0L, SEEK_END);
fprintf(cacheFile, "!%s\nI%s\nN%s\nD%s\nC%u\nO%s\nS%llu\nV%llu\nB%u\n$\n",
ISOFile.GetFileName().c_str(),
ISOFile.GetUniqueID().c_str(),
ISOFile.GetName().c_str(),
ISOFile.GetDescription().c_str(),
ISOFile.GetCountry(),
ISOFile.GetCompany().c_str(),
ISOFile.GetFileSize(),
ISOFile.GetVolumeSize(),
ISOFile.IsCompressed());
ISOFile.m_Image.SaveFile("GameIni\\" + ISOFile.GetUniqueID() + ".png", wxBITMAP_TYPE_PNG);//".JPG",wxBITMAP_TYPE_JPEG);
// TODO: add the banner saving TO 1 FILE AND JPG as well & make the cache MUCH better.
// This is ugly as fuck
}
#endif 0
m_ISOFiles.push_back(ISOFile);
}
else
PanicAlert("Invalid ISO file %s", rFilenames[i].c_str());
} }
GameListItem ISOFile(rFilenames[i]);
if (ISOFile.IsValid())
{
m_ISOFiles.push_back(ISOFile);
}
else
PanicAlert("Invalid ISO file %s", rFilenames[i].c_str());
} }
#if 0
fclose (cacheFile);
#endif
} }
std::sort(m_ISOFiles.begin(), m_ISOFiles.end()); std::sort(m_ISOFiles.begin(), m_ISOFiles.end());
} }
@ -754,7 +576,7 @@ void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event))
wxMessageBoxCaptionStr, wxYES_NO|wxICON_EXCLAMATION) == wxYES) wxMessageBoxCaptionStr, wxYES_NO|wxICON_EXCLAMATION) == wxYES)
{ {
File::Delete(iso->GetFileName().c_str()); File::Delete(iso->GetFileName().c_str());
Update(false); Update();
} }
} }
else else
@ -769,7 +591,7 @@ void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event))
const GameListItem *iso = GetSelectedISO(); const GameListItem *iso = GetSelectedISO();
File::Delete(iso->GetFileName().c_str()); File::Delete(iso->GetFileName().c_str());
} }
Update(false); Update();
} }
} }
} }
@ -858,7 +680,7 @@ void CGameListCtrl::CompressSelection(bool _compress)
} }
m_currentItem++; m_currentItem++;
} }
Update(false); Update();
} }
void CGameListCtrl::CompressCB(const char* text, float percent, void* arg) void CGameListCtrl::CompressCB(const char* text, float percent, void* arg)
@ -937,7 +759,7 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
else else
DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), path.char_str(), 0, 16384, &CompressCB, &dialog); DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), path.char_str(), 0, 16384, &CompressCB, &dialog);
Update(false); Update();
} }
void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event)) void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))

View File

@ -31,7 +31,7 @@ public:
CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style); CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
~CGameListCtrl(); ~CGameListCtrl();
void Update(bool loadcache); void Update();
void BrowseForDirectory(); void BrowseForDirectory();
const GameListItem *GetSelectedISO(); const GameListItem *GetSelectedISO();
const GameListItem *GetISO(int index) const; const GameListItem *GetISO(int index) const;
@ -59,7 +59,7 @@ private:
void InitBitmaps(); void InitBitmaps();
void InsertItemInReportView(long _Index); void InsertItemInReportView(long _Index);
void SetBackgroundColor(); void SetBackgroundColor();
void ScanForISOs(bool loadcache); void ScanForISOs();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()