parent
a3f1c3be29
commit
3d34d0d9eb
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "joypadconfig.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <gtkmm/stock.h>
|
||||
|
||||
#include "intl.h"
|
||||
|
||||
|
@ -41,40 +41,56 @@ const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] =
|
|||
{ KEY_BUTTON_CAPTURE, "Capture :" }
|
||||
};
|
||||
|
||||
JoypadConfigDialog::JoypadConfigDialog(EPad _eJoypad) :
|
||||
JoypadConfigDialog::JoypadConfigDialog() :
|
||||
Gtk::Dialog("Joypad config", true, true),
|
||||
m_ePad(_eJoypad)
|
||||
m_oTitleHBox(false, 5),
|
||||
m_oTitleLabel("Joypad :", Gtk::ALIGN_RIGHT),
|
||||
m_oTable(G_N_ELEMENTS(m_astKeys), 2, false),
|
||||
m_ePad(PAD_MAIN)
|
||||
{
|
||||
Gtk::Table * poTable = Gtk::manage( new Gtk::Table(G_N_ELEMENTS(m_astKeys), 2, false) );
|
||||
poTable->set_border_width(5);
|
||||
poTable->set_spacings(5);
|
||||
get_vbox()->pack_start(* poTable);
|
||||
// Joypad selection
|
||||
m_oTitleCombo.append_text("1");
|
||||
m_oTitleCombo.append_text("2");
|
||||
m_oTitleCombo.append_text("3");
|
||||
m_oTitleCombo.append_text("4");
|
||||
|
||||
m_oTitleHBox.pack_start(m_oTitleLabel, Gtk::PACK_SHRINK);
|
||||
m_oTitleHBox.pack_start(m_oTitleCombo);
|
||||
|
||||
// Joypad buttons
|
||||
for (guint i = 0; i < G_N_ELEMENTS(m_astKeys); i++)
|
||||
{
|
||||
Gtk::Label * poLabel = Gtk::manage( new Gtk::Label(m_astKeys[i].m_csKeyName, Gtk::ALIGN_RIGHT) );
|
||||
Gtk::Entry * poEntry = Gtk::manage( new Gtk::Entry() );
|
||||
poTable->attach(* poLabel, 0, 1, i, i + 1);
|
||||
poTable->attach(* poEntry, 1, 2, i, i + 1);
|
||||
m_oTable.attach(* poLabel, 0, 1, i, i + 1);
|
||||
m_oTable.attach(* poEntry, 1, 2, i, i + 1);
|
||||
m_oEntries.push_back(poEntry);
|
||||
|
||||
poEntry->signal_focus_in_event().connect(sigc::bind(
|
||||
sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusIn),
|
||||
i));
|
||||
sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusIn), i));
|
||||
poEntry->signal_focus_out_event().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusOut));
|
||||
}
|
||||
|
||||
// Dialog validation button
|
||||
m_poOkButton = add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
|
||||
|
||||
show_all_children();
|
||||
|
||||
vEmptyEventQueue();
|
||||
memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent));
|
||||
// Layout
|
||||
m_oTitleHBox.set_border_width(5);
|
||||
m_oTable.set_border_width(5);
|
||||
m_oTable.set_spacings(5);
|
||||
get_vbox()->pack_start(m_oTitleHBox);
|
||||
get_vbox()->pack_start(m_oSeparator);
|
||||
get_vbox()->pack_start(m_oTable);
|
||||
|
||||
// Signals and default values
|
||||
m_oConfigSig = Glib::signal_idle().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnConfigIdle),
|
||||
Glib::PRIORITY_DEFAULT_IDLE);
|
||||
|
||||
vUpdateEntries();
|
||||
m_oTitleCombo.signal_changed().connect(sigc::mem_fun(*this,
|
||||
&JoypadConfigDialog::vOnJoypadSelect) );
|
||||
m_oTitleCombo.set_active_text("1");
|
||||
|
||||
show_all_children();
|
||||
}
|
||||
|
||||
JoypadConfigDialog::~JoypadConfigDialog()
|
||||
|
@ -224,4 +240,31 @@ void JoypadConfigDialog::vEmptyEventQueue()
|
|||
while(SDL_PollEvent(&event));
|
||||
}
|
||||
|
||||
void JoypadConfigDialog::vOnJoypadSelect()
|
||||
{
|
||||
std::string oText = m_oTitleCombo.get_active_text();
|
||||
|
||||
if (oText == "1")
|
||||
{
|
||||
m_ePad = PAD_1;
|
||||
}
|
||||
else if (oText == "2")
|
||||
{
|
||||
m_ePad = PAD_2;
|
||||
}
|
||||
else if (oText == "3")
|
||||
{
|
||||
m_ePad = PAD_3;
|
||||
}
|
||||
else if (oText == "4")
|
||||
{
|
||||
m_ePad = PAD_4;
|
||||
}
|
||||
|
||||
vEmptyEventQueue();
|
||||
memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent));
|
||||
|
||||
vUpdateEntries();
|
||||
}
|
||||
|
||||
} // namespace VBA
|
||||
|
|
|
@ -22,7 +22,12 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <gtkmm/dialog.h>
|
||||
#include <gtkmm/label.h>
|
||||
#include <gtkmm/table.h>
|
||||
#include <gtkmm/entry.h>
|
||||
#include <gtkmm/comboboxtext.h>
|
||||
#include <gtkmm/separator.h>
|
||||
|
||||
#include "../sdl/inputSDL.h"
|
||||
|
||||
|
@ -32,7 +37,7 @@ namespace VBA
|
|||
class JoypadConfigDialog : public Gtk::Dialog
|
||||
{
|
||||
public:
|
||||
JoypadConfigDialog(EPad _eJoypad);
|
||||
JoypadConfigDialog();
|
||||
virtual ~JoypadConfigDialog();
|
||||
|
||||
protected:
|
||||
|
@ -49,6 +54,11 @@ private:
|
|||
const char * m_csKeyName;
|
||||
};
|
||||
|
||||
Gtk::HBox m_oTitleHBox;
|
||||
Gtk::Label m_oTitleLabel;
|
||||
Gtk::ComboBoxText m_oTitleCombo;
|
||||
Gtk::HSeparator m_oSeparator;
|
||||
Gtk::Table m_oTable;
|
||||
Gtk::Button * m_poOkButton;
|
||||
std::vector<Gtk::Entry *> m_oEntries;
|
||||
gint m_iCurrentEntry;
|
||||
|
@ -57,8 +67,9 @@ private:
|
|||
SDL_Event m_oPreviousEvent;
|
||||
EPad m_ePad;
|
||||
|
||||
void vUpdateEntries();
|
||||
bool bOnConfigIdle();
|
||||
void vOnJoypadSelect();
|
||||
void vUpdateEntries();
|
||||
void vEmptyEventQueue();
|
||||
};
|
||||
|
||||
|
|
|
@ -1038,42 +1038,10 @@
|
|||
<child>
|
||||
<widget class="GtkMenu" id="JoypadMenu_menu">
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="JoypadConfigureMenu">
|
||||
<widget class="GtkMenuItem" id="JoypadConfigure">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Configure</property>
|
||||
<property name="label" translatable="yes">_Configure ...</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child>
|
||||
<widget class="GtkMenu" id="JoypadConfigureMenu_menu">
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="JoypadConfigure1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_1...</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="JoypadConfigure2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_2...</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="JoypadConfigure3">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_3...</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="JoypadConfigure4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_4...</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
|
|
|
@ -611,21 +611,8 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
|
|||
|
||||
// Joypad menu
|
||||
//
|
||||
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure1"));
|
||||
poMI->signal_activate().connect(sigc::bind(
|
||||
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_1));
|
||||
|
||||
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure2"));
|
||||
poMI->signal_activate().connect(sigc::bind(
|
||||
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_2));
|
||||
|
||||
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure3"));
|
||||
poMI->signal_activate().connect(sigc::bind(
|
||||
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_3));
|
||||
|
||||
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure4"));
|
||||
poMI->signal_activate().connect(sigc::bind(
|
||||
sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_4));
|
||||
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("JoypadConfigure"));
|
||||
poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnJoypadConfigure));
|
||||
|
||||
int iDefaultJoypad = m_poInputConfig->oGetKey<int>("active_joypad");
|
||||
for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++)
|
||||
|
|
|
@ -159,7 +159,7 @@ protected:
|
|||
virtual void vOnEmulatorTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iEmulatorType);
|
||||
virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x);
|
||||
virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB);
|
||||
virtual void vOnJoypadConfigure(EPad _eJoypad);
|
||||
virtual void vOnJoypadConfigure();
|
||||
virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, EPad _eJoypad);
|
||||
virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, EKey _eKey);
|
||||
virtual void vOnHelpAbout();
|
||||
|
|
|
@ -636,11 +636,10 @@ void Window::vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB)
|
|||
m_poDisplayConfig->vSetKey("filterIB", _iFilterIB);
|
||||
}
|
||||
|
||||
void Window::vOnJoypadConfigure(EPad _eJoypad)
|
||||
void Window::vOnJoypadConfigure()
|
||||
{
|
||||
JoypadConfigDialog oDialog(_eJoypad);
|
||||
JoypadConfigDialog oDialog;
|
||||
oDialog.set_transient_for(*this);
|
||||
|
||||
oDialog.run();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue