Windows CE port addition
This commit is contained in:
17
Files
17
Files
@@ -43,8 +43,8 @@ pcconf.h permonst.h prop.h qtext.h quest.h
|
||||
rect.h region.h rm.h skills.h sp_lev.h
|
||||
spell.h system.h tcap.h timeout.h tosconf.h
|
||||
tradstdc.h trampoli.h trap.h unixconf.h vault.h
|
||||
vision.h vmsconf.h winami.h winprocs.h wintype.h
|
||||
you.h youprop.h
|
||||
vision.h vmsconf.h wceconf.h winami.h winprocs.h
|
||||
wintype.h you.h youprop.h
|
||||
(file for tty versions)
|
||||
wintty.h
|
||||
(files for X versions)
|
||||
@@ -173,6 +173,19 @@ Makefile.utl install.com lev_lex.h nethack.com oldcrtl.c
|
||||
spec_lev.com vmsbuild.com vmsfiles.c vmsmail.c vmsmain.c
|
||||
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.h
|
||||
winhack.rc winmain.c
|
||||
|
||||
sys/winnt:
|
||||
(files for Windows 9x, NT and Windows2000 version)
|
||||
console.rc defaults.nh Install.nt Makefile.bcc Makefile.gcc
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
* Windows NT Autodetection
|
||||
*/
|
||||
#ifdef _WIN32_WCE
|
||||
#define WIN_CE
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
@@ -118,10 +119,14 @@
|
||||
# undef UNIX
|
||||
# undef MSDOS
|
||||
# define NHSTDC
|
||||
# define STRNCMPI
|
||||
# define USE_STDARG
|
||||
# define NEED_VARARGS
|
||||
|
||||
#ifndef WIN_CE
|
||||
# define STRNCMPI
|
||||
# define STRCMPI
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -175,8 +175,12 @@ typedef xchar boolean; /* 0 or 1 */
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef WIN_CE
|
||||
#include "wceconf.h"
|
||||
#else
|
||||
#include "ntconf.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Displayable name of this port; don't redefine if defined in *conf.h */
|
||||
#ifndef PORT_ID
|
||||
|
||||
270
include/wceconf.h
Normal file
270
include/wceconf.h
Normal file
@@ -0,0 +1,270 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* Copyright (c) NetHack PC Development Team 1993, 1994. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef WCECONF_H
|
||||
#define WCECONF_H
|
||||
|
||||
#pragma warning(disable:4142) /* benign redefinition of type */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/* #define SHELL /* nt use of pcsys routines caused a hang */
|
||||
|
||||
#define RANDOM /* have Berkeley random(3) */
|
||||
#define TEXTCOLOR /* Color text */
|
||||
|
||||
#define EXEPATH /* Allow .exe location to be used as HACKDIR */
|
||||
#define TRADITIONAL_GLYPHMAP /* Store glyph mappings at level change time */
|
||||
|
||||
#define PC_LOCKING /* Prevent overwrites of aborted or in-progress games */
|
||||
/* without first receiving confirmation. */
|
||||
|
||||
#define NOTSTDC /* no strerror() */
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* The remaining code shouldn't need modification.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
/* #define SHORT_FILENAMES /* All NT filesystems support long names now */
|
||||
|
||||
#ifdef MICRO
|
||||
#undef MICRO /* never define this! */
|
||||
#endif
|
||||
|
||||
#define NOCWD_ASSUMPTIONS /* Always define this. There are assumptions that
|
||||
it is defined for WIN32.
|
||||
Allow paths to be specified for HACKDIR,
|
||||
LEVELDIR, SAVEDIR, BONESDIR, DATADIR,
|
||||
SCOREDIR, LOCKDIR, CONFIGDIR, and TROUBLEDIR */
|
||||
#define NO_TERMS
|
||||
#define ASCIIGRAPH
|
||||
|
||||
#ifdef OPTIONS_USED
|
||||
#undef OPTIONS_USED
|
||||
#endif
|
||||
#ifdef MSWIN_GRAPHICS
|
||||
#define OPTIONS_USED "guioptions"
|
||||
#else
|
||||
#define OPTIONS_USED "ttyoptions"
|
||||
#endif
|
||||
#define OPTIONS_FILE OPTIONS_USED
|
||||
|
||||
#define PORT_HELP "porthelp"
|
||||
|
||||
#include <string.h> /* Provides prototypes of strncmpi(), etc. */
|
||||
#ifdef STRNCMPI
|
||||
#define strncmpi(a,b,c) _strnicmp(a,b,c)
|
||||
#endif
|
||||
|
||||
#ifdef STRCMPI
|
||||
#define strcmpi(a,b) _stricmp(a,b)
|
||||
#define stricmp(a,b) _stricmp(a,b)
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define PATHLEN BUFSZ /* maximum pathlength */
|
||||
#define FILENAME BUFSZ /* maximum filename length (conservative) */
|
||||
|
||||
#if defined(_MAX_PATH) && defined(_MAX_FNAME)
|
||||
# if (_MAX_PATH < BUFSZ) && (_MAX_FNAME < BUFSZ)
|
||||
#undef PATHLEN
|
||||
#undef FILENAME
|
||||
#define PATHLEN _MAX_PATH
|
||||
#define FILENAME _MAX_FNAME
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#define NO_SIGNAL
|
||||
#define index strchr
|
||||
#define rindex strrchr
|
||||
#define USE_STDARG
|
||||
#ifdef RANDOM
|
||||
/* Use the high quality random number routines. */
|
||||
#define Rand() random()
|
||||
#else
|
||||
#define Rand() rand()
|
||||
#endif
|
||||
|
||||
#define FCMASK 0660 /* file creation mask */
|
||||
#define regularize nt_regularize
|
||||
#define HLOCK "NHPERM"
|
||||
|
||||
#ifndef M
|
||||
#define M(c) ((char) (0x80 | (c)))
|
||||
/* #define M(c) ((c) - 128) */
|
||||
#endif
|
||||
|
||||
#ifndef C
|
||||
#define C(c) (0x1f & (c))
|
||||
#endif
|
||||
|
||||
#if defined(DLB)
|
||||
#define FILENAME_CMP _stricmp /* case insensitive */
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
extern char levels[], bones[], permbones[],
|
||||
#endif /* 0 */
|
||||
|
||||
/* this was part of the MICRO stuff in the past */
|
||||
extern const char *alllevels, *allbones;
|
||||
extern char hackdir[];
|
||||
#define ABORT C('a')
|
||||
#define getuid() 1
|
||||
#define getlogin() ((char *)0)
|
||||
extern void NDECL(win32_abort);
|
||||
#ifdef WIN32CON
|
||||
extern void FDECL(nttty_preference_update, (const char *));
|
||||
extern void NDECL(toggle_mouse_support);
|
||||
#endif
|
||||
|
||||
#ifndef alloca
|
||||
#define ALLOCA_HACK /* used in util/panic.c */
|
||||
#endif
|
||||
|
||||
#ifndef REDO
|
||||
#undef Getchar
|
||||
#define Getchar nhgetch
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if 0
|
||||
#pragma warning(disable:4018) /* signed/unsigned mismatch */
|
||||
#pragma warning(disable:4305) /* init, conv from 'const int' to 'char' */
|
||||
#endif
|
||||
#pragma warning(disable:4761) /* integral size mismatch in arg; conv supp*/
|
||||
#ifdef YYPREFIX
|
||||
#pragma warning(disable:4102) /* unreferenced label */
|
||||
#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
|
||||
#define NH_W2A(w, a, cb) ( WideCharToMultiByte( \
|
||||
CP_ACP, \
|
||||
0, \
|
||||
(w), \
|
||||
-1, \
|
||||
(a), \
|
||||
(cb), \
|
||||
NULL, \
|
||||
NULL), (a) )
|
||||
|
||||
#define NH_A2W(a, w, cb) ( MultiByteToWideChar( \
|
||||
CP_ACP, \
|
||||
0, \
|
||||
(a), \
|
||||
-1, \
|
||||
(w), \
|
||||
(cb)), (w) )
|
||||
#else
|
||||
#define NH_W2A(w, a, cb) (strncpy((a), (w), (cb)))
|
||||
|
||||
#define NH_A2W(a, w, cb) (strncpy((w), (a), (cb)))
|
||||
#endif
|
||||
|
||||
extern int FDECL(set_win32_option, (const char *, const char *));
|
||||
|
||||
/* Missing definitions */
|
||||
extern int mswin_have_input();
|
||||
#define kbhit mswin_have_input
|
||||
|
||||
#define getenv(a) ((char*)NULL)
|
||||
|
||||
/* __stdio.h__ */
|
||||
#define perror(a)
|
||||
#define freopen(a, b, c) fopen(a, b)
|
||||
extern int isatty(int);
|
||||
|
||||
/* __time.h___ */
|
||||
#ifndef _TIME_T_DEFINED
|
||||
typedef __int64 time_t; /* time value */
|
||||
#define _TIME_T_DEFINED /* avoid multiple def's of time_t */
|
||||
#endif
|
||||
|
||||
#ifndef _TM_DEFINED
|
||||
struct tm {
|
||||
int tm_sec; /* seconds after the minute - [0,59] */
|
||||
int tm_min; /* minutes after the hour - [0,59] */
|
||||
int tm_hour; /* hours since midnight - [0,23] */
|
||||
int tm_mday; /* day of the month - [1,31] */
|
||||
int tm_mon; /* months since January - [0,11] */
|
||||
int tm_year; /* years since 1900 */
|
||||
int tm_wday; /* days since Sunday - [0,6] */
|
||||
int tm_yday; /* days since January 1 - [0,365] */
|
||||
int tm_isdst; /* daylight savings time flag - - NOT IMPLEMENTED */
|
||||
};
|
||||
#define _TM_DEFINED
|
||||
#endif
|
||||
|
||||
struct tm * __cdecl localtime(const time_t *);
|
||||
time_t __cdecl time(time_t *);
|
||||
|
||||
/* __stdio.h__ */
|
||||
#ifndef BUFSIZ
|
||||
#define BUFSIZ 255
|
||||
#endif
|
||||
|
||||
#define rewind(stream) (void)fseek( stream, 0L, SEEK_SET )
|
||||
|
||||
/* __io.h__ */
|
||||
typedef long off_t;
|
||||
|
||||
int __cdecl close(int);
|
||||
int __cdecl creat(const char *, int);
|
||||
int __cdecl eof(int);
|
||||
long __cdecl lseek(int, long, int);
|
||||
int __cdecl open(const char *, int, ...);
|
||||
int __cdecl read(int, void *, unsigned int);
|
||||
int __cdecl unlink(const char *);
|
||||
int __cdecl write(int, const void *, unsigned int);
|
||||
int __cdecl rename(const char *, const char *);
|
||||
|
||||
#ifdef DeleteFile
|
||||
#undef DeleteFile
|
||||
#endif
|
||||
#define DeleteFile(a) unlink(a)
|
||||
|
||||
int chdir( const char *dirname );
|
||||
char *getcwd( char *buffer, int maxlen );
|
||||
|
||||
/* __stdlib.h__ */
|
||||
#define abort() (void)TerminateProcess(GetCurrentProcess(), 0)
|
||||
|
||||
/* sys/stat.h */
|
||||
#define S_IWRITE GENERIC_WRITE
|
||||
#define S_IREAD GENERIC_READ
|
||||
|
||||
|
||||
/* CE 2.xx is missing even more stuff */
|
||||
#ifdef WIN_CE_2xx
|
||||
#define ZeroMemory(p, s) memset((p), 0, (s))
|
||||
|
||||
int __cdecl isupper(int c);
|
||||
int __cdecl isdigit(int c);
|
||||
int __cdecl isspace(int c);
|
||||
int __cdecl isprint(int c);
|
||||
|
||||
char* __cdecl _strdup(const char* s);
|
||||
char* __cdecl strrchr( const char *string, int c );
|
||||
int __cdecl _stricmp(const char* a, const char* b);
|
||||
#endif
|
||||
|
||||
/* ARM - the processor; avoids conflict with ARM in hack.h */
|
||||
# ifdef ARM
|
||||
# undef ARM
|
||||
# endif
|
||||
|
||||
#endif /* WCECONF_H */
|
||||
@@ -104,8 +104,10 @@ static int lockptr;
|
||||
#define Delay(a) msleep(a)
|
||||
# endif
|
||||
#define Close close
|
||||
#ifndef WIN_CE
|
||||
#define DeleteFile unlink
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USER_SOUNDS
|
||||
extern char *sounddir;
|
||||
|
||||
107
sys/wince/Install.ce
Normal file
107
sys/wince/Install.ce
Normal file
@@ -0,0 +1,107 @@
|
||||
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
|
||||
========================================================================
|
||||
Last revision: $DATE$
|
||||
|
||||
Credit for the porting of NetHack to Windows CE goes to Alex Kompel who
|
||||
initially developed and contributed the port.
|
||||
|
||||
In order to build NetHack for Windows CE, you need *both* of the following:
|
||||
|
||||
o A copy of Microsoft Visual C V6.0 SP3 or later. Things may work with
|
||||
an earlier version of the compiler, but the current code has not been
|
||||
tested with an earlier version.
|
||||
o Embedded Visual C++ 3.0 or later
|
||||
|
||||
|
||||
FIRST STEP:
|
||||
|
||||
The first step in building NetHack for Windows CE is to execute
|
||||
sys/wince/cesetup.bat.
|
||||
|
||||
From the command prompt:
|
||||
cd sys\wince
|
||||
cesetup
|
||||
|
||||
From a Windows explorer window:
|
||||
double-click on cesetup.bat
|
||||
|
||||
A "wince" directory will be created off the top of the NetHack source
|
||||
tree, and a Microsoft embedded C workspace file will be placed in the
|
||||
top of the NetHack source tree. The "wince" directory will also have
|
||||
the subdirectories wince\ceinc and wince\ceince\sys.
|
||||
|
||||
------------
|
||||
| BUILDING |
|
||||
------------
|
||||
|
||||
Boostrapping the build process on Windows NT/2000/XP
|
||||
|
||||
1. With the Visual C++ 6.0 tools in your path,
|
||||
Run "nmake /f bootstrp.mak" from the wince folder.
|
||||
|
||||
Compiling
|
||||
|
||||
2. Start the Embedded Visual C IDE. In the Embeddd Visual C IDE
|
||||
Menus, choose:
|
||||
File | Open Workspace
|
||||
|
||||
3. Set up for the build.
|
||||
|
||||
o In the Visual C "Open Workspace" dialog box, navigate to the top
|
||||
of your NetHack source directory tree.
|
||||
|
||||
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
|
||||
|
||||
o On the Embedded Visual C menus, choose:
|
||||
Project | Set Active Project | winhack
|
||||
|
||||
o On the Visual C menus again, choose either:
|
||||
Build | Set Active Configuration | Release (for your handheld platform)
|
||||
or
|
||||
Build | Set Active Configuration | Debug (for your handheld platform)
|
||||
|
||||
Building
|
||||
|
||||
4. Start your build.
|
||||
|
||||
o On the Embedded Visual C menus once again, choose:
|
||||
Build | Build winhack
|
||||
This starts the build. It is likely that the IDE message window
|
||||
where you are doing the compiling will be occupied for a while.
|
||||
Notes:
|
||||
|
||||
o You may get a bunch of warnings regarding missing include files in the
|
||||
beginning of the build process - ignore them. For some reason the tool
|
||||
that produces these messages ignores preprocessor directives. The actual
|
||||
build will go just fine.
|
||||
o Sometimes the compiler chokes on do_wear.c Ignore that - let the build
|
||||
finish. Then run it again - it will compile just fine. (Seems to be some
|
||||
sort of bug in EVC++)
|
||||
|
||||
Transfer
|
||||
|
||||
5. Transfer the files and executables to your handheld by extracting the
|
||||
files into some folder on the CE device - that should do it.
|
||||
|
||||
|
||||
PROBLEMS
|
||||
|
||||
If you encounter a bug and wish to report it, please send e-mail to:
|
||||
nethack-bugs@nethack.org
|
||||
|
||||
If you have any comments or suggestions, feel free to drop us a line c/o:
|
||||
DevTeam@nethack.org
|
||||
|
||||
You may wish to vist the NetHack Development Team's website occasionally
|
||||
to check for updates or known bugs. The website can be found at:
|
||||
http://www.nethack.org/
|
||||
|
||||
Happy NetHacking!
|
||||
16
sys/wince/assert.h
Normal file
16
sys/wince/assert.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/***
|
||||
*assert.h - define the assert macro
|
||||
*
|
||||
****/
|
||||
|
||||
#undef assert
|
||||
|
||||
#ifdef NDEBUG
|
||||
|
||||
#define assert(exp) ((void)0)
|
||||
|
||||
#else
|
||||
|
||||
#define assert(exp) (void)( (exp) || (panic("%s at %s line %ld", #exp, __FILE__,__LINE__), 1) )
|
||||
|
||||
#endif /* NDEBUG */
|
||||
877
sys/wince/bootstrp.mak
Normal file
877
sys/wince/bootstrp.mak
Normal file
@@ -0,0 +1,877 @@
|
||||
# SCCS Id: @(#)bootstrp.mak 3.4 2002/03/24
|
||||
# Copyright (c) Michael Allison
|
||||
#
|
||||
# NetHack Windows CE bootstrap file for MS Visual C++ V6.x and
|
||||
# above and MS NMAKE
|
||||
#
|
||||
# This will:
|
||||
# - build makedefs
|
||||
# -
|
||||
#==============================================================================
|
||||
# Do not delete the following 3 lines.
|
||||
#
|
||||
TARGETOS=BOTH
|
||||
APPVER=4.0
|
||||
!include <win32.mak>
|
||||
|
||||
#
|
||||
# Source directories. Makedefs hardcodes these, don't change them.
|
||||
#
|
||||
|
||||
INCL = ..\include # NetHack include files
|
||||
DAT = ..\dat # NetHack data files
|
||||
DOC = ..\doc # NetHack documentation files
|
||||
UTIL = ..\util # Utility source
|
||||
SRC = ..\src # Main source
|
||||
SSYS = ..\sys\share # Shared system files
|
||||
NTSYS = ..\sys\winnt # NT Win32 specific files
|
||||
TTY = ..\win\tty # window port files (tty)
|
||||
WIN32 = ..\win\win32 # window port files (WINCE)
|
||||
WSHR = ..\win\share # Tile support files
|
||||
SWINCE= ..\wince # wince files
|
||||
WINCE = ..\wince # wince build area
|
||||
OBJ = $(WINCE)\ceobj
|
||||
DLB = $(DAT)\nhdat
|
||||
|
||||
#==========================================
|
||||
# Setting up the compiler and linker
|
||||
# macros. All builds include the base ones.
|
||||
#==========================================
|
||||
|
||||
CFLAGSBASE = -c $(cflags) $(cvarsmt) -I$(INCL) -nologo $(cdebug) $(WINPINC) -DDLB
|
||||
LFLAGSBASEC = $(linkdebug) /NODEFAULTLIB /INCREMENTAL:NO /RELEASE /NOLOGO -subsystem:console,4.0 $(conlibsmt)
|
||||
LFLAGSBASEG = $(linkdebug) $(guiflags) $(guilibsmt) comctl32.lib
|
||||
|
||||
#==========================================
|
||||
# Util builds
|
||||
#==========================================
|
||||
|
||||
CFLAGSU = $(CFLAGSBASE) $(WINPFLAG)
|
||||
LFLAGSU = $(LFLAGSBASEC)
|
||||
|
||||
LEVCFLAGS= -c -nologo -DWINVER=0x0400 -DWIN32 -D_WIN32 \
|
||||
-D_MT -MT -I..\include -nologo -Z7 -Od -DDLB
|
||||
|
||||
|
||||
#==========================================
|
||||
#================ RULES ==================
|
||||
#==========================================
|
||||
|
||||
.SUFFIXES: .exe .o .til .uu .c .y .l
|
||||
|
||||
#==========================================
|
||||
# Rules for files in src
|
||||
#==========================================
|
||||
|
||||
#.c{$(OBJ)}.o:
|
||||
# $(cc) $(CFLAGSU) -Fo$@ $<
|
||||
|
||||
{$(SRC)}.c{$(OBJ)}.o:
|
||||
$(CC) $(CFLAGSU) -Fo$@ $<
|
||||
|
||||
#==========================================
|
||||
# Rules for files in sys\share
|
||||
#==========================================
|
||||
|
||||
{$(SSYS)}.c{$(OBJ)}.o:
|
||||
$(CC) $(CFLAGSU) -Fo$@ $<
|
||||
|
||||
#==========================================
|
||||
# Rules for files in sys\winnt
|
||||
#==========================================
|
||||
|
||||
{$(NTSYS)}.c{$(OBJ)}.o:
|
||||
$(CC) $(CFLAGSU) -Fo$@ $<
|
||||
|
||||
{$(NTSYS)}.h{$(INCL)}.h:
|
||||
copy $< $@
|
||||
|
||||
#==========================================
|
||||
# Rules for files in util
|
||||
#==========================================
|
||||
|
||||
{$(UTIL)}.c{$(OBJ)}.o:
|
||||
$(CC) $(CFLAGSU) -Fo$@ $<
|
||||
|
||||
#==========================================
|
||||
# Rules for files in win\share
|
||||
#==========================================
|
||||
|
||||
{$(WSHR)}.c{$(OBJ)}.o:
|
||||
$(CC) $(CFLAGSU) -Fo$@ $<
|
||||
|
||||
{$(WSHR)}.h{$(INCL)}.h:
|
||||
copy $< $@
|
||||
|
||||
#{$(WSHR)}.txt{$(DAT)}.txt:
|
||||
# copy $< $@
|
||||
|
||||
#==========================================
|
||||
# Rules for files in win\tty
|
||||
#==========================================
|
||||
|
||||
{$(TTY)}.c{$(OBJ)}.o:
|
||||
$(CC) $(CFLAGSU) -Fo$@ $<
|
||||
|
||||
|
||||
#==========================================
|
||||
# Rules for files in win\win32
|
||||
#==========================================
|
||||
|
||||
{$(WIN32)}.c{$(OBJ)}.o:
|
||||
$(cc) $(CFLAGSU) -Fo$@ $<
|
||||
|
||||
#==========================================
|
||||
# Rules for files in sys\wince
|
||||
#==========================================
|
||||
|
||||
{$(SWINCE)}.c{$(OBJ)}.o:
|
||||
$(cc) $(CFLAGSU) -Fo$@ $<
|
||||
|
||||
#==========================================
|
||||
#================ MACROS ==================
|
||||
#==========================================
|
||||
|
||||
#
|
||||
# Shorten up the location for some files
|
||||
#
|
||||
|
||||
O = $(OBJ)^\
|
||||
|
||||
U = $(UTIL)^\
|
||||
|
||||
#
|
||||
# Utility Objects.
|
||||
#
|
||||
|
||||
MAKESRC = $(U)makedefs.c
|
||||
|
||||
SPLEVSRC = $(U)lev_yacc.c $(U)lev_$(LEX).c $(U)lev_main.c $(U)panic.c
|
||||
|
||||
DGNCOMPSRC = $(U)dgn_yacc.c $(U)dgn_$(LEX).c $(U)dgn_main.c
|
||||
|
||||
MAKEOBJS = $(O)makedefs.o $(O)monst.o $(O)objects.o
|
||||
|
||||
SPLEVOBJS = $(O)lev_yacc.o $(O)lev_$(LEX).o $(O)lev_main.o \
|
||||
$(O)alloc.o $(O)decl.o $(O)drawing.o \
|
||||
$(O)monst.o $(O)objects.o $(O)panic.o
|
||||
|
||||
DGNCOMPOBJS = $(O)dgn_yacc.o $(O)dgn_$(LEX).o $(O)dgn_main.o \
|
||||
$(O)alloc.o $(O)panic.o
|
||||
|
||||
TILEFILES = $(WSHR)\monsters.txt $(WSHR)\objects.txt $(WSHR)\other.txt
|
||||
|
||||
#
|
||||
# These are not invoked during a normal game build in 3.4.0
|
||||
#
|
||||
TEXT_IO = $(O)tiletext.o $(O)tiletxt.o $(O)drawing.o \
|
||||
$(O)decl.o $(O)monst.o $(O)objects.o
|
||||
|
||||
TEXT_IO32 = $(O)tilete32.o $(O)tiletx32.o $(O)drawing.o \
|
||||
$(O)decl.o $(O)monst.o $(O)objects.o
|
||||
|
||||
GIFREADERS = $(O)gifread.o $(O)alloc.o $(O)panic.o
|
||||
GIFREADERS32 = $(O)gifrd32.o $(O)alloc.o $(O)panic.o
|
||||
|
||||
PPMWRITERS = $(O)ppmwrite.o $(O)alloc.o $(O)panic.o
|
||||
|
||||
DLBOBJ = $(O)dlb.o
|
||||
|
||||
#==========================================
|
||||
# Header file macros
|
||||
#==========================================
|
||||
|
||||
CONFIG_H = $(INCL)\config.h $(INCL)\config1.h $(INCL)\tradstdc.h \
|
||||
$(INCL)\global.h $(INCL)\coord.h $(INCL)\vmsconf.h \
|
||||
$(INCL)\system.h $(INCL)\unixconf.h $(INCL)\os2conf.h \
|
||||
$(INCL)\micro.h $(INCL)\pcconf.h $(INCL)\tosconf.h \
|
||||
$(INCL)\amiconf.h $(INCL)\macconf.h $(INCL)\beconf.h \
|
||||
$(INCL)\ntconf.h $(INCL)\nhlan.h $(INCL)\wceconf.h
|
||||
|
||||
HACK_H = $(INCL)\hack.h $(CONFIG_H) $(INCL)\align.h \
|
||||
$(INCL)\dungeon.h $(INCL)\monsym.h $(INCL)\mkroom.h \
|
||||
$(INCL)\objclass.h $(INCL)\youprop.h $(INCL)\prop.h \
|
||||
$(INCL)\permonst.h $(INCL)\monattk.h \
|
||||
$(INCL)\monflag.h $(INCL)\mondata.h $(INCL)\pm.h \
|
||||
$(INCL)\wintype.h $(INCL)\decl.h $(INCL)\quest.h \
|
||||
$(INCL)\spell.h $(INCL)\color.h $(INCL)\obj.h \
|
||||
$(INCL)\you.h $(INCL)\attrib.h $(INCL)\monst.h \
|
||||
$(INCL)\skills.h $(INCL)\onames.h $(INCL)\timeout.h \
|
||||
$(INCL)\trap.h $(INCL)\flag.h $(INCL)\rm.h \
|
||||
$(INCL)\vision.h $(INCL)\display.h $(INCL)\engrave.h \
|
||||
$(INCL)\rect.h $(INCL)\region.h $(INCL)\winprocs.h \
|
||||
$(INCL)\wintty.h $(INCL)\trampoli.h
|
||||
|
||||
LEV_H = $(INCL)\lev.h
|
||||
DGN_FILE_H = $(INCL)\dgn_file.h
|
||||
LEV_COMP_H = $(INCL)\lev_comp.h
|
||||
SP_LEV_H = $(INCL)\sp_lev.h
|
||||
TILE_H = ..\win\share\tile.h
|
||||
|
||||
#==========================================
|
||||
# Miscellaneous
|
||||
#==========================================
|
||||
|
||||
DATABASE = $(DAT)\data.base
|
||||
|
||||
#==========================================
|
||||
#=============== TARGETS ==================
|
||||
#==========================================
|
||||
|
||||
#
|
||||
# The default make target (so just typing 'nmake' is useful).
|
||||
#
|
||||
default : all
|
||||
|
||||
#
|
||||
# Everything
|
||||
#
|
||||
|
||||
all : $(INCL)\date.h $(INCL)\onames.h $(INCL)\pm.h \
|
||||
$(SRC)\monstr.c $(SRC)\vis_tab.c $(U)lev_comp.exe $(INCL)\vis_tab.h \
|
||||
$(U)dgn_comp.exe $(U)uudecode.exe \
|
||||
$(DAT)\data $(DAT)\rumors $(DAT)\dungeon \
|
||||
$(DAT)\oracles $(DAT)\quest.dat $(O)sp_lev.tag $(DLB) $(SRC)\tile.c \
|
||||
$(SWINCE)\nethack.ico $(SWINCE)\tiles.bmp $(SWINCE)\mnsel.bmp \
|
||||
$(SWINCE)\mnunsel.bmp $(SWINCE)\petmark.bmp $(SWINCE)\mnselcnt.bmp \
|
||||
$(SWINCE)\keypad.bmp
|
||||
@echo Done!
|
||||
|
||||
$(O)sp_lev.tag: $(DAT)\bigroom.des $(DAT)\castle.des \
|
||||
$(DAT)\endgame.des $(DAT)\gehennom.des $(DAT)\knox.des \
|
||||
$(DAT)\medusa.des $(DAT)\oracle.des $(DAT)\tower.des \
|
||||
$(DAT)\yendor.des $(DAT)\arch.des $(DAT)\barb.des \
|
||||
$(DAT)\caveman.des $(DAT)\healer.des $(DAT)\knight.des \
|
||||
$(DAT)\monk.des $(DAT)\priest.des $(DAT)\ranger.des \
|
||||
$(DAT)\rogue.des $(DAT)\samurai.des $(DAT)\sokoban.des \
|
||||
$(DAT)\tourist.des $(DAT)\valkyrie.des $(DAT)\wizard.des
|
||||
cd $(DAT)
|
||||
$(U)lev_comp bigroom.des
|
||||
$(U)lev_comp castle.des
|
||||
$(U)lev_comp endgame.des
|
||||
$(U)lev_comp gehennom.des
|
||||
$(U)lev_comp knox.des
|
||||
$(U)lev_comp mines.des
|
||||
$(U)lev_comp medusa.des
|
||||
$(U)lev_comp oracle.des
|
||||
$(U)lev_comp sokoban.des
|
||||
$(U)lev_comp tower.des
|
||||
$(U)lev_comp yendor.des
|
||||
$(U)lev_comp arch.des
|
||||
$(U)lev_comp barb.des
|
||||
$(U)lev_comp caveman.des
|
||||
$(U)lev_comp healer.des
|
||||
$(U)lev_comp knight.des
|
||||
$(U)lev_comp monk.des
|
||||
$(U)lev_comp priest.des
|
||||
$(U)lev_comp ranger.des
|
||||
$(U)lev_comp rogue.des
|
||||
$(U)lev_comp samurai.des
|
||||
$(U)lev_comp tourist.des
|
||||
$(U)lev_comp valkyrie.des
|
||||
$(U)lev_comp wizard.des
|
||||
cd $(WINCE)
|
||||
echo sp_levs done > $(O)sp_lev.tag
|
||||
|
||||
#$(NHRES): $(TILEBMP16) $(WINCE)\winhack.rc $(WINCE)\mnsel.bmp \
|
||||
# $(WINCE)\mnselcnt.bmp $(WINCE)\mnunsel.bmp \
|
||||
# $(WINCE)\petmark.bmp $(WINCE)\NetHack.ico $(WINCE)\rip.bmp \
|
||||
# $(WINCE)\splash.bmp
|
||||
# $(rc) -r -fo$@ -i$(WINCE) -dNDEBUG $(WINCE)\winhack.rc
|
||||
|
||||
#
|
||||
# Utility Targets.
|
||||
#
|
||||
|
||||
#==========================================
|
||||
# Makedefs Stuff
|
||||
#==========================================
|
||||
|
||||
$(U)makedefs.exe: $(MAKEOBJS)
|
||||
$(link) $(LFLAGSU) -out:$@ $(MAKEOBJS)
|
||||
|
||||
$(O)makedefs.o: $(CONFIG_H) $(INCL)\monattk.h $(INCL)\monflag.h $(INCL)\objclass.h \
|
||||
$(INCL)\monsym.h $(INCL)\qtext.h $(INCL)\patchlevel.h \
|
||||
$(U)makedefs.c
|
||||
if not exist $(OBJ)\*.* echo creating directory $(OBJ)
|
||||
if not exist $(OBJ)\*.* mkdir $(OBJ)
|
||||
$(CC) $(CFLAGSU) -Fo$@ $(U)makedefs.c
|
||||
|
||||
#
|
||||
# date.h should be remade every time any of the source or include
|
||||
# files is modified.
|
||||
#
|
||||
|
||||
$(INCL)\date.h $(OPTIONS_FILE) : $(U)makedefs.exe
|
||||
$(U)makedefs -v
|
||||
|
||||
$(INCL)\onames.h : $(U)makedefs.exe
|
||||
$(U)makedefs -o
|
||||
|
||||
$(INCL)\pm.h : $(U)makedefs.exe
|
||||
$(U)makedefs -p
|
||||
|
||||
#$(INCL)\trap.h : $(U)makedefs.exe
|
||||
# $(U)makedefs -t
|
||||
|
||||
$(SRC)\monstr.c: $(U)makedefs.exe
|
||||
$(U)makedefs -m
|
||||
|
||||
$(INCL)\vis_tab.h: $(U)makedefs.exe
|
||||
$(U)makedefs -z
|
||||
|
||||
$(SRC)\vis_tab.c: $(U)makedefs.exe
|
||||
$(U)makedefs -z
|
||||
|
||||
#==========================================
|
||||
# uudecode utility and uuencoded targets
|
||||
#==========================================
|
||||
|
||||
$(U)uudecode.exe: $(O)uudecode.o
|
||||
$(link) $(LFLAGSU) -out:$@ $(O)uudecode.o
|
||||
|
||||
$(O)uudecode.o: $(SSYS)\uudecode.c
|
||||
|
||||
$(SWINCE)\NetHack.ico : $(U)uudecode.exe $(SWINCE)\nhico.uu
|
||||
chdir $(SWINCE)
|
||||
..\util\uudecode.exe nhico.uu
|
||||
chdir $(WINCE)
|
||||
|
||||
$(SWINCE)\mnsel.bmp: $(U)uudecode.exe $(SWINCE)\mnsel.uu
|
||||
chdir $(SWINCE)
|
||||
..\util\uudecode.exe mnsel.uu
|
||||
chdir $(WINCE)
|
||||
|
||||
$(SWINCE)\mnselcnt.bmp: $(U)uudecode.exe $(SWINCE)\mnselcnt.uu
|
||||
chdir $(SWINCE)
|
||||
..\util\uudecode.exe mnselcnt.uu
|
||||
chdir $(WINCE)
|
||||
|
||||
$(SWINCE)\mnunsel.bmp: $(U)uudecode.exe $(SWINCE)\mnunsel.uu
|
||||
chdir $(SWINCE)
|
||||
..\util\uudecode.exe mnunsel.uu
|
||||
chdir $(WINCE)
|
||||
|
||||
$(SWINCE)\petmark.bmp: $(U)uudecode.exe $(SWINCE)\petmark.uu
|
||||
chdir $(SWINCE)
|
||||
..\util\uudecode.exe petmark.uu
|
||||
chdir $(WINCE)
|
||||
|
||||
$(SWINCE)\rip.bmp: $(U)uudecode.exe $(SWINCE)\rip.uu
|
||||
chdir $(SWINCE)
|
||||
..\util\uudecode.exe rip.uu
|
||||
chdir $(WINCE)
|
||||
|
||||
$(SWINCE)\splash.bmp: $(U)uudecode.exe $(SWINCE)\splash.uu
|
||||
chdir $(SWINCE)
|
||||
..\util\uudecode.exe splash.uu
|
||||
chdir $(WINCE)
|
||||
|
||||
$(SWINCE)\keypad.bmp: $(U)uudecode.exe $(SWINCE)\keypad.uu
|
||||
chdir $(SWINCE)
|
||||
..\util\uudecode.exe keypad.uu
|
||||
chdir $(WINCE)
|
||||
|
||||
#==========================================
|
||||
# Level Compiler Stuff
|
||||
#==========================================
|
||||
|
||||
$(U)lev_comp.exe: $(SPLEVOBJS)
|
||||
echo Linking $@...
|
||||
$(link) $(LFLAGSU) -out:$@ @<<$(@B).lnk
|
||||
$(SPLEVOBJS:^ =^
|
||||
)
|
||||
<<
|
||||
|
||||
$(O)lev_yacc.o: $(HACK_H) $(SP_LEV_H) $(INCL)\lev_comp.h $(U)lev_yacc.c
|
||||
$(CC) $(LEVCFLAGS) -W0 -Fo$@ $(U)lev_yacc.c
|
||||
|
||||
$(O)lev_$(LEX).o: $(HACK_H) $(INCL)\lev_comp.h $(SP_LEV_H) \
|
||||
$(U)lev_$(LEX).c
|
||||
$(CC) $(LEVCFLAGS) -W0 -Fo$@ $(U)lev_$(LEX).c
|
||||
|
||||
$(O)lev_main.o: $(U)lev_main.c $(HACK_H) $(SP_LEV_H)
|
||||
$(CC) $(LEVCFLAGS) -W0 -Fo$@ $(U)lev_main.c
|
||||
|
||||
|
||||
$(U)lev_yacc.c $(INCL)\lev_comp.h : $(U)lev_comp.y
|
||||
@echo We will copy the prebuilt lev_yacc.c and
|
||||
@echo lev_comp.h from $(SSYS) into $(UTIL) and use them.
|
||||
@copy $(SSYS)\lev_yacc.c $(U)lev_yacc.c >nul
|
||||
@copy $(SSYS)\lev_comp.h $(INCL)\lev_comp.h >nul
|
||||
@echo /**/ >>$(U)lev_yacc.c
|
||||
@echo /**/ >>$(INCL)\lev_comp.h
|
||||
|
||||
$(U)lev_$(LEX).c: $(U)lev_comp.l
|
||||
@echo We will copy the prebuilt lev_lex.c
|
||||
@echo from $(SSYS) into $(UTIL) and use it.
|
||||
@copy $(SSYS)\lev_lex.c $@ >nul
|
||||
@echo /**/ >>$@
|
||||
|
||||
#==========================================
|
||||
# Dungeon Compiler Stuff
|
||||
#==========================================
|
||||
|
||||
$(U)dgn_comp.exe: $(DGNCOMPOBJS)
|
||||
@echo Linking $@...
|
||||
$(link) $(LFLAGSU) -out:$@ @<<$(@B).lnk
|
||||
$(DGNCOMPOBJS:^ =^
|
||||
)
|
||||
<<
|
||||
|
||||
$(O)dgn_yacc.o: $(HACK_H) $(DGN_FILE_H) $(INCL)\dgn_comp.h $(U)dgn_yacc.c
|
||||
$(CC) $(LEVCFLAGS) -W0 -Fo$@ $(U)dgn_yacc.c
|
||||
|
||||
$(O)dgn_$(LEX).o: $(HACK_H) $(DGN_FILE_H) $(INCL)\dgn_comp.h \
|
||||
$(U)dgn_$(LEX).c
|
||||
$(CC) $(LEVCFLAGS) -W0 -Fo$@ $(U)dgn_$(LEX).c
|
||||
|
||||
$(O)dgn_main.o: $(HACK_H) $(U)dgn_main.c
|
||||
$(CC) $(LEVCFLAGS) -W0 -Fo$@ $(U)dgn_main.c
|
||||
|
||||
$(U)dgn_yacc.c $(INCL)\dgn_comp.h : $(U)dgn_comp.y
|
||||
@echo We will copy the prebuilt $(U)dgn_yacc.c and
|
||||
@echo dgn_comp.h from $(SSYS) into $(UTIL) and use them.
|
||||
@copy $(SSYS)\dgn_yacc.c $(U)dgn_yacc.c >nul
|
||||
@copy $(SSYS)\dgn_comp.h $(INCL)\dgn_comp.h >nul
|
||||
@echo /**/ >>$(U)dgn_yacc.c
|
||||
@echo /**/ >>$(INCL)\dgn_comp.h
|
||||
|
||||
$(U)dgn_$(LEX).c: $(U)dgn_comp.l
|
||||
@echo We will copy the prebuilt dgn_lex.c
|
||||
@echo from $(SSYS) into $(UTIL) and use it.
|
||||
@copy $(SSYS)\dgn_lex.c $@ >nul
|
||||
@echo /**/ >>$@
|
||||
|
||||
#==========================================
|
||||
# Create directory for holding object files
|
||||
#==========================================
|
||||
|
||||
$(O)obj.tag:
|
||||
if not exist $(OBJ)\*.* echo creating directory $(OBJ)
|
||||
if not exist $(OBJ)\*.* mkdir $(OBJ)
|
||||
echo directory created >$@
|
||||
|
||||
#==========================================
|
||||
# Notify of any CL environment variables
|
||||
# in effect since they change the compiler
|
||||
# options.
|
||||
#==========================================
|
||||
|
||||
envchk:
|
||||
! IF "$(CL)"!=""
|
||||
@echo Warning, the CL Environment variable is defined:
|
||||
@echo CL=$(CL)
|
||||
! ENDIF
|
||||
@echo ----
|
||||
@echo NOTE: This build will include tile support.
|
||||
@echo ----
|
||||
|
||||
#==========================================
|
||||
#=========== SECONDARY TARGETS ============
|
||||
#==========================================
|
||||
|
||||
#===========================================
|
||||
# Header files NOT distributed in ..\include
|
||||
#===========================================
|
||||
|
||||
$(INCL)\win32api.h: $(NTSYS)\win32api.h
|
||||
copy $(NTSYS)\win32api.h $@
|
||||
|
||||
|
||||
#==========================================
|
||||
# DLB utility and nhdat file creation
|
||||
#==========================================
|
||||
|
||||
$(U)dlb_main.exe: $(DLBOBJ) $(O)dlb.o
|
||||
$(link) $(LFLAGSU) -out:$@ @<<$(@B).lnk
|
||||
$(O)dlb_main.o
|
||||
$(O)dlb.o
|
||||
$(O)alloc.o
|
||||
$(O)panic.o
|
||||
<<
|
||||
|
||||
$(O)dlb.o: $(O)dlb_main.o $(O)alloc.o $(O)panic.o $(INCL)\dlb.h
|
||||
$(CC) $(CFLAGSU) /Fo$@ $(SRC)\dlb.c
|
||||
|
||||
$(O)dlb_main.o: $(UTIL)\dlb_main.c $(INCL)\config.h $(INCL)\dlb.h
|
||||
$(CC) $(CFLAGSU) /Fo$@ $(UTIL)\dlb_main.c
|
||||
|
||||
#$(DAT)\porthelp: $(NTSYS)\porthelp
|
||||
# copy $(NTSYS)\porthelp $@ >nul
|
||||
|
||||
$(DAT)\nhdat: $(U)dlb_main.exe $(DAT)\data $(DAT)\oracles $(OPTIONS_FILE) \
|
||||
$(DAT)\quest.dat $(DAT)\rumors $(DAT)\help $(DAT)\hh $(DAT)\cmdhelp \
|
||||
$(DAT)\history $(DAT)\opthelp $(DAT)\wizhelp $(DAT)\dungeon \
|
||||
$(DAT)\license $(O)sp_lev.tag
|
||||
cd $(DAT)
|
||||
echo data >dlb.lst
|
||||
echo oracles >>dlb.lst
|
||||
if exist options echo options >>dlb.lst
|
||||
if exist ttyoptions echo ttyoptions >>dlb.lst
|
||||
if exist guioptions echo guioptions >>dlb.lst
|
||||
if exist porthelp echo porthelp >>dlb.lst
|
||||
echo quest.dat >>dlb.lst
|
||||
echo rumors >>dlb.lst
|
||||
echo help >>dlb.lst
|
||||
echo hh >>dlb.lst
|
||||
echo cmdhelp >>dlb.lst
|
||||
echo history >>dlb.lst
|
||||
echo opthelp >>dlb.lst
|
||||
echo wizhelp >>dlb.lst
|
||||
echo dungeon >>dlb.lst
|
||||
echo license >>dlb.lst
|
||||
for %%N in (*.lev) do echo %%N >>dlb.lst
|
||||
$(U)dlb_main cIf dlb.lst nhdat
|
||||
cd $(WINCE)
|
||||
|
||||
#==========================================
|
||||
# Tile Mapping
|
||||
#==========================================
|
||||
|
||||
$(SRC)\tile.c: $(U)tilemap.exe
|
||||
echo A new $@ has been created
|
||||
$(U)tilemap
|
||||
|
||||
$(U)tilemap.exe: $(O)tilemap.o
|
||||
$(link) $(LFLAGSU) -out:$@ $(O)tilemap.o
|
||||
|
||||
$(O)tilemap.o: $(WSHR)\tilemap.c $(HACK_H)
|
||||
$(CC) $(CFLAGSU) -Fo$@ $(WSHR)\tilemap.c
|
||||
|
||||
$(O)tiletx32.o: $(WSHR)\tilemap.c $(HACK_H)
|
||||
$(CC) $(CFLAGSU) /DTILETEXT /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tilemap.c
|
||||
|
||||
$(O)tiletxt.o: $(WSHR)\tilemap.c $(HACK_H)
|
||||
$(CC) $(CFLAGSU) /DTILETEXT -Fo$@ $(WSHR)\tilemap.c
|
||||
|
||||
$(O)gifread.o: $(WSHR)\gifread.c $(CONFIG_H) $(TILE_H)
|
||||
$(CC) $(CFLAGSU) -I$(WSHR) -Fo$@ $(WSHR)\gifread.c
|
||||
|
||||
$(O)gifrd32.o: $(WSHR)\gifread.c $(CONFIG_H) $(TILE_H)
|
||||
$(CC) $(CFLAGSU) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\gifread.c
|
||||
|
||||
$(O)ppmwrite.o: $(WSHR)\ppmwrite.c $(CONFIG_H) $(TILE_H)
|
||||
$(CC) $(CFLAGSU) -I$(WSHR) -Fo$@ $(WSHR)\ppmwrite.c
|
||||
|
||||
$(O)tiletext.o: $(WSHR)\tiletext.c $(CONFIG_H) $(TILE_H)
|
||||
$(CC) $(CFLAGSU) -I$(WSHR) -Fo$@ $(WSHR)\tiletext.c
|
||||
|
||||
$(O)tilete32.o: $(WSHR)\tiletext.c $(CONFIG_H) $(TILE_H)
|
||||
$(CC) $(CFLAGSU) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tiletext.c
|
||||
|
||||
$(SWINCE)\tiles.bmp: $(U)tile2bmp.exe $(TILEFILES)
|
||||
echo Creating 16x16 binary tile files (this may take some time)
|
||||
$(U)tile2bmp $@
|
||||
|
||||
#$(TILEBMP32): $(TILEUTIL32) $(TILEFILES32)
|
||||
# echo Creating 32x32 binary tile files (this may take some time)
|
||||
# $(U)til2bm32 $(TILEBMP32)
|
||||
|
||||
|
||||
$(U)tile2bmp.exe: $(O)tile2bmp.o $(TEXT_IO)
|
||||
@echo Linking $@...
|
||||
$(link) $(LFLAGSU) -out:$@ @<<$(@B).lnk
|
||||
$(O)tile2bmp.o
|
||||
$(TEXT_IO:^ =^
|
||||
)
|
||||
<<
|
||||
|
||||
$(U)til2bm32.exe: $(O)til2bm32.o $(TEXT_IO32)
|
||||
@echo Linking $@...
|
||||
$(link) $(LFLAGSU) -out:$@ @<<$(@B).lnk
|
||||
$(O)til2bm32.o
|
||||
$(TEXT_IO32:^ =^
|
||||
)
|
||||
<<
|
||||
|
||||
$(O)tile2bmp.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(INCL)\win32api.h
|
||||
$(CC) $(CFLAGSU) -I$(WSHR) /DPACKED_FILE /Fo$@ $(WSHR)\tile2bmp.c
|
||||
|
||||
$(O)til2bm32.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(INCL)\win32api.h
|
||||
$(CC) $(CFLAGSU) -I$(WSHR) /DPACKED_FILE /DTILE_X=32 /DTILE_Y=32 /Fo$@ $(WSHR)\tile2bmp.c
|
||||
|
||||
#===================================================================
|
||||
# OTHER DEPENDENCIES
|
||||
#===================================================================
|
||||
|
||||
#
|
||||
# dat dependencies
|
||||
#
|
||||
|
||||
$(DAT)\data: $(UTIL)\makedefs.exe
|
||||
$(U)makedefs -d
|
||||
|
||||
$(DAT)\rumors: $(UTIL)\makedefs.exe $(DAT)\rumors.tru $(DAT)\rumors.fal
|
||||
$(U)makedefs -r
|
||||
|
||||
$(DAT)\quest.dat: $(UTIL)\makedefs.exe $(DAT)\quest.txt
|
||||
$(U)makedefs -q
|
||||
|
||||
$(DAT)\oracles: $(UTIL)\makedefs.exe $(DAT)\oracles.txt
|
||||
$(U)makedefs -h
|
||||
|
||||
$(DAT)\dungeon: $(UTIL)\makedefs.exe $(DAT)\dungeon.def
|
||||
$(U)makedefs -e
|
||||
cd $(DAT)
|
||||
$(U)dgn_comp dungeon.pdf
|
||||
cd $(WINCE)
|
||||
|
||||
#
|
||||
# NT dependencies
|
||||
#
|
||||
#
|
||||
#$(O)nttty.o: $(HACK_H) $(TILE_H) $(INCL)\win32api.h $(NTSYS)\nttty.c
|
||||
# $(CC) $(CFLAGSU) -I$(WSHR) -Fo$@ $(NTSYS)\nttty.c
|
||||
#$(O)winnt.o: $(HACK_H) $(INCL)\win32api.h $(NTSYS)\winnt.c
|
||||
# $(CC) $(CFLAGSU) -Fo$@ $(NTSYS)\winnt.c
|
||||
#$(O)ntsound.o: $(HACK_H) $(NTSYS)\ntsound.c
|
||||
# $(CC) $(CFLAGSU) -Fo$@ $(NTSYS)\ntsound.c
|
||||
#$(O)mapimail.o: $(HACK_H) $(INCL)\nhlan.h $(NTSYS)\mapimail.c
|
||||
# $(CC) $(CFLAGSU) -DMAPI_VERBOSE -Fo$@ $(NTSYS)\mapimail.c
|
||||
|
||||
#
|
||||
# util dependencies
|
||||
#
|
||||
|
||||
$(O)panic.o: $(U)panic.c $(CONFIG_H)
|
||||
$(CC) $(CFLAGSU) -Fo$@ $(U)panic.c
|
||||
|
||||
#
|
||||
# The rest are stolen from sys/unix/Makefile.src,
|
||||
# with slashes changed to back-slashes
|
||||
# and -c (which is included in CFLAGSU) substituted
|
||||
# with -Fo$@ , but otherwise untouched. That
|
||||
# means that there is some irrelevant stuff
|
||||
# in here, but maintenance should be easier.
|
||||
#
|
||||
$(O)tos.o: ..\sys\atari\tos.c $(HACK_H) $(INCL)\tcap.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\sys\atari\tos.c
|
||||
$(O)pcmain.o: ..\sys\share\pcmain.c $(HACK_H) $(INCL)\dlb.h \
|
||||
$(INCL)\win32api.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\sys\share\pcmain.c
|
||||
$(O)pcsys.o: ..\sys\share\pcsys.c $(HACK_H)
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\sys\share\pcsys.c
|
||||
$(O)pctty.o: ..\sys\share\pctty.c $(HACK_H)
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\sys\share\pctty.c
|
||||
$(O)pcunix.o: ..\sys\share\pcunix.c $(HACK_H)
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\sys\share\pcunix.c
|
||||
$(O)random.o: ..\sys\share\random.c $(HACK_H)
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\sys\share\random.c
|
||||
$(O)ioctl.o: ..\sys\share\ioctl.c $(HACK_H) $(INCL)\tcap.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\sys\share\ioctl.c
|
||||
$(O)unixtty.o: ..\sys\share\unixtty.c $(HACK_H)
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\sys\share\unixtty.c
|
||||
$(O)unixmain.o: ..\sys\unix\unixmain.c $(HACK_H) $(INCL)\dlb.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\sys\unix\unixmain.c
|
||||
$(O)unixunix.o: ..\sys\unix\unixunix.c $(HACK_H)
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\sys\unix\unixunix.c
|
||||
$(O)bemain.o: ..\sys\be\bemain.c $(HACK_H) $(INCL)\dlb.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\sys\be\bemain.c
|
||||
$(O)getline.o: ..\win\tty\getline.c $(HACK_H) $(INCL)\func_tab.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\tty\getline.c
|
||||
$(O)termcap.o: ..\win\tty\termcap.c $(HACK_H) $(INCL)\tcap.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\tty\termcap.c
|
||||
$(O)topl.o: ..\win\tty\topl.c $(HACK_H) $(INCL)\tcap.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\tty\topl.c
|
||||
$(O)wintty.o: ..\win\tty\wintty.c $(HACK_H) $(INCL)\dlb.h \
|
||||
$(INCL)\patchlevel.h $(INCL)\tcap.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\tty\wintty.c
|
||||
$(O)Window.o: ..\win\X11\Window.c $(INCL)\xwindowp.h $(INCL)\xwindow.h \
|
||||
$(CONFIG_H)
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\X11\Window.c
|
||||
$(O)dialogs.o: ..\win\X11\dialogs.c $(CONFIG_H)
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\X11\dialogs.c
|
||||
$(O)winX.o: ..\win\X11\winX.c $(HACK_H) $(INCL)\winX.h $(INCL)\dlb.h \
|
||||
$(INCL)\patchlevel.h ..\win\X11\nh72icon \
|
||||
..\win\X11\nh56icon ..\win\X11\nh32icon
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\X11\winX.c
|
||||
$(O)winmap.o: ..\win\X11\winmap.c $(INCL)\xwindow.h $(HACK_H) $(INCL)\dlb.h \
|
||||
$(INCL)\winX.h $(INCL)\tile2x11.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\X11\winmap.c
|
||||
$(O)winmenu.o: ..\win\X11\winmenu.c $(HACK_H) $(INCL)\winX.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\X11\winmenu.c
|
||||
$(O)winmesg.o: ..\win\X11\winmesg.c $(INCL)\xwindow.h $(HACK_H) $(INCL)\winX.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\X11\winmesg.c
|
||||
$(O)winmisc.o: ..\win\X11\winmisc.c $(HACK_H) $(INCL)\func_tab.h \
|
||||
$(INCL)\winX.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\X11\winmisc.c
|
||||
$(O)winstat.o: ..\win\X11\winstat.c $(HACK_H) $(INCL)\winX.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\X11\winstat.c
|
||||
$(O)wintext.o: ..\win\X11\wintext.c $(HACK_H) $(INCL)\winX.h $(INCL)\xwindow.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\X11\wintext.c
|
||||
$(O)winval.o: ..\win\X11\winval.c $(HACK_H) $(INCL)\winX.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\X11\winval.c
|
||||
$(O)tile.o: $(SRC)\tile.c $(HACK_H)
|
||||
$(O)gnaskstr.o: ..\win\gnome\gnaskstr.c ..\win\gnome\gnaskstr.h \
|
||||
..\win\gnome\gnmain.h
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnaskstr.c
|
||||
$(O)gnbind.o: ..\win\gnome\gnbind.c ..\win\gnome\gnbind.h ..\win\gnome\gnmain.h \
|
||||
..\win\gnome\gnaskstr.h ..\win\gnome\gnyesno.h
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnbind.c
|
||||
$(O)gnglyph.o: ..\win\gnome\gnglyph.c ..\win\gnome\gnglyph.h
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnglyph.c
|
||||
$(O)gnmain.o: ..\win\gnome\gnmain.c ..\win\gnome\gnmain.h ..\win\gnome\gnsignal.h \
|
||||
..\win\gnome\gnbind.h ..\win\gnome\gnopts.h $(HACK_H) \
|
||||
$(INCL)\date.h
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnmain.c
|
||||
$(O)gnmap.o: ..\win\gnome\gnmap.c ..\win\gnome\gnmap.h ..\win\gnome\gnglyph.h \
|
||||
..\win\gnome\gnsignal.h $(HACK_H)
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnmap.c
|
||||
$(O)gnmenu.o: ..\win\gnome\gnmenu.c ..\win\gnome\gnmenu.h ..\win\gnome\gnmain.h \
|
||||
..\win\gnome\gnbind.h
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnmenu.c
|
||||
$(O)gnmesg.o: ..\win\gnome\gnmesg.c ..\win\gnome\gnmesg.h ..\win\gnome\gnsignal.h
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnmesg.c
|
||||
$(O)gnopts.o: ..\win\gnome\gnopts.c ..\win\gnome\gnopts.h ..\win\gnome\gnglyph.h \
|
||||
..\win\gnome\gnmain.h ..\win\gnome\gnmap.h $(HACK_H)
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnopts.c
|
||||
$(O)gnplayer.o: ..\win\gnome\gnplayer.c ..\win\gnome\gnplayer.h \
|
||||
..\win\gnome\gnmain.h $(HACK_H)
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnplayer.c
|
||||
$(O)gnsignal.o: ..\win\gnome\gnsignal.c ..\win\gnome\gnsignal.h \
|
||||
..\win\gnome\gnmain.h
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnsignal.c
|
||||
$(O)gnstatus.o: ..\win\gnome\gnstatus.c ..\win\gnome\gnstatus.h \
|
||||
..\win\gnome\gnsignal.h ..\win\gnome\gn_xpms.h \
|
||||
..\win\gnome\gnomeprv.h
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnstatus.c
|
||||
$(O)gntext.o: ..\win\gnome\gntext.c ..\win\gnome\gntext.h ..\win\gnome\gnmain.h \
|
||||
..\win\gnome\gn_rip.h
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gntext.c
|
||||
$(O)gnyesno.o: ..\win\gnome\gnyesno.c ..\win\gnome\gnbind.h ..\win\gnome\gnyesno.h
|
||||
$(CC) $(CFLAGSU) $(GNOMEINC) -c ..\win\gnome\gnyesno.c
|
||||
$(O)wingem.o: ..\win\gem\wingem.c $(HACK_H) $(INCL)\func_tab.h $(INCL)\dlb.h \
|
||||
$(INCL)\patchlevel.h $(INCL)\wingem.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\gem\wingem.c
|
||||
$(O)wingem1.o: ..\win\gem\wingem1.c $(INCL)\gem_rsc.h $(INCL)\load_img.h \
|
||||
$(INCL)\wintype.h $(INCL)\wingem.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\gem\wingem1.c
|
||||
$(O)load_img.o: ..\win\gem\load_img.c $(INCL)\load_img.h
|
||||
$(CC) $(CFLAGSU) -Fo$@ ..\win\gem\load_img.c
|
||||
$(O)tile.o: $(SRC)\tile.c $(HACK_H)
|
||||
$(O)qt_win.o: ..\win\Qt\qt_win.cpp $(HACK_H) $(INCL)\func_tab.h \
|
||||
$(INCL)\dlb.h $(INCL)\patchlevel.h $(INCL)\qt_win.h \
|
||||
$(INCL)\qt_clust.h $(INCL)\qt_kde0.h \
|
||||
$(INCL)\qt_xpms.h qt_win.moc qt_kde0.moc
|
||||
$(CXX) $(CXXFLAGS) -c ..\win\Qt\qt_win.cpp
|
||||
$(O)qt_clust.o: ..\win\Qt\qt_clust.cpp $(INCL)\qt_clust.h
|
||||
$(CXX) $(CXXFLAGS) -c ..\win\Qt\qt_clust.cpp
|
||||
$(O)monstr.o: $(SRC)\monstr.c $(CONFIG_H)
|
||||
$(O)vis_tab.o: $(SRC)\vis_tab.c $(CONFIG_H) $(INCL)\vis_tab.h
|
||||
$(O)allmain.o: $(SRC)\allmain.c $(HACK_H)
|
||||
$(O)alloc.o: $(SRC)\alloc.c $(CONFIG_H)
|
||||
$(O)apply.o: $(SRC)\apply.c $(HACK_H) $(INCL)\edog.h
|
||||
$(O)artifact.o: $(SRC)\artifact.c $(HACK_H) $(INCL)\artifact.h $(INCL)\artilist.h
|
||||
$(O)attrib.o: $(SRC)\attrib.c $(HACK_H) $(INCL)\artifact.h
|
||||
$(O)ball.o: $(SRC)\ball.c $(HACK_H)
|
||||
$(O)bones.o: $(SRC)\bones.c $(HACK_H) $(INCL)\lev.h
|
||||
$(O)botl.o: $(SRC)\botl.c $(HACK_H)
|
||||
$(O)cmd.o: $(SRC)\cmd.c $(HACK_H) $(INCL)\func_tab.h
|
||||
$(O)dbridge.o: $(SRC)\dbridge.c $(HACK_H)
|
||||
$(O)decl.o: $(SRC)\decl.c $(HACK_H)
|
||||
$(O)detect.o: $(SRC)\detect.c $(HACK_H) $(INCL)\artifact.h
|
||||
$(O)dig.o: $(SRC)\dig.c $(HACK_H) $(INCL)\edog.h
|
||||
$(O)display.o: $(SRC)\display.c $(HACK_H)
|
||||
$(O)dlb.o: $(SRC)\dlb.c $(CONFIG_H) $(INCL)\dlb.h
|
||||
$(O)do.o: $(SRC)\do.c $(HACK_H) $(INCL)\lev.h
|
||||
$(O)do_name.o: $(SRC)\do_name.c $(HACK_H)
|
||||
$(O)do_wear.o: $(SRC)\do_wear.c $(HACK_H)
|
||||
$(O)dog.o: $(SRC)\dog.c $(HACK_H) $(INCL)\edog.h
|
||||
$(O)dogmove.o: $(SRC)\dogmove.c $(HACK_H) $(INCL)\mfndpos.h $(INCL)\edog.h
|
||||
$(O)dokick.o: $(SRC)\dokick.c $(HACK_H) $(INCL)\eshk.h
|
||||
$(O)dothrow.o: $(SRC)\dothrow.c $(HACK_H)
|
||||
$(O)drawing.o: $(SRC)\drawing.c $(HACK_H) $(INCL)\tcap.h
|
||||
$(O)dungeon.o: $(SRC)\dungeon.c $(HACK_H) $(INCL)\dgn_file.h $(INCL)\dlb.h
|
||||
$(O)eat.o: $(SRC)\eat.c $(HACK_H)
|
||||
$(O)end.o: $(SRC)\end.c $(HACK_H) $(INCL)\eshk.h $(INCL)\dlb.h
|
||||
$(O)engrave.o: $(SRC)\engrave.c $(HACK_H) $(INCL)\lev.h
|
||||
$(O)exper.o: $(SRC)\exper.c $(HACK_H)
|
||||
$(O)explode.o: $(SRC)\explode.c $(HACK_H)
|
||||
$(O)extralev.o: $(SRC)\extralev.c $(HACK_H)
|
||||
$(O)files.o: $(SRC)\files.c $(HACK_H) $(INCL)\dlb.h
|
||||
$(O)fountain.o: $(SRC)\fountain.c $(HACK_H)
|
||||
$(O)hack.o: $(SRC)\hack.c $(HACK_H)
|
||||
$(O)hacklib.o: $(SRC)\hacklib.c $(HACK_H)
|
||||
$(O)invent.o: $(SRC)\invent.c $(HACK_H) $(INCL)\artifact.h
|
||||
$(O)light.o: $(SRC)\light.c $(HACK_H) $(INCL)\lev.h
|
||||
$(O)lock.o: $(SRC)\lock.c $(HACK_H)
|
||||
$(O)mail.o: $(SRC)\mail.c $(HACK_H) $(INCL)\mail.h
|
||||
$(O)makemon.o: $(SRC)\makemon.c $(HACK_H) $(INCL)\epri.h $(INCL)\emin.h \
|
||||
$(INCL)\edog.h
|
||||
$(O)mapglyph.o: $(SRC)\mapglyph.c $(HACK_H)
|
||||
$(O)mcastu.o: $(SRC)\mcastu.c $(HACK_H)
|
||||
$(O)mhitm.o: $(SRC)\mhitm.c $(HACK_H) $(INCL)\artifact.h $(INCL)\edog.h
|
||||
$(O)mhitu.o: $(SRC)\mhitu.c $(HACK_H) $(INCL)\artifact.h $(INCL)\edog.h
|
||||
$(O)minion.o: $(SRC)\minion.c $(HACK_H) $(INCL)\emin.h $(INCL)\epri.h
|
||||
$(O)mklev.o: $(SRC)\mklev.c $(HACK_H)
|
||||
$(O)mkmap.o: $(SRC)\mkmap.c $(HACK_H) $(INCL)\sp_lev.h
|
||||
$(O)mkmaze.o: $(SRC)\mkmaze.c $(HACK_H) $(INCL)\sp_lev.h $(INCL)\lev.h
|
||||
$(O)mkobj.o: $(SRC)\mkobj.c $(HACK_H) $(INCL)\artifact.h
|
||||
$(O)mkroom.o: $(SRC)\mkroom.c $(HACK_H)
|
||||
$(O)mon.o: $(SRC)\mon.c $(HACK_H) $(INCL)\mfndpos.h $(INCL)\edog.h
|
||||
$(O)mondata.o: $(SRC)\mondata.c $(HACK_H) $(INCL)\eshk.h $(INCL)\epri.h
|
||||
$(O)monmove.o: $(SRC)\monmove.c $(HACK_H) $(INCL)\mfndpos.h $(INCL)\artifact.h
|
||||
$(O)monst.o: $(SRC)\monst.c $(CONFIG_H) $(INCL)\permonst.h $(INCL)\align.h \
|
||||
$(INCL)\monattk.h $(INCL)\monflag.h $(INCL)\monsym.h \
|
||||
$(INCL)\dungeon.h $(INCL)\eshk.h $(INCL)\vault.h \
|
||||
$(INCL)\epri.h $(INCL)\color.h
|
||||
$(O)mplayer.o: $(SRC)\mplayer.c $(HACK_H)
|
||||
$(O)mthrowu.o: $(SRC)\mthrowu.c $(HACK_H)
|
||||
$(O)muse.o: $(SRC)\muse.c $(HACK_H) $(INCL)\edog.h
|
||||
$(O)music.o: $(SRC)\music.c $(HACK_H) #interp.c
|
||||
$(O)o_init.o: $(SRC)\o_init.c $(HACK_H) $(INCL)\lev.h
|
||||
$(O)objects.o: $(SRC)\objects.c $(CONFIG_H) $(INCL)\obj.h $(INCL)\objclass.h \
|
||||
$(INCL)\prop.h $(INCL)\skills.h $(INCL)\color.h
|
||||
$(O)objnam.o: $(SRC)\objnam.c $(HACK_H)
|
||||
$(O)options.o: $(SRC)\options.c $(CONFIG_H) $(INCL)\objclass.h $(INCL)\flag.h \
|
||||
$(HACK_H) $(INCL)\tcap.h
|
||||
$(O)pager.o: $(SRC)\pager.c $(HACK_H) $(INCL)\dlb.h
|
||||
$(O)pickup.o: $(SRC)\pickup.c $(HACK_H)
|
||||
$(O)pline.o: $(SRC)\pline.c $(HACK_H) $(INCL)\epri.h $(INCL)\edog.h
|
||||
$(O)polyself.o: $(SRC)\polyself.c $(HACK_H)
|
||||
$(O)potion.o: $(SRC)\potion.c $(HACK_H)
|
||||
$(O)pray.o: $(SRC)\pray.c $(HACK_H) $(INCL)\epri.h
|
||||
$(O)priest.o: $(SRC)\priest.c $(HACK_H) $(INCL)\mfndpos.h $(INCL)\eshk.h \
|
||||
$(INCL)\epri.h $(INCL)\emin.h
|
||||
$(O)quest.o: $(SRC)\quest.c $(HACK_H) $(INCL)\qtext.h
|
||||
$(O)questpgr.o: $(SRC)\questpgr.c $(HACK_H) $(INCL)\dlb.h $(INCL)\qtext.h
|
||||
$(O)read.o: $(SRC)\read.c $(HACK_H)
|
||||
$(O)rect.o: $(SRC)\rect.c $(HACK_H)
|
||||
$(O)region.o: $(SRC)\region.c $(HACK_H) $(INCL)\lev.h
|
||||
$(O)restore.o: $(SRC)\restore.c $(HACK_H) $(INCL)\lev.h $(INCL)\tcap.h
|
||||
$(O)rip.o: $(SRC)\rip.c $(HACK_H)
|
||||
$(O)rnd.o: $(SRC)\rnd.c $(HACK_H)
|
||||
$(O)role.o: $(SRC)\role.c $(HACK_H)
|
||||
$(O)rumors.o: $(SRC)\rumors.c $(HACK_H) $(INCL)\lev.h $(INCL)\dlb.h
|
||||
$(O)save.o: $(SRC)\save.c $(HACK_H) $(INCL)\lev.h
|
||||
$(O)shk.o: $(SRC)\shk.c $(HACK_H) $(INCL)\eshk.h
|
||||
$(O)shknam.o: $(SRC)\shknam.c $(HACK_H) $(INCL)\eshk.h
|
||||
$(O)sit.o: $(SRC)\sit.c $(HACK_H) $(INCL)\artifact.h
|
||||
$(O)sounds.o: $(SRC)\sounds.c $(HACK_H) $(INCL)\edog.h
|
||||
$(O)sp_lev.o: $(SRC)\sp_lev.c $(HACK_H) $(INCL)\dlb.h $(INCL)\sp_lev.h
|
||||
$(O)spell.o: $(SRC)\spell.c $(HACK_H)
|
||||
$(O)steal.o: $(SRC)\steal.c $(HACK_H)
|
||||
$(O)steed.o: $(SRC)\steed.c $(HACK_H)
|
||||
$(O)teleport.o: $(SRC)\teleport.c $(HACK_H)
|
||||
$(O)timeout.o: $(SRC)\timeout.c $(HACK_H) $(INCL)\lev.h
|
||||
$(O)topten.o: $(SRC)\topten.c $(HACK_H) $(INCL)\dlb.h $(INCL)\patchlevel.h
|
||||
$(O)track.o: $(SRC)\track.c $(HACK_H)
|
||||
$(O)trap.o: $(SRC)\trap.c $(HACK_H)
|
||||
$(O)u_init.o: $(SRC)\u_init.c $(HACK_H)
|
||||
$(O)uhitm.o: $(SRC)\uhitm.c $(HACK_H)
|
||||
$(O)vault.o: $(SRC)\vault.c $(HACK_H) $(INCL)\vault.h
|
||||
$(O)version.o: $(SRC)\version.c $(HACK_H) $(INCL)\date.h $(INCL)\patchlevel.h
|
||||
$(O)vision.o: $(SRC)\vision.c $(HACK_H) $(INCL)\vis_tab.h
|
||||
$(O)weapon.o: $(SRC)\weapon.c $(HACK_H)
|
||||
$(O)were.o: $(SRC)\were.c $(HACK_H)
|
||||
$(O)wield.o: $(SRC)\wield.c $(HACK_H)
|
||||
$(O)windows.o: $(SRC)\windows.c $(HACK_H) $(INCL)\wingem.h $(INCL)\winGnome.h
|
||||
$(O)wizard.o: $(SRC)\wizard.c $(HACK_H) $(INCL)\qtext.h
|
||||
$(O)worm.o: $(SRC)\worm.c $(HACK_H) $(INCL)\lev.h
|
||||
$(O)worn.o: $(SRC)\worn.c $(HACK_H)
|
||||
$(O)write.o: $(SRC)\write.c $(HACK_H)
|
||||
$(O)zap.o: $(SRC)\zap.c $(HACK_H)
|
||||
|
||||
# end of file
|
||||
|
||||
289
sys/wince/celib.c
Normal file
289
sys/wince/celib.c
Normal file
@@ -0,0 +1,289 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#define NEED_VARARGS
|
||||
#include "hack.h"
|
||||
#include <fcntl.h>
|
||||
// #include "wceconf.h"
|
||||
|
||||
static union {
|
||||
time_t t_val;
|
||||
struct time_pack {
|
||||
unsigned int ss:6;
|
||||
unsigned int mm:6;
|
||||
unsigned int dd:5;
|
||||
unsigned int hh:6;
|
||||
unsigned int mo:4;
|
||||
unsigned int yr:10;
|
||||
unsigned int wd:3;
|
||||
} tm_val;
|
||||
} _t_cnv;
|
||||
|
||||
#define IS_LEAP(yr) (((yr)%4==0 || (yr)%100==0) && !(yr)%400==0)
|
||||
static char _day_mo_leap[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
static char _day_mo[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
struct tm * __cdecl localtime ( const time_t *ptime )
|
||||
{
|
||||
static struct tm ptm;
|
||||
int i;
|
||||
if( !ptime ) return NULL;
|
||||
|
||||
_t_cnv.t_val = *ptime;
|
||||
|
||||
ptm.tm_sec = _t_cnv.tm_val.ss ; /* seconds after the minute - [0,59] */
|
||||
ptm.tm_min = _t_cnv.tm_val.mm; /* minutes after the hour - [0,59] */
|
||||
ptm.tm_hour = _t_cnv.tm_val.hh; /* hours since midnight - [0,23] */
|
||||
ptm.tm_mday = _t_cnv.tm_val.dd; /* day of the month - [1,31] */
|
||||
ptm.tm_mon = _t_cnv.tm_val.mo-1; /* months since January - [0,11] */
|
||||
ptm.tm_year = _t_cnv.tm_val.yr; /* years since 1900 */
|
||||
ptm.tm_wday = _t_cnv.tm_val.wd; /* days since Sunday - [0,6] */
|
||||
|
||||
ptm.tm_yday = _t_cnv.tm_val.dd; /* days since January 1 - [0,365] */
|
||||
for( i=0; i<ptm.tm_mon; i++ )
|
||||
ptm.tm_yday += IS_LEAP(_t_cnv.tm_val.yr+1900)?_day_mo_leap[i] : _day_mo[i] ;
|
||||
|
||||
ptm.tm_isdst = 0; /* daylight savings time flag - NOT IMPLEMENTED */
|
||||
return &ptm;
|
||||
}
|
||||
|
||||
time_t __cdecl time(time_t * timeptr)
|
||||
{
|
||||
SYSTEMTIME stm;
|
||||
GetLocalTime(&stm);
|
||||
|
||||
_t_cnv.tm_val.yr = stm.wYear-1900;
|
||||
_t_cnv.tm_val.mo = stm.wMonth;
|
||||
_t_cnv.tm_val.dd = stm.wDay;
|
||||
_t_cnv.tm_val.hh = stm.wHour;
|
||||
_t_cnv.tm_val.mm = stm.wMinute;
|
||||
_t_cnv.tm_val.ss = stm.wSecond;
|
||||
_t_cnv.tm_val.wd = stm.wDayOfWeek;
|
||||
|
||||
if( timeptr)
|
||||
*timeptr = _t_cnv.t_val;
|
||||
return _t_cnv.t_val;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* __io.h__ */
|
||||
/* Hack io.h function with stdio.h functions */
|
||||
/* ASSUMPTION : int can hold FILE* */
|
||||
static char _nh_cwd[255];
|
||||
|
||||
int __cdecl close(int f) {
|
||||
FILE* p = (FILE*)f;
|
||||
return fclose(p);
|
||||
}
|
||||
|
||||
int __cdecl creat(const char *fname , int mode)
|
||||
{
|
||||
FILE* f;
|
||||
f = fopen(fname, "w+");
|
||||
if( !f ) return -1;
|
||||
else return (int)f;
|
||||
}
|
||||
|
||||
int __cdecl eof(int f)
|
||||
{
|
||||
FILE* p = (FILE*)f;
|
||||
return feof(p);
|
||||
}
|
||||
|
||||
long __cdecl lseek( int handle, long offset, int origin )
|
||||
{
|
||||
FILE* p = (FILE*)handle;
|
||||
if( !fseek(p, offset, origin) ) return ftell(p);
|
||||
else return -1;
|
||||
}
|
||||
|
||||
int __cdecl open( const char *filename, int oflag, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int pmode;
|
||||
char mode[16];
|
||||
char fname[255];
|
||||
FILE* f;
|
||||
|
||||
va_start(ap, oflag);
|
||||
pmode = va_arg(ap, int);
|
||||
va_end(ap);
|
||||
|
||||
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");
|
||||
|
||||
if( oflag & O_BINARY ) strcat(mode, "b");
|
||||
if( oflag & O_TEXT ) strcat(mode, "t");
|
||||
|
||||
fname[0]='\x0';
|
||||
if( *filename!='\\' && *filename!='/' ) {
|
||||
strncat(fname, _nh_cwd, sizeof(fname));
|
||||
strncat(fname, "\\", sizeof(fname) - strlen(fname));
|
||||
}
|
||||
strncat(fname, filename, sizeof(fname) - strlen(fname));
|
||||
|
||||
f = fopen(fname, mode);
|
||||
if( !f ) return -1;
|
||||
else {
|
||||
if( !(oflag & O_APPEND) ) fseek(f, SEEK_SET, 0);
|
||||
return (int)f;
|
||||
}
|
||||
}
|
||||
|
||||
int __cdecl read( int handle, void *buffer, unsigned int count )
|
||||
{
|
||||
FILE* p = (FILE*)handle;
|
||||
return fread(buffer, 1, count, p);
|
||||
}
|
||||
|
||||
int __cdecl unlink(const char * filename)
|
||||
{
|
||||
TCHAR wbuf[NHSTR_BUFSIZE];
|
||||
char fname[255];
|
||||
|
||||
fname[0]='\x0';
|
||||
if( *filename!='\\' && *filename!='/' ) {
|
||||
strncat(fname, _nh_cwd, sizeof(fname));
|
||||
strncat(fname, "\\", sizeof(fname) - strlen(fname));
|
||||
}
|
||||
strncat(fname, filename, sizeof(fname) - strlen(fname));
|
||||
|
||||
return !DeleteFileW(NH_A2W(fname, wbuf, NHSTR_BUFSIZE));
|
||||
}
|
||||
|
||||
int __cdecl write( int handle, const void *buffer, unsigned int count )
|
||||
{
|
||||
FILE* p = (FILE*)handle;
|
||||
return fwrite(buffer, 1, count, p);
|
||||
}
|
||||
|
||||
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);
|
||||
return !MoveFile(f1, f2);
|
||||
}
|
||||
|
||||
int chdir( const char *dirname )
|
||||
{
|
||||
ZeroMemory(_nh_cwd, sizeof(_nh_cwd));
|
||||
strncpy(_nh_cwd, dirname, sizeof(_nh_cwd)-1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *getcwd( char *buffer, int maxlen )
|
||||
{
|
||||
if( maxlen<(int)strlen(_nh_cwd) ) return NULL;
|
||||
else return strcpy(buffer, _nh_cwd);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* __errno.h__ */
|
||||
int errno;
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Chdrive() changes the default drive.
|
||||
*/
|
||||
void
|
||||
chdrive(char *str)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is used in nhlan.c to implement some of the LAN_FEATURES.
|
||||
*/
|
||||
char *get_username(lan_username_size)
|
||||
int *lan_username_size;
|
||||
{
|
||||
static char username_buffer[BUFSZ];
|
||||
strcpy(username_buffer, "nhsave");
|
||||
return username_buffer;
|
||||
}
|
||||
|
||||
void Delay(int ms)
|
||||
{
|
||||
(void)Sleep(ms);
|
||||
}
|
||||
|
||||
void more()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int isatty(int f)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef WIN_CE_2xx
|
||||
int __cdecl isupper(int c)
|
||||
{
|
||||
char str[2];
|
||||
WCHAR wstr[2];
|
||||
str[0] = c;
|
||||
str[1] = 0;
|
||||
|
||||
NH_A2W(str, wstr, 1);
|
||||
return iswupper(wstr[0]);
|
||||
}
|
||||
|
||||
int __cdecl isdigit(int c)
|
||||
{
|
||||
return ('0' <= c && c <= '9');
|
||||
}
|
||||
|
||||
int __cdecl isspace(int c)
|
||||
{
|
||||
char str[2];
|
||||
WCHAR wstr[2];
|
||||
str[0] = c;
|
||||
str[1] = 0;
|
||||
|
||||
NH_A2W(str, wstr, 1);
|
||||
return iswspace(wstr[0]);
|
||||
}
|
||||
|
||||
int __cdecl isprint(int c)
|
||||
{
|
||||
char str[2];
|
||||
WCHAR wstr[2];
|
||||
str[0] = c;
|
||||
str[1] = 0;
|
||||
|
||||
NH_A2W(str, wstr, 1);
|
||||
return iswprint(wstr[0]);
|
||||
}
|
||||
|
||||
char* __cdecl _strdup(const char* s)
|
||||
{
|
||||
char* p;
|
||||
p = malloc(strlen(s)+1);
|
||||
return strcpy(p, s);
|
||||
}
|
||||
|
||||
char* __cdecl strrchr( const char *s, int c )
|
||||
{
|
||||
WCHAR wstr[1024];
|
||||
WCHAR *w;
|
||||
w = wcsrchr(NH_A2W(s, wstr, 1024), c);
|
||||
if(w) return (char*)(s + (w - wstr));
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
int __cdecl _stricmp(const char* a, const char* b)
|
||||
{
|
||||
return strncmpi(a, b, 65535u);
|
||||
}
|
||||
|
||||
#endif
|
||||
80
sys/wince/cesetup.bat
Executable file
80
sys/wince/cesetup.bat
Executable file
@@ -0,0 +1,80 @@
|
||||
@REM SCCS Id: @(#)nhsetup.bat $Date$
|
||||
@REM Copyright (c) Alex Kompel, 2002
|
||||
@REM NetHack may be freely redistributed. See license for details.
|
||||
@REM Win32 nhsetup batch file, see Install.ce for details
|
||||
@REM
|
||||
@echo off
|
||||
REM
|
||||
REM Make sure directories necessary for build exist
|
||||
REM
|
||||
if NOT exist ..\..\wince\*.* mkdir ..\..\wince
|
||||
if NOT exist ..\..\wince\ceinc\*.* mkdir ..\..\wince\ceinc
|
||||
if NOT exist ..\..\wince\ceinc\sys\*.* mkdir ..\..\wince\ceinc\sys
|
||||
REM
|
||||
REM Get these files from the win\win32 port
|
||||
REM
|
||||
copy ..\..\win\win32\mnsel.uu ..\..\wince\mnsel.uu
|
||||
copy ..\..\win\win32\mnselcnt.uu ..\..\wince\mnselcnt.uu
|
||||
copy ..\..\win\win32\mnunsel.uu ..\..\wince\mnunsel.uu
|
||||
copy ..\..\win\win32\petmark.uu ..\..\wince\petmark.uu
|
||||
copy ..\..\sys\winnt\nhico.uu ..\..\wince\nhico.uu
|
||||
REM
|
||||
REM Get these files from sys\wince
|
||||
REM
|
||||
copy bootstrp.mak ..\..\wince\bootstrp.mak
|
||||
copy wince.vcw ..\..\wince.vcw
|
||||
copy keypad.uu ..\..\wince\keypad.uu
|
||||
copy assert.h ..\..\wince\assert.h
|
||||
copy assert.h ..\..\wince\ceinc\assert.h
|
||||
copy errno.h ..\..\wince\ceinc\errno.h
|
||||
copy fcntl.h ..\..\wince\ceinc\fcntl.h
|
||||
copy stat.h ..\..\wince\ceinc\sys\stat.h
|
||||
copy celib.c ..\..\wince\celib.c
|
||||
copy mhaskyn.c ..\..\wince\mhaskyn.c
|
||||
copy mhaskyn.h ..\..\wince\mhaskyn.h
|
||||
copy mhcmd.c ..\..\wince\mhcmd.c
|
||||
copy mhcmd.h ..\..\wince\mhcmd.h
|
||||
copy mhcolor.c ..\..\wince\mhcolor.c
|
||||
copy mhcolor.h ..\..\wince\mhcolor.h
|
||||
copy mhdlg.c ..\..\wince\mhdlg.c
|
||||
copy mhdlg.h ..\..\wince\mhdlg.h
|
||||
copy mhfont.c ..\..\wince\mhfont.c
|
||||
copy mhfont.h ..\..\wince\mhfont.h
|
||||
copy mhinput.c ..\..\wince\mhinput.c
|
||||
copy mhinput.h ..\..\wince\mhinput.h
|
||||
copy mhmain.c ..\..\wince\mhmain.c
|
||||
copy mhmain.h ..\..\wince\mhmain.h
|
||||
copy mhmap.c ..\..\wince\mhmap.c
|
||||
copy mhmap.h ..\..\wince\mhmap.h
|
||||
copy mhmenu.c ..\..\wince\mhmenu.c
|
||||
copy mhmenu.h ..\..\wince\mhmenu.h
|
||||
copy mhmsg.h ..\..\wince\mhmsg.h
|
||||
copy mhmsgwnd.c ..\..\wince\mhmsgwnd.c
|
||||
copy mhmsgwnd.h ..\..\wince\mhmsgwnd.h
|
||||
copy mhrip.c ..\..\wince\mhrip.c
|
||||
copy mhrip.h ..\..\wince\mhrip.h
|
||||
copy mhstatus.c ..\..\wince\mhstatus.c
|
||||
copy mhstatus.h ..\..\wince\mhstatus.h
|
||||
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 winhack.c ..\..\wince\winhack.c
|
||||
copy winhack.h ..\..\wince\winhack.h
|
||||
copy winhack.rc ..\..\wince\winhack.rc
|
||||
copy winmain.c ..\..\wince\winmain.c
|
||||
copy winMS.h ..\..\wince\winMS.h
|
||||
echo.
|
||||
echo Proceed with the following steps:
|
||||
echo.
|
||||
echo cd ..\..\wince
|
||||
echo nmake /f bootstrp.mak
|
||||
echo.
|
||||
echo Then start Embedded Visual C and open
|
||||
echo the workspace wince.vcw (at the top of the NetHack tree)
|
||||
echo to build. See Install.ce for details.
|
||||
echo.
|
||||
|
||||
3
sys/wince/errno.h
Normal file
3
sys/wince/errno.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* empty file */
|
||||
|
||||
extern int errno;
|
||||
67
sys/wince/fcntl.h
Normal file
67
sys/wince/fcntl.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/***
|
||||
*fcntl.h - file control options used by open()
|
||||
*
|
||||
*Purpose:
|
||||
* This file defines constants for the file control options used
|
||||
* by the _open() function.
|
||||
* [System V]
|
||||
*
|
||||
* [Public]
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef _INC_FCNTL
|
||||
#define _INC_FCNTL
|
||||
|
||||
#define _O_RDONLY 0x0000 /* open for reading only */
|
||||
#define _O_WRONLY 0x0001 /* open for writing only */
|
||||
#define _O_RDWR 0x0002 /* open for reading and writing */
|
||||
#define _O_APPEND 0x0008 /* writes done at eof */
|
||||
|
||||
#define _O_CREAT 0x0100 /* create and open file */
|
||||
#define _O_TRUNC 0x0200 /* open and truncate */
|
||||
#define _O_EXCL 0x0400 /* open only if file doesn't already exist */
|
||||
|
||||
/* O_TEXT files have <cr><lf> sequences translated to <lf> on read()'s,
|
||||
** and <lf> sequences translated to <cr><lf> on write()'s
|
||||
*/
|
||||
|
||||
#define _O_TEXT 0x4000 /* file mode is text (translated) */
|
||||
#define _O_BINARY 0x8000 /* file mode is binary (untranslated) */
|
||||
|
||||
/* macro to translate the C 2.0 name used to force binary mode for files */
|
||||
|
||||
#define _O_RAW _O_BINARY
|
||||
|
||||
/* Open handle inherit bit */
|
||||
|
||||
#define _O_NOINHERIT 0x0080 /* child process doesn't inherit file */
|
||||
|
||||
/* Temporary file bit - file is deleted when last handle is closed */
|
||||
|
||||
#define _O_TEMPORARY 0x0040 /* temporary file bit */
|
||||
|
||||
/* sequential/random access hints */
|
||||
|
||||
#define _O_SEQUENTIAL 0x0020 /* file access is primarily sequential */
|
||||
#define _O_RANDOM 0x0010 /* file access is primarily random */
|
||||
|
||||
#if !__STDC__ || defined(_POSIX_)
|
||||
/* Non-ANSI names for compatibility */
|
||||
#define O_RDONLY _O_RDONLY
|
||||
#define O_WRONLY _O_WRONLY
|
||||
#define O_RDWR _O_RDWR
|
||||
#define O_APPEND _O_APPEND
|
||||
#define O_CREAT _O_CREAT
|
||||
#define O_TRUNC _O_TRUNC
|
||||
#define O_EXCL _O_EXCL
|
||||
#define O_TEXT _O_TEXT
|
||||
#define O_BINARY _O_BINARY
|
||||
#define O_RAW _O_BINARY
|
||||
#define O_TEMPORARY _O_TEMPORARY
|
||||
#define O_NOINHERIT _O_NOINHERIT
|
||||
#define O_SEQUENTIAL _O_SEQUENTIAL
|
||||
#define O_RANDOM _O_RANDOM
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#endif /* _INC_FCNTL */
|
||||
7
sys/wince/keypad.uu
Normal file
7
sys/wince/keypad.uu
Normal file
@@ -0,0 +1,7 @@
|
||||
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__?________________'
|
||||
`
|
||||
end
|
||||
11
sys/wince/mhaskyn.c
Normal file
11
sys/wince/mhaskyn.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include <assert.h>
|
||||
#include "winMS.h"
|
||||
#include "mhaskyn.h"
|
||||
|
||||
int mswin_yes_no_dialog( const char *question, const char *choices, int def)
|
||||
{
|
||||
return '\032';
|
||||
}
|
||||
11
sys/wince/mhaskyn.h
Normal file
11
sys/wince/mhaskyn.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MSWINAskYesNO_h
|
||||
#define MSWINAskYesNO_h
|
||||
|
||||
#include "winMS.h"
|
||||
|
||||
int mswin_yes_no_dialog( const char *question, const char *choices, int def);
|
||||
|
||||
#endif /* MSWINAskYesNO_h */
|
||||
720
sys/wince/mhcmd.c
Normal file
720
sys/wince/mhcmd.c
Normal file
@@ -0,0 +1,720 @@
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "winMS.h"
|
||||
#include "resource.h"
|
||||
#include "mhcmd.h"
|
||||
#include "mhinput.h"
|
||||
#include "mhcolor.h"
|
||||
|
||||
static TCHAR szNHCmdWindowClass[] = TEXT("MSNethackCmdWndClass");
|
||||
|
||||
#ifndef C
|
||||
# define C(c) (0x1f & (c))
|
||||
#endif
|
||||
|
||||
/* cell status 0 */
|
||||
#define NH_CST_CHECKED 1
|
||||
|
||||
/* fonts */
|
||||
#define NH_CMDPAD_FONT_NORMAL 0
|
||||
#define NH_CMDPAD_FONT_MAX 0
|
||||
#define NHCMD_DEFAULT_FONT_NAME TEXT("Tahoma")
|
||||
|
||||
/* type of the cell */
|
||||
#define NH_CELL_REG 0
|
||||
#define NH_CELL_CTRL 1
|
||||
#define NH_CELL_CAP 2
|
||||
#define NH_CELL_SHIFT 3
|
||||
|
||||
/* dimensions of the command pad */
|
||||
#define NH_CMDPAD_ROWS 3
|
||||
#define NH_CMDPAD_COLS 19
|
||||
#define NH_CMDPAD_CELLNUM (NH_CMDPAD_COLS*NH_CMDPAD_ROWS)
|
||||
|
||||
/* cell information */
|
||||
typedef struct t_NHCmdPadCell {
|
||||
UINT cmd_code; /* Windows command code (menu processing - not implemented - set to -1) */
|
||||
char f_char; /* nethack char */
|
||||
const char* text; /* display text */
|
||||
int image; /* >0 - image ID - not implented
|
||||
<=0 - absolute index of the font table */
|
||||
int type; /* cell type */
|
||||
int mult; /* cell width multiplier */
|
||||
} NHCmdPadCell, *PNHCmdPadCell;
|
||||
|
||||
/* lowercase layout */
|
||||
NHCmdPadCell layout_mod1[NH_CMDPAD_ROWS*NH_CMDPAD_COLS] =
|
||||
{
|
||||
{ -1, '7', "7", 1, NH_CELL_REG, 1 },
|
||||
{ -1, '8', "8", 2, NH_CELL_REG, 1 },
|
||||
{ -1, '9', "9", 3, NH_CELL_REG, 1 },
|
||||
{ -1, '<', "<", 10, NH_CELL_REG, 1 },
|
||||
{ -1, ' ', "CAP", -NH_CMDPAD_FONT_NORMAL, NH_CELL_CAP, 2 },
|
||||
{ -1, ' ', "", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 0 }, /* complement for CAPS */
|
||||
{ -1, '\x1b', "Esc", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 2 },
|
||||
{ -1, ' ', "", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 0 }, /* complement for ESC */
|
||||
{ -1, '?', "?", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '*', "*", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, ',', ",", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '/', "/", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, ':', ":", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, ';', ";", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '-', "-", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '#', "#", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '^', "^", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '&', "&", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '\\', "\\", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
|
||||
{ -1, '4', "4", 4, NH_CELL_REG, 1 },
|
||||
{ -1, '5', "5", 5, NH_CELL_REG, 1 },
|
||||
{ -1, '6', "6", 6, NH_CELL_REG, 1 },
|
||||
{ -1, '.', ".", 11, NH_CELL_REG, 1 },
|
||||
{ -1, ' ', "Shft", -NH_CMDPAD_FONT_NORMAL, NH_CELL_SHIFT, 2 },
|
||||
{ -1, ' ', "", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 0 }, /* complement for shift */
|
||||
{ -1, 'a', "a", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'b', "b", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'c', "c", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'd', "d", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'e', "e", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'f', "f", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'g', "g", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'h', "h", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'i', "i", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'j', "j", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'k', "k", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'l', "l", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'm', "m", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
|
||||
{ -1, '1', "1", 7, NH_CELL_REG, 1 },
|
||||
{ -1, '2', "2", 8, NH_CELL_REG, 1 },
|
||||
{ -1, '3', "3", 9, NH_CELL_REG, 1 },
|
||||
{ -1, '>', ">", 12, NH_CELL_REG, 1 },
|
||||
{ -1, ' ', "Ctrl", -NH_CMDPAD_FONT_NORMAL, NH_CELL_CTRL, 2 },
|
||||
{ -1, ' ', "", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 0 }, /* complement for CTRL */
|
||||
{ -1, 'n', "n", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'o', "o", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'p', "p", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'q', "q", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'r', "r", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 's', "s", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 't', "t", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'u', "u", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'v', "v", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'w', "w", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'x', "x", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'y', "y", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'z', "z", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 }
|
||||
};
|
||||
|
||||
/* uppercase layout */
|
||||
NHCmdPadCell layout_mod2[-NH_CMDPAD_ROWS*-NH_CMDPAD_COLS] =
|
||||
{
|
||||
{ -1, '7', "7", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '8', "8", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '9', "9", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '<', "<", 10, NH_CELL_REG, 1 },
|
||||
{ -1, ' ', "CAP", -NH_CMDPAD_FONT_NORMAL, NH_CELL_CAP, 2 },
|
||||
{ -1, ' ', "", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 0 }, /* complement for CAPS */
|
||||
{ -1, '\x1b', "Esc", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 2 },
|
||||
{ -1, ' ', "", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 0 }, /* complement for ESC */
|
||||
{ -1, '?', "?", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '*', "*", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '[', "[", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, ']', "]", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '(', "(", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, ')', ")", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '+', "+", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '=', "=", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '"', "\"", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '$', "$", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '@', "@", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
|
||||
{ -1, '4', "4", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '5', "5", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '6', "6", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '0', "0", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, ' ', "Shft", -NH_CMDPAD_FONT_NORMAL, NH_CELL_SHIFT, 2 },
|
||||
{ -1, ' ', "", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 0 }, /* complement for shift */
|
||||
{ -1, 'A', "A", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'B', "B", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'C', "C", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'D', "D", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'E', "E", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'F', "F", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'G', "G", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'H', "H", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'I', "I", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'J', "J", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'K', "K", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'L', "L", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'M', "M", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
|
||||
{ -1, '1', "1", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '2', "2", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '3', "3", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, '>', ">", 12, NH_CELL_REG, 1 },
|
||||
{ -1, ' ', "Ctrl", -NH_CMDPAD_FONT_NORMAL, NH_CELL_CTRL, 2 },
|
||||
{ -1, ' ', "", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 0 }, /* complement for CTRL */
|
||||
{ -1, 'N', "N", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'O', "O", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'P', "P", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'Q', "Q", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'R', "R", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'S', "S", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'T', "T", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'U', "U", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'V', "V", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'W', "W", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'X', "X", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'Y', "Y", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 },
|
||||
{ -1, 'Z', "Z", -NH_CMDPAD_FONT_NORMAL, NH_CELL_REG, 1 }
|
||||
};
|
||||
|
||||
/* display cell layout */
|
||||
typedef struct t_NHCmdPadLayoutCell {
|
||||
POINT orig; /* origin of the cell rect */
|
||||
BYTE type; /* cell type */
|
||||
int state; /* cell state */
|
||||
} NHCmdPadLayoutCell, *PNHCmdPadLayoutCell;
|
||||
|
||||
/* command window data */
|
||||
typedef struct mswin_nethack_cmd_window {
|
||||
NHCmdPadLayoutCell cells[NH_CMDPAD_CELLNUM]; /* display cells */
|
||||
SIZE cell_size; /* cell size */
|
||||
PNHCmdPadCell layout; /* current layout */
|
||||
HFONT font[NH_CMDPAD_FONT_MAX+1]; /* fonts for cell text */
|
||||
HBITMAP images; /* key images map */
|
||||
int active_cell; /* current active cell */
|
||||
|
||||
boolean is_caps; /* is CAPS selected */
|
||||
boolean is_ctrl; /* is CRTL selected */
|
||||
boolean is_shift; /* is SHIFT selected */
|
||||
} NHCmdWindow, *PNHCmdWindow;
|
||||
|
||||
LRESULT CALLBACK NHCommandWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static void register_command_window_class();
|
||||
static void LayoutCmdWindow(HWND hWnd);
|
||||
static void SetCmdWindowLayout(HWND hWnd, PNHCmdPadCell layout);
|
||||
static int CellFromPoint(PNHCmdWindow data, POINT pt );
|
||||
static void CalculateCellSize(HWND hWnd, LPSIZE pSize);
|
||||
static void SelectCell(HWND hWnd, int cell, BOOL isSelected);
|
||||
|
||||
/* message handlers */
|
||||
static void onPaint(HWND hWnd); // on WM_PAINT
|
||||
static void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam); // on WM_CREATE
|
||||
static void onMouseDown(HWND hWnd, WPARAM wParam, LPARAM lParam); // on WM_LBUTTONDOWN
|
||||
static void onMouseMove(HWND hWnd, WPARAM wParam, LPARAM lParam); // on WM_MOUSEMOVE
|
||||
static void onMouseUp(HWND hWnd, WPARAM wParam, LPARAM lParam); // on WM_LBUTTONUP
|
||||
|
||||
|
||||
HWND mswin_init_command_window () {
|
||||
static int run_once = 0;
|
||||
HWND ret;
|
||||
|
||||
/* register window class */
|
||||
if( !run_once ) {
|
||||
register_command_window_class();
|
||||
run_once = 1;
|
||||
}
|
||||
|
||||
/* create window */
|
||||
ret = CreateWindow(
|
||||
szNHCmdWindowClass, /* registered class name */
|
||||
NULL, /* window name */
|
||||
WS_CHILD | WS_CLIPSIBLINGS, /* window style */
|
||||
0, /* horizontal position of window - set it later */
|
||||
0, /* vertical position of window - set it later */
|
||||
0, /* window width - set it later */
|
||||
0, /* window height - set it later*/
|
||||
GetNHApp()->hMainWnd, /* handle to parent or owner window */
|
||||
NULL, /* menu handle or child identifier */
|
||||
GetNHApp()->hApp, /* handle to application instance */
|
||||
NULL ); /* window-creation data */
|
||||
if( !ret ) {
|
||||
panic("Cannot create command window");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* calculate mimimum window size */
|
||||
void mswin_command_window_size (HWND hwnd, LPSIZE sz)
|
||||
{
|
||||
RECT rt;
|
||||
SIZE cell_size;
|
||||
|
||||
CalculateCellSize(hwnd, &cell_size);
|
||||
GetWindowRect(GetNHApp()->hMainWnd, &rt);
|
||||
sz->cx = rt.right - rt.left;
|
||||
sz->cy = cell_size.cy*NH_CMDPAD_ROWS+2*GetSystemMetrics(SM_CYBORDER);
|
||||
}
|
||||
|
||||
void register_command_window_class()
|
||||
{
|
||||
WNDCLASS wcex;
|
||||
ZeroMemory( &wcex, sizeof(wcex));
|
||||
|
||||
/* window class */
|
||||
wcex.style = CS_NOCLOSE;
|
||||
wcex.lpfnWndProc = (WNDPROC)NHCommandWndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = GetNHApp()->hApp;
|
||||
wcex.hIcon = NULL;
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = mswin_get_brush(NHW_KEYPAD, MSWIN_COLOR_BG);
|
||||
wcex.lpszMenuName = NULL;
|
||||
wcex.lpszClassName = szNHCmdWindowClass;
|
||||
|
||||
if( !RegisterClass(&wcex) ) {
|
||||
panic("cannot register Map window class");
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK NHCommandWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHCmdWindow data;
|
||||
int i;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
onCreate( hWnd, wParam, lParam );
|
||||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
onPaint(hWnd);
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
LayoutCmdWindow(hWnd);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
onMouseDown(hWnd, wParam, lParam);
|
||||
return 0;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
/* proceed only if if have mouse focus (set in onMouseDown() -
|
||||
left mouse button is pressed) */
|
||||
if( GetCapture()==hWnd ) {
|
||||
onMouseMove(hWnd, wParam, lParam);
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
/* proceed only if if have mouse focus (set in onMouseDown()) */
|
||||
if( GetCapture()==hWnd ) {
|
||||
onMouseUp(hWnd, wParam, lParam);
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
for(i=0; i<=NH_CMDPAD_FONT_MAX; i++ )
|
||||
if( data->font[i] ) DeleteObject(data->font[i]);
|
||||
free(data);
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void onPaint(HWND hWnd)
|
||||
{
|
||||
PNHCmdWindow data;
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC;
|
||||
int i;
|
||||
TCHAR wbuf[BUFSZ];
|
||||
HGDIOBJ saveFont;
|
||||
BITMAP bm;
|
||||
|
||||
/* get window data */
|
||||
data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
|
||||
if( !IsRectEmpty(&ps.rcPaint) ) {
|
||||
HGDIOBJ oldBr;
|
||||
HBRUSH hbrPattern;
|
||||
COLORREF OldBg, OldFg;
|
||||
HPEN hPen;
|
||||
HGDIOBJ hOldPen;
|
||||
|
||||
saveFont = SelectObject(hDC, data->font[NH_CMDPAD_FONT_NORMAL]);
|
||||
OldBg = SetBkColor(hDC, mswin_get_color(NHW_KEYPAD, MSWIN_COLOR_BG));
|
||||
OldFg = SetTextColor(hDC, mswin_get_color(NHW_KEYPAD, MSWIN_COLOR_FG));
|
||||
|
||||
GetObject(data->images, sizeof(BITMAP), (LPVOID)&bm);
|
||||
|
||||
hbrPattern = CreatePatternBrush(data->images);
|
||||
hPen = CreatePen(PS_SOLID, 1, mswin_get_color(NHW_KEYPAD, MSWIN_COLOR_FG));
|
||||
|
||||
for( i=0; i<NH_CMDPAD_CELLNUM; i++ ) {
|
||||
RECT cell_rt;
|
||||
POINT pt[5];
|
||||
|
||||
/* calculate the cell rectangle */
|
||||
cell_rt.left = data->cells[i].orig.x;
|
||||
cell_rt.top = data->cells[i].orig.y;
|
||||
cell_rt.right = data->cells[i].orig.x + data->cell_size.cx*data->layout[i].mult;
|
||||
cell_rt.bottom = data->cells[i].orig.y + data->cell_size.cy;
|
||||
|
||||
/* draw border */
|
||||
hOldPen = SelectObject(hDC, hPen);
|
||||
pt[0].x = cell_rt.left;
|
||||
pt[0].y = cell_rt.top;
|
||||
pt[1].x = cell_rt.right;
|
||||
pt[1].y = cell_rt.top;
|
||||
pt[2].x = cell_rt.right;
|
||||
pt[2].y = cell_rt.bottom;
|
||||
pt[3].x = cell_rt.left;
|
||||
pt[3].y = cell_rt.bottom;
|
||||
pt[4].x = cell_rt.left;
|
||||
pt[4].y = cell_rt.top;
|
||||
Polyline(hDC, pt, 5);
|
||||
SelectObject(hDC, hOldPen);
|
||||
|
||||
/* calculate clipping rectangle for the text */
|
||||
cell_rt.left++;
|
||||
cell_rt.top ++;
|
||||
cell_rt.right--;
|
||||
cell_rt.bottom--;
|
||||
|
||||
/* draw the cell text */
|
||||
if( data->layout[i].image<=0 ) {
|
||||
SelectObject(hDC, data->font[ -data->layout[i].image ]);
|
||||
DrawText(hDC,
|
||||
NH_A2W(data->layout[i].text, wbuf, BUFSZ),
|
||||
strlen(data->layout[i].text),
|
||||
&cell_rt,
|
||||
DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX
|
||||
);
|
||||
} else {
|
||||
/* draw bitmap */
|
||||
int bmOffset;
|
||||
RECT bitmap_rt;
|
||||
|
||||
bmOffset = (data->layout[i].image - 1)*bm.bmHeight;
|
||||
|
||||
bitmap_rt.left = ((cell_rt.left+cell_rt.right) - min(bm.bmHeight, (cell_rt.right-cell_rt.left)))/2;
|
||||
bitmap_rt.top = ((cell_rt.bottom+cell_rt.top) - min(bm.bmHeight, (cell_rt.bottom-cell_rt.top)))/2;
|
||||
bitmap_rt.right = bitmap_rt.left + min(bm.bmHeight, (cell_rt.right-cell_rt.left));
|
||||
bitmap_rt.bottom = bitmap_rt.top + min(bm.bmHeight, (cell_rt.bottom-cell_rt.top));
|
||||
|
||||
SetBrushOrgEx(hDC, bitmap_rt.left-bmOffset, bitmap_rt.top, NULL);
|
||||
oldBr = SelectObject(hDC, hbrPattern);
|
||||
PatBlt(
|
||||
hDC,
|
||||
bitmap_rt.left,
|
||||
bitmap_rt.top,
|
||||
bitmap_rt.right-bitmap_rt.left,
|
||||
bitmap_rt.bottom-bitmap_rt.top,
|
||||
PATCOPY);
|
||||
SelectObject(hDC, oldBr);
|
||||
}
|
||||
|
||||
/* invert the cell if it is selected */
|
||||
if( data->cells[i].state == NH_CST_CHECKED ) {
|
||||
IntersectRect( &cell_rt, &cell_rt, &ps.rcPaint);
|
||||
PatBlt( hDC,
|
||||
cell_rt.left,
|
||||
cell_rt.top,
|
||||
cell_rt.right - cell_rt.left,
|
||||
cell_rt.bottom - cell_rt.top,
|
||||
DSTINVERT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SetTextColor(hDC, OldFg);
|
||||
SetBkColor(hDC, OldBg);
|
||||
SelectObject(hDC, saveFont);
|
||||
DeleteObject(hbrPattern);
|
||||
DeleteObject(hPen);
|
||||
}
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
|
||||
void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHCmdWindow data;
|
||||
|
||||
/* set window data */
|
||||
data = (PNHCmdWindow)malloc(sizeof(NHCmdWindow));
|
||||
if( !data ) panic("out of memory");
|
||||
|
||||
ZeroMemory(data, sizeof(NHCmdWindow));
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)data);
|
||||
|
||||
data->active_cell = -1;
|
||||
|
||||
/* load images bitmap */
|
||||
data->images = LoadBitmap(GetNHApp()->hApp, MAKEINTRESOURCE(IDB_KEYPAD));
|
||||
if( !data->images ) panic("cannot load keypad bitmap");
|
||||
|
||||
/* set default layout */
|
||||
SetCmdWindowLayout(hWnd, layout_mod1);
|
||||
}
|
||||
|
||||
void LayoutCmdWindow(HWND hWnd)
|
||||
{
|
||||
RECT clrt;
|
||||
PNHCmdWindow data;
|
||||
int i, j;
|
||||
int x, y;
|
||||
LOGFONT lgfnt;
|
||||
|
||||
GetClientRect(hWnd, &clrt);
|
||||
if( IsRectEmpty(&clrt) ) return;
|
||||
|
||||
data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
if( !data->layout ) return;
|
||||
|
||||
/* calculate cell size */
|
||||
CalculateCellSize(hWnd, &data->cell_size);
|
||||
|
||||
/* initialize display cells aray */
|
||||
x = 0;
|
||||
y = 0;
|
||||
for( i=0; i<NH_CMDPAD_ROWS; i++ ) {
|
||||
for( j=0; j<NH_CMDPAD_COLS; j++ ) {
|
||||
int index;
|
||||
|
||||
index = (i*NH_CMDPAD_COLS)+j;
|
||||
data->cells[index].orig.x = x;
|
||||
data->cells[index].orig.y = y;
|
||||
data->cells[index].type = data->layout[index].type;
|
||||
|
||||
switch(data->cells[index].type) {
|
||||
case NH_CELL_CTRL:
|
||||
data->cells[index].state = data->is_ctrl? NH_CST_CHECKED : 0;
|
||||
break;
|
||||
case NH_CELL_CAP:
|
||||
data->cells[index].state = data->is_caps? NH_CST_CHECKED : 0;
|
||||
break;
|
||||
case NH_CELL_SHIFT:
|
||||
data->cells[index].state = data->is_shift? NH_CST_CHECKED : 0;
|
||||
break;
|
||||
default:
|
||||
data->cells[index].state = 0;
|
||||
}
|
||||
|
||||
x += data->cell_size.cx * data->layout[index].mult;
|
||||
}
|
||||
x = 0;
|
||||
y += data->cell_size.cy;
|
||||
}
|
||||
|
||||
/* create font for display cell text */
|
||||
for(i=0; i<=NH_CMDPAD_FONT_MAX; i++ )
|
||||
if( data->font[i] ) DeleteObject(data->font[i]);
|
||||
|
||||
ZeroMemory( &lgfnt, sizeof(lgfnt) );
|
||||
lgfnt.lfHeight = data->cell_size.cy; // height of font
|
||||
lgfnt.lfWidth = 0; // average character width
|
||||
lgfnt.lfEscapement = 0; // angle of escapement
|
||||
lgfnt.lfOrientation = 0; // base-line orientation angle
|
||||
lgfnt.lfWeight = FW_NORMAL; // font weight
|
||||
lgfnt.lfItalic = FALSE; // italic attribute option
|
||||
lgfnt.lfUnderline = FALSE; // underline attribute option
|
||||
lgfnt.lfStrikeOut = FALSE; // strikeout attribute option
|
||||
lgfnt.lfCharSet = ANSI_CHARSET; // character set identifier
|
||||
lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision
|
||||
lgfnt.lfClipPrecision = CLIP_CHARACTER_PRECIS; // clipping precision
|
||||
lgfnt.lfQuality = DEFAULT_QUALITY; // output quality
|
||||
lgfnt.lfPitchAndFamily = VARIABLE_PITCH; // pitch and family
|
||||
_tcsncpy(lgfnt.lfFaceName, NHCMD_DEFAULT_FONT_NAME, LF_FACESIZE);
|
||||
data->font[NH_CMDPAD_FONT_NORMAL] = CreateFontIndirect(&lgfnt);
|
||||
}
|
||||
|
||||
|
||||
void SetCmdWindowLayout(HWND hWnd, PNHCmdPadCell layout)
|
||||
{
|
||||
PNHCmdWindow data;
|
||||
|
||||
data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
data->layout = layout;
|
||||
ZeroMemory(data->cells, sizeof(data->cells));
|
||||
LayoutCmdWindow(hWnd);
|
||||
}
|
||||
|
||||
void onMouseDown(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHCmdWindow data;
|
||||
POINT mpt;
|
||||
|
||||
/* get mouse coordinates */
|
||||
mpt.x = LOWORD(lParam);
|
||||
mpt.y = HIWORD(lParam);
|
||||
|
||||
/* map mouse coordinates to the display cell */
|
||||
data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
data->active_cell = CellFromPoint(data, mpt);
|
||||
if( data->active_cell==-1 ) return;
|
||||
|
||||
/* set mouse focus to the current window */
|
||||
SetCapture(hWnd);
|
||||
|
||||
/* invert the selection */
|
||||
SelectCell(hWnd, data->active_cell, (data->cells[data->active_cell].state!=NH_CST_CHECKED) );
|
||||
}
|
||||
|
||||
void onMouseMove(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHCmdWindow data;
|
||||
POINT mpt;
|
||||
int newActiveCell;
|
||||
|
||||
/* get mouse coordinates */
|
||||
mpt.x = LOWORD(lParam);
|
||||
mpt.y = HIWORD(lParam);
|
||||
|
||||
/* map mouse coordinates to the display cell */
|
||||
data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
newActiveCell = CellFromPoint(data, mpt);
|
||||
if( data->active_cell == -1 ) return;
|
||||
|
||||
/* if mouse is within orginal display cell - select the cell otherwise
|
||||
clear the selection */
|
||||
switch( data->layout[data->active_cell].type ) {
|
||||
case NH_CELL_REG:
|
||||
SelectCell(hWnd, data->active_cell,
|
||||
(newActiveCell==data->active_cell) );
|
||||
break;
|
||||
|
||||
case NH_CELL_CTRL:
|
||||
SelectCell(hWnd, data->active_cell,
|
||||
((newActiveCell==data->active_cell)? !data->is_ctrl : data->is_ctrl) );
|
||||
break;
|
||||
|
||||
case NH_CELL_CAP:
|
||||
SelectCell(hWnd, data->active_cell,
|
||||
((newActiveCell==data->active_cell)? !data->is_caps : data->is_caps) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void onMouseUp(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHCmdWindow data;
|
||||
int i;
|
||||
|
||||
/* release mouse capture */
|
||||
ReleaseCapture();
|
||||
|
||||
/* get active display cell */
|
||||
data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
if( data->active_cell == -1 ) return;
|
||||
|
||||
/* act depending on the cell type:
|
||||
CAPS - change layout
|
||||
CTRL - modify CTRL status
|
||||
REG - place keyboard event on the nethack input queue
|
||||
*/
|
||||
switch( data->layout[data->active_cell].type ) {
|
||||
case NH_CELL_REG:
|
||||
if( data->is_ctrl ) {
|
||||
NHEVENT_KBD(C(data->layout[data->active_cell].f_char));
|
||||
|
||||
data->is_ctrl = 0;
|
||||
for( i=0; i<NH_CMDPAD_CELLNUM; i++ ) {
|
||||
if( data->layout[i].type == NH_CELL_CTRL ) {
|
||||
SelectCell(hWnd, i, data->is_ctrl);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NHEVENT_KBD(data->layout[data->active_cell].f_char);
|
||||
}
|
||||
SelectCell(hWnd, data->active_cell, FALSE);
|
||||
|
||||
if( !data->is_shift ) break;
|
||||
// else fall through and reset the shift
|
||||
|
||||
case NH_CELL_SHIFT:
|
||||
data->is_shift = !data->is_shift;
|
||||
SetCmdWindowLayout(
|
||||
hWnd,
|
||||
(data->is_shift ^ data->is_caps)? layout_mod2 : layout_mod1
|
||||
);
|
||||
data->cells[data->active_cell].state = data->is_shift? NH_CST_CHECKED : 0;
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
break;
|
||||
|
||||
case NH_CELL_CTRL:
|
||||
data->is_ctrl = !data->is_ctrl;
|
||||
SelectCell(hWnd, data->active_cell, data->is_ctrl);
|
||||
break;
|
||||
|
||||
case NH_CELL_CAP:
|
||||
data->is_caps = !data->is_caps;
|
||||
SetCmdWindowLayout(
|
||||
hWnd,
|
||||
(data->is_shift ^ data->is_caps)? layout_mod2 : layout_mod1
|
||||
);
|
||||
data->cells[data->active_cell].state = data->is_caps? NH_CST_CHECKED : 0;
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
data->active_cell = -1;
|
||||
}
|
||||
|
||||
int CellFromPoint(PNHCmdWindow data, POINT pt )
|
||||
{
|
||||
int i;
|
||||
for( i=0; i<NH_CMDPAD_CELLNUM; i++ ) {
|
||||
RECT cell_rt;
|
||||
cell_rt.left = data->cells[i].orig.x;
|
||||
cell_rt.top = data->cells[i].orig.y;
|
||||
cell_rt.right = data->cells[i].orig.x + data->cell_size.cx*data->layout[i].mult;
|
||||
cell_rt.bottom = data->cells[i].orig.y + data->cell_size.cy;
|
||||
if( PtInRect(&cell_rt, pt) ) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CalculateCellSize(HWND hWnd, LPSIZE pSize)
|
||||
{
|
||||
HDC hdc;
|
||||
RECT clrt;
|
||||
|
||||
GetClientRect(hWnd, &clrt);
|
||||
|
||||
hdc = GetDC(hWnd);
|
||||
pSize->cx = (clrt.right - clrt.left)/NH_CMDPAD_COLS;
|
||||
pSize->cy = max(pSize->cx, 10*GetDeviceCaps(hdc, LOGPIXELSY)/72);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
}
|
||||
|
||||
void SelectCell(HWND hWnd, int cell, BOOL isSelected)
|
||||
{
|
||||
HDC hDC;
|
||||
PNHCmdWindow data;
|
||||
int prevState;
|
||||
|
||||
data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
prevState = data->cells[cell].state;
|
||||
data->cells[cell].state = (isSelected)? NH_CST_CHECKED : 0;
|
||||
|
||||
if( prevState!=data->cells[cell].state ) {
|
||||
hDC = GetDC(hWnd);
|
||||
PatBlt( hDC,
|
||||
data->cells[cell].orig.x+1,
|
||||
data->cells[cell].orig.y+1,
|
||||
data->cell_size.cx*data->layout[cell].mult - 2,
|
||||
data->cell_size.cy - 2,
|
||||
DSTINVERT
|
||||
);
|
||||
ReleaseDC(hWnd, hDC);
|
||||
}
|
||||
}
|
||||
13
sys/wince/mhcmd.h
Normal file
13
sys/wince/mhcmd.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MSWINCMDWindow_h
|
||||
#define MSWINCMDWindow_h
|
||||
|
||||
#include "winMS.h"
|
||||
#include "config.h"
|
||||
#include "global.h"
|
||||
|
||||
HWND mswin_init_command_window ();
|
||||
void mswin_command_window_size (HWND hwnd, LPSIZE sz);
|
||||
|
||||
#endif /* MSWINCMDWindow_h */
|
||||
217
sys/wince/mhcolor.c
Normal file
217
sys/wince/mhcolor.c
Normal file
@@ -0,0 +1,217 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/* color management and such */
|
||||
|
||||
#include "winMS.h"
|
||||
#include "mhcolor.h"
|
||||
|
||||
#define TOTAL_BRUSHES 10
|
||||
#define NHBRUSH_CODE(win, type) ((((win)&0xFF)<<8)|((type)&0xFF))
|
||||
|
||||
struct t_brush_table {
|
||||
int code;
|
||||
HBRUSH brush;
|
||||
COLORREF color;
|
||||
};
|
||||
static struct t_brush_table brush_table[TOTAL_BRUSHES];
|
||||
static int max_brush = 0;
|
||||
|
||||
static struct t_brush_table default_brush_table[] =
|
||||
{
|
||||
{ NHBRUSH_CODE(NHW_STATUS, MSWIN_COLOR_FG), NULL, RGB(0, 0, 0) },
|
||||
{ NHBRUSH_CODE(NHW_MESSAGE, MSWIN_COLOR_FG), NULL, RGB(0, 0, 0) },
|
||||
{ NHBRUSH_CODE(NHW_STATUS, MSWIN_COLOR_FG), NULL, RGB(0, 0, 0) },
|
||||
{ NHBRUSH_CODE(NHW_TEXT, MSWIN_COLOR_FG), NULL, RGB(0, 0, 0) },
|
||||
{ NHBRUSH_CODE(NHW_KEYPAD, MSWIN_COLOR_FG), NULL, RGB(0, 0, 0) },
|
||||
{ NHBRUSH_CODE(NHW_MAP, MSWIN_COLOR_FG), NULL, RGB(96, 96, 96) },
|
||||
|
||||
{ NHBRUSH_CODE(NHW_MENU, MSWIN_COLOR_BG), NULL, RGB(255, 255, 255) },
|
||||
{ NHBRUSH_CODE(NHW_MESSAGE, MSWIN_COLOR_BG), NULL, RGB(192, 192, 192) },
|
||||
{ NHBRUSH_CODE(NHW_STATUS, MSWIN_COLOR_BG), NULL, RGB(192, 192, 192) },
|
||||
{ NHBRUSH_CODE(NHW_TEXT, MSWIN_COLOR_BG), NULL, RGB(255, 255, 255) },
|
||||
{ NHBRUSH_CODE(NHW_KEYPAD, MSWIN_COLOR_BG), NULL, RGB(255, 255, 255) },
|
||||
{ NHBRUSH_CODE(NHW_MAP, MSWIN_COLOR_BG), NULL, RGB(192, 192, 192) },
|
||||
{ -1, NULL, RGB(0, 0, 0) }
|
||||
};
|
||||
|
||||
static void mswin_color_from_string(char *colorstring, HBRUSH* brushptr, COLORREF *colorptr);
|
||||
|
||||
typedef struct ctv
|
||||
{
|
||||
const char *colorstring;
|
||||
COLORREF colorvalue;
|
||||
} color_table_value;
|
||||
|
||||
/*
|
||||
* The color list here is a combination of:
|
||||
* NetHack colors. (See mhmap.c)
|
||||
* HTML colors. (See http://www.w3.org/TR/REC-html40/types.html#h-6.5 )
|
||||
*/
|
||||
|
||||
static color_table_value color_table[] = {
|
||||
/* NetHack colors */
|
||||
{ "black", RGB(0x55, 0x55, 0x55)},
|
||||
{ "red", RGB(0xFF, 0x00, 0x00)},
|
||||
{ "green", RGB(0x00, 0x80, 0x00)},
|
||||
{ "brown", RGB(0xA5, 0x2A, 0x2A)},
|
||||
{ "blue", RGB(0x00, 0x00, 0xFF)},
|
||||
{ "magenta", RGB(0xFF, 0x00, 0xFF)},
|
||||
{ "cyan", RGB(0x00, 0xFF, 0xFF)},
|
||||
{ "orange", RGB(0xFF, 0xA5, 0x00)},
|
||||
{ "brightgreen", RGB(0x00, 0xFF, 0x00)},
|
||||
{ "yellow", RGB(0xFF, 0xFF, 0x00)},
|
||||
{ "brightblue", RGB(0x00, 0xC0, 0xFF)},
|
||||
{ "brightmagenta", RGB(0xFF, 0x80, 0xFF)},
|
||||
{ "brightcyan", RGB(0x80, 0xFF, 0xFF)},
|
||||
{ "white", RGB(0xFF, 0xFF, 0xFF)},
|
||||
/* Remaining HTML colors */
|
||||
{ "trueblack", RGB(0x00, 0x00, 0x00)},
|
||||
{ "gray", RGB(0x80, 0x80, 0x80)},
|
||||
{ "grey", RGB(0x80, 0x80, 0x80)},
|
||||
{ "purple", RGB(0x80, 0x00, 0x80)},
|
||||
{ "silver", RGB(0xC0, 0xC0, 0xC0)},
|
||||
{ "maroon", RGB(0x80, 0x00, 0x00)},
|
||||
{ "fuchsia", RGB(0xFF, 0x00, 0xFF)}, /* = NetHack magenta */
|
||||
{ "lime", RGB(0x00, 0xFF, 0x00)}, /* = NetHack bright green */
|
||||
{ "olive", RGB(0x80, 0x80, 0x00)},
|
||||
{ "navy", RGB(0x00, 0x00, 0x80)},
|
||||
{ "teal", RGB(0x00, 0x80, 0x80)},
|
||||
{ "aqua", RGB(0x00, 0xFF, 0xFF)}, /* = NetHack cyan */
|
||||
{ "", RGB(0x00, 0x00, 0x00)},
|
||||
};
|
||||
|
||||
typedef struct ctbv
|
||||
{
|
||||
char *colorstring;
|
||||
int syscolorvalue;
|
||||
} color_table_brush_value;
|
||||
|
||||
static color_table_brush_value color_table_brush[] = {
|
||||
{ "activeborder", COLOR_ACTIVEBORDER },
|
||||
{ "activecaption", COLOR_ACTIVECAPTION },
|
||||
{ "appworkspace", COLOR_APPWORKSPACE },
|
||||
{ "background", COLOR_BACKGROUND },
|
||||
{ "btnface", COLOR_BTNFACE },
|
||||
{ "btnshadow", COLOR_BTNSHADOW },
|
||||
{ "btntext", COLOR_BTNTEXT },
|
||||
{ "captiontext", COLOR_CAPTIONTEXT },
|
||||
{ "graytext", COLOR_GRAYTEXT },
|
||||
{ "greytext", COLOR_GRAYTEXT },
|
||||
{ "highlight", COLOR_HIGHLIGHT },
|
||||
{ "highlighttext", COLOR_HIGHLIGHTTEXT },
|
||||
{ "inactiveborder", COLOR_INACTIVEBORDER },
|
||||
{ "inactivecaption", COLOR_INACTIVECAPTION },
|
||||
{ "menu", COLOR_MENU },
|
||||
{ "menutext", COLOR_MENUTEXT },
|
||||
{ "scrollbar", COLOR_SCROLLBAR },
|
||||
{ "window", COLOR_WINDOW },
|
||||
{ "windowframe", COLOR_WINDOWFRAME },
|
||||
{ "windowtext", COLOR_WINDOWTEXT },
|
||||
{ "", -1 },
|
||||
};
|
||||
|
||||
void mswin_init_color_table()
|
||||
{
|
||||
int i;
|
||||
struct t_brush_table* p;
|
||||
|
||||
/* cleanup */
|
||||
for( i=0; i<max_brush; i++ )
|
||||
DeleteObject(brush_table[i].brush);
|
||||
max_brush = 0;
|
||||
|
||||
/* initialize brush table */
|
||||
#define BRUSHTABLE_ENTRY(opt, win, type) \
|
||||
brush_table[max_brush].code = NHBRUSH_CODE((win), (type)); \
|
||||
mswin_color_from_string((opt), &brush_table[max_brush].brush, &brush_table[max_brush].color); \
|
||||
max_brush++;
|
||||
|
||||
BRUSHTABLE_ENTRY(iflags.wc_foregrnd_menu, NHW_MENU, MSWIN_COLOR_FG);
|
||||
BRUSHTABLE_ENTRY(iflags.wc_foregrnd_message, NHW_MESSAGE, MSWIN_COLOR_FG);
|
||||
BRUSHTABLE_ENTRY(iflags.wc_foregrnd_status, NHW_STATUS, MSWIN_COLOR_FG);
|
||||
BRUSHTABLE_ENTRY(iflags.wc_foregrnd_text, NHW_TEXT, MSWIN_COLOR_FG);
|
||||
BRUSHTABLE_ENTRY(iflags.wc_foregrnd_message, NHW_KEYPAD, MSWIN_COLOR_FG);
|
||||
|
||||
BRUSHTABLE_ENTRY(iflags.wc_backgrnd_menu, NHW_MENU, MSWIN_COLOR_BG);
|
||||
BRUSHTABLE_ENTRY(iflags.wc_backgrnd_message, NHW_MESSAGE, MSWIN_COLOR_BG);
|
||||
BRUSHTABLE_ENTRY(iflags.wc_backgrnd_status, NHW_STATUS, MSWIN_COLOR_BG);
|
||||
BRUSHTABLE_ENTRY(iflags.wc_backgrnd_text, NHW_TEXT, MSWIN_COLOR_BG);
|
||||
BRUSHTABLE_ENTRY(iflags.wc_backgrnd_message, NHW_KEYPAD, MSWIN_COLOR_BG);
|
||||
#undef BRUSHTABLE_ENTRY
|
||||
|
||||
/* go through the values and fill in "blanks" (use default values) */
|
||||
for( i=0; i<max_brush; i++ ) {
|
||||
if( !brush_table[i].brush ) {
|
||||
for( p = default_brush_table; p->code != -1; p++ ) {
|
||||
if( p->code==brush_table[i].code ) {
|
||||
brush_table[i].brush = CreateSolidBrush(p->color);
|
||||
brush_table[i].color = p->color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HBRUSH mswin_get_brush(int win_type, int color_index)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<max_brush; i++)
|
||||
if( brush_table[i].code == NHBRUSH_CODE(win_type, color_index) )
|
||||
return brush_table[i].brush;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
COLORREF mswin_get_color(int win_type, int color_index)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<max_brush; i++)
|
||||
if( brush_table[i].code == NHBRUSH_CODE(win_type, color_index) )
|
||||
return brush_table[i].color;
|
||||
return RGB(0, 0, 0);
|
||||
}
|
||||
|
||||
static void mswin_color_from_string(char *colorstring, HBRUSH* brushptr, COLORREF *colorptr)
|
||||
{
|
||||
color_table_value *ctv_ptr = color_table;
|
||||
color_table_brush_value *ctbv_ptr = color_table_brush;
|
||||
int red_value, blue_value, green_value;
|
||||
static char *hexadecimals = "0123456789abcdef";
|
||||
|
||||
*brushptr = NULL;
|
||||
*colorptr = RGB(0, 0, 0);
|
||||
|
||||
if (colorstring == NULL) return;
|
||||
if (*colorstring == '#') {
|
||||
if (strlen(++colorstring) != 6) return;
|
||||
|
||||
red_value = index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
|
||||
red_value *= 16;
|
||||
red_value += index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
|
||||
|
||||
green_value = index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
|
||||
green_value *= 16;
|
||||
green_value += index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
|
||||
|
||||
blue_value = index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
|
||||
blue_value *= 16;
|
||||
blue_value += index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
|
||||
|
||||
*colorptr = RGB(red_value, blue_value, green_value);
|
||||
} else {
|
||||
while (*ctv_ptr->colorstring && _stricmp(ctv_ptr->colorstring, colorstring))
|
||||
++ctv_ptr;
|
||||
if (*ctv_ptr->colorstring) {
|
||||
*colorptr = ctv_ptr->colorvalue;
|
||||
} else {
|
||||
while (*ctbv_ptr->colorstring && _stricmp(ctbv_ptr->colorstring, colorstring))
|
||||
++ctbv_ptr;
|
||||
if (*ctbv_ptr->colorstring) {
|
||||
*brushptr = SYSCLR_TO_BRUSH(ctbv_ptr->syscolorvalue);
|
||||
*colorptr = GetSysColor(ctbv_ptr->syscolorvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (max_brush > TOTAL_BRUSHES) panic("Too many colors!");
|
||||
*brushptr = CreateSolidBrush(*colorptr);
|
||||
}
|
||||
17
sys/wince/mhcolor.h
Normal file
17
sys/wince/mhcolor.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/* color management functions */
|
||||
|
||||
#ifndef MSWINColor_h
|
||||
#define MSWINColor_h
|
||||
|
||||
#define MSWIN_COLOR_BG 0
|
||||
#define MSWIN_COLOR_FG 1
|
||||
#define SYSCLR_TO_BRUSH(x) ((HBRUSH)((x) + 1))
|
||||
|
||||
extern void mswin_init_color_table();
|
||||
extern HBRUSH mswin_get_brush(int win_type, int color_index);
|
||||
extern COLORREF mswin_get_color(int win_type, int color_index);
|
||||
|
||||
#endif /* MSWINColor_h */
|
||||
733
sys/wince/mhdlg.c
Normal file
733
sys/wince/mhdlg.c
Normal file
@@ -0,0 +1,733 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/* various dialog boxes are defined here */
|
||||
|
||||
#include "winMS.h"
|
||||
#include "hack.h"
|
||||
#include "func_tab.h"
|
||||
#include "resource.h"
|
||||
#include "mhdlg.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 */
|
||||
struct getlin_data {
|
||||
const char* question;
|
||||
char* result;
|
||||
size_t result_size;
|
||||
};
|
||||
|
||||
LRESULT CALLBACK GetlinDlgProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
int mswin_getlin_window (
|
||||
const char *question,
|
||||
char *result,
|
||||
size_t result_size
|
||||
)
|
||||
{
|
||||
int ret;
|
||||
struct getlin_data data;
|
||||
|
||||
/* initilize dialog data */
|
||||
ZeroMemory(&data, sizeof(data));
|
||||
data.question = question;
|
||||
data.result = result;
|
||||
data.result_size = result_size;
|
||||
|
||||
/* create modal dialog window */
|
||||
ret = DialogBoxParam(
|
||||
GetNHApp()->hApp,
|
||||
MAKEINTRESOURCE(IDD_GETLIN),
|
||||
GetNHApp()->hMainWnd,
|
||||
GetlinDlgProc,
|
||||
(LPARAM)&data
|
||||
);
|
||||
if( ret==-1 ) panic("Cannot create getlin window");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
struct getlin_data* data;
|
||||
RECT main_rt, text_rt, dlg_rt, edit_rt;
|
||||
SIZE dlg_sz;
|
||||
TCHAR wbuf[BUFSZ];
|
||||
HDC hdc;
|
||||
HWND control;
|
||||
|
||||
#ifndef WIN_CE_2xx
|
||||
SHInputDialog(hWnd, message, wParam);
|
||||
#endif
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
data = (struct getlin_data*)lParam;
|
||||
SetWindowText(hWnd, NH_A2W(data->question, wbuf, sizeof(wbuf)));
|
||||
SetWindowLong(hWnd, GWL_USERDATA, lParam);
|
||||
|
||||
/* get title text width */
|
||||
SetRect(&text_rt, 0, 0, 100, 50);
|
||||
hdc = GetWindowDC(hWnd);
|
||||
DrawText(hdc, wbuf, _tcslen(wbuf), &text_rt,
|
||||
DT_CALCRECT | DT_SINGLELINE | DT_NOPREFIX | DT_LEFT | DT_VCENTER );
|
||||
ReleaseDC(hWnd, hdc);
|
||||
|
||||
/* center dialog in the main window */
|
||||
GetWindowRect(hWnd, &dlg_rt);
|
||||
GetWindowRect(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_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;
|
||||
dlg_rt.bottom = dlg_rt.top + dlg_sz.cy;
|
||||
MoveWindow( hWnd,
|
||||
(main_rt.left+main_rt.right-dlg_sz.cx)/2,
|
||||
(main_rt.top+main_rt.bottom-dlg_sz.cy)/2,
|
||||
dlg_sz.cx,
|
||||
dlg_sz.cy,
|
||||
TRUE );
|
||||
|
||||
/* change layout of controls */
|
||||
GetClientRect(hWnd, &dlg_rt);
|
||||
|
||||
control = GetDlgItem(hWnd, IDC_GETLIN_EDIT);
|
||||
GetWindowRect(control, &edit_rt);
|
||||
MoveWindow( control,
|
||||
0,
|
||||
0,
|
||||
dlg_rt.right - dlg_rt.left,
|
||||
edit_rt.bottom - edit_rt.top,
|
||||
TRUE );
|
||||
|
||||
control = GetDlgItem(hWnd, IDOK);
|
||||
GetWindowRect(control, &text_rt);
|
||||
MoveWindow( control,
|
||||
0,
|
||||
edit_rt.bottom - edit_rt.top,
|
||||
(dlg_rt.right-dlg_rt.left)/2,
|
||||
text_rt.bottom - text_rt.top,
|
||||
TRUE );
|
||||
|
||||
control = GetDlgItem(hWnd, IDCANCEL);
|
||||
GetWindowRect(control, &text_rt);
|
||||
MoveWindow( control,
|
||||
(dlg_rt.right-dlg_rt.left)/2,
|
||||
edit_rt.bottom - edit_rt.top,
|
||||
(dlg_rt.right-dlg_rt.left)/2,
|
||||
text_rt.bottom - text_rt.top,
|
||||
TRUE );
|
||||
|
||||
/* set focus to the edit control */
|
||||
SetFocus(GetDlgItem(hWnd, IDC_GETLIN_EDIT));
|
||||
|
||||
/* tell windows that we've set the focus */
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
TCHAR wbuf[BUFSZ];
|
||||
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
/* OK button was pressed */
|
||||
case IDOK:
|
||||
data = (struct getlin_data*)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
SendDlgItemMessage(hWnd, IDC_GETLIN_EDIT, WM_GETTEXT, (WPARAM)sizeof(wbuf), (LPARAM)wbuf );
|
||||
NH_W2A(wbuf, data->result, data->result_size);
|
||||
|
||||
/* Fall through. */
|
||||
|
||||
/* cancel button was pressed */
|
||||
case IDCANCEL:
|
||||
EndDialog(hWnd, wParam);
|
||||
return TRUE;
|
||||
}
|
||||
} break;
|
||||
|
||||
} /* end switch (message) */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------*/
|
||||
/* dialog data for the list of extended commands */
|
||||
struct extcmd_data {
|
||||
int* selection;
|
||||
};
|
||||
|
||||
LRESULT CALLBACK ExtCmdDlgProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
int mswin_ext_cmd_window (int* selection)
|
||||
{
|
||||
int ret;
|
||||
struct extcmd_data data;
|
||||
|
||||
/* init dialog data */
|
||||
ZeroMemory(&data, sizeof(data));
|
||||
*selection = -1;
|
||||
data.selection = selection;
|
||||
|
||||
/* create modal dialog window */
|
||||
ret = DialogBoxParam(
|
||||
GetNHApp()->hApp,
|
||||
MAKEINTRESOURCE(IDD_EXTCMD),
|
||||
GetNHApp()->hMainWnd,
|
||||
ExtCmdDlgProc,
|
||||
(LPARAM)&data
|
||||
);
|
||||
if( ret==-1 ) panic("Cannot create extcmd window");
|
||||
return ret;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK ExtCmdDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
struct extcmd_data* data;
|
||||
RECT main_rt, dlg_rt;
|
||||
SIZE dlg_sz;
|
||||
int i;
|
||||
const char *ptr;
|
||||
TCHAR wbuf[255];
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
data = (struct extcmd_data*)lParam;
|
||||
SetWindowLong(hWnd, GWL_USERDATA, lParam);
|
||||
|
||||
/* center dialog in the main window */
|
||||
GetWindowRect(GetNHApp()->hMainWnd, &main_rt);
|
||||
GetWindowRect(hWnd, &dlg_rt);
|
||||
dlg_sz.cx = dlg_rt.right - dlg_rt.left;
|
||||
dlg_sz.cy = dlg_rt.bottom - dlg_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;
|
||||
dlg_rt.bottom = dlg_rt.top + dlg_sz.cy;
|
||||
MoveWindow( hWnd,
|
||||
(main_rt.left+main_rt.right-dlg_sz.cx)/2,
|
||||
(main_rt.top+main_rt.bottom-dlg_sz.cy)/2,
|
||||
dlg_sz.cx,
|
||||
dlg_sz.cy,
|
||||
TRUE );
|
||||
|
||||
/* fill combobox with extended commands */
|
||||
for(i=0; (ptr=extcmdlist[i].ef_txt); i++) {
|
||||
SendDlgItemMessage(hWnd, IDC_EXTCMD_LIST, LB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(ptr, wbuf, sizeof(wbuf)) );
|
||||
}
|
||||
|
||||
/* set focus to the list control */
|
||||
SetFocus(GetDlgItem(hWnd, IDC_EXTCMD_LIST));
|
||||
|
||||
/* tell windows we set the focus */
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
data = (struct extcmd_data*)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
/* OK button ws clicked */
|
||||
case IDOK:
|
||||
*data->selection = SendDlgItemMessage(hWnd, IDC_EXTCMD_LIST, LB_GETCURSEL, (WPARAM)0, (LPARAM)0 );
|
||||
if( *data->selection==LB_ERR )
|
||||
*data->selection = -1;
|
||||
/* Fall through. */
|
||||
|
||||
/* CANCEL button ws clicked */
|
||||
case IDCANCEL:
|
||||
EndDialog(hWnd, wParam);
|
||||
return TRUE;
|
||||
|
||||
/* list control events */
|
||||
case IDC_EXTCMD_LIST:
|
||||
switch(HIWORD(wParam)) {
|
||||
|
||||
case LBN_DBLCLK:
|
||||
/* double click within the list
|
||||
wParam
|
||||
The low-order word is the list box identifier.
|
||||
The high-order word is the notification message.
|
||||
lParam
|
||||
Handle to the list box
|
||||
*/
|
||||
*data->selection = SendMessage((HWND)lParam, LB_GETCURSEL, (WPARAM)0, (LPARAM)0);
|
||||
if( *data->selection==LB_ERR )
|
||||
*data->selection = -1;
|
||||
EndDialog(hWnd, IDOK);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------*/
|
||||
/* player selector dialog data */
|
||||
struct plsel_data {
|
||||
int* selection;
|
||||
};
|
||||
|
||||
BOOL CALLBACK PlayerSelectorDlgProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static void plselInitDialog(HWND hWnd);
|
||||
static void plselAdjustLists(HWND hWnd, int changed_opt);
|
||||
static int plselFinalSelection(HWND hWnd, int* selection);
|
||||
|
||||
int mswin_player_selection_window ( int* selection )
|
||||
{
|
||||
int ret;
|
||||
struct plsel_data data;
|
||||
|
||||
/* init dialog data */
|
||||
ZeroMemory(&data, sizeof(data));
|
||||
data.selection = selection;
|
||||
|
||||
/* create modal dialog */
|
||||
ret = DialogBoxParam(
|
||||
GetNHApp()->hApp,
|
||||
MAKEINTRESOURCE(IDD_PLAYER_SELECTOR),
|
||||
GetNHApp()->hMainWnd,
|
||||
PlayerSelectorDlgProc,
|
||||
(LPARAM)&data
|
||||
);
|
||||
if( ret==-1 ) panic("Cannot create getlin window");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL CALLBACK PlayerSelectorDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
struct plsel_data* data;
|
||||
RECT main_rt, dlg_rt;
|
||||
SIZE dlg_sz;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
data = (struct plsel_data*)lParam;
|
||||
SetWindowLong(hWnd, GWL_USERDATA, lParam);
|
||||
|
||||
/* center dialog in the main window */
|
||||
GetWindowRect(GetNHApp()->hMainWnd, &main_rt);
|
||||
GetWindowRect(hWnd, &dlg_rt);
|
||||
dlg_sz.cx = dlg_rt.right - dlg_rt.left;
|
||||
dlg_sz.cy = dlg_rt.bottom - dlg_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;
|
||||
dlg_rt.bottom = dlg_rt.top + dlg_sz.cy;
|
||||
MoveWindow( hWnd,
|
||||
(main_rt.left+main_rt.right-dlg_sz.cx)/2,
|
||||
(main_rt.top+main_rt.bottom-dlg_sz.cy)/2,
|
||||
dlg_sz.cx,
|
||||
dlg_sz.cy,
|
||||
TRUE );
|
||||
|
||||
/* init dialog */
|
||||
plselInitDialog(hWnd);
|
||||
|
||||
/* set focus on the role checkbox (random) field */
|
||||
SetFocus(GetDlgItem(hWnd, IDC_PLSEL_ROLE_RANDOM));
|
||||
|
||||
/* tell windows we set the focus */
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
data = (struct plsel_data*)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
switch (LOWORD(wParam)) {
|
||||
|
||||
/* OK button was clicked */
|
||||
case IDOK:
|
||||
if( plselFinalSelection(hWnd, data->selection) ) {
|
||||
EndDialog(hWnd, wParam);
|
||||
} else {
|
||||
MessageBox(hWnd, TEXT("Cannot match this role. Try something else."), TEXT("STOP"), MB_OK );
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
/* CANCEL button was clicked */
|
||||
case IDCANCEL:
|
||||
*data->selection = -1;
|
||||
EndDialog(hWnd, wParam);
|
||||
return TRUE;
|
||||
|
||||
/* following are events from dialog controls:
|
||||
"random" checkboxes send BN_CLICKED messages;
|
||||
role/race/... combo-boxes send CBN_SELENDOK
|
||||
if something was selected;
|
||||
*/
|
||||
case IDC_PLSEL_ROLE_RANDOM:
|
||||
if( HIWORD(wParam)==BN_CLICKED ) {
|
||||
/* enable corresponding list window if "random"
|
||||
checkbox was "unchecked" */
|
||||
EnableWindow(
|
||||
GetDlgItem(hWnd, IDC_PLSEL_ROLE_LIST),
|
||||
SendMessage((HWND)lParam, BM_GETCHECK, 0, 0)==BST_UNCHECKED
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_PLSEL_RACE_RANDOM:
|
||||
if( HIWORD(wParam)==BN_CLICKED ) {
|
||||
EnableWindow(
|
||||
GetDlgItem(hWnd, IDC_PLSEL_RACE_LIST),
|
||||
SendMessage((HWND)lParam, BM_GETCHECK, 0, 0)==BST_UNCHECKED
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_PLSEL_GENDER_RANDOM:
|
||||
if( HIWORD(wParam)==BN_CLICKED ) {
|
||||
EnableWindow(
|
||||
GetDlgItem(hWnd, IDC_PLSEL_GENDER_LIST),
|
||||
SendMessage((HWND)lParam, BM_GETCHECK, 0, 0)==BST_UNCHECKED
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_PLSEL_ALIGN_RANDOM:
|
||||
if( HIWORD(wParam)==BN_CLICKED ) {
|
||||
EnableWindow(
|
||||
GetDlgItem(hWnd, IDC_PLSEL_ALIGN_LIST),
|
||||
SendMessage((HWND)lParam, BM_GETCHECK, 0, 0)==BST_UNCHECKED
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_PLSEL_ROLE_LIST:
|
||||
if( HIWORD(wParam)==CBN_SELENDOK ) {
|
||||
/* filter out invalid options if
|
||||
the selection was made */
|
||||
plselAdjustLists( hWnd, LOWORD(wParam) );
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_PLSEL_RACE_LIST:
|
||||
if( HIWORD(wParam)==CBN_SELENDOK ) {
|
||||
plselAdjustLists( hWnd, LOWORD(wParam) );
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_PLSEL_GENDER_LIST:
|
||||
if( HIWORD(wParam)==CBN_SELENDOK ) {
|
||||
plselAdjustLists( hWnd, LOWORD(wParam) );
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_PLSEL_ALIGN_LIST:
|
||||
if( HIWORD(wParam)==CBN_SELENDOK ) {
|
||||
plselAdjustLists( hWnd, LOWORD(wParam) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* initialize player selector dialog */
|
||||
void plselInitDialog(HWND hWnd)
|
||||
{
|
||||
TCHAR wbuf[BUFSZ];
|
||||
|
||||
/* set player name */
|
||||
SetDlgItemText(hWnd, IDC_PLSEL_NAME, NH_A2W(plname, wbuf, sizeof(wbuf)));
|
||||
|
||||
plselAdjustLists(hWnd, -1);
|
||||
|
||||
/* intialize roles list */
|
||||
if( flags.initrole<0 || !ok_role(flags.initrole, ROLE_NONE, ROLE_NONE, ROLE_NONE)) {
|
||||
CheckDlgButton(hWnd, IDC_PLSEL_ROLE_RANDOM, BST_CHECKED);
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_PLSEL_ROLE_LIST), FALSE);
|
||||
} else {
|
||||
CheckDlgButton(hWnd, IDC_PLSEL_ROLE_RANDOM, BST_UNCHECKED);
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_PLSEL_ROLE_LIST), TRUE);
|
||||
SendDlgItemMessage(hWnd, IDC_PLSEL_ROLE_LIST, CB_SETCURSEL, (WPARAM)flags.initrole, 0);
|
||||
}
|
||||
|
||||
/* intialize races list */
|
||||
if( flags.initrace<0 || !ok_race(flags.initrole, flags.initrace, ROLE_NONE, ROLE_NONE) ) {
|
||||
CheckDlgButton(hWnd, IDC_PLSEL_RACE_RANDOM, BST_CHECKED);
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_PLSEL_RACE_LIST), FALSE);
|
||||
} else {
|
||||
CheckDlgButton(hWnd, IDC_PLSEL_RACE_RANDOM, BST_UNCHECKED);
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_PLSEL_RACE_LIST), TRUE);
|
||||
SendDlgItemMessage(hWnd, IDC_PLSEL_RACE_LIST, CB_SETCURSEL, (WPARAM)flags.initrace, 0);
|
||||
}
|
||||
|
||||
/* intialize genders list */
|
||||
if( flags.initgend<0 || !ok_gend(flags.initrole, flags.initrace, flags.initgend, ROLE_NONE)) {
|
||||
CheckDlgButton(hWnd, IDC_PLSEL_GENDER_RANDOM, BST_CHECKED);
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_PLSEL_GENDER_LIST), FALSE);
|
||||
} else {
|
||||
CheckDlgButton(hWnd, IDC_PLSEL_GENDER_RANDOM, BST_UNCHECKED);
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_PLSEL_GENDER_LIST), TRUE);
|
||||
SendDlgItemMessage(hWnd, IDC_PLSEL_GENDER_LIST, CB_SETCURSEL, (WPARAM)flags.initgend, 0);
|
||||
}
|
||||
|
||||
/* intialize alignments list */
|
||||
if( flags.initalign<0 || !ok_align(flags.initrole, flags.initrace, flags.initgend, flags.initalign) ) {
|
||||
CheckDlgButton(hWnd, IDC_PLSEL_ALIGN_RANDOM, BST_CHECKED);
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_PLSEL_ALIGN_LIST), FALSE);
|
||||
} else {
|
||||
CheckDlgButton(hWnd, IDC_PLSEL_ALIGN_RANDOM, BST_UNCHECKED);
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_PLSEL_ALIGN_LIST), TRUE);
|
||||
SendDlgItemMessage(hWnd, IDC_PLSEL_ALIGN_LIST, CB_SETCURSEL, (WPARAM)flags.initalign, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* adjust role/race/alignment/gender list - filter out
|
||||
invalid combinations
|
||||
changed_sel points to the list where selection occured
|
||||
(-1 if unknown)
|
||||
*/
|
||||
void plselAdjustLists(HWND hWnd, int changed_sel)
|
||||
{
|
||||
HWND control_role, control_race, control_gender, control_align;
|
||||
int initrole, initrace, initgend, initalign;
|
||||
int i;
|
||||
int ind;
|
||||
int valid_opt;
|
||||
TCHAR wbuf[255];
|
||||
|
||||
/* get control handles */
|
||||
control_role = GetDlgItem(hWnd, IDC_PLSEL_ROLE_LIST);
|
||||
control_race = GetDlgItem(hWnd, IDC_PLSEL_RACE_LIST);
|
||||
control_gender = GetDlgItem(hWnd, IDC_PLSEL_GENDER_LIST);
|
||||
control_align = GetDlgItem(hWnd, IDC_PLSEL_ALIGN_LIST);
|
||||
|
||||
/* get current selections */
|
||||
ind = SendMessage(control_role, CB_GETCURSEL, 0, 0);
|
||||
initrole = (ind==LB_ERR)? ROLE_NONE : SendMessage(control_role, CB_GETITEMDATA, ind, 0);
|
||||
|
||||
ind = SendMessage(control_race, CB_GETCURSEL, 0, 0);
|
||||
initrace = (ind==LB_ERR)? ROLE_NONE : SendMessage(control_race, CB_GETITEMDATA, ind, 0);
|
||||
|
||||
ind = SendMessage(control_gender, CB_GETCURSEL, 0, 0);
|
||||
initgend = (ind==LB_ERR)? ROLE_NONE : SendMessage(control_gender, CB_GETITEMDATA, ind, 0);
|
||||
|
||||
ind = SendMessage(control_align, CB_GETCURSEL, 0, 0);
|
||||
initalign = (ind==LB_ERR)? ROLE_NONE : SendMessage(control_align, CB_GETITEMDATA, ind, 0);
|
||||
|
||||
/* intialize roles list */
|
||||
if( changed_sel==-1 ) {
|
||||
valid_opt = 0;
|
||||
|
||||
/* reset content and populate the list */
|
||||
SendMessage(control_role, CB_RESETCONTENT, 0, 0);
|
||||
for (i = 0; roles[i].name.m; i++) {
|
||||
if (ok_role(i, initrace, initgend, initalign)) {
|
||||
if (initgend>=0 && flags.female && roles[i].name.f)
|
||||
ind = SendMessage(control_role, CB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(roles[i].name.f, wbuf, sizeof(wbuf)) );
|
||||
else
|
||||
ind = SendMessage(control_role, CB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(roles[i].name.m, wbuf, sizeof(wbuf)) );
|
||||
|
||||
SendMessage(control_role, CB_SETITEMDATA, (WPARAM)ind, (LPARAM)i );
|
||||
if( i==initrole ) {
|
||||
SendMessage(control_role, CB_SETCURSEL, (WPARAM)ind, (LPARAM)0 );
|
||||
valid_opt = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* set selection to the previously selected role
|
||||
if it is still valid */
|
||||
if( !valid_opt ) {
|
||||
initrole = ROLE_NONE;
|
||||
initrace = ROLE_NONE;
|
||||
initgend = ROLE_NONE;
|
||||
initalign = ROLE_NONE;
|
||||
SendMessage(control_role, CB_SETCURSEL, (WPARAM)-1, (LPARAM)0 );
|
||||
}
|
||||
|
||||
/* trigger change of the races list */
|
||||
changed_sel=IDC_PLSEL_ROLE_LIST;
|
||||
}
|
||||
|
||||
/* intialize races list */
|
||||
if( changed_sel==IDC_PLSEL_ROLE_LIST ) {
|
||||
valid_opt = 0;
|
||||
|
||||
/* reset content and populate the list */
|
||||
SendMessage(control_race, CB_RESETCONTENT, 0, 0);
|
||||
for (i = 0; races[i].noun; i++)
|
||||
if (ok_race(initrole, i, ROLE_NONE, ROLE_NONE)) {
|
||||
ind = SendMessage(control_race, CB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(races[i].noun, wbuf, sizeof(wbuf)) );
|
||||
SendMessage(control_race, CB_SETITEMDATA, (WPARAM)ind, (LPARAM)i );
|
||||
if( i==initrace ) {
|
||||
SendMessage(control_race, CB_SETCURSEL, (WPARAM)ind, (LPARAM)0 );
|
||||
valid_opt = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* set selection to the previously selected race
|
||||
if it is still valid */
|
||||
if( !valid_opt ) {
|
||||
initrace = ROLE_NONE;
|
||||
initgend = ROLE_NONE;
|
||||
initalign = ROLE_NONE;
|
||||
SendMessage(control_race, CB_SETCURSEL, (WPARAM)-1, (LPARAM)0 );
|
||||
}
|
||||
|
||||
/* trigger change of the genders list */
|
||||
changed_sel=IDC_PLSEL_RACE_LIST;
|
||||
}
|
||||
|
||||
/* intialize genders list */
|
||||
if( changed_sel==IDC_PLSEL_RACE_LIST ) {
|
||||
valid_opt = 0;
|
||||
|
||||
/* reset content and populate the list */
|
||||
SendMessage(control_gender, CB_RESETCONTENT, 0, 0);
|
||||
for (i = 0; i < ROLE_GENDERS; i++)
|
||||
if (ok_gend(initrole, initrace, i, ROLE_NONE)) {
|
||||
ind = SendMessage(control_gender, CB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(genders[i].adj, wbuf, sizeof(wbuf)) );
|
||||
SendMessage(control_gender, CB_SETITEMDATA, (WPARAM)ind, (LPARAM)i );
|
||||
if( i==initgend ) {
|
||||
SendMessage(control_gender, CB_SETCURSEL, (WPARAM)ind, (LPARAM)0 );
|
||||
}
|
||||
}
|
||||
|
||||
/* set selection to the previously selected gender
|
||||
if it is still valid */
|
||||
if( !valid_opt ) {
|
||||
initgend = ROLE_NONE;
|
||||
initalign = ROLE_NONE;
|
||||
SendMessage(control_gender, CB_SETCURSEL, (WPARAM)-1, (LPARAM)0 );
|
||||
}
|
||||
|
||||
/* trigger change of the alignments list */
|
||||
changed_sel=IDC_PLSEL_GENDER_LIST;
|
||||
}
|
||||
|
||||
/* intialize alignments list */
|
||||
if( changed_sel==IDC_PLSEL_GENDER_LIST ) {
|
||||
valid_opt = 0;
|
||||
|
||||
/* reset content and populate the list */
|
||||
SendMessage(control_align, CB_RESETCONTENT, 0, 0);
|
||||
for (i = 0; i < ROLE_ALIGNS; i++)
|
||||
if (ok_align(initrole, initrace, initgend, i)) {
|
||||
ind = SendMessage(control_align, CB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(aligns[i].adj, wbuf, sizeof(wbuf)) );
|
||||
SendMessage(control_align, CB_SETITEMDATA, (WPARAM)ind, (LPARAM)i );
|
||||
if( i==initalign ) {
|
||||
SendMessage(control_align, CB_SETCURSEL, (WPARAM)ind, (LPARAM)0 );
|
||||
valid_opt = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* set selection to the previously selected alignment
|
||||
if it is still valid */
|
||||
if( !valid_opt ) {
|
||||
initalign = ROLE_NONE;
|
||||
SendMessage(control_align, CB_SETCURSEL, (WPARAM)-1, (LPARAM)0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* player made up his mind - get final selection here */
|
||||
int plselFinalSelection(HWND hWnd, int* selection)
|
||||
{
|
||||
int ind;
|
||||
|
||||
/* get current selections */
|
||||
if( SendDlgItemMessage(hWnd, IDC_PLSEL_ROLE_RANDOM, BM_GETCHECK, 0, 0)==BST_CHECKED ) {
|
||||
flags.initrole = ROLE_RANDOM;
|
||||
} else {
|
||||
ind = SendDlgItemMessage(hWnd, IDC_PLSEL_ROLE_LIST, CB_GETCURSEL, 0, 0);
|
||||
flags.initrole = (ind==LB_ERR)? ROLE_RANDOM : SendDlgItemMessage(hWnd, IDC_PLSEL_ROLE_LIST, CB_GETITEMDATA, ind, 0);
|
||||
}
|
||||
|
||||
if( SendDlgItemMessage(hWnd, IDC_PLSEL_RACE_RANDOM, BM_GETCHECK, 0, 0)==BST_CHECKED ) {
|
||||
flags.initrace = ROLE_RANDOM;
|
||||
} else {
|
||||
ind = SendDlgItemMessage(hWnd, IDC_PLSEL_RACE_LIST, CB_GETCURSEL, 0, 0);
|
||||
flags.initrace = (ind==LB_ERR)? ROLE_RANDOM : SendDlgItemMessage(hWnd, IDC_PLSEL_RACE_LIST, CB_GETITEMDATA, ind, 0);
|
||||
}
|
||||
|
||||
if( SendDlgItemMessage(hWnd, IDC_PLSEL_GENDER_RANDOM, BM_GETCHECK, 0, 0)==BST_CHECKED ) {
|
||||
flags.initgend = ROLE_RANDOM;
|
||||
} else {
|
||||
ind = SendDlgItemMessage(hWnd, IDC_PLSEL_GENDER_LIST, CB_GETCURSEL, 0, 0);
|
||||
flags.initgend = (ind==LB_ERR)? ROLE_RANDOM : SendDlgItemMessage(hWnd, IDC_PLSEL_GENDER_LIST, CB_GETITEMDATA, ind, 0);
|
||||
}
|
||||
|
||||
if( SendDlgItemMessage(hWnd, IDC_PLSEL_ALIGN_RANDOM, BM_GETCHECK, 0, 0)==BST_CHECKED ) {
|
||||
flags.initalign = ROLE_RANDOM;
|
||||
} else {
|
||||
ind = SendDlgItemMessage(hWnd, IDC_PLSEL_ALIGN_LIST, CB_GETCURSEL, 0, 0);
|
||||
flags.initalign = (ind==LB_ERR)? ROLE_RANDOM : SendDlgItemMessage(hWnd, IDC_PLSEL_ALIGN_LIST, CB_GETITEMDATA, ind, 0);
|
||||
}
|
||||
|
||||
|
||||
/* check the role */
|
||||
if( flags.initrole==ROLE_RANDOM ) {
|
||||
flags.initrole = pick_role(flags.initrace, flags.initgend, flags.initalign, PICK_RANDOM);
|
||||
if (flags.initrole < 0) {
|
||||
MessageBox(hWnd, TEXT("Incompatible role!"), TEXT("STOP"), MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Select a race, if necessary */
|
||||
/* force compatibility with role */
|
||||
if (flags.initrace==ROLE_RANDOM || !validrace(flags.initrole, flags.initrace)) {
|
||||
/* pre-selected race not valid */
|
||||
if (flags.initrace == ROLE_RANDOM) {
|
||||
flags.initrace = pick_race(flags.initrole, flags.initgend, flags.initalign, PICK_RANDOM);
|
||||
}
|
||||
|
||||
if (flags.initrace < 0) {
|
||||
MessageBox(hWnd, TEXT("Incompatible race!"), TEXT("STOP"), MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Select a gender, if necessary */
|
||||
/* force compatibility with role/race, try for compatibility with
|
||||
* pre-selected alignment */
|
||||
if (flags.initgend < 0 ||
|
||||
!validgend(flags.initrole, flags.initrace, flags.initgend)) {
|
||||
/* pre-selected gender not valid */
|
||||
if (flags.initgend == ROLE_RANDOM) {
|
||||
flags.initgend = pick_gend(flags.initrole, flags.initrace, flags.initalign, PICK_RANDOM);
|
||||
}
|
||||
|
||||
if (flags.initgend < 0) {
|
||||
MessageBox(hWnd, TEXT("Incompatible gender!"), TEXT("STOP"), MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Select an alignment, if necessary */
|
||||
/* force compatibility with role/race/gender */
|
||||
if (flags.initalign < 0 ||
|
||||
!validalign(flags.initrole, flags.initrace, flags.initalign)) {
|
||||
/* pre-selected alignment not valid */
|
||||
if (flags.initalign == ROLE_RANDOM) {
|
||||
flags.initalign = pick_align(flags.initrole, flags.initrace, flags.initgend, PICK_RANDOM);
|
||||
} else {
|
||||
MessageBox(hWnd, TEXT("Incompatible alignment!"), TEXT("STOP"), MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
15
sys/wince/mhdlg.h
Normal file
15
sys/wince/mhdlg.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MSWINDlgWindow_h
|
||||
#define MSWINDlgWindow_h
|
||||
|
||||
#include "winMS.h"
|
||||
#include "config.h"
|
||||
#include "global.h"
|
||||
|
||||
int mswin_getlin_window (const char *question, char *result, size_t result_size);
|
||||
int mswin_ext_cmd_window (int* selection);
|
||||
int mswin_player_selection_window(int* selection);
|
||||
|
||||
#endif /* MSWINDlgWindow_h */
|
||||
164
sys/wince/mhfont.c
Normal file
164
sys/wince/mhfont.c
Normal file
@@ -0,0 +1,164 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/* font management and such */
|
||||
|
||||
#include "mhfont.h"
|
||||
|
||||
#define MAXFONTS 64
|
||||
|
||||
/* font table - 64 fonts ought to be enough */
|
||||
static struct font_table_entry {
|
||||
int code;
|
||||
HFONT hFont;
|
||||
} font_table[MAXFONTS] ;
|
||||
static int font_table_size = 0;
|
||||
|
||||
#define NHFONT_CODE(win, attr) ((((win)&0xFF)<<8)|((attr)&0xFF))
|
||||
|
||||
static void __cdecl font_table_cleanup(void);
|
||||
|
||||
/* create font based on window type, charater attributes and
|
||||
window device context */
|
||||
HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace)
|
||||
{
|
||||
HFONT fnt = NULL;
|
||||
LOGFONT lgfnt;
|
||||
int font_size;
|
||||
int font_index;
|
||||
static BOOL once = FALSE;
|
||||
|
||||
if( !once ) {
|
||||
once = TRUE;
|
||||
atexit(font_table_cleanup);
|
||||
}
|
||||
|
||||
ZeroMemory( &lgfnt, sizeof(lgfnt) );
|
||||
|
||||
/* try find font in the table */
|
||||
for(font_index=0; font_index<font_table_size; font_index++)
|
||||
if(NHFONT_CODE(win_type, attr)==font_table[font_index].code)
|
||||
break;
|
||||
|
||||
if( !replace && font_index<font_table_size )
|
||||
return font_table[font_index].hFont;
|
||||
|
||||
switch(win_type) {
|
||||
case NHW_STATUS:
|
||||
lgfnt.lfHeight = -iflags.wc_fontsiz_status*GetDeviceCaps(hdc, LOGPIXELSY)/72; // height of font
|
||||
lgfnt.lfWidth = 0; // average character width
|
||||
lgfnt.lfEscapement = 0; // angle of escapement
|
||||
lgfnt.lfOrientation = 0; // base-line orientation angle
|
||||
lgfnt.lfWeight = FW_NORMAL; // font weight
|
||||
lgfnt.lfItalic = FALSE; // italic attribute option
|
||||
lgfnt.lfUnderline = FALSE; // underline attribute option
|
||||
lgfnt.lfStrikeOut = FALSE; // strikeout attribute option
|
||||
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;
|
||||
|
||||
case NHW_MENU:
|
||||
lgfnt.lfHeight = -iflags.wc_fontsiz_menu*GetDeviceCaps(hdc, LOGPIXELSY)/72; // height of font
|
||||
lgfnt.lfWidth = 0; // average character width
|
||||
lgfnt.lfEscapement = 0; // angle of escapement
|
||||
lgfnt.lfOrientation = 0; // base-line orientation angle
|
||||
lgfnt.lfWeight = (attr==ATR_BOLD || attr==ATR_INVERSE)? FW_BOLD : FW_NORMAL; // font weight
|
||||
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.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
|
||||
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
|
||||
}
|
||||
break;
|
||||
|
||||
case NHW_MESSAGE:
|
||||
font_size = (attr==ATR_INVERSE)? iflags.wc_fontsiz_message+1 : iflags.wc_fontsiz_message;
|
||||
lgfnt.lfHeight = -font_size*GetDeviceCaps(hdc, LOGPIXELSY)/72; // height of font
|
||||
lgfnt.lfWidth = 0; // average character width
|
||||
lgfnt.lfEscapement = 0; // angle of escapement
|
||||
lgfnt.lfOrientation = 0; // base-line orientation angle
|
||||
lgfnt.lfWeight = (attr==ATR_BOLD || attr==ATR_INVERSE)? FW_BOLD : FW_NORMAL; // font weight
|
||||
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.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
|
||||
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
|
||||
}
|
||||
break;
|
||||
|
||||
case NHW_TEXT:
|
||||
lgfnt.lfHeight = -iflags.wc_fontsiz_text*GetDeviceCaps(hdc, LOGPIXELSY)/72; // height of font
|
||||
lgfnt.lfWidth = 0; // average character width
|
||||
lgfnt.lfEscapement = 0; // angle of escapement
|
||||
lgfnt.lfOrientation = 0; // base-line orientation angle
|
||||
lgfnt.lfWeight = (attr==ATR_BOLD || attr==ATR_INVERSE)? FW_BOLD : FW_NORMAL; // font weight
|
||||
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.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
|
||||
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
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
fnt = CreateFontIndirect(&lgfnt);
|
||||
|
||||
/* add font to the table */
|
||||
if( font_index==font_table_size ) {
|
||||
if( font_table_size>=MAXFONTS ) panic( "font table overflow!" );
|
||||
font_table_size++;
|
||||
} else {
|
||||
DeleteObject(font_table[font_index].hFont);
|
||||
}
|
||||
|
||||
font_table[font_index].code = NHFONT_CODE(win_type, attr);
|
||||
font_table[font_index].hFont = fnt;
|
||||
return fnt;
|
||||
}
|
||||
|
||||
void __cdecl font_table_cleanup(void)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<font_table_size; i++) {
|
||||
DeleteObject(font_table[i].hFont);
|
||||
}
|
||||
font_table_size = 0;
|
||||
}
|
||||
|
||||
13
sys/wince/mhfont.h
Normal file
13
sys/wince/mhfont.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/* font management functions */
|
||||
|
||||
#ifndef MSWINFont_h
|
||||
#define MSWINFont_h
|
||||
|
||||
#include "winMS.h"
|
||||
|
||||
HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace);
|
||||
|
||||
#endif /* MSWINFont_h */
|
||||
85
sys/wince/mhinput.c
Normal file
85
sys/wince/mhinput.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include <assert.h>
|
||||
#include "winMS.h"
|
||||
#include "mhinput.h"
|
||||
|
||||
/* nethack input queue functions */
|
||||
|
||||
#define NH_INPUT_BUFFER_SIZE 64
|
||||
|
||||
/* as it stands right now we need only one slot
|
||||
since events are processed almost the same time as
|
||||
they occur but I like large round numbers */
|
||||
|
||||
static MSNHEvent nhi_input_buffer[NH_INPUT_BUFFER_SIZE];
|
||||
static int nhi_init_input = 0;
|
||||
static int nhi_read_pos = 0;
|
||||
static int nhi_write_pos = 0;
|
||||
|
||||
/* initialize input queue */
|
||||
void mswin_nh_input_init()
|
||||
{
|
||||
if( !nhi_init_input ) {
|
||||
nhi_init_input = 1;
|
||||
|
||||
ZeroMemory( nhi_input_buffer, sizeof(nhi_input_buffer) );
|
||||
nhi_read_pos = 0;
|
||||
nhi_write_pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* check for input */
|
||||
int mswin_have_input()
|
||||
{
|
||||
return (nhi_read_pos!=nhi_write_pos);
|
||||
}
|
||||
|
||||
/* add event to the queue */
|
||||
void mswin_input_push(PMSNHEvent event)
|
||||
{
|
||||
int new_write_pos;
|
||||
|
||||
if( !nhi_init_input ) mswin_nh_input_init();
|
||||
|
||||
new_write_pos = (nhi_write_pos+1) % NH_INPUT_BUFFER_SIZE;
|
||||
|
||||
if(new_write_pos!=nhi_read_pos) {
|
||||
memcpy(nhi_input_buffer+nhi_write_pos, event, sizeof(*event));
|
||||
nhi_write_pos = new_write_pos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* get event from the queue and delete it */
|
||||
PMSNHEvent mswin_input_pop()
|
||||
{
|
||||
PMSNHEvent retval;
|
||||
|
||||
if( !nhi_init_input ) mswin_nh_input_init();
|
||||
|
||||
if( nhi_read_pos!=nhi_write_pos ) {
|
||||
retval = &nhi_input_buffer[nhi_read_pos];
|
||||
nhi_read_pos = (nhi_read_pos+1) % NH_INPUT_BUFFER_SIZE;
|
||||
} else {
|
||||
retval = NULL;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* get event from the queue but leave it there */
|
||||
PMSNHEvent mswin_input_peek()
|
||||
{
|
||||
PMSNHEvent retval;
|
||||
|
||||
if( !nhi_init_input ) mswin_nh_input_init();
|
||||
|
||||
if( nhi_read_pos!=nhi_write_pos ) {
|
||||
retval = &nhi_input_buffer[nhi_read_pos];
|
||||
} else {
|
||||
retval = NULL;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
35
sys/wince/mhinput.h
Normal file
35
sys/wince/mhinput.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MSWINInput_h
|
||||
#define MSWINInput_h
|
||||
|
||||
/* nethack input queue - store/extract input events */
|
||||
#include "winMS.h"
|
||||
|
||||
#define NHEVENT_CHAR 1
|
||||
#define NHEVENT_MOUSE 2
|
||||
typedef struct mswin_event {
|
||||
int type;
|
||||
union {
|
||||
struct {
|
||||
int ch;
|
||||
} kbd;
|
||||
|
||||
struct {
|
||||
int mod;
|
||||
int x, y;
|
||||
} ms;
|
||||
};
|
||||
} MSNHEvent, *PMSNHEvent;
|
||||
|
||||
#define NHEVENT_KBD(c) { MSNHEvent e; e.type=NHEVENT_CHAR; e.kbd.ch=(c); mswin_input_push(&e); }
|
||||
#define NHEVENT_MS(_mod, _x, _y) { MSNHEvent e; e.type=NHEVENT_MOUSE; e.ms.mod = (_mod); e.ms.x=(_x); e.ms.y=(_y); mswin_input_push(&e); }
|
||||
|
||||
void mswin_nh_input_init();
|
||||
int mswin_have_input();
|
||||
void mswin_input_push(PMSNHEvent event);
|
||||
PMSNHEvent mswin_input_pop();
|
||||
PMSNHEvent mswin_input_peek();
|
||||
|
||||
#endif /* MSWINInput_h */
|
||||
932
sys/wince/mhmain.c
Normal file
932
sys/wince/mhmain.c
Normal file
@@ -0,0 +1,932 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* 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"
|
||||
#include "mhmenu.h"
|
||||
#include "mhstatus.h"
|
||||
#include "mhmsgwnd.h"
|
||||
#include "mhcmd.h"
|
||||
#include "mhmap.h"
|
||||
#include "patchlevel.h"
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
|
||||
typedef struct mswin_nethack_main_window {
|
||||
HWND hCmdWnd;
|
||||
int mapAcsiiModeSave;
|
||||
} NHMainWindow, *PNHMainWindow;
|
||||
|
||||
TCHAR szMainWindowClass[] = TEXT("MSNHMainWndClass");
|
||||
static TCHAR szTitle[MAX_LOADSTRING];
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
||||
static LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
static void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
static void register_main_window_class();
|
||||
static void select_map_mode(int map_mode);
|
||||
static int menuid2mapmode(int menuid);
|
||||
static int mapmode2menuid(int map_mode);
|
||||
|
||||
HWND mswin_init_main_window () {
|
||||
static int run_once = 0;
|
||||
HWND ret;
|
||||
|
||||
/* register window class */
|
||||
if( !run_once ) {
|
||||
LoadString(GetNHApp()->hApp, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||
register_main_window_class( );
|
||||
run_once = 1;
|
||||
}
|
||||
|
||||
/* create the main window */
|
||||
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 */
|
||||
NULL, /* handle to parent or owner window */
|
||||
NULL, /* menu handle or child identifier */
|
||||
GetNHApp()->hApp, /* handle to application instance */
|
||||
NULL /* window-creation data */
|
||||
);
|
||||
|
||||
if( !ret ) panic("Cannot create main window");
|
||||
return ret;
|
||||
}
|
||||
|
||||
void register_main_window_class()
|
||||
{
|
||||
WNDCLASS wcex;
|
||||
|
||||
ZeroMemory(&wcex, sizeof(wcex));
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = (WNDPROC)MainWndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = GetNHApp()->hApp;
|
||||
wcex.hIcon = LoadIcon(GetNHApp()->hApp, (LPCTSTR)IDI_WINHACK);
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||
wcex.lpszMenuName = NULL;
|
||||
wcex.lpszClassName = szMainWindowClass;
|
||||
|
||||
RegisterClass(&wcex);
|
||||
}
|
||||
|
||||
/*
|
||||
* Keypad keys are translated to the normal values below.
|
||||
* Shifted keypad keys are translated to the
|
||||
* shift values below.
|
||||
*/
|
||||
|
||||
enum KEY_INDEXES {
|
||||
KEY_NW, KEY_N, KEY_NE, KEY_MINUS,
|
||||
KEY_W, KEY_GOINTERESTING, KEY_E, KEY_PLUS,
|
||||
KEY_SW, KEY_S, KEY_SE,
|
||||
KEY_INV, KEY_WAITLOOK,
|
||||
KEY_LAST};
|
||||
|
||||
static const unsigned char
|
||||
/* normal, shift, control */
|
||||
keypad[KEY_LAST][3] = {
|
||||
{'y', 'Y', C('y')}, /* 7 */
|
||||
{'k', 'K', C('k')}, /* 8 */
|
||||
{'u', 'U', C('u')}, /* 9 */
|
||||
{'m', C('p'), C('p')}, /* - */
|
||||
{'h', 'H', C('h')}, /* 4 */
|
||||
{'g', 'G', 'g'}, /* 5 */
|
||||
{'l', 'L', C('l')}, /* 6 */
|
||||
{'+', 'P', C('p')}, /* + */
|
||||
{'b', 'B', C('b')}, /* 1 */
|
||||
{'j', 'J', C('j')}, /* 2 */
|
||||
{'n', 'N', C('n')}, /* 3 */
|
||||
{'i', 'I', C('i')}, /* Ins */
|
||||
{'.', ':', ':'} /* Del */
|
||||
},
|
||||
numpad[KEY_LAST][3] = {
|
||||
{'7', M('7'), '7'}, /* 7 */
|
||||
{'8', M('8'), '8'}, /* 8 */
|
||||
{'9', M('9'), '9'}, /* 9 */
|
||||
{'m', C('p'), C('p')}, /* - */
|
||||
{'4', M('4'), '4'}, /* 4 */
|
||||
{'g', 'G', 'g'}, /* 5 */
|
||||
{'6', M('6'), '6'}, /* 6 */
|
||||
{'+', 'P', C('p')}, /* + */
|
||||
{'1', M('1'), '1'}, /* 1 */
|
||||
{'2', M('2'), '2'}, /* 2 */
|
||||
{'3', M('3'), '3'}, /* 3 */
|
||||
{'i', 'I', C('i')}, /* Ins */
|
||||
{'.', ':', ':'} /* Del */
|
||||
};
|
||||
|
||||
#define STATEON(x) ((GetKeyState(x) & 0xFFFE) != 0)
|
||||
#define KEYTABLE_REGULAR(x) ((iflags.num_pad ? numpad : keypad)[x][0])
|
||||
#define KEYTABLE_SHIFT(x) ((iflags.num_pad ? numpad : keypad)[x][1])
|
||||
#define KEYTABLE(x) (STATEON(VK_SHIFT) ? KEYTABLE_SHIFT(x) : KEYTABLE_REGULAR(x))
|
||||
|
||||
/* map mode macros */
|
||||
#define IS_MAP_FIT_TO_SCREEN(mode) ((mode)==MAP_MODE_ASCII_FIT_TO_SCREEN || \
|
||||
(mode)==MAP_MODE_TILES_FIT_TO_SCREEN )
|
||||
|
||||
#define IS_MAP_ASCII(mode) ((mode)!=MAP_MODE_TILES && (mode)!=MAP_MODE_TILES_FIT_TO_SCREEN)
|
||||
|
||||
|
||||
/*
|
||||
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
|
||||
//
|
||||
// PURPOSE: Processes messages for the main window.
|
||||
*/
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHMainWindow data;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE: {
|
||||
#ifndef WIN_CE_2xx
|
||||
SHMENUBARINFO menubar;
|
||||
#endif
|
||||
/* set window data */
|
||||
data = (PNHMainWindow)malloc(sizeof(NHMainWindow));
|
||||
if( !data ) panic("out of memory");
|
||||
ZeroMemory(data, sizeof(NHMainWindow));
|
||||
data->mapAcsiiModeSave = MAP_MODE_ASCII12x16;
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)data);
|
||||
|
||||
GetNHApp()->hMainWnd = hWnd;
|
||||
|
||||
/* create menu bar */
|
||||
#ifndef WIN_CE_2xx
|
||||
ZeroMemory(&menubar, sizeof(menubar));
|
||||
menubar.cbSize = sizeof(menubar);
|
||||
menubar.hwndParent = hWnd;
|
||||
menubar.dwFlags = 0;
|
||||
menubar.nToolBarId = IDC_WINHACK;
|
||||
menubar.hInstRes = GetNHApp()->hApp;
|
||||
menubar.nBmpId = 0;
|
||||
menubar.cBmpImages = 0;
|
||||
if( !SHCreateMenuBar(&menubar) ) panic("cannot create menu");
|
||||
GetNHApp()->hMenuBar = menubar.hwndMB;
|
||||
#else
|
||||
GetNHApp()->hMenuBar = CommandBar_Create(GetNHApp()->hApp, hWnd, 1);
|
||||
if( !GetNHApp()->hMenuBar ) panic("cannot create menu");
|
||||
CommandBar_InsertMenubar(
|
||||
GetNHApp()->hMenuBar, GetNHApp()->hApp,
|
||||
IDC_WINHACK, 0 );
|
||||
#endif
|
||||
|
||||
/* create command pad (keyboard emulator) */
|
||||
data->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 */
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_LEFT:
|
||||
if( STATEON(VK_CONTROL) ) {
|
||||
/* scroll map window one line left */
|
||||
SendMessage(
|
||||
mswin_hwnd_from_winid(WIN_MAP),
|
||||
WM_HSCROLL,
|
||||
MAKEWPARAM(SB_LINEUP, 0),
|
||||
(LPARAM)NULL
|
||||
);
|
||||
} else {
|
||||
NHEVENT_KBD(KEYTABLE(KEY_W));
|
||||
}
|
||||
return 0;
|
||||
|
||||
case VK_RIGHT:
|
||||
if( STATEON(VK_CONTROL) ) {
|
||||
/* scroll map window one line right */
|
||||
SendMessage(
|
||||
mswin_hwnd_from_winid(WIN_MAP),
|
||||
WM_HSCROLL,
|
||||
MAKEWPARAM(SB_LINEDOWN, 0),
|
||||
(LPARAM)NULL
|
||||
);
|
||||
} else {
|
||||
NHEVENT_KBD(KEYTABLE(KEY_E));
|
||||
}
|
||||
return 0;
|
||||
|
||||
case VK_UP:
|
||||
if( STATEON(VK_CONTROL) ) {
|
||||
/* scroll map window one line up */
|
||||
SendMessage(
|
||||
mswin_hwnd_from_winid(WIN_MAP),
|
||||
WM_VSCROLL,
|
||||
MAKEWPARAM(SB_LINEUP, 0),
|
||||
(LPARAM)NULL
|
||||
);
|
||||
} else {
|
||||
NHEVENT_KBD(KEYTABLE(KEY_N));
|
||||
}
|
||||
return 0;
|
||||
|
||||
case VK_DOWN:
|
||||
if( STATEON(VK_CONTROL) ) {
|
||||
/* scroll map window one line down */
|
||||
SendMessage(
|
||||
mswin_hwnd_from_winid(WIN_MAP),
|
||||
WM_VSCROLL,
|
||||
MAKEWPARAM(SB_LINEDOWN, 0),
|
||||
(LPARAM)NULL
|
||||
);
|
||||
} else {
|
||||
NHEVENT_KBD(KEYTABLE(KEY_S));
|
||||
}
|
||||
return 0;
|
||||
|
||||
case VK_HOME:
|
||||
if( STATEON(VK_CONTROL) ) {
|
||||
/* scroll map window to upper left corner */
|
||||
SendMessage(
|
||||
mswin_hwnd_from_winid(WIN_MAP),
|
||||
WM_VSCROLL,
|
||||
MAKEWPARAM(SB_THUMBTRACK, 0),
|
||||
(LPARAM)NULL
|
||||
);
|
||||
|
||||
SendMessage(
|
||||
mswin_hwnd_from_winid(WIN_MAP),
|
||||
WM_HSCROLL,
|
||||
MAKEWPARAM(SB_THUMBTRACK, 0),
|
||||
(LPARAM)NULL
|
||||
);
|
||||
} else {
|
||||
NHEVENT_KBD(KEYTABLE(KEY_NW));
|
||||
}
|
||||
return 0;
|
||||
|
||||
case VK_END:
|
||||
if( STATEON(VK_CONTROL) ) {
|
||||
/* scroll map window to lower right corner */
|
||||
SendMessage(
|
||||
mswin_hwnd_from_winid(WIN_MAP),
|
||||
WM_VSCROLL,
|
||||
MAKEWPARAM(SB_THUMBTRACK, ROWNO),
|
||||
(LPARAM)NULL
|
||||
);
|
||||
|
||||
SendMessage(
|
||||
mswin_hwnd_from_winid(WIN_MAP),
|
||||
WM_HSCROLL,
|
||||
MAKEWPARAM(SB_THUMBTRACK, COLNO),
|
||||
(LPARAM)NULL
|
||||
);
|
||||
} else {
|
||||
NHEVENT_KBD(KEYTABLE(KEY_SW));
|
||||
}
|
||||
return 0;
|
||||
|
||||
case VK_PRIOR:
|
||||
if( STATEON(VK_CONTROL) ) {
|
||||
/* scroll map window one page up */
|
||||
SendMessage(
|
||||
mswin_hwnd_from_winid(WIN_MAP),
|
||||
WM_VSCROLL,
|
||||
MAKEWPARAM(SB_PAGEUP, 0),
|
||||
(LPARAM)NULL
|
||||
);
|
||||
} else {
|
||||
NHEVENT_KBD(KEYTABLE(KEY_NE));
|
||||
}
|
||||
return 0;
|
||||
|
||||
case VK_NEXT:
|
||||
if( STATEON(VK_CONTROL) ) {
|
||||
/* scroll map window one page down */
|
||||
SendMessage(
|
||||
mswin_hwnd_from_winid(WIN_MAP),
|
||||
WM_VSCROLL,
|
||||
MAKEWPARAM(SB_PAGEDOWN, 0),
|
||||
(LPARAM)NULL
|
||||
);
|
||||
} else {
|
||||
NHEVENT_KBD(KEYTABLE(KEY_SE));
|
||||
}
|
||||
return 0;
|
||||
|
||||
case VK_DECIMAL:
|
||||
case VK_DELETE:
|
||||
NHEVENT_KBD(KEYTABLE(KEY_WAITLOOK));
|
||||
return 0;
|
||||
|
||||
case VK_INSERT:
|
||||
NHEVENT_KBD(KEYTABLE(KEY_INV));
|
||||
return 0;
|
||||
|
||||
case VK_SUBTRACT:
|
||||
NHEVENT_KBD(KEYTABLE(KEY_MINUS));
|
||||
return 0;
|
||||
|
||||
case VK_ADD:
|
||||
NHEVENT_KBD(KEYTABLE(KEY_PLUS));
|
||||
return 0;
|
||||
|
||||
case VK_CLEAR: /* This is the '5' key */
|
||||
NHEVENT_KBD(KEYTABLE(KEY_GOINTERESTING));
|
||||
return 0;
|
||||
|
||||
case VK_F4:
|
||||
if( IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode) ) {
|
||||
mswin_select_map_mode(
|
||||
IS_MAP_ASCII(iflags.wc_map_mode)?
|
||||
data->mapAcsiiModeSave :
|
||||
MAP_MODE_TILES
|
||||
);
|
||||
} else {
|
||||
mswin_select_map_mode(
|
||||
IS_MAP_ASCII(iflags.wc_map_mode)?
|
||||
MAP_MODE_ASCII_FIT_TO_SCREEN :
|
||||
MAP_MODE_TILES_FIT_TO_SCREEN
|
||||
);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case VK_F5:
|
||||
if( IS_MAP_ASCII(iflags.wc_map_mode) ) {
|
||||
if( IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode) ) {
|
||||
mswin_select_map_mode(MAP_MODE_TILES_FIT_TO_SCREEN);
|
||||
} else {
|
||||
mswin_select_map_mode(MAP_MODE_TILES);
|
||||
}
|
||||
} else {
|
||||
if( IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode) ) {
|
||||
mswin_select_map_mode(MAP_MODE_ASCII_FIT_TO_SCREEN);
|
||||
} else {
|
||||
mswin_select_map_mode(data->mapAcsiiModeSave);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} return 1;
|
||||
|
||||
case WM_CHAR:
|
||||
/* all characters go to nethack */
|
||||
NHEVENT_KBD( (lParam & 1<<29)? M(tolower(wParam)) : wParam );
|
||||
return 0;
|
||||
|
||||
case WM_COMMAND:
|
||||
/* process commands - menu commands mostly */
|
||||
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 */
|
||||
if( IsWindow( GetNHApp()->hPopupWnd ) ) {
|
||||
SetFocus( GetNHApp()->hPopupWnd );
|
||||
}
|
||||
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
|
||||
WM_QUIT somehow */
|
||||
|
||||
/* clean up */
|
||||
free( (PNHMainWindow)GetWindowLong(hWnd, GWL_USERDATA) );
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)0);
|
||||
|
||||
terminate(EXIT_SUCCESS);
|
||||
} break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(wParam) {
|
||||
|
||||
/* new window was just added */
|
||||
case MSNH_MSG_ADDWND: {
|
||||
PMSNHMsgAddWnd msg_param = (PMSNHMsgAddWnd)lParam;
|
||||
HWND child = GetNHApp()->windowlist[msg_param->wid].win;
|
||||
|
||||
if( GetNHApp()->windowlist[msg_param->wid].type == NHW_MAP )
|
||||
mswin_select_map_mode(iflags.wc_map_mode);
|
||||
|
||||
if( child ) mswin_layout_main_window(child);
|
||||
} break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* adjust windows to fit main window layout
|
||||
---------------------------
|
||||
| Status |
|
||||
+-------------------------+
|
||||
| |
|
||||
| |
|
||||
| MAP |
|
||||
| |
|
||||
| |
|
||||
+-------------------------+
|
||||
| Command pad |
|
||||
+-------------------------+
|
||||
| Messages |
|
||||
---------------------------
|
||||
*/
|
||||
void mswin_layout_main_window(HWND changed_child)
|
||||
{
|
||||
winid i;
|
||||
RECT client_rt, wnd_rect;
|
||||
POINT status_org;
|
||||
SIZE status_size;
|
||||
POINT msg_org;
|
||||
SIZE msg_size;
|
||||
POINT map_org;
|
||||
SIZE map_size;
|
||||
POINT cmd_org;
|
||||
SIZE cmd_size;
|
||||
HWND wnd_status, wnd_msg;
|
||||
PNHMainWindow data;
|
||||
#ifndef WIN_CE_2xx
|
||||
SIPINFO sip;
|
||||
RECT menu_bar;
|
||||
#endif
|
||||
|
||||
GetClientRect(GetNHApp()->hMainWnd, &client_rt);
|
||||
|
||||
#ifndef WIN_CE_2xx
|
||||
ZeroMemory(&sip, sizeof(sip));
|
||||
sip.cbSize = sizeof(sip);
|
||||
SHSipInfo(SPI_GETSIPINFO, 0, &sip, 0);
|
||||
|
||||
/* adjust client rectangle size */
|
||||
GetWindowRect(GetNHApp()->hMenuBar, &menu_bar);
|
||||
client_rt.bottom -= menu_bar.bottom-menu_bar.top;
|
||||
#else
|
||||
client_rt.top += CommandBar_Height(GetNHApp()->hMenuBar);
|
||||
#endif
|
||||
|
||||
/* get window data */
|
||||
data = (PNHMainWindow)GetWindowLong(GetNHApp()->hMainWnd, GWL_USERDATA);
|
||||
|
||||
/* get sizes of child windows */
|
||||
wnd_status = mswin_hwnd_from_winid(WIN_STATUS);
|
||||
if( IsWindow(wnd_status) ) {
|
||||
mswin_status_window_size(wnd_status, &status_size);
|
||||
} else {
|
||||
status_size.cx = status_size.cy = 0;
|
||||
}
|
||||
|
||||
wnd_msg = mswin_hwnd_from_winid(WIN_MESSAGE);
|
||||
if( IsWindow(wnd_msg) ) {
|
||||
mswin_message_window_size(wnd_msg, &msg_size);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
/* set window positions */
|
||||
|
||||
/* keypad */
|
||||
SetRect(&wnd_rect, client_rt.left, client_rt.top, client_rt.right, client_rt.bottom);
|
||||
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;
|
||||
|
||||
/* status window */
|
||||
switch(iflags.wc_align_status) {
|
||||
case ALIGN_LEFT:
|
||||
status_size.cx = (wnd_rect.right-wnd_rect.left)/4;
|
||||
status_size.cy = (wnd_rect.bottom-wnd_rect.top); // that won't look good
|
||||
status_org.x = wnd_rect.left;
|
||||
status_org.y = wnd_rect.top;
|
||||
wnd_rect.left += status_size.cx;
|
||||
break;
|
||||
|
||||
case ALIGN_RIGHT:
|
||||
status_size.cx = (wnd_rect.right-wnd_rect.left)/4;
|
||||
status_size.cy = (wnd_rect.bottom-wnd_rect.top); // that won't look good
|
||||
status_org.x = wnd_rect.right - status_size.cx;
|
||||
status_org.y = wnd_rect.top;
|
||||
wnd_rect.right -= status_size.cx;
|
||||
break;
|
||||
|
||||
case ALIGN_TOP:
|
||||
status_size.cx = (wnd_rect.right-wnd_rect.left);
|
||||
status_org.x = wnd_rect.left;
|
||||
status_org.y = wnd_rect.top;
|
||||
wnd_rect.top += status_size.cy;
|
||||
break;
|
||||
|
||||
case ALIGN_BOTTOM:
|
||||
default:
|
||||
status_size.cx = (wnd_rect.right-wnd_rect.left);
|
||||
status_org.x = wnd_rect.left;
|
||||
status_org.y = wnd_rect.bottom - status_size.cy;
|
||||
wnd_rect.bottom -= status_size.cy;
|
||||
break;
|
||||
}
|
||||
|
||||
/* message window */
|
||||
switch(iflags.wc_align_message) {
|
||||
case ALIGN_LEFT:
|
||||
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;
|
||||
wnd_rect.left += msg_size.cx;
|
||||
break;
|
||||
|
||||
case ALIGN_RIGHT:
|
||||
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;
|
||||
wnd_rect.right -= msg_size.cx;
|
||||
break;
|
||||
|
||||
case ALIGN_TOP:
|
||||
msg_size.cx = (wnd_rect.right-wnd_rect.left);
|
||||
msg_org.x = wnd_rect.left;
|
||||
msg_org.y = wnd_rect.top;
|
||||
wnd_rect.top += msg_size.cy;
|
||||
break;
|
||||
|
||||
case ALIGN_BOTTOM:
|
||||
default:
|
||||
msg_size.cx = (wnd_rect.right-wnd_rect.left);
|
||||
msg_org.x = wnd_rect.left;
|
||||
msg_org.y = wnd_rect.bottom - msg_size.cy;
|
||||
wnd_rect.bottom -= msg_size.cy;
|
||||
break;
|
||||
}
|
||||
|
||||
map_org.x = wnd_rect.left;
|
||||
map_org.y = wnd_rect.top;
|
||||
map_size.cx = wnd_rect.right - wnd_rect.left;
|
||||
map_size.cy = wnd_rect.bottom - wnd_rect.top;
|
||||
|
||||
/* go through the windows list and adjust sizes */
|
||||
for( i=0; i<MAXWINDOWS; i++ ) {
|
||||
if(GetNHApp()->windowlist[i].win && !GetNHApp()->windowlist[i].dead) {
|
||||
switch( GetNHApp()->windowlist[i].type ) {
|
||||
case NHW_MESSAGE:
|
||||
MoveWindow(GetNHApp()->windowlist[i].win,
|
||||
msg_org.x,
|
||||
msg_org.y,
|
||||
msg_size.cx,
|
||||
msg_size.cy,
|
||||
TRUE );
|
||||
break;
|
||||
case NHW_MAP:
|
||||
MoveWindow(GetNHApp()->windowlist[i].win,
|
||||
map_org.x,
|
||||
map_org.y,
|
||||
map_size.cx,
|
||||
map_size.cy,
|
||||
TRUE );
|
||||
break;
|
||||
case NHW_STATUS:
|
||||
MoveWindow(GetNHApp()->windowlist[i].win,
|
||||
status_org.x,
|
||||
status_org.y,
|
||||
status_size.cx,
|
||||
status_size.cy,
|
||||
TRUE );
|
||||
break;
|
||||
|
||||
case NHW_TEXT:
|
||||
case NHW_MENU:
|
||||
case NHW_RIP:
|
||||
{
|
||||
POINT menu_org;
|
||||
SIZE menu_size;
|
||||
|
||||
menu_org.x = client_rt.left;
|
||||
menu_org.y = client_rt.top;
|
||||
#ifndef WIN_CE_2xx
|
||||
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,
|
||||
client_rt.bottom - client_rt.top);
|
||||
#else
|
||||
menu_size.cx = client_rt.right - client_rt.left;
|
||||
menu_size.cy = client_rt.bottom - client_rt.top;
|
||||
#endif
|
||||
|
||||
MoveWindow(GetNHApp()->windowlist[i].win,
|
||||
menu_org.x,
|
||||
menu_org.y,
|
||||
menu_size.cx,
|
||||
menu_size.cy,
|
||||
TRUE );
|
||||
} break;
|
||||
}
|
||||
ShowWindow(GetNHApp()->windowlist[i].win, SW_SHOW);
|
||||
InvalidateRect(GetNHApp()->windowlist[i].win, NULL, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if( IsWindow(data->hCmdWnd) ) {
|
||||
if( GetNHApp()->bCmdPad ) {
|
||||
MoveWindow(data->hCmdWnd,
|
||||
cmd_org.x,
|
||||
cmd_org.y,
|
||||
cmd_size.cx,
|
||||
cmd_size.cy,
|
||||
TRUE );
|
||||
ShowWindow(data->hCmdWnd, SW_SHOW);
|
||||
} else {
|
||||
ShowWindow(data->hCmdWnd, SW_HIDE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int wmId, wmEvent;
|
||||
PNHMainWindow data;
|
||||
|
||||
data = (PNHMainWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
wmId = LOWORD(wParam);
|
||||
wmEvent = HIWORD(wParam);
|
||||
|
||||
// process the menu selections:
|
||||
switch (wmId)
|
||||
{
|
||||
case IDM_ABOUT:
|
||||
DialogBox(GetNHApp()->hApp, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
|
||||
break;
|
||||
|
||||
case IDM_EXIT:
|
||||
done2();
|
||||
break;
|
||||
|
||||
case IDM_SAVE:
|
||||
dosave();
|
||||
break;
|
||||
|
||||
case IDM_MAP_TILES:
|
||||
case IDM_MAP_ASCII4X6:
|
||||
case IDM_MAP_ASCII6X8:
|
||||
case IDM_MAP_ASCII8X8:
|
||||
case IDM_MAP_ASCII16X8:
|
||||
case IDM_MAP_ASCII7X12:
|
||||
case IDM_MAP_ASCII8X12:
|
||||
case IDM_MAP_ASCII12X16:
|
||||
case IDM_MAP_ASCII16X12:
|
||||
case IDM_MAP_ASCII10X18:
|
||||
mswin_select_map_mode(menuid2mapmode(wmId));
|
||||
break;
|
||||
|
||||
case IDM_MAP_FIT_TO_SCREEN:
|
||||
if( IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode) ) {
|
||||
mswin_select_map_mode(
|
||||
IS_MAP_ASCII(iflags.wc_map_mode)?
|
||||
data->mapAcsiiModeSave :
|
||||
MAP_MODE_TILES
|
||||
);
|
||||
} else {
|
||||
mswin_select_map_mode(
|
||||
IS_MAP_ASCII(iflags.wc_map_mode)?
|
||||
MAP_MODE_ASCII_FIT_TO_SCREEN :
|
||||
MAP_MODE_TILES_FIT_TO_SCREEN
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_HELP_LONG:
|
||||
display_file(HELP, TRUE);
|
||||
break;
|
||||
|
||||
case IDM_HELP_COMMANDS:
|
||||
display_file(SHELP, TRUE);
|
||||
break;
|
||||
|
||||
case IDM_HELP_HISTORY:
|
||||
(void) dohistory();
|
||||
break;
|
||||
|
||||
case IDM_HELP_INFO_CHAR:
|
||||
(void) dowhatis();
|
||||
break;
|
||||
|
||||
case IDM_HELP_INFO_KEY:
|
||||
(void) dowhatdoes();
|
||||
break;
|
||||
|
||||
case IDM_HELP_OPTIONS:
|
||||
option_help();
|
||||
break;
|
||||
|
||||
case IDM_HELP_OPTIONS_LONG:
|
||||
display_file(OPTIONFILE, TRUE);
|
||||
break;
|
||||
|
||||
case IDM_HELP_EXTCMD:
|
||||
(void) doextlist();
|
||||
break;
|
||||
|
||||
case IDM_HELP_LICENSE:
|
||||
display_file(LICENSE, TRUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Mesage handler for about box.
|
||||
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
TCHAR wbuf[NHSTR_BUFSIZE];
|
||||
RECT main_rt, dlg_rt;
|
||||
SIZE dlg_sz;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
getversionstring(buf);
|
||||
SetDlgItemText(hDlg, IDC_ABOUT_VERSION, NH_A2W(buf, wbuf, NHSTR_BUFSIZE));
|
||||
|
||||
SetDlgItemText(hDlg, IDC_ABOUT_COPYRIGHT,
|
||||
NH_A2W(
|
||||
COPYRIGHT_BANNER_A "\n"
|
||||
COPYRIGHT_BANNER_B "\n"
|
||||
COPYRIGHT_BANNER_C,
|
||||
wbuf,
|
||||
NHSTR_BUFSIZE
|
||||
) );
|
||||
|
||||
|
||||
/* center dialog in the main window */
|
||||
GetWindowRect(GetNHApp()->hMainWnd, &main_rt);
|
||||
GetWindowRect(hDlg, &dlg_rt);
|
||||
dlg_sz.cx = dlg_rt.right - dlg_rt.left;
|
||||
dlg_sz.cy = dlg_rt.bottom - dlg_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;
|
||||
dlg_rt.bottom = dlg_rt.top + dlg_sz.cy;
|
||||
MoveWindow( hDlg,
|
||||
(main_rt.left+main_rt.right-dlg_sz.cx)/2,
|
||||
(main_rt.top+main_rt.bottom-dlg_sz.cy)/2,
|
||||
dlg_sz.cx,
|
||||
dlg_sz.cy,
|
||||
TRUE );
|
||||
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* Set map display mode */
|
||||
void mswin_select_map_mode(int mode)
|
||||
{
|
||||
HMENU hmenuMap;
|
||||
PNHMainWindow data;
|
||||
winid map_id;
|
||||
#ifndef WIN_CE_2xx
|
||||
TBBUTTONINFO tbbi;
|
||||
#endif
|
||||
|
||||
map_id = WIN_MAP;
|
||||
data = (PNHMainWindow)GetWindowLong(GetNHApp()->hMainWnd, GWL_USERDATA);
|
||||
|
||||
/* override for Rogue level */
|
||||
#ifdef REINCARNATION
|
||||
if( Is_rogue_level(&u.uz) && !IS_MAP_ASCII(mode) ) return;
|
||||
#endif
|
||||
|
||||
#ifndef WIN_CE_2xx
|
||||
tbbi.cbSize = sizeof(tbbi);
|
||||
tbbi.dwMask = TBIF_LPARAM;
|
||||
SendMessage( GetNHApp()->hMenuBar, TB_GETBUTTONINFO, ID_MAP, (LPARAM)&tbbi);
|
||||
hmenuMap = (HMENU)tbbi.lParam;
|
||||
#else
|
||||
hmenuMap = CommandBar_GetMenu(GetNHApp()->hMenuBar, 0);
|
||||
#endif
|
||||
|
||||
/* set map mode menu mark */
|
||||
if( IS_MAP_ASCII(mode) ) {
|
||||
CheckMenuRadioItem(
|
||||
hmenuMap,
|
||||
IDM_MAP_TILES,
|
||||
IDM_MAP_FIT_TO_SCREEN,
|
||||
mapmode2menuid( IS_MAP_FIT_TO_SCREEN(mode)? data->mapAcsiiModeSave : mode ),
|
||||
MF_BYCOMMAND);
|
||||
} else {
|
||||
CheckMenuRadioItem(
|
||||
hmenuMap,
|
||||
IDM_MAP_TILES,
|
||||
IDM_MAP_FIT_TO_SCREEN,
|
||||
mapmode2menuid( MAP_MODE_TILES ),
|
||||
MF_BYCOMMAND);
|
||||
}
|
||||
|
||||
/* set fit-to-screen mode mark */
|
||||
CheckMenuItem(
|
||||
hmenuMap,
|
||||
IDM_MAP_FIT_TO_SCREEN,
|
||||
MF_BYCOMMAND |
|
||||
(IS_MAP_FIT_TO_SCREEN(mode)? MF_CHECKED : MF_UNCHECKED)
|
||||
);
|
||||
|
||||
if( IS_MAP_ASCII(iflags.wc_map_mode) && !IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
|
||||
data->mapAcsiiModeSave = iflags.wc_map_mode;
|
||||
}
|
||||
|
||||
iflags.wc_map_mode = mode;
|
||||
|
||||
/*
|
||||
** first, check if WIN_MAP has been inialized.
|
||||
** If not - attempt to retrieve it by type, then check it again
|
||||
*/
|
||||
if( map_id==WIN_ERR )
|
||||
map_id = mswin_winid_from_type(NHW_MAP);
|
||||
if( map_id!=WIN_ERR )
|
||||
mswin_map_mode(mswin_hwnd_from_winid(map_id), mode);
|
||||
}
|
||||
|
||||
static struct t_menu2mapmode {
|
||||
int menuID;
|
||||
int mapMode;
|
||||
} _menu2mapmode[] =
|
||||
{
|
||||
{ IDM_MAP_TILES, MAP_MODE_TILES },
|
||||
{ IDM_MAP_ASCII4X6, MAP_MODE_ASCII4x6 },
|
||||
{ IDM_MAP_ASCII6X8, MAP_MODE_ASCII6x8 },
|
||||
{ IDM_MAP_ASCII8X8, MAP_MODE_ASCII8x8 },
|
||||
{ IDM_MAP_ASCII16X8, MAP_MODE_ASCII16x8 },
|
||||
{ IDM_MAP_ASCII7X12, MAP_MODE_ASCII7x12 },
|
||||
{ IDM_MAP_ASCII8X12, MAP_MODE_ASCII8x12 },
|
||||
{ IDM_MAP_ASCII12X16, MAP_MODE_ASCII12x16 },
|
||||
{ IDM_MAP_ASCII16X12, MAP_MODE_ASCII16x12 },
|
||||
{ IDM_MAP_ASCII10X18, MAP_MODE_ASCII10x18 },
|
||||
{ IDM_MAP_FIT_TO_SCREEN, MAP_MODE_ASCII_FIT_TO_SCREEN },
|
||||
{ -1, -1 }
|
||||
};
|
||||
|
||||
int menuid2mapmode(int menuid)
|
||||
{
|
||||
struct t_menu2mapmode* p;
|
||||
for( p = _menu2mapmode; p->mapMode!=-1; p++ )
|
||||
if(p->menuID==menuid ) return p->mapMode;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mapmode2menuid(int map_mode)
|
||||
{
|
||||
struct t_menu2mapmode* p;
|
||||
for( p = _menu2mapmode; p->mapMode!=-1; p++ )
|
||||
if(p->mapMode==map_mode ) return p->menuID;
|
||||
return -1;
|
||||
}
|
||||
16
sys/wince/mhmain.h
Normal file
16
sys/wince/mhmain.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MSWINMainWindow_h
|
||||
#define MSWINMainWindow_h
|
||||
|
||||
/* this is a main appliation window */
|
||||
|
||||
#include "winMS.h"
|
||||
|
||||
extern TCHAR szMainWindowClass[];
|
||||
HWND mswin_init_main_window ();
|
||||
void mswin_layout_main_window(HWND changed_child);
|
||||
void mswin_select_map_mode(int map_mode);
|
||||
|
||||
#endif /* MSWINMainWindow_h */
|
||||
898
sys/wince/mhmap.c
Normal file
898
sys/wince/mhmap.c
Normal file
@@ -0,0 +1,898 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* 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 "patchlevel.h"
|
||||
|
||||
#define NHMAP_FONT_NAME TEXT("Terminal")
|
||||
#define MAXWINDOWTEXT 255
|
||||
|
||||
extern short glyph2tile[];
|
||||
|
||||
/* map window data */
|
||||
typedef struct mswin_nethack_map_window {
|
||||
int map[COLNO][ROWNO]; /* glyph map */
|
||||
|
||||
int mapMode; /* current map mode */
|
||||
boolean bAsciiMode; /* switch ASCII/tiled mode */
|
||||
boolean bFitToScreenMode; /* switch Fit map to screen mode on/off */
|
||||
int xPos, yPos; /* scroll position */
|
||||
int xPageSize, yPageSize; /* scroll page size */
|
||||
int xCur, yCur; /* position of the cursor */
|
||||
int xScrTile, yScrTile; /* size of display tile */
|
||||
POINT map_orig; /* map origin point */
|
||||
|
||||
HFONT hMapFont; /* font for ASCII mode */
|
||||
} NHMapWindow, *PNHMapWindow;
|
||||
|
||||
static TCHAR szNHMapWindowClass[] = TEXT("MSNethackMapWndClass");
|
||||
LRESULT CALLBACK MapWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static void register_map_window_class(void);
|
||||
static void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
static void onMSNH_VScroll(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
static void onMSNH_HScroll(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
static void onPaint(HWND hWnd);
|
||||
static void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
static void nhcoord2display(PNHMapWindow data, int x, int y, LPRECT lpOut);
|
||||
#if (VERSION_MAJOR < 4) && (VERSION_MINOR < 4) && (PATCHLEVEL < 2)
|
||||
static void nhglyph2charcolor(short glyph, uchar* ch, int* color);
|
||||
#endif
|
||||
static COLORREF nhcolor_to_RGB(int c);
|
||||
|
||||
HWND mswin_init_map_window () {
|
||||
static int run_once = 0;
|
||||
HWND ret;
|
||||
|
||||
if( !run_once ) {
|
||||
register_map_window_class();
|
||||
run_once = 1;
|
||||
}
|
||||
|
||||
ret = CreateWindow(
|
||||
szNHMapWindowClass, /* registered class name */
|
||||
NULL, /* window name */
|
||||
WS_CHILD | WS_HSCROLL | WS_VSCROLL | WS_CLIPSIBLINGS, /* window style */
|
||||
0, /* horizontal position of window - set it later */
|
||||
0, /* vertical position of window - set it later */
|
||||
0, /* window width - set it later */
|
||||
0, /* window height - set it later*/
|
||||
GetNHApp()->hMainWnd, /* handle to parent or owner window */
|
||||
NULL, /* menu handle or child identifier */
|
||||
GetNHApp()->hApp, /* handle to application instance */
|
||||
NULL ); /* window-creation data */
|
||||
if( !ret ) {
|
||||
panic("Cannot create map window");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void mswin_map_stretch(HWND hWnd, LPSIZE lpsz, BOOL redraw)
|
||||
{
|
||||
PNHMapWindow data;
|
||||
RECT client_rt;
|
||||
SCROLLINFO si;
|
||||
SIZE wnd_size;
|
||||
LOGFONT lgfnt;
|
||||
|
||||
/* check arguments */
|
||||
if( !IsWindow(hWnd) ||
|
||||
!lpsz ||
|
||||
lpsz->cx<=0 ||
|
||||
lpsz->cy<=0 ) return;
|
||||
|
||||
/* calculate window size */
|
||||
GetClientRect(hWnd, &client_rt);
|
||||
wnd_size.cx = client_rt.right - client_rt.left;
|
||||
wnd_size.cy = client_rt.bottom - client_rt.top;
|
||||
|
||||
/* set new screen tile size */
|
||||
data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
data->xScrTile =
|
||||
max(1, (data->bFitToScreenMode? wnd_size.cx : lpsz->cx) / COLNO);
|
||||
data->yScrTile =
|
||||
max(1, (data->bFitToScreenMode? wnd_size.cy : lpsz->cy) / ROWNO);
|
||||
|
||||
/* set map origin point */
|
||||
data->map_orig.x = max(0, client_rt.left + (wnd_size.cx - data->xScrTile*COLNO)/2 );
|
||||
data->map_orig.y = max(0, client_rt.top + (wnd_size.cy - data->yScrTile*ROWNO)/2 );
|
||||
|
||||
data->map_orig.x -= data->map_orig.x % data->xScrTile;
|
||||
data->map_orig.y -= data->map_orig.y % data->yScrTile;
|
||||
|
||||
/* adjust horizontal scroll bar */
|
||||
if( data->bFitToScreenMode )
|
||||
data->xPageSize = COLNO+1; /* disable scroll bar */
|
||||
else
|
||||
data->xPageSize = wnd_size.cx/data->xScrTile;
|
||||
|
||||
if( data->xPageSize >= COLNO ) {
|
||||
data->xPos = 0;
|
||||
GetNHApp()->bNoHScroll = TRUE;
|
||||
} else {
|
||||
GetNHApp()->bNoHScroll = FALSE;
|
||||
data->xPos = max(0, min(COLNO-data->xPageSize+1, u.ux - data->xPageSize/2));
|
||||
}
|
||||
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
|
||||
si.nMin = 0;
|
||||
si.nMax = COLNO;
|
||||
si.nPage = data->xPageSize;
|
||||
si.nPos = data->xPos;
|
||||
SetScrollInfo(hWnd, SB_HORZ, &si, TRUE);
|
||||
|
||||
/* adjust vertical scroll bar */
|
||||
if( data->bFitToScreenMode )
|
||||
data->yPageSize = ROWNO+1; /* disable scroll bar */
|
||||
else
|
||||
data->yPageSize = wnd_size.cy/data->yScrTile;
|
||||
|
||||
if( data->yPageSize >= ROWNO ) {
|
||||
data->yPos = 0;
|
||||
GetNHApp()->bNoVScroll = TRUE;
|
||||
} else {
|
||||
GetNHApp()->bNoVScroll = FALSE;
|
||||
data->yPos = max(0, min(ROWNO-data->yPageSize+1, u.uy - data->yPageSize/2));
|
||||
}
|
||||
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
|
||||
si.nMin = 0;
|
||||
si.nMax = ROWNO;
|
||||
si.nPage = data->yPageSize;
|
||||
si.nPos = data->yPos;
|
||||
SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
|
||||
|
||||
/* create font */
|
||||
if( data->hMapFont ) DeleteObject(data->hMapFont);
|
||||
ZeroMemory(&lgfnt, sizeof(lgfnt));
|
||||
lgfnt.lfHeight = -data->yScrTile; // height of font
|
||||
lgfnt.lfWidth = -data->xScrTile; // average character width
|
||||
lgfnt.lfEscapement = 0; // angle of escapement
|
||||
lgfnt.lfOrientation = 0; // base-line orientation angle
|
||||
lgfnt.lfWeight = FW_NORMAL; // font weight
|
||||
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.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);
|
||||
data->hMapFont = CreateFontIndirect(&lgfnt);
|
||||
|
||||
mswin_cliparound(data->xCur, data->yCur);
|
||||
|
||||
if(redraw) InvalidateRect(hWnd, NULL, TRUE);
|
||||
}
|
||||
|
||||
/* set map mode */
|
||||
int mswin_map_mode(HWND hWnd, int mode)
|
||||
{
|
||||
PNHMapWindow data;
|
||||
int oldMode;
|
||||
SIZE mapSize;
|
||||
|
||||
data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
if( mode == data->mapMode ) return mode;
|
||||
|
||||
oldMode = data->mapMode;
|
||||
data->mapMode = mode;
|
||||
|
||||
switch( data->mapMode ) {
|
||||
|
||||
case MAP_MODE_ASCII4x6:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 4*COLNO;
|
||||
mapSize.cy = 6*ROWNO;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII6x8:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 6*COLNO;
|
||||
mapSize.cy = 8*ROWNO;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII8x8:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 8*COLNO;
|
||||
mapSize.cy = 8*ROWNO;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII16x8:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 16*COLNO;
|
||||
mapSize.cy = 8*ROWNO;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII7x12:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 7*COLNO;
|
||||
mapSize.cy = 12*ROWNO;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII8x12:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 8*COLNO;
|
||||
mapSize.cy = 12*ROWNO;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII16x12:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 16*COLNO;
|
||||
mapSize.cy = 12*ROWNO;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII12x16:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 12*COLNO;
|
||||
mapSize.cy = 16*ROWNO;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII10x18:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 10*COLNO;
|
||||
mapSize.cy = 18*ROWNO;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII_FIT_TO_SCREEN: {
|
||||
RECT client_rt;
|
||||
GetClientRect(hWnd, &client_rt);
|
||||
mapSize.cx = client_rt.right - client_rt.left;
|
||||
mapSize.cy = client_rt.bottom - client_rt.top;
|
||||
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = TRUE;
|
||||
} break;
|
||||
|
||||
case MAP_MODE_TILES_FIT_TO_SCREEN: {
|
||||
RECT client_rt;
|
||||
GetClientRect(hWnd, &client_rt);
|
||||
mapSize.cx = client_rt.right - client_rt.left;
|
||||
mapSize.cy = client_rt.bottom - client_rt.top;
|
||||
|
||||
data->bAsciiMode = FALSE;
|
||||
data->bFitToScreenMode = TRUE;
|
||||
} break;
|
||||
|
||||
case MAP_MODE_TILES:
|
||||
default:
|
||||
data->bAsciiMode = FALSE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = GetNHApp()->mapTile_X*COLNO;
|
||||
mapSize.cy = GetNHApp()->mapTile_Y*ROWNO;
|
||||
break;
|
||||
}
|
||||
|
||||
mswin_map_stretch(hWnd, &mapSize, TRUE);
|
||||
|
||||
return oldMode;
|
||||
}
|
||||
|
||||
/* register window class for map window */
|
||||
void register_map_window_class()
|
||||
{
|
||||
WNDCLASS wcex;
|
||||
ZeroMemory( &wcex, sizeof(wcex));
|
||||
|
||||
/* window class */
|
||||
wcex.style = CS_NOCLOSE | CS_DBLCLKS;
|
||||
wcex.lpfnWndProc = (WNDPROC)MapWndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = GetNHApp()->hApp;
|
||||
wcex.hIcon = NULL;
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = CreateSolidBrush(RGB(0, 0, 0)); /* set backgroup here */
|
||||
wcex.lpszMenuName = NULL;
|
||||
wcex.lpszClassName = szNHMapWindowClass;
|
||||
|
||||
if( !RegisterClass(&wcex) ) {
|
||||
panic("cannot register Map window class");
|
||||
}
|
||||
}
|
||||
|
||||
/* map window procedure */
|
||||
LRESULT CALLBACK MapWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHMapWindow data;
|
||||
|
||||
data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
onCreate( hWnd, wParam, lParam );
|
||||
break;
|
||||
|
||||
case WM_MSNH_COMMAND:
|
||||
onMSNHCommand(hWnd, wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
onPaint(hWnd);
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
/* transfer focus back to the main window */
|
||||
SetFocus(GetNHApp()->hMainWnd);
|
||||
break;
|
||||
|
||||
case WM_HSCROLL:
|
||||
onMSNH_HScroll(hWnd, wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_VSCROLL:
|
||||
onMSNH_VScroll(hWnd, wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
SIZE size;
|
||||
|
||||
if( data->bFitToScreenMode ) {
|
||||
size.cx = LOWORD(lParam);
|
||||
size.cy = HIWORD(lParam);
|
||||
} else {
|
||||
/* mapping factor is unchaged we just need to adjust scroll bars */
|
||||
size.cx = data->xScrTile*COLNO;
|
||||
size.cy = data->yScrTile*ROWNO;
|
||||
}
|
||||
mswin_map_stretch(hWnd, &size, TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
NHEVENT_MS(
|
||||
CLICK_1,
|
||||
max(0, min(COLNO, data->xPos + (LOWORD(lParam)-data->map_orig.x)/data->xScrTile)),
|
||||
max(0, min(ROWNO, data->yPos + (HIWORD(lParam)-data->map_orig.y)/data->yScrTile))
|
||||
);
|
||||
return 0;
|
||||
|
||||
case WM_LBUTTONDBLCLK :
|
||||
NHEVENT_MS(
|
||||
CLICK_2,
|
||||
max(0, min(COLNO, data->xPos + (LOWORD(lParam)-data->map_orig.x)/data->xScrTile)),
|
||||
max(0, min(ROWNO, data->yPos + (HIWORD(lParam)-data->map_orig.y)/data->yScrTile))
|
||||
);
|
||||
return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
if( data->hMapFont ) DeleteObject(data->hMapFont);
|
||||
free(data);
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* on WM_COMMAND */
|
||||
void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHMapWindow data;
|
||||
RECT rt;
|
||||
|
||||
data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
switch(wParam) {
|
||||
case MSNH_MSG_PRINT_GLYPH:
|
||||
{
|
||||
PMSNHMsgPrintGlyph msg_data = (PMSNHMsgPrintGlyph)lParam;
|
||||
data->map[msg_data->x][msg_data->y] = msg_data->glyph;
|
||||
|
||||
/* invalidate the update area */
|
||||
nhcoord2display(data, msg_data->x, msg_data->y, &rt);
|
||||
InvalidateRect(hWnd, &rt, TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case MSNH_MSG_CLIPAROUND:
|
||||
{
|
||||
PMSNHMsgClipAround msg_data = (PMSNHMsgClipAround)lParam;
|
||||
int x, y;
|
||||
BOOL scroll_x, scroll_y;
|
||||
int mcam = iflags.wc_scroll_margin;
|
||||
|
||||
/* calculate if you should clip around */
|
||||
scroll_x =
|
||||
!GetNHApp()->bNoHScroll &&
|
||||
( msg_data->x<(data->xPos+mcam) ||
|
||||
msg_data->x>(data->xPos+data->xPageSize-mcam) );
|
||||
scroll_y =
|
||||
!GetNHApp()->bNoVScroll &&
|
||||
( msg_data->y<(data->yPos+mcam) ||
|
||||
msg_data->y>(data->yPos+data->yPageSize-mcam) );
|
||||
|
||||
/* get page size and center horizontally on x-position */
|
||||
if( scroll_x ) {
|
||||
if( data->xPageSize<=2*mcam ) {
|
||||
x = max(0, min(COLNO, msg_data->x - data->xPageSize/2));
|
||||
} else if( msg_data->x < data->xPos+data->xPageSize/2 ) {
|
||||
x = max(0, min(COLNO, msg_data->x - mcam));
|
||||
} else {
|
||||
x = max(0, min(COLNO, msg_data->x - data->xPageSize + mcam));
|
||||
}
|
||||
SendMessage( hWnd, WM_HSCROLL, (WPARAM)MAKELONG(SB_THUMBTRACK, x), (LPARAM)NULL );
|
||||
}
|
||||
|
||||
/* get page size and center vertically on y-position */
|
||||
if( scroll_y ) {
|
||||
if( data->yPageSize<=2*mcam ) {
|
||||
y = max(0, min(ROWNO, msg_data->y - data->yPageSize/2));
|
||||
} else if( msg_data->y < data->yPos+data->yPageSize/2 ) {
|
||||
y = max(0, min(ROWNO, msg_data->y - mcam));
|
||||
} else {
|
||||
y = max(0, min(ROWNO, msg_data->y - data->yPageSize + mcam));
|
||||
}
|
||||
SendMessage( hWnd, WM_VSCROLL, (WPARAM)MAKELONG(SB_THUMBTRACK, y), (LPARAM)NULL );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MSNH_MSG_CLEAR_WINDOW:
|
||||
{
|
||||
int i, j;
|
||||
for(i=0; i<COLNO; i++)
|
||||
for(j=0; j<ROWNO; j++) {
|
||||
data->map[i][j] = -1;
|
||||
}
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
} break;
|
||||
|
||||
case MSNH_MSG_CURSOR:
|
||||
{
|
||||
PMSNHMsgCursor msg_data = (PMSNHMsgCursor)lParam;
|
||||
HDC hdc;
|
||||
RECT rt;
|
||||
|
||||
/* move focus rectangle at the cursor postion */
|
||||
hdc = GetDC(hWnd);
|
||||
|
||||
nhcoord2display(data, data->xCur, data->yCur, &rt);
|
||||
if( data->bAsciiMode ) {
|
||||
PatBlt(hdc, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top, DSTINVERT);
|
||||
} else {
|
||||
DrawFocusRect(hdc, &rt);
|
||||
}
|
||||
|
||||
data->xCur = msg_data->x;
|
||||
data->yCur = msg_data->y;
|
||||
|
||||
nhcoord2display(data, data->xCur, data->yCur, &rt);
|
||||
if( data->bAsciiMode ) {
|
||||
PatBlt(hdc, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top, DSTINVERT);
|
||||
} else {
|
||||
DrawFocusRect(hdc, &rt);
|
||||
}
|
||||
|
||||
ReleaseDC(hWnd, hdc);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
/* on WM_CREATE */
|
||||
void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHMapWindow data;
|
||||
int i,j;
|
||||
|
||||
/* set window data */
|
||||
data = (PNHMapWindow)malloc(sizeof(NHMapWindow));
|
||||
if( !data ) panic("out of memory");
|
||||
|
||||
ZeroMemory(data, sizeof(NHMapWindow));
|
||||
for(i=0; i<COLNO; i++)
|
||||
for(j=0; j<ROWNO; j++) {
|
||||
data->map[i][j] = -1;
|
||||
}
|
||||
|
||||
data->bAsciiMode = FALSE;
|
||||
|
||||
data->xScrTile = GetNHApp()->mapTile_X;
|
||||
data->yScrTile = GetNHApp()->mapTile_Y;
|
||||
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)data);
|
||||
}
|
||||
|
||||
/* on WM_PAINT */
|
||||
void onPaint(HWND hWnd)
|
||||
{
|
||||
PNHMapWindow data;
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC;
|
||||
HDC tileDC;
|
||||
HGDIOBJ saveBmp;
|
||||
RECT paint_rt;
|
||||
int i, j;
|
||||
|
||||
/* get window data */
|
||||
data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
|
||||
/* calculate paint rectangle */
|
||||
if( !IsRectEmpty(&ps.rcPaint) ) {
|
||||
/* calculate paint rectangle */
|
||||
paint_rt.left = max(data->xPos + (ps.rcPaint.left - data->map_orig.x)/data->xScrTile, 0);
|
||||
paint_rt.top = max(data->yPos + (ps.rcPaint.top - data->map_orig.y)/data->yScrTile, 0);
|
||||
paint_rt.right = min(data->xPos + (ps.rcPaint.right - data->map_orig.x)/data->xScrTile+1, COLNO);
|
||||
paint_rt.bottom = min(data->yPos + (ps.rcPaint.bottom - data->map_orig.y)/data->yScrTile+1, ROWNO);
|
||||
|
||||
if( data->bAsciiMode
|
||||
#ifdef REINCARNATION
|
||||
|| Is_rogue_level(&u.uz)
|
||||
/* You enter a VERY primitive world! */
|
||||
#endif
|
||||
) {
|
||||
HGDIOBJ oldFont;
|
||||
|
||||
oldFont = SelectObject(hDC, data->hMapFont);
|
||||
SetBkMode(hDC, TRANSPARENT);
|
||||
|
||||
/* draw the map */
|
||||
for(i=paint_rt.left; i<paint_rt.right; i++)
|
||||
for(j=paint_rt.top; j<paint_rt.bottom; j++)
|
||||
if(data->map[i][j]>=0) {
|
||||
char ch;
|
||||
TCHAR wch;
|
||||
RECT glyph_rect;
|
||||
int color;
|
||||
unsigned special;
|
||||
int mgch;
|
||||
HBRUSH back_brush;
|
||||
COLORREF OldFg;
|
||||
|
||||
nhcoord2display(data, i, j, &glyph_rect);
|
||||
|
||||
#if (VERSION_MAJOR < 4) && (VERSION_MINOR < 4) && (PATCHLEVEL < 2)
|
||||
nhglyph2charcolor(data->map[i][j], &ch, &color);
|
||||
OldFg = SetTextColor (hDC, nhcolor_to_RGB(color) );
|
||||
#else
|
||||
/* rely on NetHack core helper routine */
|
||||
mapglyph(data->map[i][j], &mgch, &color,
|
||||
&special, i, j);
|
||||
ch = (char)mgch;
|
||||
if (((special & MG_PET) && iflags.hilite_pet) ||
|
||||
((special & MG_DETECT) && iflags.use_inverse)) {
|
||||
back_brush = CreateSolidBrush(nhcolor_to_RGB(CLR_GRAY));
|
||||
FillRect (hDC, &glyph_rect, back_brush);
|
||||
DeleteObject (back_brush);
|
||||
switch (color)
|
||||
{
|
||||
case CLR_GRAY:
|
||||
case CLR_WHITE:
|
||||
OldFg = SetTextColor( hDC, nhcolor_to_RGB(CLR_BLACK));
|
||||
break;
|
||||
default:
|
||||
OldFg = SetTextColor (hDC, nhcolor_to_RGB(color) );
|
||||
}
|
||||
} else {
|
||||
OldFg = SetTextColor (hDC, nhcolor_to_RGB(color) );
|
||||
}
|
||||
#endif
|
||||
|
||||
DrawText(hDC,
|
||||
NH_A2W(&ch, &wch, 1),
|
||||
1,
|
||||
&glyph_rect,
|
||||
DT_CENTER | DT_VCENTER | DT_NOPREFIX
|
||||
);
|
||||
SetTextColor (hDC, OldFg);
|
||||
}
|
||||
SelectObject(hDC, oldFont);
|
||||
} else {
|
||||
/* prepare tiles DC for mapping */
|
||||
tileDC = CreateCompatibleDC(hDC);
|
||||
saveBmp = SelectObject(tileDC, GetNHApp()->bmpMapTiles);
|
||||
|
||||
/* draw the map */
|
||||
for(i=paint_rt.left; i<paint_rt.right; i++)
|
||||
for(j=paint_rt.top; j<paint_rt.bottom; j++)
|
||||
if(data->map[i][j]>=0) {
|
||||
short ntile;
|
||||
int t_x, t_y;
|
||||
RECT glyph_rect;
|
||||
|
||||
ntile = glyph2tile[ data->map[i][j] ];
|
||||
t_x = (ntile % GetNHApp()->mapTilesPerLine)*GetNHApp()->mapTile_X;
|
||||
t_y = (ntile / GetNHApp()->mapTilesPerLine)*GetNHApp()->mapTile_Y;
|
||||
|
||||
nhcoord2display(data, i, j, &glyph_rect);
|
||||
|
||||
StretchBlt(
|
||||
hDC,
|
||||
glyph_rect.left,
|
||||
glyph_rect.top,
|
||||
data->xScrTile,
|
||||
data->yScrTile,
|
||||
tileDC,
|
||||
t_x,
|
||||
t_y,
|
||||
GetNHApp()->mapTile_X,
|
||||
GetNHApp()->mapTile_Y,
|
||||
SRCCOPY
|
||||
);
|
||||
if( glyph_is_pet(data->map[i][j]) && iflags.wc_hilite_pet ) {
|
||||
/* apply pet mark transparently over
|
||||
pet image */
|
||||
HDC hdcPetMark;
|
||||
HBITMAP bmPetMarkOld;
|
||||
|
||||
/* this is DC for petmark bitmap */
|
||||
hdcPetMark = CreateCompatibleDC(hDC);
|
||||
bmPetMarkOld = SelectObject(hdcPetMark, GetNHApp()->bmpPetMark);
|
||||
|
||||
nhapply_image_transparent(
|
||||
hDC,
|
||||
glyph_rect.left,
|
||||
glyph_rect.top,
|
||||
data->xScrTile,
|
||||
data->yScrTile,
|
||||
hdcPetMark,
|
||||
0,
|
||||
0,
|
||||
TILE_X,
|
||||
TILE_Y,
|
||||
TILE_BK_COLOR
|
||||
);
|
||||
SelectObject(hdcPetMark, bmPetMarkOld);
|
||||
DeleteDC(hdcPetMark);
|
||||
}
|
||||
}
|
||||
SelectObject(tileDC, saveBmp);
|
||||
DeleteDC(tileDC);
|
||||
}
|
||||
|
||||
/* draw focus rect */
|
||||
nhcoord2display(data, data->xCur, data->yCur, &paint_rt);
|
||||
if( data->bAsciiMode ) {
|
||||
PatBlt( hDC,
|
||||
paint_rt.left, paint_rt.top,
|
||||
paint_rt.right-paint_rt.left, paint_rt.bottom-paint_rt.top,
|
||||
DSTINVERT );
|
||||
} else {
|
||||
DrawFocusRect(hDC, &paint_rt);
|
||||
}
|
||||
}
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
|
||||
/* on WM_VSCROLL */
|
||||
void onMSNH_VScroll(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHMapWindow data;
|
||||
SCROLLINFO si;
|
||||
int yNewPos;
|
||||
int yDelta;
|
||||
|
||||
/* get window data */
|
||||
data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
switch(LOWORD (wParam))
|
||||
{
|
||||
/* User clicked shaft left of the scroll box. */
|
||||
case SB_PAGEUP:
|
||||
yNewPos = data->yPos-data->yPageSize;
|
||||
break;
|
||||
|
||||
/* User clicked shaft right of the scroll box. */
|
||||
case SB_PAGEDOWN:
|
||||
yNewPos = data->yPos+data->yPageSize;
|
||||
break;
|
||||
|
||||
/* User clicked the left arrow. */
|
||||
case SB_LINEUP:
|
||||
yNewPos = data->yPos-1;
|
||||
break;
|
||||
|
||||
/* User clicked the right arrow. */
|
||||
case SB_LINEDOWN:
|
||||
yNewPos = data->yPos+1;
|
||||
break;
|
||||
|
||||
/* User dragged the scroll box. */
|
||||
case SB_THUMBTRACK:
|
||||
yNewPos = HIWORD(wParam);
|
||||
break;
|
||||
|
||||
default:
|
||||
yNewPos = data->yPos;
|
||||
}
|
||||
|
||||
yNewPos = max(0, min(ROWNO-data->yPageSize+1, yNewPos));
|
||||
if( yNewPos == data->yPos ) return;
|
||||
|
||||
yDelta = yNewPos - data->yPos;
|
||||
data->yPos = yNewPos;
|
||||
|
||||
ScrollWindowEx (hWnd, 0, -data->yScrTile * yDelta,
|
||||
(CONST RECT *) NULL, (CONST RECT *) NULL,
|
||||
(HRGN) NULL, (LPRECT) NULL, SW_INVALIDATE | SW_ERASE);
|
||||
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_POS;
|
||||
si.nPos = data->yPos;
|
||||
SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
|
||||
}
|
||||
|
||||
/* on WM_HSCROLL */
|
||||
void onMSNH_HScroll(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHMapWindow data;
|
||||
SCROLLINFO si;
|
||||
int xNewPos;
|
||||
int xDelta;
|
||||
|
||||
/* get window data */
|
||||
data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
switch(LOWORD (wParam))
|
||||
{
|
||||
/* User clicked shaft left of the scroll box. */
|
||||
case SB_PAGEUP:
|
||||
xNewPos = data->xPos-data->xPageSize;
|
||||
break;
|
||||
|
||||
/* User clicked shaft right of the scroll box. */
|
||||
case SB_PAGEDOWN:
|
||||
xNewPos = data->xPos+data->xPageSize;
|
||||
break;
|
||||
|
||||
/* User clicked the left arrow. */
|
||||
case SB_LINEUP:
|
||||
xNewPos = data->xPos-1;
|
||||
break;
|
||||
|
||||
/* User clicked the right arrow. */
|
||||
case SB_LINEDOWN:
|
||||
xNewPos = data->xPos+1;
|
||||
break;
|
||||
|
||||
/* User dragged the scroll box. */
|
||||
case SB_THUMBTRACK:
|
||||
xNewPos = HIWORD(wParam);
|
||||
break;
|
||||
|
||||
default:
|
||||
xNewPos = data->xPos;
|
||||
}
|
||||
|
||||
xNewPos = max(0, min(COLNO-data->xPageSize+1, xNewPos));
|
||||
if( xNewPos == data->xPos ) return;
|
||||
|
||||
xDelta = xNewPos - data->xPos;
|
||||
data->xPos = xNewPos;
|
||||
|
||||
ScrollWindowEx (hWnd, -data->xScrTile * xDelta, 0,
|
||||
(CONST RECT *) NULL, (CONST RECT *) NULL,
|
||||
(HRGN) NULL, (LPRECT) NULL, SW_INVALIDATE | SW_ERASE);
|
||||
|
||||
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_POS;
|
||||
si.nPos = data->xPos;
|
||||
SetScrollInfo(hWnd, SB_HORZ, &si, TRUE);
|
||||
}
|
||||
|
||||
/* map nethack map coordinates to the screen location */
|
||||
void nhcoord2display(PNHMapWindow data, int x, int y, LPRECT lpOut)
|
||||
{
|
||||
lpOut->left = (x - data->xPos)*data->xScrTile + data->map_orig.x;
|
||||
lpOut->top = (y - data->yPos)*data->yScrTile + data->map_orig.y;
|
||||
lpOut->right = lpOut->left + data->xScrTile;
|
||||
lpOut->bottom = lpOut->top + data->yScrTile;
|
||||
}
|
||||
|
||||
#if (VERSION_MAJOR < 4) && (VERSION_MINOR < 4) && (PATCHLEVEL < 2)
|
||||
/* map glyph to character/color combination */
|
||||
void nhglyph2charcolor(short g, uchar* ch, int* color)
|
||||
{
|
||||
int offset;
|
||||
#ifdef TEXTCOLOR
|
||||
|
||||
#define zap_color(n) *color = iflags.use_color ? zapcolors[n] : NO_COLOR
|
||||
#define cmap_color(n) *color = iflags.use_color ? defsyms[n].color : NO_COLOR
|
||||
#define obj_color(n) *color = iflags.use_color ? objects[n].oc_color : NO_COLOR
|
||||
#define mon_color(n) *color = iflags.use_color ? mons[n].mcolor : NO_COLOR
|
||||
#define pet_color(n) *color = iflags.use_color ? mons[n].mcolor : NO_COLOR
|
||||
#define warn_color(n) *color = iflags.use_color ? def_warnsyms[n].color : NO_COLOR
|
||||
|
||||
# else /* no text color */
|
||||
|
||||
#define zap_color(n)
|
||||
#define cmap_color(n)
|
||||
#define obj_color(n)
|
||||
#define mon_color(n)
|
||||
#define pet_color(c)
|
||||
#define warn_color(c)
|
||||
*color = CLR_WHITE;
|
||||
#endif
|
||||
|
||||
if ((offset = (g - GLYPH_WARNING_OFF)) >= 0) { /* a warning flash */
|
||||
*ch = warnsyms[offset];
|
||||
warn_color(offset);
|
||||
} else if ((offset = (g - GLYPH_SWALLOW_OFF)) >= 0) { /* swallow */
|
||||
/* see swallow_to_glyph() in display.c */
|
||||
*ch = (uchar) showsyms[S_sw_tl + (offset & 0x7)];
|
||||
mon_color(offset >> 3);
|
||||
} else if ((offset = (g - GLYPH_ZAP_OFF)) >= 0) { /* zap beam */
|
||||
/* see zapdir_to_glyph() in display.c */
|
||||
*ch = showsyms[S_vbeam + (offset & 0x3)];
|
||||
zap_color((offset >> 2));
|
||||
} else if ((offset = (g - GLYPH_CMAP_OFF)) >= 0) { /* cmap */
|
||||
*ch = showsyms[offset];
|
||||
cmap_color(offset);
|
||||
} else if ((offset = (g - GLYPH_OBJ_OFF)) >= 0) { /* object */
|
||||
*ch = oc_syms[(int)objects[offset].oc_class];
|
||||
obj_color(offset);
|
||||
} else if ((offset = (g - GLYPH_BODY_OFF)) >= 0) { /* a corpse */
|
||||
*ch = oc_syms[(int)objects[CORPSE].oc_class];
|
||||
mon_color(offset);
|
||||
} else if ((offset = (g - GLYPH_PET_OFF)) >= 0) { /* a pet */
|
||||
*ch = monsyms[(int)mons[offset].mlet];
|
||||
pet_color(offset);
|
||||
} else { /* a monster */
|
||||
*ch = monsyms[(int)mons[g].mlet];
|
||||
mon_color(g);
|
||||
}
|
||||
// end of wintty code
|
||||
}
|
||||
#endif
|
||||
|
||||
/* map nethack color to RGB */
|
||||
COLORREF nhcolor_to_RGB(int c)
|
||||
{
|
||||
switch(c) {
|
||||
case CLR_BLACK: return RGB(0x55, 0x55, 0x55);
|
||||
case CLR_RED: return RGB(0xFF, 0x00, 0x00);
|
||||
case CLR_GREEN: return RGB(0x00, 0x80, 0x00);
|
||||
case CLR_BROWN: return RGB(0xA5, 0x2A, 0x2A);
|
||||
case CLR_BLUE: return RGB(0x00, 0x00, 0xFF);
|
||||
case CLR_MAGENTA: return RGB(0xFF, 0x00, 0xFF);
|
||||
case CLR_CYAN: return RGB(0x00, 0xFF, 0xFF);
|
||||
case CLR_GRAY: return RGB(0xC0, 0xC0, 0xC0);
|
||||
case NO_COLOR: return RGB(0xFF, 0xFF, 0xFF);
|
||||
case CLR_ORANGE: return RGB(0xFF, 0xA5, 0x00);
|
||||
case CLR_BRIGHT_GREEN: return RGB(0x00, 0xFF, 0x00);
|
||||
case CLR_YELLOW: return RGB(0xFF, 0xFF, 0x00);
|
||||
case CLR_BRIGHT_BLUE: return RGB(0x00, 0xC0, 0xFF);
|
||||
case CLR_BRIGHT_MAGENTA: return RGB(0xFF, 0x80, 0xFF);
|
||||
case CLR_BRIGHT_CYAN: return RGB(0x80, 0xFF, 0xFF); /* something close to aquamarine */
|
||||
case CLR_WHITE: return RGB(0xFF, 0xFF, 0xFF);
|
||||
default: return RGB(0x00, 0x00, 0x00); /* black */
|
||||
}
|
||||
}
|
||||
|
||||
/* 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,
|
||||
COLORREF cTransparent
|
||||
)
|
||||
{
|
||||
TransparentImage(
|
||||
hDC, x, y, width, height,
|
||||
sourceDC, s_x, s_y, s_width, s_height,
|
||||
cTransparent
|
||||
);
|
||||
}
|
||||
34
sys/wince/mhmap.h
Normal file
34
sys/wince/mhmap.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MSWINMapWindow_h
|
||||
#define MSWINMapWindow_h
|
||||
|
||||
#include "winMS.h"
|
||||
#include "config.h"
|
||||
#include "global.h"
|
||||
|
||||
|
||||
HWND mswin_init_map_window ();
|
||||
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
|
||||
|
||||
|
||||
#endif /* MSWINMapWindow_h */
|
||||
1420
sys/wince/mhmenu.c
Normal file
1420
sys/wince/mhmenu.c
Normal file
File diff suppressed because it is too large
Load Diff
17
sys/wince/mhmenu.h
Normal file
17
sys/wince/mhmenu.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MSWINMenuWindow_h
|
||||
#define MSWINMenuWindow_h
|
||||
|
||||
#include "winMS.h"
|
||||
#include "config.h"
|
||||
#include "global.h"
|
||||
|
||||
#define MENU_TYPE_TEXT 1
|
||||
#define MENU_TYPE_MENU 2
|
||||
|
||||
HWND mswin_init_menu_window ( int type );
|
||||
int mswin_menu_window_select_menu (HWND hwnd, int how, MENU_ITEM_P **);
|
||||
void mswin_menu_window_size (HWND hwnd, LPSIZE sz);
|
||||
|
||||
#endif /* MSWINTextWindow_h */
|
||||
60
sys/wince/mhmsg.h
Normal file
60
sys/wince/mhmsg.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MHNethackMessages_H
|
||||
#define MHNethackMessages_H
|
||||
|
||||
/* nethack messages */
|
||||
#define WM_MSNH_COMMAND (WM_APP+1)
|
||||
|
||||
#define MSNH_MSG_ADDWND 100
|
||||
#define MSNH_MSG_PUTSTR 101
|
||||
#define MSNH_MSG_PRINT_GLYPH 102
|
||||
#define MSNH_MSG_CLEAR_WINDOW 103
|
||||
#define MSNH_MSG_CLIPAROUND 104
|
||||
#define MSNH_MSG_STARTMENU 105
|
||||
#define MSNH_MSG_ADDMENU 106
|
||||
#define MSNH_MSG_CURSOR 107
|
||||
#define MSNH_MSG_ENDMENU 108
|
||||
|
||||
typedef struct mswin_nhmsg_add_wnd {
|
||||
winid wid;
|
||||
} MSNHMsgAddWnd, *PMSNHMsgAddWnd;
|
||||
|
||||
typedef struct mswin_nhmsg_putstr {
|
||||
int attr;
|
||||
const char* text;
|
||||
boolean append;
|
||||
} MSNHMsgPutstr, *PMSNHMsgPutstr;
|
||||
|
||||
typedef struct mswin_nhmsg_print_glyph {
|
||||
XCHAR_P x;
|
||||
XCHAR_P y;
|
||||
int glyph;
|
||||
} MSNHMsgPrintGlyph, *PMSNHMsgPrintGlyph;
|
||||
|
||||
typedef struct mswin_nhmsg_cliparound {
|
||||
int x;
|
||||
int y;
|
||||
} MSNHMsgClipAround, *PMSNHMsgClipAround;
|
||||
|
||||
typedef struct mswin_nhmsg_add_menu {
|
||||
int glyph;
|
||||
const ANY_P* identifier;
|
||||
CHAR_P accelerator;
|
||||
CHAR_P group_accel;
|
||||
int attr;
|
||||
const char * str;
|
||||
BOOLEAN_P presel;
|
||||
} MSNHMsgAddMenu, *PMSNHMsgAddMenu;
|
||||
|
||||
typedef struct mswin_nhmsg_cursor {
|
||||
int x;
|
||||
int y;
|
||||
} MSNHMsgCursor, *PMSNHMsgCursor;
|
||||
|
||||
typedef struct mswin_nhmsg_end_menu {
|
||||
const char* text;
|
||||
} MSNHMsgEndMenu, *PMSNHMsgEndMenu;
|
||||
|
||||
#endif
|
||||
538
sys/wince/mhmsgwnd.c
Normal file
538
sys/wince/mhmsgwnd.c
Normal file
@@ -0,0 +1,538 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "winMS.h"
|
||||
#include "mhmsgwnd.h"
|
||||
#include "mhmsg.h"
|
||||
#include "mhfont.h"
|
||||
#include "mhcolor.h"
|
||||
|
||||
#define MSG_WRAP_TEXT
|
||||
|
||||
#define MSG_VISIBLE_LINES max(iflags.wc_vary_msgcount, 2)
|
||||
#define MAX_MSG_LINES 32
|
||||
#define MSG_LINES (int)min(iflags.msg_history, MAX_MSG_LINES)
|
||||
#define MAXWINDOWTEXT 200
|
||||
|
||||
struct window_line {
|
||||
int attr;
|
||||
char text[MAXWINDOWTEXT];
|
||||
};
|
||||
|
||||
typedef struct mswin_nethack_message_window {
|
||||
size_t max_text;
|
||||
struct window_line window_text[MAX_MSG_LINES];
|
||||
|
||||
int xChar; /* horizontal scrolling unit */
|
||||
int yChar; /* vertical scrolling unit */
|
||||
int xUpper; /* average width of uppercase letters */
|
||||
int xPos; /* current horizontal scrolling position */
|
||||
int yPos; /* current vertical scrolling position */
|
||||
int xMax; /* maximum horizontal scrolling position */
|
||||
int yMax; /* maximum vertical scrolling position */
|
||||
int xPage; /* page size of horizontal scroll bar */
|
||||
} NHMessageWindow, *PNHMessageWindow;
|
||||
|
||||
static TCHAR szMessageWindowClass[] = TEXT("MSNHMessageWndClass");
|
||||
LRESULT CALLBACK NHMessageWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static void register_message_window_class();
|
||||
static void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
static void onMSNH_VScroll(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
#ifndef MSG_WRAP_TEXT
|
||||
static void onMSNH_HScroll(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
#endif
|
||||
static void onPaint(HWND hWnd);
|
||||
static void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
static HDC prepareDC( HDC hdc );
|
||||
|
||||
HWND mswin_init_message_window () {
|
||||
static int run_once = 0;
|
||||
HWND ret;
|
||||
DWORD style;
|
||||
|
||||
if( !run_once ) {
|
||||
register_message_window_class( );
|
||||
run_once = 1;
|
||||
}
|
||||
|
||||
#ifdef MSG_WRAP_TEXT
|
||||
style = WS_BORDER | WS_CHILD | WS_CLIPSIBLINGS | WS_VSCROLL;
|
||||
#else
|
||||
style = WS_BORDER | WS_CHILD | WS_CLIPSIBLINGS | WS_VSCROLL | WS_HSCROLL;
|
||||
#endif
|
||||
|
||||
ret = CreateWindow(
|
||||
szMessageWindowClass, /* registered class name */
|
||||
NULL, /* window name */
|
||||
style, /* window style */
|
||||
0, /* horizontal position of window */
|
||||
0, /* vertical position of window */
|
||||
0, /* window width */
|
||||
0, /* window height - set it later */
|
||||
GetNHApp()->hMainWnd, /* handle to parent or owner window */
|
||||
NULL, /* menu handle or child identifier */
|
||||
GetNHApp()->hApp, /* handle to application instance */
|
||||
NULL ); /* window-creation data */
|
||||
|
||||
if( !ret ) panic("Cannot create message window");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void register_message_window_class()
|
||||
{
|
||||
WNDCLASS wcex;
|
||||
ZeroMemory( &wcex, sizeof(wcex));
|
||||
|
||||
wcex.style = CS_NOCLOSE;
|
||||
wcex.lpfnWndProc = (WNDPROC)NHMessageWndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = GetNHApp()->hApp;
|
||||
wcex.hIcon = NULL;
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = mswin_get_brush(NHW_MESSAGE, MSWIN_COLOR_BG);
|
||||
wcex.lpszMenuName = NULL;
|
||||
wcex.lpszClassName = szMessageWindowClass;
|
||||
|
||||
RegisterClass(&wcex);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK NHMessageWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
onCreate( hWnd, wParam, lParam );
|
||||
break;
|
||||
|
||||
case WM_MSNH_COMMAND:
|
||||
onMSNHCommand(hWnd, wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
onPaint(hWnd);
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
SetFocus(GetNHApp()->hMainWnd);
|
||||
break;
|
||||
|
||||
#ifndef MSG_WRAP_TEXT
|
||||
case WM_HSCROLL:
|
||||
onMSNH_HScroll(hWnd, wParam, lParam);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case WM_VSCROLL:
|
||||
onMSNH_VScroll(hWnd, wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
PNHMessageWindow data;
|
||||
data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
free(data);
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)0);
|
||||
} break;
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
SCROLLINFO si;
|
||||
int xNewSize;
|
||||
int yNewSize;
|
||||
PNHMessageWindow data;
|
||||
|
||||
data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
xNewSize = LOWORD(lParam);
|
||||
yNewSize = HIWORD(lParam);
|
||||
|
||||
if( xNewSize>0 || yNewSize>0 ) {
|
||||
|
||||
#ifndef MSG_WRAP_TEXT
|
||||
data->xPage = xNewSize/data->xChar;
|
||||
data->xMax = max(0, (int)(1 + data->max_text - data->xPage));
|
||||
data->xPos = min(data->xPos, data->xMax);
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
|
||||
si.nMin = 0;
|
||||
si.nMax = data->max_text;
|
||||
si.nPage = data->xPage;
|
||||
si.nPos = data->xPos;
|
||||
SetScrollInfo(hWnd, SB_HORZ, &si, TRUE);
|
||||
#endif
|
||||
|
||||
data->yMax = MSG_LINES - MSG_VISIBLE_LINES - 1;
|
||||
data->yPos = min(data->yPos, data->yMax);
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
|
||||
si.nMin = 0;
|
||||
si.nMax = MSG_LINES;
|
||||
si.nPage = MSG_VISIBLE_LINES;
|
||||
si.nPos = data->yPos;
|
||||
SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHMessageWindow data;
|
||||
|
||||
data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
switch( wParam ) {
|
||||
case MSNH_MSG_PUTSTR:
|
||||
{
|
||||
PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr)lParam;
|
||||
SCROLLINFO si;
|
||||
char* p;
|
||||
|
||||
if( msg_data->append ) {
|
||||
strncat(data->window_text[MSG_LINES-1].text, msg_data->text,
|
||||
MAXWINDOWTEXT - strlen(data->window_text[MSG_LINES-1].text));
|
||||
} else {
|
||||
/* check if the string is empty */
|
||||
for(p = data->window_text[MSG_LINES-1].text; *p && isspace(*p); p++);
|
||||
|
||||
if( *p ) {
|
||||
/* last string is not empty - scroll up */
|
||||
memmove(&data->window_text[0],
|
||||
&data->window_text[1],
|
||||
(MSG_LINES-1)*sizeof(data->window_text[0]));
|
||||
}
|
||||
|
||||
/* append new text to the end of the array */
|
||||
data->window_text[MSG_LINES-1].attr = msg_data->attr;
|
||||
strncpy(data->window_text[MSG_LINES-1].text, msg_data->text, MAXWINDOWTEXT);
|
||||
}
|
||||
|
||||
/* reset V-scroll position to display new text */
|
||||
data->yPos = data->yMax;
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_POS;
|
||||
si.nPos = data->yPos;
|
||||
SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
|
||||
|
||||
/* update window content */
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case MSNH_MSG_CLEAR_WINDOW:
|
||||
{
|
||||
MSNHMsgPutstr data;
|
||||
|
||||
/* append an empty line to the message window (send message to itself) */
|
||||
data.attr = ATR_NONE;
|
||||
data.text = " ";
|
||||
onMSNHCommand(hWnd, (WPARAM)MSNH_MSG_PUTSTR, (LPARAM)&data);
|
||||
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onMSNH_VScroll(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHMessageWindow data;
|
||||
SCROLLINFO si;
|
||||
int yInc;
|
||||
|
||||
/* get window data */
|
||||
data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_PAGE | SIF_POS;
|
||||
GetScrollInfo(hWnd, SB_VERT, &si);
|
||||
|
||||
switch(LOWORD (wParam))
|
||||
{
|
||||
// User clicked the shaft above the scroll box.
|
||||
|
||||
case SB_PAGEUP:
|
||||
yInc = -(int)si.nPage;
|
||||
break;
|
||||
|
||||
// User clicked the shaft below the scroll box.
|
||||
|
||||
case SB_PAGEDOWN:
|
||||
yInc = si.nPage;
|
||||
break;
|
||||
|
||||
// User clicked the top arrow.
|
||||
|
||||
case SB_LINEUP:
|
||||
yInc = -1;
|
||||
break;
|
||||
|
||||
// User clicked the bottom arrow.
|
||||
|
||||
case SB_LINEDOWN:
|
||||
yInc = 1;
|
||||
break;
|
||||
|
||||
// User dragged the scroll box.
|
||||
|
||||
case SB_THUMBTRACK:
|
||||
yInc = HIWORD(wParam) - data->yPos;
|
||||
break;
|
||||
|
||||
default:
|
||||
yInc = 0;
|
||||
}
|
||||
|
||||
// If applying the vertical scrolling increment does not
|
||||
// take the scrolling position out of the scrolling range,
|
||||
// increment the scrolling position, adjust the position
|
||||
// of the scroll box, and update the window. UpdateWindow
|
||||
// sends the WM_PAINT message.
|
||||
|
||||
if (yInc = max(-data->yPos, min(yInc, data->yMax - data->yPos)))
|
||||
{
|
||||
data->yPos += yInc;
|
||||
/* ScrollWindowEx(hWnd, 0, -data->yChar * yInc,
|
||||
(CONST RECT *) NULL, (CONST RECT *) NULL,
|
||||
(HRGN) NULL, (LPRECT) NULL, SW_INVALIDATE | SW_ERASE);
|
||||
*/
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_POS;
|
||||
si.nPos = data->yPos;
|
||||
SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
|
||||
|
||||
UpdateWindow (hWnd);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MSG_WRAP_TEXT
|
||||
void onMSNH_HScroll(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHMessageWindow data;
|
||||
SCROLLINFO si;
|
||||
int xInc;
|
||||
|
||||
/* get window data */
|
||||
data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_PAGE;
|
||||
GetScrollInfo(hWnd, SB_HORZ, &si);
|
||||
|
||||
switch(LOWORD (wParam))
|
||||
{
|
||||
// User clicked shaft left of the scroll box.
|
||||
|
||||
case SB_PAGEUP:
|
||||
xInc = - (int)si.nPage;
|
||||
break;
|
||||
|
||||
// User clicked shaft right of the scroll box.
|
||||
|
||||
case SB_PAGEDOWN:
|
||||
xInc = si.nPage;
|
||||
break;
|
||||
|
||||
// User clicked the left arrow.
|
||||
|
||||
case SB_LINEUP:
|
||||
xInc = -1;
|
||||
break;
|
||||
|
||||
// User clicked the right arrow.
|
||||
|
||||
case SB_LINEDOWN:
|
||||
xInc = 1;
|
||||
break;
|
||||
|
||||
// User dragged the scroll box.
|
||||
|
||||
case SB_THUMBTRACK:
|
||||
xInc = HIWORD(wParam) - data->xPos;
|
||||
break;
|
||||
|
||||
default:
|
||||
xInc = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// If applying the horizontal scrolling increment does not
|
||||
// take the scrolling position out of the scrolling range,
|
||||
// increment the scrolling position, adjust the position
|
||||
// of the scroll box, and update the window.
|
||||
|
||||
if (xInc = max (-data->xPos, min (xInc, data->xMax - data->xPos)))
|
||||
{
|
||||
data->xPos += xInc;
|
||||
ScrollWindowEx (hWnd, -data->xChar * xInc, 0,
|
||||
(CONST RECT *) NULL, (CONST RECT *) NULL,
|
||||
(HRGN) NULL, (LPRECT) NULL, SW_INVALIDATE | SW_ERASE);
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_POS;
|
||||
si.nPos = data->xPos;
|
||||
SetScrollInfo(hWnd, SB_HORZ, &si, TRUE);
|
||||
UpdateWindow (hWnd);
|
||||
}
|
||||
}
|
||||
#endif // MSG_WRAP_TEXT
|
||||
|
||||
void onPaint(HWND hWnd)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
PNHMessageWindow data;
|
||||
RECT client_rt, draw_rt;
|
||||
int FirstLine, LastLine;
|
||||
int i, x, y;
|
||||
HGDIOBJ oldFont;
|
||||
TCHAR wbuf[MAXWINDOWTEXT+2];
|
||||
size_t wlen;
|
||||
COLORREF OldBg, OldFg;
|
||||
|
||||
hdc = BeginPaint(hWnd, &ps);
|
||||
|
||||
OldBg = SetBkColor(hdc, mswin_get_color(NHW_MESSAGE, MSWIN_COLOR_BG));
|
||||
OldFg = SetTextColor(hdc, mswin_get_color(NHW_MESSAGE, MSWIN_COLOR_FG));
|
||||
|
||||
data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
GetClientRect(hWnd, &client_rt);
|
||||
|
||||
if( !IsRectEmpty(&ps.rcPaint) ) {
|
||||
FirstLine = max (0, data->yPos + ps.rcPaint.top/data->yChar - 1);
|
||||
LastLine = min (MSG_LINES-1, data->yPos + ps.rcPaint.bottom/data->yChar);
|
||||
y = min( ps.rcPaint.bottom, client_rt.bottom - 2);
|
||||
for (i=LastLine; i>=FirstLine; i--) {
|
||||
if( i==MSG_LINES-1 ) {
|
||||
x = data->xChar * (2 - data->xPos);
|
||||
} else {
|
||||
x = data->xChar * (4 - data->xPos);
|
||||
}
|
||||
|
||||
|
||||
if( strlen(data->window_text[i].text)>0 ) {
|
||||
/* convert to UNICODE */
|
||||
NH_A2W(data->window_text[i].text, wbuf, sizeof(wbuf));
|
||||
wlen = _tcslen(wbuf);
|
||||
|
||||
/* calculate text height */
|
||||
draw_rt.left = x;
|
||||
draw_rt.right = client_rt.right;
|
||||
draw_rt.top = y - data->yChar;
|
||||
draw_rt.bottom = y;
|
||||
|
||||
oldFont = SelectObject(hdc, mswin_get_font(NHW_MESSAGE, data->window_text[i].attr, hdc, FALSE));
|
||||
|
||||
#ifdef MSG_WRAP_TEXT
|
||||
DrawText(hdc, wbuf, wlen, &draw_rt, DT_NOPREFIX | DT_WORDBREAK | DT_CALCRECT);
|
||||
draw_rt.top = y - (draw_rt.bottom - draw_rt.top);
|
||||
draw_rt.bottom = y;
|
||||
DrawText(hdc, wbuf, wlen, &draw_rt, DT_NOPREFIX | DT_WORDBREAK);
|
||||
#else
|
||||
DrawText(hdc, wbuf, wlen, &draw_rt, DT_NOPREFIX );
|
||||
#endif
|
||||
SelectObject(hdc, oldFont);
|
||||
|
||||
y -= draw_rt.bottom - draw_rt.top;
|
||||
} else {
|
||||
y -= data->yChar;
|
||||
}
|
||||
|
||||
/* highligh the last line */
|
||||
if( i==MSG_LINES-1 ) {
|
||||
draw_rt.left = client_rt.left;
|
||||
draw_rt.right = draw_rt.left + 2*data->xChar;
|
||||
DrawText(hdc, TEXT("> "), 2, &draw_rt, DT_NOPREFIX );
|
||||
|
||||
y -= 2;
|
||||
draw_rt.left = client_rt.left;
|
||||
draw_rt.right = client_rt.right;
|
||||
draw_rt.top -= 2;
|
||||
draw_rt.bottom = client_rt.bottom;
|
||||
DrawEdge(hdc, &draw_rt, EDGE_SUNKEN, BF_TOP );
|
||||
DrawEdge(hdc, &draw_rt, EDGE_SUNKEN, BF_BOTTOM );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetTextColor (hdc, OldFg);
|
||||
SetBkColor (hdc, OldBg);
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
|
||||
void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
TEXTMETRIC tm;
|
||||
PNHMessageWindow data;
|
||||
HGDIOBJ saveFont;
|
||||
|
||||
/* set window data */
|
||||
data = (PNHMessageWindow)malloc(sizeof(NHMessageWindow));
|
||||
if( !data ) panic("out of memory");
|
||||
ZeroMemory(data, sizeof(NHMessageWindow));
|
||||
data->max_text = MAXWINDOWTEXT;
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)data);
|
||||
|
||||
/* Get the handle to the client area's device context. */
|
||||
hdc = prepareDC( GetDC(hWnd) );
|
||||
saveFont = SelectObject(hdc, mswin_get_font(NHW_MESSAGE, ATR_NONE, hdc, FALSE));
|
||||
|
||||
/* Extract font dimensions from the text metrics. */
|
||||
GetTextMetrics (hdc, &tm);
|
||||
data->xChar = tm.tmAveCharWidth;
|
||||
data->xUpper = (tm.tmPitchAndFamily & 1 ? 3 : 2) * data->xChar/2;
|
||||
data->yChar = tm.tmHeight + tm.tmExternalLeading;
|
||||
data->xPage = 1;
|
||||
|
||||
/* Free the device context. */
|
||||
SelectObject(hdc, saveFont);
|
||||
ReleaseDC (hWnd, hdc);
|
||||
}
|
||||
|
||||
HDC prepareDC( HDC hdc )
|
||||
{
|
||||
// set font here
|
||||
return hdc;
|
||||
}
|
||||
|
||||
|
||||
void mswin_message_window_size (HWND hWnd, LPSIZE sz)
|
||||
{
|
||||
PNHMessageWindow data;
|
||||
RECT rt, client_rt;
|
||||
|
||||
GetWindowRect(hWnd, &rt);
|
||||
|
||||
sz->cx = rt.right - rt.left;
|
||||
sz->cy = rt.bottom - rt.top;
|
||||
|
||||
data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
if(data) {
|
||||
/* set size to accomodate MSG_VISIBLE_LINES, highligh rectangle and
|
||||
horizontal scroll bar (difference between window rect and client rect */
|
||||
GetClientRect(hWnd, &client_rt);
|
||||
sz->cy = sz->cy-(client_rt.bottom - client_rt.top) +
|
||||
data->yChar * MSG_VISIBLE_LINES + 4;
|
||||
}
|
||||
}
|
||||
15
sys/wince/mhmsgwnd.h
Normal file
15
sys/wince/mhmsgwnd.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MSWINMessageWindow_h
|
||||
#define MSWINMessageWindow_h
|
||||
|
||||
#include "winMS.h"
|
||||
#include "config.h"
|
||||
#include "global.h"
|
||||
|
||||
HWND mswin_init_message_window ();
|
||||
void mswin_message_window_size (HWND hWnd, LPSIZE sz);
|
||||
|
||||
|
||||
#endif /* MSWINMessageWindow_h */
|
||||
17
sys/wince/mhrip.c
Normal file
17
sys/wince/mhrip.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "winMS.h"
|
||||
#include "resource.h"
|
||||
#include "mhrip.h"
|
||||
#include "mhtext.h"
|
||||
|
||||
HWND mswin_init_RIP_window ()
|
||||
{
|
||||
return mswin_init_text_window();
|
||||
}
|
||||
|
||||
void mswin_display_RIP_window (HWND hWnd)
|
||||
{
|
||||
mswin_display_text_window(hWnd);
|
||||
}
|
||||
14
sys/wince/mhrip.h
Normal file
14
sys/wince/mhrip.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MSWINRIPWindow_h
|
||||
#define MSWINRIPWindow_h
|
||||
|
||||
#include "winMS.h"
|
||||
#include "config.h"
|
||||
#include "global.h"
|
||||
|
||||
HWND mswin_init_RIP_window ();
|
||||
void mswin_display_RIP_window (HWND hwnd);
|
||||
|
||||
#endif /* MSWINRIPWindow_h */
|
||||
262
sys/wince/mhstatus.c
Normal file
262
sys/wince/mhstatus.c
Normal file
@@ -0,0 +1,262 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "winMS.h"
|
||||
#include "mhstatus.h"
|
||||
#include "mhmsg.h"
|
||||
#include "mhfont.h"
|
||||
#include "mhcolor.h"
|
||||
|
||||
#define MAXWINDOWTEXT 255
|
||||
#define NHSW_LINES 4
|
||||
|
||||
typedef struct mswin_nethack_status_window {
|
||||
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);
|
||||
|
||||
HWND mswin_init_status_window () {
|
||||
static int run_once = 0;
|
||||
HWND ret;
|
||||
NHStatusWindow* data;
|
||||
|
||||
if( !run_once ) {
|
||||
register_status_window_class( );
|
||||
run_once = 1;
|
||||
}
|
||||
|
||||
ret = CreateWindow(
|
||||
szStatusWindowClass,
|
||||
NULL,
|
||||
WS_CHILD | WS_DISABLED | WS_CLIPSIBLINGS,
|
||||
0, /* x position */
|
||||
0, /* y position */
|
||||
0, /* x-size - we will set it later */
|
||||
0, /* y-size - we will set it later */
|
||||
GetNHApp()->hMainWnd,
|
||||
NULL,
|
||||
GetNHApp()->hApp,
|
||||
NULL );
|
||||
if( !ret ) panic("Cannot create status window");
|
||||
|
||||
EnableWindow(ret, FALSE);
|
||||
|
||||
data = (PNHStatusWindow)malloc(sizeof(NHStatusWindow));
|
||||
if( !data ) panic("out of memory");
|
||||
|
||||
ZeroMemory(data, sizeof(NHStatusWindow));
|
||||
SetWindowLong(ret, GWL_USERDATA, (LONG)data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void register_status_window_class()
|
||||
{
|
||||
WNDCLASS wcex;
|
||||
|
||||
ZeroMemory( &wcex, sizeof(wcex));
|
||||
wcex.style = CS_NOCLOSE;
|
||||
wcex.lpfnWndProc = (WNDPROC)StatusWndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = GetNHApp()->hApp;
|
||||
wcex.hIcon = NULL;
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = mswin_get_brush(NHW_STATUS, MSWIN_COLOR_BG);
|
||||
wcex.lpszMenuName = NULL;
|
||||
wcex.lpszClassName = szStatusWindowClass;
|
||||
|
||||
RegisterClass(&wcex);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CALLBACK StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
RECT rt;
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
PNHStatusWindow data;
|
||||
|
||||
data = (PNHStatusWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
switch (message)
|
||||
{
|
||||
case WM_MSNH_COMMAND: {
|
||||
switch( wParam ) {
|
||||
|
||||
case MSNH_MSG_PUTSTR:
|
||||
case MSNH_MSG_CLEAR_WINDOW:
|
||||
ZeroMemory(data->window_text, sizeof(data->window_text));
|
||||
FormatStatusString(data->window_text);
|
||||
break;
|
||||
|
||||
case MSNH_MSG_CURSOR: {
|
||||
PMSNHMsgCursor msg_data = (PMSNHMsgCursor)lParam;
|
||||
if( msg_data->y==0 ) {
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case WM_PAINT: {
|
||||
HGDIOBJ oldFont;
|
||||
TCHAR wbuf[MAXWINDOWTEXT];
|
||||
COLORREF OldBg, OldFg;
|
||||
|
||||
hdc = BeginPaint(hWnd, &ps);
|
||||
GetClientRect(hWnd, &rt);
|
||||
|
||||
oldFont = SelectObject(hdc, mswin_get_font(NHW_STATUS, ATR_NONE, hdc, FALSE));
|
||||
OldBg = SetBkColor(hdc, mswin_get_color(NHW_STATUS, MSWIN_COLOR_BG));
|
||||
OldFg = SetTextColor(hdc, mswin_get_color(NHW_STATUS, MSWIN_COLOR_FG));
|
||||
|
||||
DrawText(hdc,
|
||||
NH_A2W(data->window_text, wbuf, MAXWINDOWTEXT),
|
||||
strlen(data->window_text),
|
||||
&rt,
|
||||
DT_LEFT | DT_NOPREFIX);
|
||||
|
||||
SetTextColor (hdc, OldFg);
|
||||
SetBkColor (hdc, OldBg);
|
||||
SelectObject(hdc, oldFont);
|
||||
EndPaint(hWnd, &ps);
|
||||
} break;
|
||||
|
||||
case WM_DESTROY:
|
||||
free(data);
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)0);
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
SetFocus(GetNHApp()->hMainWnd);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mswin_status_window_size (HWND hWnd, LPSIZE sz)
|
||||
{
|
||||
TEXTMETRIC tm;
|
||||
HGDIOBJ saveFont;
|
||||
HDC hdc;
|
||||
PNHStatusWindow data;
|
||||
RECT rt;
|
||||
GetWindowRect(hWnd, &rt);
|
||||
sz->cx = rt.right - rt.left;
|
||||
sz->cy = rt.bottom - rt.top;
|
||||
|
||||
data = (PNHStatusWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
if(data) {
|
||||
hdc = GetDC(hWnd);
|
||||
saveFont = SelectObject(hdc, mswin_get_font(NHW_STATUS, ATR_NONE, hdc, FALSE));
|
||||
GetTextMetrics(hdc, &tm);
|
||||
|
||||
sz->cy = tm.tmHeight * NHSW_LINES;
|
||||
|
||||
SelectObject(hdc, saveFont);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
}
|
||||
}
|
||||
extern const char *hu_stat[]; /* defined in eat.c */
|
||||
extern const char *enc_stat[]; /* define in botl.c */
|
||||
void FormatStatusString(char* text)
|
||||
{
|
||||
register char *nb;
|
||||
int hp, hpmax;
|
||||
int cap = near_capacity();
|
||||
|
||||
Strcpy(text, plname);
|
||||
if('a' <= text[0] && text[0] <= 'z') text[0] += 'A'-'a';
|
||||
text[10] = 0;
|
||||
Sprintf(nb = eos(text)," the ");
|
||||
|
||||
if (Upolyd) {
|
||||
char mbot[BUFSZ];
|
||||
int k = 0;
|
||||
|
||||
Strcpy(mbot, mons[u.umonnum].mname);
|
||||
while(mbot[k] != 0) {
|
||||
if ((k == 0 || (k > 0 && mbot[k-1] == ' ')) &&
|
||||
'a' <= mbot[k] && mbot[k] <= 'z')
|
||||
mbot[k] += 'A' - 'a';
|
||||
k++;
|
||||
}
|
||||
Sprintf(nb = eos(nb), mbot);
|
||||
} else
|
||||
Sprintf(nb = eos(nb), rank_of(u.ulevel, Role_switch, flags.female));
|
||||
|
||||
Sprintf(nb = eos(nb),"\r\n");
|
||||
|
||||
if (ACURR(A_STR) > 18) {
|
||||
if (ACURR(A_STR) > STR18(100))
|
||||
Sprintf(nb = eos(nb),"St:%2d ",ACURR(A_STR)-100);
|
||||
else if (ACURR(A_STR) < STR18(100))
|
||||
Sprintf(nb = eos(nb), "St:18/%02d ",ACURR(A_STR)-18);
|
||||
else
|
||||
Sprintf(nb = eos(nb),"St:18/** ");
|
||||
} else
|
||||
Sprintf(nb = eos(nb), "St:%-1d ",ACURR(A_STR));
|
||||
Sprintf(nb = eos(nb),
|
||||
"Dx:%-1d Co:%-1d In:%-1d Wi:%-1d Ch:%-1d",
|
||||
ACURR(A_DEX), ACURR(A_CON), ACURR(A_INT), ACURR(A_WIS), ACURR(A_CHA));
|
||||
Sprintf(nb = eos(nb), (u.ualign.type == A_CHAOTIC) ? " Chaotic" :
|
||||
(u.ualign.type == A_NEUTRAL) ? " Neutral" : " Lawful");
|
||||
#ifdef SCORE_ON_BOTL
|
||||
if (flags.showscore)
|
||||
Sprintf(nb = eos(nb), " S:%ld", botl_score());
|
||||
#endif
|
||||
strcat(text, "\r\n");
|
||||
|
||||
/* third line */
|
||||
hp = Upolyd ? u.mh : u.uhp;
|
||||
hpmax = Upolyd ? u.mhmax : u.uhpmax;
|
||||
|
||||
if(hp < 0) hp = 0;
|
||||
(void) describe_level(nb=eos(nb));
|
||||
Sprintf(nb = eos(nb),
|
||||
"%c:%-2ld HP:%d(%d) Pw:%d(%d) AC:%-2d", oc_syms[COIN_CLASS],
|
||||
#ifndef GOLDOBJ
|
||||
u.ugold,
|
||||
#else
|
||||
money_cnt(invent),
|
||||
#endif
|
||||
hp, hpmax, u.uen, u.uenmax, u.uac);
|
||||
|
||||
if (Upolyd)
|
||||
Sprintf(nb = eos(nb), " HD:%d", mons[u.umonnum].mlevel);
|
||||
#ifdef EXP_ON_BOTL
|
||||
else if(flags.showexp)
|
||||
Sprintf(nb = eos(nb), " Xp:%u/%-1ld", u.ulevel,u.uexp);
|
||||
#endif
|
||||
else
|
||||
Sprintf(nb = eos(nb), " Exp:%u", u.ulevel);
|
||||
strcat(text, "\r\n");
|
||||
|
||||
/* forth line */
|
||||
if(flags.time)
|
||||
Sprintf(nb = eos(nb), "T:%ld ", moves);
|
||||
|
||||
if(strcmp(hu_stat[u.uhs], " ")) {
|
||||
Strcat(text, hu_stat[u.uhs]);
|
||||
Sprintf(nb = eos(nb), " ");
|
||||
}
|
||||
if(Confusion) Sprintf(nb = eos(nb), "Conf");
|
||||
if(Sick) {
|
||||
if (u.usick_type & SICK_VOMITABLE)
|
||||
Sprintf(nb = eos(nb), " FoodPois");
|
||||
if (u.usick_type & SICK_NONVOMITABLE)
|
||||
Sprintf(nb = eos(nb), " Ill");
|
||||
}
|
||||
if(Blind) Sprintf(nb = eos(nb), " Blind");
|
||||
if(Stunned) Sprintf(nb = eos(nb), " Stun");
|
||||
if(Hallucination) Sprintf(nb = eos(nb), " Hallu");
|
||||
if(Slimed) Sprintf(nb = eos(nb), " Slime");
|
||||
if(cap > UNENCUMBERED)
|
||||
Sprintf(nb = eos(nb), " %s", enc_stat[cap]);
|
||||
}
|
||||
14
sys/wince/mhstatus.h
Normal file
14
sys/wince/mhstatus.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MSWINStatusWindow_h
|
||||
#define MSWINStatusWindow_h
|
||||
|
||||
#include "winMS.h"
|
||||
#include "config.h"
|
||||
#include "global.h"
|
||||
|
||||
HWND mswin_init_status_window ();
|
||||
void mswin_status_window_size (HWND hWnd, LPSIZE sz);
|
||||
|
||||
#endif /* MSWINStatusWindow_h */
|
||||
180
sys/wince/mhtext.c
Normal file
180
sys/wince/mhtext.c
Normal file
@@ -0,0 +1,180 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "winMS.h"
|
||||
#include "resource.h"
|
||||
#include "mhtext.h"
|
||||
#include "mhmsg.h"
|
||||
#include "mhfont.h"
|
||||
#include "mhcolor.h"
|
||||
|
||||
typedef struct mswin_nethack_text_window {
|
||||
TCHAR* window_text;
|
||||
} NHTextWindow, *PNHTextWindow;
|
||||
|
||||
LRESULT CALLBACK TextWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
static void LayoutText(HWND hwnd);
|
||||
|
||||
HWND mswin_init_text_window () {
|
||||
HWND ret;
|
||||
PNHTextWindow data;
|
||||
|
||||
ret = CreateDialog(
|
||||
GetNHApp()->hApp,
|
||||
MAKEINTRESOURCE(IDD_NHTEXT),
|
||||
GetNHApp()->hMainWnd,
|
||||
TextWndProc
|
||||
);
|
||||
if( !ret ) panic("Cannot create text window");
|
||||
|
||||
data = (PNHTextWindow)malloc(sizeof(NHTextWindow));
|
||||
if( !data ) panic("out of memory");
|
||||
|
||||
ZeroMemory(data, sizeof(NHTextWindow));
|
||||
SetWindowLong(ret, GWL_USERDATA, (LONG)data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void mswin_display_text_window (HWND hWnd)
|
||||
{
|
||||
PNHTextWindow data;
|
||||
|
||||
data = (PNHTextWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
if( data && data->window_text ) {
|
||||
HWND control;
|
||||
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);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK TextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND control;
|
||||
HDC hdc;
|
||||
PNHTextWindow data;
|
||||
|
||||
data = (PNHTextWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
/* set text control font */
|
||||
control = GetDlgItem(hWnd, IDC_TEXT_CONTROL);
|
||||
if( !control ) {
|
||||
panic("cannot get text view window");
|
||||
}
|
||||
|
||||
hdc = GetDC(control);
|
||||
SendMessage(control, WM_SETFONT, (WPARAM)mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE), 0);
|
||||
ReleaseDC(control, hdc);
|
||||
|
||||
SetFocus(control);
|
||||
return FALSE;
|
||||
|
||||
case WM_MSNH_COMMAND:
|
||||
onMSNHCommand(hWnd, wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
LayoutText(hWnd);
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
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);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CTLCOLORBTN:
|
||||
case WM_CTLCOLOREDIT:
|
||||
case WM_CTLCOLORSTATIC: { /* sent by edit control before it is drawn */
|
||||
HDC hdcEdit = (HDC) wParam;
|
||||
HWND hwndEdit = (HWND) lParam;
|
||||
if( hwndEdit == GetDlgItem(hWnd, IDC_TEXT_CONTROL) ) {
|
||||
SetBkColor(hdcEdit, mswin_get_color(NHW_TEXT, MSWIN_COLOR_BG));
|
||||
SetTextColor(hdcEdit, mswin_get_color(NHW_TEXT, MSWIN_COLOR_FG));
|
||||
return (BOOL)mswin_get_brush(NHW_TEXT, MSWIN_COLOR_BG);
|
||||
}
|
||||
} return FALSE;
|
||||
|
||||
case WM_DESTROY:
|
||||
if( data ) {
|
||||
if( data->window_text ) free(data->window_text);
|
||||
free(data);
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)0);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PNHTextWindow data;
|
||||
|
||||
data = (PNHTextWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
switch( wParam ) {
|
||||
case MSNH_MSG_PUTSTR: {
|
||||
PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr)lParam;
|
||||
TCHAR wbuf[NHSTR_BUFSIZE];
|
||||
size_t text_size;
|
||||
|
||||
if( !data->window_text ) {
|
||||
text_size = strlen(msg_data->text) + 4;
|
||||
data->window_text = (TCHAR*)malloc(text_size*sizeof(data->window_text[0]));
|
||||
ZeroMemory(data->window_text, text_size*sizeof(data->window_text[0]));
|
||||
} else {
|
||||
text_size = _tcslen(data->window_text) + strlen(msg_data->text) + 4;
|
||||
data->window_text = (TCHAR*)realloc(data->window_text, text_size*sizeof(data->window_text[0]));
|
||||
}
|
||||
if( !data->window_text ) break;
|
||||
|
||||
_tcscat(data->window_text, NH_A2W(msg_data->text, wbuf, NHSTR_BUFSIZE));
|
||||
_tcscat(data->window_text, TEXT("\r\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutText(HWND hWnd)
|
||||
{
|
||||
HWND btn_ok;
|
||||
HWND text;
|
||||
RECT clrt, rt;
|
||||
POINT pt_elem, pt_ok;
|
||||
SIZE sz_elem, sz_ok;
|
||||
|
||||
text = GetDlgItem(hWnd, IDC_TEXT_CONTROL);
|
||||
btn_ok = GetDlgItem(hWnd, IDOK);
|
||||
|
||||
/* get window coordinates */
|
||||
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;
|
||||
|
||||
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 );
|
||||
}
|
||||
14
sys/wince/mhtext.h
Normal file
14
sys/wince/mhtext.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef MSWINTextWindow_h
|
||||
#define MSWINTextWindow_h
|
||||
|
||||
#include "winMS.h"
|
||||
#include "config.h"
|
||||
#include "global.h"
|
||||
|
||||
HWND mswin_init_text_window ();
|
||||
void mswin_display_text_window (HWND hwnd);
|
||||
|
||||
#endif /* MSWINTextWindow_h */
|
||||
1762
sys/wince/mswproc.c
Normal file
1762
sys/wince/mswproc.c
Normal file
File diff suppressed because it is too large
Load Diff
39
sys/wince/newres.h
Normal file
39
sys/wince/newres.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef __NEWRES_H__
|
||||
#define __NEWRES_H__
|
||||
|
||||
#if !defined(UNDER_CE)
|
||||
#define UNDER_CE _WIN32_WCE
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
#if !defined(WCEOLE_ENABLE_DIALOGEX)
|
||||
#define DIALOGEX DIALOG DISCARDABLE
|
||||
#endif
|
||||
#include <commctrl.h>
|
||||
#define SHMENUBAR RCDATA
|
||||
#if defined(WIN32_PLATFORM_PSPC) && (_WIN32_WCE >= 300)
|
||||
#include <aygshell.h>
|
||||
#else
|
||||
#define I_IMAGENONE (-2)
|
||||
#define NOMENU 0xFFFF
|
||||
#define IDS_SHNEW 1
|
||||
|
||||
#define IDM_SHAREDNEW 10
|
||||
#define IDM_SHAREDNEWDEFAULT 11
|
||||
#endif
|
||||
#endif // _WIN32_WCE
|
||||
|
||||
|
||||
#ifdef RC_INVOKED
|
||||
#ifndef _INC_WINDOWS
|
||||
#define _INC_WINDOWS
|
||||
#include "winuser.h" // extract from windows header
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef IDC_STATIC
|
||||
#undef IDC_STATIC
|
||||
#endif
|
||||
#define IDC_STATIC (-1)
|
||||
|
||||
#endif //__NEWRES_H__
|
||||
1898
sys/wince/recover.vcp
Normal file
1898
sys/wince/recover.vcp
Normal file
File diff suppressed because it is too large
Load Diff
150
sys/wince/resource.h
Normal file
150
sys/wince/resource.h
Normal file
@@ -0,0 +1,150 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by winhack.rc
|
||||
//
|
||||
#define IDC_MYICON 2
|
||||
#define IDD_WINHACK_DIALOG 102
|
||||
#define IDD_ABOUTBOX 103
|
||||
#define IDS_APP_TITLE 103
|
||||
#define IDM_ABOUT 104
|
||||
#define IDM_EXIT 105
|
||||
#define IDS_HELLO 106
|
||||
#define IDI_WINHACK 107
|
||||
#define IDC_WINHACK 109
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDB_TILES 129
|
||||
#define IDD_TEXT 130
|
||||
#define IDD_NHTEXT 130
|
||||
#define IDD_MENU 132
|
||||
#define IDB_MENU_SEL 133
|
||||
#define IDB_MENU_UNSEL 134
|
||||
#define IDD_COMMANDS 136
|
||||
#define IDD_GETLIN 138
|
||||
#define IDD_EXTCMD 139
|
||||
#define IDD_PLAYER_SELECTOR 141
|
||||
#define IDB_PETMARK 145
|
||||
#define IDB_MENU_SEL_COUNT 146
|
||||
#define IDB_KEYPAD 147
|
||||
#define IDC_TEXT_VIEW 1001
|
||||
#define IDC_CMD_MOVE_NW 1001
|
||||
#define IDC_CMD_MOVE_N 1002
|
||||
#define IDC_MENU_LIST 1003
|
||||
#define IDC_CMD_MOVE_NE 1003
|
||||
#define IDC_MENU_TEXT 1004
|
||||
#define IDC_CMD_MOVE_W 1004
|
||||
#define IDC_CMD_MOVE_SELF 1005
|
||||
#define IDC_CMD_MOVE_E 1006
|
||||
#define IDC_CMD_MOVE_SW 1007
|
||||
#define IDC_CMD_MOVE_S 1008
|
||||
#define IDC_CMD_MOVE_SE 1009
|
||||
#define IDC_CMD_MOVE_UP 1010
|
||||
#define IDC_CMD_MOVE_DOWN 1011
|
||||
#define IDC_CMD_5 1012
|
||||
#define IDC_CMD_A 1013
|
||||
#define IDC_CMD_B 1014
|
||||
#define IDC_CMD_C 1015
|
||||
#define IDC_CMD_D 1016
|
||||
#define IDC_CMD_E 1017
|
||||
#define IDC_CMD_F 1018
|
||||
#define IDC_CMD_G 1019
|
||||
#define IDC_CMD_H 1020
|
||||
#define IDC_CMD_I 1021
|
||||
#define IDC_CMD_J 1022
|
||||
#define IDC_CMD_K 1023
|
||||
#define IDC_CMD_L 1024
|
||||
#define IDC_CMD_M 1025
|
||||
#define IDC_CMD_N 1026
|
||||
#define IDC_CMD_O 1027
|
||||
#define IDC_CMD_P 1028
|
||||
#define IDC_CMD_Q 1029
|
||||
#define IDC_CMD_R 1030
|
||||
#define IDC_CMD_S 1031
|
||||
#define IDC_CMD_T 1032
|
||||
#define IDC_CMD_U 1033
|
||||
#define IDC_CMD_V 1034
|
||||
#define IDC_CMD_W 1035
|
||||
#define IDC_CMD_X 1036
|
||||
#define IDC_CMD_Y 1037
|
||||
#define IDC_CMD_Z 1038
|
||||
#define IDC_CMD_AA 1039
|
||||
#define IDC_CMD_BB 1040
|
||||
#define IDC_CMD_CC 1041
|
||||
#define IDC_CMD_DD 1042
|
||||
#define IDC_CMD_EE 1043
|
||||
#define IDC_CMD_FF 1044
|
||||
#define IDC_CMD_GG 1045
|
||||
#define IDC_CMD_HH 1046
|
||||
#define IDC_CMD_II 1047
|
||||
#define IDC_CMD_JJ 1048
|
||||
#define IDC_CMD_KK 1049
|
||||
#define IDC_CMD_LL 1050
|
||||
#define IDC_CMD_MM 1051
|
||||
#define IDC_CMD_NN 1052
|
||||
#define IDC_CMD_OO 1053
|
||||
#define IDC_CMD_PP 1054
|
||||
#define IDC_CMD_QQ 1055
|
||||
#define IDC_CMD_RR 1056
|
||||
#define IDC_CMD_SS 1057
|
||||
#define IDC_CMD_TT 1058
|
||||
#define IDC_CMD_UU 1059
|
||||
#define IDC_CMD_VV 1060
|
||||
#define IDC_CMD_WW 1061
|
||||
#define IDC_CMD_XX 1062
|
||||
#define IDC_CMD_YY 1063
|
||||
#define IDC_CMD_ZZ 1064
|
||||
#define IDC_CMD_FIRST 1100
|
||||
#define IDC_CMD_LAST 1300
|
||||
#define IDC_GETLIN_EDIT 1309
|
||||
#define IDC_EXTCMD_LIST 1310
|
||||
#define IDC_PLSEL_NAME 1314
|
||||
#define IDC_PLSEL_ROLE_RANDOM 1315
|
||||
#define IDC_PLSEL_RACE_RANDOM 1318
|
||||
#define IDC_PLSEL_GENDER_RANDOM 1319
|
||||
#define IDC_PLSEL_ALIGN_RANDOM 1320
|
||||
#define IDC_PLSEL_ROLE_LIST 1323
|
||||
#define IDC_PLSEL_RACE_LIST 1324
|
||||
#define IDC_PLSEL_ALIGN_LIST 1325
|
||||
#define IDC_PLSEL_GENDER_LIST 1326
|
||||
#define IDC_ABOUT_VERSION 1327
|
||||
#define IDC_TEXT_CONTROL 1331
|
||||
#define IDC_ABOUT_COPYRIGHT 1332
|
||||
#define IDM_SAVE 32771
|
||||
#define IDM_HELP_LONG 32772
|
||||
#define IDM_HELP_COMMANDS 32773
|
||||
#define IDM_HELP_HISTORY 32774
|
||||
#define IDM_HELP_INFO_CHAR 32775
|
||||
#define IDM_HELP_INFO_KEY 32776
|
||||
#define IDM_HELP_OPTIONS 32777
|
||||
#define IDM_HELP_OPTIONS_LONG 32778
|
||||
#define IDM_HELP_EXTCMD 32779
|
||||
#define IDM_HELP_LICENSE 32780
|
||||
#define IDM_MAP_TILES 32781
|
||||
#define IDM_MAP_ASCII4X6 32782
|
||||
#define IDM_MAP_ASCII6X8 32783
|
||||
#define IDM_MAP_ASCII8X8 32784
|
||||
#define IDM_MAP_ASCII16X8 32785
|
||||
#define IDM_MAP_ASCII7X12 32786
|
||||
#define IDM_MAP_ASCII8X12 32787
|
||||
#define IDM_MAP_ASCII16X12 32788
|
||||
#define IDM_MAP_ASCII12X16 32789
|
||||
#define IDM_MAP_ASCII10X18 32790
|
||||
#define IDM_MAP_FIT_TO_SCREEN 32791
|
||||
#define ID_FILE 32792
|
||||
#define IDS_CAP_FILE 32793
|
||||
#define ID_HELP 32794
|
||||
#define IDS_CAP_HELP 32795
|
||||
#define IDS_CAP_TEMP 32796
|
||||
#define ID_MAP 32797
|
||||
#define IDS_CAP_AMP 32798
|
||||
#define IDS_CAP_MAP 32799
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 148
|
||||
#define _APS_NEXT_COMMAND_VALUE 32800
|
||||
#define _APS_NEXT_CONTROL_VALUE 1333
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
||||
2
sys/wince/stat.h
Normal file
2
sys/wince/stat.h
Normal file
@@ -0,0 +1,2 @@
|
||||
/* empty file */
|
||||
|
||||
141
sys/wince/winMS.h
Normal file
141
sys/wince/winMS.h
Normal file
@@ -0,0 +1,141 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef WINMS_H
|
||||
#define WINMS_H
|
||||
|
||||
#pragma warning(disable:4142) /* benign redefinition of type */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <tchar.h>
|
||||
#include "hack.h"
|
||||
|
||||
/* Create an array to keep track of the various windows */
|
||||
|
||||
#ifndef MAXWINDOWS
|
||||
#define MAXWINDOWS 15
|
||||
#endif
|
||||
|
||||
/* RIP window ID */
|
||||
#define NHW_RIP 32
|
||||
#define NHW_KEYPAD 33
|
||||
|
||||
/* size of tiles */
|
||||
#ifndef TILE_X
|
||||
#define TILE_X 16
|
||||
#endif
|
||||
#define TILE_Y 16
|
||||
|
||||
/* tiles per line in the bitmap */
|
||||
#define TILES_PER_LINE 40
|
||||
|
||||
/* tile background color */
|
||||
#define TILE_BK_COLOR RGB(71, 108, 108)
|
||||
|
||||
/* minimum/maximum font size (in points - 1/72 inch) */
|
||||
#define NHFONT_DEFAULT_SIZE 9
|
||||
#define NHFONT_STATUS_DEFAULT_SIZE 6
|
||||
#define NHFONT_SIZE_MIN 3
|
||||
#define NHFONT_SIZE_MAX 20
|
||||
|
||||
typedef struct mswin_nhwindow_data {
|
||||
HWND win;
|
||||
int type;
|
||||
int dead;
|
||||
} MSNHWinData, *PMSNHWinData;
|
||||
|
||||
/* global application data - alailable thour GetNHApp() */
|
||||
typedef struct mswin_nhwindow_app {
|
||||
HINSTANCE hApp; /* hInstance from WinMain */
|
||||
int nCmdShow; /* main window mode flag */
|
||||
HWND hMainWnd; /* main window handle */
|
||||
HACCEL hAccelTable; /* accelerator table */
|
||||
HWND hPopupWnd; /* active dialog window (nethack menu, text, etc) */
|
||||
HWND hMenuBar; /* menu bar */
|
||||
|
||||
MSNHWinData windowlist[MAXWINDOWS]; /* nethack windows array */
|
||||
|
||||
HBITMAP bmpTiles; /* nethack tiles */
|
||||
HBITMAP bmpPetMark; /* pet mark Bitmap */
|
||||
HBITMAP bmpMapTiles; /* alternative map tiles */
|
||||
int mapTile_X; /* alt. tiles width */
|
||||
int mapTile_Y; /* alt. tiles height */
|
||||
int mapTilesPerLine; /* number of tile per row in the bitmap */
|
||||
|
||||
boolean bNoHScroll; /* disable cliparound for horizontal grid (map) */
|
||||
boolean bNoVScroll; /* disable cliparound for vertical grid (map) */
|
||||
|
||||
int mapDisplayModeSave; /* saved map display mode */
|
||||
|
||||
int bCmdPad; /* command pad - on-screen keyboard */
|
||||
} NHWinApp, *PNHWinApp;
|
||||
extern PNHWinApp GetNHApp();
|
||||
|
||||
#define E extern
|
||||
|
||||
E struct window_procs mswin_procs;
|
||||
|
||||
#undef E
|
||||
|
||||
/* Some prototypes */
|
||||
void mswin_init_nhwindows(int* argc, char** argv);
|
||||
void mswin_player_selection(void);
|
||||
void mswin_askname(void);
|
||||
void mswin_get_nh_event(void);
|
||||
void mswin_exit_nhwindows(const char *);
|
||||
void mswin_suspend_nhwindows(const char *);
|
||||
void mswin_resume_nhwindows(void);
|
||||
winid mswin_create_nhwindow(int type);
|
||||
void mswin_clear_nhwindow(winid wid);
|
||||
void mswin_display_nhwindow(winid wid, BOOLEAN_P block);
|
||||
void mswin_destroy_nhwindow(winid wid);
|
||||
void mswin_curs(winid wid, int x, int y);
|
||||
void mswin_putstr(winid wid, int attr, const char *text);
|
||||
void mswin_putstr_ex(winid wid, int attr, const char *text, boolean append);
|
||||
void mswin_display_file(const char *filename,BOOLEAN_P must_exist);
|
||||
void mswin_start_menu(winid wid);
|
||||
void mswin_add_menu(winid wid, int glyph, const ANY_P * identifier,
|
||||
CHAR_P accelerator, CHAR_P group_accel, int attr,
|
||||
const char *str, BOOLEAN_P presel);
|
||||
void mswin_end_menu(winid wid, const char *prompt);
|
||||
int mswin_select_menu(winid wid, int how, MENU_ITEM_P **selected);
|
||||
void mswin_update_inventory(void);
|
||||
void mswin_mark_synch(void);
|
||||
void mswin_wait_synch(void);
|
||||
void mswin_cliparound(int x, int y);
|
||||
void mswin_print_glyph(winid wid,XCHAR_P x,XCHAR_P y,int glyph);
|
||||
void mswin_raw_print(const char *str);
|
||||
void mswin_raw_print_bold(const char *str);
|
||||
int mswin_nhgetch(void);
|
||||
int mswin_nh_poskey(int *x, int *y, int *mod);
|
||||
void mswin_nhbell(void);
|
||||
int mswin_doprev_message(void);
|
||||
char mswin_yn_function(const char *question, const char *choices,
|
||||
CHAR_P def);
|
||||
void mswin_getlin(const char *question, char *input);
|
||||
int mswin_get_ext_cmd(void);
|
||||
void mswin_number_pad(int state);
|
||||
void mswin_delay_output(void);
|
||||
void mswin_change_color(void);
|
||||
char *mswin_get_color_string(void);
|
||||
void mswin_start_screen(void);
|
||||
void mswin_end_screen(void);
|
||||
void mswin_outrip(winid wid, int how);
|
||||
void mswin_preference_update(const char *pref);
|
||||
|
||||
/* helper function */
|
||||
HWND mswin_hwnd_from_winid(winid wid);
|
||||
winid mswin_winid_from_type(int type);
|
||||
winid mswin_winid_from_handle(HWND hWnd);
|
||||
void mswin_window_mark_dead(winid wid);
|
||||
void bail(const char *mesg);
|
||||
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,
|
||||
COLORREF cTransparent
|
||||
);
|
||||
void mswin_popup_display(HWND popup, int* done_indicator);
|
||||
void mswin_popup_destroy(HWND popup);
|
||||
#endif /* WINmswin_H */
|
||||
93616
sys/wince/wince.vcp
Normal file
93616
sys/wince/wince.vcp
Normal file
File diff suppressed because it is too large
Load Diff
41
sys/wince/wince.vcw
Normal file
41
sys/wince/wince.vcw
Normal file
@@ -0,0 +1,41 @@
|
||||
Microsoft eMbedded Visual Tools Workspace File, Format Version 3.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "recover"=.\wince\recover.vcp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "winhack"=.\wince\wince.vcp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
385
sys/wince/winhack.c
Normal file
385
sys/wince/winhack.c
Normal file
@@ -0,0 +1,385 @@
|
||||
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
|
||||
// winhack.cpp : Defines the entry point for the application.
|
||||
//
|
||||
|
||||
#include "winMS.h"
|
||||
#include "hack.h"
|
||||
#include "dlb.h"
|
||||
#include "resource.h"
|
||||
#include "mhmain.h"
|
||||
#include "mhmap.h"
|
||||
|
||||
#ifdef OVL0
|
||||
#define SHARED_DCL
|
||||
#else
|
||||
#define SHARED_DCL extern
|
||||
#endif
|
||||
|
||||
SHARED_DCL char orgdir[PATHLEN]; /* also used in pcsys.c, amidos.c */
|
||||
|
||||
extern void FDECL(nethack_exit,(int));
|
||||
static TCHAR* _get_cmd_arg(TCHAR* pCmdLine);
|
||||
|
||||
// Global Variables:
|
||||
NHWinApp _nethack_app;
|
||||
|
||||
// Foward declarations of functions included in this code module:
|
||||
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 **));
|
||||
|
||||
#define MAX_CMDLINE_PARAM 255
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPWSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
INITCOMMONCONTROLSEX InitCtrls;
|
||||
HWND nethackWnd;
|
||||
int argc;
|
||||
char* argv[MAX_CMDLINE_PARAM];
|
||||
size_t len;
|
||||
TCHAR* p;
|
||||
TCHAR wbuf[NHSTR_BUFSIZE];
|
||||
char buf[NHSTR_BUFSIZE];
|
||||
|
||||
/* ensure that we don't access violate on a panic() */
|
||||
windowprocs.win_raw_print = mswin_raw_print;
|
||||
windowprocs.win_raw_print_bold = mswin_raw_print_bold;
|
||||
|
||||
/* init applicatio structure */
|
||||
_nethack_app.hApp = hInstance;
|
||||
_nethack_app.nCmdShow = nCmdShow;
|
||||
_nethack_app.hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_WINHACK);
|
||||
_nethack_app.hMainWnd = NULL;
|
||||
_nethack_app.hPopupWnd = NULL;
|
||||
_nethack_app.hMenuBar = NULL;
|
||||
_nethack_app.bmpTiles = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TILES));
|
||||
if( _nethack_app.bmpTiles==NULL ) panic("cannot load tiles bitmap");
|
||||
_nethack_app.bmpPetMark = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PETMARK));
|
||||
if( _nethack_app.bmpPetMark==NULL ) panic("cannot load pet mark bitmap");
|
||||
_nethack_app.bmpMapTiles = _nethack_app.bmpTiles;
|
||||
_nethack_app.mapTile_X = TILE_X;
|
||||
_nethack_app.mapTile_Y = TILE_Y;
|
||||
_nethack_app.mapTilesPerLine = TILES_PER_LINE;
|
||||
_nethack_app.bNoHScroll = FALSE;
|
||||
_nethack_app.bNoVScroll = FALSE;
|
||||
#ifndef WIN_CE_2xx
|
||||
_nethack_app.bCmdPad = TRUE;
|
||||
#else
|
||||
_nethack_app.bCmdPad = FALSE;
|
||||
#endif
|
||||
|
||||
// check for running nethack programs
|
||||
nethackWnd = FindWindow(szMainWindowClass, NULL);
|
||||
if( nethackWnd ) {
|
||||
// bring on top
|
||||
SetForegroundWindow(nethackWnd);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// init controls
|
||||
ZeroMemory(&InitCtrls, sizeof(InitCtrls));
|
||||
InitCtrls.dwSize = sizeof(InitCtrls);
|
||||
InitCtrls.dwICC = ICC_LISTVIEW_CLASSES;
|
||||
if( !InitCommonControlsEx(&InitCtrls) ) {
|
||||
MessageBox(NULL, TEXT("Cannot init common controls"), TEXT("ERROR"), MB_OK | MB_ICONSTOP);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Perform application initialization:
|
||||
if (!InitInstance (hInstance, nCmdShow))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* get command line parameters */
|
||||
p = _get_cmd_arg(
|
||||
#ifdef WIN_CE_2xx
|
||||
lpCmdLine
|
||||
#else
|
||||
GetCommandLine()
|
||||
#endif
|
||||
);
|
||||
for( argc = 1; p && argc<MAX_CMDLINE_PARAM; argc++ ) {
|
||||
len = _tcslen(p);
|
||||
if( len>0 ) {
|
||||
argv[argc] = _strdup( NH_W2A(p, buf, BUFSZ) );
|
||||
} else {
|
||||
argv[argc] = "";
|
||||
}
|
||||
p = _get_cmd_arg(NULL);
|
||||
}
|
||||
GetModuleFileName(NULL, wbuf, BUFSZ);
|
||||
argv[0] = _strdup(NH_W2A(wbuf, buf, BUFSZ));
|
||||
|
||||
pcmain(argc,argv);
|
||||
|
||||
moveloop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// FUNCTION: InitInstance(HANDLE, int)
|
||||
//
|
||||
// PURPOSE: Saves instance handle and creates main window
|
||||
//
|
||||
// COMMENTS:
|
||||
//
|
||||
// In this function, we save the instance handle in a global variable and
|
||||
// create and display the main program window.
|
||||
//
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PNHWinApp GetNHApp()
|
||||
{
|
||||
return &_nethack_app;
|
||||
}
|
||||
|
||||
static int
|
||||
eraseoldlocks()
|
||||
{
|
||||
register int i;
|
||||
|
||||
/* cannot use maxledgerno() here, because we need to find a lock name
|
||||
* before starting everything (including the dungeon initialization
|
||||
* that sets astral_level, needed for maxledgerno()) up
|
||||
*/
|
||||
for(i = 1; i <= MAXDUNGEON*MAXLEVEL + 1; i++) {
|
||||
/* try to remove all */
|
||||
set_levelfile_name(lock, i);
|
||||
(void) unlink(fqname(lock, LEVELPREFIX, 0));
|
||||
}
|
||||
set_levelfile_name(lock, 0);
|
||||
if(unlink(fqname(lock, LEVELPREFIX, 0)))
|
||||
return 0; /* cannot remove it */
|
||||
return(1); /* success! */
|
||||
}
|
||||
|
||||
void
|
||||
getlock()
|
||||
{
|
||||
const char *fq_lock;
|
||||
char tbuf[BUFSZ];
|
||||
TCHAR wbuf[BUFSZ];
|
||||
HANDLE f;
|
||||
int fd;
|
||||
int choice;
|
||||
|
||||
/* regularize(lock); */ /* already done in pcmain */
|
||||
Sprintf(tbuf,fqname(lock, LEVELPREFIX, 0));
|
||||
set_levelfile_name(lock, 0);
|
||||
fq_lock = fqname(lock, LEVELPREFIX, 1);
|
||||
|
||||
f = CreateFile(
|
||||
NH_A2W(fq_lock, wbuf, BUFSZ),
|
||||
GENERIC_READ,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if( f==INVALID_HANDLE_VALUE ) {
|
||||
if(GetLastError()==ERROR_FILE_NOT_FOUND) goto gotlock; /* no such file */
|
||||
error("Cannot open %s", fq_lock);
|
||||
}
|
||||
|
||||
CloseHandle(f);
|
||||
|
||||
/* 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("Nethack"),
|
||||
MB_YESNOCANCEL );
|
||||
switch(choice) {
|
||||
case IDYES:
|
||||
run_recover();
|
||||
break;
|
||||
|
||||
case IDNO:
|
||||
if(eraseoldlocks()) {
|
||||
goto gotlock;
|
||||
} else {
|
||||
error("Couldn't destroy old game.");
|
||||
}
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
SetLastError(0);
|
||||
error("%s", "Good-bye.");
|
||||
break;
|
||||
};
|
||||
|
||||
gotlock:
|
||||
fd = creat(fq_lock, FCMASK);
|
||||
if(fd == -1) {
|
||||
error("cannot creat lock file (%s.)", fq_lock);
|
||||
} else {
|
||||
if(write(fd, (char *) &hackpid, sizeof(hackpid))
|
||||
!= sizeof(hackpid)){
|
||||
error("cannot write lock (%s)", fq_lock);
|
||||
}
|
||||
if(close(fd) == -1) {
|
||||
error("cannot close lock (%s)", fq_lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* misc functions */
|
||||
void
|
||||
error VA_DECL(const char *,s)
|
||||
TCHAR wbuf[1024];
|
||||
char buf[1024];
|
||||
DWORD last_error = GetLastError();
|
||||
|
||||
VA_START(s);
|
||||
VA_INIT(s, const char *);
|
||||
/* error() may get called before tty is initialized */
|
||||
if (iflags.window_inited) end_screen();
|
||||
|
||||
vsprintf(buf, s, VA_ARGS);
|
||||
NH_A2W(buf, wbuf, sizeof(wbuf)/sizeof(wbuf[0]));
|
||||
if( last_error>0 ) {
|
||||
LPVOID lpMsgBuf;
|
||||
if( FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
last_error,
|
||||
0, // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
_tcsncat(wbuf, TEXT("\nSystem Error: "), sizeof(wbuf)/sizeof(wbuf[0]) - _tcslen(wbuf) );
|
||||
_tcsncat(wbuf, lpMsgBuf, sizeof(wbuf)/sizeof(wbuf[0]) - _tcslen(wbuf) );
|
||||
|
||||
// Free the buffer.
|
||||
LocalFree( lpMsgBuf );
|
||||
}
|
||||
}
|
||||
VA_END();
|
||||
|
||||
MessageBox( NULL, wbuf, TEXT("Error"), MB_OK | MB_ICONERROR );
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
TCHAR* _get_cmd_arg(TCHAR* pCmdLine)
|
||||
{
|
||||
static TCHAR* pArgs = NULL;
|
||||
TCHAR *pRetArg;
|
||||
BOOL bQuoted;
|
||||
|
||||
if( !pCmdLine && !pArgs ) return NULL;
|
||||
if( !pArgs ) pArgs = pCmdLine;
|
||||
|
||||
/* skip whitespace */
|
||||
for(pRetArg = pArgs; *pRetArg && _istspace(*pRetArg); pRetArg = CharNext(pRetArg));
|
||||
if( !*pRetArg ) {
|
||||
pArgs = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* check for quote */
|
||||
if( *pRetArg==TEXT('"') ) {
|
||||
bQuoted = TRUE;
|
||||
pRetArg = CharNext(pRetArg);
|
||||
pArgs = _tcschr(pRetArg, TEXT('"'));
|
||||
} else {
|
||||
/* skip to whitespace */
|
||||
for(pArgs = pRetArg; *pArgs && !_istspace(*pArgs); pArgs = CharNext(pArgs));
|
||||
}
|
||||
|
||||
if( pArgs && *pArgs ) {
|
||||
TCHAR* p;
|
||||
p = pArgs;
|
||||
pArgs = CharNext(pArgs);
|
||||
*p = (TCHAR)0;
|
||||
} else {
|
||||
pArgs = NULL;
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
void
|
||||
nt_regularize(s) /* normalize file name */
|
||||
register char *s;
|
||||
{
|
||||
register unsigned char *lp;
|
||||
|
||||
for (lp = s; *lp; lp++)
|
||||
if ( *lp == '?' || *lp == '"' || *lp == '\\' ||
|
||||
*lp == '/' || *lp == '>' || *lp == '<' ||
|
||||
*lp == '*' || *lp == '|' || *lp == ':' || (*lp > 127))
|
||||
*lp = '_';
|
||||
}
|
||||
|
||||
void win32_abort()
|
||||
{
|
||||
|
||||
#ifdef WIZARD
|
||||
if (wizard)
|
||||
DebugBreak();
|
||||
#endif
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
14
sys/wince/winhack.h
Normal file
14
sys/wince/winhack.h
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
#if !defined(AFX_WINHACK_H__6397C328_BAF8_460C_9465_F12C596C5732__INCLUDED_)
|
||||
#define AFX_WINHACK_H__6397C328_BAF8_460C_9465_F12C596C5732__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
#endif // !defined(AFX_WINHACK_H__6397C328_BAF8_460C_9465_F12C596C5732__INCLUDED_)
|
||||
350
sys/wince/winhack.rc
Normal file
350
sys/wince/winhack.rc
Normal file
@@ -0,0 +1,350 @@
|
||||
//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
|
||||
POPUP "File"
|
||||
BEGIN
|
||||
MENUITEM "&Save", IDM_SAVE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Quit", IDM_EXIT
|
||||
END
|
||||
POPUP "Map"
|
||||
BEGIN
|
||||
MENUITEM "&0 - Use Tiles", IDM_MAP_TILES
|
||||
MENUITEM "&1 - ASCII (4x6)", IDM_MAP_ASCII4X6
|
||||
MENUITEM "&2 - ASCII (6x8)", IDM_MAP_ASCII6X8
|
||||
MENUITEM "&3 - ASCII (8x8)", IDM_MAP_ASCII8X8
|
||||
MENUITEM "&4 - ASCII (16x8)", IDM_MAP_ASCII16X8
|
||||
MENUITEM "&5 - ASCII (7x12)", IDM_MAP_ASCII7X12
|
||||
MENUITEM "&6 - ASCII (8x12)", IDM_MAP_ASCII8X12
|
||||
MENUITEM "&7 - ASCII (16x12)", IDM_MAP_ASCII16X12
|
||||
MENUITEM "&8 - ASCII (12x16)", IDM_MAP_ASCII12X16
|
||||
MENUITEM "&9 - ASCII (10x18)", IDM_MAP_ASCII10X18
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Fit To Screen", IDM_MAP_FIT_TO_SCREEN
|
||||
END
|
||||
POPUP "Help"
|
||||
BEGIN
|
||||
MENUITEM "&About ...", IDM_ABOUT
|
||||
MENUITEM "&Long description of the game", IDM_HELP_LONG
|
||||
MENUITEM "List of &commands", IDM_HELP_COMMANDS
|
||||
MENUITEM "&History of NetHack", IDM_HELP_HISTORY
|
||||
MENUITEM "&Info on a character", IDM_HELP_INFO_CHAR
|
||||
MENUITEM "Info on what a given &key does", IDM_HELP_INFO_KEY
|
||||
MENUITEM "List of game &options", IDM_HELP_OPTIONS
|
||||
MENUITEM "&Longer list of game options", IDM_HELP_OPTIONS_LONG
|
||||
MENUITEM "List of e&xtended commands", IDM_HELP_EXTCMD
|
||||
MENUITEM "The &NetHack license", IDM_HELP_LICENSE
|
||||
END
|
||||
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, 153
|
||||
STYLE WS_CHILD | WS_CLIPSIBLINGS | WS_BORDER
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,5,130,50,14,BS_NOTIFY
|
||||
PUSHBUTTON "Cancel",IDCANCEL,55,130,50,14,BS_NOTIFY
|
||||
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_GETLIN DIALOG DISCARDABLE 0, 0, 115, 30
|
||||
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
|
||||
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
|
||||
|
||||
IDD_NHTEXT DIALOG DISCARDABLE 0, 0, 83, 97
|
||||
STYLE WS_CHILD | WS_BORDER
|
||||
FONT 8, "System"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,15,80,50,14
|
||||
EDITTEXT IDC_TEXT_CONTROL,5,0,70,75,ES_MULTILINE | ES_READONLY |
|
||||
WS_VSCROLL | WS_HSCROLL
|
||||
END
|
||||
|
||||
IDD_EXTCMD DIALOG DISCARDABLE 0, 0, 109, 114
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Extended Commands"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,75,5,30,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,75,20,30,14
|
||||
LISTBOX IDC_EXTCMD_LIST,5,5,65,105,LBS_NOINTEGRALHEIGHT |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
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_GETLIN, DIALOG
|
||||
BEGIN
|
||||
BOTTOMMARGIN, 29
|
||||
END
|
||||
|
||||
IDD_PLAYER_SELECTOR, DIALOG
|
||||
BEGIN
|
||||
RIGHTMARGIN, 98
|
||||
BOTTOMMARGIN, 117
|
||||
END
|
||||
|
||||
IDD_NHTEXT, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 5
|
||||
RIGHTMARGIN, 76
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 94
|
||||
END
|
||||
|
||||
IDD_EXTCMD, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 102
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 107
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Data
|
||||
//
|
||||
|
||||
IDC_WINHACK SHMENUBAR DISCARDABLE
|
||||
BEGIN
|
||||
IDC_WINHACK, 3,
|
||||
I_IMAGENONE, ID_FILE, TBSTATE_ENABLED,
|
||||
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_CAP_FILE, 0, 0,
|
||||
I_IMAGENONE, ID_MAP, TBSTATE_ENABLED,
|
||||
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_CAP_MAP, 0, 1,
|
||||
I_IMAGENONE, ID_HELP, TBSTATE_ENABLED,
|
||||
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_CAP_HELP, 0, 2,
|
||||
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", "Winhack is a GUI version of Nethack 3.4.0 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", "020617\0"
|
||||
VALUE "ProductName", "WinHack\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
|
||||
IDS_CAP_FILE "File"
|
||||
IDS_CAP_HELP "Help"
|
||||
IDS_CAP_MAP "Map"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
110
sys/wince/winmain.c
Normal file
110
sys/wince/winmain.c
Normal file
@@ -0,0 +1,110 @@
|
||||
// winmain.cpp : Defines the entry point for the application.
|
||||
|
||||
#include "winMS.h"
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_CMDLINE_PARAM 255
|
||||
|
||||
extern int FDECL (main, (int,char **));
|
||||
static TCHAR* _get_cmd_arg(TCHAR* pCmdLine);
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPWSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
int argc;
|
||||
char* argv[MAX_CMDLINE_PARAM];
|
||||
size_t len;
|
||||
TCHAR* p;
|
||||
TCHAR wbuf[NHSTR_BUFSIZE];
|
||||
char buf[NHSTR_BUFSIZE];
|
||||
|
||||
/* get command line parameters */
|
||||
p = _get_cmd_arg(
|
||||
#ifdef WIN_CE_2xx
|
||||
lpCmdLine
|
||||
#else
|
||||
GetCommandLine()
|
||||
#endif
|
||||
);
|
||||
for( argc = 1; p && argc<MAX_CMDLINE_PARAM; argc++ ) {
|
||||
len = _tcslen(p);
|
||||
if( len>0 ) {
|
||||
argv[argc] = _strdup( NH_W2A(p, buf, BUFSZ) );
|
||||
} else {
|
||||
argv[argc] = "";
|
||||
}
|
||||
p = _get_cmd_arg(NULL);
|
||||
}
|
||||
GetModuleFileName(NULL, wbuf, BUFSZ);
|
||||
argv[0] = _strdup(NH_W2A(wbuf, buf, BUFSZ));
|
||||
|
||||
main(argc, argv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TCHAR* _get_cmd_arg(TCHAR* pCmdLine)
|
||||
{
|
||||
static TCHAR* pArgs = NULL;
|
||||
TCHAR *pRetArg;
|
||||
BOOL bQuoted;
|
||||
|
||||
if( !pCmdLine && !pArgs ) return NULL;
|
||||
if( !pArgs ) pArgs = pCmdLine;
|
||||
|
||||
/* skip whitespace */
|
||||
for(pRetArg = pArgs; *pRetArg && _istspace(*pRetArg); pRetArg = CharNext(pRetArg));
|
||||
if( !*pRetArg ) {
|
||||
pArgs = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* check for quote */
|
||||
if( *pRetArg==TEXT('"') ) {
|
||||
bQuoted = TRUE;
|
||||
pRetArg = CharNext(pRetArg);
|
||||
pArgs = _tcschr(pRetArg, TEXT('"'));
|
||||
} else {
|
||||
/* skip to whitespace */
|
||||
for(pArgs = pRetArg; *pArgs && !_istspace(*pArgs); pArgs = CharNext(pArgs));
|
||||
}
|
||||
|
||||
if( pArgs && *pArgs ) {
|
||||
TCHAR* p;
|
||||
p = pArgs;
|
||||
pArgs = CharNext(pArgs);
|
||||
*p = (TCHAR)0;
|
||||
} else {
|
||||
pArgs = NULL;
|
||||
}
|
||||
|
||||
return pRetArg;
|
||||
}
|
||||
|
||||
#ifndef STRNCMPI
|
||||
char
|
||||
lowc(c) /* force 'c' into lowercase */
|
||||
char c;
|
||||
{
|
||||
return((char)(('A' <= c && c <= 'Z') ? (c | 040) : c));
|
||||
}
|
||||
|
||||
int
|
||||
strncmpi(s1, s2, n) /* case insensitive counted string comparison */
|
||||
register const char *s1, *s2;
|
||||
register int n; /*(should probably be size_t, which is usually unsigned)*/
|
||||
{ /*{ aka strncasecmp }*/
|
||||
register char t1, t2;
|
||||
|
||||
while (n--) {
|
||||
if (!*s2) return (*s1 != 0); /* s1 >= s2 */
|
||||
else if (!*s1) return -1; /* s1 < s2 */
|
||||
t1 = lowc(*s1++);
|
||||
t2 = lowc(*s2++);
|
||||
if (t1 != t2) return (t1 > t2) ? 1 : -1;
|
||||
}
|
||||
return 0; /* s1 == s2 */
|
||||
}
|
||||
#endif /* STRNCMPI */
|
||||
Reference in New Issue
Block a user