GTK: Apply patch #3524058 - Auto-load/save cheats
Thanks go to unmacaque git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1156 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
c872f0d625
commit
b5bcf0490c
|
@ -30,6 +30,7 @@ const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] =
|
||||||
{ "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" },
|
{ "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" },
|
||||||
{ "gb_roms", N_("GB roms :"), "GBRomsDirEntry" },
|
{ "gb_roms", N_("GB roms :"), "GBRomsDirEntry" },
|
||||||
{ "batteries", N_("Batteries :"), "BatteriesDirEntry" },
|
{ "batteries", N_("Batteries :"), "BatteriesDirEntry" },
|
||||||
|
{ "cheats", N_("Cheats :"), "CheatsDirEntry" },
|
||||||
{ "saves", N_("Saves :"), "SavesDirEntry" },
|
{ "saves", N_("Saves :"), "SavesDirEntry" },
|
||||||
{ "captures", N_("Captures :"), "CapturesDirEntry" }
|
{ "captures", N_("Captures :"), "CapturesDirEntry" }
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,7 @@ private:
|
||||||
|
|
||||||
Config::Section * m_poConfig;
|
Config::Section * m_poConfig;
|
||||||
static const SDirEntry m_astDirs[];
|
static const SDirEntry m_astDirs[];
|
||||||
Gtk::FileChooserButton * m_poButtons[5];
|
Gtk::FileChooserButton * m_poButtons[6];
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -504,6 +504,7 @@ void Window::vInitConfig()
|
||||||
m_poDirConfig->vSetKey("gb_roms", Glib::get_home_dir());
|
m_poDirConfig->vSetKey("gb_roms", Glib::get_home_dir());
|
||||||
m_poDirConfig->vSetKey("gba_roms", Glib::get_home_dir());
|
m_poDirConfig->vSetKey("gba_roms", Glib::get_home_dir());
|
||||||
m_poDirConfig->vSetKey("batteries", m_sUserDataDir);
|
m_poDirConfig->vSetKey("batteries", m_sUserDataDir);
|
||||||
|
m_poDirConfig->vSetKey("cheats", m_sUserDataDir);
|
||||||
m_poDirConfig->vSetKey("saves", m_sUserDataDir);
|
m_poDirConfig->vSetKey("saves", m_sUserDataDir);
|
||||||
m_poDirConfig->vSetKey("captures", m_sUserDataDir);
|
m_poDirConfig->vSetKey("captures", m_sUserDataDir);
|
||||||
|
|
||||||
|
@ -588,6 +589,11 @@ void Window::vCheckConfig()
|
||||||
{
|
{
|
||||||
m_poDirConfig->vSetKey("batteries", m_sUserDataDir);
|
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");
|
sValue = m_poDirConfig->sGetKey("saves");
|
||||||
if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR))
|
if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR))
|
||||||
{
|
{
|
||||||
|
@ -1078,6 +1084,7 @@ bool Window::bLoadROM(const std::string & _rsFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
vLoadBattery();
|
vLoadBattery();
|
||||||
|
vLoadCheats();
|
||||||
vUpdateScreen();
|
vUpdateScreen();
|
||||||
|
|
||||||
emulating = 1;
|
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()
|
void Window::vSaveBattery()
|
||||||
{
|
{
|
||||||
std::string sBattery;
|
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()
|
void Window::vStartEmu()
|
||||||
{
|
{
|
||||||
if (m_oEmuSig.connected())
|
if (m_oEmuSig.connected())
|
||||||
|
|
|
@ -272,7 +272,9 @@ private:
|
||||||
void vSetDefaultTitle();
|
void vSetDefaultTitle();
|
||||||
void vCreateFileOpenDialog();
|
void vCreateFileOpenDialog();
|
||||||
void vLoadBattery();
|
void vLoadBattery();
|
||||||
|
void vLoadCheats();
|
||||||
void vSaveBattery();
|
void vSaveBattery();
|
||||||
|
void vSaveCheats();
|
||||||
void vStartEmu();
|
void vStartEmu();
|
||||||
void vStopEmu();
|
void vStopEmu();
|
||||||
void vUpdateGameSlots();
|
void vUpdateGameSlots();
|
||||||
|
|
|
@ -335,6 +335,7 @@ void Window::vOnFileClose()
|
||||||
vSetDefaultTitle();
|
vSetDefaultTitle();
|
||||||
vDrawDefaultScreen();
|
vDrawDefaultScreen();
|
||||||
vSaveBattery();
|
vSaveBattery();
|
||||||
|
vSaveCheats();
|
||||||
m_stEmulator.emuCleanUp();
|
m_stEmulator.emuCleanUp();
|
||||||
m_eCartridge = CartridgeNone;
|
m_eCartridge = CartridgeNone;
|
||||||
emulating = 0;
|
emulating = 0;
|
||||||
|
|
Loading…
Reference in New Issue