GTK: Add GameBoy cheats support. Thanks to unmacaque for the patch.

This commit is contained in:
bgk 2011-02-25 17:56:10 +00:00
parent 2057f2b8d7
commit 5c61339992
7 changed files with 108 additions and 56 deletions

View File

@ -246,6 +246,7 @@ SET(SRC_GTK
src/gtk/gameboyadvanceconfig.cpp src/gtk/gameboyadvanceconfig.cpp
src/gtk/cheatlist.cpp src/gtk/cheatlist.cpp
src/gtk/cheatedit.cpp src/gtk/cheatedit.cpp
src/gtk/gameboycheatlist.cpp
src/gtk/joypadconfig.cpp src/gtk/joypadconfig.cpp
src/gtk/directoriesconfig.cpp src/gtk/directoriesconfig.cpp
src/gtk/displayconfig.cpp src/gtk/displayconfig.cpp

View File

@ -5,7 +5,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-02-24 17:56+0100\n" "POT-Creation-Date: 2011-02-25 18:50+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -13,23 +13,33 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: ../src/gtk/cheatedit.cpp:48 #: ../src/gtk/cheatedit.cpp:83
msgid "Generic Code" msgid "Generic Code"
msgstr "" msgstr ""
#: ../src/gtk/cheatedit.cpp:53 #: ../src/gtk/cheatedit.cpp:88
msgid "Gameshark Advance" msgid "Gameshark Advance"
msgstr "" msgstr ""
#: ../src/gtk/cheatedit.cpp:58 #: ../src/gtk/cheatedit.cpp:93
msgid "CodeBreaker Advance" msgid "CodeBreaker Advance"
msgstr "" msgstr ""
#: ../src/gtk/cheatlist.cpp:73 tmp/cheatlist.ui.h:5 #: ../src/gtk/cheatedit.cpp:103
msgid "GameShark"
msgstr ""
#: ../src/gtk/cheatedit.cpp:108
msgid "GameGenie"
msgstr ""
#: ../src/gtk/cheatlist.cpp:73 ../src/gtk/gameboycheatlist.cpp:73
#: tmp/cheatlist.ui.h:5
msgid "Open cheat list" msgid "Open cheat list"
msgstr "" msgstr ""
#: ../src/gtk/cheatlist.cpp:96 tmp/cheatlist.ui.h:6 #: ../src/gtk/cheatlist.cpp:96 ../src/gtk/gameboycheatlist.cpp:96
#: tmp/cheatlist.ui.h:6
msgid "Save cheat list" msgid "Save cheat list"
msgstr "" msgstr ""
@ -226,19 +236,19 @@ msgstr ""
msgid "<Undefined>" msgid "<Undefined>"
msgstr "" msgstr ""
#: ../src/gtk/main.cpp:42 ../src/gtk/windowcallbacks.cpp:496 #: ../src/gtk/main.cpp:41 ../src/gtk/windowcallbacks.cpp:506
msgid "VBA-M" msgid "VBA-M"
msgstr "" msgstr ""
#: ../src/gtk/main.cpp:51 #: ../src/gtk/main.cpp:50
msgid "Main VBA-M options" msgid "Main VBA-M options"
msgstr "" msgstr ""
#: ../src/gtk/main.cpp:56 #: ../src/gtk/main.cpp:55
msgid "Output version information." msgid "Output version information."
msgstr "" msgstr ""
#: ../src/gtk/main.cpp:82 #: ../src/gtk/main.cpp:81
#, c-format #, c-format
msgid "VisualBoyAdvance version %s [GTK+]\n" msgid "VisualBoyAdvance version %s [GTK+]\n"
msgstr "" msgstr ""
@ -248,92 +258,88 @@ msgstr ""
msgid "*** OpenGL : Cannot open display.\n" msgid "*** OpenGL : Cannot open display.\n"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:426 #: ../src/gtk/window.cpp:427
#, c-format #, c-format
msgid "Unable to initialize output, falling back to Cairo\n" msgid "Unable to initialize output, falling back to Cairo\n"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:467 #: ../src/gtk/window.cpp:468
#, c-format #, c-format
msgid "Failed to init SDL: %s" msgid "Failed to init SDL: %s"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:975 #: ../src/gtk/window.cpp:1021
#, c-format #, c-format
msgid "Unknown file type %s" msgid "Unknown file type %s"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:1114 #: ../src/gtk/window.cpp:1158
#, c-format #, c-format
msgid "VBA-M - %d%%" msgid "VBA-M - %d%%"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:1119 #: ../src/gtk/window.cpp:1163
#, c-format #, c-format
msgid "VBA-M - %d%% (%d, %d fps)" msgid "VBA-M - %d%% (%d, %d fps)"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:1221 #: ../src/gtk/window.cpp:1265
msgid "Open" msgid "Open"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:1256 #: ../src/gtk/window.cpp:1300
msgid "All Gameboy Advance files" msgid "All Gameboy Advance files"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:1263 #: ../src/gtk/window.cpp:1307
msgid "Gameboy Advance files" msgid "Gameboy Advance files"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:1270 #: ../src/gtk/window.cpp:1314
msgid "Gameboy files" msgid "Gameboy files"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:1296 #: ../src/gtk/window.cpp:1340
msgid "Loaded battery" msgid "Loaded battery"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:1313 #: ../src/gtk/window.cpp:1357
msgid "Saved battery" msgid "Saved battery"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:1338 ../src/gtk/window.cpp:1383 #: ../src/gtk/window.cpp:1382 ../src/gtk/window.cpp:1427
msgid "----/--/-- --:--:--" msgid "----/--/-- --:--:--"
msgstr "" msgstr ""
#: ../src/gtk/window.cpp:1368 #: ../src/gtk/window.cpp:1412
msgid "%Y/%m/%d %H:%M:%S" msgid "%Y/%m/%d %H:%M:%S"
msgstr "" msgstr ""
#: ../src/gtk/windowcallbacks.cpp:83 #: ../src/gtk/windowcallbacks.cpp:84
msgid "Load game" msgid "Load game"
msgstr "" msgstr ""
#: ../src/gtk/windowcallbacks.cpp:98 ../src/gtk/windowcallbacks.cpp:133 #: ../src/gtk/windowcallbacks.cpp:99 ../src/gtk/windowcallbacks.cpp:134
msgid "VisualBoyAdvance save game" msgid "VisualBoyAdvance save game"
msgstr "" msgstr ""
#: ../src/gtk/windowcallbacks.cpp:116 #: ../src/gtk/windowcallbacks.cpp:117
msgid "Save game" msgid "Save game"
msgstr "" msgstr ""
#: ../src/gtk/windowcallbacks.cpp:149 ../src/gtk/windowcallbacks.cpp:311 #: ../src/gtk/windowcallbacks.cpp:150 ../src/gtk/windowcallbacks.cpp:312
msgid "File already exists. Overwrite it?" msgid "File already exists. Overwrite it?"
msgstr "" msgstr ""
#: ../src/gtk/windowcallbacks.cpp:276 #: ../src/gtk/windowcallbacks.cpp:277
msgid "Save screenshot" msgid "Save screenshot"
msgstr "" msgstr ""
#: ../src/gtk/windowcallbacks.cpp:293 #: ../src/gtk/windowcallbacks.cpp:294
msgid "PNG image" msgid "PNG image"
msgstr "" msgstr ""
#: ../src/gtk/windowcallbacks.cpp:461 #: ../src/gtk/windowcallbacks.cpp:508
msgid "Only Gameboy Advance cheats are supported"
msgstr ""
#: ../src/gtk/windowcallbacks.cpp:498
msgid "Nintendo GameBoy Advance emulator." msgid "Nintendo GameBoy Advance emulator."
msgstr "" msgstr ""

View File

@ -42,23 +42,6 @@ CheatEditDialog::CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::
m_poCheatTypeComboBox->set_model(m_poCheatTypeStore); m_poCheatTypeComboBox->set_model(m_poCheatTypeStore);
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGeneric;
row[m_oTypeModel.uText] = _("Generic Code");
row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGSA;
row[m_oTypeModel.uText] = _("Gameshark Advance");
row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatCBA;
row[m_oTypeModel.uText] = _("CodeBreaker Advance");
m_poCheatTypeComboBox->set_active(CheatGeneric);
m_poCheatApplyButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnApply)); m_poCheatApplyButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnApply));
m_poCheatCancelButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnCancel)); m_poCheatCancelButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnCancel));
} }
@ -87,6 +70,47 @@ ECheatType CheatEditDialog::vGetType()
return CheatGeneric; return CheatGeneric;
} }
void CheatEditDialog::vSetWindow(VBA::Window * _poWindow)
{
m_poWindow = _poWindow;
// GameBoy Advance
if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGBA)
{
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGeneric;
row[m_oTypeModel.uText] = _("Generic Code");
row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGSA;
row[m_oTypeModel.uText] = _("Gameshark Advance");
row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatCBA;
row[m_oTypeModel.uText] = _("CodeBreaker Advance");
m_poCheatTypeComboBox->set_active(CheatGeneric);
}
// GameBoy
else if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGB)
{
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGS;
row[m_oTypeModel.uText] = _("GameShark");
row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGG;
row[m_oTypeModel.uText] = _("GameGenie");
m_poCheatTypeComboBox->set_active(0);
}
}
void CheatEditDialog::vOnApply() void CheatEditDialog::vOnApply()
{ {
response(Gtk::RESPONSE_APPLY); response(Gtk::RESPONSE_APPLY);

View File

@ -34,7 +34,9 @@ enum ECheatType
{ {
CheatGeneric, CheatGeneric,
CheatGSA, CheatGSA,
CheatCBA CheatCBA,
CheatGS,
CheatGG
}; };
class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
@ -59,6 +61,7 @@ public:
Glib::RefPtr<Gtk::TextBuffer> vGetCode(); Glib::RefPtr<Gtk::TextBuffer> vGetCode();
Glib::ustring vGetDesc(); Glib::ustring vGetDesc();
ECheatType vGetType(); ECheatType vGetType();
void vSetWindow(VBA::Window * _poWindow);
private: private:
void vOnApply(); void vOnApply();

View File

@ -74,7 +74,7 @@ void CheatListDialog::vOnCheatOpen()
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
oDialog.set_current_folder(Glib::get_home_dir()); // TODO: remember dir? oDialog.set_current_folder(Glib::get_home_dir());
while (oDialog.run() == Gtk::RESPONSE_OK) while (oDialog.run() == Gtk::RESPONSE_OK)
{ {
@ -111,6 +111,7 @@ void CheatListDialog::vOnCheatAdd()
CheatEditDialog * poDialog = 0; CheatEditDialog * poDialog = 0;
poBuilder->get_widget_derived("CheatEditDialog", poDialog); poBuilder->get_widget_derived("CheatEditDialog", poDialog);
poDialog->set_transient_for(*this); poDialog->set_transient_for(*this);
poDialog->vSetWindow(m_poWindow);
int response = poDialog->run(); int response = poDialog->run();
poDialog->hide(); poDialog->hide();
@ -198,6 +199,7 @@ void CheatListDialog::vOnCheatAdd()
} // end of loop } // end of loop
} // end of case } // end of case
default:; // silence warnings
} // end of switch } // end of switch
vUpdateList(previous); vUpdateList(previous);
@ -253,6 +255,11 @@ void CheatListDialog::vOnCheatToggled(Glib::ustring const& string_path)
vToggleCheat(row[m_oRecordModel.iIndex], row[m_oRecordModel.bEnabled]); vToggleCheat(row[m_oRecordModel.iIndex], row[m_oRecordModel.bEnabled]);
} }
void CheatListDialog::vSetWindow(VBA::Window * _poWindow)
{
m_poWindow = _poWindow;
}
void CheatListDialog::vToggleCheat(int index, bool enable) { void CheatListDialog::vToggleCheat(int index, bool enable) {
if (enable) if (enable)
cheatsEnable(index); cheatsEnable(index);

View File

@ -53,6 +53,7 @@ class CheatListDialog : public Gtk::Dialog
{ {
public: public:
CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder); CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetWindow(VBA::Window * _poWindow);
private: private:
void vAddCheat(int index, Glib::ustring desc, bool enabled = true); void vAddCheat(int index, Glib::ustring desc, bool enabled = true);

View File

@ -42,6 +42,7 @@
#include "gameboyadvanceconfig.h" #include "gameboyadvanceconfig.h"
#include "generalconfig.h" #include "generalconfig.h"
#include "cheatlist.h" #include "cheatlist.h"
#include "gameboycheatlist.h"
namespace VBA namespace VBA
{ {
@ -453,19 +454,28 @@ void Window::vOnCheatList()
CheatListDialog * poDialog = 0; CheatListDialog * poDialog = 0;
poBuilder->get_widget_derived("CheatListDialog", poDialog); poBuilder->get_widget_derived("CheatListDialog", poDialog);
poDialog->set_transient_for(*this); poDialog->set_transient_for(*this);
poDialog->vSetWindow(this);
poDialog->run(); poDialog->run();
poDialog->hide(); poDialog->hide();
} }
else else if (m_eCartridge == CartridgeGB)
{ {
vPopupError(_("Only Gameboy Advance cheats are supported")); std::string sUiFile = sGetUiFilePath("cheatlist.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
GameBoyCheatListDialog * poDialog = 0;
poBuilder->get_widget_derived("CheatListDialog", poDialog);
poDialog->set_transient_for(*this);
poDialog->vSetWindow(this);
poDialog->run();
poDialog->hide();
} }
} }
void Window::vOnCheatDisableToggled(Gtk::CheckMenuItem * _poCMI) void Window::vOnCheatDisableToggled(Gtk::CheckMenuItem * _poCMI)
{ {
if (m_eCartridge == CartridgeGB) { if (m_eCartridge == CartridgeGB) {
// TODO: implement cheatsEnabled = !cheatsEnabled;
} }
else if (m_eCartridge == CartridgeGBA) { else if (m_eCartridge == CartridgeGBA) {
cheatsEnabled = !cheatsEnabled; cheatsEnabled = !cheatsEnabled;