Started reorganizing the menus
This commit is contained in:
bgk 2008-09-13 12:10:05 +00:00
parent 1a5e6f0835
commit a3f1c3be29
4 changed files with 79 additions and 419 deletions

View File

@ -26,31 +26,83 @@
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator1">
<widget class="GtkMenuItem" id="RecentMenu">
<property name="visible">True</property>
<property name="label" translatable="yes">Open rece_nt</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator4">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="FileLoad">
<widget class="GtkMenuItem" id="FileScreenCapture">
<property name="visible">True</property>
<property name="label" translatable="yes">_Load...</property>
<property name="label" translatable="yes">Screen capt_ure...</property>
<property name="use_underline">True</property>
<accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="FileSave">
<widget class="GtkSeparatorMenuItem" id="separator6">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-save-as</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="FileClose">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-close</property>
<property name="use_stock">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="FileExit">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-quit</property>
<property name="use_stock">True</property>
<property name="use_underline">True</property>
<accelerator key="X" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="EmulationMenu">
<property name="visible">True</property>
<property name="label" translatable="yes">_Emulation</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="EmulationMenu_menu">
<child>
<widget class="GtkCheckMenuItem" id="FilePause">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-media-pause</property>
<property name="use_stock">True</property>
<property name="use_underline">True</property>
<accelerator key="P" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="FileReset">
<property name="visible">True</property>
<property name="label" translatable="yes">_Reset</property>
<property name="use_underline">True</property>
<accelerator key="R" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator3">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="LoadGameMenu">
<property name="visible">True</property>
<property name="label" translatable="yes">Loa_d game</property>
<property name="label" translatable="yes">Loa_d state</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="LoadGameMenu_menu">
@ -153,6 +205,14 @@
<accelerator key="F10" modifiers="" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="FileLoad">
<property name="visible">True</property>
<property name="label" translatable="yes">From _File ...</property>
<property name="use_underline">True</property>
<accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
</widget>
</child>
</widget>
@ -160,7 +220,7 @@
<child>
<widget class="GtkMenuItem" id="SaveGameMenu">
<property name="visible">True</property>
<property name="label" translatable="yes">S_ave game</property>
<property name="label" translatable="yes">S_ave state</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="SaveGameMenu_menu">
@ -256,119 +316,23 @@
<accelerator key="F10" modifiers="GDK_SHIFT_MASK" signal="activate"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator2">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="FilePause">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-media-pause</property>
<property name="use_stock">True</property>
<property name="use_underline">True</property>
<accelerator key="P" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="FileReset">
<property name="visible">True</property>
<property name="label" translatable="yes">_Reset</property>
<property name="use_underline">True</property>
<accelerator key="R" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator3">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="RecentMenu">
<property name="visible">True</property>
<property name="label" translatable="yes">Rece_nt</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator4">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="ImportMenu">
<property name="visible">True</property>
<property name="label" translatable="yes">_Import</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="ImportMenu_menu">
<child>
<widget class="GtkMenuItem" id="ImportBatteryFile">
<widget class="GtkSeparatorMenuItem" id="separator25">
<property name="visible">True</property>
<property name="label" translatable="yes">_Battery file...</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="FileSave">
<property name="visible">True</property>
<property name="label" translatable="yes">To _File ...</property>
<property name="use_underline">True</property>
<accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="ExportMenu">
<property name="visible">True</property>
<property name="label" translatable="yes">E_xport</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="ExportMenu_menu">
<child>
<widget class="GtkMenuItem" id="ExportBatteryFile">
<property name="visible">True</property>
<property name="label" translatable="yes">_Battery file...</property>
<property name="use_underline">True</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator5">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="FileScreenCapture">
<property name="visible">True</property>
<property name="label" translatable="yes">Screen capt_ure...</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator6">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="FileClose">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-close</property>
<property name="use_stock">True</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="FileExit">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-quit</property>
<property name="use_stock">True</property>
<property name="use_underline">True</property>
<accelerator key="X" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
</widget>
</child>
</widget>
@ -583,86 +547,6 @@
<property name="group">Video1x</property>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator9">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="LayersMenu">
<property name="visible">True</property>
<property name="label" translatable="yes">_Layers</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="LayersMenu_menu">
<child>
<widget class="GtkCheckMenuItem" id="LayersBg0">
<property name="visible">True</property>
<property name="label" translatable="yes">BG0</property>
<property name="use_underline">True</property>
<accelerator key="1" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="LayersBg1">
<property name="visible">True</property>
<property name="label" translatable="yes">BG1</property>
<property name="use_underline">True</property>
<accelerator key="2" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="LayersBg2">
<property name="visible">True</property>
<property name="label" translatable="yes">BG2</property>
<property name="use_underline">True</property>
<accelerator key="3" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="LayersBg3">
<property name="visible">True</property>
<property name="label" translatable="yes">BG3</property>
<property name="use_underline">True</property>
<accelerator key="4" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="LayersObj">
<property name="visible">True</property>
<property name="label" translatable="yes">OBJ</property>
<property name="use_underline">True</property>
<accelerator key="5" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="LayersWin0">
<property name="visible">True</property>
<property name="label" translatable="yes">WIN0</property>
<property name="use_underline">True</property>
<accelerator key="6" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="LayersWin1">
<property name="visible">True</property>
<property name="label" translatable="yes">WIN1</property>
<property name="use_underline">True</property>
<accelerator key="7" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="LayersObjWin">
<property name="visible">True</property>
<property name="label" translatable="yes">OBJWIN</property>
<property name="use_underline">True</property>
<accelerator key="8" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
@ -1142,11 +1026,6 @@
<property name="group">FilterNone</property>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separator17">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
</widget>

View File

@ -259,18 +259,6 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
m_poRecentMenu = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("RecentMenu"));
m_poRecentMenu->set_submenu(static_cast<Gtk::Menu &>(*m_poRecentChooserMenu));
// Import menu
//
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("ImportBatteryFile"));
poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnImportBatteryFile));
m_listSensitiveWhenPlaying.push_back(poMI);
// Export menu
//
poMI = dynamic_cast<Gtk::MenuItem *>(_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<Xml> & _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<Gtk::CheckMenuItem *>(_poXml->get_widget(astLayer[i].m_csName));
poCMI->set_active(m_poCoreConfig->oGetKey<bool>(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<Gtk::MenuItem *>(_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))

View File

@ -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();

View File

@ -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