From 42db684bb5ef421d64b452c28e85cb81477fbf7e Mon Sep 17 00:00:00 2001 From: bgk Date: Sat, 13 Sep 2008 12:10:05 +0000 Subject: [PATCH] GTK : Started reorganizing the menus git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@717 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/gtk/vba.glade | 277 ++++++++++-------------------------- src/gtk/window.cpp | 52 +------ src/gtk/window.h | 3 - src/gtk/windowcallbacks.cpp | 166 --------------------- 4 files changed, 79 insertions(+), 419 deletions(-) diff --git a/src/gtk/vba.glade b/src/gtk/vba.glade index 9c06ddf0..21307684 100644 --- a/src/gtk/vba.glade +++ b/src/gtk/vba.glade @@ -26,31 +26,83 @@ - + + True + Open rece_nt + True + + + + True - + True - _Load... + Screen capt_ure... True - - + True - gtk-save-as + + + + + True + gtk-close + True True - True - + + + + + True + gtk-quit + True + True + + + + + + + + + + True + _Emulation + True + + + + + True + gtk-media-pause + True + True + + + + + + True + _Reset + True + + + + + + True True - Loa_d game + Loa_d state True @@ -153,6 +205,14 @@ + + + True + From _File ... + True + + + @@ -160,7 +220,7 @@ True - S_ave game + S_ave state True @@ -256,119 +316,23 @@ - - - - - - - True - - - - - True - gtk-media-pause - True - True - - - - - - True - _Reset - True - - - - - - True - - - - - True - Rece_nt - True - - - - - True - - - - - True - _Import - True - - - + True - _Battery file... + + + + + True + To _File ... True + - - - True - E_xport - True - - - - - True - _Battery file... - True - - - - - - - - - True - - - - - True - Screen capt_ure... - True - - - - - True - - - - - True - gtk-close - True - True - - - - - True - gtk-quit - True - True - - - @@ -583,86 +547,6 @@ Video1x - - - True - - - - - True - _Layers - True - - - - - True - BG0 - True - - - - - - True - BG1 - True - - - - - - True - BG2 - True - - - - - - True - BG3 - True - - - - - - True - OBJ - True - - - - - - True - WIN0 - True - - - - - - True - WIN1 - True - - - - - - True - OBJWIN - True - - - - - - - @@ -1142,11 +1026,6 @@ FilterNone - - - True - - diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 077ae366..02b88249 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -259,18 +259,6 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : m_poRecentMenu = dynamic_cast(_poXml->get_widget("RecentMenu")); m_poRecentMenu->set_submenu(static_cast(*m_poRecentChooserMenu)); - // Import menu - // - poMI = dynamic_cast(_poXml->get_widget("ImportBatteryFile")); - poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnImportBatteryFile)); - m_listSensitiveWhenPlaying.push_back(poMI); - - // Export menu - // - poMI = dynamic_cast(_poXml->get_widget("ExportBatteryFile")); - poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnExportBatteryFile)); - m_listSensitiveWhenPlaying.push_back(poMI); - // Frameskip menu // struct @@ -344,35 +332,6 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : poCMI, astVideoScale[i].m_iScale)); } - // Layers menu - // - struct - { - const char * m_csName; - const char * m_csKey; - const int m_iLayer; - } - astLayer[] = - { - { "LayersBg0", "layer_bg0", 0 }, - { "LayersBg1", "layer_bg1", 1 }, - { "LayersBg2", "layer_bg2", 2 }, - { "LayersBg3", "layer_bg3", 3 }, - { "LayersObj", "layer_obj", 4 }, - { "LayersWin0", "layer_win0", 5 }, - { "LayersWin1", "layer_win1", 6 }, - { "LayersObjWin", "layer_objwin", 7 } - }; - for (guint i = 0; i < G_N_ELEMENTS(astLayer); i++) - { - poCMI = dynamic_cast(_poXml->get_widget(astLayer[i].m_csName)); - poCMI->set_active(m_poCoreConfig->oGetKey(astLayer[i].m_csKey)); - vOnLayerToggled(poCMI, astLayer[i].m_iLayer); - poCMI->signal_toggled().connect(sigc::bind( - sigc::mem_fun(*this, &Window::vOnLayerToggled), - poCMI, astLayer[i].m_iLayer)); - } - // Emulator menu // poMI = dynamic_cast(_poXml->get_widget("EmulatorDirectories")); @@ -899,14 +858,6 @@ void Window::vInitConfig() m_poCoreConfig = m_oConfig.poAddSection("Core"); m_poCoreConfig->vSetKey("load_game_auto", false ); m_poCoreConfig->vSetKey("frameskip", "auto" ); - m_poCoreConfig->vSetKey("layer_bg0", true ); - m_poCoreConfig->vSetKey("layer_bg1", true ); - m_poCoreConfig->vSetKey("layer_bg2", true ); - m_poCoreConfig->vSetKey("layer_bg3", true ); - m_poCoreConfig->vSetKey("layer_obj", true ); - m_poCoreConfig->vSetKey("layer_win0", true ); - m_poCoreConfig->vSetKey("layer_win1", true ); - m_poCoreConfig->vSetKey("layer_objwin", true ); m_poCoreConfig->vSetKey("use_bios_file", false ); m_poCoreConfig->vSetKey("bios_file", "" ); m_poCoreConfig->vSetKey("save_type", SaveAuto ); @@ -1369,11 +1320,10 @@ void Window::vComputeFrameskip(int _iRate) if (m_bWasEmulating) { - int iWantedSpeed = 100; - if (m_bAutoFrameskip) { Glib::TimeVal uiDiff = uiTime - uiLastTime; + const int iWantedSpeed = 100; int iSpeed = iWantedSpeed; if (uiDiff != Glib::TimeVal(0, 0)) diff --git a/src/gtk/window.h b/src/gtk/window.h index 1b2bd4e3..d8adbe4a 100644 --- a/src/gtk/window.h +++ b/src/gtk/window.h @@ -137,8 +137,6 @@ protected: virtual void vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI); virtual void vOnFileReset(); virtual void vOnRecentFile(); - virtual void vOnImportBatteryFile(); - virtual void vOnExportBatteryFile(); virtual void vOnFileScreenCapture(); virtual void vOnFileClose(); virtual void vOnFileExit(); @@ -146,7 +144,6 @@ protected: virtual void vOnVideoFullscreen(); virtual void vOnVideoOutputToggled(Gtk::CheckMenuItem * _poCMI, int _iOutput); virtual void vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale); - virtual void vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer); virtual void vOnDirectories(); virtual void vOnPauseWhenInactiveToggled(Gtk::CheckMenuItem * _poCMI); virtual void vOnSelectBios(); diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp index 23ed2873..d0997a38 100644 --- a/src/gtk/windowcallbacks.cpp +++ b/src/gtk/windowcallbacks.cpp @@ -246,145 +246,6 @@ void Window::vOnRecentFile() } } -void Window::vOnImportBatteryFile() -{ - std::string BatteryDir = m_poDirConfig->sGetKey("batteries"); - - Gtk::FileChooserDialog oDialog(*this, _("Import battery file")); - oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - if (BatteryDir == "") - { - oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile)); - } - else - { - oDialog.set_current_folder(BatteryDir); - oDialog.add_shortcut_folder(BatteryDir); - } - - Gtk::FileFilter oBatteryFilter; - oBatteryFilter.set_name(_("Battery file")); - oBatteryFilter.add_pattern("*.[sS][aA][vV]"); - - Gtk::FileFilter oFlashFilter; - oFlashFilter.set_name(_("Flash save")); - oFlashFilter.add_pattern("*.[dD][aA][tT]"); - - oDialog.add_filter(oBatteryFilter); - oDialog.add_filter(oFlashFilter); - - while (oDialog.run() == Gtk::RESPONSE_OK) - { - Gtk::MessageDialog oConfirmDialog(*this, - _("Importing a battery file will erase any saved games and reset the emulator. Do you want to continue?"), - false, - Gtk::MESSAGE_QUESTION, - Gtk::BUTTONS_YES_NO); - if (oConfirmDialog.run() != Gtk::RESPONSE_YES) - { - continue; - } - - if (m_stEmulator.emuReadBattery(oDialog.get_filename().c_str())) - { - m_stEmulator.emuReset(); - break; - } - else - { - vPopupError(_("Failed to import battery file %s."), - oDialog.get_filename().c_str()); - } - } -} - -void Window::vOnExportBatteryFile() -{ - std::string sBatteryDir = m_poDirConfig->sGetKey("batteries"); - - Gtk::FileChooserDialog oDialog(*this, _("Export battery file"), - Gtk::FILE_CHOOSER_ACTION_SAVE); - oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); - - if (sBatteryDir == "") - { - oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile)); - } - else - { - oDialog.set_current_folder(sBatteryDir); - oDialog.add_shortcut_folder(sBatteryDir); - } - oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile))); - - Gtk::FileFilter oBatteryFilter; - oBatteryFilter.set_name(_("Battery file")); - oBatteryFilter.add_pattern("*.[sS][aA][vV]"); - - Gtk::FileFilter oFlashFilter; - oFlashFilter.set_name(_("Flash save")); - oFlashFilter.add_pattern("*.[dD][aA][tT]"); - - oDialog.add_filter(oBatteryFilter); - oDialog.add_filter(oFlashFilter); - - while (oDialog.run() == Gtk::RESPONSE_OK) - { - Glib::ustring sFile = oDialog.get_filename(); - Glib::ustring sExt; - - if (oDialog.get_filter() == &oBatteryFilter) - { - sExt = ".sav"; - } - else - { - sExt = ".dat"; - } - - if (! bHasSuffix(sFile, sExt, false)) - { - sFile += sExt; - } - - if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) - { - Gtk::MessageDialog oConfirmDialog(*this, - _("File already exists. Overwrite it?"), - false, - Gtk::MESSAGE_QUESTION, - Gtk::BUTTONS_YES_NO); - if (oConfirmDialog.run() != Gtk::RESPONSE_YES) - { - continue; - } - } - - bool bResult; - if (m_eCartridge == CartridgeGB) - { - bResult = gbWriteBatteryFile(sFile.c_str(), false); - } - else - { - bResult = m_stEmulator.emuWriteBattery(sFile.c_str()); - } - - if (bResult) - { - break; - } - else - { - vPopupError(_("Failed to export battery file %s."), - sFile.c_str()); - } - } -} - void Window::vOnFileScreenCapture() { std::string sCaptureDir = m_poDirConfig->sGetKey("captures"); @@ -523,33 +384,6 @@ void Window::vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale) vUpdateScreen(); } -void Window::vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer) -{ - int iMask = (0x0100 << _iLayer); - if (_poCMI->get_active()) - { - layerSettings |= iMask; - } - else - { - layerSettings &= ~iMask; - } - layerEnable = DISPCNT & layerSettings; - - const char * acsLayers[] = - { - "layer_bg0", - "layer_bg1", - "layer_bg2", - "layer_bg3", - "layer_obj", - "layer_win0", - "layer_win1", - "layer_objwin" - }; - m_poCoreConfig->vSetKey(acsLayers[_iLayer], _poCMI->get_active()); -} - void Window::vOnDirectories() { struct