wince (from <Someone>)
Added support for
Palm-size PC (Windows CE 2.11) and Smartphone 2002.
It works fine under emulation, but it still needs to be tested
on real device. There are also some minor tweaks here and there.
Removed files:
sys/wince/recover.vcp
sys/wince/wince.vcp
New files:
sys/wince/winhcksp.rc
sys/wince/defaults.nh
sys/wince/hpc.vcp
sys/wince/palmpc.vcp
sys/wince/pocketpc.vcp
sys/wince/smartphn.vcp
<Someone>
This commit is contained in:
20
Files
20
Files
@@ -175,16 +175,16 @@ vmsmisc.c vmstty.c vmsunix.c
|
||||
|
||||
sys/wince:
|
||||
(files for Windows CE and PocketPC)
|
||||
assert.h bootstrp.mak celib.c cesetup.bat errno.h
|
||||
fcntl.h Install.ce keypad.uu mhaskyn.c mhaskyn.h
|
||||
mhcmd.c mhcmd.h mhcolor.c mhcolor.h mhdlg.c
|
||||
mhdlg.h mhfont.c mhfont.h mhinput.c mhinput.h
|
||||
mhmain.c mhmain.h mhmap.c mhmap.h mhmenu.c
|
||||
mhmenu.h mhmsg.h mhmsgwnd.c mhmsgwnd.h mhrip.c
|
||||
mhrip.h mhstatus.c mhstatus.h mhtext.c mhtext.h
|
||||
mswproc.c newres.h recover.vcp resource.h stat.h
|
||||
winMS.h wince.vcp wince.vcw winhack.c winhack.rc
|
||||
winmain.c
|
||||
assert.h bootstrp.mak celib.c cesetup.bat defaults.nh
|
||||
errno.h fcntl.h hpc.vcp Install.ce keypad.uu
|
||||
mhaskyn.c mhaskyn.h mhcmd.c mhcmd.h mhcolor.c
|
||||
mhcolor.h mhdlg.c mhdlg.h mhfont.c mhfont.h
|
||||
mhinput.c mhinput.h mhmain.c mhmain.h mhmap.c
|
||||
mhmap.h mhmenu.c mhmenu.h mhmsg.h mhmsgwnd.c
|
||||
mhmsgwnd.h mhrip.c mhrip.h mhstatus.c mhstatus.h
|
||||
mhtext.c mhtext.h mswproc.c newres.h palmpc.vcp
|
||||
pocketpc.vcp resource.h smartphn.vcp stat.h winMS.h
|
||||
wince.vcw winhack.c winhack.rc winhcksp.rc winmain.c
|
||||
|
||||
sys/winnt:
|
||||
(files for Windows 9x, NT and Windows2000 version)
|
||||
|
||||
@@ -11,6 +11,21 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/* Detect the targe device */
|
||||
#if defined(WIN32_PLATFORM_PSPC)
|
||||
# if _WIN32_WCE >= 300
|
||||
# define WIN_CE_POCKETPC
|
||||
# else
|
||||
# define WIN_CE_PS2xx
|
||||
# endif
|
||||
#elif defined(WIN32_PLATFORM_HPCPRO)
|
||||
# define WIN_CE_HPCPRO
|
||||
#elif defined(WIN32_PLATFORM_WFSP)
|
||||
# define WIN_CE_SMARTPHONE
|
||||
#else
|
||||
# error "Unsupported Windows CE platform"
|
||||
#endif
|
||||
|
||||
/* #define SHELL /* nt use of pcsys routines caused a hang */
|
||||
|
||||
#define RANDOM /* have Berkeley random(3) */
|
||||
@@ -22,6 +37,8 @@
|
||||
#define PC_LOCKING /* Prevent overwrites of aborted or in-progress games */
|
||||
/* without first receiving confirmation. */
|
||||
|
||||
#define SELF_RECOVER /* Allow the game itself to recover from an aborted game */
|
||||
|
||||
#define NOTSTDC /* no strerror() */
|
||||
|
||||
/*
|
||||
@@ -144,11 +161,6 @@ extern void NDECL(toggle_mouse_support);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Detect HPC - CE ver 2.11 */
|
||||
#if UNDER_CE<300
|
||||
#define WIN_CE_2xx
|
||||
#endif
|
||||
|
||||
/* UNICODE stuff */
|
||||
#define NHSTR_BUFSIZE 255
|
||||
#ifdef UNICODE
|
||||
@@ -249,7 +261,7 @@ char *getcwd( char *buffer, int maxlen );
|
||||
|
||||
|
||||
/* CE 2.xx is missing even more stuff */
|
||||
#ifdef WIN_CE_2xx
|
||||
#if defined(WIN_CE_PS2xx) || defined(WIN32_PLATFORM_HPCPRO)
|
||||
#define ZeroMemory(p, s) memset((p), 0, (s))
|
||||
|
||||
int __cdecl isupper(int c);
|
||||
|
||||
@@ -2,7 +2,7 @@ Copyright (c) Alex Kompel, 2002
|
||||
NetHack may be freely redistributed. See license for details.
|
||||
========================================================================
|
||||
Instructions for compiling and installing
|
||||
NetHack 3.4 on a Windows CE or PocketPC system
|
||||
NetHack 3.4.1 on a Windows CE or PocketPC system
|
||||
========================================================================
|
||||
Last revision: $Date$
|
||||
|
||||
@@ -57,11 +57,30 @@ Compiling
|
||||
In there, highlight "wince.vcw" and click on Open.
|
||||
Once the workspace has been opened, you should see the following
|
||||
list in the Visual C selection window:
|
||||
+ winhack files
|
||||
+ recover files
|
||||
+ nethack_hpc files
|
||||
+ nethack_palm_pc files
|
||||
+ nethack_pocket_pc files
|
||||
+ nethack_smartphone files
|
||||
+ recover_hpc files
|
||||
+ recover_palm_pc files
|
||||
+ recover_pocket_pc files
|
||||
+ recover_smartphone files
|
||||
|
||||
o On the Embedded Visual C menus, choose:
|
||||
Project | Set Active Project | winhack
|
||||
Project | Set Active Platform | <platform>
|
||||
where <platform> is:
|
||||
Palm-size PC 2.11 - palm size PC running Windows CE version 2.11
|
||||
Pocket PC - palm-size PC running Windows CE 3.0 and higher (PocketPC)
|
||||
H/PC Pro 2.11 - handheld computers running Windows CE 2.11 anf higher
|
||||
Smartphone 2002 - Microsoft SmartPhone device
|
||||
|
||||
o On the Embedded Visual C menus, choose:
|
||||
Project | Set Active Project | <project>
|
||||
where <project> is based on the platform you selected:
|
||||
nethack_palm_pc for Palm-size PC 2.11 platform
|
||||
nethack_pocket_pc for Pocket PC platform
|
||||
nethack_hpc for H/PC Pro 2.11 platform
|
||||
nethack_smartphone for Smartphone 2002
|
||||
|
||||
o On the Visual C menus again, choose either:
|
||||
Build | Set Active Configuration | Release (for your handheld platform)
|
||||
|
||||
@@ -69,120 +69,259 @@ time_t __cdecl time(time_t * timeptr)
|
||||
/* __io.h__ */
|
||||
/* Hack io.h function with stdio.h functions */
|
||||
/* ASSUMPTION : int can hold FILE* */
|
||||
static char _nh_cwd[255];
|
||||
static TCHAR _nh_cwd[MAX_PATH];
|
||||
const int MAGIC_OFFSET=5;
|
||||
#define FILE_TABLE_SIZE 256
|
||||
static HANDLE _nh_file_table[FILE_TABLE_SIZE];
|
||||
static int file_pointer = -1;
|
||||
|
||||
static HANDLE get_file_handle(int i)
|
||||
{
|
||||
i -= MAGIC_OFFSET;
|
||||
if( i>=0 && i<FILE_TABLE_SIZE )
|
||||
return _nh_file_table[i];
|
||||
else
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
static int alloc_file_handle(HANDLE h)
|
||||
{
|
||||
int i;
|
||||
if( file_pointer==-1 ) {
|
||||
file_pointer=0;
|
||||
for(i=0; i<FILE_TABLE_SIZE; i++ )
|
||||
_nh_file_table[i] = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
i = (file_pointer+1)%FILE_TABLE_SIZE;
|
||||
while(_nh_file_table[i]!=INVALID_HANDLE_VALUE ) {
|
||||
if( i==file_pointer ) {
|
||||
MessageBox(NULL, _T("Ran out of file handles."), _T("Fatal Error"), MB_OK);
|
||||
abort();
|
||||
}
|
||||
i = (i+1) % FILE_TABLE_SIZE;
|
||||
}
|
||||
|
||||
file_pointer = i;
|
||||
_nh_file_table[file_pointer] = h;
|
||||
return file_pointer+MAGIC_OFFSET;
|
||||
}
|
||||
|
||||
int __cdecl close(int f) {
|
||||
FILE* p = (FILE*)f;
|
||||
return fclose(p);
|
||||
int retval;
|
||||
f -= MAGIC_OFFSET;
|
||||
if( f<0 || f>=FILE_TABLE_SIZE ) return -1;
|
||||
retval = (CloseHandle(_nh_file_table[f])? 0 : -1);
|
||||
_nh_file_table[f] = INVALID_HANDLE_VALUE;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int __cdecl creat(const char *fname , int mode)
|
||||
{
|
||||
FILE* f;
|
||||
f = fopen(fname, "w+");
|
||||
if( !f ) return -1;
|
||||
else return (int)f;
|
||||
HANDLE f;
|
||||
TCHAR wbuf[MAX_PATH+1];
|
||||
ZeroMemory(wbuf, sizeof(wbuf));
|
||||
NH_A2W(fname, wbuf, MAX_PATH);
|
||||
|
||||
f = CreateFile(
|
||||
wbuf,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
|
||||
if( f==INVALID_HANDLE_VALUE ) return -1;
|
||||
else return alloc_file_handle(f);
|
||||
}
|
||||
|
||||
int __cdecl eof(int f)
|
||||
{
|
||||
FILE* p = (FILE*)f;
|
||||
return feof(p);
|
||||
DWORD fpos, fsize;
|
||||
HANDLE p = get_file_handle(f);
|
||||
|
||||
if( f==-1 ) return -1;
|
||||
|
||||
fpos = SetFilePointer(p, 0, NULL, FILE_CURRENT);
|
||||
fsize = SetFilePointer(p, 0, NULL, FILE_END);
|
||||
if( fpos==0xFFFFFFFF || fsize==0xFFFFFFFF ) return -1;
|
||||
if( fpos==fsize ) return 1;
|
||||
else {
|
||||
SetFilePointer(p, fpos, NULL, FILE_BEGIN);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
long __cdecl lseek( int handle, long offset, int origin )
|
||||
long __cdecl lseek( int f, long offset, int origin )
|
||||
{
|
||||
FILE* p = (FILE*)handle;
|
||||
if( !fseek(p, offset, origin) ) return ftell(p);
|
||||
else return -1;
|
||||
HANDLE p = get_file_handle(f);
|
||||
DWORD fpos;
|
||||
switch(origin) {
|
||||
case SEEK_SET:
|
||||
fpos = SetFilePointer(p, offset, NULL, FILE_BEGIN);
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
fpos = SetFilePointer(p, offset, NULL, FILE_CURRENT);
|
||||
break;
|
||||
case SEEK_END:
|
||||
fpos = SetFilePointer(p, offset, NULL, FILE_END);
|
||||
break;
|
||||
default:
|
||||
fpos = 0xFFFFFFFF;
|
||||
break;
|
||||
}
|
||||
if( fpos==0xFFFFFFFF ) return -1;
|
||||
else return (long)fpos;
|
||||
}
|
||||
|
||||
int __cdecl open( const char *filename, int oflag, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int pmode;
|
||||
char mode[16];
|
||||
char fname[255];
|
||||
FILE* f;
|
||||
TCHAR fname[MAX_PATH+1];
|
||||
TCHAR path[MAX_PATH+1];
|
||||
HANDLE f;
|
||||
DWORD fileaccess;
|
||||
DWORD filecreate;
|
||||
|
||||
va_start(ap, oflag);
|
||||
pmode = va_arg(ap, int);
|
||||
va_end(ap);
|
||||
/* O_TEXT is not supported */
|
||||
|
||||
ZeroMemory(mode, sizeof(mode));
|
||||
if( (oflag & (O_WRONLY|O_APPEND)) == (O_WRONLY|O_APPEND) ) strcat(mode, "a");
|
||||
else if( (oflag & (O_RDWR | O_APPEND)) == (O_RDWR | O_APPEND) ) strcat(mode, "a+");
|
||||
else if( (oflag & (O_RDWR | O_TRUNC)) == (O_RDWR | O_TRUNC) ) strcat(mode, "w+");
|
||||
else if( (oflag & (O_RDWR | O_CREAT)) == (O_RDWR | O_CREAT) ) strcat(mode, "a+");
|
||||
else if( (oflag & O_RDWR) == O_RDWR ) strcat(mode, "r+");
|
||||
else if( (oflag & O_WRONLY) == O_WRONLY ) strcat(mode, "w");
|
||||
else if( (oflag & O_RDONLY) == O_RDONLY ) strcat(mode, "r");
|
||||
/*
|
||||
* decode the access flags
|
||||
*/
|
||||
switch( oflag & (_O_RDONLY | _O_WRONLY | _O_RDWR) ) {
|
||||
|
||||
if( oflag & O_BINARY ) strcat(mode, "b");
|
||||
if( oflag & O_TEXT ) strcat(mode, "t");
|
||||
case _O_RDONLY: /* read access */
|
||||
fileaccess = GENERIC_READ;
|
||||
break;
|
||||
case _O_WRONLY: /* write access */
|
||||
fileaccess = GENERIC_READ | GENERIC_WRITE;
|
||||
break;
|
||||
case _O_RDWR: /* read and write access */
|
||||
fileaccess = GENERIC_READ | GENERIC_WRITE;
|
||||
break;
|
||||
default: /* error, bad oflag */
|
||||
return -1;
|
||||
}
|
||||
|
||||
fname[0]='\x0';
|
||||
/*
|
||||
* decode open/create method flags
|
||||
*/
|
||||
switch ( oflag & (_O_CREAT | _O_EXCL | _O_TRUNC) ) {
|
||||
case 0:
|
||||
case _O_EXCL: // ignore EXCL w/o CREAT
|
||||
filecreate = OPEN_EXISTING;
|
||||
break;
|
||||
|
||||
case _O_CREAT:
|
||||
filecreate = OPEN_ALWAYS;
|
||||
break;
|
||||
|
||||
case _O_CREAT | _O_EXCL:
|
||||
case _O_CREAT | _O_TRUNC | _O_EXCL:
|
||||
filecreate = CREATE_NEW;
|
||||
break;
|
||||
|
||||
case _O_TRUNC:
|
||||
case _O_TRUNC | _O_EXCL: // ignore EXCL w/o CREAT
|
||||
filecreate = TRUNCATE_EXISTING;
|
||||
break;
|
||||
|
||||
case _O_CREAT | _O_TRUNC:
|
||||
filecreate = CREATE_ALWAYS;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* assemple the file name */
|
||||
ZeroMemory(fname, sizeof(fname));
|
||||
ZeroMemory(path, sizeof(path));
|
||||
NH_A2W(filename, fname, MAX_PATH);
|
||||
if( *filename!='\\' && *filename!='/' ) {
|
||||
strncat(fname, _nh_cwd, sizeof(fname));
|
||||
strncat(fname, "\\", sizeof(fname) - strlen(fname));
|
||||
_tcscpy(path, _nh_cwd);
|
||||
_tcsncat(path, _T("\\"), MAX_PATH - _tcslen(path));
|
||||
}
|
||||
strncat(fname, filename, sizeof(fname) - strlen(fname));
|
||||
_tcsncat(path, fname, MAX_PATH - _tcslen(path));
|
||||
|
||||
f = fopen(fname, mode);
|
||||
if( !f ) return -1;
|
||||
else {
|
||||
if( !(oflag & O_APPEND) ) fseek(f, SEEK_SET, 0);
|
||||
return (int)f;
|
||||
}
|
||||
/*
|
||||
* try to open/create the file
|
||||
*/
|
||||
if ( (f = CreateFile( path,
|
||||
fileaccess,
|
||||
0,
|
||||
NULL,
|
||||
filecreate,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL ))
|
||||
== INVALID_HANDLE_VALUE )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( !(oflag & O_APPEND) ) SetFilePointer(f, 0, NULL, FILE_BEGIN);
|
||||
return alloc_file_handle(f);
|
||||
}
|
||||
|
||||
int __cdecl read( int handle, void *buffer, unsigned int count )
|
||||
int __cdecl read( int f, void *buffer, unsigned int count )
|
||||
{
|
||||
FILE* p = (FILE*)handle;
|
||||
return fread(buffer, 1, count, p);
|
||||
HANDLE p = get_file_handle(f);
|
||||
DWORD bytes_read;
|
||||
if( !ReadFile(p, buffer, count, &bytes_read, NULL) )
|
||||
return -1;
|
||||
else
|
||||
return (int)bytes_read;
|
||||
}
|
||||
|
||||
int __cdecl unlink(const char * filename)
|
||||
{
|
||||
TCHAR wbuf[NHSTR_BUFSIZE];
|
||||
char fname[255];
|
||||
|
||||
fname[0]='\x0';
|
||||
TCHAR wbuf[MAX_PATH+1];
|
||||
TCHAR fname[MAX_PATH+1];
|
||||
|
||||
ZeroMemory(wbuf, sizeof(wbuf));
|
||||
ZeroMemory(fname, sizeof(fname));
|
||||
NH_A2W(filename, wbuf, MAX_PATH);
|
||||
if( *filename!='\\' && *filename!='/' ) {
|
||||
strncat(fname, _nh_cwd, sizeof(fname));
|
||||
strncat(fname, "\\", sizeof(fname) - strlen(fname));
|
||||
_tcscpy(fname, _nh_cwd);
|
||||
_tcsncat(fname, _T("\\"), MAX_PATH - _tcslen(fname));
|
||||
}
|
||||
strncat(fname, filename, sizeof(fname) - strlen(fname));
|
||||
_tcsncat(fname, wbuf, MAX_PATH - _tcslen(fname));
|
||||
|
||||
return !DeleteFileW(NH_A2W(fname, wbuf, NHSTR_BUFSIZE));
|
||||
return !DeleteFileW(fname);
|
||||
}
|
||||
|
||||
int __cdecl write( int handle, const void *buffer, unsigned int count )
|
||||
int __cdecl write( int f, const void *buffer, unsigned int count )
|
||||
{
|
||||
FILE* p = (FILE*)handle;
|
||||
return fwrite(buffer, 1, count, p);
|
||||
HANDLE p = get_file_handle(f);
|
||||
DWORD bytes_written;
|
||||
if( !WriteFile(p, buffer, count, &bytes_written, NULL) )
|
||||
return -1;
|
||||
else
|
||||
return (int)bytes_written;
|
||||
}
|
||||
|
||||
int __cdecl rename( const char *oldname, const char *newname )
|
||||
{
|
||||
WCHAR f1[255];
|
||||
WCHAR f2[255];
|
||||
MultiByteToWideChar(CP_ACP, 0, oldname, -1, f1, 255);
|
||||
MultiByteToWideChar(CP_ACP, 0, newname, -1, f2, 255);
|
||||
WCHAR f1[MAX_PATH+1];
|
||||
WCHAR f2[MAX_PATH+1];
|
||||
ZeroMemory(f1, sizeof(f1));
|
||||
ZeroMemory(f2, sizeof(f2));
|
||||
MultiByteToWideChar(CP_ACP, 0, oldname, -1, f1, MAX_PATH);
|
||||
MultiByteToWideChar(CP_ACP, 0, newname, -1, f2, MAX_PATH);
|
||||
return !MoveFile(f1, f2);
|
||||
}
|
||||
|
||||
int chdir( const char *dirname )
|
||||
{
|
||||
ZeroMemory(_nh_cwd, sizeof(_nh_cwd));
|
||||
strncpy(_nh_cwd, dirname, sizeof(_nh_cwd)-1);
|
||||
NH_A2W(dirname, _nh_cwd, MAX_PATH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *getcwd( char *buffer, int maxlen )
|
||||
{
|
||||
if( maxlen<(int)strlen(_nh_cwd) ) return NULL;
|
||||
else return strcpy(buffer, _nh_cwd);
|
||||
if( maxlen<(int)_tcslen(_nh_cwd) ) return NULL;
|
||||
else return NH_W2A(_nh_cwd, buffer, maxlen);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
@@ -226,7 +365,7 @@ int isatty(int f)
|
||||
}
|
||||
|
||||
|
||||
#ifdef WIN_CE_2xx
|
||||
#if defined(WIN_CE_PS2xx) || defined(WIN32_PLATFORM_HPCPRO)
|
||||
int __cdecl isupper(int c)
|
||||
{
|
||||
char str[2];
|
||||
@@ -243,6 +382,13 @@ int __cdecl isdigit(int c)
|
||||
return ('0' <= c && c <= '9');
|
||||
}
|
||||
|
||||
int __cdecl isxdigit(int c)
|
||||
{
|
||||
return (('0' <= c && c <= '9') ||
|
||||
('a' <= c && c <= 'f') ||
|
||||
('A' <= c && c <= 'F'));
|
||||
}
|
||||
|
||||
int __cdecl isspace(int c)
|
||||
{
|
||||
char str[2];
|
||||
@@ -286,4 +432,377 @@ int __cdecl _stricmp(const char* a, const char* b)
|
||||
return strncmpi(a, b, 65535u);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(WIN_CE_PS2xx)
|
||||
/* stdio.h functions are missing from PAlm Size PC SDK 1.2 (SH3 and MIPS) */
|
||||
|
||||
#pragma warning(disable:4273)
|
||||
|
||||
FILE * __cdecl fopen(const char* filename, const char *mode)
|
||||
{
|
||||
int modeflag;
|
||||
int whileflag;
|
||||
int filedes;
|
||||
|
||||
/* First mode character must be 'r', 'w', or 'a'. */
|
||||
switch (*mode) {
|
||||
case 'r':
|
||||
modeflag = _O_RDONLY;
|
||||
break;
|
||||
case 'w':
|
||||
modeflag = _O_WRONLY | _O_CREAT | _O_TRUNC;
|
||||
break;
|
||||
case 'a':
|
||||
modeflag = _O_WRONLY | _O_CREAT | _O_APPEND;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
whileflag=1;
|
||||
while(*++mode && whileflag)
|
||||
switch(*mode) {
|
||||
|
||||
case '+':
|
||||
if (modeflag & _O_RDWR)
|
||||
whileflag=0;
|
||||
else {
|
||||
modeflag |= _O_RDWR;
|
||||
modeflag &= ~(_O_RDONLY | _O_WRONLY);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
if (modeflag & (_O_TEXT | _O_BINARY))
|
||||
whileflag=0;
|
||||
else
|
||||
modeflag |= _O_BINARY;
|
||||
break;
|
||||
|
||||
case 't': /* not supported */
|
||||
whileflag=0;
|
||||
break;
|
||||
|
||||
default:
|
||||
whileflag=0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((filedes = open(filename, modeflag))==-1) return NULL;
|
||||
|
||||
return (FILE*)filedes;
|
||||
}
|
||||
|
||||
int __cdecl fscanf(FILE *f , const char *format, ...)
|
||||
{
|
||||
/* Format spec: %[*] [width] [l] type ] */
|
||||
int ch;
|
||||
int sch;
|
||||
int matched = 0;
|
||||
int width = 65535;
|
||||
int modifier = -1;
|
||||
int skip_flag = 0;
|
||||
int n_read = 0;
|
||||
char buf[BUFSZ];
|
||||
TCHAR wbuf[BUFSZ];
|
||||
char* p;
|
||||
va_list args;
|
||||
|
||||
#define RETURN_SCANF(i) { va_end(args); return i; }
|
||||
#define NEXT_CHAR(f) (n_read++, fgetc(f))
|
||||
|
||||
va_start(args, format);
|
||||
|
||||
ch = *format++;
|
||||
sch = NEXT_CHAR(f);
|
||||
while( ch && sch!=EOF ) {
|
||||
if( isspace(ch) ) {
|
||||
while( ch && isspace(ch) ) ch = *format++;
|
||||
while( sch!=EOF && isspace(sch) ) sch = NEXT_CHAR(f);
|
||||
format--;
|
||||
goto next_spec;
|
||||
}
|
||||
|
||||
/* read % */
|
||||
if( ch!='%' ) {
|
||||
if( sch!=ch ) RETURN_SCANF(matched);
|
||||
sch = NEXT_CHAR(f);
|
||||
goto next_spec;
|
||||
} else {
|
||||
/* process '%%' */
|
||||
ch = *format++;
|
||||
if( ch=='%' ) {
|
||||
if( sch!='%' ) RETURN_SCANF(matched);
|
||||
sch = NEXT_CHAR(f);
|
||||
goto next_spec;
|
||||
}
|
||||
|
||||
if( ch=='*' ) {
|
||||
/* read skip flag - '*' */
|
||||
skip_flag=1;
|
||||
ch = *format++;
|
||||
}
|
||||
|
||||
/* get width */
|
||||
if( isdigit(ch) ) {
|
||||
width = 0;
|
||||
while(ch && isdigit(ch)) {
|
||||
width = width*10 + (ch-'0');
|
||||
ch = *format++;
|
||||
}
|
||||
}
|
||||
|
||||
/* get modifier */
|
||||
if( ch=='l' ) {
|
||||
modifier = 'l';
|
||||
ch = *format++;
|
||||
}
|
||||
|
||||
/* get type */
|
||||
switch(ch) {
|
||||
case 'c':
|
||||
if( !skip_flag ) {
|
||||
*(va_arg(args, char*))=sch;
|
||||
matched++;
|
||||
}
|
||||
sch = NEXT_CHAR(f);
|
||||
goto next_spec;
|
||||
case 'd':
|
||||
p = buf;
|
||||
/* skip space */
|
||||
while(sch!=EOF && isspace(sch)) sch=NEXT_CHAR(f);
|
||||
while(sch!=EOF && isdigit(sch) && --width>=0) { *p++ = sch; sch=NEXT_CHAR(f); }
|
||||
*p = '\x0';
|
||||
if( !skip_flag ) {
|
||||
matched++;
|
||||
if( modifier=='l' ) {
|
||||
*(va_arg(args, long*))=wcstol(NH_A2W(buf, wbuf, BUFSZ), NULL, 10);
|
||||
} else {
|
||||
*(va_arg(args, int*))=wcstol(NH_A2W(buf, wbuf, BUFSZ), NULL, 10);
|
||||
}
|
||||
}
|
||||
goto next_spec;
|
||||
case 'x':
|
||||
p = buf;
|
||||
while(sch!=EOF && isspace(sch)) sch=NEXT_CHAR(f);
|
||||
while(sch!=EOF && isxdigit(sch) && --width>=0) { *p++ = sch; sch=NEXT_CHAR(f); }
|
||||
*p = '\x0';
|
||||
if( !skip_flag ) {
|
||||
matched++;
|
||||
if( modifier=='l' ) {
|
||||
*(va_arg(args, long*))=wcstol(NH_A2W(buf, wbuf, BUFSZ), NULL, 16);
|
||||
} else {
|
||||
*(va_arg(args, int*))=wcstol(NH_A2W(buf, wbuf, BUFSZ), NULL, 16);
|
||||
}
|
||||
}
|
||||
goto next_spec;
|
||||
case 'n':
|
||||
*(va_arg(args, int*)) = n_read;
|
||||
matched++;
|
||||
goto next_spec;
|
||||
case 's':
|
||||
if( skip_flag ) {
|
||||
while(sch!=EOF && !isspace(sch) && --width>=0) { sch=NEXT_CHAR(f); }
|
||||
} else {
|
||||
p = va_arg(args, char*);
|
||||
while(sch!=EOF && !isspace(sch) && --width>=0) { *p++ = sch; sch=NEXT_CHAR(f); }
|
||||
*p = '\x0';
|
||||
matched++;
|
||||
}
|
||||
goto next_spec;
|
||||
case '[': {
|
||||
char pattern[256];
|
||||
int start, end;
|
||||
int negate;
|
||||
|
||||
ZeroMemory(pattern, sizeof(pattern));
|
||||
p = pattern;
|
||||
|
||||
/* try to parse '^' modifier */
|
||||
ch = *format++;
|
||||
if( ch=='^' ) { negate=1; ch=*format++; }
|
||||
else { negate=0; }
|
||||
if( ch==0 ) RETURN_SCANF(EOF);
|
||||
|
||||
for( ; ch && ch!=']'; ch = *format++ ) {
|
||||
/* try to parse range: a-z */
|
||||
if( format[0]=='-' &&
|
||||
format[1] && format[1]!=']' ) {
|
||||
start = ch;
|
||||
format++;
|
||||
end = *format++;
|
||||
while(start<=end) {
|
||||
if(!strchr(pattern, (char)start))
|
||||
*p++ = (char)start;
|
||||
start++;
|
||||
}
|
||||
} else {
|
||||
if(!strchr(pattern, (char)ch)) *p++ = (char)ch;
|
||||
}
|
||||
}
|
||||
|
||||
if( skip_flag ) {
|
||||
while(sch!=EOF && strchr(pattern, sch) && --width>=0) { sch=NEXT_CHAR(f); }
|
||||
} else {
|
||||
p = va_arg(args, char*);
|
||||
if( negate )
|
||||
while(sch!=EOF && !strchr(pattern, sch) && --width>=0) { *p++ = sch; sch=NEXT_CHAR(f); }
|
||||
else
|
||||
while(sch!=EOF && strchr(pattern, sch) && --width>=0) { *p++ = sch; sch=NEXT_CHAR(f); }
|
||||
*p = '\x0';
|
||||
matched++;
|
||||
}
|
||||
} goto next_spec;
|
||||
default:
|
||||
RETURN_SCANF(EOF);
|
||||
}
|
||||
}
|
||||
|
||||
next_spec:
|
||||
width = 65535;
|
||||
modifier = -1;
|
||||
skip_flag = 0;
|
||||
ch = *format++;
|
||||
}
|
||||
fseek(f, -1, SEEK_CUR);
|
||||
RETURN_SCANF(matched);
|
||||
|
||||
#undef RETURN_SCANF
|
||||
#undef NEXT_CHAR
|
||||
}
|
||||
|
||||
int __cdecl fprintf(FILE *f , const char *format, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list args;
|
||||
|
||||
if( !f || !format ) return 0;
|
||||
|
||||
va_start(args, format);
|
||||
retval = vfprintf(f, format, args);
|
||||
va_end(args);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int __cdecl vfprintf(FILE* f, const char *format, va_list args)
|
||||
{
|
||||
char buf[4096];
|
||||
int retval;
|
||||
|
||||
if( !f || !format ) return 0;
|
||||
|
||||
retval = vsprintf(buf, format, args);
|
||||
|
||||
write((int)f, buf, strlen(buf));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int __cdecl fgetc(FILE * f)
|
||||
{
|
||||
char c;
|
||||
int fh = (int)f;
|
||||
|
||||
if( !f ) return EOF;
|
||||
if( read(fh, &c, 1)==1 ) return c;
|
||||
else return EOF;
|
||||
}
|
||||
|
||||
char * __cdecl fgets(char *s, int size, FILE *f)
|
||||
{
|
||||
/* not the best performance but it will do for now...*/
|
||||
char c;
|
||||
if( !f || !s || size==0 ) return NULL;
|
||||
while( --size>0 ) {
|
||||
if( (c = fgetc(f))==EOF ) return NULL;
|
||||
|
||||
*s++ = c;
|
||||
if( c=='\n' ) break;
|
||||
}
|
||||
*s = '\x0';
|
||||
return s;
|
||||
}
|
||||
|
||||
int __cdecl printf(const char *format, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list args;
|
||||
|
||||
if( !format ) return 0;
|
||||
|
||||
va_start(args, format);
|
||||
retval = vprintf(format, args);
|
||||
va_end(args);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int __cdecl vprintf(const char *format, va_list args)
|
||||
{
|
||||
char buf[4096];
|
||||
int retval;
|
||||
|
||||
retval = vsprintf(buf, format, args);
|
||||
puts(buf);
|
||||
return retval;
|
||||
}
|
||||
|
||||
// int __cdecl putchar(int);
|
||||
int __cdecl puts(const char * s)
|
||||
{
|
||||
TCHAR wbuf[4096];
|
||||
NH_A2W(s, wbuf, 4096);
|
||||
MessageBox(NULL, wbuf, _T("stdout"), MB_OK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE* __cdecl _getstdfilex(int desc)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int __cdecl fclose(FILE * f)
|
||||
{
|
||||
if(!f) return EOF;
|
||||
return close((int)f)==-1? EOF : 0;
|
||||
}
|
||||
|
||||
size_t __cdecl fread(void *p, size_t size, size_t count, FILE *f)
|
||||
{
|
||||
int read_bytes;
|
||||
if(!f || !p || size==0 || count==0) return 0;
|
||||
read_bytes = read((int)f, p, size*count);
|
||||
return read_bytes>0? (read_bytes/size) : 0;
|
||||
}
|
||||
|
||||
size_t __cdecl fwrite(const void *p, size_t size, size_t count, FILE * f)
|
||||
{
|
||||
int write_bytes;
|
||||
if(!f || !p || size==0 || count==0) return 0;
|
||||
write_bytes = write((int)f, p, size*count);
|
||||
return write_bytes>0? write_bytes/size : 0;
|
||||
}
|
||||
|
||||
int __cdecl fflush(FILE *f)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __cdecl feof(FILE *f)
|
||||
{
|
||||
return (f && eof((int)f)==0)? 0 : 1;
|
||||
}
|
||||
|
||||
int __cdecl fseek(FILE *f, long offset, int from)
|
||||
{
|
||||
return (f && lseek((int)f, offset, from)>=0)? 0 : 1;
|
||||
}
|
||||
|
||||
long __cdecl ftell(FILE * f)
|
||||
{
|
||||
return f? lseek((int)f, 0, SEEK_CUR) : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -59,11 +59,14 @@ copy mhtext.c ..\..\wince\mhtext.c
|
||||
copy mhtext.h ..\..\wince\mhtext.h
|
||||
copy mswproc.c ..\..\wince\mswproc.c
|
||||
copy newres.h ..\..\wince\newres.h
|
||||
copy recover.vcp ..\..\wince\recover.vcp
|
||||
copy resource.h ..\..\wince\resource.h
|
||||
copy wince.vcp ..\..\wince\wince.vcp
|
||||
copy hpc.vcp ..\..\wince\wince_hpc.vcp
|
||||
copy palmpc.vcp ..\..\wince\wince_palm_pc.vcp
|
||||
copy pocketpc.vcp ..\..\wince\wince_pocket_pc.vcp
|
||||
copy smartphn.vcp ..\..\wince\wince_smartphone.vcp
|
||||
copy winhack.c ..\..\wince\winhack.c
|
||||
copy winhack.rc ..\..\wince\winhack.rc
|
||||
copy winhcksp.rc ..\..\wince\winhack_sp.rc
|
||||
copy winmain.c ..\..\wince\winmain.c
|
||||
copy winMS.h ..\..\wince\winMS.h
|
||||
echo.
|
||||
|
||||
139
sys/wince/defaults.nh
Normal file
139
sys/wince/defaults.nh
Normal file
@@ -0,0 +1,139 @@
|
||||
# Sample config file for win32 NetHack
|
||||
# A '#' at the beginning of a line means the rest of the line is a comment.
|
||||
#
|
||||
# Some options MUST be set in this file, other options can be toggled while
|
||||
# playing. For a list of options available see the <opthelp.> file.
|
||||
#
|
||||
# To change the configuration, comment out the unwanted lines, and
|
||||
# uncomment the configuration you want.
|
||||
|
||||
# *** OPTIONS ***
|
||||
#
|
||||
# Use the IBM character set rather than just plain ascii characters
|
||||
# for tty window-port.
|
||||
# OPTIONS=IBMGraphics
|
||||
|
||||
# *** Personal Preferences ***
|
||||
# Some options to set personal preferences. Uncomment and change these to
|
||||
# suit your personal preference. If several people are to use the same
|
||||
# configuration, options like these should not be set.
|
||||
#
|
||||
#OPTIONS=name:Janet,role:Valkyrie,race:Human,gender:female,align:lawful
|
||||
#OPTIONS=dogname:Fido,catname:Morris,fruit:guava
|
||||
#OPTIONS=horsename:Silver
|
||||
#OPTIONS=autopickup,pickup_types:$"=/!?+
|
||||
#OPTIONS=packorder:")[%?+/=!(*0_`
|
||||
#OPTIONS=scores:10 top/2 around/own
|
||||
#OPTIONS=nolegacy,noverbose
|
||||
#OPTIONS=menustyle:traditional
|
||||
|
||||
#
|
||||
# General options. You might also set "silent" so as not to attract
|
||||
# the boss's attention.
|
||||
#
|
||||
OPTIONS=time,noshowexp,number_pad,lit_corridor,rest_on_space
|
||||
#
|
||||
# If you want to get rid of "use #quit to quit..." use:
|
||||
#OPTIONS=suppress_alert:3.3.1
|
||||
#
|
||||
# Set some options to control graphical window-port (these will
|
||||
# be safely and silently ignored by the tty port)
|
||||
#
|
||||
# Map window settings
|
||||
# possible map_mode options include: tiles|ascii4x6|ascii6x8|ascii8x8|ascii16x8|
|
||||
# ascii7x12|ascii8x12|ascii16x12|ascii12x16|
|
||||
# ascii10x18|fit_to_screen
|
||||
OPTIONS=map_mode:tiles,scroll_margin:3
|
||||
|
||||
# Menu settings
|
||||
# OPTIONS=font_menu:Arial
|
||||
|
||||
# Other
|
||||
#OPTIONS=windowcolors:message yellow/black status white/#000000 menu yellow/black text yellow/black
|
||||
OPTIONS=hilite_pet,!toptenwin
|
||||
OPTIONS=!splash_screen,player_selection:prompts
|
||||
OPTIONS=vary_msgcount:4
|
||||
|
||||
# Status/message window colors
|
||||
# Possible color options include:
|
||||
# six digit hexadecimal RGB color value ("#8F8F8F"), black, red, green, brown,
|
||||
# blue, magenta, cyan, gray (or grey), orange, brightgreen, yellow, brightblue,
|
||||
# brightmagenta, brightcyan, white, trueblack, purple, silver, maroon, fuchsia,
|
||||
# lime, olive, navy, teal, aqua, activeborder, activecaption, appworkspace,
|
||||
# background, btnface, btnshadow, btntext, captiontext, graytext, highlight,
|
||||
# highlighttext, inactiveborder, inactivecaption, menu, menutext, scrollbar,
|
||||
# window, windowframe, windowtext.
|
||||
#OPTIONS=windowcolors:status windowtext/window message windowtext/window
|
||||
OPTIONS=windowcolors:status white/#000000 message white/#000000 menu white/#000000 text white/#000000
|
||||
|
||||
#
|
||||
#HACKDIR=c:\games\nethack
|
||||
#
|
||||
# Note: On Windows HACKDIR defaults to the location
|
||||
# of the NetHack.exe or NetHackw.exe file.
|
||||
# Setting HACKDIR above will override that.
|
||||
#
|
||||
# LEVELS and SAVE default to HACKDIR
|
||||
#
|
||||
#LEVELS=c:\games\nethack\bones
|
||||
#SAVE=c:\games\nethack\bones
|
||||
|
||||
# *** CHARACTER GRAPHICS ***
|
||||
#
|
||||
# See the on-line help or the Guidebook for which symbols are in which
|
||||
# positions.
|
||||
#
|
||||
# If you merely set the IBMgraphics option as above, NetHack will use IBM
|
||||
# extended ASCII for dungeon characters. If you don't like the selections,
|
||||
# you can make up your own via these graphics options, but you should still
|
||||
# set IBMgraphics if you are using IBM graphics characters to get the correct
|
||||
# processing.
|
||||
#
|
||||
# ================================================
|
||||
# An example using the IBM graphics character set:
|
||||
#DUNGEON= 032 179 196 218 191 192 217 197 193 194 \
|
||||
# 180 195 249 239 239 254 254 240 241 249 \
|
||||
# 177 177 060 062 060 062 220 124 190 035 \
|
||||
# 244 247 249 247 042 042 186 205 046 035 \
|
||||
# 247
|
||||
#
|
||||
#TRAPS= 094 094 094 094 094 094 094 094 094 094 \
|
||||
# 094 094 094 094 232 232 232 157 094 094 \
|
||||
# 094 094
|
||||
#
|
||||
#EFFECTS= 179 196 092 047 042 033 041 040 \
|
||||
# 048 035 064 042 \
|
||||
# 047 045 092 058 058 092 045 047 \
|
||||
# 047 045 092 058 032 058 092 045 047
|
||||
#
|
||||
# ================================================
|
||||
# Some alternatives:
|
||||
#DUNGEON= 032 186 205 201 187 200 188 206 202 203 \
|
||||
# 185 204 249 239 239 254 254 240 241 249 \
|
||||
# 177 177 060 062 060 062 095 124 092 035 \
|
||||
# 244 247 249 247 042 042 179 196 046 035 \
|
||||
# 247
|
||||
#
|
||||
#TRAPS= 094 094 094 094 094 094 094 094 094 094 \
|
||||
# 094 094 094 094 094 034 094 094 094 094 \
|
||||
# 094 094
|
||||
|
||||
# ================================================
|
||||
# Here is a recommendation sent in by Michael Feir
|
||||
# for use by blind NetHack players.
|
||||
#
|
||||
#DUNGEON= 032 124 045 124 124 124 124 045 045 045 \
|
||||
# 124 124 046 045 124 043 043 046 035 035 \
|
||||
# 060 062 060 062 095 092 035 126 126 126 \
|
||||
# 126 042 042 035 035 032 035 126
|
||||
#
|
||||
#TRAPS= 094 094 094 094 094 094 094 094 094 094 \
|
||||
# 094 094 094 094 094 094 094 094 094 094 \
|
||||
# 094 094
|
||||
#
|
||||
#EFFECTS= 124 095 092 047 042 033 041 040 \
|
||||
# 048 035 064 042 \
|
||||
# 047 045 092 058 058 092 045 047 \
|
||||
# 047 045 092 058 032 058 092 045 047
|
||||
|
||||
|
||||
47779
sys/wince/hpc.vcp
Normal file
47779
sys/wince/hpc.vcp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,8 @@
|
||||
begin 600 keypad.bmp
|
||||
M0DV>`````````#X````H````8`````@````!``$``````&````!T$@``=!(`
|
||||
M`````````````````/___P#________________O__O____________G__/W
|
||||
MX_?_]__W__?CP>/GU?/AX\/OY_OAX\/'P?'CP>//Y_G_]__GU?/G__/O__O_
|
||||
7___WX_?O__OW__?________________'
|
||||
M0DV^`````````#X````H````<`````@````!``$``````(``````````````
|
||||
M`````````````````/___P#__________________P``[__[____________
|
||||
M_R0``.?_\_?C]__W__?_]^MU``#CP>/GU?/AX\/OY_O5=0``X>/#Q\'QX\'C
|
||||
MS^?YZR4``/_W_^?5\^?_\^__^]5M``#____WX_?O__OW__?_)```________
|
||||
*__________\``.?5
|
||||
`
|
||||
end
|
||||
|
||||
1107
sys/wince/mhcmd.c
1107
sys/wince/mhcmd.c
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,18 @@
|
||||
#include "global.h"
|
||||
|
||||
HWND mswin_init_command_window ();
|
||||
|
||||
/* if either sz->cx or sz->cy are already set this function will
|
||||
no modify it. It will adjust them to the minimum size
|
||||
required by the command window */
|
||||
void mswin_command_window_size (HWND hwnd, LPSIZE sz);
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
/* special keypad input handling for SmartPhone */
|
||||
BOOL NHSPhoneTranslateKbdMessage(WPARAM wParam, LPARAM lParam, BOOL keyDown);
|
||||
void NHSPhoneSetKeypadFromString(const char* str);
|
||||
void NHSPhoneSetKeypadDirection();
|
||||
void NHSPhoneSetKeypadDefault();
|
||||
#endif
|
||||
|
||||
#endif /* MSWINCMDWindow_h */
|
||||
|
||||
@@ -6,16 +6,11 @@
|
||||
#include "winMS.h"
|
||||
#include "hack.h"
|
||||
#include "func_tab.h"
|
||||
#include "resource.h"
|
||||
#include "mhdlg.h"
|
||||
#include "mhmain.h"
|
||||
|
||||
#ifndef WIN_CE_2xx
|
||||
#include <aygshell.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN_CE
|
||||
#define CheckDlgButton(dlg, btn_id, st) SendDlgItemMessage((dlg), (btn_id), BM_SETCHECK, (WPARAM)(st), 0)
|
||||
#endif
|
||||
|
||||
|
||||
/*---------------------------------------------------------------*/
|
||||
/* data for getlin dialog */
|
||||
@@ -61,10 +56,11 @@ LRESULT CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
||||
RECT main_rt, text_rt, dlg_rt, edit_rt;
|
||||
SIZE dlg_sz;
|
||||
TCHAR wbuf[BUFSZ];
|
||||
HDC hdc;
|
||||
HDC hdc;
|
||||
HWND control;
|
||||
HWND hwndMap;
|
||||
|
||||
#ifndef WIN_CE_2xx
|
||||
#if defined(WIN_CE_POCKETPC)
|
||||
SHInputDialog(hWnd, message, wParam);
|
||||
#endif
|
||||
|
||||
@@ -84,11 +80,12 @@ LRESULT CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
||||
|
||||
/* center dialog in the main window */
|
||||
GetWindowRect(hWnd, &dlg_rt);
|
||||
GetWindowRect(GetNHApp()->hMainWnd, &main_rt);
|
||||
hwndMap = mswin_hwnd_from_winid(WIN_MAP);
|
||||
GetWindowRect( IsWindow(hwndMap)? hwndMap : GetNHApp()->hMainWnd, &main_rt);
|
||||
dlg_sz.cx = max(dlg_rt.right-dlg_rt.left,
|
||||
min( text_rt.right-text_rt.left+GetSystemMetrics(SM_CXICON),
|
||||
main_rt.right-main_rt.left ) );
|
||||
dlg_sz.cy = dlg_rt.bottom - dlg_rt.top;
|
||||
dlg_sz.cy = min(dlg_rt.bottom - dlg_rt.top, main_rt.bottom - main_rt.top);
|
||||
dlg_rt.left = (main_rt.left+main_rt.right-dlg_sz.cx)/2;
|
||||
dlg_rt.right = dlg_rt.left + dlg_sz.cx;
|
||||
dlg_rt.top = (main_rt.top+main_rt.bottom-dlg_sz.cy)/2;
|
||||
@@ -130,6 +127,10 @@ LRESULT CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
||||
text_rt.bottom - text_rt.top,
|
||||
TRUE );
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
NHSPhoneDialogSetup(hWnd, TRUE);
|
||||
#endif
|
||||
|
||||
/* set focus to the edit control */
|
||||
SetFocus(GetDlgItem(hWnd, IDC_GETLIN_EDIT));
|
||||
|
||||
@@ -157,7 +158,15 @@ LRESULT CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
||||
return TRUE;
|
||||
}
|
||||
} break;
|
||||
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
case WM_HOTKEY:
|
||||
if(VK_TBACK == HIWORD(lParam)) {
|
||||
SHSendBackToFocusWindow(message, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
} /* end switch (message) */
|
||||
return FALSE;
|
||||
}
|
||||
@@ -230,6 +239,16 @@ LRESULT CALLBACK ExtCmdDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
||||
SendDlgItemMessage(hWnd, IDC_EXTCMD_LIST, LB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(ptr, wbuf, sizeof(wbuf)) );
|
||||
}
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
NHSPhoneDialogSetup(hWnd, FALSE);
|
||||
|
||||
GetClientRect(hWnd, &dlg_rt);
|
||||
MoveWindow(GetDlgItem(hWnd, IDC_EXTCMD_LIST),
|
||||
dlg_rt.left, dlg_rt.top,
|
||||
dlg_rt.right-dlg_rt.left, dlg_rt.bottom-dlg_rt.top,
|
||||
TRUE);
|
||||
#endif
|
||||
|
||||
/* set focus to the list control */
|
||||
SetFocus(GetDlgItem(hWnd, IDC_EXTCMD_LIST));
|
||||
|
||||
@@ -342,6 +361,9 @@ BOOL CALLBACK PlayerSelectorDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
|
||||
/* init dialog */
|
||||
plselInitDialog(hWnd);
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
NHSPhoneDialogSetup(hWnd, FALSE);
|
||||
#endif
|
||||
/* set focus on the role checkbox (random) field */
|
||||
SetFocus(GetDlgItem(hWnd, IDC_PLSEL_ROLE_RANDOM));
|
||||
|
||||
@@ -730,4 +752,5 @@ int plselFinalSelection(HWND hWnd, int* selection)
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,10 @@ static struct font_table_entry {
|
||||
HFONT hFont;
|
||||
} font_table[MAXFONTS] ;
|
||||
static int font_table_size = 0;
|
||||
HFONT version_splash_font;
|
||||
HFONT extrainfo_splash_font;
|
||||
|
||||
#define NHFONT_CODE(win, attr) ((((win)&0xFF)<<8)|((attr)&0xFF))
|
||||
#define NHFONT_CODE(win, attr) (((attr&0xFF)<<8)|(win_type&0xFF))
|
||||
|
||||
static void __cdecl font_table_cleanup(void);
|
||||
|
||||
@@ -53,17 +55,16 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace)
|
||||
lgfnt.lfItalic = FALSE; // italic attribute option
|
||||
lgfnt.lfUnderline = FALSE; // underline attribute option
|
||||
lgfnt.lfStrikeOut = FALSE; // strikeout attribute option
|
||||
lgfnt.lfCharSet = mswin_charset(); // character set identifier
|
||||
lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision
|
||||
lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision
|
||||
lgfnt.lfQuality = DEFAULT_QUALITY; // output quality
|
||||
if( iflags.wc_font_status &&
|
||||
*iflags.wc_font_status ) {
|
||||
lgfnt.lfPitchAndFamily = DEFAULT_PITCH; // pitch and family
|
||||
lgfnt.lfCharSet = DEFAULT_CHARSET; // character set identifier
|
||||
NH_A2W( iflags.wc_font_status, lgfnt.lfFaceName, LF_FACESIZE);
|
||||
} else {
|
||||
lgfnt.lfPitchAndFamily = FIXED_PITCH; // pitch and family
|
||||
lgfnt.lfCharSet = ANSI_CHARSET; // character set identifier
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -76,17 +77,16 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace)
|
||||
lgfnt.lfItalic = (attr==ATR_BLINK)? TRUE: FALSE; // italic attribute option
|
||||
lgfnt.lfUnderline = (attr==ATR_ULINE)? TRUE : FALSE; // underline attribute option
|
||||
lgfnt.lfStrikeOut = FALSE; // strikeout attribute option
|
||||
lgfnt.lfCharSet = mswin_charset(); // character set identifier
|
||||
lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision
|
||||
lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision
|
||||
lgfnt.lfQuality = DEFAULT_QUALITY; // output quality
|
||||
if( iflags.wc_font_menu &&
|
||||
*iflags.wc_font_menu ) {
|
||||
lgfnt.lfPitchAndFamily = DEFAULT_PITCH; // pitch and family
|
||||
lgfnt.lfCharSet = DEFAULT_CHARSET; // character set identifier
|
||||
lgfnt.lfPitchAndFamily = DEFAULT_PITCH; // pitch and family
|
||||
NH_A2W( iflags.wc_font_menu, lgfnt.lfFaceName, LF_FACESIZE);
|
||||
} else {
|
||||
lgfnt.lfPitchAndFamily = VARIABLE_PITCH; // pitch and family
|
||||
lgfnt.lfCharSet = ANSI_CHARSET; // character set identifier
|
||||
lgfnt.lfPitchAndFamily = FIXED_PITCH; // pitch and family
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -100,17 +100,16 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace)
|
||||
lgfnt.lfItalic = (attr==ATR_BLINK)? TRUE: FALSE; // italic attribute option
|
||||
lgfnt.lfUnderline = (attr==ATR_ULINE)? TRUE : FALSE; // underline attribute option
|
||||
lgfnt.lfStrikeOut = FALSE; // strikeout attribute option
|
||||
lgfnt.lfCharSet = mswin_charset(); // character set identifier
|
||||
lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision
|
||||
lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision
|
||||
lgfnt.lfQuality = DEFAULT_QUALITY; // output quality
|
||||
if( iflags.wc_font_message &&
|
||||
*iflags.wc_font_message ) {
|
||||
lgfnt.lfPitchAndFamily = DEFAULT_PITCH; // pitch and family
|
||||
lgfnt.lfCharSet = DEFAULT_CHARSET; // character set identifier
|
||||
lgfnt.lfPitchAndFamily = DEFAULT_PITCH; // pitch and family
|
||||
NH_A2W( iflags.wc_font_message, lgfnt.lfFaceName, LF_FACESIZE);
|
||||
} else {
|
||||
lgfnt.lfPitchAndFamily = VARIABLE_PITCH; // pitch and family
|
||||
lgfnt.lfCharSet = ANSI_CHARSET; // character set identifier
|
||||
lgfnt.lfPitchAndFamily = VARIABLE_PITCH; // pitch and family
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -123,17 +122,16 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace)
|
||||
lgfnt.lfItalic = (attr==ATR_BLINK)? TRUE: FALSE; // italic attribute option
|
||||
lgfnt.lfUnderline = (attr==ATR_ULINE)? TRUE : FALSE; // underline attribute option
|
||||
lgfnt.lfStrikeOut = FALSE; // strikeout attribute option
|
||||
lgfnt.lfCharSet = mswin_charset(); // character set identifier
|
||||
lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision
|
||||
lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision
|
||||
lgfnt.lfQuality = DEFAULT_QUALITY; // output quality
|
||||
if( iflags.wc_font_text &&
|
||||
*iflags.wc_font_text ) {
|
||||
lgfnt.lfPitchAndFamily = DEFAULT_PITCH; // pitch and family
|
||||
lgfnt.lfCharSet = DEFAULT_CHARSET; // character set identifier
|
||||
lgfnt.lfPitchAndFamily = DEFAULT_PITCH; // pitch and family
|
||||
NH_A2W( iflags.wc_font_text, lgfnt.lfFaceName, LF_FACESIZE);
|
||||
} else {
|
||||
lgfnt.lfPitchAndFamily = FIXED_PITCH; // pitch and family
|
||||
lgfnt.lfCharSet = ANSI_CHARSET; // character set identifier
|
||||
lgfnt.lfPitchAndFamily = FIXED_PITCH; // pitch and family
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -153,6 +151,21 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace)
|
||||
return fnt;
|
||||
}
|
||||
|
||||
UINT mswin_charset()
|
||||
{
|
||||
CHARSETINFO cis;
|
||||
if( iflags.IBMgraphics )
|
||||
if( TranslateCharsetInfo((DWORD*)GetOEMCP(), &cis, TCI_SRCCODEPAGE) )
|
||||
return cis.ciCharset;
|
||||
else
|
||||
return OEM_CHARSET;
|
||||
else
|
||||
if( TranslateCharsetInfo((DWORD*)GetACP(), &cis, TCI_SRCCODEPAGE) )
|
||||
return cis.ciCharset;
|
||||
else
|
||||
return ANSI_CHARSET;
|
||||
}
|
||||
|
||||
void __cdecl font_table_cleanup(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
#include "winMS.h"
|
||||
|
||||
HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace);
|
||||
UINT mswin_charset();
|
||||
|
||||
#endif /* MSWINFont_h */
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "winMS.h"
|
||||
#include "newres.h"
|
||||
#include "resource.h"
|
||||
#include "mhmsg.h"
|
||||
#include "mhinput.h"
|
||||
#include "mhmain.h"
|
||||
@@ -17,7 +15,6 @@
|
||||
#define MAX_LOADSTRING 100
|
||||
|
||||
typedef struct mswin_nethack_main_window {
|
||||
HWND hCmdWnd;
|
||||
int mapAcsiiModeSave;
|
||||
} NHMainWindow, *PNHMainWindow;
|
||||
|
||||
@@ -37,6 +34,7 @@ static HMENU _get_main_menu(UINT menu_id);
|
||||
HWND mswin_init_main_window () {
|
||||
static int run_once = 0;
|
||||
HWND ret;
|
||||
RECT rc;
|
||||
|
||||
/* register window class */
|
||||
if( !run_once ) {
|
||||
@@ -46,14 +44,16 @@ HWND mswin_init_main_window () {
|
||||
}
|
||||
|
||||
/* create the main window */
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);
|
||||
|
||||
ret = CreateWindow(
|
||||
szMainWindowClass, /* registered class name */
|
||||
szTitle, /* window name */
|
||||
WS_CLIPCHILDREN, /* window style */
|
||||
CW_USEDEFAULT, /* horizontal position of window */
|
||||
CW_USEDEFAULT, /* vertical position of window */
|
||||
CW_USEDEFAULT, /* window width */
|
||||
CW_USEDEFAULT, /* window height */
|
||||
rc.left, /* horizontal position of window */
|
||||
rc.top, /* vertical position of window */
|
||||
rc.right - rc.left, /* window width */
|
||||
rc.bottom - rc.top, /* window height */
|
||||
NULL, /* handle to parent or owner window */
|
||||
NULL, /* menu handle or child identifier */
|
||||
GetNHApp()->hApp, /* handle to application instance */
|
||||
@@ -152,8 +152,9 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
|
||||
switch (message)
|
||||
{
|
||||
/*-----------------------------------------------------------------------*/
|
||||
case WM_CREATE: {
|
||||
#ifndef WIN_CE_2xx
|
||||
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
|
||||
SHMENUBARINFO menubar;
|
||||
#endif
|
||||
/* set window data */
|
||||
@@ -166,7 +167,7 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
GetNHApp()->hMainWnd = hWnd;
|
||||
|
||||
/* create menu bar */
|
||||
#ifndef WIN_CE_2xx
|
||||
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
|
||||
ZeroMemory(&menubar, sizeof(menubar));
|
||||
menubar.cbSize = sizeof(menubar);
|
||||
menubar.hwndParent = hWnd;
|
||||
@@ -176,7 +177,7 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
menubar.nBmpId = 0;
|
||||
menubar.cBmpImages = 0;
|
||||
if( !SHCreateMenuBar(&menubar) ) panic("cannot create menu");
|
||||
GetNHApp()->hMenuBar = menubar.hwndMB;
|
||||
GetNHApp()->hMenuBar = menubar.hwndMB;
|
||||
#else
|
||||
GetNHApp()->hMenuBar = CommandBar_Create(GetNHApp()->hApp, hWnd, 1);
|
||||
if( !GetNHApp()->hMenuBar ) panic("cannot create menu");
|
||||
@@ -192,15 +193,18 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
);
|
||||
|
||||
/* create command pad (keyboard emulator) */
|
||||
data->hCmdWnd = mswin_init_command_window();
|
||||
GetNHApp()->hCmdWnd = mswin_init_command_window();
|
||||
} break;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
case WM_MSNH_COMMAND:
|
||||
onMSNHCommand(hWnd, wParam, lParam);
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
data = (PNHMainWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
/* translate arrow keys into nethack commands */
|
||||
@@ -384,27 +388,60 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} return 1;
|
||||
|
||||
case VK_RETURN:
|
||||
NHEVENT_MS( CLICK_1, u.ux, u.uy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
if( NHSPhoneTranslateKbdMessage(wParam, lParam, TRUE) ) return 0;
|
||||
#endif
|
||||
return 1; /* end of WM_KEYDOWN */
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
case WM_KEYUP:
|
||||
if( NHSPhoneTranslateKbdMessage(wParam, lParam, FALSE) ) return 0;
|
||||
return 1; /* end of WM_KEYUP */
|
||||
#endif
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if !defined(WIN_CE_SMARTPHONE)
|
||||
case WM_CHAR:
|
||||
/* all characters go to nethack */
|
||||
NHEVENT_KBD( (lParam & 1<<29)? M(tolower(wParam)) : wParam );
|
||||
if( wParam=='\n' || wParam=='\r' || wParam==C('M') ) return 0; /* we already processed VK_RETURN */
|
||||
|
||||
/* all characters go to nethack except Ctrl-P that scrolls message window up */
|
||||
if( wParam==C('P') || wParam==C('p') ) {
|
||||
SendMessage(mswin_hwnd_from_winid(WIN_MESSAGE), WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), (LPARAM)NULL);
|
||||
} else {
|
||||
NHEVENT_KBD( (lParam & 1<<29)? M(tolower(wParam)) : wParam );
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
case WM_COMMAND:
|
||||
/* process commands - menu commands mostly */
|
||||
if( onWMCommand(hWnd, wParam, lParam) )
|
||||
if( IsWindow(GetNHApp()->hPopupWnd) ) {
|
||||
return SendMessage(GetNHApp()->hPopupWnd, message, wParam, lParam);
|
||||
} else if( onWMCommand(hWnd, wParam, lParam) )
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
else
|
||||
return 0;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
case WM_ACTIVATE:
|
||||
case WM_SETTINGCHANGE:
|
||||
case WM_SIZE:
|
||||
mswin_layout_main_window(NULL);
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
case WM_SETFOCUS:
|
||||
/* if there is a menu window out there -
|
||||
transfer input focus to it */
|
||||
@@ -413,12 +450,16 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
}
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
case WM_CLOSE:
|
||||
{
|
||||
/* exit gracefully */
|
||||
dosave0();
|
||||
} return 0;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
case WM_DESTROY: {
|
||||
/* apparently we never get here
|
||||
TODO: work on exit routines - need to send
|
||||
@@ -431,6 +472,8 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
terminate(EXIT_SUCCESS);
|
||||
} break;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
@@ -484,14 +527,16 @@ void mswin_layout_main_window(HWND changed_child)
|
||||
SIZE cmd_size;
|
||||
HWND wnd_status, wnd_msg;
|
||||
PNHMainWindow data;
|
||||
#ifndef WIN_CE_2xx
|
||||
#if defined(WIN_CE_POCKETPC)
|
||||
SIPINFO sip;
|
||||
RECT menu_bar;
|
||||
RECT visible_rt;
|
||||
POINT pt;
|
||||
#endif
|
||||
|
||||
GetClientRect(GetNHApp()->hMainWnd, &client_rt);
|
||||
|
||||
#ifndef WIN_CE_2xx
|
||||
#if defined(WIN_CE_POCKETPC)
|
||||
ZeroMemory(&sip, sizeof(sip));
|
||||
sip.cbSize = sizeof(sip);
|
||||
SHSipInfo(SPI_GETSIPINFO, 0, &sip, 0);
|
||||
@@ -499,8 +544,21 @@ void mswin_layout_main_window(HWND changed_child)
|
||||
/* adjust client rectangle size */
|
||||
GetWindowRect(GetNHApp()->hMenuBar, &menu_bar);
|
||||
client_rt.bottom -= menu_bar.bottom-menu_bar.top;
|
||||
|
||||
/* calcuate visible rect in client coordinates */
|
||||
pt.x = sip.rcVisibleDesktop.left;
|
||||
pt.y = sip.rcVisibleDesktop.top;
|
||||
ScreenToClient(GetNHApp()->hMainWnd, &pt);
|
||||
SetRect(&wnd_rect,
|
||||
pt.x,
|
||||
pt.y,
|
||||
pt.x+sip.rcVisibleDesktop.right-sip.rcVisibleDesktop.left,
|
||||
pt.y+sip.rcVisibleDesktop.bottom-sip.rcVisibleDesktop.top );
|
||||
IntersectRect(&visible_rt, &client_rt, &wnd_rect);
|
||||
#else
|
||||
# if !defined(WIN_CE_SMARTPHONE)
|
||||
client_rt.top += CommandBar_Height(GetNHApp()->hMenuBar);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* get window data */
|
||||
@@ -521,21 +579,30 @@ void mswin_layout_main_window(HWND changed_child)
|
||||
msg_size.cx = msg_size.cy = 0;
|
||||
}
|
||||
|
||||
if( GetNHApp()->bCmdPad && IsWindow(data->hCmdWnd) ) {
|
||||
mswin_command_window_size(data->hCmdWnd, &cmd_size);
|
||||
} else {
|
||||
cmd_size.cx = cmd_size.cy = 0;
|
||||
cmd_size.cx = cmd_size.cy = 0;
|
||||
if( GetNHApp()->bCmdPad && IsWindow(GetNHApp()->hCmdWnd) ) {
|
||||
mswin_command_window_size(GetNHApp()->hCmdWnd, &cmd_size);
|
||||
}
|
||||
|
||||
/* set window positions */
|
||||
|
||||
/* keypad */
|
||||
/* calculate the application windows size */
|
||||
#if defined(WIN_CE_POCKETPC)
|
||||
SetRect(&wnd_rect, visible_rt.left, visible_rt.top, visible_rt.right, visible_rt.bottom);
|
||||
if( sip.fdwFlags & SIPF_ON )
|
||||
cmd_size.cx = cmd_size.cy = 0; /* hide keypad window */
|
||||
#else
|
||||
SetRect(&wnd_rect, client_rt.left, client_rt.top, client_rt.right, client_rt.bottom);
|
||||
#endif
|
||||
|
||||
#if !defined(WIN_CE_SMARTPHONE)
|
||||
/* other ports have it at the bottom of the screen */
|
||||
cmd_size.cx = (wnd_rect.right-wnd_rect.left);
|
||||
cmd_org.x = wnd_rect.left;
|
||||
cmd_org.y = wnd_rect.bottom - cmd_size.cy;
|
||||
wnd_rect.bottom -= cmd_size.cy;
|
||||
|
||||
#endif
|
||||
|
||||
/* status window */
|
||||
switch(iflags.wc_align_status) {
|
||||
case ALIGN_LEFT:
|
||||
@@ -573,33 +640,71 @@ void mswin_layout_main_window(HWND changed_child)
|
||||
/* message window */
|
||||
switch(iflags.wc_align_message) {
|
||||
case ALIGN_LEFT:
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
/* smartphone has a keypad window on the right (bottom) side of the message window */
|
||||
msg_size.cx = cmd_size.cx = max(msg_size.cx, cmd_size.cx);
|
||||
msg_size.cy = (wnd_rect.bottom-wnd_rect.top) - cmd_size.cy;
|
||||
msg_org.x = cmd_org.x = wnd_rect.left;
|
||||
msg_org.y = wnd_rect.top;
|
||||
cmd_org.y = msg_org.y + msg_size.cy;
|
||||
#else
|
||||
msg_size.cx = (wnd_rect.right-wnd_rect.left)/4;
|
||||
msg_size.cy = (wnd_rect.bottom-wnd_rect.top);
|
||||
msg_org.x = wnd_rect.left;
|
||||
msg_org.y = wnd_rect.top;
|
||||
#endif
|
||||
wnd_rect.left += msg_size.cx;
|
||||
|
||||
break;
|
||||
|
||||
case ALIGN_RIGHT:
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
/* smartphone has a keypad window on the right (bottom) side of the message window */
|
||||
msg_size.cx = cmd_size.cx = max(msg_size.cx, cmd_size.cx);
|
||||
msg_size.cy = (wnd_rect.bottom-wnd_rect.top) - cmd_size.cy;
|
||||
msg_org.x = cmd_org.x = wnd_rect.right - msg_size.cx;
|
||||
msg_org.y = wnd_rect.top;
|
||||
cmd_org.y = msg_org.y + msg_size.cy;
|
||||
#else
|
||||
msg_size.cx = (wnd_rect.right-wnd_rect.left)/4;
|
||||
msg_size.cy = (wnd_rect.bottom-wnd_rect.top);
|
||||
msg_org.x = wnd_rect.right - msg_size.cx;
|
||||
msg_org.y = wnd_rect.top;
|
||||
#endif
|
||||
|
||||
wnd_rect.right -= msg_size.cx;
|
||||
break;
|
||||
|
||||
case ALIGN_TOP:
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
/* smartphone has a keypad window on the right side of the message window */
|
||||
msg_size.cy = cmd_size.cy = max(msg_size.cy, cmd_size.cy);
|
||||
msg_size.cx = (wnd_rect.right - wnd_rect.left) - cmd_size.cx;
|
||||
msg_org.x = wnd_rect.left;
|
||||
cmd_org.x = msg_org.x + msg_size.cx;
|
||||
msg_org.y = cmd_org.y = wnd_rect.bottom - msg_size.cy;
|
||||
#else
|
||||
msg_size.cx = (wnd_rect.right-wnd_rect.left);
|
||||
msg_org.x = wnd_rect.left;
|
||||
msg_org.y = wnd_rect.top;
|
||||
#endif
|
||||
wnd_rect.top += msg_size.cy;
|
||||
break;
|
||||
|
||||
case ALIGN_BOTTOM:
|
||||
default:
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
/* smartphone has a keypad window on the right side of the message window */
|
||||
msg_size.cy = cmd_size.cy = max(msg_size.cy, cmd_size.cy);
|
||||
msg_size.cx = (wnd_rect.right - wnd_rect.left) - cmd_size.cx;
|
||||
msg_org.x = wnd_rect.left;
|
||||
cmd_org.x = msg_org.x + msg_size.cx;
|
||||
msg_org.y = cmd_org.y = wnd_rect.bottom - msg_size.cy;
|
||||
#else
|
||||
msg_size.cx = (wnd_rect.right-wnd_rect.left);
|
||||
msg_org.x = wnd_rect.left;
|
||||
msg_org.y = wnd_rect.bottom - msg_size.cy;
|
||||
#endif
|
||||
wnd_rect.bottom -= msg_size.cy;
|
||||
break;
|
||||
}
|
||||
@@ -647,7 +752,7 @@ void mswin_layout_main_window(HWND changed_child)
|
||||
|
||||
menu_org.x = client_rt.left;
|
||||
menu_org.y = client_rt.top;
|
||||
#ifndef WIN_CE_2xx
|
||||
#if defined(WIN_CE_POCKETPC)
|
||||
menu_size.cx = min(sip.rcVisibleDesktop.right-sip.rcVisibleDesktop.left,
|
||||
client_rt.right - client_rt.left);
|
||||
menu_size.cy = min(sip.rcVisibleDesktop.bottom-sip.rcVisibleDesktop.top,
|
||||
@@ -656,7 +761,17 @@ void mswin_layout_main_window(HWND changed_child)
|
||||
menu_size.cx = client_rt.right - client_rt.left;
|
||||
menu_size.cy = client_rt.bottom - client_rt.top;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
/* leave room for the command window */
|
||||
if( GetNHApp()->windowlist[i].type == NHW_MENU ) {
|
||||
menu_size.cy -= cmd_size.cy;
|
||||
}
|
||||
|
||||
/* dialogs are popup windows unde SmartPhone so we need
|
||||
to convert to screen coordinates */
|
||||
ClientToScreen(GetNHApp()->hMainWnd, &menu_org);
|
||||
#endif
|
||||
MoveWindow(GetNHApp()->windowlist[i].win,
|
||||
menu_org.x,
|
||||
menu_org.y,
|
||||
@@ -670,17 +785,19 @@ void mswin_layout_main_window(HWND changed_child)
|
||||
}
|
||||
}
|
||||
|
||||
if( IsWindow(data->hCmdWnd) ) {
|
||||
if( GetNHApp()->bCmdPad ) {
|
||||
MoveWindow(data->hCmdWnd,
|
||||
if( IsWindow(GetNHApp()->hCmdWnd) ) {
|
||||
/* show command window only if it exists and
|
||||
the game is ready (plname is set) */
|
||||
if( GetNHApp()->bCmdPad && cmd_size.cx>0 && cmd_size.cy>0 && *plname) {
|
||||
MoveWindow(GetNHApp()->hCmdWnd,
|
||||
cmd_org.x,
|
||||
cmd_org.y,
|
||||
cmd_size.cx,
|
||||
cmd_size.cy,
|
||||
TRUE );
|
||||
ShowWindow(data->hCmdWnd, SW_SHOW);
|
||||
ShowWindow(GetNHApp()->hCmdWnd, SW_SHOW);
|
||||
} else {
|
||||
ShowWindow(data->hCmdWnd, SW_HIDE);
|
||||
ShowWindow(GetNHApp()->hCmdWnd, SW_HIDE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -746,7 +863,7 @@ LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
MF_BYCOMMAND |
|
||||
(GetNHApp()->bCmdPad? MF_CHECKED : MF_UNCHECKED)
|
||||
);
|
||||
mswin_layout_main_window(data->hCmdWnd);
|
||||
mswin_layout_main_window(GetNHApp()->hCmdWnd);
|
||||
break;
|
||||
|
||||
case IDM_HELP_LONG:
|
||||
@@ -785,6 +902,10 @@ LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
display_file(LICENSE, TRUE);
|
||||
break;
|
||||
|
||||
case IDM_HELP_MENU:
|
||||
dohelp();
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
@@ -855,7 +976,12 @@ void mswin_select_map_mode(int mode)
|
||||
|
||||
map_id = WIN_MAP;
|
||||
data = (PNHMainWindow)GetWindowLong(GetNHApp()->hMainWnd, GWL_USERDATA);
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
/* Smartphone manu has only 2 items */
|
||||
hmenuMap = _get_main_menu(ID_VIEW);
|
||||
#else
|
||||
hmenuMap = _get_main_menu(ID_MAP);
|
||||
#endif
|
||||
|
||||
/* override for Rogue level */
|
||||
#ifdef REINCARNATION
|
||||
@@ -879,6 +1005,34 @@ void mswin_select_map_mode(int mode)
|
||||
MF_BYCOMMAND);
|
||||
}
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
/* update "Fit To Screen" item text */
|
||||
{
|
||||
TCHAR wbuf[BUFSZ];
|
||||
TBBUTTONINFO tbbi;
|
||||
|
||||
ZeroMemory( wbuf, sizeof(wbuf) );
|
||||
if( !LoadString(
|
||||
GetNHApp()->hApp,
|
||||
(IS_MAP_FIT_TO_SCREEN(mode)? IDS_CAP_NORMALMAP : IDS_CAP_ENTIREMAP),
|
||||
wbuf,
|
||||
BUFSZ) ) {
|
||||
panic("cannot load main menu strings");
|
||||
}
|
||||
|
||||
ZeroMemory( &tbbi, sizeof(tbbi) );
|
||||
tbbi.cbSize = sizeof(tbbi);
|
||||
tbbi.dwMask = TBIF_TEXT;
|
||||
tbbi.pszText = wbuf;
|
||||
if( !SendMessage(
|
||||
GetNHApp()->hMenuBar,
|
||||
TB_SETBUTTONINFO,
|
||||
IDM_MAP_FIT_TO_SCREEN,
|
||||
(LPARAM)&tbbi) ) {
|
||||
error( "Cannot update IDM_MAP_FIT_TO_SCREEN menu item." );
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* set fit-to-screen mode mark */
|
||||
CheckMenuItem(
|
||||
hmenuMap,
|
||||
@@ -886,6 +1040,7 @@ void mswin_select_map_mode(int mode)
|
||||
MF_BYCOMMAND |
|
||||
(IS_MAP_FIT_TO_SCREEN(mode)? MF_CHECKED : MF_UNCHECKED)
|
||||
);
|
||||
#endif
|
||||
|
||||
if( IS_MAP_ASCII(iflags.wc_map_mode) && !IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
|
||||
data->mapAcsiiModeSave = iflags.wc_map_mode;
|
||||
@@ -941,11 +1096,11 @@ int mapmode2menuid(int map_mode)
|
||||
HMENU _get_main_menu(UINT menu_id)
|
||||
{
|
||||
HMENU hmenuMap;
|
||||
#ifndef WIN_CE_2xx
|
||||
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
|
||||
TBBUTTONINFO tbbi;
|
||||
#endif
|
||||
|
||||
#ifndef WIN_CE_2xx
|
||||
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
|
||||
tbbi.cbSize = sizeof(tbbi);
|
||||
tbbi.dwMask = TBIF_LPARAM;
|
||||
SendMessage( GetNHApp()->hMenuBar, TB_GETBUTTONINFO, menu_id, (LPARAM)&tbbi);
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "winMS.h"
|
||||
#include "resource.h"
|
||||
#include "mhmap.h"
|
||||
#include "mhmsg.h"
|
||||
#include "mhinput.h"
|
||||
#include "mhfont.h"
|
||||
|
||||
#include "patchlevel.h"
|
||||
|
||||
@@ -159,12 +159,18 @@ void mswin_map_stretch(HWND hWnd, LPSIZE lpsz, BOOL redraw)
|
||||
lgfnt.lfItalic = FALSE; // italic attribute option
|
||||
lgfnt.lfUnderline = FALSE; // underline attribute option
|
||||
lgfnt.lfStrikeOut = FALSE; // strikeout attribute option
|
||||
lgfnt.lfCharSet = OEM_CHARSET; // character set identifier
|
||||
lgfnt.lfCharSet = mswin_charset(); // character set identifier
|
||||
lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision
|
||||
lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision
|
||||
lgfnt.lfQuality = DEFAULT_QUALITY; // output quality
|
||||
lgfnt.lfPitchAndFamily = FIXED_PITCH; // pitch and family
|
||||
_tcscpy(lgfnt.lfFaceName, NHMAP_FONT_NAME);
|
||||
if( iflags.wc_font_map &&
|
||||
*iflags.wc_font_map ) {
|
||||
lgfnt.lfPitchAndFamily = DEFAULT_PITCH; // pitch and family
|
||||
NH_A2W(iflags.wc_font_map, lgfnt.lfFaceName, LF_FACESIZE);
|
||||
} else {
|
||||
lgfnt.lfPitchAndFamily = FIXED_PITCH; // pitch and family
|
||||
_tcsncpy(lgfnt.lfFaceName, NHMAP_FONT_NAME, LF_FACESIZE);
|
||||
}
|
||||
data->hMapFont = CreateFontIndirect(&lgfnt);
|
||||
|
||||
mswin_cliparound(data->xCur, data->yCur);
|
||||
@@ -420,6 +426,7 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
( msg_data->y<(data->yPos+mcam) ||
|
||||
msg_data->y>(data->yPos+data->yPageSize-mcam) );
|
||||
|
||||
mcam += iflags.wc_scroll_amount - 1;
|
||||
/* get page size and center horizontally on x-position */
|
||||
if( scroll_x ) {
|
||||
if( data->xPageSize<=2*mcam ) {
|
||||
@@ -882,8 +889,6 @@ COLORREF nhcolor_to_RGB(int c)
|
||||
|
||||
/* apply bitmap pointed by sourceDc transparently over
|
||||
bitmap pointed by hDC */
|
||||
|
||||
typedef BOOL (WINAPI* LPTRANSPARENTBLT)(HDC, int, int, int, int, HDC, int, int, int, int, UINT);
|
||||
void nhapply_image_transparent(
|
||||
HDC hDC, int x, int y, int width, int height,
|
||||
HDC sourceDC, int s_x, int s_y, int s_width, int s_height,
|
||||
@@ -895,4 +900,4 @@ void nhapply_image_transparent(
|
||||
sourceDC, s_x, s_y, s_width, s_height,
|
||||
cTransparent
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -9,26 +9,13 @@
|
||||
#include "global.h"
|
||||
|
||||
|
||||
HWND mswin_init_map_window ();
|
||||
HWND mswin_init_map_window (void);
|
||||
void mswin_map_stretch(HWND hWnd, LPSIZE lpsz, BOOL redraw);
|
||||
|
||||
#define NHMAP_VIEW_TILES 0
|
||||
#define NHMAP_VIEW_ASCII4x6 1
|
||||
#define NHMAP_VIEW_ASCII6x8 2
|
||||
#define NHMAP_VIEW_ASCII8x8 3
|
||||
#define NHMAP_VIEW_ASCII16x8 4
|
||||
#define NHMAP_VIEW_ASCII7x12 5
|
||||
#define NHMAP_VIEW_ASCII8x12 6
|
||||
#define NHMAP_VIEW_ASCII16x12 7
|
||||
#define NHMAP_VIEW_ASCII12x16 8
|
||||
#define NHMAP_VIEW_ASCII10x18 9
|
||||
#define NHMAP_VIEW_FIT_TO_SCREEN 10
|
||||
|
||||
int mswin_map_mode(HWND hWnd, int mode);
|
||||
|
||||
#define ROGUE_LEVEL_MAP_MODE NHMAP_VIEW_ASCII8x12
|
||||
|
||||
#define DEF_CLIPAROUND_MARGIN 3
|
||||
#define ROGUE_LEVEL_MAP_MODE MAP_MODE_ASCII12x16
|
||||
|
||||
#define DEF_CLIPAROUND_MARGIN 5
|
||||
#define DEF_CLIPAROUND_AMOUNT 1
|
||||
|
||||
#endif /* MSWINMapWindow_h */
|
||||
|
||||
@@ -2,17 +2,14 @@
|
||||
|
||||
#include "winMS.h"
|
||||
#include <assert.h>
|
||||
#include "resource.h"
|
||||
#include "mhmenu.h"
|
||||
#include "mhmain.h"
|
||||
#include "mhmsg.h"
|
||||
#include "mhcmd.h"
|
||||
#include "mhinput.h"
|
||||
#include "mhfont.h"
|
||||
#include "mhcolor.h"
|
||||
|
||||
#ifndef WIN_CE_2xx
|
||||
#include <aygshell.h>
|
||||
#endif
|
||||
|
||||
#define MENU_MARGIN 0
|
||||
#define NHMENU_STR_SIZE BUFSZ
|
||||
#define MIN_TABSTOP_SIZE 0
|
||||
@@ -107,6 +104,7 @@ int mswin_menu_window_select_menu (HWND hWnd, int how, MENU_ITEM_P ** _selected)
|
||||
MENU_ITEM_P *selected = NULL;
|
||||
int i;
|
||||
char* ap;
|
||||
char accell_str[256];
|
||||
|
||||
assert( _selected!=NULL );
|
||||
*_selected = NULL;
|
||||
@@ -118,21 +116,45 @@ int mswin_menu_window_select_menu (HWND hWnd, int how, MENU_ITEM_P ** _selected)
|
||||
SetMenuListType(hWnd, how);
|
||||
|
||||
/* Ok, now give items a unique accelerators */
|
||||
ZeroMemory(accell_str, sizeof(accell_str));
|
||||
ap = accell_str;
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
if( data->menu.size>10 ) {
|
||||
*ap++ = MENU_FIRST_PAGE;
|
||||
*ap++ = MENU_LAST_PAGE;
|
||||
*ap++ = MENU_NEXT_PAGE;
|
||||
*ap++ = MENU_PREVIOUS_PAGE;
|
||||
if( data->how == PICK_ANY ) {
|
||||
*ap++ = MENU_SELECT_ALL;
|
||||
*ap++ = MENU_UNSELECT_ALL;
|
||||
*ap++ = MENU_INVERT_ALL;
|
||||
*ap++ = MENU_SELECT_PAGE;
|
||||
*ap++ = MENU_UNSELECT_PAGE;
|
||||
*ap++ = MENU_INVERT_PAGE;
|
||||
}
|
||||
*ap++ = MENU_SEARCH;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( data->type == MENU_TYPE_MENU ) {
|
||||
char next_char = 'a';
|
||||
|
||||
for( i=0; i<data->menu.size; i++) {
|
||||
if( data->menu.items[i].accelerator!=0 ) {
|
||||
*ap++ = data->menu.items[i].accelerator;
|
||||
next_char = (char)(data->menu.items[i].accelerator+1);
|
||||
} else if( NHMENU_IS_SELECTABLE(data->menu.items[i]) ) {
|
||||
if ( (next_char>='a' && next_char<='z') ||
|
||||
(next_char>='A' && next_char<='Z') ) {
|
||||
data->menu.items[i].accelerator = next_char;
|
||||
*ap++ = data->menu.items[i].accelerator;
|
||||
} else {
|
||||
if( next_char > 'z' ) next_char = 'A';
|
||||
else if ( next_char > 'Z' ) break;
|
||||
|
||||
data->menu.items[i].accelerator = next_char;
|
||||
*ap++ = data->menu.items[i].accelerator;
|
||||
}
|
||||
|
||||
next_char ++;
|
||||
@@ -155,6 +177,10 @@ int mswin_menu_window_select_menu (HWND hWnd, int how, MENU_ITEM_P ** _selected)
|
||||
reset_menu_count(NULL, data);
|
||||
}
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
if( data->type==MENU_TYPE_MENU ) NHSPhoneSetKeypadFromString( accell_str );
|
||||
#endif
|
||||
|
||||
mswin_popup_display(hWnd, &data->done);
|
||||
|
||||
/* get the result */
|
||||
@@ -194,6 +220,10 @@ int mswin_menu_window_select_menu (HWND hWnd, int how, MENU_ITEM_P ** _selected)
|
||||
|
||||
mswin_popup_destroy(hWnd);
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
if( data->type==MENU_TYPE_MENU ) NHSPhoneSetKeypadDefault();
|
||||
#endif
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@@ -202,7 +232,7 @@ LRESULT CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
PNHMenuWindow data;
|
||||
|
||||
CheckInputDialog(hWnd, message, wParam, lParam);
|
||||
|
||||
|
||||
data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
switch (message)
|
||||
{
|
||||
@@ -221,7 +251,12 @@ LRESULT CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
/* subclass edit control */
|
||||
editControlWndProc = (WNDPROC)GetWindowLong(GetDlgItem(hWnd, IDC_MENU_TEXT), GWL_WNDPROC);
|
||||
SetWindowLong(GetDlgItem(hWnd, IDC_MENU_TEXT), GWL_WNDPROC, (LONG)NHMenuTextWndProc);
|
||||
break;
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
/* special initialization for SmartPhone dialogs */
|
||||
NHSPhoneDialogSetup(hWnd, FALSE);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case WM_MSNH_COMMAND:
|
||||
onMSNHCommand(hWnd, wParam, lParam);
|
||||
@@ -288,6 +323,17 @@ LRESULT CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
data->result = 0;
|
||||
return TRUE;
|
||||
}
|
||||
} else if( data->how==PICK_ANY ) {
|
||||
if( lpnmlv->iItem>=0 &&
|
||||
lpnmlv->iItem<data->menu.size &&
|
||||
NHMENU_IS_SELECTABLE(data->menu.items[lpnmlv->iItem]) ) {
|
||||
SelectMenuItem(
|
||||
lpnmlv->hdr.hwndFrom,
|
||||
data,
|
||||
lpnmlv->iItem,
|
||||
NHMENU_IS_SELECTED(data->menu.items[lpnmlv->iItem])? 0 : -1
|
||||
);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -310,10 +356,9 @@ LRESULT CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
if( lpnmlv->iItem==-1 ) return 0;
|
||||
if( !(lpnmlv->uChanged & LVIF_STATE) ) return 0;
|
||||
|
||||
if( data->how==PICK_ONE || data->how==PICK_ANY ) {
|
||||
data->menu.items[lpnmlv->iItem].has_focus = !!(lpnmlv->uNewState & LVIS_FOCUSED);
|
||||
ListView_RedrawItems(lpnmlv->hdr.hwndFrom, lpnmlv->iItem, lpnmlv->iItem);
|
||||
}
|
||||
/* update item that has the focus */
|
||||
data->menu.items[lpnmlv->iItem].has_focus = !!(lpnmlv->uNewState & LVIS_FOCUSED);
|
||||
ListView_RedrawItems(lpnmlv->hdr.hwndFrom, lpnmlv->iItem, lpnmlv->iItem);
|
||||
|
||||
/* update count for single-selection menu (follow the listview selection) */
|
||||
if( data->how==PICK_ONE ) {
|
||||
@@ -328,10 +373,8 @@ LRESULT CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
}
|
||||
|
||||
/* check item focus */
|
||||
if( data->how==PICK_ONE || data->how==PICK_ANY ) {
|
||||
data->menu.items[lpnmlv->iItem].has_focus = !!(lpnmlv->uNewState & LVIS_FOCUSED);
|
||||
ListView_RedrawItems(lpnmlv->hdr.hwndFrom, lpnmlv->iItem, lpnmlv->iItem);
|
||||
}
|
||||
data->menu.items[lpnmlv->iItem].has_focus = !!(lpnmlv->uNewState & LVIS_FOCUSED);
|
||||
ListView_RedrawItems(lpnmlv->hdr.hwndFrom, lpnmlv->iItem, lpnmlv->iItem);
|
||||
} break;
|
||||
|
||||
case NM_KILLFOCUS:
|
||||
@@ -346,6 +389,7 @@ LRESULT CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
case WM_SETFOCUS:
|
||||
if( hWnd!=GetNHApp()->hPopupWnd ) {
|
||||
SetFocus(GetNHApp()->hPopupWnd );
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -391,8 +435,7 @@ LRESULT CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
|
||||
void CheckInputDialog(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
/* NOP in Windows CE 211 */
|
||||
#ifndef WIN_CE_2xx
|
||||
#if defined(WIN_CE_POCKETPC)
|
||||
PNHMenuWindow data;
|
||||
|
||||
data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
@@ -581,26 +624,37 @@ void LayoutMenu(HWND hWnd)
|
||||
GetClientRect(hWnd, &clrt );
|
||||
|
||||
/* set window placements */
|
||||
GetWindowRect(menu_ok, &rt);
|
||||
sz_ok.cx = (clrt.right - clrt.left)/2 - 2*MENU_MARGIN;
|
||||
sz_ok.cy = rt.bottom-rt.top;
|
||||
pt_ok.x = clrt.left + MENU_MARGIN;
|
||||
pt_ok.y = clrt.bottom - MENU_MARGIN - sz_ok.cy;
|
||||
|
||||
GetWindowRect(menu_cancel, &rt);
|
||||
sz_cancel.cx = (clrt.right - clrt.left)/2 - 2*MENU_MARGIN;
|
||||
sz_cancel.cy = rt.bottom-rt.top;
|
||||
pt_cancel.x = (clrt.left + clrt.right)/2 + MENU_MARGIN;
|
||||
pt_cancel.y = clrt.bottom - MENU_MARGIN - sz_cancel.cy;
|
||||
if( IsWindow(menu_ok) ) {
|
||||
GetWindowRect(menu_ok, &rt);
|
||||
sz_ok.cx = (clrt.right - clrt.left)/2 - 2*MENU_MARGIN;
|
||||
sz_ok.cy = rt.bottom-rt.top;
|
||||
pt_ok.x = clrt.left + MENU_MARGIN;
|
||||
pt_ok.y = clrt.bottom - MENU_MARGIN - sz_ok.cy;
|
||||
MoveWindow(menu_ok, pt_ok.x, pt_ok.y, sz_ok.cx, sz_ok.cy, TRUE );
|
||||
} else {
|
||||
pt_ok.x = 0;
|
||||
pt_ok.y = clrt.bottom;
|
||||
sz_ok.cx = sz_ok.cy = 0;
|
||||
}
|
||||
|
||||
if( IsWindow(menu_cancel) ) {
|
||||
GetWindowRect(menu_cancel, &rt);
|
||||
sz_cancel.cx = (clrt.right - clrt.left)/2 - 2*MENU_MARGIN;
|
||||
sz_cancel.cy = rt.bottom-rt.top;
|
||||
pt_cancel.x = (clrt.left + clrt.right)/2 + MENU_MARGIN;
|
||||
pt_cancel.y = clrt.bottom - MENU_MARGIN - sz_cancel.cy;
|
||||
MoveWindow(menu_cancel, pt_cancel.x, pt_cancel.y, sz_cancel.cx, sz_cancel.cy, TRUE );
|
||||
} else {
|
||||
pt_cancel.x = 0;
|
||||
pt_cancel.y = clrt.bottom;
|
||||
sz_cancel.cx = sz_cancel.cy = 0;
|
||||
}
|
||||
|
||||
pt_elem.x = clrt.left + MENU_MARGIN;
|
||||
pt_elem.y = clrt.top + MENU_MARGIN;
|
||||
sz_elem.cx = (clrt.right - clrt.left) - 2*MENU_MARGIN;
|
||||
sz_elem.cy = min(pt_cancel.y, pt_ok.y) - 2*MENU_MARGIN;
|
||||
|
||||
sz_elem.cy = min(pt_cancel.y, pt_ok.y) - MENU_MARGIN - pt_elem.y;
|
||||
MoveWindow(GetMenuControl(hWnd), pt_elem.x, pt_elem.y, sz_elem.cx, sz_elem.cy, TRUE );
|
||||
MoveWindow(menu_ok, pt_ok.x, pt_ok.y, sz_ok.cx, sz_ok.cy, TRUE );
|
||||
MoveWindow(menu_cancel, pt_cancel.x, pt_cancel.y, sz_cancel.cx, sz_cancel.cy, TRUE );
|
||||
}
|
||||
|
||||
void SetMenuType(HWND hWnd, int type)
|
||||
@@ -804,37 +858,39 @@ LRESULT onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
x = lpdis->rcItem.left + 1;
|
||||
|
||||
/* print check mark */
|
||||
if( NHMENU_IS_SELECTABLE(*item) ) {
|
||||
HGDIOBJ saveBrush;
|
||||
HBRUSH hbrCheckMark;
|
||||
char buf[2];
|
||||
/* print check mark if it is a "selectable" menu */
|
||||
if( data->how!=PICK_NONE ) {
|
||||
if( NHMENU_IS_SELECTABLE(*item) ) {
|
||||
HGDIOBJ saveBrush;
|
||||
HBRUSH hbrCheckMark;
|
||||
char buf[2];
|
||||
|
||||
switch(item->count) {
|
||||
case -1: hbrCheckMark = CreatePatternBrush(data->bmpChecked); break;
|
||||
case 0: hbrCheckMark = CreatePatternBrush(data->bmpNotChecked); break;
|
||||
default: hbrCheckMark = CreatePatternBrush(data->bmpCheckedCount); break;
|
||||
switch(item->count) {
|
||||
case -1: hbrCheckMark = CreatePatternBrush(data->bmpChecked); break;
|
||||
case 0: hbrCheckMark = CreatePatternBrush(data->bmpNotChecked); break;
|
||||
default: hbrCheckMark = CreatePatternBrush(data->bmpCheckedCount); break;
|
||||
}
|
||||
|
||||
y = (lpdis->rcItem.bottom + lpdis->rcItem.top - TILE_Y) / 2;
|
||||
SetBrushOrgEx(lpdis->hDC, x, y, NULL);
|
||||
saveBrush = SelectObject(lpdis->hDC, hbrCheckMark);
|
||||
PatBlt(lpdis->hDC, x, y, TILE_X, TILE_Y, PATCOPY);
|
||||
SelectObject(lpdis->hDC, saveBrush);
|
||||
DeleteObject(hbrCheckMark);
|
||||
|
||||
x += TILE_X + 5;
|
||||
|
||||
if(item->accelerator!=0) {
|
||||
buf[0] = item->accelerator;
|
||||
buf[1] = '\x0';
|
||||
|
||||
SetRect( &drawRect, x, lpdis->rcItem.top, lpdis->rcItem.right, lpdis->rcItem.bottom );
|
||||
DrawText(lpdis->hDC, NH_A2W(buf, wbuf, 2), 1, &drawRect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
|
||||
}
|
||||
x += tm.tmAveCharWidth + tm.tmOverhang + 5;
|
||||
} else {
|
||||
x += TILE_X + tm.tmAveCharWidth + tm.tmOverhang + 10;
|
||||
}
|
||||
|
||||
y = (lpdis->rcItem.bottom + lpdis->rcItem.top - TILE_Y) / 2;
|
||||
SetBrushOrgEx(lpdis->hDC, x, y, NULL);
|
||||
saveBrush = SelectObject(lpdis->hDC, hbrCheckMark);
|
||||
PatBlt(lpdis->hDC, x, y, TILE_X, TILE_Y, PATCOPY);
|
||||
SelectObject(lpdis->hDC, saveBrush);
|
||||
DeleteObject(hbrCheckMark);
|
||||
|
||||
x += TILE_X + 5;
|
||||
|
||||
if(item->accelerator!=0) {
|
||||
buf[0] = item->accelerator;
|
||||
buf[1] = '\x0';
|
||||
|
||||
SetRect( &drawRect, x, lpdis->rcItem.top, lpdis->rcItem.right, lpdis->rcItem.bottom );
|
||||
DrawText(lpdis->hDC, NH_A2W(buf, wbuf, 2), 1, &drawRect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
|
||||
}
|
||||
x += tm.tmAveCharWidth + tm.tmOverhang + 5;
|
||||
} else {
|
||||
x += TILE_X + tm.tmAveCharWidth + tm.tmOverhang + 10;
|
||||
}
|
||||
|
||||
/* print glyph if present */
|
||||
@@ -1113,6 +1169,7 @@ BOOL onListChar(HWND hWnd, HWND hwndList, WORD ch)
|
||||
NHMENU_IS_SELECTED(data->menu.items[i])? 0 : -1
|
||||
);
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1327,33 +1384,66 @@ void reset_menu_count(HWND hwndList, PNHMenuWindow data)
|
||||
/* List window Proc */
|
||||
LRESULT CALLBACK NHMenuListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
BOOL bUpdateFocusItem;
|
||||
|
||||
bUpdateFocusItem = FALSE;
|
||||
|
||||
/* bring the system input pad up if required */
|
||||
// CheckInputDialog(GetParent(hWnd), message, wParam);
|
||||
BOOL bUpdateFocusItem = FALSE;
|
||||
|
||||
switch(message) {
|
||||
|
||||
/* filter keyboard input for the control */
|
||||
#if !defined(WIN_CE_SMARTPHONE)
|
||||
case WM_KEYDOWN:
|
||||
case WM_KEYUP: {
|
||||
MSG msg;
|
||||
BOOL processed;
|
||||
|
||||
processed = FALSE;
|
||||
if( PeekMessage(&msg, hWnd, WM_CHAR, WM_CHAR, PM_REMOVE) ) {
|
||||
if( onListChar(GetParent(hWnd), hWnd, (char)msg.wParam)==-2 ) {
|
||||
processed = TRUE;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if( processed ) return 0;
|
||||
|
||||
if( wParam==VK_LEFT || wParam==VK_RIGHT )
|
||||
bUpdateFocusItem = TRUE;
|
||||
} break;
|
||||
|
||||
#else /* defined(WIN_CE_SMARTPHONE) */
|
||||
case WM_KEYDOWN:
|
||||
if( wParam==VK_TACTION ) {
|
||||
if( onListChar(GetParent(hWnd), hWnd, ' ')==-2 ) {
|
||||
return 0;
|
||||
}
|
||||
} else if( NHSPhoneTranslateKbdMessage(wParam, lParam, TRUE) ) {
|
||||
PMSNHEvent evt;
|
||||
BOOL processed = FALSE;
|
||||
if( mswin_have_input() ) {
|
||||
evt = mswin_input_pop();
|
||||
if( evt->type==NHEVENT_CHAR &&
|
||||
onListChar(GetParent(hWnd), hWnd, evt->kbd.ch)==-2 ) {
|
||||
processed = TRUE;
|
||||
}
|
||||
|
||||
/* eat the rest of the events */
|
||||
if( mswin_have_input() ) mswin_input_pop();
|
||||
}
|
||||
if( processed ) return 0;
|
||||
}
|
||||
|
||||
if( wParam==VK_LEFT || wParam==VK_RIGHT )
|
||||
bUpdateFocusItem = TRUE;
|
||||
break;
|
||||
|
||||
case WM_KEYUP:
|
||||
/* translate SmartPhone keyboard message */
|
||||
if( NHSPhoneTranslateKbdMessage(wParam, lParam, FALSE) )
|
||||
return 0;
|
||||
break;
|
||||
|
||||
/* tell Windows not to process default button on VK_RETURN */
|
||||
case WM_GETDLGCODE:
|
||||
return DLGC_DEFPUSHBUTTON | DLGC_WANTALLKEYS |
|
||||
(wndProcListViewOrig?
|
||||
CallWindowProc(wndProcListViewOrig, hWnd, message, wParam, lParam)
|
||||
: 0 );
|
||||
#endif
|
||||
|
||||
case WM_SIZE:
|
||||
case WM_HSCROLL:
|
||||
bUpdateFocusItem = TRUE;
|
||||
@@ -1383,14 +1473,35 @@ LRESULT CALLBACK NHMenuListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
|
||||
LRESULT CALLBACK NHMenuTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(message) {
|
||||
|
||||
/* close on space */
|
||||
case WM_KEYDOWN:
|
||||
if( wParam==VK_SPACE ) {
|
||||
case WM_KEYUP:
|
||||
switch( wParam ) {
|
||||
case VK_SPACE:
|
||||
case VK_RETURN:
|
||||
/* close on space */
|
||||
PostMessage(GetParent(hWnd), WM_COMMAND, MAKELONG(IDOK, 0), 0);
|
||||
}
|
||||
break;
|
||||
return 0;
|
||||
|
||||
case VK_UP:
|
||||
/* scoll up */
|
||||
PostMessage(hWnd, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), (LPARAM)NULL);
|
||||
return 0;
|
||||
|
||||
case VK_DOWN:
|
||||
/* scoll down */
|
||||
PostMessage(hWnd, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), (LPARAM)NULL);
|
||||
return 0;
|
||||
|
||||
case VK_LEFT:
|
||||
/* scoll left */
|
||||
PostMessage(hWnd, WM_HSCROLL, MAKEWPARAM(SB_LINELEFT, 0), (LPARAM)NULL);
|
||||
return 0;
|
||||
|
||||
case VK_RIGHT:
|
||||
/* scoll right */
|
||||
PostMessage(hWnd, WM_HSCROLL, MAKEWPARAM(SB_LINERIGHT, 0), (LPARAM)NULL);
|
||||
return 0;
|
||||
}
|
||||
break; /* case WM_KEYUP: */
|
||||
}
|
||||
|
||||
if( editControlWndProc )
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "winMS.h"
|
||||
#include "resource.h"
|
||||
#include "mhrip.h"
|
||||
#include "mhtext.h"
|
||||
|
||||
|
||||
@@ -8,16 +8,18 @@
|
||||
#include "mhcolor.h"
|
||||
|
||||
#define MAXWINDOWTEXT 255
|
||||
#define NHSW_LINES 4
|
||||
|
||||
#define NHSTAT_LINES_2 2
|
||||
#define NHSTAT_LINES_4 4
|
||||
typedef struct mswin_nethack_status_window {
|
||||
int nhstat_format;
|
||||
char window_text[MAXWINDOWTEXT];
|
||||
} NHStatusWindow, *PNHStatusWindow;
|
||||
|
||||
static TCHAR szStatusWindowClass[] = TEXT("MSNHStatusWndClass");
|
||||
LRESULT CALLBACK StatusWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static void register_status_window_class(void);
|
||||
static void FormatStatusString(char* text);
|
||||
static void FormatStatusString(char* text, int format);
|
||||
|
||||
HWND mswin_init_status_window () {
|
||||
static int run_once = 0;
|
||||
@@ -49,6 +51,7 @@ HWND mswin_init_status_window () {
|
||||
if( !data ) panic("out of memory");
|
||||
|
||||
ZeroMemory(data, sizeof(NHStatusWindow));
|
||||
data->nhstat_format = NHSTAT_LINES_4;
|
||||
SetWindowLong(ret, GWL_USERDATA, (LONG)data);
|
||||
return ret;
|
||||
}
|
||||
@@ -89,7 +92,7 @@ LRESULT CALLBACK StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
||||
case MSNH_MSG_PUTSTR:
|
||||
case MSNH_MSG_CLEAR_WINDOW:
|
||||
ZeroMemory(data->window_text, sizeof(data->window_text));
|
||||
FormatStatusString(data->window_text);
|
||||
FormatStatusString(data->window_text, data->nhstat_format);
|
||||
break;
|
||||
|
||||
case MSNH_MSG_CURSOR: {
|
||||
@@ -157,7 +160,12 @@ void mswin_status_window_size (HWND hWnd, LPSIZE sz)
|
||||
saveFont = SelectObject(hdc, mswin_get_font(NHW_STATUS, ATR_NONE, hdc, FALSE));
|
||||
GetTextMetrics(hdc, &tm);
|
||||
|
||||
sz->cy = tm.tmHeight * NHSW_LINES;
|
||||
/* see if the status window can fit 80 characters per line */
|
||||
if( (80*tm.tmMaxCharWidth)>=sz->cx ) data->nhstat_format = NHSTAT_LINES_4;
|
||||
else data->nhstat_format = NHSTAT_LINES_2;
|
||||
|
||||
/* set height of the status box */
|
||||
sz->cy = tm.tmHeight * data->nhstat_format;
|
||||
|
||||
SelectObject(hdc, saveFont);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
@@ -165,7 +173,7 @@ void mswin_status_window_size (HWND hWnd, LPSIZE sz)
|
||||
}
|
||||
extern const char *hu_stat[]; /* defined in eat.c */
|
||||
extern const char *enc_stat[]; /* define in botl.c */
|
||||
void FormatStatusString(char* text)
|
||||
void FormatStatusString(char* text, int format)
|
||||
{
|
||||
register char *nb;
|
||||
int hp, hpmax;
|
||||
@@ -191,7 +199,7 @@ void FormatStatusString(char* text)
|
||||
} else
|
||||
Sprintf(nb = eos(nb), rank_of(u.ulevel, Role_switch, flags.female));
|
||||
|
||||
Sprintf(nb = eos(nb),"\r\n");
|
||||
if( format==NHSTAT_LINES_4 ) Sprintf(nb = eos(nb),"\r\n");
|
||||
|
||||
if (ACURR(A_STR) > 18) {
|
||||
if (ACURR(A_STR) > STR18(100))
|
||||
@@ -211,7 +219,8 @@ void FormatStatusString(char* text)
|
||||
if (flags.showscore)
|
||||
Sprintf(nb = eos(nb), " S:%ld", botl_score());
|
||||
#endif
|
||||
strcat(text, "\r\n");
|
||||
if( format==NHSTAT_LINES_4 ||
|
||||
format==NHSTAT_LINES_2 ) strcat(text, "\r\n");
|
||||
|
||||
/* third line */
|
||||
hp = Upolyd ? u.mh : u.uhp;
|
||||
@@ -236,7 +245,7 @@ void FormatStatusString(char* text)
|
||||
#endif
|
||||
else
|
||||
Sprintf(nb = eos(nb), " Exp:%u", u.ulevel);
|
||||
strcat(text, "\r\n");
|
||||
if( format==NHSTAT_LINES_4 ) strcat(text, "\r\n");
|
||||
|
||||
/* forth line */
|
||||
if(flags.time)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "winMS.h"
|
||||
#include "resource.h"
|
||||
#include "mhtext.h"
|
||||
#include "mhmsg.h"
|
||||
#include "mhfont.h"
|
||||
@@ -10,9 +9,13 @@
|
||||
|
||||
typedef struct mswin_nethack_text_window {
|
||||
TCHAR* window_text;
|
||||
int done;
|
||||
} NHTextWindow, *PNHTextWindow;
|
||||
|
||||
static WNDPROC editControlWndProc = NULL;
|
||||
|
||||
LRESULT CALLBACK TextWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT CALLBACK NHTextControlWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
static void LayoutText(HWND hwnd);
|
||||
|
||||
@@ -46,10 +49,11 @@ void mswin_display_text_window (HWND hWnd)
|
||||
control = GetDlgItem(hWnd, IDC_TEXT_CONTROL);
|
||||
SendMessage(control, EM_FMTLINES, 1, 0 );
|
||||
SetWindowText(GetDlgItem(hWnd, IDC_TEXT_CONTROL), data->window_text);
|
||||
}
|
||||
|
||||
mswin_popup_display(hWnd, NULL);
|
||||
mswin_popup_destroy(hWnd);
|
||||
data->done = 0;
|
||||
mswin_popup_display(hWnd, &data->done);
|
||||
mswin_popup_destroy(hWnd);
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK TextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
@@ -72,6 +76,14 @@ LRESULT CALLBACK TextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
SendMessage(control, WM_SETFONT, (WPARAM)mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE), 0);
|
||||
ReleaseDC(control, hdc);
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
/* special initialization for SmartPhone dialogs */
|
||||
NHSPhoneDialogSetup(hWnd, FALSE);
|
||||
#endif
|
||||
/* subclass edit control */
|
||||
editControlWndProc = (WNDPROC)GetWindowLong(control, GWL_WNDPROC);
|
||||
SetWindowLong(control, GWL_WNDPROC, (LONG)NHTextControlWndProc);
|
||||
|
||||
SetFocus(control);
|
||||
return FALSE;
|
||||
|
||||
@@ -88,11 +100,7 @@ LRESULT CALLBACK TextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||
{
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
mswin_window_mark_dead(mswin_winid_from_handle(hWnd));
|
||||
if( GetNHApp()->hMainWnd==hWnd )
|
||||
GetNHApp()->hMainWnd=NULL;
|
||||
DestroyWindow(hWnd);
|
||||
SetFocus(GetNHApp()->hMainWnd);
|
||||
data->done = 1;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
@@ -164,17 +172,65 @@ void LayoutText(HWND hWnd)
|
||||
GetClientRect(hWnd, &clrt );
|
||||
|
||||
/* set window placements */
|
||||
GetWindowRect(btn_ok, &rt);
|
||||
sz_ok.cx = clrt.right - clrt.left;
|
||||
sz_ok.cy = rt.bottom-rt.top;
|
||||
pt_ok.x = clrt.left;
|
||||
pt_ok.y = clrt.bottom - sz_ok.cy;
|
||||
if( IsWindow(btn_ok) ) {
|
||||
GetWindowRect(btn_ok, &rt);
|
||||
sz_ok.cx = clrt.right - clrt.left;
|
||||
sz_ok.cy = rt.bottom-rt.top;
|
||||
pt_ok.x = clrt.left;
|
||||
pt_ok.y = clrt.bottom - sz_ok.cy;
|
||||
MoveWindow(btn_ok, pt_ok.x, pt_ok.y, sz_ok.cx, sz_ok.cy, TRUE );
|
||||
|
||||
pt_elem.x = clrt.left;
|
||||
pt_elem.y = clrt.top;
|
||||
sz_elem.cx = clrt.right - clrt.left;
|
||||
sz_elem.cy = pt_ok.y;
|
||||
|
||||
MoveWindow(text, pt_elem.x, pt_elem.y, sz_elem.cx, sz_elem.cy, TRUE );
|
||||
MoveWindow(btn_ok, pt_ok.x, pt_ok.y, sz_ok.cx, sz_ok.cy, TRUE );
|
||||
pt_elem.x = clrt.left;
|
||||
pt_elem.y = clrt.top;
|
||||
sz_elem.cx = clrt.right - clrt.left;
|
||||
sz_elem.cy = pt_ok.y;
|
||||
MoveWindow(text, pt_elem.x, pt_elem.y, sz_elem.cx, sz_elem.cy, TRUE );
|
||||
} else {
|
||||
pt_elem.x = clrt.left;
|
||||
pt_elem.y = clrt.top;
|
||||
sz_elem.cx = clrt.right - clrt.left;
|
||||
sz_elem.cy = clrt.bottom - clrt.top;
|
||||
MoveWindow(text, pt_elem.x, pt_elem.y, sz_elem.cx, sz_elem.cy, TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
/* Text control window proc - implements close on space and scrolling on arrows */
|
||||
LRESULT CALLBACK NHTextControlWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(message) {
|
||||
case WM_KEYUP:
|
||||
switch( wParam ) {
|
||||
case VK_SPACE:
|
||||
case VK_RETURN:
|
||||
/* close on space */
|
||||
PostMessage(GetParent(hWnd), WM_COMMAND, MAKELONG(IDOK, 0), 0);
|
||||
return 0;
|
||||
|
||||
case VK_UP:
|
||||
/* scoll up */
|
||||
PostMessage(hWnd, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), (LPARAM)NULL);
|
||||
return 0;
|
||||
|
||||
case VK_DOWN:
|
||||
/* scoll down */
|
||||
PostMessage(hWnd, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), (LPARAM)NULL);
|
||||
return 0;
|
||||
|
||||
case VK_LEFT:
|
||||
/* scoll left */
|
||||
PostMessage(hWnd, WM_HSCROLL, MAKEWPARAM(SB_LINELEFT, 0), (LPARAM)NULL);
|
||||
return 0;
|
||||
|
||||
case VK_RIGHT:
|
||||
/* scoll right */
|
||||
PostMessage(hWnd, WM_HSCROLL, MAKEWPARAM(SB_LINERIGHT, 0), (LPARAM)NULL);
|
||||
return 0;
|
||||
}
|
||||
break; /* case WM_KEYUP: */
|
||||
}
|
||||
|
||||
if( editControlWndProc )
|
||||
return CallWindowProc(editControlWndProc, hWnd, message, wParam, lParam);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "mhmsgwnd.h"
|
||||
#include "mhmenu.h"
|
||||
#include "mhmsg.h"
|
||||
#include "mhcmd.h"
|
||||
#include "mhinput.h"
|
||||
#include "mhaskyn.h"
|
||||
#include "mhdlg.h"
|
||||
@@ -24,7 +25,6 @@
|
||||
#include "mhcolor.h"
|
||||
|
||||
#define LLEN 128
|
||||
#define NHMAP_FONT_NAME "Lucida Console"
|
||||
|
||||
#ifdef _DEBUG
|
||||
extern void logDebug(const char *fmt, ...);
|
||||
@@ -213,11 +213,16 @@ void mswin_init_nhwindows(int* argc, char** argv)
|
||||
*/
|
||||
void mswin_player_selection(void)
|
||||
{
|
||||
int nRole;
|
||||
|
||||
logDebug("mswin_player_selection()\n");
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
/* SmartPhone does not supprt combo-boxes therefor we cannot
|
||||
use dialog for player selection */
|
||||
prompt_for_player_selection();
|
||||
#else
|
||||
if (iflags.wc_player_selection == VIA_DIALOG) {
|
||||
int nRole;
|
||||
|
||||
/* pick player type randomly (use pre-selected role/race/gender/alignment) */
|
||||
if( flags.randomall ) {
|
||||
if (flags.initrole < 0) {
|
||||
@@ -266,6 +271,7 @@ void mswin_player_selection(void)
|
||||
} else { /* iflags.wc_player_selection == VIA_PROMPTS */
|
||||
prompt_for_player_selection();
|
||||
}
|
||||
#endif /* defined(WIN_CE_SMARTPHONE) */
|
||||
}
|
||||
|
||||
void prompt_for_player_selection(void)
|
||||
@@ -297,7 +303,12 @@ void prompt_for_player_selection(void)
|
||||
box_result = MessageBox(NULL,
|
||||
NH_A2W(prompt, wbuf, BUFSZ),
|
||||
TEXT("NetHack for Windows"),
|
||||
MB_YESNOCANCEL | MB_DEFBUTTON1 );
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
MB_YESNO | MB_DEFBUTTON1
|
||||
#else
|
||||
MB_YESNOCANCEL | MB_DEFBUTTON1
|
||||
#endif
|
||||
);
|
||||
|
||||
pick4u = (box_result == IDYES) ? 'y' : (box_result == IDNO) ? 'n' : '\033';
|
||||
/* tty_putstr(BASE_WINDOW, 0, prompt); */
|
||||
@@ -1336,21 +1347,49 @@ char mswin_yn_function(const char *question, const char *choices,
|
||||
logDebug("mswin_yn_function(%s, %s, %d)\n", question, choices, def);
|
||||
|
||||
if (choices) {
|
||||
char *cb, choicebuf[QBUFSZ];
|
||||
Strcpy(choicebuf, choices);
|
||||
if ((cb = index(choicebuf, '\033')) != 0) {
|
||||
/* anything beyond <esc> is hidden */
|
||||
*cb = '\0';
|
||||
}
|
||||
sprintf(message, "%s [%s] ", question, choicebuf);
|
||||
if (def) sprintf(eos(message), "(%c) ", def);
|
||||
/* escape maps to 'q' or 'n' or default, in that order */
|
||||
yn_esc_map = (index(choices, 'q') ? 'q' :
|
||||
(index(choices, 'n') ? 'n' : def));
|
||||
} else {
|
||||
Strcpy(message, question);
|
||||
char *cb, choicebuf[QBUFSZ];
|
||||
Strcpy(choicebuf, choices);
|
||||
if ((cb = index(choicebuf, '\033')) != 0) {
|
||||
/* anything beyond <esc> is hidden */
|
||||
*cb = '\0';
|
||||
}
|
||||
sprintf(message, "%s [%s] ", question, choicebuf);
|
||||
if (def) sprintf(eos(message), "(%c) ", def);
|
||||
/* escape maps to 'q' or 'n' or default, in that order */
|
||||
yn_esc_map = (index(choices, 'q') ? 'q' :
|
||||
(index(choices, 'n') ? 'n' : def));
|
||||
} else {
|
||||
Strcpy(message, question);
|
||||
}
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
ZeroMemory(buf, sizeof(buf));
|
||||
if( choices ) {
|
||||
if( !index(choices, '\033') ) buf[0]='\033'; /* make sure ESC is always available */
|
||||
strncat( buf, choices, sizeof(buf)-2);
|
||||
NHSPhoneSetKeypadFromString( buf );
|
||||
} else {
|
||||
/* sometimes choices are included in the message itself, e.g. "what? [abcd]" */
|
||||
char *p1, *p2;
|
||||
p1 = strchr(question, '[');
|
||||
p2 = strrchr(question, ']');
|
||||
if( p1 && p2 && p1<p2 ) {
|
||||
buf[0]='\033'; /* make sure ESC is always available */
|
||||
strncat(buf, p1+1, p2-p1-1);
|
||||
NHSPhoneSetKeypadFromString( buf );
|
||||
} else if( strstr(question, "direction") ) {
|
||||
/* asking for direction here */
|
||||
NHSPhoneSetKeypadDirection( );
|
||||
} else {
|
||||
/* anything goes */
|
||||
NHSPhoneSetKeypadFromString( "\0330-9a-zA-Z" );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* defined(WIN_CE_SMARTPHONE) */
|
||||
|
||||
mswin_putstr(WIN_MESSAGE, ATR_BOLD, message);
|
||||
|
||||
/* Only here if main window is not present */
|
||||
@@ -1378,6 +1417,9 @@ char mswin_yn_function(const char *question, const char *choices,
|
||||
mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, res_ch, 1);
|
||||
}
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
NHSPhoneSetKeypadDefault();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1695,14 +1737,20 @@ void mswin_popup_display(HWND hWnd, int* done_indicator)
|
||||
for( hChild=GetWindow(GetNHApp()->hMainWnd, GW_CHILD);
|
||||
hChild;
|
||||
hChild = GetWindow(hChild, GW_HWNDNEXT) ) {
|
||||
if( hChild!= hWnd) EnableWindow(hChild, FALSE);
|
||||
if( hChild!=hWnd ) EnableWindow(hChild, FALSE);
|
||||
}
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
ShowWindow(GetNHApp()->hMenuBar, SW_HIDE);
|
||||
ShowWindow(SHFindMenuBar(hWnd), SW_SHOW);
|
||||
#else
|
||||
EnableWindow(GetNHApp()->hMenuBar, FALSE);
|
||||
#endif
|
||||
|
||||
/* bring menu window on top */
|
||||
SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
|
||||
/* go into message loop */
|
||||
if( done_indicator ) *done_indicator = 0;
|
||||
while( IsWindow(hWnd) &&
|
||||
(done_indicator==NULL || !*done_indicator) &&
|
||||
GetMessage(&msg, NULL, 0, 0)!=0 ) {
|
||||
@@ -1727,7 +1775,12 @@ void mswin_popup_destroy(HWND hWnd)
|
||||
EnableWindow(hChild, TRUE);
|
||||
}
|
||||
}
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
ShowWindow(SHFindMenuBar(hWnd), SW_HIDE);
|
||||
ShowWindow(GetNHApp()->hMenuBar, SW_SHOW);
|
||||
#else
|
||||
EnableWindow(GetNHApp()->hMenuBar, TRUE);
|
||||
#endif
|
||||
|
||||
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW);
|
||||
GetNHApp()->hPopupWnd = NULL;
|
||||
@@ -1739,6 +1792,45 @@ void mswin_popup_destroy(HWND hWnd)
|
||||
SetFocus(GetNHApp()->hMainWnd );
|
||||
}
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
void NHSPhoneDialogSetup(HWND hDlg, BOOL is_edit)
|
||||
{
|
||||
SHMENUBARINFO mbi;
|
||||
HWND hOK, hCancel;
|
||||
RECT rtOK, rtDlg;
|
||||
|
||||
// Create our MenuBar
|
||||
ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
|
||||
mbi.cbSize = sizeof(mbi);
|
||||
mbi.hwndParent = hDlg;
|
||||
mbi.nToolBarId = IDC_SPHONE_DIALOGBAR;
|
||||
mbi.hInstRes = GetNHApp()->hApp;
|
||||
if(!SHCreateMenuBar(&mbi)) {
|
||||
error("cannot create dialog menu");
|
||||
}
|
||||
|
||||
/* hide OK and CANCEL buttons */
|
||||
hOK = GetDlgItem(hDlg, IDOK);
|
||||
hCancel = GetDlgItem(hDlg, IDCANCEL);
|
||||
|
||||
if( IsWindow(hCancel) ) ShowWindow(hCancel, SW_HIDE);
|
||||
if( IsWindow(hOK) ) {
|
||||
GetWindowRect(hOK, &rtOK);
|
||||
GetWindowRect(hDlg, &rtDlg);
|
||||
|
||||
rtDlg.bottom -= rtOK.bottom-rtOK.top;
|
||||
ShowWindow(hOK, SW_HIDE);
|
||||
SetWindowPos( hDlg, HWND_TOP,
|
||||
0, 0,
|
||||
rtDlg.right-rtDlg.left, rtDlg.bottom-rtDlg.top,
|
||||
SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOZORDER );
|
||||
}
|
||||
|
||||
/* override "Back" button for edit box dialogs */
|
||||
if( is_edit )
|
||||
SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK, MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY, SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
|
||||
}
|
||||
#endif /* defined(WIN_CE_SMARTPHONE) */
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#endif
|
||||
#include <commctrl.h>
|
||||
#define SHMENUBAR RCDATA
|
||||
#if defined(WIN32_PLATFORM_PSPC) && (_WIN32_WCE >= 300)
|
||||
#if (defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) && (_WIN32_WCE >= 300)
|
||||
#include <aygshell.h>
|
||||
#else
|
||||
#define I_IMAGENONE (-2)
|
||||
|
||||
32331
sys/wince/palmpc.vcp
Normal file
32331
sys/wince/palmpc.vcp
Normal file
File diff suppressed because it is too large
Load Diff
39883
sys/wince/pocketpc.vcp
Normal file
39883
sys/wince/pocketpc.vcp
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by winhack.rc
|
||||
// Used by winhack_sp.rc
|
||||
//
|
||||
#define IDC_MYICON 2
|
||||
#define IDD_WINHACK_DIALOG 102
|
||||
@@ -11,6 +11,7 @@
|
||||
#define IDS_HELLO 106
|
||||
#define IDI_WINHACK 107
|
||||
#define IDC_WINHACK 109
|
||||
#define IDC_SPHONE_DIALOGBAR 111
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDB_TILES 129
|
||||
#define IDD_TEXT 130
|
||||
@@ -140,14 +141,17 @@
|
||||
#define IDM_VIEW_KEYPAD 32800
|
||||
#define ID_VIEW 32801
|
||||
#define IDS_CAP_VIEW 32802
|
||||
#define IDS_CAP_ENTIREMAP 32826
|
||||
#define IDS_CAP_NORMALMAP 32827
|
||||
#define IDM_HELP_MENU 32828
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 148
|
||||
#define _APS_NEXT_COMMAND_VALUE 32805
|
||||
#define _APS_NEXT_CONTROL_VALUE 1333
|
||||
#define _APS_NEXT_RESOURCE_VALUE 153
|
||||
#define _APS_NEXT_COMMAND_VALUE 32829
|
||||
#define _APS_NEXT_CONTROL_VALUE 1334
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
||||
|
||||
16998
sys/wince/smartphn.vcp
Normal file
16998
sys/wince/smartphn.vcp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,8 +10,29 @@
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <tchar.h>
|
||||
#include <newres.h>
|
||||
#include "resource.h"
|
||||
#include "hack.h"
|
||||
|
||||
#if defined(WIN_CE_POCKETPC)
|
||||
#include <aygshell.h>
|
||||
#include <sipapi.h>
|
||||
#endif
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
#include <aygshell.h>
|
||||
#include <sipapi.h>
|
||||
#include <shlobj.h>
|
||||
#include <prsht.h>
|
||||
#include <Tpcshell.h>
|
||||
#include <windowsm.h>
|
||||
#include <KEYBD.H>
|
||||
#endif
|
||||
|
||||
#if defined(WIN_CE_PS2xx) || defined(WIN32_PLATFORM_HPCPRO)
|
||||
#include <sipapi.h>
|
||||
#endif
|
||||
|
||||
/* Create an array to keep track of the various windows */
|
||||
|
||||
#ifndef MAXWINDOWS
|
||||
@@ -70,6 +91,7 @@ typedef struct mswin_nhwindow_app {
|
||||
int mapDisplayModeSave; /* saved map display mode */
|
||||
|
||||
int bCmdPad; /* command pad - on-screen keyboard */
|
||||
HWND hCmdWnd; /* handle of on-screen keyboard window */
|
||||
} NHWinApp, *PNHWinApp;
|
||||
extern PNHWinApp GetNHApp();
|
||||
|
||||
@@ -138,4 +160,9 @@ void nhapply_image_transparent(
|
||||
);
|
||||
void mswin_popup_display(HWND popup, int* done_indicator);
|
||||
void mswin_popup_destroy(HWND popup);
|
||||
|
||||
#if defined(WIN_CE_SMARTPHONE)
|
||||
void NHSPhoneDialogSetup(HWND hDlg, BOOL is_edit);
|
||||
#endif
|
||||
|
||||
#endif /* WINmswin_H */
|
||||
|
||||
93612
sys/wince/wince.vcp
93612
sys/wince/wince.vcp
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ Microsoft eMbedded Visual Tools Workspace File, Format Version 3.00
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "recover"=.\wince\recover.vcp - Package Owner=<4>
|
||||
Project: "nethack_hpc"=.\wince\wince_hpc.vcp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
@@ -15,7 +15,31 @@ Package=<4>
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "winhack"=.\wince\wince.vcp - Package Owner=<4>
|
||||
Project: "nethack_palm_pc"=.\wince\wince_palm_pc.vcp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "nethack_pocketp_pc"=.\wince\wince_pocket_pc.vcp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "nethack_smartphone"=.\wince\wince_smartphone.vcp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "winMS.h"
|
||||
#include "hack.h"
|
||||
#include "dlb.h"
|
||||
#include "resource.h"
|
||||
#include "mhmain.h"
|
||||
#include "mhmap.h"
|
||||
|
||||
@@ -28,7 +27,6 @@ BOOL InitInstance(HINSTANCE, int);
|
||||
|
||||
static void win_hack_init(int, char **);
|
||||
static void __cdecl mswin_moveloop(void *);
|
||||
static void run_recover();
|
||||
static BOOL setMapTiles(const char* fname);
|
||||
|
||||
extern void FDECL(pcmain, (int,char **));
|
||||
@@ -70,7 +68,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
|
||||
_nethack_app.mapTilesPerLine = TILES_PER_LINE;
|
||||
_nethack_app.bNoHScroll = FALSE;
|
||||
_nethack_app.bNoVScroll = FALSE;
|
||||
#ifndef WIN_CE_2xx
|
||||
#if defined(WIN_CE_PS2xx) || defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
|
||||
_nethack_app.bCmdPad = TRUE;
|
||||
#else
|
||||
_nethack_app.bCmdPad = FALSE;
|
||||
@@ -101,7 +99,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
|
||||
|
||||
/* get command line parameters */
|
||||
p = _get_cmd_arg(
|
||||
#ifdef WIN_CE_2xx
|
||||
#if defined(WIN_CE_PS2xx) || defined(WIN32_PLATFORM_HPCPRO)
|
||||
lpCmdLine
|
||||
#else
|
||||
GetCommandLine()
|
||||
@@ -177,7 +175,7 @@ getlock()
|
||||
int choice;
|
||||
|
||||
/* regularize(lock); */ /* already done in pcmain */
|
||||
Sprintf(tbuf,fqname(lock, LEVELPREFIX, 0));
|
||||
Sprintf(tbuf, "%s", fqname(lock, LEVELPREFIX, 0));
|
||||
set_levelfile_name(lock, 0);
|
||||
fq_lock = fqname(lock, LEVELPREFIX, 1);
|
||||
|
||||
@@ -199,28 +197,22 @@ getlock()
|
||||
/* prompt user that the game alredy exist */
|
||||
choice = MessageBox(
|
||||
GetNHApp()->hMainWnd,
|
||||
TEXT("There is already a game in progress under your name.\n")
|
||||
TEXT("If this is unexpected, you may be able to use \n")
|
||||
TEXT("\"recover\" to get it back.")
|
||||
TEXT("\nDo you want to recover the old game?"),
|
||||
TEXT("There are files from a game in progress under your name. Recover?"),
|
||||
TEXT("Nethack"),
|
||||
MB_YESNOCANCEL );
|
||||
MB_YESNO | MB_DEFBUTTON1
|
||||
);
|
||||
switch(choice) {
|
||||
case IDYES:
|
||||
run_recover();
|
||||
break;
|
||||
|
||||
case IDNO:
|
||||
if(eraseoldlocks()) {
|
||||
if(recover_savefile()) {
|
||||
goto gotlock;
|
||||
} else {
|
||||
error("Couldn't destroy old game.");
|
||||
error("Couldn't recover old game.");
|
||||
}
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
SetLastError(0);
|
||||
error("%s", "Good-bye.");
|
||||
case IDNO:
|
||||
unlock_file(HLOCK);
|
||||
error("%s", "Cannot start a new game.");
|
||||
break;
|
||||
};
|
||||
|
||||
@@ -321,40 +313,6 @@ TCHAR* _get_cmd_arg(TCHAR* pCmdLine)
|
||||
return pRetArg;
|
||||
}
|
||||
|
||||
static void run_recover()
|
||||
{
|
||||
TCHAR wbuf[BUFSZ];
|
||||
TCHAR cmd_name[BUFSZ];
|
||||
char cmd_line[BUFSZ];
|
||||
DWORD ret;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
_stprintf(cmd_name, TEXT("%s\\recover.exe"), NH_A2W(hackdir, wbuf, BUFSZ) );
|
||||
sprintf(cmd_line, "-d \"%s\" \"%s-%s\"",
|
||||
hackdir,
|
||||
get_username(0),
|
||||
plname
|
||||
);
|
||||
ret = CreateProcess(
|
||||
cmd_name,
|
||||
NH_A2W(cmd_line, wbuf, BUFSZ),
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&pi );
|
||||
if( ret==0 ) {
|
||||
error( "cannot run recover.exe" );
|
||||
}
|
||||
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
GetExitCodeProcess(pi.hProcess, &ret );
|
||||
/* do something with exit status? */
|
||||
}
|
||||
|
||||
/*
|
||||
* Strip out troublesome file system characters.
|
||||
*/
|
||||
|
||||
@@ -122,8 +122,8 @@ STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Question?"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,0,15,55,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,55,15,60,14
|
||||
DEFPUSHBUTTON "OK",IDOK,0,16,55,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,55,16,60,14
|
||||
EDITTEXT IDC_GETLIN_EDIT,0,0,115,15,ES_AUTOHSCROLL
|
||||
END
|
||||
|
||||
@@ -226,11 +226,6 @@ IDB_KEYPAD BITMAP DISCARDABLE "keypad.bmp"
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_GETLIN, DIALOG
|
||||
BEGIN
|
||||
BOTTOMMARGIN, 29
|
||||
END
|
||||
|
||||
IDD_PLAYER_SELECTOR, DIALOG
|
||||
BEGIN
|
||||
RIGHTMARGIN, 98
|
||||
@@ -252,6 +247,7 @@ BEGIN
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 107
|
||||
END
|
||||
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
@@ -274,7 +270,6 @@ BEGIN
|
||||
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_CAP_HELP, 0, 3,
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -345,6 +340,12 @@ BEGIN
|
||||
IDS_CAP_VIEW "View"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDOK "Done"
|
||||
IDCANCEL "Cancel"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
345
sys/wince/winhcksp.rc
Normal file
345
sys/wince/winhcksp.rc
Normal file
@@ -0,0 +1,345 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "newres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_WINHACK ICON DISCARDABLE "NETHACK.ICO"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menubar
|
||||
//
|
||||
|
||||
IDC_WINHACK MENU DISCARDABLE
|
||||
BEGIN
|
||||
MENUITEM "Entire Map", IDM_MAP_FIT_TO_SCREEN
|
||||
POPUP "Menu"
|
||||
BEGIN
|
||||
MENUITEM "Keypad", IDM_VIEW_KEYPAD
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "ASCII", IDM_MAP_ASCII8X8
|
||||
MENUITEM "Use Tiles", IDM_MAP_TILES
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Help", IDM_HELP_MENU
|
||||
MENUITEM "Save", IDM_SAVE
|
||||
MENUITEM "Quit", IDM_EXIT
|
||||
END
|
||||
END
|
||||
|
||||
IDC_SPHONE_DIALOGBAR MENU DISCARDABLE
|
||||
BEGIN
|
||||
MENUITEM "Done", IDOK
|
||||
MENUITEM "Cancel", IDCANCEL
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDC_WINHACK ACCELERATORS MOVEABLE PURE
|
||||
BEGIN
|
||||
"?", IDM_ABOUT, ASCII, ALT
|
||||
"/", IDM_ABOUT, ASCII, ALT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 123, 87
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About"
|
||||
FONT 8, "System"
|
||||
BEGIN
|
||||
LTEXT "NetHack",IDC_ABOUT_VERSION,0,2,120,15,SS_NOPREFIX
|
||||
LTEXT "Copyright",IDC_ABOUT_COPYRIGHT,0,20,120,50
|
||||
DEFPUSHBUTTON "OK",IDOK,45,75,30,11,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_MENU DIALOG DISCARDABLE 0, 0, 109, 131
|
||||
STYLE DS_SETFOREGROUND | DS_CONTROL | WS_POPUP | WS_CLIPSIBLINGS | WS_BORDER
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CONTROL "List1",IDC_MENU_LIST,"SysListView32",WS_BORDER |
|
||||
WS_TABSTOP,5,5,100,60
|
||||
EDITTEXT IDC_MENU_TEXT,5,70,100,55,ES_MULTILINE | ES_READONLY |
|
||||
WS_VSCROLL | WS_HSCROLL
|
||||
END
|
||||
|
||||
IDD_NHTEXT DIALOG DISCARDABLE 0, 0, 83, 83
|
||||
STYLE WS_POPUP | WS_BORDER
|
||||
FONT 8, "System"
|
||||
BEGIN
|
||||
EDITTEXT IDC_TEXT_CONTROL,5,0,70,75,ES_MULTILINE | ES_READONLY |
|
||||
WS_VSCROLL | WS_HSCROLL
|
||||
END
|
||||
|
||||
IDD_EXTCMD DIALOG DISCARDABLE 0, 0, 88, 82
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Extended Commands"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LISTBOX IDC_EXTCMD_LIST,7,5,75,69,LBS_NOINTEGRALHEIGHT |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
END
|
||||
|
||||
IDD_GETLIN DIALOG DISCARDABLE 0, 0, 115, 16
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Question?"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
EDITTEXT IDC_GETLIN_EDIT,0,0,115,15,ES_AUTOHSCROLL
|
||||
END
|
||||
|
||||
IDD_PLAYER_SELECTOR DIALOG DISCARDABLE 0, 0, 105, 124
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "What are you?"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
EDITTEXT IDC_PLSEL_NAME,35,0,70,12,ES_AUTOHSCROLL | ES_READONLY
|
||||
LTEXT "Name:",IDC_STATIC,0,0,25,10
|
||||
CONTROL "Random",IDC_PLSEL_ROLE_RANDOM,"Button",BS_AUTOCHECKBOX |
|
||||
BS_NOTIFY | WS_GROUP | WS_TABSTOP,5,20,40,10
|
||||
COMBOBOX IDC_PLSEL_ROLE_LIST,50,20,50,50,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_GROUP | WS_TABSTOP
|
||||
CONTROL "Random",IDC_PLSEL_RACE_RANDOM,"Button",BS_AUTOCHECKBOX |
|
||||
BS_NOTIFY | WS_GROUP | WS_TABSTOP,5,45,40,10
|
||||
COMBOBOX IDC_PLSEL_RACE_LIST,50,45,50,45,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_GROUP | WS_TABSTOP
|
||||
CONTROL "Random",IDC_PLSEL_GENDER_RANDOM,"Button",
|
||||
BS_AUTOCHECKBOX | BS_NOTIFY | WS_GROUP | WS_TABSTOP,5,70,
|
||||
40,10
|
||||
COMBOBOX IDC_PLSEL_GENDER_LIST,50,70,50,40,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_GROUP | WS_TABSTOP
|
||||
CONTROL "Random",IDC_PLSEL_ALIGN_RANDOM,"Button",BS_AUTOCHECKBOX |
|
||||
BS_NOTIFY | WS_GROUP | WS_TABSTOP,5,95,40,10
|
||||
COMBOBOX IDC_PLSEL_ALIGN_LIST,50,95,50,45,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_GROUP | WS_TABSTOP
|
||||
GROUPBOX "Role",IDC_STATIC,0,10,105,25,WS_GROUP
|
||||
GROUPBOX "Race",IDC_STATIC,0,35,105,25
|
||||
GROUPBOX "Gender",IDC_STATIC,0,60,105,25
|
||||
GROUPBOX "Alignment",IDC_STATIC,0,85,105,25
|
||||
DEFPUSHBUTTON "Play",IDOK,0,110,55,14
|
||||
PUSHBUTTON "Quit",IDCANCEL,55,110,50,14
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""newres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDB_TILES BITMAP DISCARDABLE "tiles.bmp"
|
||||
IDB_MENU_SEL BITMAP DISCARDABLE "mnsel.bmp"
|
||||
IDB_MENU_UNSEL BITMAP DISCARDABLE "mnunsel.bmp"
|
||||
IDB_PETMARK BITMAP DISCARDABLE "petmark.bmp"
|
||||
IDB_MENU_SEL_COUNT BITMAP DISCARDABLE "mnselcnt.bmp"
|
||||
IDB_KEYPAD BITMAP DISCARDABLE "keypad.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_NHTEXT, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 5
|
||||
RIGHTMARGIN, 76
|
||||
TOPMARGIN, 7
|
||||
END
|
||||
|
||||
IDD_EXTCMD, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 82
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 75
|
||||
END
|
||||
|
||||
IDD_PLAYER_SELECTOR, DIALOG
|
||||
BEGIN
|
||||
RIGHTMARGIN, 98
|
||||
BOTTOMMARGIN, 117
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Data
|
||||
//
|
||||
|
||||
IDC_WINHACK SHMENUBAR DISCARDABLE
|
||||
BEGIN
|
||||
IDC_WINHACK, 2,
|
||||
I_IMAGENONE, IDM_MAP_FIT_TO_SCREEN, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE, IDM_MAP_FIT_TO_SCREEN, 0, NOMENU,
|
||||
I_IMAGENONE, ID_VIEW, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_CAP_VIEW, 0, 1,
|
||||
END
|
||||
|
||||
IDC_SPHONE_DIALOGBAR SHMENUBAR DISCARDABLE
|
||||
BEGIN
|
||||
IDC_SPHONE_DIALOGBAR, 2,
|
||||
I_IMAGENONE, IDOK, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE, IDOK, 0, NOMENU,
|
||||
I_IMAGENONE, IDCANCEL, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE, IDCANCEL, 0,
|
||||
NOMENU,
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,1,0
|
||||
PRODUCTVERSION 1,0,1,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x9L
|
||||
#else
|
||||
FILEFLAGS 0x8L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "Nethack 3.4.1 for Smartphone (GUI by Alex Kompel)\0"
|
||||
VALUE "CompanyName", " \0"
|
||||
VALUE "FileDescription", "winhack\0"
|
||||
VALUE "FileVersion", "1, 0, 1, 0\0"
|
||||
VALUE "InternalName", "winhack\0"
|
||||
VALUE "LegalCopyright", "Copyright © 2002\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "winhack.exe\0"
|
||||
VALUE "PrivateBuild", "021111\0"
|
||||
VALUE "ProductName", "Nethack For Smartphone\0"
|
||||
VALUE "ProductVersion", "1, 0, 1, 0\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APP_TITLE "winhack"
|
||||
IDC_WINHACK "WINHACK"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDM_MAP_FIT_TO_SCREEN "Entire Map"
|
||||
IDS_CAP_FILE "File"
|
||||
IDS_CAP_HELP "Help"
|
||||
IDS_CAP_MAP "Map"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDM_VIEW_KEYPAD "Show/Hide keypad."
|
||||
IDS_CAP_VIEW "Menu"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDOK "Done"
|
||||
IDCANCEL "Cancel"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_CAP_ENTIREMAP "Entire Map"
|
||||
IDS_CAP_NORMALMAP "Normal Map"
|
||||
IDM_HELP_MENU "Help Menu"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -22,7 +22,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
|
||||
|
||||
/* get command line parameters */
|
||||
p = _get_cmd_arg(
|
||||
#ifdef WIN_CE_2xx
|
||||
#if defined(WIN_CE_PS2xx) || defined(WIN32_PLATFORM_HPCPRO)
|
||||
lpCmdLine
|
||||
#else
|
||||
GetCommandLine()
|
||||
|
||||
Reference in New Issue
Block a user