diff --git a/src/gba/GBALink.cpp b/src/gba/GBALink.cpp index dcf78c37..5ec79895 100644 --- a/src/gba/GBALink.cpp +++ b/src/gba/GBALink.cpp @@ -4,6 +4,10 @@ #include #include +#ifdef _MSC_VER +#define snprintf _snprintf +#endif + int vbaid = 0; const char *MakeInstanceFilename(const char *Input) { @@ -1208,11 +1212,10 @@ ConnectionState InitLink(LinkMode mode) } } - // No errors, save the link mode - if (gba_connection_state != LINK_ERROR) { - gba_link_mode = mode; - } else { - gba_link_mode = LINK_DISCONNECTED; + // Save the link mode + gba_link_mode = mode; + if (gba_connection_state == LINK_ERROR) { + CloseLink(); } return gba_connection_state; @@ -1382,6 +1385,7 @@ void CloseLink(void){ ls.tcpsocket[i].Close(); } } + lanlink.tcpsocket.Close(); } if (gba_link_mode == LINK_CABLE_IPC || gba_link_mode == LINK_RFU_IPC) { diff --git a/src/win32/JoybusOptions.cpp b/src/win32/JoybusOptions.cpp deleted file mode 100644 index f78be118..00000000 --- a/src/win32/JoybusOptions.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef NO_LINK - -#include "stdafx.h" -#include "vba.h" -#include "JoybusOptions.h" -#include "../gba/GBALink.h" - -// JoybusOptions dialog - -IMPLEMENT_DYNAMIC(JoybusOptions, CDialog) - -JoybusOptions::JoybusOptions(CWnd* pParent /*=NULL*/) - : CDialog(JoybusOptions::IDD, pParent) -{ -} - -JoybusOptions::~JoybusOptions() -{ -} - -void JoybusOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_JOYBUS_ENABLE, enable_check); - DDX_Control(pDX, IDC_JOYBUS_HOSTNAME, hostname); -} - -BEGIN_MESSAGE_MAP(JoybusOptions, CDialog) - ON_BN_CLICKED(IDC_JOYBUS_ENABLE, &JoybusOptions::OnBnClickedJoybusEnable) - ON_BN_CLICKED(IDOK, &JoybusOptions::OnBnClickedOk) -END_MESSAGE_MAP() - -BOOL JoybusOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - enable_check.SetCheck(GetLinkMode() == LINK_GAMECUBE_DOLPHIN ? BST_CHECKED : BST_UNCHECKED); - - hostname.EnableWindow(enable_check.GetCheck() == BST_CHECKED); - - hostname.SetWindowText(joybusHostAddr.ToString().c_str()); - - return TRUE; -} - -void JoybusOptions::OnBnClickedJoybusEnable() -{ - hostname.EnableWindow(enable_check.GetCheck() == BST_CHECKED); -} - -void JoybusOptions::OnBnClickedOk() -{ - if ( (hostname.GetWindowTextLength() == 0) - && (enable_check.GetCheck() == BST_CHECKED) ) - { - hostname.SetWindowText("Enter IP or Hostname"); - return; - } - - CString address; - hostname.GetWindowText(address); - - sf::IPAddress new_server; - new_server = std::string(address); - - if (!new_server.IsValid()) - { - hostname.SetWindowText("Enter IP or Hostname"); - return; - } - - joybusHostAddr = new_server; - - if (enable_check.GetCheck() == BST_CHECKED) - { - CloseLink(); - InitLink(LINK_GAMECUBE_DOLPHIN); - } - - OnOK(); -} - -#endif // NO_LINK diff --git a/src/win32/JoybusOptions.h b/src/win32/JoybusOptions.h deleted file mode 100644 index bfbda832..00000000 --- a/src/win32/JoybusOptions.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include "afxwin.h" - -// JoybusOptions dialog - -class JoybusOptions : public CDialog -{ - DECLARE_DYNAMIC(JoybusOptions) - -public: - JoybusOptions(CWnd* pParent = NULL); // standard constructor - virtual ~JoybusOptions(); - -// Dialog Data - enum { IDD = IDD_JOYBUS_DIALOG }; - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - DECLARE_MESSAGE_MAP() -public: - virtual BOOL OnInitDialog(); - afx_msg void OnBnClickedJoybusEnable(); - CButton enable_check; - CEdit hostname; - afx_msg void OnBnClickedOk(); -}; diff --git a/src/win32/LinkOptions.cpp b/src/win32/LinkOptions.cpp index 290b4667..2e7e5b3e 100644 --- a/src/win32/LinkOptions.cpp +++ b/src/win32/LinkOptions.cpp @@ -5,39 +5,46 @@ #include "LinkOptions.h" #include "../gba/GBALink.h" -extern lserver ls; - #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif +template +void DDX_CBData(CDataExchange* pDX, int nIDC, T& data) +{ + HWND hWndCtrl = pDX->PrepareCtrl(nIDC); + if (pDX->m_bSaveAndValidate) + { + int index = static_cast(::SendMessage(hWndCtrl, CB_GETCURSEL, 0, 0L)); + data = (index == CB_ERR ? NULL : static_cast(::SendMessage(hWndCtrl, CB_GETITEMDATA, index, 0L))); + } + else + { + int count = static_cast(::SendMessage(hWndCtrl, CB_GETCOUNT, 0, 0L)); + for (int i = 0; i != count; ++i) + { + if (static_cast(::SendMessage(hWndCtrl, CB_GETITEMDATA, i, 0L)) == data) + { + ::SendMessage(hWndCtrl, CB_SETCURSEL, i, 0L); + return; + } + } + ::SendMessage(hWndCtrl, CB_SETCURSEL, -1, 0L); + } +} + ///////////////////////////////////////////////////////////////////////////// // LinkOptions dialog -CMyTabCtrl::CMyTabCtrl(){ - m_tabdialog[0] = new LinkGeneral; - m_tabdialog[1] = new LinkServer; - m_tabdialog[2] = new LinkClient; -} - -CMyTabCtrl::~CMyTabCtrl() -{ - m_tabdialog[0]->DestroyWindow(); - m_tabdialog[1]->DestroyWindow(); - m_tabdialog[2]->DestroyWindow(); - - delete m_tabdialog[0]; - delete m_tabdialog[1]; - delete m_tabdialog[2]; -} - LinkOptions::LinkOptions(CWnd* pParent /*=NULL*/) : CDialog(LinkOptions::IDD, pParent) { //{{AFX_DATA_INIT(LinkOptions) - // NOTE: the ClassWizard will add member initialization here + m_numplayers = 0; + m_type = theApp.linkMode; + m_server = FALSE; //}}AFX_DATA_INIT } @@ -46,55 +53,52 @@ void LinkOptions::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(LinkOptions) + DDX_CBData(pDX, IDC_LINK_MODE, m_type); + DDX_Control(pDX, IDC_LINKTIMEOUT, m_timeout); + DDX_Control(pDX, IDC_LINK_MODE, m_mode); + DDX_Control(pDX, IDC_SERVERIP, m_serverip); + DDX_Check(pDX, IDC_SSPEED, m_hacks); + DDX_Radio(pDX, IDC_LINK2P, m_numplayers); + DDX_Radio(pDX, IDC_LINK_CLIENT, m_server); //}}AFX_DATA_MAP } BOOL LinkOptions::OnInitDialog(){ - TCITEM tabitem; - char tabtext[3][8] = {"General", "Server", "Client"}; - int i; + char timeout[6]; CDialog::OnInitDialog(); - m_tabctrl.SubclassDlgItem(IDC_TAB1, this); + AddMode("Nothing (Disconnect)", LINK_DISCONNECTED); + AddMode("Cable - Single Computer", LINK_CABLE_IPC); + AddMode("Cable - Network", LINK_CABLE_SOCKET); + AddMode("GameCube - Dolphin", LINK_GAMECUBE_DOLPHIN); + AddMode("Wireless adapter - Single Computer", LINK_RFU_IPC); - tabitem.mask = TCIF_TEXT; + sprintf(timeout, "%d", linktimeout); - for(i=0;i<3;i++){ - tabitem.pszText = tabtext[i]; - m_tabctrl.InsertItem(i, &tabitem); - } - m_tabctrl.m_tabdialog[0]->Create(IDD_LINKTAB1, this); - m_tabctrl.m_tabdialog[1]->Create(IDD_LINKTAB2, this); - m_tabctrl.m_tabdialog[2]->Create(IDD_LINKTAB3, this); + m_timeout.LimitText(5); + m_timeout.SetWindowText(timeout); - m_tabctrl.m_tabdialog[0]->ShowWindow(SW_SHOW); - m_tabctrl.m_tabdialog[1]->ShowWindow(SW_HIDE); - m_tabctrl.m_tabdialog[2]->ShowWindow(SW_HIDE); + m_serverip.SetWindowText(theApp.linkHost); - m_tabctrl.SetCurSel(0); - m_tabctrl.OnSwitchTabs(); + UpdateAvailability(); + + UpdateData(FALSE); return TRUE; } - BOOL LinkOptions::PreTranslateMessage(MSG* pMsg) - { - return m_tabctrl.TranslatePropSheetMsg(pMsg) ? TRUE : - CDialog::PreTranslateMessage(pMsg); - } - - - - -BEGIN_MESSAGE_MAP(LinkOptions, CDialog) + BEGIN_MESSAGE_MAP(LinkOptions, CDialog) //{{AFX_MSG_MAP(LinkOptions) - ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1) + ON_CBN_SELCHANGE(IDC_LINK_MODE, &LinkOptions::OnCbnSelchangeLinkMode) ON_BN_CLICKED(ID_OK, OnOk) ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_BN_CLICKED(IDC_LINK_SERVER, &LinkOptions::OnBnClickedLinkServer) + ON_BN_CLICKED(IDC_LINK_CLIENT, &LinkOptions::OnBnClickedLinkClient) //}}AFX_MSG_MAP -END_MESSAGE_MAP() + + END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // LinkOptions message handlers @@ -102,601 +106,120 @@ END_MESSAGE_MAP() // LinkGeneral dialog -LinkGeneral::LinkGeneral(CWnd* pParent /*=NULL*/) - : CDialog(LinkGeneral::IDD, pParent) -{ - //{{AFX_DATA_INIT(LinkGeneral) - //}}AFX_DATA_INIT +void LinkOptions::AddMode(LPCTSTR name, int value) { + m_mode.AddString(name); + int index = m_mode.FindStringExact(-1, name); + m_mode.SetItemData(index, value); } -void LinkGeneral::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(LinkGeneral) - DDX_Radio(pDX, IDC_LINK_DISCONNECTED, m_type); - DDX_Control(pDX, IDC_LINKTIMEOUT, m_timeout); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(LinkGeneral, CDialog) - //{{AFX_MSG_MAP(LinkGeneral) - ON_BN_CLICKED(IDC_LINK_SINGLE, OnRadio1) - ON_BN_CLICKED(IDC_LINK_LAN, OnRadio2) - //}}AFX_MSG_MAP - ON_BN_CLICKED(IDC_LINK_DISCONNECTED, &LinkGeneral::OnBnClickedLinkDisconnected) - ON_BN_CLICKED(IDC_LINK_RFU, &LinkGeneral::OnBnClickedLinkRfu) - ON_BN_CLICKED(IDC_LINK_GAMECUBE, &LinkGeneral::OnBnClickedLinkGamecube) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// LinkGeneral message handlers -///////////////////////////////////////////////////////////////////////////// -// LinkServer dialog - - -LinkServer::LinkServer(CWnd* pParent /*=NULL*/) - : CDialog(LinkServer::IDD, pParent) -{ - //{{AFX_DATA_INIT(LinkServer) - m_numplayers = -1; - m_prottype = -1; - m_speed = FALSE; - //}}AFX_DATA_INIT -} - - -void LinkServer::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(LinkServer) - DDX_Radio(pDX, IDC_LINK2P, m_numplayers); - DDX_Radio(pDX, IDC_LINKTCP, m_prottype); - DDX_Check(pDX, IDC_SSPEED, m_speed); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(LinkServer, CDialog) - //{{AFX_MSG_MAP(LinkServer) - ON_BN_CLICKED(IDC_SERVERSTART, OnServerStart) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// LinkServer message handlers - -LinkClient::LinkClient(CWnd* pParent /*=NULL*/) - : CDialog(LinkClient::IDD, pParent) -{ - //{{AFX_DATA_INIT(LinkClient) - m_prottype = -1; - m_hacks = -1; - //}}AFX_DATA_INIT -} - - -void LinkClient::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(LinkClient) - DDX_Control(pDX, IDC_SERVERIP, m_serverip); - DDX_Radio(pDX, IDC_CLINKTCP, m_prottype); - DDX_Radio(pDX, IDC_SPEEDOFF, m_hacks); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(LinkClient, CDialog) - //{{AFX_MSG_MAP(LinkClient) - ON_BN_CLICKED(IDC_LINKCONNECT, OnLinkConnect) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// LinkClient message handlers - -BOOL LinkServer::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_numplayers = lanlink.numslaves; - m_prottype = lanlink.type; - m_speed = lanlink.speed; - - UpdateData(FALSE); - - return TRUE; -} - -void LinkOptions::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult) -{ - m_tabctrl.OnSwitchTabs(); - *pResult = 0; -} - -IMPLEMENT_DYNAMIC(CMyTabCtrl, CTabCtrl) -BEGIN_MESSAGE_MAP(CMyTabCtrl, CTabCtrl) - ON_NOTIFY_REFLECT(TCN_SELCHANGING, OnSelChanging) -END_MESSAGE_MAP() - -BOOL CMyTabCtrl::SubclassDlgItem(UINT nID, CWnd* pParent) -{ - if (!CTabCtrl::SubclassDlgItem(nID, pParent)) - return FALSE; - - ModifyStyle(0, TCS_OWNERDRAWFIXED); - - // If first tab is disabled, go to next enabled tab - if (!IsTabEnabled(0)) { - int iTab = NextEnabledTab(0, TRUE); - SetActiveTab(iTab); - } - return TRUE; -} - -BOOL CMyTabCtrl::IsTabEnabled(int iTab) -{ - LinkGeneral *general = (LinkGeneral*)m_tabdialog[0]; - - if (general->m_type != LINK_CABLE_SOCKET && iTab > 0) - return false; - return true; -} - -////////////////// -// Draw the tab: mimic SysTabControl32, except use gray if tab is disabled -// -void CMyTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) -{ - DRAWITEMSTRUCT& ds = *lpDrawItemStruct; - - int iItem = ds.itemID; - - // Get tab item info - char text[128]; - TCITEM tci; - tci.mask = TCIF_TEXT; - tci.pszText = text; - tci.cchTextMax = sizeof(text); - GetItem(iItem, &tci); - - // use draw item DC - CDC dc; - dc.Attach(ds.hDC); - - // calculate text rectangle and color - CRect rc = ds.rcItem; - rc += CPoint(1,4); // ?? by trial and error - - // draw the text - OnDrawText(dc, rc, text, !IsTabEnabled(iItem)); - - dc.Detach(); -} - -////////////////// -// Draw tab text. You can override to use different color/font. -// -void CMyTabCtrl::OnDrawText(CDC& dc, CRect rc, - CString sText, BOOL bDisabled) -{ - dc.SetTextColor(GetSysColor(bDisabled ? COLOR_3DHILIGHT : COLOR_BTNTEXT)); - dc.DrawText(sText, &rc, DT_CENTER|DT_VCENTER); - - if (bDisabled) { - // disabled: draw again shifted northwest for shadow effect - rc += CPoint(-1,-1); - dc.SetTextColor(GetSysColor(COLOR_GRAYTEXT)); - dc.DrawText(sText, &rc, DT_CENTER|DT_VCENTER); - } -} - -////////////////// -// Selection is changing: disallow if tab is disabled -// -void CMyTabCtrl::OnSelChanging(NMHDR* pnmh, LRESULT* pRes) -{ - TRACE("CMyTabCtrl::OnSelChanging\n"); - - // Figure out index of new tab we are about to go to, as opposed - // to the current one we're at. Believe it or not, Windows doesn't - // pass this info - // - TC_HITTESTINFO htinfo; - GetCursorPos(&htinfo.pt); - ScreenToClient(&htinfo.pt); - int iNewTab = HitTest(&htinfo); - - if (iNewTab >= 0 && !IsTabEnabled(iNewTab)) - *pRes = TRUE; // tab disabled: prevent selection -} - -////////////////// -// Trap arrow-left key to skip disabled tabs. -// This is the only way to know where we're coming from--ie from -// arrow-left (prev) or arrow-right (next). -// -BOOL CMyTabCtrl::PreTranslateMessage(MSG* pMsg) -{ - if (pMsg->message == WM_KEYDOWN && - (pMsg->wParam == VK_LEFT || pMsg->wParam == VK_RIGHT)) { - - int iNewTab = (pMsg->wParam == VK_LEFT) ? - PrevEnabledTab(GetCurSel(), FALSE) : - NextEnabledTab(GetCurSel(), FALSE); - if (iNewTab >= 0) - SetActiveTab(iNewTab); - return TRUE; - } - return CTabCtrl::PreTranslateMessage(pMsg); -} - -//////////////// -// Translate parent property sheet message. Translates Control-Tab and -// Control-Shift-Tab keys. These are normally handled by the property -// sheet, so you must call this function from your prop sheet's -// PreTranslateMessage function. -// -BOOL CMyTabCtrl::TranslatePropSheetMsg(MSG* pMsg) -{ - WPARAM key = pMsg->wParam; - if (pMsg->message == WM_KEYDOWN && GetAsyncKeyState(VK_CONTROL) < 0 && - (key == VK_TAB || key == VK_PRIOR || key == VK_NEXT)) { - - int iNewTab = (key==VK_PRIOR || GetAsyncKeyState(VK_SHIFT) < 0) ? - PrevEnabledTab(GetCurSel(), TRUE) : - NextEnabledTab(GetCurSel(), TRUE); - if (iNewTab >= 0) - SetActiveTab(iNewTab); - return TRUE; - } - return FALSE; -} - -////////////////// -// Helper to set the active page, when moving backwards (left-arrow and -// Control-Shift-Tab). Must simulate Windows messages to tell parent I -// am changing the tab; SetCurSel does not do this!! -// -// In normal operation, this fn will always succeed, because I don't call it -// unless I already know IsTabEnabled() = TRUE; but if you call SetActiveTab -// with a random value, it could fail. -// -BOOL CMyTabCtrl::SetActiveTab(UINT iNewTab) -{ - TRACE("CMyTabCtrl::SetActiveTab\n"); - - // send the parent TCN_SELCHANGING - NMHDR nmh; - nmh.hwndFrom = m_hWnd; - nmh.idFrom = GetDlgCtrlID(); - nmh.code = TCN_SELCHANGING; - - if (GetParent()->SendMessage(WM_NOTIFY, nmh.idFrom, (LPARAM)&nmh) >=0) { - // OK to change: set the new tab - SetCurSel(iNewTab); - - // send parent TCN_SELCHANGE - nmh.code = TCN_SELCHANGE; - GetParent()->SendMessage(WM_NOTIFY, nmh.idFrom, (LPARAM)&nmh); - return TRUE; - } - return FALSE; -} - -///////////////// -// Return the index of the next enabled tab after a given index, or -1 if none -// (0 = first tab). -// If bWrap is TRUE, wrap from beginning to end; otherwise stop at zero. -// -int CMyTabCtrl::NextEnabledTab(int iCurrentTab, BOOL bWrap) -{ - int nTabs = GetItemCount(); - for (int iTab = iCurrentTab+1; iTab != iCurrentTab; iTab++) { - if (iTab >= nTabs) { - if (!bWrap) - return -1; - iTab = 0; - } - if (IsTabEnabled(iTab)) { - return iTab; - } - } - return -1; -} - -///////////////// -// Return the index of the previous enabled tab before a given index, or -1. -// (0 = first tab). -// If bWrap is TRUE, wrap from beginning to end; otherwise stop at zero. -// -int CMyTabCtrl::PrevEnabledTab(int iCurrentTab, BOOL bWrap) -{ - for (int iTab = iCurrentTab-1; iTab != iCurrentTab; iTab--) { - if (iTab < 0) { - if (!bWrap) - return -1; - iTab = GetItemCount() - 1; - } - if (IsTabEnabled(iTab)) { - return iTab; - } - } - return -1; -} - - -void CMyTabCtrl::OnSwitchTabs(void) -{ - CRect clientRect, wndRect; - int i; - LinkGeneral *general = (LinkGeneral*)m_tabdialog[0]; - - GetClientRect(clientRect); - AdjustRect(FALSE, clientRect); - GetWindowRect(wndRect); - GetParent()->ScreenToClient(wndRect); - clientRect.OffsetRect(wndRect.left, wndRect.top); - - - - if (general->m_type != LINK_CABLE_SOCKET) - SetCurSel(0); - - for(i=0;i<3;i++){ - if(i==GetCurSel()){ - m_tabdialog[i]->SetWindowPos(&wndTop, clientRect.left, clientRect.top, clientRect.Width(), clientRect.Height(), SWP_SHOWWINDOW); - } else { - m_tabdialog[i]->ShowWindow(SW_HIDE); - } - } - return; -} - - void LinkOptions::OnOk() { - GetAllData((LinkGeneral*)m_tabctrl.m_tabdialog[0]); + static const int length = 256; + CString timeout; + CString host; + CString title; + CString addressMessage; + + UpdateData(TRUE); + + // Close any previous link + CloseLink(); + + m_serverip.GetWindowText(host); + m_timeout.GetWindowText(timeout); + sscanf(timeout, "%d", &linktimeout); + + LinkMode newMode = (LinkMode) m_type; + bool needsServerHost = newMode == LINK_GAMECUBE_DOLPHIN || (newMode == LINK_CABLE_SOCKET && !m_server); + + if (needsServerHost) { + bool valid = SetLinkServerHost(host); + if (!valid) { + AfxMessageBox("You must enter a valid host name", MB_OK | MB_ICONSTOP); + return; + } + } + + EnableSpeedHacks(m_hacks); + EnableLinkServer(m_server, m_numplayers + 1); + + if (m_server) { + char localhost[length]; + GetLinkServerHost(localhost, length); + + title = "Waiting for clients..."; + addressMessage.Format("Server IP address is: %s\n", localhost); + } else { + title = "Waiting for connection..."; + addressMessage.Format("Connecting to %s\n", host); + } + + // Init link + ConnectionState state = InitLink(newMode); + + // Display a progress dialog while the connection is establishing + if (state == LINK_NEEDS_UPDATE) { + ServerWait *dlg = new ServerWait(); + dlg->Create(ServerWait::IDD, this); + dlg->m_plconn[1] = title; + dlg->m_serveraddress = addressMessage; + dlg->ShowWindow(SW_SHOW); + + while (state == LINK_NEEDS_UPDATE) { + // Ask the core for updates + char message[length]; + state = ConnectLinkUpdate(message, length); + + // Update the wait message + if (strlen(message)) { + dlg->m_plconn[1] = message; + } + + // Step the progress bar and update dialog data + dlg->m_prgctrl.StepIt(); + dlg->UpdateData(false); + + // Process Windows messages + MSG msg; + while (PeekMessage (&msg, 0, 0, 0, PM_NOREMOVE)) { + AfxGetApp()->PumpMessage(); + } + + // Check whether the user has aborted + if (dlg->m_userAborted) { + state = LINK_ABORT; + } + } + + delete dlg; + } + + // The user canceled the connection attempt + if (state == LINK_ABORT) { + CloseLink(); + return; + } + + // Something failed during init + if (state == LINK_ERROR) { + AfxMessageBox("Error occurred.\nPlease try again.", MB_OK | MB_ICONSTOP); + return; + } + + theApp.linkMode = GetLinkMode(); + theApp.linkHost = host; + CDialog::OnOK(); return; } -void LinkGeneral::OnRadio1() -{ - m_type = LINK_CABLE_IPC; - GetParent()->Invalidate(); -} - -void LinkGeneral::OnRadio2() -{ - m_type = LINK_CABLE_SOCKET; - GetParent()->Invalidate(); -} - -BOOL LinkGeneral::OnInitDialog(){ - - char timeout[6]; - - CDialog::OnInitDialog(); - - m_type = GetLinkMode(); - - m_timeout.LimitText(5); - sprintf(timeout, "%d", linktimeout); - m_timeout.SetWindowText(timeout); - - UpdateData(FALSE); - - return TRUE; -} - - void LinkOptions::OnCancel() { CDialog::OnCancel(); return; } -class Win32ServerInfoDisplay : public ServerInfoDisplay -{ -public: - Win32ServerInfoDisplay(ServerWait *_dlg) - { - dlg = _dlg; - } - ~Win32ServerInfoDisplay() - { - if (dlg) - { - // not connected - MessageBox(NULL, "Failed to connect.", "Link", MB_OK); - dlg->SendMessage(WM_CLOSE, 0, 0); - } - - delete dlg; - dlg = NULL; - } - - void ShowServerIP(const sf::IPAddress& addr) - { - dlg->m_serveraddress.Format("Server IP address is: %s", addr.ToString()); - } - - void ShowConnect(const int player) - { - dlg->m_plconn[0].Format("Player %d connected", player); - dlg->UpdateData(false); - } - - void Ping() - { - dlg->m_prgctrl.StepIt(); - } - - void Connected() - { - MessageBox(NULL, "All players connected", "Link", MB_OK); - dlg->SendMessage(WM_CLOSE, 0, 0); - delete dlg; - dlg = NULL; - } - -private: - ServerWait *dlg; -}; - -void LinkServer::OnServerStart() -{ - UpdateData(TRUE); - - lanlink.numslaves = m_numplayers+1; - lanlink.type = m_prottype; - lanlink.server = true; - lanlink.speed = m_speed==1 ? true : false; - sf::IPAddress addr; - - // These must be created on the heap - referenced from the connection thread - ServerWait *dlg = new ServerWait(); - dlg->Create(IDD_SERVERWAIT, this); - dlg->ShowWindow(SW_SHOW); - - // Owns the ServerWait* - Win32ServerInfoDisplay *dlginfo = new Win32ServerInfoDisplay(dlg); - - // ls thread will own the dlginfo - if (!ls.Init(dlginfo)) - { - // Thread didn't get created - delete dlginfo; - MessageBox("Error occurred.\nPlease try again.", "Error", MB_OK); - } - - return; -} - -BOOL LinkClient::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_prottype = lanlink.type; - m_hacks = lanlink.speed; - - UpdateData(FALSE); - - return TRUE; -} - -class Win32ClientInfoDisplay : public ClientInfoDisplay -{ -public: - Win32ClientInfoDisplay(ServerWait *_dlg) - { - dlg = _dlg; - } - - ~Win32ClientInfoDisplay() - { - if (dlg) - { - // not connected - MessageBox(NULL, "Failed to connect.", "Link", MB_OK); - dlg->SendMessage(WM_CLOSE, 0, 0); - } - - delete dlg; - dlg = NULL; - } - - void ConnectStart(const sf::IPAddress& addr) - { - dlg->SetWindowText("Connecting..."); - } - - void ShowConnect(const int player, const int togo) - { - dlg->m_serveraddress.Format("Connected as #%d", player); - if (togo) - dlg->m_plconn[0].Format("Waiting for %d players to join", togo); - else - dlg->m_plconn[0].Format("All players joined."); - } - - void Ping() - { - dlg->m_prgctrl.StepIt(); - } - - void Connected() - { - MessageBox(NULL, "Connected.", "Link", MB_OK); - dlg->SendMessage(WM_CLOSE, 0, 0); - delete dlg; - dlg = NULL; - } - -private: - ServerWait *dlg; -}; - -void LinkClient::OnLinkConnect() -{ - char ipaddress[31]; - - UpdateData(TRUE); - - lanlink.type = m_prottype; - lanlink.server = false; - lanlink.speed = m_hacks==1 ? true : false; - - m_serverip.GetWindowText(ipaddress, 30); - - // These must be created on the heap - referenced from the connection thread - ServerWait *dlg = new ServerWait(); - dlg->Create(IDD_SERVERWAIT, this); - dlg->ShowWindow(SW_SHOW); - - // Owns the ServerWait* - Win32ClientInfoDisplay *dlginfo = new Win32ClientInfoDisplay(dlg); - - // lc thread will own the dlginfo - if (!lc.Init(sf::IPAddress(std::string(ipaddress)), dlginfo)) - { - // Thread didn't get created - delete dlginfo; - MessageBox("Error occurred.\nPlease try again.", "Error", MB_OK); - } - - return; -} - -void LinkOptions::GetAllData(LinkGeneral *src) -{ - char timeout[6]; - - src->UpdateData(true); - - src->m_timeout.GetWindowText(timeout, 5); - sscanf(timeout, "%d", &linktimeout); - - if(src->m_type == LINK_CABLE_SOCKET){ - lanlink.speed = 0; - } - - LinkMode oldMode = GetLinkMode(); - LinkMode newMode = (LinkMode) src->m_type; - - if (newMode != oldMode) { - CloseLink(); - ConnectionState state = InitLink(newMode); - if (state != LINK_OK) { - CloseLink(); - } - } - - return; -} ///////////////////////////////////////////////////////////////////////////// // ServerWait dialog @@ -710,6 +233,8 @@ ServerWait::ServerWait(CWnd* pParent /*=NULL*/) m_plconn[1] = _T(""); m_plconn[2] = _T(""); //}}AFX_DATA_INIT + + m_userAborted = false; } @@ -736,56 +261,47 @@ END_MESSAGE_MAP() void ServerWait::OnCancel() { - lanlink.terminate = true; - CDialog::OnCancel(); + m_userAborted = true; + ShowWindow(SW_HIDE); } -BOOL LinkGeneral::PreTranslateMessage(MSG* pMsg) +void LinkOptions::OnCbnSelchangeLinkMode() { - if(pMsg->message==WM_KEYDOWN) - if(pMsg->wParam==VK_RETURN||pMsg->wParam==VK_ESCAPE) - pMsg->wParam = NULL; - - return CDialog::PreTranslateMessage(pMsg); + UpdateData(TRUE); + UpdateAvailability(); } -BOOL LinkClient::PreTranslateMessage(MSG* pMsg) +void LinkOptions::UpdateAvailability() { - if(pMsg->message==WM_KEYDOWN) - if(pMsg->wParam==VK_RETURN||pMsg->wParam==VK_ESCAPE) - pMsg->wParam = NULL; + bool isDisconnected = m_type == LINK_DISCONNECTED; + bool isNetwork = m_type == LINK_CABLE_SOCKET; + bool canHaveServer = (m_type == LINK_CABLE_SOCKET && !m_server) || m_type == LINK_GAMECUBE_DOLPHIN; + bool hasHacks = m_type == LINK_CABLE_SOCKET; - return CDialog::PreTranslateMessage(pMsg); -} + GetDlgItem(IDC_LINK_CLIENT)->EnableWindow(isNetwork); + GetDlgItem(IDC_LINK_SERVER)->EnableWindow(isNetwork); + GetDlgItem(IDC_SSPEED)->EnableWindow(isNetwork); -BOOL LinkServer::PreTranslateMessage(MSG* pMsg) -{ - if(pMsg->message==WM_KEYDOWN) - if(pMsg->wParam==VK_RETURN||pMsg->wParam==VK_ESCAPE) - pMsg->wParam = NULL; + m_serverip.EnableWindow(canHaveServer); + m_timeout.EnableWindow(!isDisconnected); - return CDialog::PreTranslateMessage(pMsg); + GetDlgItem(IDC_LINK2P)->EnableWindow(isNetwork && m_server); + GetDlgItem(IDC_LINK3P)->EnableWindow(isNetwork && m_server); + GetDlgItem(IDC_LINK4P)->EnableWindow(isNetwork && m_server); } #endif // NO_LINK -void LinkGeneral::OnBnClickedLinkDisconnected() +void LinkOptions::OnBnClickedLinkServer() { - m_type = LINK_DISCONNECTED; - GetParent()->Invalidate(); + UpdateData(TRUE); + UpdateAvailability(); } -void LinkGeneral::OnBnClickedLinkRfu() +void LinkOptions::OnBnClickedLinkClient() { - m_type = LINK_RFU_IPC; - GetParent()->Invalidate(); -} - - -void LinkGeneral::OnBnClickedLinkGamecube() -{ - m_type = LINK_GAMECUBE_DOLPHIN; - GetParent()->Invalidate(); + UpdateData(TRUE); + UpdateAvailability(); } diff --git a/src/win32/LinkOptions.h b/src/win32/LinkOptions.h index b2a34a06..2bbe3503 100644 --- a/src/win32/LinkOptions.h +++ b/src/win32/LinkOptions.h @@ -1,78 +1,5 @@ #pragma once -class CMyTabCtrl : public CTabCtrl { - DECLARE_DYNAMIC(CMyTabCtrl) -public: - CMyTabCtrl(void); - ~CMyTabCtrl(void); - - BOOL IsTabEnabled(int iTab); // you must override - BOOL TranslatePropSheetMsg(MSG* pMsg); // call from prop sheet - BOOL SubclassDlgItem(UINT nID, CWnd* pParent); // non-virtual override - - // helpers - int NextEnabledTab(int iTab, BOOL bWrap); // get next enabled tab - int PrevEnabledTab(int iTab, BOOL bWrap); // get prev enabled tab - BOOL SetActiveTab(UINT iNewTab); // set tab (fail if disabled) - - CDialog *m_tabdialog[3]; - - void OnSwitchTabs(void); -protected: - DECLARE_MESSAGE_MAP() - afx_msg void OnSelChanging(NMHDR* pNmh, LRESULT* pRes); - - // MFC overrides - virtual BOOL PreTranslateMessage(MSG* pMsg); - virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); - - // override to draw text only; eg, colored text or different font - virtual void OnDrawText(CDC& dc, CRect rc, CString sText, BOOL bDisabled); - -}; - -///////////////////////////////////////////////////////////////////////////// -// LinkGeneral dialog - -class LinkGeneral : public CDialog -{ -// Construction -public: - LinkGeneral(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(LinkGeneral) - enum { IDD = IDD_LINKTAB1 }; - int m_type; - CEdit m_timeout; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(LinkGeneral) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(LinkGeneral) - virtual BOOL OnInitDialog(); - afx_msg void OnRadio1(); - afx_msg void OnRadio2(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnBnClickedLinkDisconnected(); - afx_msg void OnBnClickedLinkRfu(); - afx_msg void OnBnClickedLinkGamecube(); -}; - ///////////////////////////////////////////////////////////////////////////// // LinkOptions dialog @@ -81,19 +8,22 @@ class LinkOptions : public CDialog // Construction public: LinkOptions(CWnd* pParent = NULL); // standard constructor - void GetAllData(LinkGeneral*); // Dialog Data //{{AFX_DATA(LinkOptions) enum { IDD = IDD_LINKTAB }; - CMyTabCtrl m_tabctrl; + int m_type; + CEdit m_timeout; + CComboBox m_mode; + CEdit m_serverip; + BOOL m_server; + int m_numplayers; + BOOL m_hacks; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(LinkOptions) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL @@ -101,88 +31,22 @@ public: // Implementation protected: + void AddMode(LPCTSTR name, int value); + void UpdateAvailability(); + // Generated message map functions //{{AFX_MSG(LinkOptions) - afx_msg void OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnCbnSelchangeLinkMode(); virtual BOOL OnInitDialog(); afx_msg void OnOk(); afx_msg void OnCancel(); //}}AFX_MSG DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// LinkServer dialog - -class LinkServer : public CDialog -{ -// Construction public: - LinkServer(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(LinkServer) - enum { IDD = IDD_LINKTAB2 }; - int m_numplayers; - int m_prottype; - BOOL m_speed; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(LinkServer) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(LinkServer) - virtual BOOL OnInitDialog(); - afx_msg void OnServerStart(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + afx_msg void OnBnClickedLinkServer(); + afx_msg void OnBnClickedLinkClient(); }; -class LinkClient : public CDialog -{ -// Construction -public: - LinkClient(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(LinkClient) - enum { IDD = IDD_LINKTAB3 }; - CEdit m_serverip; - int m_prottype; - int m_hacks; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(LinkClient) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(LinkClient) - virtual BOOL OnInitDialog(); - afx_msg void OnLinkConnect(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// @@ -200,10 +64,9 @@ public: CProgressCtrl m_prgctrl; CString m_serveraddress; CString m_plconn[3]; - //CString m_p2conn; - //CString m_p3conn; //}}AFX_DATA + bool m_userAborted; // Overrides // ClassWizard generated virtual function overrides diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp index b44ee50a..3a3a62b6 100644 --- a/src/win32/MainWnd.cpp +++ b/src/win32/MainWnd.cpp @@ -323,7 +323,6 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd) ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_GAMEOVERRIDES, OnUpdateOptionsEmulatorGameoverrides) ON_COMMAND(ID_HELP_GNUPUBLICLICENSE, OnHelpGnupubliclicense) ON_COMMAND(ID_OPTIONS_LINK_OPTIONS, OnLinkOptions) - ON_COMMAND(ID_OPTIONS_JOYBUS, &MainWnd::OnOptionsJoybus) //}}AFX_MSG_MAP ON_COMMAND_EX_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE10, OnFileRecentFile) diff --git a/src/win32/MainWnd.h b/src/win32/MainWnd.h index c2b9bff3..79b895e5 100644 --- a/src/win32/MainWnd.h +++ b/src/win32/MainWnd.h @@ -330,7 +330,6 @@ protected: afx_msg void OnOptionsSoundHardwareacceleration(); afx_msg void OnUpdateOptionsSoundHardwareacceleration(CCmdUI *pCmdUI); afx_msg void OnLinkOptions(); - afx_msg void OnOptionsJoybus(); afx_msg void OnOutputapiDirectsound(); afx_msg void OnUpdateOutputapiDirectsound(CCmdUI *pCmdUI); diff --git a/src/win32/MainWndOptions.cpp b/src/win32/MainWndOptions.cpp index 6effd764..598ac632 100644 --- a/src/win32/MainWndOptions.cpp +++ b/src/win32/MainWndOptions.cpp @@ -7,7 +7,6 @@ #include "FileDlg.h" #include "GameOverrides.h" #include "LinkOptions.h" -#include "JoybusOptions.h" #include "GBColorDlg.h" #include "Joypad.h" #include "MaxScale.h" @@ -1555,14 +1554,8 @@ void MainWnd::OnLinkOptions() dlg.DoModal(); } -void MainWnd::OnOptionsJoybus() -{ - JoybusOptions dlg; - dlg.DoModal(); -} #else void MainWnd::OnLinkOptions() { } -void MainWnd::OnOptionsJoybus() { } #endif void MainWnd::OnOptionsEmulatorGameoverrides() diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp index 1f1adb08..f5e89b30 100644 --- a/src/win32/VBA.cpp +++ b/src/win32/VBA.cpp @@ -475,9 +475,6 @@ BOOL VBA::InitInstance() loadSettings(); - if(!InitLink((LinkMode) linkMode)) - return FALSE; - if(!initDisplay()) { if(videoOption >= VIDEO_320x240) { regSetDwordValue("video", VIDEO_2X); @@ -1257,8 +1254,8 @@ BOOL VBA::OnIdle(LONG lCount) emulator.emuMain(emulator.emuCount); #ifndef NO_LINK - if (lanlink.connected && linkid && lc.numtransfers == 0) - lc.CheckConn(); + if (GetLinkMode() != LINK_DISCONNECTED) + CheckLinkConnection(); #endif if(rewindSaveNeeded && rewindMemory && emulator.emuWriteMemState) { @@ -1628,11 +1625,7 @@ void VBA::loadSettings() linkMode = regQueryDwordValue("LinkMode", LINK_DISCONNECTED); - buffer = regQueryStringValue("joybusHostAddr", ""); - - if(!buffer.IsEmpty()) { - joybusHostAddr = std::string(buffer); - } + linkHost = regQueryStringValue("LinkHostAddr", "localhost"); #endif @@ -2561,8 +2554,8 @@ void VBA::saveSettings() #ifndef NO_LINK regSetDwordValue("LinkTimeout", linktimeout); - regSetDwordValue("LinkMode", GetLinkMode()); - regSetStringValue("joybusHostAddr", joybusHostAddr.ToString().c_str()); + regSetDwordValue("LinkMode", linkMode); + regSetStringValue("LinkHostAddr", linkHost); #endif regSetDwordValue("lastFullscreen", lastFullscreen); diff --git a/src/win32/VBA.h b/src/win32/VBA.h index a90afb9c..fbb6cd02 100644 --- a/src/win32/VBA.h +++ b/src/win32/VBA.h @@ -204,6 +204,7 @@ class VBA : public CWinApp CString wndClass; int linkMode; + CString linkHost; public: VBA(); diff --git a/src/win32/VBA.rc b/src/win32/VBA.rc index 560aa3fc..d636bce7 100644 --- a/src/win32/VBA.rc +++ b/src/win32/VBA.rc @@ -112,57 +112,28 @@ BEGIN LTEXT "Please select filter plugin:",IDC_STATIC,6,6,162,8 END -IDD_LINKTAB DIALOGEX 0, 0, 254, 203 +IDD_LINKTAB DIALOGEX 0, 0, 254, 198 STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Link Options" +CAPTION "Connect Link" FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - CONTROL "Tab1",IDC_TAB1,"SysTabControl32",0x0,9,7,240,162 - PUSHBUTTON "OK",ID_OK,57,180,60,15 - PUSHBUTTON "Cancel",ID_CANCEL,140,180,57,15 -END - -IDD_LINKTAB1 DIALOGEX 0, 0, 184, 113 -STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - CONTROL "Disconnected",IDC_LINK_DISCONNECTED,"Button",BS_AUTORADIOBUTTON | WS_GROUP,15,23,152,16 - CONTROL "Cable - Single Computer",IDC_LINK_SINGLE,"Button",BS_AUTORADIOBUTTON,15,39,152,16 - CONTROL "Cable - Network",IDC_LINK_LAN,"Button",BS_AUTORADIOBUTTON,15,55,154,16 - CONTROL "Wireless adapter",IDC_LINK_RFU,"Button",BS_AUTORADIOBUTTON,15,71,152,16 - CONTROL "GameCube",IDC_LINK_GAMECUBE,"Button",BS_AUTORADIOBUTTON,15,87,152,16 - LTEXT "Link timeout (in milliseconds)",IDC_STATIC,17,12,92,12 - EDITTEXT IDC_LINKTIMEOUT,116,10,53,14,ES_AUTOHSCROLL | ES_NUMBER -END - -IDD_LINKTAB2 DIALOGEX 0, 0, 210, 113 -STYLE DS_SETFONT | WS_CHILD -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - CONTROL "2",IDC_LINK2P,"Button",BS_AUTORADIOBUTTON | WS_GROUP,46,16,21,13 - CONTROL "3",IDC_LINK3P,"Button",BS_AUTORADIOBUTTON,94,16,21,13 - CONTROL "4",IDC_LINK4P,"Button",BS_AUTORADIOBUTTON,142,16,21,13 - CONTROL "TCP/IP",IDC_LINKTCP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,54,47,42,14 - CONTROL "UDP",IDC_LINKUDP,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,121,47,33,14 - PUSHBUTTON "Start!",IDC_SERVERSTART,79,89,50,17 - LTEXT "Select number of players:",IDC_STATIC,60,7,89,10 - LTEXT "Select protocol:",IDC_STATIC,78,33,53,11 - CONTROL "Speed hacks",IDC_SSPEED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,76,70,57,12 -END - -IDD_LINKTAB3 DIALOGEX 0, 0, 188, 108 -STYLE DS_SETFONT | WS_CHILD -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - CONTROL "TCP/IP",IDC_CLINKTCP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,58,20,39,12 - CONTROL "UDP",IDC_CLINKUDP,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,118,20,32,12 - EDITTEXT IDC_SERVERIP,84,39,79,12,ES_AUTOHSCROLL | WS_GROUP - PUSHBUTTON "Connect",IDC_LINKCONNECT,75,81,59,16 - LTEXT "Select protocol:",IDC_STATIC,78,7,53,9 - LTEXT "Server IP address or hostname:",IDC_STATIC,7,37,62,18 - LTEXT "Speed hacks:",IDC_STATIC,7,64,47,10 - CONTROL "Off (accurate)",IDC_SPEEDOFF,"Button",BS_AUTORADIOBUTTON | WS_GROUP,60,63,57,12 - CONTROL "On (fast)",IDC_SPEEDON,"Button",BS_AUTORADIOBUTTON,128,63,48,12 + CONTROL "Client",IDC_LINK_CLIENT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,53,46,33,10 + CONTROL "Server",IDC_LINK_SERVER,"Button",BS_AUTORADIOBUTTON,95,46,37,10 + LTEXT "Link with",IDC_LINK_WITH,11,10,38,10 + COMBOBOX IDC_LINK_MODE,50,8,194,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Link timeout (in milliseconds)",IDC_STATIC_TIMEOUT,11,153,92,12 + EDITTEXT IDC_LINKTIMEOUT,111,150,53,14,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Server IP address or hostname:",IDC_STATIC,25,70,75,18 + EDITTEXT IDC_SERVERIP,114,73,105,12,ES_AUTOHSCROLL | WS_GROUP + LTEXT "Expected number of players:",IDC_STATIC,25,94,89,10 + CONTROL "2",IDC_LINK2P,"Button",BS_AUTORADIOBUTTON | WS_GROUP,53,106,21,13 + CONTROL "3",IDC_LINK3P,"Button",BS_AUTORADIOBUTTON,99,106,21,13 + CONTROL "4",IDC_LINK4P,"Button",BS_AUTORADIOBUTTON,145,106,21,13 + CONTROL "Enable speed hacks",IDC_SSPEED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,121,138,12 + PUSHBUTTON "OK",ID_OK,60,176,60,15 + PUSHBUTTON "Cancel",ID_CANCEL,136,176,57,15 + GROUPBOX "Network options",IDC_GROUP_NETWORK,11,28,231,113 + LTEXT "Role:",IDC_LINK_ROLE,25,46,18,8 END IDD_SERVERWAIT DIALOG 0, 0, 186, 90 @@ -1206,17 +1177,6 @@ BEGIN COMBOBOX IDC_SAMPLE_RATE,66,54,66,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END -IDD_JOYBUS_DIALOG DIALOGEX 0, 0, 209, 57 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION -EXSTYLE WS_EX_TOOLWINDOW -CAPTION "Joybus Options" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,152,36,50,14 - CONTROL "Enable Joybus Connection",IDC_JOYBUS_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,195,10 - EDITTEXT IDC_JOYBUS_HOSTNAME,7,20,195,14,ES_AUTOHSCROLL -END - ///////////////////////////////////////////////////////////////////////////// // @@ -1246,16 +1206,7 @@ BEGIN BEGIN END - IDD_LINKTAB1, DIALOG - BEGIN - BOTTOMMARGIN, 79 - END - - IDD_LINKTAB2, DIALOG - BEGIN - END - - IDD_LINKTAB3, DIALOG + IDD_SERVERWAIT, DIALOG BEGIN END @@ -1591,14 +1542,6 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 163 END - - IDD_JOYBUS_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 202 - TOPMARGIN, 7 - BOTTOMMARGIN, 50 - END END #endif // APSTUDIO_INVOKED @@ -1657,6 +1600,8 @@ BEGIN MENUITEM "Open GB...", ID_FILE_OPEN_GB MENUITEM "Close", ID_FILE_CLOSE MENUITEM SEPARATOR + MENUITEM "&Link with...", ID_OPTIONS_LINK_OPTIONS + MENUITEM SEPARATOR POPUP "Recent" BEGIN MENUITEM "&Reset", ID_FILE_RECENT_RESET @@ -1973,12 +1918,6 @@ BEGIN MENUITEM SEPARATOR MENUITEM "&Colors...", ID_OPTIONS_GAMEBOY_COLORS END - POPUP "&Link" - BEGIN - MENUITEM "&Options...", ID_OPTIONS_LINK_OPTIONS - MENUITEM SEPARATOR - MENUITEM "&Joybus Options...", ID_OPTIONS_JOYBUS - END END POPUP "&Cheats" BEGIN diff --git a/src/win32/resource.h b/src/win32/resource.h index 0eb717b9..d73ec76a 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -107,7 +107,6 @@ #define IDD_FULLSCREEN 162 #define IDD_XAUDIO2_CONFIG 163 #define IDD_AUDIO_CORE_SETTINGS 164 -#define IDD_JOYBUS_DIALOG 165 #define IDC_R0 1000 #define IDC_EDIT_UP 1000 #define IDC_R1 1001 @@ -564,8 +563,13 @@ #define IDC_SOUND_FILTERING 1294 #define IDC_COMBO1 1296 #define IDC_SAMPLE_RATE 1296 -#define IDC_JOYBUS_HOSTNAME 1297 -#define IDC_JOYBUS_ENABLE 1298 +#define IDC_LINK_MODE 1296 +#define IDC_LINK_WITH 1300 +#define IDC_STATIC_TIMEOUT 1301 +#define IDC_LINK_SERVER 1302 +#define IDC_LINK_CLIENT 1303 +#define IDC_GROUP_NETWORK 1304 +#define IDC_LINK_ROLE 1305 #define IDS_OAL_NODEVICE 2000 #define IDS_OAL_NODLL 2001 #define IDS_AVI_CANNOT_CREATE_AVI 2002 @@ -815,10 +819,7 @@ #define ID_OPTIONS_SOUND_PCMINTERPOLATION_CUBIC 40296 #define ID_OPTIONS_SOUND_PCMINTERPOLATION_FIR 40297 #define ID_OPTIONS_SOUND_PCMINTERPOLATION_LIBRESAMPLE 40298 -#define IDD_LINKTAB1 40300 #define IDD_LINKTAB 40301 -#define IDD_LINKTAB2 40302 -#define IDD_LINKTAB3 40303 #define IDD_SERVERWAIT 40304 #define IDC_TAB1 40305 #define IDC_LINK_SINGLE 40306 @@ -827,25 +828,17 @@ #define IDC_LINK_LAN 40308 #define IDC_LINK2P 40309 #define IDC_LINK_RFU 40309 -#define IDC_LINKTCP 40310 #define IDC_LINK_GAMECUBE 40310 #define IDC_SSPEED 40311 -#define IDC_SERVERSTART 40312 #define IDC_SERVERIP 40313 #define IDC_CLINKIP 40314 -#define IDC_SPEEDOFF 40315 -#define IDC_LINKCONNECT 40316 #define ID_OPTIONS_LINK_OPTIONS 40318 #define ID_OPTIONS_LINK_LOG 40319 #define ID_OPTIONS_LINK_WIRELESSADAPTER 40320 #define IDC_LINKTIMEOUT 40321 -#define IDC_CLINKTCP 40322 #define IDC_SERVERWAIT 40323 -#define IDC_LINKUDP 40324 #define IDC_LINK3P 40325 #define IDC_LINK4P 40326 -#define IDC_CLINKUDP 40327 -#define IDC_SPEEDON 40328 #define ID_OPTIONS_EMULATOR_REMOVEINTROSGBA 40331 #define ID_Menu 40332 #define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLANISOTROPIC 40333 @@ -891,9 +884,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 166 +#define _APS_NEXT_RESOURCE_VALUE 167 #define _APS_NEXT_COMMAND_VALUE 40377 -#define _APS_NEXT_CONTROL_VALUE 1299 +#define _APS_NEXT_CONTROL_VALUE 1306 #define _APS_NEXT_SYMED_VALUE 103 #endif #endif