winemine: Convert to Unicode.

This commit is contained in:
Alexandre Julliard 2012-01-19 20:24:31 +01:00
parent be91790988
commit 020faceaae
6 changed files with 95 additions and 75 deletions

View File

@ -1,5 +1,6 @@
MODULE = winemine.exe
APPMODE = -mwindows
APPMODE = -mwindows -municode
EXTRADEFS = -DWINE_NO_UNICODE_MACROS
IMPORTS = user32 gdi32 advapi32
DELAYIMPORTS = shell32

View File

@ -63,16 +63,15 @@ INT_PTR CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP
switch( uMsg ) {
case WM_INITDIALOG:
p_board = (BOARD*) lParam;
SetDlgItemText( hDlg, IDC_EDITNAME,
p_board->best_name[p_board->difficulty] );
SetDlgItemTextW( hDlg, IDC_EDITNAME, p_board->best_name[p_board->difficulty] );
return TRUE;
case WM_COMMAND:
switch( LOWORD( wParam ) ) {
case IDOK:
GetDlgItemText( hDlg, IDC_EDITNAME,
GetDlgItemTextW( hDlg, IDC_EDITNAME,
p_board->best_name[p_board->difficulty],
sizeof( p_board->best_name[p_board->difficulty] ) );
sizeof( p_board->best_name[p_board->difficulty] ) / sizeof(WCHAR) );
EndDialog( hDlg, 0 );
return TRUE;
@ -96,7 +95,7 @@ INT_PTR CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
/* set best names */
for( i = 0; i < 3; i++ )
SetDlgItemText( hDlg, (IDC_NAME1) + i, p_board->best_name[i] );
SetDlgItemTextW( hDlg, (IDC_NAME1) + i, p_board->best_name[i] );
/* set best times */
for( i = 0; i < 3; i++ )

View File

@ -33,8 +33,19 @@
WINE_DEFAULT_DEBUG_CHANNEL(winemine);
static const DWORD wnd_style = WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX;
static const char* registry_key = "Software\\Microsoft\\WinMine";
static const WCHAR registry_key[] = {'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','M','i','n','e',0};
static const WCHAR xposW[] = {'X','p','o','s',0};
static const WCHAR yposW[] = {'Y','p','o','s',0};
static const WCHAR heightW[] = {'H','e','i','g','h','t',0};
static const WCHAR widthW[] = {'W','i','d','t','h',0};
static const WCHAR minesW[] = {'M','i','n','e','s',0};
static const WCHAR difficultyW[] = {'D','i','f','f','i','c','u','l','t','y',0};
static const WCHAR markW[] = {'M','a','r','k',0};
static const WCHAR nameW[] = {'N','a','m','e','%','u',0};
static const WCHAR timeW[] = {'T','i','m','e','%','u',0};
void CheckLevel( BOARD *p_board )
{
@ -62,62 +73,61 @@ static void LoadBoard( BOARD *p_board )
DWORD size;
DWORD type;
HKEY hkey;
char data[MAX_PLAYER_NAME_SIZE+1];
char key_name[8];
WCHAR data[MAX_PLAYER_NAME_SIZE+1];
WCHAR key_name[8];
unsigned i;
RegOpenKeyEx( HKEY_CURRENT_USER, registry_key,
0, KEY_QUERY_VALUE, &hkey );
RegOpenKeyExW( HKEY_CURRENT_USER, registry_key, 0, KEY_QUERY_VALUE, &hkey );
size = sizeof( p_board->pos.x );
if( !RegQueryValueEx( hkey, "Xpos", NULL, &type,
if( !RegQueryValueExW( hkey, xposW, NULL, &type,
(LPBYTE) &p_board->pos.x, &size ) == ERROR_SUCCESS )
p_board->pos.x = 0;
size = sizeof( p_board->pos.y );
if( !RegQueryValueEx( hkey, "Ypos", NULL, &type,
if( !RegQueryValueExW( hkey, yposW, NULL, &type,
(LPBYTE) &p_board->pos.y, &size ) == ERROR_SUCCESS )
p_board->pos.y = 0;
size = sizeof( p_board->rows );
if( !RegQueryValueEx( hkey, "Height", NULL, &type,
if( !RegQueryValueExW( hkey, heightW, NULL, &type,
(LPBYTE) &p_board->rows, &size ) == ERROR_SUCCESS )
p_board->rows = BEGINNER_ROWS;
size = sizeof( p_board->cols );
if( !RegQueryValueEx( hkey, "Width", NULL, &type,
if( !RegQueryValueExW( hkey, widthW, NULL, &type,
(LPBYTE) &p_board->cols, &size ) == ERROR_SUCCESS )
p_board->cols = BEGINNER_COLS;
size = sizeof( p_board->mines );
if( !RegQueryValueEx( hkey, "Mines", NULL, &type,
if( !RegQueryValueExW( hkey, minesW, NULL, &type,
(LPBYTE) &p_board->mines, &size ) == ERROR_SUCCESS )
p_board->mines = BEGINNER_MINES;
size = sizeof( p_board->difficulty );
if( !RegQueryValueEx( hkey, "Difficulty", NULL, &type,
if( !RegQueryValueExW( hkey, difficultyW, NULL, &type,
(LPBYTE) &p_board->difficulty, &size ) == ERROR_SUCCESS )
p_board->difficulty = BEGINNER;
size = sizeof( p_board->IsMarkQ );
if( !RegQueryValueEx( hkey, "Mark", NULL, &type,
if( !RegQueryValueExW( hkey, markW, NULL, &type,
(LPBYTE) &p_board->IsMarkQ, &size ) == ERROR_SUCCESS )
p_board->IsMarkQ = TRUE;
for( i = 0; i < 3; i++ ) {
wsprintf( key_name, "Name%d", i+1 );
wsprintfW( key_name, nameW, i+1 );
size = sizeof( data );
if( RegQueryValueEx( hkey, key_name, NULL, &type,
if( RegQueryValueExW( hkey, key_name, NULL, &type,
(LPBYTE) data, &size ) == ERROR_SUCCESS )
lstrcpynA( p_board->best_name[i], data, sizeof(p_board->best_name[i]) );
lstrcpynW( p_board->best_name[i], data, sizeof(p_board->best_name[i])/sizeof(WCHAR) );
else
LoadString( p_board->hInst, IDS_NOBODY, p_board->best_name[i], MAX_PLAYER_NAME_SIZE+1 );
LoadStringW( p_board->hInst, IDS_NOBODY, p_board->best_name[i], MAX_PLAYER_NAME_SIZE+1 );
}
for( i = 0; i < 3; i++ ) {
wsprintf( key_name, "Time%d", i+1 );
wsprintfW( key_name, timeW, i+1 );
size = sizeof( p_board->best_time[i] );
if( !RegQueryValueEx( hkey, key_name, NULL, &type,
if( !RegQueryValueExW( hkey, key_name, NULL, &type,
(LPBYTE) &p_board->best_time[i], &size ) == ERROR_SUCCESS )
p_board->best_time[i] = 999;
}
@ -128,9 +138,9 @@ static void InitBoard( BOARD *p_board )
{
HMENU hMenu;
p_board->hMinesBMP = LoadBitmap( p_board->hInst, "mines");
p_board->hFacesBMP = LoadBitmap( p_board->hInst, "faces");
p_board->hLedsBMP = LoadBitmap( p_board->hInst, "leds");
p_board->hMinesBMP = LoadBitmapW( p_board->hInst, MAKEINTRESOURCEW(IDI_MINES));
p_board->hFacesBMP = LoadBitmapW( p_board->hInst, MAKEINTRESOURCEW(IDI_FACES));
p_board->hLedsBMP = LoadBitmapW( p_board->hInst, MAKEINTRESOURCEW(IDI_LEDS));
LoadBoard( p_board );
@ -148,32 +158,32 @@ static void SaveBoard( BOARD *p_board )
{
HKEY hkey;
unsigned i;
char data[MAX_PLAYER_NAME_SIZE+1];
char key_name[8];
WCHAR data[MAX_PLAYER_NAME_SIZE+1];
WCHAR key_name[8];
if( RegCreateKeyEx( HKEY_CURRENT_USER, registry_key,
if( RegCreateKeyExW( HKEY_CURRENT_USER, registry_key,
0, NULL,
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
&hkey, NULL ) != ERROR_SUCCESS)
return;
RegSetValueEx( hkey, "Xpos", 0, REG_DWORD, (LPBYTE) &p_board->pos.x, sizeof(p_board->pos.x) );
RegSetValueEx( hkey, "Ypos", 0, REG_DWORD, (LPBYTE) &p_board->pos.y, sizeof(p_board->pos.y) );
RegSetValueEx( hkey, "Difficulty", 0, REG_DWORD, (LPBYTE) &p_board->difficulty, sizeof(p_board->difficulty) );
RegSetValueEx( hkey, "Height", 0, REG_DWORD, (LPBYTE) &p_board->rows, sizeof(p_board->rows) );
RegSetValueEx( hkey, "Width", 0, REG_DWORD, (LPBYTE) &p_board->cols, sizeof(p_board->cols) );
RegSetValueEx( hkey, "Mines", 0, REG_DWORD, (LPBYTE) &p_board->mines, sizeof(p_board->mines) );
RegSetValueEx( hkey, "Mark", 0, REG_DWORD, (LPBYTE) &p_board->IsMarkQ, sizeof(p_board->IsMarkQ) );
RegSetValueExW( hkey, xposW, 0, REG_DWORD, (LPBYTE) &p_board->pos.x, sizeof(p_board->pos.x) );
RegSetValueExW( hkey, yposW, 0, REG_DWORD, (LPBYTE) &p_board->pos.y, sizeof(p_board->pos.y) );
RegSetValueExW( hkey, difficultyW, 0, REG_DWORD, (LPBYTE) &p_board->difficulty, sizeof(p_board->difficulty) );
RegSetValueExW( hkey, heightW, 0, REG_DWORD, (LPBYTE) &p_board->rows, sizeof(p_board->rows) );
RegSetValueExW( hkey, widthW, 0, REG_DWORD, (LPBYTE) &p_board->cols, sizeof(p_board->cols) );
RegSetValueExW( hkey, minesW, 0, REG_DWORD, (LPBYTE) &p_board->mines, sizeof(p_board->mines) );
RegSetValueExW( hkey, markW, 0, REG_DWORD, (LPBYTE) &p_board->IsMarkQ, sizeof(p_board->IsMarkQ) );
for( i = 0; i < 3; i++ ) {
wsprintf( key_name, "Name%u", i+1 );
lstrcpyn( data, p_board->best_name[i], sizeof( data ) );
RegSetValueEx( hkey, key_name, 0, REG_SZ, (LPBYTE) data, strlen(data)+1 );
wsprintfW( key_name, nameW, i+1 );
lstrcpynW( data, p_board->best_name[i], sizeof(data)/sizeof(WCHAR) );
RegSetValueExW( hkey, key_name, 0, REG_SZ, (LPBYTE) data, (lstrlenW(data)+1) * sizeof(WCHAR) );
}
for( i = 0; i < 3; i++ ) {
wsprintf( key_name, "Time%u", i+1 );
RegSetValueEx( hkey, key_name, 0, REG_DWORD, (LPBYTE) &p_board->best_time[i], sizeof(p_board->best_time[i]) );
wsprintfW( key_name, timeW, i+1 );
RegSetValueExW( hkey, key_name, 0, REG_DWORD, (LPBYTE) &p_board->best_time[i], sizeof(p_board->best_time[i]) );
}
RegCloseKey( hkey );
}
@ -190,7 +200,7 @@ static void SetDifficulty( BOARD *p_board, DIFFICULTY difficulty )
HMENU hMenu;
if ( difficulty == CUSTOM )
if (DialogBoxParam( p_board->hInst, "DLG_CUSTOM", p_board->hWnd,
if (DialogBoxParamW( p_board->hInst, MAKEINTRESOURCEW(DLG_CUSTOM), p_board->hWnd,
CustomDlgProc, (LPARAM) p_board) != 0)
return;
@ -246,7 +256,7 @@ static void MoveOnScreen(RECT* rect)
/* ... and move it into the work area (ie excluding task bar)*/
mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi);
GetMonitorInfoW(hMonitor, &mi);
ShiftBetween(&rect->left, &rect->right, mi.rcWork.left, mi.rcWork.right);
ShiftBetween(&rect->top, &rect->bottom, mi.rcWork.top, mi.rcWork.bottom);
@ -821,10 +831,9 @@ static void TestBoard( HWND hWnd, BOARD *p_board, int x, int y, int msg )
p_board->time < p_board->best_time[p_board->difficulty] ) {
p_board->best_time[p_board->difficulty] = p_board->time;
DialogBoxParam( p_board->hInst, "DLG_CONGRATS", hWnd,
DialogBoxParamW( p_board->hInst, MAKEINTRESOURCEW(DLG_CONGRATS), hWnd,
CongratsDlgProc, (LPARAM) p_board);
DialogBoxParam( p_board->hInst, "DLG_TIMES", hWnd,
DialogBoxParamW( p_board->hInst, MAKEINTRESOURCEW(DLG_TIMES), hWnd,
TimesDlgProc, (LPARAM) p_board);
}
}
@ -841,7 +850,7 @@ static LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
switch( msg ) {
case WM_CREATE:
board.hInst = ((LPCREATESTRUCT) lParam)->hInstance;
board.hInst = ((LPCREATESTRUCTW) lParam)->hInstance;
board.hWnd = hWnd;
InitBoard( &board );
CreateBoard( &board );
@ -980,11 +989,11 @@ static LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
return 0;
case IDM_EXIT:
SendMessage( hWnd, WM_CLOSE, 0, 0);
SendMessageW( hWnd, WM_CLOSE, 0, 0);
return 0;
case IDM_TIMES:
DialogBoxParam( board.hInst, "DLG_TIMES", hWnd,
DialogBoxParamW( board.hInst, MAKEINTRESOURCEW(DLG_TIMES), hWnd,
TimesDlgProc, (LPARAM) &board);
return 0;
@ -1002,18 +1011,18 @@ static LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
break;
}
}
return( DefWindowProc( hWnd, msg, wParam, lParam ));
return DefWindowProcW( hWnd, msg, wParam, lParam );
}
int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow )
int WINAPI wWinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR cmdline, int cmdshow )
{
MSG msg;
WNDCLASSEX wc;
WNDCLASSEXW wc;
HWND hWnd;
HACCEL haccel;
char appname[20];
WCHAR appname[20];
LoadString( hInst, IDS_APPNAME, appname, sizeof(appname));
LoadStringW( hInst, IDS_APPNAME, appname, sizeof(appname)/sizeof(WCHAR));
wc.cbSize = sizeof(wc);
wc.style = 0;
@ -1021,16 +1030,16 @@ int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmd
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInst;
wc.hIcon = LoadIcon( hInst, "WINEMINE" );
wc.hCursor = LoadCursor( 0, IDI_APPLICATION );
wc.hIcon = LoadIconW( hInst, MAKEINTRESOURCEW(IDI_WINEMINE) );
wc.hCursor = LoadCursorW( 0, (LPWSTR)IDI_APPLICATION );
wc.hbrBackground = GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = "MENU_WINEMINE";
wc.lpszMenuName = MAKEINTRESOURCEW(IDM_WINEMINE);
wc.lpszClassName = appname;
wc.hIconSm = LoadImage( hInst, "WINEMINE", IMAGE_ICON,
wc.hIconSm = LoadImageW( hInst, MAKEINTRESOURCEW(IDI_WINEMINE), IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED );
if (!RegisterClassEx(&wc)) ExitProcess(1);
hWnd = CreateWindow( appname, appname,
if (!RegisterClassExW(&wc)) ExitProcess(1);
hWnd = CreateWindowW( appname, appname,
wnd_style,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, hInst, NULL );
@ -1040,14 +1049,14 @@ int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmd
ShowWindow( hWnd, cmdshow );
UpdateWindow( hWnd );
haccel = LoadAccelerators( hInst, MAKEINTRESOURCE(IDA_WINEMINE) );
haccel = LoadAcceleratorsW( hInst, MAKEINTRESOURCEW(IDA_WINEMINE) );
SetTimer( hWnd, ID_TIMER, 1000, NULL );
while( GetMessage(&msg, 0, 0, 0) ) {
if (!TranslateAccelerator( hWnd, haccel, &msg ))
while( GetMessageW(&msg, 0, 0, 0) ) {
if (!TranslateAcceleratorW( hWnd, haccel, &msg ))
TranslateMessage( &msg );
DispatchMessage( &msg );
DispatchMessageW( &msg );
}
return msg.wParam;
}

View File

@ -86,7 +86,7 @@ typedef struct tagBOARD
unsigned rows;
unsigned cols;
unsigned mines;
char best_name [3][MAX_PLAYER_NAME_SIZE+1];
WCHAR best_name [3][MAX_PLAYER_NAME_SIZE+1];
DWORD best_time [3];
DIFFICULTY difficulty;

View File

@ -52,3 +52,14 @@
#define IDS_ABOUT 1103
#define IDA_WINEMINE 1201
#define IDM_WINEMINE 1
#define IDI_WINEMINE 1
#define IDI_FACES 2
#define IDI_LEDS 3
#define IDI_MINES 4
#define DLG_TIMES 1
#define DLG_CONGRATS 2
#define DLG_CUSTOM 3

View File

@ -29,7 +29,7 @@ STRINGTABLE {
IDS_ABOUT, "Copyright 2000 Joshua Thielen"
}
MENU_WINEMINE MENU
IDM_WINEMINE MENU
{
POPUP "&Game" {
MENUITEM "&New\tF2", IDM_NEW
@ -102,13 +102,13 @@ IDA_WINEMINE ACCELERATORS
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL
/* @makedep: winemine.ico */
WINEMINE ICON winemine.ico
IDI_WINEMINE ICON winemine.ico
/* @makedep: faces.bmp */
FACES BITMAP faces.bmp
IDI_FACES BITMAP faces.bmp
/* @makedep: leds.bmp */
LEDS BITMAP leds.bmp
IDI_LEDS BITMAP leds.bmp
/* @makedep: mines.bmp */
MINES BITMAP mines.bmp
IDI_MINES BITMAP mines.bmp