From f874183475237adc0e994452ef2e719a39c29357 Mon Sep 17 00:00:00 2001 From: ehouse Date: Sun, 8 Mar 2009 20:00:20 +0000 Subject: [PATCH] Use nwgamest support for separate config button beside role combo, and remove hack responding to tap (without change) on that combo. --- xwords4/wince/ceginfo.c | 71 ++++++++++++++++++---------------------- xwords4/wince/resource.h | 2 +- xwords4/wince/xwords4.rc | 1 + 3 files changed, 33 insertions(+), 41 deletions(-) diff --git a/xwords4/wince/ceginfo.c b/xwords4/wince/ceginfo.c index 45b8f1ef1..50e6bbbdd 100755 --- a/xwords4/wince/ceginfo.c +++ b/xwords4/wince/ceginfo.c @@ -325,27 +325,34 @@ handlePrefsButton( HWND hDlg, CEAppGlobals* globals, GameInfoState* state ) #ifndef XWFEATURE_STANDALONE_ONLY static void -handleConnOptionsButton( GameInfoState* state, DeviceRole role ) +callConnsDlg( GameInfoState* state ) +{ + if ( WrapConnsDlg( state->dlgHdr.hDlg, state->dlgHdr.globals, + &state->prefsPrefs.addrRec, + &state->prefsPrefs.addrRec, state->lastRole, + state->isNewGame ) ) { + state->addrChanged = XP_TRUE; + } +} + + +static void +handleConnOptionsButton( GameInfoState* state ) { HWND hDlg = state->dlgHdr.hDlg; CEAppGlobals* globals = state->dlgHdr.globals; + DeviceRole role; + NGValue value; - if ( role == SERVER_STANDALONE ) { - NGValue value; - role = (DeviceRole)SendDlgItemMessage( hDlg, - state->roleComboId, - GETCURSEL(globals), 0, - 0L); - value.ng_role = role; - newg_attrChanged( state->newGameCtx, NG_ATTR_ROLE, value ); - } + role = (DeviceRole)SendDlgItemMessage( hDlg, state->roleComboId, + GETCURSEL(globals), 0, 0L); + value.ng_role = role; + newg_attrChanged( state->newGameCtx, NG_ATTR_ROLE, value ); - state->lastRole = role; - if ( role != SERVER_STANDALONE) { - if ( WrapConnsDlg( hDlg, globals, &state->prefsPrefs.addrRec, - &state->prefsPrefs.addrRec, role, - state->isNewGame ) ) { - state->addrChanged = XP_TRUE; + if ( state->lastRole != role ) { + state->lastRole = role; + if ( role != SERVER_STANDALONE ) { + callConnsDlg( state ); } } } /* handleConnOptionsButton */ @@ -387,6 +394,9 @@ resIDForAttr( GameInfoState* state, NewGameAttr attr ) case NG_ATTR_ROLE: resID = state->roleComboId; break; + case NG_ATTR_CANCONFIG: + resID = GIROLECONF_BUTTON; + break; case NG_ATTR_REMHEADER: resID = IDC_REMOTE_LABEL; break; @@ -582,26 +592,10 @@ checkUpdateCombo( GameInfoState* state, XP_U16 id ) } } else if ( id == state->roleComboId ) { XP_ASSERT( SERVER_STANDALONE == 0 ); - handleConnOptionsButton( state, SERVER_STANDALONE ); + handleConnOptionsButton( state ); } } /* checkUpdateCombo */ -/* If we're mid-game and can't change role, click on role dropdown should - * still bring up conns dialog in read-only mode. - */ -static void -checkRoleClick( GameInfoState* state, XP_U16 xx, XP_U16 yy ) -{ - RECT rect; - ceGetItemRect( state->dlgHdr.hDlg, state->roleComboId, &rect ); - - /* Isn't there API for PtInRect? */ - if ( xx > rect.left && xx < rect.right - && yy > rect.top && yy < rect.bottom ) { - handleConnOptionsButton( state, state->lastRole ); - } -} /* checkRoleClick */ - LRESULT CALLBACK GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { @@ -674,12 +668,6 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } break; - case WM_LBUTTONUP: - if ( !state->isNewGame ) { - checkRoleClick( state, LOWORD(lParam), HIWORD(lParam) ); - } - break; - case WM_COMMAND: result = TRUE; id = LOWORD(wParam); @@ -713,9 +701,12 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if ( HIWORD(wParam) == CBN_SELCHANGE ) { /* If we've switched to a state where we'll be connecting */ - handleConnOptionsButton( state, SERVER_STANDALONE ); + handleConnOptionsButton( state ); } break; + case GIROLECONF_BUTTON: + callConnsDlg( state ); + break; #endif case GIJUGGLE_BUTTON: XP_ASSERT( state->isNewGame ); diff --git a/xwords4/wince/resource.h b/xwords4/wince/resource.h index c45f27ad8..26d6ff836 100755 --- a/xwords4/wince/resource.h +++ b/xwords4/wince/resource.h @@ -74,7 +74,7 @@ #define IDC_PREFCOLORS 1045 #define IDC_PREFFONTS 1046 #define PHONIES_LABEL 1048 -/* #define IDC_ROLECOMBO 1049 */ +#define GIROLECONF_BUTTON 1049 #define GIJUGGLE_BUTTON 1050 #define IDC_TOTAL_LABEL 1051 #define IDC_REMOTE_LABEL 1052 diff --git a/xwords4/wince/xwords4.rc b/xwords4/wince/xwords4.rc index e66d37857..4b14621e6 100755 --- a/xwords4/wince/xwords4.rc +++ b/xwords4/wince/xwords4.rc @@ -271,6 +271,7 @@ BEGIN #endif COMBOBOX IDC_ROLECOMBO_PPC,25,SERVERROLE_ROW,50,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Conf.",GIROLECONF_BUTTON,75,SERVERROLE_ROW,20,ROW_HEIGHT #endif