diff --git a/src/gtk/directoriesconfig.cpp b/src/gtk/directoriesconfig.cpp index adff4e2b..28f3a50d 100644 --- a/src/gtk/directoriesconfig.cpp +++ b/src/gtk/directoriesconfig.cpp @@ -30,6 +30,7 @@ const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] = { "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" }, { "gb_roms", N_("GB roms :"), "GBRomsDirEntry" }, { "batteries", N_("Batteries :"), "BatteriesDirEntry" }, + { "cheats", N_("Cheats :"), "CheatsDirEntry" }, { "saves", N_("Saves :"), "SavesDirEntry" }, { "captures", N_("Captures :"), "CapturesDirEntry" } }; diff --git a/src/gtk/directoriesconfig.h b/src/gtk/directoriesconfig.h index f1f4a2d9..74477842 100644 --- a/src/gtk/directoriesconfig.h +++ b/src/gtk/directoriesconfig.h @@ -47,7 +47,7 @@ private: Config::Section * m_poConfig; static const SDirEntry m_astDirs[]; - Gtk::FileChooserButton * m_poButtons[5]; + Gtk::FileChooserButton * m_poButtons[6]; }; } // namespace VBA diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 3daf24b1..96b0803a 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -504,6 +504,7 @@ void Window::vInitConfig() m_poDirConfig->vSetKey("gb_roms", Glib::get_home_dir()); m_poDirConfig->vSetKey("gba_roms", Glib::get_home_dir()); m_poDirConfig->vSetKey("batteries", m_sUserDataDir); + m_poDirConfig->vSetKey("cheats", m_sUserDataDir); m_poDirConfig->vSetKey("saves", m_sUserDataDir); m_poDirConfig->vSetKey("captures", m_sUserDataDir); @@ -588,6 +589,11 @@ void Window::vCheckConfig() { m_poDirConfig->vSetKey("batteries", m_sUserDataDir); } + sValue = m_poDirConfig->sGetKey("cheats"); + if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR)) + { + m_poDirConfig->vSetKey("cheats", m_sUserDataDir); + } sValue = m_poDirConfig->sGetKey("saves"); if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR)) { @@ -1078,6 +1084,7 @@ bool Window::bLoadROM(const std::string & _rsFile) } vLoadBattery(); + vLoadCheats(); vUpdateScreen(); emulating = 1; @@ -1342,6 +1349,30 @@ void Window::vLoadBattery() } } +void Window::vLoadCheats() +{ + std::string sCheats; + std::string sDir = m_poDirConfig->sGetKey("cheats"); + if (sDir == "") + { + sDir = m_sUserDataDir; + } + + sCheats = sDir + "/" + sCutSuffix(Glib::path_get_basename(m_sRomFile)) + ".clt"; + + if (Glib::file_test(sCheats, Glib::FILE_TEST_EXISTS)) + { + if (m_eCartridge == CartridgeGB) + { + gbCheatsLoadCheatList(sCheats.c_str()); + } + else if (m_eCartridge == CartridgeGBA) + { + cheatsLoadCheatList(sCheats.c_str()); + } + } +} + void Window::vSaveBattery() { std::string sBattery; @@ -1359,6 +1390,27 @@ void Window::vSaveBattery() } } +void Window::vSaveCheats() +{ + std::string sCheats; + std::string sDir = m_poDirConfig->sGetKey("cheats"); + if (sDir == "") + { + sDir = m_sUserDataDir; + } + + sCheats = sDir + "/" + sCutSuffix(Glib::path_get_basename(m_sRomFile)) + ".clt"; + + if (m_eCartridge == CartridgeGB) + { + gbCheatsSaveCheatList(sCheats.c_str()); + } + else if (m_eCartridge == CartridgeGBA) + { + cheatsSaveCheatList(sCheats.c_str()); + } +} + void Window::vStartEmu() { if (m_oEmuSig.connected()) diff --git a/src/gtk/window.h b/src/gtk/window.h index 2488ebfb..77652499 100644 --- a/src/gtk/window.h +++ b/src/gtk/window.h @@ -272,7 +272,9 @@ private: void vSetDefaultTitle(); void vCreateFileOpenDialog(); void vLoadBattery(); + void vLoadCheats(); void vSaveBattery(); + void vSaveCheats(); void vStartEmu(); void vStopEmu(); void vUpdateGameSlots(); diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp index 1380bffb..9396b99a 100644 --- a/src/gtk/windowcallbacks.cpp +++ b/src/gtk/windowcallbacks.cpp @@ -335,6 +335,7 @@ void Window::vOnFileClose() vSetDefaultTitle(); vDrawDefaultScreen(); vSaveBattery(); + vSaveCheats(); m_stEmulator.emuCleanUp(); m_eCartridge = CartridgeNone; emulating = 0;