mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
Clean up saved games dialogs, and remove (temporarily) controls that
won't do anything for b2. Rename a couple of structs.
This commit is contained in:
parent
63419db11a
commit
ac63d5621f
3 changed files with 102 additions and 64 deletions
|
@ -26,21 +26,20 @@
|
|||
#include "ceutil.h"
|
||||
#include "cedebug.h"
|
||||
|
||||
typedef struct SaveGameNameState {
|
||||
typedef struct CeSaveGameNameState {
|
||||
CEAppGlobals* globals;
|
||||
/* HWND hDlg; */
|
||||
wchar_t* buf;
|
||||
XP_U16 buflen;
|
||||
XP_Bool cancelled;
|
||||
XP_Bool inited;
|
||||
} SaveGameNameState;
|
||||
} CeSaveGameNameState;
|
||||
|
||||
static void
|
||||
notImpl( CEAppGlobals* globals )
|
||||
{
|
||||
messageBoxChar( globals, "To be implemented soon....",
|
||||
L"Notice", MB_OK );
|
||||
}
|
||||
/* static void */
|
||||
/* notImpl( CEAppGlobals* globals ) */
|
||||
/* { */
|
||||
/* messageBoxChar( globals, "To be implemented soon....", */
|
||||
/* L"Notice", MB_OK ); */
|
||||
/* } */
|
||||
|
||||
static XP_Bool
|
||||
ceFileExists( const wchar_t* name )
|
||||
|
@ -58,7 +57,8 @@ makeUniqueName( wchar_t* buf, XP_U16 bufLen )
|
|||
{
|
||||
XP_U16 ii;
|
||||
for ( ii = 1; ii < 100; ++ii ) {
|
||||
swprintf( buf, L"Untitled%d", ii );
|
||||
int len = swprintf( buf, L"Untitled%d", ii );
|
||||
XP_ASSERT( len < bufLen );
|
||||
if ( !ceFileExists( buf ) ) {
|
||||
break;
|
||||
}
|
||||
|
@ -70,14 +70,14 @@ makeUniqueName( wchar_t* buf, XP_U16 bufLen )
|
|||
static LRESULT CALLBACK
|
||||
SaveNameDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
SaveGameNameState* state;
|
||||
CeSaveGameNameState* state;
|
||||
XP_U16 wid;
|
||||
BOOL result = FALSE;
|
||||
|
||||
if ( message == WM_INITDIALOG ) {
|
||||
SetWindowLong( hDlg, GWL_USERDATA, lParam );
|
||||
|
||||
state = (SaveGameNameState*)lParam;
|
||||
state = (CeSaveGameNameState*)lParam;
|
||||
state->cancelled = XP_TRUE;
|
||||
state->inited = XP_FALSE;
|
||||
|
||||
|
@ -85,11 +85,11 @@ SaveNameDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
|||
|
||||
result = TRUE;
|
||||
} else {
|
||||
state = (SaveGameNameState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||
state = (CeSaveGameNameState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||
if ( !!state ) {
|
||||
if ( !state->inited ) {
|
||||
(void)SetDlgItemText( hDlg, IDC_SVGN_EDIT, state->buf );
|
||||
state->inited = XP_TRUE;
|
||||
(void)SetDlgItemText( hDlg, IDC_SVGN_EDIT, state->buf );
|
||||
}
|
||||
|
||||
switch (message) {
|
||||
|
@ -119,12 +119,12 @@ SaveNameDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
|||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} /* SaveNameDlg */
|
||||
|
||||
XP_Bool
|
||||
ceConfirmUniqueName( CEAppGlobals* globals, wchar_t* buf, XP_U16 buflen )
|
||||
{
|
||||
SaveGameNameState state;
|
||||
CeSaveGameNameState state;
|
||||
|
||||
LOG_FUNC();
|
||||
|
||||
|
@ -141,21 +141,22 @@ ceConfirmUniqueName( CEAppGlobals* globals, wchar_t* buf, XP_U16 buflen )
|
|||
return !state.cancelled;
|
||||
} /* ceConfirmUniqueName */
|
||||
|
||||
typedef struct SavedGamesState {
|
||||
typedef struct CeSavedGamesState {
|
||||
CEAppGlobals* globals;
|
||||
HWND hDlg;
|
||||
wchar_t* buf;
|
||||
XP_U16 buflen;
|
||||
XP_S16 sel;
|
||||
wchar_t curName[128];
|
||||
XP_U16 nItems;
|
||||
|
||||
/* wchar_t** names; */
|
||||
/* XP_U16 nNamesUsed; */
|
||||
/* XP_U16 nNamesAllocd; */
|
||||
|
||||
XP_Bool cancelled;
|
||||
XP_Bool opened;
|
||||
XP_Bool inited;
|
||||
} SavedGamesState;
|
||||
} CeSavedGamesState;
|
||||
|
||||
/* Probably belongs as a utility */
|
||||
static void
|
||||
|
@ -171,18 +172,26 @@ getCBText( HWND hDlg, XP_U16 id, XP_U16 sel, wchar_t* buf, XP_U16* lenp )
|
|||
} /* getCBText */
|
||||
|
||||
static void
|
||||
setEditFromSel( SavedGamesState* state )
|
||||
setEditFromSel( CeSavedGamesState* XP_UNUSED(state) )
|
||||
{
|
||||
wchar_t buf[64];
|
||||
XP_U16 len = VSIZE(buf);
|
||||
getCBText( state->hDlg, IDC_SVGM_GAMELIST, state->sel, buf, &len );
|
||||
if ( len <= VSIZE(buf) ) {
|
||||
(void)SetDlgItemText( state->hDlg, IDC_SVGM_EDIT, buf );
|
||||
}
|
||||
/* wchar_t buf[64]; */
|
||||
/* XP_U16 len = VSIZE(buf); */
|
||||
/* getCBText( state->hDlg, IDC_SVGM_GAMELIST, state->sel, buf, &len ); */
|
||||
/* if ( len <= VSIZE(buf) ) { */
|
||||
/* (void)SetDlgItemText( state->hDlg, IDC_SVGM_EDIT, buf ); */
|
||||
/* } */
|
||||
} /* */
|
||||
|
||||
static void
|
||||
initSavedGamesData( SavedGamesState* state )
|
||||
setButtons( CeSavedGamesState* state )
|
||||
{
|
||||
/* Open button disabled by default in case no games */
|
||||
ceEnOrDisable( state->hDlg, IDC_SVGM_OPEN, state->nItems > 0 );
|
||||
/* ceEnOrDisable( state->hDlg, IDC_SVGM_DEL, state->nItems > 0 ); */
|
||||
}
|
||||
|
||||
static void
|
||||
initSavedGamesData( CeSavedGamesState* state )
|
||||
{
|
||||
HANDLE fileH;
|
||||
WIN32_FIND_DATA data;
|
||||
|
@ -208,6 +217,8 @@ initSavedGamesData( SavedGamesState* state )
|
|||
SendDlgItemMessage( state->hDlg, IDC_SVGM_GAMELIST, ADDSTRING,
|
||||
0, (LPARAM)data.cFileName );
|
||||
|
||||
++state->nItems;
|
||||
|
||||
if ( !FindNextFile( fileH, &data ) ) {
|
||||
XP_ASSERT( GetLastError() == ERROR_NO_MORE_FILES );
|
||||
break;
|
||||
|
@ -218,29 +229,51 @@ initSavedGamesData( SavedGamesState* state )
|
|||
state->sel = curSel;
|
||||
setEditFromSel( state );
|
||||
|
||||
setButtons( state );
|
||||
|
||||
LOG_RETURN_VOID();
|
||||
} /* initSavedGamesData */
|
||||
|
||||
/* static void */
|
||||
/* deleteSelected( CeSavedGamesState* state ) */
|
||||
/* { */
|
||||
/* wchar_t buf[128]; */
|
||||
/* wchar_t path[128]; */
|
||||
/* XP_U16 len = VSIZE(buf); */
|
||||
|
||||
/* /\* confirm first!!!! *\/ */
|
||||
|
||||
/* getCBText( state->hDlg, IDC_SVGM_GAMELIST, state->sel, buf, &len ); */
|
||||
/* swprintf( path, DEFAULT_DIR_NAME L"\\%s.xwg", buf ); */
|
||||
/* DeleteFile( path ); */
|
||||
|
||||
/* SendDlgItemMessage( state->hDlg, IDC_SVGM_GAMELIST, DELETESTRING, */
|
||||
/* state->sel, 0L ); */
|
||||
|
||||
/* --state->nItems; */
|
||||
|
||||
/* setButtons( state ); */
|
||||
/* } */
|
||||
|
||||
static LRESULT CALLBACK
|
||||
SavedGamesDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
SavedGamesState* state;
|
||||
CeSavedGamesState* state;
|
||||
XP_U16 wid;
|
||||
BOOL result = FALSE;
|
||||
|
||||
if ( message == WM_INITDIALOG ) {
|
||||
SetWindowLong( hDlg, GWL_USERDATA, lParam );
|
||||
|
||||
state = (SavedGamesState*)lParam;
|
||||
state = (CeSavedGamesState*)lParam;
|
||||
state->hDlg = hDlg;
|
||||
state->cancelled = XP_TRUE;
|
||||
state->inited = XP_FALSE;
|
||||
|
||||
ceDlgSetup( state->globals, hDlg );
|
||||
|
||||
result = TRUE;
|
||||
} else {
|
||||
state = (SavedGamesState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||
state = (CeSavedGamesState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||
if ( !!state ) {
|
||||
|
||||
if ( !state->inited ) {
|
||||
|
@ -278,25 +311,26 @@ SavedGamesDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
|||
}
|
||||
break;
|
||||
|
||||
case IDC_SVGM_DUP:
|
||||
case IDC_SVGM_DEL:
|
||||
case IDC_SVGM_CHANGE:
|
||||
notImpl( state->globals );
|
||||
break;
|
||||
/* case IDC_SVGM_DUP: */
|
||||
/* case IDC_SVGM_CHANGE: */
|
||||
/* notImpl( state->globals ); */
|
||||
/* break; */
|
||||
/* case IDC_SVGM_DEL: */
|
||||
/* deleteSelected( state ); */
|
||||
/* break; */
|
||||
|
||||
case IDC_SVGM_OPEN: {
|
||||
wchar_t buf[128];
|
||||
XP_U16 len = sizeof(buf);
|
||||
XP_U16 len = VSIZE(buf);
|
||||
getCBText( state->hDlg, IDC_SVGM_GAMELIST, state->sel,
|
||||
buf, &len );
|
||||
swprintf( state->buf, DEFAULT_DIR_NAME L"\\%s.xwg", buf );
|
||||
XP_LOGW( "returning", state->buf );
|
||||
state->opened = XP_TRUE;
|
||||
}
|
||||
/* fallthrough */
|
||||
case IDOK:
|
||||
state->cancelled = XP_FALSE;
|
||||
/* fallthrough */
|
||||
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlg, wid);
|
||||
result = TRUE;
|
||||
|
@ -313,7 +347,7 @@ XP_Bool
|
|||
ceSavedGamesDlg( CEAppGlobals* globals, const XP_UCHAR* curPath,
|
||||
wchar_t* buf, XP_U16 buflen )
|
||||
{
|
||||
SavedGamesState state;
|
||||
CeSavedGamesState state;
|
||||
|
||||
LOG_FUNC();
|
||||
|
||||
|
@ -341,5 +375,5 @@ ceSavedGamesDlg( CEAppGlobals* globals, const XP_UCHAR* curPath,
|
|||
|
||||
XP_LOGW( __func__, buf );
|
||||
|
||||
return !state.cancelled;
|
||||
return state.opened;
|
||||
} /*ceSavedGamesDlg */
|
||||
|
|
|
@ -162,11 +162,12 @@
|
|||
|
||||
#define IDC_SVGM_SELLAB 1109
|
||||
#define IDC_SVGM_GAMELIST 1110
|
||||
#define IDC_SVGM_EDITLAB 1111
|
||||
#define IDC_SVGM_CHANGE 1112
|
||||
#define IDC_SVGM_EDIT 1113
|
||||
#define IDC_SVGM_DUP 1114
|
||||
#define IDC_SVGM_DEL 1115
|
||||
/* Let's remove these until they're implemented */
|
||||
/* #define IDC_SVGM_EDITLAB 1111 */
|
||||
/* #define IDC_SVGM_CHANGE 1112 */
|
||||
/* #define IDC_SVGM_EDIT 1113 */
|
||||
/* #define IDC_SVGM_DUP 1114 */
|
||||
/* #define IDC_SVGM_DEL 1115 */
|
||||
#define IDC_SVGM_OPEN 1116
|
||||
|
||||
#define IDC_SVGN_SELLAB 1117
|
||||
|
|
|
@ -378,13 +378,13 @@ CAPTION "Game name"
|
|||
FONT 8, "System"
|
||||
BEGIN
|
||||
LTEXT "To save this game, give it a name. (You can change the name later using the Saved games dialog.)",
|
||||
IDC_SVGN_SELLAB,SVGN_LEFT_COL,SVGN_ROW_1,90,40
|
||||
EDITTEXT IDC_SVGN_EDIT,SVGN_LEFT_COL,SVGN_ROW_2,80,12,
|
||||
IDC_SVGN_SELLAB,SVGN_LEFT_COL,SVGN_ROW_1,86,40
|
||||
EDITTEXT IDC_SVGN_EDIT,SVGN_LEFT_COL,SVGN_ROW_2,86,12,
|
||||
ES_AUTOHSCROLL
|
||||
#ifndef _WIN32_WCE
|
||||
DEFPUSHBUTTON "OK",IDOK,SVGN_LEFT_COL,SVGN_ROW_3,REPOS_BUTTON_WIDTH,
|
||||
DEFPUSHBUTTON "OK",IDOK,SVGN_LEFT_COL+10,SVGN_ROW_3,REPOS_BUTTON_WIDTH,
|
||||
BUTTON_HT
|
||||
PUSHBUTTON "Cancel",IDCANCEL,SVGN_LEFT_COL+REPOS_BUTTON_WIDTH+10,
|
||||
PUSHBUTTON "Cancel",IDCANCEL,SVGN_LEFT_COL+10+REPOS_BUTTON_WIDTH+10,
|
||||
SVGN_ROW_3,REPOS_BUTTON_WIDTH, BUTTON_HT
|
||||
#endif
|
||||
END
|
||||
|
@ -393,11 +393,14 @@ END
|
|||
#define SVGM_ROW_1 2
|
||||
#define SVGM_ROW_2 (SVGM_ROW_1+22)
|
||||
#define SVGM_ROW_3 (SVGM_ROW_2+23)
|
||||
#define SVGM_ROW_4 (SVGM_ROW_3+30)
|
||||
/* #define SVGM_ROW_4 (SVGM_ROW_3+30) */
|
||||
#ifdef _WIN32_WCE
|
||||
# define SVGM_DLG_HT (SVGM_ROW_4)
|
||||
# define SVGM_DLG_HT (SVGM_ROW_3)
|
||||
/* # define SVGM_DLG_HT (SVGM_ROW_4) */
|
||||
#else
|
||||
# define SVGM_DLG_HT (SVGM_ROW_4 + 18)
|
||||
# define SVGM_ROW_OK (SVGM_ROW_2 + 18)
|
||||
# define SVGM_DLG_HT (SVGM_ROW_OK + 18)
|
||||
/* # define SVGM_DLG_HT (SVGM_ROW_4 + 18) */
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -420,21 +423,21 @@ BEGIN
|
|||
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
#endif
|
||||
|
||||
PUSHBUTTON "Dup.",IDC_SVGM_DUP,SVGM_LEFT_COL,SVGM_ROW_2,20,14,WS_DISABLED
|
||||
PUSHBUTTON "Delete",IDC_SVGM_DEL,SVGM_LEFT_COL+22,SVGM_ROW_2,25,14,WS_DISABLED
|
||||
PUSHBUTTON "Open",IDC_SVGM_OPEN,SVGM_LEFT_COL+54,SVGM_ROW_2,25,14
|
||||
/* PUSHBUTTON "Dup.",IDC_SVGM_DUP,SVGM_LEFT_COL,SVGM_ROW_2,20,14,WS_DISABLED */
|
||||
/* PUSHBUTTON "Delete",IDC_SVGM_DEL,SVGM_LEFT_COL+22,SVGM_ROW_2,25,14,WS_DISABLED */
|
||||
PUSHBUTTON "Open",IDC_SVGM_OPEN,SVGM_LEFT_COL+54,SVGM_ROW_2,25,14,WS_DISABLED
|
||||
|
||||
LTEXT "Edit its name",IDC_SVGM_EDITLAB,SVGM_LEFT_COL,SVGM_ROW_3,
|
||||
45,12
|
||||
PUSHBUTTON "Rename",IDC_SVGM_CHANGE,SVGM_LEFT_COL+46,SVGM_ROW_3,32,12,WS_DISABLED
|
||||
EDITTEXT IDC_SVGM_EDIT,SVGM_LEFT_COL+5,SVGM_ROW_3+15,70,12,
|
||||
ES_AUTOHSCROLL
|
||||
/* LTEXT "Edit its name",IDC_SVGM_EDITLAB,SVGM_LEFT_COL,SVGM_ROW_3, */
|
||||
/* 45,12 */
|
||||
/* PUSHBUTTON "Rename",IDC_SVGM_CHANGE,SVGM_LEFT_COL+46,SVGM_ROW_3,32,12,WS_DISABLED */
|
||||
/* EDITTEXT IDC_SVGM_EDIT,SVGM_LEFT_COL+5,SVGM_ROW_3+15,70,12, */
|
||||
/* ES_AUTOHSCROLL */
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
DEFPUSHBUTTON "OK",IDOK,SVGM_LEFT_COL,SVGM_ROW_4,REPOS_BUTTON_WIDTH,
|
||||
DEFPUSHBUTTON "OK",IDOK,SVGM_LEFT_COL+10,SVGM_ROW_OK,REPOS_BUTTON_WIDTH,
|
||||
BUTTON_HT
|
||||
PUSHBUTTON "Cancel",IDCANCEL,SVGM_LEFT_COL+REPOS_BUTTON_WIDTH+10,
|
||||
SVGM_ROW_4,REPOS_BUTTON_WIDTH, BUTTON_HT
|
||||
PUSHBUTTON "Cancel",IDCANCEL,SVGM_LEFT_COL+10+REPOS_BUTTON_WIDTH+10,
|
||||
SVGM_ROW_OK,REPOS_BUTTON_WIDTH, BUTTON_HT
|
||||
#endif
|
||||
END
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue