From: S?bastien G. <kx...@us...> - 2004-05-05 19:36:39
|
Update of /cvsroot/vba/VisualBoyAdvance/src/gtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30645 Modified Files: vba.glade window.cpp window.h windowcallbacks.cpp Log Message: Added screenshot dialog. Index: window.h =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/window.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** window.h 5 May 2004 16:01:12 -0000 1.16 --- window.h 5 May 2004 19:36:31 -0000 1.17 *************** *** 131,141 **** virtual void vOnFileOpen(); ! virtual void vOnLoadGame(); ! virtual void vOnSaveGame(); virtual void vOnLoadGameMostRecent(); virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI); ! virtual void vOnLoadGameSlot(int _iSlot); virtual void vOnSaveGameOldest(); ! virtual void vOnSaveGameSlot(int _iSlot); virtual void vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI); virtual void vOnFileReset(); --- 131,141 ---- virtual void vOnFileOpen(); ! virtual void vOnFileLoad(); ! virtual void vOnFileSave(); virtual void vOnLoadGameMostRecent(); virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI); ! virtual void vOnLoadGame(int _iSlot); virtual void vOnSaveGameOldest(); ! virtual void vOnSaveGame(int _iSlot); virtual void vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI); virtual void vOnFileReset(); *************** *** 145,148 **** --- 145,149 ---- virtual void vOnImportBatteryFile(); virtual void vOnExportBatteryFile(); + virtual void vOnFileScreenCapture(); virtual void vOnFileClose(); virtual void vOnFileExit(); Index: window.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/window.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** window.cpp 5 May 2004 16:01:12 -0000 1.16 --- window.cpp 5 May 2004 19:36:31 -0000 1.17 *************** *** 132,140 **** poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileLoad")); ! poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnLoadGame)); m_listSensitiveWhenPlaying.push_back(poMI); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileSave")); ! poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnSaveGame)); m_listSensitiveWhenPlaying.push_back(poMI); --- 132,140 ---- poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileLoad")); ! poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileLoad)); m_listSensitiveWhenPlaying.push_back(poMI); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileSave")); ! poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileSave)); m_listSensitiveWhenPlaying.push_back(poMI); *************** *** 148,155 **** m_apoLoadGameItem[i]->signal_activate().connect(SigC::bind<int>( ! SigC::slot(*this, &Window::vOnLoadGameSlot), i + 1)); m_apoSaveGameItem[i]->signal_activate().connect(SigC::bind<int>( ! SigC::slot(*this, &Window::vOnSaveGameSlot), i + 1)); } --- 148,155 ---- m_apoLoadGameItem[i]->signal_activate().connect(SigC::bind<int>( ! SigC::slot(*this, &Window::vOnLoadGame), i + 1)); m_apoSaveGameItem[i]->signal_activate().connect(SigC::bind<int>( ! SigC::slot(*this, &Window::vOnSaveGame), i + 1)); } *************** *** 183,186 **** --- 183,190 ---- m_listSensitiveWhenPlaying.push_back(poMI); + poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileScreenCapture")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileScreenCapture)); + m_listSensitiveWhenPlaying.push_back(poMI); + poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("FileClose")); poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileClose)); Index: vba.glade =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/vba.glade,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** vba.glade 5 May 2004 01:34:31 -0000 1.10 --- vba.glade 5 May 2004 19:36:31 -0000 1.11 *************** *** 51,55 **** <child internal-child="image"> ! <widget class="GtkImage" id="image114"> <property name="visible">True</property> <property name="stock">gtk-open</property> --- 51,55 ---- <child internal-child="image"> ! <widget class="GtkImage" id="image116"> <property name="visible">True</property> <property name="stock">gtk-open</property> *************** *** 461,472 **** <child> - <widget class="GtkMenuItem" id="FileRomInformation"> - <property name="visible">True</property> - <property name="label" translatable="yes">RO_M information...</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> <widget class="GtkSeparatorMenuItem" id="separator6"> <property name="visible">True</property> --- 461,464 ---- *************** *** 481,485 **** <child internal-child="image"> ! <widget class="GtkImage" id="image115"> <property name="visible">True</property> <property name="stock">gtk-close</property> --- 473,477 ---- <child internal-child="image"> ! <widget class="GtkImage" id="image117"> <property name="visible">True</property> <property name="stock">gtk-close</property> *************** *** 502,506 **** <child internal-child="image"> ! <widget class="GtkImage" id="image116"> <property name="visible">True</property> <property name="stock">gtk-quit</property> --- 494,498 ---- <child internal-child="image"> ! <widget class="GtkImage" id="image118"> <property name="visible">True</property> <property name="stock">gtk-quit</property> Index: windowcallbacks.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/windowcallbacks.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** windowcallbacks.cpp 5 May 2004 16:01:12 -0000 1.5 --- windowcallbacks.cpp 5 May 2004 19:36:31 -0000 1.6 *************** *** 139,143 **** } ! void Window::vOnLoadGame() { std::string sSaveDir = m_poDirConfig->sGetKey("saves"); --- 139,143 ---- } ! void Window::vOnFileLoad() { std::string sSaveDir = m_poDirConfig->sGetKey("saves"); *************** *** 190,194 **** } ! void Window::vOnSaveGame() { Glib::ustring sSaveDir = m_poDirConfig->sGetKey("saves"); --- 190,194 ---- } ! void Window::vOnFileSave() { Glib::ustring sSaveDir = m_poDirConfig->sGetKey("saves"); *************** *** 199,213 **** oDialog.set_transient_for(*this); - Glib::ustring sDefaultFile; if (sSaveDir == "") { ! sDefaultFile = sCutSuffix(m_sRomFile) + ".sgm"; } else { ! sDefaultFile = sSaveDir + "/" ! + sCutSuffix(Glib::path_get_basename(m_sRomFile)) + ".sgm"; } - oDialog.set_filename(sDefaultFile); #else // ! GTKMM20 --- 199,211 ---- oDialog.set_transient_for(*this); if (sSaveDir == "") { ! oDialog.set_filename(sCutSuffix(m_sRomFile)); } else { ! oDialog.set_filename(sSaveDir + "/" + ! sCutSuffix(Glib::path_get_basename(m_sRomFile))); } #else // ! GTKMM20 *************** *** 227,231 **** oDialog.add_shortcut_folder(sSaveDir); } ! oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile)) + ".sgm"); Gtk::FileFilter oSaveFilter; --- 225,229 ---- oDialog.add_shortcut_folder(sSaveDir); } ! oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile))); Gtk::FileFilter oSaveFilter; *************** *** 284,288 **** if (iMostRecent >= 0) { ! vOnLoadGameSlot(iMostRecent + 1); } } --- 282,286 ---- if (iMostRecent >= 0) { ! vOnLoadGame(iMostRecent + 1); } } *************** *** 293,297 **** } ! void Window::vOnLoadGameSlot(int _iSlot) { int i = _iSlot - 1; --- 291,295 ---- } ! void Window::vOnLoadGame(int _iSlot) { int i = _iSlot - 1; *************** *** 320,332 **** if (iOldest >= 0) { ! vOnSaveGameSlot(iOldest + 1); } else { ! vOnSaveGameSlot(1); } } ! void Window::vOnSaveGameSlot(int _iSlot) { int i = _iSlot - 1; --- 318,330 ---- if (iOldest >= 0) { ! vOnSaveGame(iOldest + 1); } else { ! vOnSaveGame(1); } } ! void Window::vOnSaveGame(int _iSlot) { int i = _iSlot - 1; *************** *** 464,472 **** if (sBatteryDir == "") { ! oDialog.set_filename(Glib::path_get_dirname(m_sRomFile) + "/"); } else { ! oDialog.set_filename(sBatteryDir + "/"); } --- 462,471 ---- if (sBatteryDir == "") { ! oDialog.set_filename(sCutSuffix(m_sRomFile)); } else { ! oDialog.set_filename(sBatteryDir + "/" + ! sCutSuffix(Glib::path_get_basename(m_sRomFile))); } *************** *** 487,490 **** --- 486,490 ---- oDialog.add_shortcut_folder(sBatteryDir); } + oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile))); Gtk::FileFilter oBatteryFilter; *************** *** 565,568 **** --- 565,677 ---- } + void Window::vOnFileScreenCapture() + { + std::string sCaptureDir = m_poDirConfig->sGetKey("captures"); + + #ifdef GTKMM20 + + Gtk::FileSelection oDialog(_("Save screenshot")); + oDialog.set_transient_for(*this); + + if (sCaptureDir == "") + { + oDialog.set_filename(sCutSuffix(m_sRomFile)); + } + else + { + oDialog.set_filename(sCaptureDir + "/" + + sCutSuffix(Glib::path_get_basename(m_sRomFile))); + } + + #else // ! GTKMM20 + + Gtk::FileChooserDialog oDialog(*this, _("Save screenshot"), + Gtk::FILE_CHOOSER_ACTION_SAVE); + oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); + + if (sCaptureDir == "") + { + oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile)); + } + else + { + oDialog.set_current_folder(sCaptureDir); + oDialog.add_shortcut_folder(sCaptureDir); + } + oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile))); + + Gtk::FileFilter oPngFilter; + oPngFilter.set_name(_("PNG image")); + oPngFilter.add_pattern("*.[pP][nN][gG]"); + + Gtk::FileFilter oBmpFilter; + oBmpFilter.set_name(_("BMP image")); + oBmpFilter.add_pattern("*.[bB][mM][pP]"); + + oDialog.add_filter(oPngFilter); + oDialog.add_filter(oBmpFilter); + + #endif // ! GTKMM20 + + while (oDialog.run() == Gtk::RESPONSE_OK) + { + Glib::ustring sFile = oDialog.get_filename(); + Glib::ustring sExt; + + #ifdef GTKMM20 + + sExt = ".png"; + + #else // ! GTKMM20 + + if (oDialog.get_filter() == &oPngFilter) + { + sExt = ".png"; + } + else + { + sExt = ".bmp"; + } + + #endif // ! GTKMM20 + + 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?"), + #ifndef GTKMM20 + false, + #endif // ! GTKMM20 + Gtk::MESSAGE_QUESTION, + Gtk::BUTTONS_YES_NO); + if (oConfirmDialog.run() != Gtk::RESPONSE_YES) + { + continue; + } + } + + bool bResult; + if (sExt == ".png") + { + bResult = m_stEmulator.emuWritePNG(sFile.c_str()); + } + else + { + bResult = m_stEmulator.emuWriteBMP(sFile.c_str()); + } + + if (bResult) + { + break; + } + } + } + void Window::vOnFileClose() { |