Minor GUI rearrangement

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4805 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx 2010-01-11 13:56:11 +00:00
parent 98ce4c4d8f
commit 60a2d20fda
5 changed files with 53 additions and 103 deletions

View File

@ -262,7 +262,6 @@ void Config::Load()
iniFile.Load(FULL_CONFIG_DIR "Wiimote.ini");
// Real Wiimote
iniFile.Get("Real", "Connect", &bConnectRealWiimote, true);
iniFile.Get("Real", "UpdateStatus", &bUpdateRealWiimote, true);
iniFile.Get("Real", "AccNeutralX", &iAccNeutralX, 0);
iniFile.Get("Real", "AccNeutralY", &iAccNeutralY, 0);
@ -349,8 +348,7 @@ void Config::Save()
{
IniFile iniFile;
iniFile.Load(FULL_CONFIG_DIR "Wiimote.ini");
iniFile.Set("Real", "Connect", bConnectRealWiimote);
iniFile.Set("Real", "UpdateStatus", bUpdateRealWiimote);
iniFile.Set("Real", "AccNeutralX", iAccNeutralX);
iniFile.Set("Real", "AccNeutralY", iAccNeutralY);

View File

@ -32,8 +32,8 @@ struct Config
int CurrentPage;
// Real Wiimote
bool bConnectRealWiimote, bUpdateRealWiimote;
int bFoundRealWiimotes, bNumberRealWiimotes, bNumberEmuWiimotes;
bool bUpdateRealWiimote;
int bNumberRealWiimotes, bNumberEmuWiimotes;
int iIRLeft, iIRTop, iIRWidth, iIRHeight;
int iAccNeutralX, iAccNeutralY, iAccNeutralZ;
int iAccNunNeutralX, iAccNunNeutralY, iAccNunNeutralZ;

View File

@ -31,13 +31,14 @@ BEGIN_EVENT_TABLE(WiimoteBasicConfigDialog,wxDialog)
EVT_CLOSE(WiimoteBasicConfigDialog::OnClose)
EVT_BUTTON(ID_OK, WiimoteBasicConfigDialog::ButtonClick)
EVT_BUTTON(ID_CANCEL, WiimoteBasicConfigDialog::ButtonClick)
EVT_BUTTON(ID_REFRESH_REAL, WiimoteBasicConfigDialog::ButtonClick)
EVT_BUTTON(ID_BUTTONMAPPING, WiimoteBasicConfigDialog::ButtonClick)
EVT_BUTTON(ID_BUTTONRECORDING, WiimoteBasicConfigDialog::ButtonClick)
EVT_BUTTON(ID_BUTTONPAIRUP, WiimoteBasicConfigDialog::ButtonClick)
EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, WiimoteBasicConfigDialog::NotebookPageChanged)
EVT_BUTTON(IDB_PAIRUP_REAL, WiimoteBasicConfigDialog::ButtonClick)
EVT_BUTTON(IDB_REFRESH_REAL, WiimoteBasicConfigDialog::ButtonClick)
EVT_CHOICE(IDC_INPUT_SOURCE, WiimoteBasicConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_CONNECT_REAL, WiimoteBasicConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_SIDEWAYSWIIMOTE, WiimoteBasicConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_UPRIGHTWIIMOTE, WiimoteBasicConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_MOTIONPLUSCONNECTED, WiimoteBasicConfigDialog::GeneralSettingsChanged)
@ -110,21 +111,28 @@ void WiimoteBasicConfigDialog::ButtonClick(wxCommandEvent& event)
m_RecordingConfigFrame->Destroy();
m_RecordingConfigFrame = NULL;
break;
#ifdef WIN32
case ID_BUTTONPAIRUP:
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY) {
m_ButtonPairUp->Enable(false);
if (WiiMoteReal::WiimotePairUp() > 0) { //Only temporay solution TODO: 2nd step: threaded.
#ifdef _WIN32
case IDB_PAIRUP_REAL:
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY)
{
m_PairUpRealWiimote[m_Page]->Enable(false);
if (WiiMoteReal::WiimotePairUp() > 0)
{ // Only temporay solution TODO: 2nd step: threaded.
// sleep would be required (but not best way to solve that cuz 3000ms~ would be needed, which is not convenient),cuz BT device is not ready yet when calling DoRefreshReal()
DoRefreshReal();
}
m_ButtonPairUp->Enable(true);
m_PairUpRealWiimote[m_Page]->Enable(true);
}
UpdateGUI();
break;
#endif
case ID_REFRESH_REAL:
DoRefreshReal();
case IDB_REFRESH_REAL:
// If the config dialog was open when the user click on Play/Pause, the GUI was not updated, so this could crash everything!
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY)
{
DoRefreshReal();
}
UpdateGUI();
break;
}
}
@ -164,11 +172,14 @@ void WiimoteBasicConfigDialog::CreateGUIControls()
m_Extension[i] = new wxChoice(m_Controller[i], IDC_EXTCONNECTED, wxDefaultPosition, wxDefaultSize, arrayStringFor_extension, 0, wxDefaultValidator);
m_ConnectRealWiimote[i] = new wxCheckBox(m_Controller[i], IDC_CONNECT_REAL, wxT("Connect Real Wiimote"));
m_ConnectRealWiimote[i]->SetToolTip(wxT("Connected to the Real WiiMote(s).\nThis can only be changed when the emulator is paused or stopped."));
m_FoundWiimote[i] = new wxStaticText(m_Controller[i], ID_FOUND_REAL, wxT("Found 0 WiiMotes"));
m_RefreshRealWiiMote[i] = new wxButton(m_Controller[i], ID_REFRESH_REAL, wxT("Refresh Real WiiMotes"));
m_RefreshRealWiiMote[i]->SetToolTip(wxT("Reconnect to all Real WiiMotes.\nThis is useful if you recently connected another one.\nThis can only be done when the emulator is paused or stopped."));
m_PairUpRealWiimote[i] = new wxButton(m_Controller[i], IDB_PAIRUP_REAL, wxT("Pair Up Real Wiimotes"));
m_PairUpRealWiimote[i]->SetToolTip(wxT("Press the Buttons 1 and 2 on your Wiimote.\nThis might take a few seconds.\nIt only works if you are using Microsoft Bluetooth stack.")); // Only working with MS BT Stack.
#ifndef _WIN32
m_PairUpRealWiimote[i]->Enable(false);
#endif
m_TextFoundRealWiimote[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Connected to 0 Real Wiimotes"));
m_ConnectRealWiimote[i] = new wxButton(m_Controller[i], IDB_REFRESH_REAL, wxT("Refresh Real Wiimotes"));
m_ConnectRealWiimote[i]->SetToolTip(wxT("This can only be done when the emulator is paused or stopped."));
//IR Pointer
m_TextScreenWidth[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Width: 000"));
@ -203,9 +214,9 @@ void WiimoteBasicConfigDialog::CreateGUIControls()
m_SizeExtensions[i]->Add(m_Extension[i], 0, wxEXPAND | wxALL, 5);
m_SizeReal[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Real Wiimote"));
m_SizeReal[i]->Add(m_PairUpRealWiimote[i], 0, wxEXPAND | wxALL, 5);
m_SizeReal[i]->Add(m_TextFoundRealWiimote[i], 0, wxEXPAND | wxALL, 5);
m_SizeReal[i]->Add(m_ConnectRealWiimote[i], 0, wxEXPAND | wxALL, 5);
m_SizeReal[i]->Add(m_FoundWiimote[i], 0, wxEXPAND | wxALL, 5);
m_SizeReal[i]->Add(m_RefreshRealWiiMote[i], 0, wxEXPAND | wxALL, 5);
m_SizerIRPointerWidth[i] = new wxBoxSizer(wxHORIZONTAL);
m_SizerIRPointerWidth[i]->Add(m_TextScreenLeft[i], 0, wxEXPAND | (wxTOP), 3);
@ -249,13 +260,6 @@ void WiimoteBasicConfigDialog::CreateGUIControls()
m_ButtonMapping = new wxButton(this, ID_BUTTONMAPPING, wxT("Button Mapping"));
m_Recording = new wxButton(this, ID_BUTTONRECORDING, wxT("Recording"));
m_ButtonPairUp = new wxButton(this, ID_BUTTONPAIRUP, wxT("Wiimotes PairUp"));
#ifdef WIN32
m_ButtonPairUp->SetToolTip(wxT("Pair up your Wiimotes with your system.\nPress the Buttons 1 and 2 on your Wiimote before pairing up.\nThis might take a few seconds.\nIt only works if you're using Microsoft's Bluetooth stack.")); // Only working with MS BT Stack.
#else
m_ButtonPairUp->Enable(false);
#endif
m_OK = new wxButton(this, ID_OK, wxT("OK"));
m_OK->SetToolTip(wxT("Save changes and close"));
@ -265,7 +269,6 @@ void WiimoteBasicConfigDialog::CreateGUIControls()
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
sButtons->Add(m_ButtonMapping, 0, (wxALL), 0);
sButtons->Add(m_Recording, 0, (wxALL), 0);
sButtons->Add(m_ButtonPairUp, 0, (wxALL), 0);
sButtons->AddStretchSpacer();
sButtons->Add(m_OK, 0, (wxALL), 0);
sButtons->Add(m_Cancel, 0, (wxLEFT), 5);
@ -300,35 +303,12 @@ void WiimoteBasicConfigDialog::UpdateOnce(wxTimerEvent& event)
}
}
void WiimoteBasicConfigDialog::DoConnectReal()
{
if (g_Config.bConnectRealWiimote)
{
if (!g_RealWiiMoteInitialized)
{
WiiMoteReal::Initialize();
UpdateGUI();
}
}
else
{
DEBUG_LOG(WIIMOTE, "Post Message: %i", g_RealWiiMoteInitialized);
if (g_RealWiiMoteInitialized)
WiiMoteReal::Shutdown();
}
}
void WiimoteBasicConfigDialog::DoRefreshReal()
{
if (g_Config.bConnectRealWiimote && g_EmulatorState != PLUGIN_EMUSTATE_PLAY)
{
if (g_RealWiiMoteInitialized)
WiiMoteReal::Shutdown();
if (!g_RealWiiMoteInitialized)
WiiMoteReal::Initialize();
}
UpdateGUI();
if (g_RealWiiMoteInitialized)
WiiMoteReal::Shutdown();
if (!g_RealWiiMoteInitialized)
WiiMoteReal::Initialize();
}
void WiimoteBasicConfigDialog::DoUseReal()
@ -399,14 +379,6 @@ void WiimoteBasicConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
{
switch (event.GetId())
{
case IDC_CONNECT_REAL:
// If the config dialog was open when the user click on Play/Pause, the GUI was not updated, so this could crash everything!
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY)
{
g_Config.bConnectRealWiimote = m_ConnectRealWiimote[m_Page]->IsChecked();
DoConnectReal();
}
break;
case IDC_INPUT_SOURCE:
// If the config dialog was open when the user click on Play/Pause, the GUI was not updated, so this could crash everything!
if (g_EmulatorState == PLUGIN_EMUSTATE_PLAY)
@ -479,19 +451,12 @@ void WiimoteBasicConfigDialog::UpdateGUI()
mean that the wiimote must be sent the current reporting mode and the channel ID after it
has been initialized. Functions for that are basically already in place so these two options
could possibly be simplified to one option. */
m_InputSource[m_Page]->Enable(g_EmulatorState != PLUGIN_EMUSTATE_PLAY);
m_ConnectRealWiimote[m_Page]->SetValue(g_Config.bConnectRealWiimote);
m_PairUpRealWiimote[m_Page]->Enable(g_EmulatorState != PLUGIN_EMUSTATE_PLAY);
m_TextFoundRealWiimote[m_Page]->SetLabel(wxString::Format(wxT("Connected to %i Real Wiimotes"), WiiMoteReal::g_NumberOfWiiMotes));
m_ConnectRealWiimote[m_Page]->Enable(g_EmulatorState != PLUGIN_EMUSTATE_PLAY);
m_RefreshRealWiiMote[m_Page]->Enable(g_EmulatorState != PLUGIN_EMUSTATE_PLAY && g_Config.bConnectRealWiimote);
m_ButtonPairUp->Enable(g_EmulatorState != PLUGIN_EMUSTATE_PLAY);
wxString Found;
if (g_Config.bConnectRealWiimote)
Found.Printf(wxT("Connected to %i Real WiiMote(s)"), WiiMoteReal::g_NumberOfWiiMotes);
else
Found.Printf(wxT("Not connected to Real WiiMotes"));
m_FoundWiimote[m_Page]->SetLabel(Found);
m_InputSource[m_Page]->SetSelection(WiiMoteEmu::WiiMapping[m_Page].Source);
m_InputSource[m_Page]->Enable(g_EmulatorState != PLUGIN_EMUSTATE_PLAY);
if (WiiMoteEmu::WiiMapping[m_Page].Source == 2)
{
m_SidewaysWiimote[m_Page]->Enable(false);

View File

@ -66,8 +66,8 @@ class WiimoteBasicConfigDialog : public wxDialog
*m_Cancel,
*m_ButtonMapping,
*m_Recording,
*m_ButtonPairUp,
*m_RefreshRealWiiMote[MAX_WIIMOTES];
*m_PairUpRealWiimote[MAX_WIIMOTES],
*m_ConnectRealWiimote[MAX_WIIMOTES];
wxChoice *m_InputSource[MAX_WIIMOTES],
*m_Extension[MAX_WIIMOTES];
@ -77,8 +77,7 @@ class WiimoteBasicConfigDialog : public wxDialog
*m_SliderLeft[MAX_WIIMOTES],
*m_SliderTop[MAX_WIIMOTES];
wxCheckBox *m_ConnectRealWiimote[MAX_WIIMOTES],
*m_SidewaysWiimote[MAX_WIIMOTES],
wxCheckBox *m_SidewaysWiimote[MAX_WIIMOTES],
*m_UprightWiimote[MAX_WIIMOTES],
*m_WiiMotionPlusConnected[MAX_WIIMOTES],
*m_CheckAR43[MAX_WIIMOTES],
@ -90,7 +89,7 @@ class WiimoteBasicConfigDialog : public wxDialog
*m_TextScreenLeft[MAX_WIIMOTES],
*m_TextScreenTop[MAX_WIIMOTES],
*m_TextAR[MAX_WIIMOTES],
*m_FoundWiimote[MAX_WIIMOTES];
*m_TextFoundRealWiimote[MAX_WIIMOTES];
wxBoxSizer *m_MainSizer,
*m_SizeBasicGeneral[MAX_WIIMOTES],
@ -130,16 +129,13 @@ class WiimoteBasicConfigDialog : public wxDialog
IDC_EXTCONNECTED,
// Real
IDC_CONNECT_REAL,
ID_FOUND_REAL,
ID_REFRESH_REAL,
IDB_PAIRUP_REAL,
IDB_REFRESH_REAL,
IDS_WIDTH,
IDS_HEIGHT,
IDS_LEFT,
IDS_TOP,
ID_BUTTONPAIRUP,
};
void CreateGUIControls();
@ -148,8 +144,7 @@ class WiimoteBasicConfigDialog : public wxDialog
void GeneralSettingsChanged(wxCommandEvent& event);
void IRCursorChanged(wxScrollEvent& event);
void DoConnectReal(); // Real
void DoRefreshReal();
void DoRefreshReal(); // Real
void DoUseReal();
void DoExtensionConnectedDisconnected(int Extension = -1); // Emulated

View File

@ -319,22 +319,14 @@ int Initialize()
g_RealWiiMotePresent = false;
g_RealWiiMoteAllocated = false;
if (g_Config.bConnectRealWiimote)
{
// Call Wiiuse.dll
g_WiiMotesFromWiiUse = wiiuse_init(MAX_WIIMOTES);
g_NumberOfWiiMotes = wiiuse_find(g_WiiMotesFromWiiUse, MAX_WIIMOTES, 5);
DEBUG_LOG(WIIMOTE, "Found No of Wiimotes: %i", g_NumberOfWiiMotes);
if (g_NumberOfWiiMotes > 0)
g_RealWiiMotePresent = true;
else
return 0;
}
// Call Wiiuse.dll
g_WiiMotesFromWiiUse = wiiuse_init(MAX_WIIMOTES);
g_NumberOfWiiMotes = wiiuse_find(g_WiiMotesFromWiiUse, MAX_WIIMOTES, 5);
DEBUG_LOG(WIIMOTE, "Found No of Wiimotes: %i", g_NumberOfWiiMotes);
if (g_NumberOfWiiMotes > 0)
g_RealWiiMotePresent = true;
else
{
g_NumberOfWiiMotes = 0;
return 0;
}
for (int i = 0; i < g_NumberOfWiiMotes; i++)
{