static int LoadCheatsFiles(const wxDirName& folderName, wxString& fileSpec, const wxString& friendlyName) { if (!folderName.Exists()) { Console.WriteLn(Color_Red, L"The %s folder ('%s') is inaccessible. Skipping...", WX_STR(friendlyName), WX_STR(folderName.ToString())); return 0; } wxDir dir(folderName.ToString()); int before = cheatnumber; wxString buffer; wxTextFile f; bool found = dir.GetFirst(&buffer, L"*", wxDIR_FILES); while (found) { if (buffer.Upper().Matches(fileSpec.Upper())) { Console.WriteLn(Color_Gray, L"Found %s file: '%s'", WX_STR(friendlyName), WX_STR(buffer)); int before = cheatnumber; f.Open(Path::Combine(dir.GetName(), buffer)); inifile_process(f); f.Close(); int loaded = cheatnumber - before; Console.WriteLn((loaded ? Color_Green : Color_Gray), L"Loaded %d %s from '%s'", loaded, WX_STR(friendlyName), WX_STR(buffer)); } found = dir.GetNext(&buffer); } return cheatnumber - before; }
wxDirName wxDirName::Combine(const wxDirName &right) const { pxAssertMsg(IsDir() && right.IsDir(), L"Warning: Malformed directory name detected during wDirName concatenation."); wxDirName result(right); result.Normalize(wxPATH_NORM_ENV_VARS | wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE, GetPath()); return result; }
void IniLoader::Entry( const wxString& var, wxDirName& value, const wxDirName defvalue, bool isAllowRelative ) { wxString dest; if( m_Config ) m_Config->Read( var, &dest, wxEmptyString ); if( dest.IsEmpty() ) value = defvalue; else { value = dest; if( isAllowRelative ) value = g_fullBaseDirName + value; if( value.IsAbsolute() ) value.Normalize(); } }
void IniSaver::Entry( const wxString& var, wxFileName& value, const wxFileName defvalue, bool isAllowRelative ) { if( !m_Config ) return; wxFileName res(value); if ( res.IsAbsolute() ) res.Normalize(); if (isAllowRelative) res = wxDirName::MakeAutoRelativeTo( res, g_fullBaseDirName.ToString() ); m_Config->Write( var, res.GetFullPath() ); }
Dialogs::CreateMemoryCardDialog::CreateMemoryCardDialog( wxWindow* parent, uint slot, const wxDirName& mcdpath, const wxString& mcdfile ) : wxDialogWithHelpers( parent, _("Create new memory card") ) , m_mcdpath( mcdpath.IsOk() ? mcdpath : (wxDirName)g_Conf->Mcd[slot].Filename.GetPath() ) , m_mcdfile( mcdfile.IsEmpty() ? g_Conf->Mcd[slot].Filename.GetFullName() : mcdfile ) { SetMinWidth( 472 ); m_filepicker = NULL; m_slot = slot; CreateControls(); //m_filepicker = CreateMemoryCardFilePicker( this, m_port, m_slot, filepath ); // ---------------------------- // Sizers and Layout // ---------------------------- if( m_radio_CardSize ) m_radio_CardSize->Realize(); wxBoxSizer& s_buttons( *new wxBoxSizer(wxHORIZONTAL) ); s_buttons += new wxButton( this, wxID_OK, _("Create") ) | pxProportion(2); s_buttons += pxStretchSpacer(3); s_buttons += new wxButton( this, wxID_CANCEL ) | pxProportion(2); wxBoxSizer& s_padding( *new wxBoxSizer(wxVERTICAL) ); //s_padding += Heading(_("Select the size for your new memory card.")); if( m_filepicker ) s_padding += m_filepicker | StdExpand(); else { s_padding += Heading( _( "New card will be saved to:" ) ) | StdExpand(); s_padding += Heading( (m_mcdpath + m_mcdfile).GetFullPath() ).Unwrapped() | StdExpand(); } s_padding += m_radio_CardSize | StdExpand(); #ifdef __WXMSW__ if( m_check_CompressNTFS ) s_padding += m_check_CompressNTFS | StdExpand(); #endif s_padding += 12; s_padding += s_buttons | StdCenter(); *this += s_padding | StdExpand(); Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CreateMemoryCardDialog::OnOk_Click ) ); //Connect( wxID_APPLY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CreateMemoryCardDialog::OnApply_Click ) ); }
// This routine loads cheats from *.pnach files // Returns number of cheats loaded // Note: Should be called after InitPatches() int LoadCheats(wxString name, const wxDirName& folderName, const wxString& friendlyName) { int loaded = 0; int numberFoundCheatsFiles; wxString filespec = name + L"*.pnach"; loaded += LoadCheatsFiles(folderName, filespec, friendlyName, numberFoundCheatsFiles); // This message _might_ be buggy. This function (LoadCheats) loads from an explicit folder. // This folder can be cheats or cheats_ws at either the default location or a custom one. // This check only tests the default cheats folder, so the message it produces is possibly misleading. if (folderName.ToString().IsSameAs(PathDefs::GetCheats().ToString()) && numberFoundCheatsFiles == 0) { wxString pathName = Path::Combine(folderName, name.MakeUpper() + L".pnach"); PatchesCon->WriteLn(Color_Gray, L"Not found %s file: %s", WX_STR(friendlyName), WX_STR(pathName)); } PatchesCon->WriteLn((loaded ? Color_Green : Color_Gray), L"Overall %d %s loaded", loaded, WX_STR(friendlyName)); return loaded; }