4 * Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies.
13 * This file helps Angband work with Windows computers.
15 * To use this file, use an appropriate "Makefile" or "Project File",
16 * make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and
17 * make sure to obtain various extra files as described below.
19 * The official compilation uses the CodeWarrior Pro compiler, which
20 * includes a special project file and precompilable header file.
23 * See also "main-dos.c" and "main-ibm.c".
26 * The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
27 * and/or color redefinitions.
29 * The "lib/user/font-win.prf" contains attr/char mappings for use with the
30 * normal "lib/xtra/font/*.fon" font files.
32 * The "lib/user/graf-win.prf" contains attr/char mappings for use with the
33 * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
37 * Compiling this file, and using the resulting executable, requires
38 * several extra files not distributed with the standard Angband code.
39 * If "USE_GRAPHICS" is defined, then "readdib.h" and "readdib.c" must
40 * be placed into "src/", and the "8X8.BMP" bitmap file must be placed
41 * into "lib/xtra/graf". In any case, some "*.fon" files (including
42 * "8X13.FON" if nothing else) must be placed into "lib/xtra/font/".
43 * If "USE_SOUND" is defined, then some special library (for example,
44 * "winmm.lib") may need to be linked in, and desired "*.WAV" sound
45 * files must be placed into "lib/xtra/sound/". All of these extra
46 * files can be found in the "ext-win" archive.
49 * The "Term_xtra_win_clear()" function should probably do a low-level
50 * clear of the current window, and redraw the borders and other things,
51 * if only for efficiency. XXX XXX XXX
53 * A simpler method is needed for selecting the "tile size" for windows.
56 * The various "warning" messages assume the existance of the "screen.w"
57 * window, I think, and only a few calls actually check for its existance,
58 * this may be okay since "NULL" means "on top of all windows". (?) The
59 * user must never be allowed to "hide" the main window, or the "menubar"
60 * will disappear. XXX XXX XXX
62 * Special "Windows Help Files" can be placed into "lib/xtra/help/" for
63 * use with the "winhelp.exe" program. These files *may* be available
64 * at the ftp site somewhere, but I have not seen them. XXX XXX XXX
67 * Initial framework (and most code) by Ben Harrison (benh@phial.com).
69 * Original code by Skirmantas Kligys (kligys@scf.usc.edu).
71 * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
72 * and Chris R. Martin (crm7479@tam2000.tamu.edu).
83 * Extract the "WIN32" flag from the compiler
85 #if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__)
93 * Hack -- allow use of "screen saver" mode
99 * Menu constants -- see "ANGBAND.RC"
102 #define IDM_FILE_NEW 100
103 #define IDM_FILE_OPEN 101
104 #define IDM_FILE_SAVE 110
105 #define IDM_FILE_SCORE 120
106 #define IDM_FILE_EXIT 130
108 #define IDM_WINDOW_VIS_0 200
109 #define IDM_WINDOW_VIS_1 201
110 #define IDM_WINDOW_VIS_2 202
111 #define IDM_WINDOW_VIS_3 203
112 #define IDM_WINDOW_VIS_4 204
113 #define IDM_WINDOW_VIS_5 205
114 #define IDM_WINDOW_VIS_6 206
115 #define IDM_WINDOW_VIS_7 207
117 #define IDM_WINDOW_FONT_0 210
118 #define IDM_WINDOW_FONT_1 211
119 #define IDM_WINDOW_FONT_2 212
120 #define IDM_WINDOW_FONT_3 213
121 #define IDM_WINDOW_FONT_4 214
122 #define IDM_WINDOW_FONT_5 215
123 #define IDM_WINDOW_FONT_6 216
124 #define IDM_WINDOW_FONT_7 217
126 #define IDM_WINDOW_POS_0 220
127 #define IDM_WINDOW_POS_1 221
128 #define IDM_WINDOW_POS_2 222
129 #define IDM_WINDOW_POS_3 223
130 #define IDM_WINDOW_POS_4 224
131 #define IDM_WINDOW_POS_5 225
132 #define IDM_WINDOW_POS_6 226
133 #define IDM_WINDOW_POS_7 227
135 #define IDM_WINDOW_BIZ_0 230
136 #define IDM_WINDOW_BIZ_1 231
137 #define IDM_WINDOW_BIZ_2 232
138 #define IDM_WINDOW_BIZ_3 233
139 #define IDM_WINDOW_BIZ_4 234
140 #define IDM_WINDOW_BIZ_5 235
141 #define IDM_WINDOW_BIZ_6 236
142 #define IDM_WINDOW_BIZ_7 237
144 #define IDM_WINDOW_I_WID_0 240
145 #define IDM_WINDOW_I_WID_1 241
146 #define IDM_WINDOW_I_WID_2 242
147 #define IDM_WINDOW_I_WID_3 243
148 #define IDM_WINDOW_I_WID_4 244
149 #define IDM_WINDOW_I_WID_5 245
150 #define IDM_WINDOW_I_WID_6 246
151 #define IDM_WINDOW_I_WID_7 247
153 #define IDM_WINDOW_D_WID_0 250
154 #define IDM_WINDOW_D_WID_1 251
155 #define IDM_WINDOW_D_WID_2 252
156 #define IDM_WINDOW_D_WID_3 253
157 #define IDM_WINDOW_D_WID_4 254
158 #define IDM_WINDOW_D_WID_5 255
159 #define IDM_WINDOW_D_WID_6 256
160 #define IDM_WINDOW_D_WID_7 257
162 #define IDM_WINDOW_I_HGT_0 260
163 #define IDM_WINDOW_I_HGT_1 261
164 #define IDM_WINDOW_I_HGT_2 262
165 #define IDM_WINDOW_I_HGT_3 263
166 #define IDM_WINDOW_I_HGT_4 264
167 #define IDM_WINDOW_I_HGT_5 265
168 #define IDM_WINDOW_I_HGT_6 266
169 #define IDM_WINDOW_I_HGT_7 267
171 #define IDM_WINDOW_D_HGT_0 270
172 #define IDM_WINDOW_D_HGT_1 271
173 #define IDM_WINDOW_D_HGT_2 272
174 #define IDM_WINDOW_D_HGT_3 273
175 #define IDM_WINDOW_D_HGT_4 274
176 #define IDM_WINDOW_D_HGT_5 275
177 #define IDM_WINDOW_D_HGT_6 276
178 #define IDM_WINDOW_D_HGT_7 277
180 #define IDM_OPTIONS_NO_GRAPHICS 400
181 #define IDM_OPTIONS_OLD_GRAPHICS 401
182 #define IDM_OPTIONS_NEW_GRAPHICS 402
183 #define IDM_OPTIONS_BIGTILE 409
184 #define IDM_OPTIONS_SOUND 410
185 #define IDM_OPTIONS_SAVER 420
186 #define IDM_OPTIONS_MAP 430
187 #define IDM_OPTIONS_BG 440
188 #define IDM_OPTIONS_OPEN_BG 441
190 #define IDM_DUMP_SCREEN_HTML 450
192 #define IDM_HELP_CONTENTS 901
197 * This may need to be removed for some compilers XXX XXX XXX
202 * Exclude parts of WINDOWS.H that are not needed
204 #define NOCOMM /* Comm driver APIs and definitions */
205 #define NOLOGERROR /* LogError() and related definitions */
206 #define NOPROFILER /* Profiler APIs */
207 #define NOLFILEIO /* _l* file I/O routines */
208 #define NOOPENFILE /* OpenFile and related definitions */
209 #define NORESOURCE /* Resource management */
210 #define NOATOM /* Atom management */
211 #define NOLANGUAGE /* Character test routines */
212 #define NOLSTRING /* lstr* string management routines */
213 #define NODBCS /* Double-byte character set routines */
214 #define NOKEYBOARDINFO /* Keyboard driver routines */
215 #define NOCOLOR /* COLOR_* color values */
216 #define NODRAWTEXT /* DrawText() and related definitions */
217 #define NOSCALABLEFONT /* Truetype scalable font support */
218 #define NOMETAFILE /* Metafile support */
219 #define NOSYSTEMPARAMSINFO /* SystemParametersInfo() and SPI_* definitions */
220 #define NODEFERWINDOWPOS /* DeferWindowPos and related definitions */
221 #define NOKEYSTATES /* MK_* message key state flags */
222 #define NOWH /* SetWindowsHook and related WH_* definitions */
223 #define NOCLIPBOARD /* Clipboard APIs and definitions */
224 #define NOICONS /* IDI_* icon IDs */
225 #define NOMDI /* MDI support */
226 #define NOHELP /* Help support */
228 /* Not defined since it breaks Borland C++ 5.5 */
229 /* #define NOCTLMGR */ /* Control management and controls */
232 * Exclude parts of WINDOWS.H that are not needed (Win32)
234 #define WIN32_LEAN_AND_MEAN
235 #define NONLS /* All NLS defines and routines */
236 #define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
237 #define NOKANJI /* Kanji support stuff. */
238 #define NOMCX /* Modem Configuration Extensions */
241 * Include the "windows" support file
246 * Exclude parts of MMSYSTEM.H that are not needed
248 #define MMNODRV /* Installable driver support */
249 #define MMNOWAVE /* Waveform support */
250 #define MMNOMIDI /* MIDI support */
251 #define MMNOAUX /* Auxiliary audio support */
252 #define MMNOTIMER /* Timer support */
253 #define MMNOJOY /* Joystick support */
254 #define MMNOMCI /* MCI support */
255 #define MMNOMMIO /* Multimedia file I/O support */
256 #define MMNOMMSYSTEM /* General MMSYSTEM functions */
259 * Include some more files. Note: the Cygnus Cygwin compiler
260 * doesn't use mmsystem.h instead it includes the winmm library
261 * which performs a similar function.
263 #include <mmsystem.h>
267 * HTML-Help requires htmlhelp.h and htmlhelp.lib from Microsoft's
268 * HTML Workshop < http://msdn.microsoft.com/workshop/author/htmlhelp/ >.
270 /* #define HTML_HELP */
273 #include <htmlhelp.h>
274 #endif /* HTML_HELP */
277 * Include the support for loading bitmaps
280 # include "readdib.h"
284 * Hack -- Fake declarations from "dos.h" XXX XXX XXX
287 #define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
289 #define FA_LABEL 0x08 /* Volume label */
290 #define FA_DIREC 0x10 /* Directory */
291 unsigned _cdecl _dos_getfileattr(const char *, unsigned *);
295 * Silliness in WIN32 drawing routine
298 # define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL)
302 * Silliness for Windows 95
304 #ifndef WS_EX_TOOLWINDOW
305 # define WS_EX_TOOLWINDOW 0
309 * Foreground color bits (hard-coded by DOS)
311 #define VID_BLACK 0x00
312 #define VID_BLUE 0x01
313 #define VID_GREEN 0x02
314 #define VID_CYAN 0x03
316 #define VID_MAGENTA 0x05
317 #define VID_YELLOW 0x06
318 #define VID_WHITE 0x07
321 * Bright text (hard-coded by DOS)
323 #define VID_BRIGHT 0x08
326 * Background color bits (hard-coded by DOS)
328 #define VUD_BLACK 0x00
329 #define VUD_BLUE 0x10
330 #define VUD_GREEN 0x20
331 #define VUD_CYAN 0x30
333 #define VUD_MAGENTA 0x50
334 #define VUD_YELLOW 0x60
335 #define VUD_WHITE 0x70
338 * Blinking text (hard-coded by DOS)
340 #define VUD_BRIGHT 0x80
346 typedef struct _term_data term_data;
351 * Note the use of "font_want" for the names of the font file requested by
352 * the user, and the use of "font_file" for the currently active font file.
354 * The "font_file" is uppercased, and takes the form "8X13.FON", while
355 * "font_want" can be in almost any form as long as it could be construed
356 * as attempting to represent the name of a font.
371 uint rows; /* int -> uint */
407 #if 1 /* #ifdef JP */
422 * Maximum number of windows XXX XXX XXX
424 #define MAX_TERM_DATA 8
427 * An array of term_data's
429 static term_data data[MAX_TERM_DATA];
432 * Hack -- global "window creation" pointer
434 static term_data *my_td;
437 * Remember normal size of main window when maxmized
442 * was main window maximized on previous playing
444 bool win_maximized = FALSE;
449 bool game_in_progress = FALSE;
452 * note when "open"/"new" become valid
454 bool initialized = FALSE;
457 * screen paletted, i.e. 256 colors
459 bool paletted = FALSE;
462 * 16 colors screen, don't use RGB()
464 bool colors16 = FALSE;
467 * Saved instance handle
469 static HINSTANCE hInstance;
472 * Yellow brush for the cursor
474 static HBRUSH hbrYellow;
484 static HPALETTE hPal;
487 static HBITMAP hBG = NULL;
488 static int use_bg = 0;
489 static char bg_bitmap_file[1024] = "bg.bmp";
494 * The screen saver window
496 static HWND hwndSaver;
498 #endif /* USE_SAVER */
504 * Flag set once "graphics" has been initialized
506 static bool can_use_graphics = FALSE;
511 static DIBINIT infGraph;
514 * The global bitmap mask
516 static DIBINIT infMask;
518 #endif /* USE_GRAPHICS */
524 * Flag set once "sound" has been initialized
526 static bool can_use_sound = FALSE;
531 * An array of sound file names
533 static cptr sound_file[SOUND_MAX][SAMPLE_MAX];
535 #endif /* USE_SOUND */
539 * Full path to ANGBAND.INI
541 static cptr ini_file = NULL;
544 * Name of application
546 static cptr AppName = "ANGBAND";
549 * Name of sub-window type
551 static cptr AngList = "AngList";
556 static cptr ANGBAND_DIR_XTRA_GRAF;
557 static cptr ANGBAND_DIR_XTRA_SOUND;
558 static cptr ANGBAND_DIR_XTRA_HELP;
559 #if 0 /* #ifndef JP */
560 static cptr ANGBAND_DIR_XTRA_FONT;
563 static cptr ANGBAND_DIR_XTRA_MUSIC;
568 * The "complex" color values
570 static COLORREF win_clr[256];
574 * Flag for macro trigger with dump ASCII
576 static bool Term_no_press = FALSE;
580 * The "simple" color values
582 * See "main-ibm.c" for original table information
584 * The entries below are taken from the "color bits" defined above.
586 * Note that many of the choices below suck, but so do crappy monitors.
588 static BYTE win_pal[256] =
590 VID_BLACK, /* Dark */
591 VID_WHITE, /* White */
592 VID_CYAN, /* Slate XXX */
593 VID_RED | VID_BRIGHT, /* Orange XXX */
595 VID_GREEN, /* Green */
597 VID_YELLOW, /* Umber XXX */
598 VID_BLACK | VID_BRIGHT, /* Light Dark */
599 VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
600 VID_MAGENTA, /* Violet XXX */
601 VID_YELLOW | VID_BRIGHT, /* Yellow */
602 VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
603 VID_GREEN | VID_BRIGHT, /* Light Green */
604 VID_BLUE | VID_BRIGHT, /* Light Blue */
605 VID_YELLOW /* Light Umber XXX */
610 * Hack -- define which keys are "special"
612 static bool special_key[256];
613 static bool ignore_key[256];
617 * Hack -- initialization list for "special_key"
619 static byte special_key_list[] = {
620 VK_CLEAR, VK_PAUSE, VK_CAPITAL,
621 VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI,
622 VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE,
623 VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
624 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN,
625 VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT,
626 VK_INSERT, VK_DELETE, VK_HELP, VK_APPS,
627 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
628 VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
629 VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD,
630 VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE,
631 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
632 VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
633 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
634 VK_F19,VK_F20, VK_F21, VK_F22, VK_F23, VK_F24,
635 VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL,
636 VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM,
641 static byte ignore_key_list[] = {
642 VK_ESCAPE, VK_TAB, VK_SPACE,
643 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
644 VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN,
645 VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL,
651 * Hack -- initialization list for "special_key"
653 * We ignore the modifier keys (shift, control, alt, num lock, scroll lock),
654 * and the normal keys (escape, tab, return, letters, numbers, etc), but we
655 * catch the keypad keys (with and without numlock set, including keypad 5),
656 * the function keys (including the "menu" key which maps to F10), and the
657 * "pause" key (between scroll lock and numlock). We also catch a few odd
658 * keys which I do not recognize, but which are listed among keys which we
659 * do catch, so they should be harmless to catch.
661 static byte special_key_list[] =
663 VK_CLEAR, /* 0x0C (KP<5>) */
665 VK_PAUSE, /* 0x13 (pause) */
667 VK_PRIOR, /* 0x21 (KP<9>) */
668 VK_NEXT, /* 0x22 (KP<3>) */
669 VK_END, /* 0x23 (KP<1>) */
670 VK_HOME, /* 0x24 (KP<7>) */
671 VK_LEFT, /* 0x25 (KP<4>) */
672 VK_UP, /* 0x26 (KP<8>) */
673 VK_RIGHT, /* 0x27 (KP<6>) */
674 VK_DOWN, /* 0x28 (KP<2>) */
675 VK_SELECT, /* 0x29 (?????) */
676 VK_PRINT, /* 0x2A (?????) */
677 VK_EXECUTE, /* 0x2B (?????) */
678 VK_SNAPSHOT, /* 0x2C (?????) */
679 VK_INSERT, /* 0x2D (KP<0>) */
680 VK_DELETE, /* 0x2E (KP<.>) */
681 VK_HELP, /* 0x2F (?????) */
683 VK_NUMPAD0, /* 0x60 (KP<0>) */
684 VK_NUMPAD1, /* 0x61 (KP<1>) */
685 VK_NUMPAD2, /* 0x62 (KP<2>) */
686 VK_NUMPAD3, /* 0x63 (KP<3>) */
687 VK_NUMPAD4, /* 0x64 (KP<4>) */
688 VK_NUMPAD5, /* 0x65 (KP<5>) */
689 VK_NUMPAD6, /* 0x66 (KP<6>) */
690 VK_NUMPAD7, /* 0x67 (KP<7>) */
691 VK_NUMPAD8, /* 0x68 (KP<8>) */
692 VK_NUMPAD9, /* 0x69 (KP<9>) */
693 VK_MULTIPLY, /* 0x6A (KP<*>) */
694 VK_ADD, /* 0x6B (KP<+>) */
695 VK_SEPARATOR, /* 0x6C (?????) */
696 VK_SUBTRACT, /* 0x6D (KP<->) */
697 VK_DECIMAL, /* 0x6E (KP<.>) */
698 VK_DIVIDE, /* 0x6F (KP</>) */
729 static void delete_bg(void)
738 static int init_bg(void)
740 char * bmfile = bg_bitmap_file;
743 if (use_bg == 0) return 0;
745 hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
748 plog_fmt("ÊÉ»æÍÑ¥Ó¥Ã¥È¥Þ¥Ã¥× '%s' ¤òÆɤ߹þ¤á¤Þ¤»¤ó¡£", bmfile);
750 plog_fmt("Can't load the bitmap file '%s'.", bmfile);
756 HDC wnddc, dcimage, dcbg;
757 HBITMAP bmimage, bmimage_old, bmbg_old;
763 dcimage = CreateCompatibleDC(wnddc);
764 dcbg = CreateCompatibleDC(wnddc);
766 bmimage = LoadImage(NULL, "bg.bmp", LR_LOADFROMFILE, 0, 0, 0);
767 if (!bmimage) quit("bg.bmp¤¬Æɤߤ³¤á¤Ê¤¤¡ª");
768 bmimage_old = SelectObject(dcimage, bmimage);
770 CreateCompatibleBitmap();
772 ReleaseDC(hwnd, wnddc);
778 static void DrawBG(HDC hdc, RECT *r)
783 int x = r->left, y = r->top;
784 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
790 GetObject(hBG, sizeof(bm), &bm);
791 swid = bm.bmWidth; shgt = bm.bmHeight;
793 hdcSrc = CreateCompatibleDC(hdc);
794 hOld = SelectObject(hdcSrc, hBG);
798 cwid = MIN(swid - sx, r->right - nx);
801 chgt = MIN(shgt - sy, r->bottom - ny);
802 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
804 } while (ny < r->bottom);
807 } while (nx < r->right);
809 SelectObject(hdcSrc, hOld);
815 * Hack -- given a pathname, point at the filename
817 static cptr extract_file_name(cptr s)
821 /* Start at the end */
822 p = s + strlen(s) - 1;
824 /* Back up to divider */
825 while ((p >= s) && (*p != ':') && (*p != '\\')) p--;
827 /* Return file name */
834 * Hack -- given a simple filename, extract the "font size" info
836 * Return a pointer to a static buffer holding the capitalized base name.
838 #if 0 /* #ifndef JP */
839 static char *analyze_font(char *path, int *wp, int *hp)
845 /* Start at the end */
846 p = path + strlen(path) - 1;
848 /* Back up to divider */
849 while ((p >= path) && (*p != ':') && (*p != '\\')) --p;
851 /* Advance to file name */
857 /* Capitalize (be paranoid) */
858 if (islower(*s)) *s = toupper(*s);
862 s = my_strchr(p, 'X');
864 /* Extract font width */
868 hgt = s ? atoi(s+1) : 0;
881 * Check for existance of a file
883 static bool check_file(cptr s)
903 attrib = GetFileAttributes(path);
905 /* Require valid filename */
906 if (attrib == INVALID_FILE_NAME) return (FALSE);
908 /* Prohibit directory */
909 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return (FALSE);
913 /* Examine and verify */
914 if (_dos_getfileattr(path, &attrib)) return (FALSE);
916 /* Prohibit something */
917 if (attrib & FA_LABEL) return (FALSE);
919 /* Prohibit directory */
920 if (attrib & FA_DIREC) return (FALSE);
930 * Check for existance of a directory
932 static bool check_dir(cptr s)
954 /* Remove trailing backslash */
955 if (i && (path[i-1] == '\\')) path[--i] = '\0';
960 attrib = GetFileAttributes(path);
962 /* Require valid filename */
963 if (attrib == INVALID_FILE_NAME) return (FALSE);
965 /* Require directory */
966 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE);
970 /* Examine and verify */
971 if (_dos_getfileattr(path, &attrib)) return (FALSE);
973 /* Prohibit something */
974 if (attrib & FA_LABEL) return (FALSE);
976 /* Require directory */
977 if (!(attrib & FA_DIREC)) return (FALSE);
989 static void validate_file(cptr s)
995 quit_fmt("ɬÍפʥե¡¥¤¥ë[%s]¤¬¸«¤¢¤¿¤ê¤Þ¤»¤ó¡£", s);
997 quit_fmt("Cannot find required file:\n%s", s);
1005 * Validate a directory
1007 static void validate_dir(cptr s, bool vital)
1009 /* Verify or fail */
1012 /* This directory contains needed data */
1016 quit_fmt("ɬÍפʥǥ£¥ì¥¯¥È¥ê[%s]¤¬¸«¤¢¤¿¤ê¤Þ¤»¤ó¡£", s);
1018 quit_fmt("Cannot find required directory:\n%s", s);
1022 /* Attempt to create this directory */
1025 quit_fmt("Unable to create directory:\n%s", s);
1032 * Get the "size" for a window
1034 static void term_getsize(term_data *td)
1041 if (td->cols < 1) td->cols = 1;
1042 if (td->rows < 1) td->rows = 1;
1045 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
1046 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
1048 /* Fake window size */
1050 rc.right = rc.left + wid;
1052 rc.bottom = rc.top + hgt;
1055 /* rc.right += 1; */
1056 /* rc.bottom += 1; */
1059 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
1062 td->size_wid = rc.right - rc.left;
1063 td->size_hgt = rc.bottom - rc.top;
1065 /* See CreateWindowEx */
1068 /* Extract actual location */
1069 GetWindowRect(td->w, &rc);
1071 /* Save the location */
1072 td->pos_x = rc.left;
1078 * Write the "prefs" for a single term
1080 static void save_prefs_aux(int i)
1082 term_data *td = &data[i];
1087 WINDOWPLACEMENT lpwndpl;
1092 /* Make section name */
1093 sprintf(sec_name, "Term-%d", i);
1098 strcpy(buf, td->visible ? "1" : "0");
1099 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
1104 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "£Í£Ó ¥´¥·¥Ã¥¯");
1107 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
1109 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
1113 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
1115 #if 1 /* #ifdef JP */
1116 wsprintf(buf, "%d", td->lf.lfWidth);
1117 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
1118 wsprintf(buf, "%d", td->lf.lfHeight);
1119 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
1120 wsprintf(buf, "%d", td->lf.lfWeight);
1121 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
1124 strcpy(buf, td->bizarre ? "1" : "0");
1125 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
1128 wsprintf(buf, "%d", td->tile_wid);
1129 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
1132 wsprintf(buf, "%d", td->tile_hgt);
1133 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
1135 /* Get window placement and dimensions */
1136 lpwndpl.length = sizeof(WINDOWPLACEMENT);
1137 GetWindowPlacement(td->w, &lpwndpl);
1139 /* Acquire position in *normal* mode (not minimized) */
1140 rc = lpwndpl.rcNormalPosition;
1142 /* Window size (x) */
1143 if (i == 0) wsprintf(buf, "%d", normsize.x);
1144 else wsprintf(buf, "%d", td->cols);
1145 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
1147 /* Window size (y) */
1148 if (i == 0) wsprintf(buf, "%d", normsize.y);
1149 else wsprintf(buf, "%d", td->rows);
1150 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
1152 /* Maxmized (only main window) */
1155 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
1156 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
1159 /* Acquire position */
1160 GetWindowRect(td->w, &rc);
1162 /* Window position (x) */
1163 wsprintf(buf, "%d", rc.left);
1164 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
1166 /* Window position (y) */
1167 wsprintf(buf, "%d", rc.top);
1168 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
1170 /* Window Z position */
1173 strcpy(buf, td->posfix ? "1" : "0");
1174 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
1182 * We assume that the windows have all been initialized
1184 static void save_prefs(void)
1190 /* Save the "arg_graphics" flag */
1191 sprintf(buf, "%d", arg_graphics);
1192 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
1194 /* Save the "arg_bigtile" flag */
1195 strcpy(buf, arg_bigtile ? "1" : "0");
1196 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
1198 /* Save the "arg_sound" flag */
1199 strcpy(buf, arg_sound ? "1" : "0");
1200 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
1203 strcpy(buf, use_bg ? "1" : "0");
1204 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
1205 WritePrivateProfileString("Angband", "BackGroundBitmap",
1206 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
1208 /* Save window prefs */
1209 for (i = 0; i < MAX_TERM_DATA; ++i)
1217 * Load the "prefs" for a single term
1219 static void load_prefs_aux(int i)
1221 term_data *td = &data[i];
1227 /* Make section name */
1228 sprintf(sec_name, "Term-%d", i);
1230 /* Make section name */
1231 sprintf(sec_name, "Term-%d", i);
1236 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
1239 /* Desired font, with default */
1241 GetPrivateProfileString(sec_name, "Font", "£Í£Ó ¥´¥·¥Ã¥¯", tmp, 127, ini_file);
1244 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
1246 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
1252 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
1254 /* Analyze font, save desired font name */
1255 #if 1 /* #ifdef JP */
1256 td->font_want = string_make(tmp);
1258 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
1259 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
1260 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
1262 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
1267 #if 1 /* #ifdef JP */
1268 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
1269 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
1271 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
1272 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
1277 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
1278 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
1279 normsize.x = td->cols; normsize.y = td->rows;
1284 win_maximized = GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file);
1287 /* Window position */
1288 td->pos_x = GetPrivateProfileInt(sec_name, "PositionX", td->pos_x, ini_file);
1289 td->pos_y = GetPrivateProfileInt(sec_name, "PositionY", td->pos_y, ini_file);
1291 /* Window Z position */
1294 td->posfix = GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file);
1302 static void load_prefs(void)
1306 /* Extract the "arg_graphics" flag */
1307 arg_graphics = GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
1309 /* Extract the "arg_bigtile" flag */
1310 arg_bigtile = GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file);
1311 use_bigtile = arg_bigtile;
1313 /* Extract the "arg_sound" flag */
1314 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
1317 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
1318 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
1320 /* Load window prefs */
1321 for (i = 0; i < MAX_TERM_DATA; ++i)
1330 * XXX XXX XXX - Taken from files.c.
1332 * Extract "tokens" from a buffer
1334 * This function uses "whitespace" as delimiters, and treats any amount of
1335 * whitespace as a single delimiter. We will never return any empty tokens.
1336 * When given an empty buffer, or a buffer containing only "whitespace", we
1337 * will return no tokens. We will never extract more than "num" tokens.
1339 * By running a token through the "text_to_ascii()" function, you can allow
1340 * that token to include (encoded) whitespace, using "\s" to encode spaces.
1342 * We save pointers to the tokens in "tokens", and return the number found.
1344 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
1356 /* Skip leading whitespace */
1357 for ( ; *s && isspace(*s); ++s) /* loop */;
1362 /* Find next whitespace, if any */
1363 for (t = s; *t && !isspace(*t); ++t) /* loop */;
1365 /* Nuke and advance (if necessary) */
1366 if (*t) *t++ = '\0';
1368 /* Save the token */
1379 static void load_sound_prefs(void)
1383 char ini_path[1024];
1384 char wav_path[1024];
1385 char *zz[SAMPLE_MAX];
1387 /* Access the sound.cfg */
1388 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
1390 for (i = 0; i < SOUND_MAX; i++)
1392 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
1394 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
1396 for (j = 0; j < num; j++)
1398 /* Access the sound */
1399 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
1401 /* Save the sound filename, if it exists */
1402 if (check_file(wav_path))
1403 sound_file[i][j] = string_make(zz[j]);
1408 #endif /* USE_SOUND */
1411 * Create the new global palette based on the bitmap palette
1412 * (if any), and the standard 16 entry palette derived from
1413 * "win_clr[]" which is used for the basic 16 Angband colors.
1415 * This function is never called before all windows are ready.
1417 * This function returns FALSE if the new palette could not be
1418 * prepared, which should normally be a fatal error. XXX XXX
1420 * Note that only some machines actually use a "palette".
1422 static int new_palette(void)
1430 LPLOGPALETTE pLogPal;
1431 LPPALETTEENTRY lppe;
1436 /* This makes no sense */
1437 if (!paletted) return (TRUE);
1447 /* Check the bitmap palette */
1448 hBmPal = infGraph.hPalette;
1450 /* Use the bitmap */
1453 lppeSize = 256 * sizeof(PALETTEENTRY);
1454 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
1455 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
1456 if ((nEntries == 0) || (nEntries > 220))
1460 plog("²èÌ̤ò16¥Ó¥Ã¥È¤«24¥Ó¥Ã¥È¥«¥é¡¼¥â¡¼¥É¤Ë¤·¤Æ²¼¤µ¤¤¡£");
1462 plog("Please switch to high- or true-color mode.");
1467 rnfree(lppe, lppeSize);
1474 #endif /* USE_GRAPHICS */
1476 /* Size of palette */
1477 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
1479 /* Allocate palette */
1480 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
1483 pLogPal->palVersion = 0x300;
1485 /* Make room for bitmap and normal data */
1486 pLogPal->palNumEntries = nEntries + 16;
1488 /* Save the bitmap data */
1489 for (i = 0; i < nEntries; i++)
1491 pLogPal->palPalEntry[i] = lppe[i];
1494 /* Save the normal data */
1495 for (i = 0; i < 16; i++)
1499 /* Access the entry */
1500 p = &(pLogPal->palPalEntry[i+nEntries]);
1502 /* Save the colors */
1503 p->peRed = GetRValue(win_clr[i]);
1504 p->peGreen = GetGValue(win_clr[i]);
1505 p->peBlue = GetBValue(win_clr[i]);
1507 /* Save the flags */
1508 p->peFlags = PC_NOCOLLAPSE;
1511 /* Free something */
1512 if (lppe) rnfree(lppe, lppeSize);
1514 /* Create a new palette, or fail */
1515 hNewPal = CreatePalette(pLogPal);
1517 if (!hNewPal) quit("¥Ñ¥ì¥Ã¥È¤òºîÀ®¤Ç¤¤Þ¤»¤ó¡ª");
1519 if (!hNewPal) quit("Cannot create palette!");
1523 /* Free the palette */
1524 rnfree(pLogPal, pLogPalSize);
1529 /* Realize the palette */
1531 SelectPalette(hdc, hNewPal, 0);
1532 i = RealizePalette(hdc);
1533 ReleaseDC(td->w, hdc);
1535 if (i == 0) quit("¥Ñ¥ì¥Ã¥È¤ò¥·¥¹¥Æ¥à¥¨¥ó¥È¥ê¤Ë¥Þ¥Ã¥×¤Ç¤¤Þ¤»¤ó¡ª");
1537 if (i == 0) quit("Cannot realize palette!");
1542 for (i = 1; i < MAX_TERM_DATA; i++)
1547 SelectPalette(hdc, hNewPal, 0);
1548 ReleaseDC(td->w, hdc);
1551 /* Delete old palette */
1552 if (hPal) DeleteObject(hPal);
1554 /* Save new palette */
1564 * Initialize graphics
1566 static bool init_graphics(void)
1568 /* Initialize once */
1569 /* if (can_use_graphics != arg_graphics) */
1575 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1582 ANGBAND_GRAF = "new";
1590 ANGBAND_GRAF = "old";
1593 /* Access the bitmap file */
1594 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
1596 /* Load the bitmap or quit */
1597 if (!ReadDIB(data[0].w, buf, &infGraph))
1600 plog_fmt("¥Ó¥Ã¥È¥Þ¥Ã¥× '%s' ¤òÆɤ߹þ¤á¤Þ¤»¤ó¡£", name);
1602 plog_fmt("Cannot read bitmap file '%s'", name);
1608 /* Save the new sizes */
1609 infGraph.CellWidth = wid;
1610 infGraph.CellHeight = hgt;
1612 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1614 /* Access the mask file */
1615 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
1617 /* Load the bitmap or quit */
1618 if (!ReadDIB(data[0].w, buf, &infMask))
1620 plog_fmt("Cannot read bitmap file '%s'", buf);
1625 /* Activate a palette */
1628 /* Free bitmap XXX XXX XXX */
1632 plog("¥Ñ¥ì¥Ã¥È¤ò¼Â¸½¤Ç¤¤Þ¤»¤ó¡ª");
1634 plog("Cannot activate palette!");
1640 /* Graphics available */
1641 can_use_graphics = arg_graphics;
1645 return (can_use_graphics);
1647 #endif /* USE_GRAPHICS */
1654 static bool init_sound(void)
1656 /* Initialize once */
1659 /* Load the prefs */
1662 /* Sound available */
1663 can_use_sound = TRUE;
1667 return (can_use_sound);
1669 #endif /* USE_SOUND */
1675 static void term_window_resize(term_data *td)
1677 /* Require window */
1680 /* Resize the window */
1681 SetWindowPos(td->w, 0, 0, 0,
1682 td->size_wid, td->size_hgt,
1683 SWP_NOMOVE | SWP_NOZORDER);
1686 InvalidateRect(td->w, NULL, TRUE);
1691 * Force the use of a new "font file" for a term_data
1693 * This function may be called before the "window" is ready
1695 * This function returns zero only if everything succeeds.
1697 * Note that the "font name" must be capitalized!!!
1699 static errr term_force_font(term_data *td, cptr path)
1703 #if 0 /* #ifndef JP */
1709 /* Forget the old font (if needed) */
1710 if (td->font_id) DeleteObject(td->font_id);
1712 #if 1 /* #ifdef JP */
1716 /* Create the font (using the 'base' of the font file name!) */
1717 td->font_id = CreateFontIndirect(&(td->lf));
1718 wid = td->lf.lfWidth;
1719 hgt = td->lf.lfHeight;
1720 if (!td->font_id) return (1);
1722 /* Forget old font */
1728 for (i = 0; i < MAX_TERM_DATA; i++)
1730 /* Don't check when closing the application */
1733 /* Check "screen" */
1734 if ((td != &data[i]) &&
1735 (data[i].font_file) &&
1736 (streq(data[i].font_file, td->font_file)))
1742 /* Remove unused font resources */
1743 if (!used) RemoveFontResource(td->font_file);
1745 /* Free the old name */
1746 string_free(td->font_file);
1749 td->font_file = NULL;
1753 if (!path) return (1);
1758 /* Analyze font path */
1759 base = analyze_font(buf, &wid, &hgt);
1762 if (!suffix(base, ".FON")) return (1);
1765 if (!check_file(buf)) return (1);
1767 /* Load the new font */
1768 if (!AddFontResource(buf)) return (1);
1770 /* Save new font name */
1771 td->font_file = string_make(base);
1773 /* Remove the "suffix" */
1774 base[strlen(base)-4] = '\0';
1776 /* Create the font (using the 'base' of the font file name!) */
1777 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
1778 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
1779 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
1780 FIXED_PITCH | FF_DONTCARE, base);
1783 /* Hack -- Unknown size */
1790 /* all this trouble to get the cell size */
1791 hdcDesktop = GetDC(HWND_DESKTOP);
1792 hfOld = SelectObject(hdcDesktop, td->font_id);
1793 GetTextMetrics(hdcDesktop, &tm);
1794 SelectObject(hdcDesktop, hfOld);
1795 ReleaseDC(HWND_DESKTOP, hdcDesktop);
1797 /* Font size info */
1798 wid = tm.tmAveCharWidth;
1802 /* Save the size info */
1813 * Allow the user to change the font for this window.
1815 static void term_change_font(term_data *td)
1817 #if 1 /* #ifdef JP */
1820 memset(&cf, 0, sizeof(cf));
1821 cf.lStructSize = sizeof(cf);
1822 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
1823 cf.lpLogFont = &(td->lf);
1825 if (ChooseFont(&cf))
1827 /* Force the font */
1828 term_force_font(td, NULL);
1830 /* Assume not bizarre */
1833 /* Reset the tile info */
1834 td->tile_wid = td->font_wid;
1835 td->tile_hgt = td->font_hgt;
1837 /* Analyze the font */
1840 /* Resize the window */
1841 term_window_resize(td);
1847 char tmp[1024] = "";
1849 /* Extract a default if possible */
1850 if (td->font_file) strcpy(tmp, td->font_file);
1852 /* Ask for a choice */
1853 memset(&ofn, 0, sizeof(ofn));
1854 ofn.lStructSize = sizeof(ofn);
1855 ofn.hwndOwner = data[0].w;
1856 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
1857 ofn.nFilterIndex = 1;
1858 ofn.lpstrFile = tmp;
1860 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
1861 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
1862 ofn.lpstrDefExt = "fon";
1864 /* Force choice if legal */
1865 if (GetOpenFileName(&ofn))
1867 /* Force the font */
1868 if (term_force_font(td, tmp))
1870 /* Access the standard font file */
1871 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
1873 /* Force the use of that font */
1874 (void)term_force_font(td, tmp);
1877 /* Assume not bizarre */
1878 td->bizarre = FALSE;
1880 /* Reset the tile info */
1881 td->tile_wid = td->font_wid;
1882 td->tile_hgt = td->font_hgt;
1884 /* Analyze the font */
1887 /* Resize the window */
1888 term_window_resize(td);
1895 * Allow the user to lock this window.
1897 static void term_window_pos(term_data *td, HWND hWnd)
1899 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
1900 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1903 static void windows_map(void);
1906 * Hack -- redraw a term_data
1908 static void term_data_redraw(term_data *td)
1912 /* Redraw the map */
1917 /* Activate the term */
1918 Term_activate(&td->t);
1920 /* Redraw the contents */
1923 /* Restore the term */
1924 Term_activate(term_screen);
1932 /*** Function hooks needed by "Term" ***/
1938 * Initialize a new Term
1940 static void Term_init_win(term *t)
1949 static void Term_nuke_win(term *t)
1958 * Interact with the User
1960 static errr Term_user_win(int n)
1971 * React to global changes
1973 static errr Term_xtra_win_react(void)
1981 /* Save the default colors */
1982 for (i = 0; i < 256; i++)
1984 /* Simply accept the desired colors */
1985 win_pal[i] = angband_color_table[i][0];
1996 bool change = FALSE;
1998 /* Save the default colors */
1999 for (i = 0; i < 256; i++)
2001 /* Extract desired values */
2002 rv = angband_color_table[i][1];
2003 gv = angband_color_table[i][2];
2004 bv = angband_color_table[i][3];
2006 /* Extract a full color code */
2007 code = PALETTERGB(rv, gv, bv);
2009 /* Activate changes */
2010 if (win_clr[i] != code)
2012 /* Note the change */
2015 /* Apply the desired color */
2020 /* Activate the palette if needed */
2021 if (change) (void)new_palette();
2027 /* Handle "arg_sound" */
2028 if (use_sound != arg_sound)
2030 /* Initialize (if needed) */
2031 if (arg_sound && !init_sound())
2035 plog("¥µ¥¦¥ó¥É¤ò½é´ü²½¤Ç¤¤Þ¤»¤ó¡ª");
2037 plog("Cannot initialize sound!");
2045 /* Change setting */
2046 use_sound = arg_sound;
2054 /* Handle "arg_graphics" */
2055 if (use_graphics != arg_graphics)
2057 /* Initialize (if needed) */
2058 if (arg_graphics && !init_graphics())
2062 plog("¥°¥é¥Õ¥£¥Ã¥¯¥¹¤ò½é´ü²½¤Ç¤¤Þ¤»¤ó!");
2064 plog("Cannot initialize graphics!");
2069 arg_graphics = GRAPHICS_NONE;
2072 /* Change setting */
2073 use_graphics = arg_graphics;
2076 #ifdef ANGBAND_2_8_1
2078 #else /* ANGBAND_2_8_1 */
2079 reset_visuals(TRUE);
2080 #endif /* ANGBAND_2_8_1 */
2083 #endif /* USE_GRAPHICS */
2086 /* Clean up windows */
2087 for (i = 0; i < MAX_TERM_DATA; i++)
2091 term_data *td = &data[i];
2093 /* Update resized windows */
2094 if ((td->cols != (uint)td->t.wid) || (td->rows != (uint)td->t.hgt))
2097 Term_activate(&td->t);
2099 /* Hack -- Resize the term */
2100 Term_resize(td->cols, td->rows);
2102 /* Redraw the contents */
2117 * Process at least one event
2119 static errr Term_xtra_win_event(int v)
2123 /* Wait for an event */
2127 if (GetMessage(&msg, NULL, 0, 0))
2129 TranslateMessage(&msg);
2130 DispatchMessage(&msg);
2134 /* Check for an event */
2138 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2140 TranslateMessage(&msg);
2141 DispatchMessage(&msg);
2151 * Process all pending events
2153 static errr Term_xtra_win_flush(void)
2157 /* Process all pending events */
2158 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2160 TranslateMessage(&msg);
2161 DispatchMessage(&msg);
2170 * Hack -- clear the screen
2172 * Make this more efficient XXX XXX XXX
2174 static errr Term_xtra_win_clear(void)
2176 term_data *td = (term_data*)(Term->data);
2181 /* Rectangle to erase */
2182 rc.left = td->size_ow1;
2183 rc.right = rc.left + td->cols * td->tile_wid;
2184 rc.top = td->size_oh1;
2185 rc.bottom = rc.top + td->rows * td->tile_hgt;
2189 SetBkColor(hdc, RGB(0, 0, 0));
2190 SelectObject(hdc, td->font_id);
2191 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2196 rc.left = 0; rc.top = 0;
2199 ReleaseDC(td->w, hdc);
2207 * Hack -- make a noise
2209 static errr Term_xtra_win_noise(void)
2211 MessageBeep(MB_ICONASTERISK);
2217 * Hack -- make a sound
2219 static errr Term_xtra_win_sound(int v)
2224 #endif /* USE_SOUND */
2226 /* Sound disabled */
2227 if (!use_sound) return (1);
2230 if ((v < 0) || (v >= SOUND_MAX)) return (1);
2234 /* Count the samples */
2235 for (i = 0; i < SAMPLE_MAX; i++)
2237 if (!sound_file[v][i])
2242 if (i == 0) return (1);
2244 /* Build the path */
2245 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_simple(i)]);
2249 /* Play the sound, catch errors */
2250 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
2254 /* Play the sound, catch errors */
2255 return (sndPlaySound(buf, SND_ASYNC));
2259 #else /* USE_SOUND */
2264 #endif /* USE_SOUND */
2269 * Delay for "x" milliseconds
2271 static int Term_xtra_win_delay(int v)
2285 t = GetTickCount() + v;
2288 while (GetTickCount() < t)
2290 /* Handle messages */
2291 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2293 TranslateMessage(&msg);
2294 DispatchMessage(&msg);
2306 * Do a "special thing"
2308 static errr Term_xtra_win(int n, int v)
2310 /* Handle a subset of the legal requests */
2313 /* Make a bell sound */
2314 case TERM_XTRA_NOISE:
2316 return (Term_xtra_win_noise());
2319 /* Make a special sound */
2320 case TERM_XTRA_SOUND:
2322 return (Term_xtra_win_sound(v));
2325 /* Process random events */
2326 case TERM_XTRA_BORED:
2328 return (Term_xtra_win_event(0));
2331 /* Process an event */
2332 case TERM_XTRA_EVENT:
2334 return (Term_xtra_win_event(v));
2337 /* Flush all events */
2338 case TERM_XTRA_FLUSH:
2340 return (Term_xtra_win_flush());
2343 /* Clear the screen */
2344 case TERM_XTRA_CLEAR:
2346 return (Term_xtra_win_clear());
2349 /* React to global changes */
2350 case TERM_XTRA_REACT:
2352 return (Term_xtra_win_react());
2355 /* Delay for some milliseconds */
2356 case TERM_XTRA_DELAY:
2358 return (Term_xtra_win_delay(v));
2369 * Low level graphics (Assumes valid input).
2371 * Draw a "cursor" at (x,y), using a "yellow box".
2373 static errr Term_curs_win(int x, int y)
2375 term_data *td = (term_data*)(Term->data);
2380 int tile_wid, tile_hgt;
2384 tile_wid = td->map_tile_wid;
2385 tile_hgt = td->map_tile_hgt;
2389 tile_wid = td->tile_wid;
2390 tile_hgt = td->tile_hgt;
2393 /* Frame the grid */
2394 rc.left = x * tile_wid + td->size_ow1;
2395 rc.right = rc.left + tile_wid;
2396 rc.top = y * tile_hgt + td->size_oh1;
2397 rc.bottom = rc.top + tile_hgt;
2399 /* Cursor is done as a yellow "box" */
2401 FrameRect(hdc, &rc, hbrYellow);
2402 ReleaseDC(td->w, hdc);
2410 * Low level graphics (Assumes valid input).
2412 * Draw a "big cursor" at (x,y), using a "yellow box".
2414 static errr Term_bigcurs_win(int x, int y)
2416 term_data *td = (term_data*)(Term->data);
2421 int tile_wid, tile_hgt;
2425 /* Normal cursor in map window */
2426 Term_curs_win(x, y);
2431 tile_wid = td->tile_wid;
2432 tile_hgt = td->tile_hgt;
2435 /* Frame the grid */
2436 rc.left = x * tile_wid + td->size_ow1;
2437 rc.right = rc.left + 2 * tile_wid;
2438 rc.top = y * tile_hgt + td->size_oh1;
2439 rc.bottom = rc.top + tile_hgt;
2441 /* Cursor is done as a yellow "box" */
2443 FrameRect(hdc, &rc, hbrYellow);
2444 ReleaseDC(td->w, hdc);
2452 * Low level graphics (Assumes valid input).
2454 * Erase a "block" of "n" characters starting at (x,y).
2456 static errr Term_wipe_win(int x, int y, int n)
2458 term_data *td = (term_data*)(Term->data);
2463 /* Rectangle to erase in client coords */
2464 rc.left = x * td->tile_wid + td->size_ow1;
2465 rc.right = rc.left + n * td->tile_wid;
2466 rc.top = y * td->tile_hgt + td->size_oh1;
2467 rc.bottom = rc.top + td->tile_hgt;
2470 SetBkColor(hdc, RGB(0, 0, 0));
2471 SelectObject(hdc, td->font_id);
2476 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2477 ReleaseDC(td->w, hdc);
2485 * Low level graphics. Assumes valid input.
2487 * Draw several ("n") chars, with an attr, at a given location.
2489 * All "graphic" data is handled by "Term_pict_win()", below.
2491 * One would think there is a more efficient method for telling a window
2492 * what color it should be using to draw with, but perhaps simply changing
2493 * it every time is not too inefficient. XXX XXX XXX
2495 static errr Term_text_win(int x, int y, int n, byte a, const char *s)
2497 term_data *td = (term_data*)(Term->data);
2501 #if 1 /* #ifdef JP */
2502 static HBITMAP WALL;
2503 static HBRUSH myBrush, oldBrush;
2505 static bool init_done = FALSE;
2508 WALL = LoadBitmap(hInstance, AppName);
2509 myBrush = CreatePatternBrush(WALL);
2514 /* Total rectangle */
2515 rc.left = x * td->tile_wid + td->size_ow1;
2516 rc.right = rc.left + n * td->tile_wid;
2517 rc.top = y * td->tile_hgt + td->size_oh1;
2518 rc.bottom = rc.top + td->tile_hgt;
2523 /* Background color */
2524 SetBkColor(hdc, RGB(0, 0, 0));
2526 /* Foreground color */
2529 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
2533 SetTextColor(hdc, win_clr[a&0x0F]);
2537 SetTextColor(hdc, win_clr[a]);
2541 SelectObject(hdc, td->font_id);
2544 if (use_bg) SetBkMode(hdc, TRANSPARENT);
2548 (td->tile_hgt != td->font_hgt) ||
2549 (td->tile_wid != td->font_wid))
2553 /* Erase complete rectangle */
2554 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2557 if (use_bg) DrawBG(hdc, &rc);
2560 rc.left += ((td->tile_wid - td->font_wid) / 2);
2561 rc.right = rc.left + td->font_wid;
2562 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
2563 rc.bottom = rc.top + td->font_hgt;
2565 /* Dump each character */
2566 for (i = 0; i < n; i++)
2569 if (use_bigtile && *(s+i)=="¢£"[0] && *(s+i+1)=="¢£"[1])
2571 rc.right += td->font_wid;
2573 oldBrush = SelectObject(hdc, myBrush);
2574 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2577 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2579 SelectObject(hdc, oldBrush);
2580 SelectObject(hdc, oldPen);
2581 rc.right -= td->font_wid;
2585 rc.left += 2 * td->tile_wid;
2586 rc.right += 2 * td->tile_wid;
2588 else if ( iskanji(*(s+i)) ) /* £²¥Ð¥¤¥Èʸ»ú */
2590 rc.right += td->font_wid;
2592 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2594 rc.right -= td->font_wid;
2598 rc.left += 2 * td->tile_wid;
2599 rc.right += 2 * td->tile_wid;
2600 } else if (*(s+i)==127){
2601 oldBrush = SelectObject(hdc, myBrush);
2602 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2605 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2607 SelectObject(hdc, oldBrush);
2608 SelectObject(hdc, oldPen);
2611 rc.left += td->tile_wid;
2612 rc.right += td->tile_wid;
2615 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2619 rc.left += td->tile_wid;
2620 rc.right += td->tile_wid;
2625 oldBrush = SelectObject(hdc, myBrush);
2626 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2629 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2631 SelectObject(hdc, oldBrush);
2632 SelectObject(hdc, oldPen);
2635 rc.left += td->tile_wid;
2636 rc.right += td->tile_wid;
2639 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2643 rc.left += td->tile_wid;
2644 rc.right += td->tile_wid;
2648 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
2652 rc.left += td->tile_wid;
2653 rc.right += td->tile_wid;
2664 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
2669 ReleaseDC(td->w, hdc);
2677 * Low level graphics. Assumes valid input.
2679 * Draw an array of "special" attr/char pairs at the given location.
2681 * We use the "Term_pict_win()" function for "graphic" data, which are
2682 * encoded by setting the "high-bits" of both the "attr" and the "char"
2683 * data. We use the "attr" to represent the "row" of the main bitmap,
2684 * and the "char" to represent the "col" of the main bitmap. The use
2685 * of this function is induced by the "higher_pict" flag.
2687 * If "graphics" is not available, we simply "wipe" the given grids.
2689 static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
2691 term_data *td = (term_data*)(Term->data);
2697 int x2, y2, w2, h2, tw2;
2709 /* Erase the grids */
2710 return (Term_wipe_win(x, y, n));
2713 /* Size of bitmap cell */
2714 w1 = infGraph.CellWidth;
2715 h1 = infGraph.CellHeight;
2717 /* Size of window cell */
2720 w2 = td->map_tile_wid;
2721 h2 = td->map_tile_hgt;
2730 if (use_bigtile) tw2 *= 2;
2733 /* Location of window cell */
2734 x2 = x * w2 + td->size_ow1;
2735 y2 = y * h2 + td->size_oh1;
2741 hdcSrc = CreateCompatibleDC(hdc);
2742 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
2744 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2746 hdcMask = CreateCompatibleDC(hdc);
2747 SelectObject(hdcMask, infMask.hBitmap);
2750 /* Draw attr/char pairs */
2751 for (i = 0; i < n; i++, x2 += w2)
2756 /* Extract picture */
2757 int row = (a & 0x7F);
2758 int col = (c & 0x7F);
2760 /* Location of bitmap cell */
2764 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2766 x3 = (tcp[i] & 0x7F) * w1;
2767 y3 = (tap[i] & 0x7F) * h1;
2770 if ((w1 == tw2) && (h1 == h2))
2772 /* Copy the terrain picture from the bitmap to the window */
2773 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
2775 /* Mask out the tile */
2776 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
2779 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
2782 /* Need to stretch */
2785 /* Set the correct mode for stretching the tiles */
2786 SetStretchBltMode(hdc, COLORONCOLOR);
2788 /* Copy the terrain picture from the bitmap to the window */
2789 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCCOPY);
2791 /* Only draw if terrain and overlay are different */
2792 if ((x1 != x3) || (y1 != y3))
2794 /* Mask out the tile */
2795 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
2798 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
2805 if ((w1 == tw2) && (h1 == h2))
2807 /* Copy the picture from the bitmap to the window */
2808 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
2811 /* Need to stretch */
2814 /* Set the correct mode for stretching the tiles */
2815 SetStretchBltMode(hdc, COLORONCOLOR);
2817 /* Copy the picture from the bitmap to the window */
2818 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
2824 SelectObject(hdcSrc, hbmSrcOld);
2827 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2830 SelectObject(hdcMask, hbmSrcOld);
2835 ReleaseDC(td->w, hdc);
2837 #else /* USE_GRAPHICS */
2839 /* Just erase this grid */
2840 return (Term_wipe_win(x, y, n));
2842 #endif /* USE_GRAPHICS */
2849 static void windows_map(void)
2851 term_data *td = &data[0];
2853 int x, min_x, max_x;
2854 int y, min_y, max_y;
2858 /* Only in graphics mode */
2859 if (!use_graphics) return;
2862 Term_xtra_win_clear();
2864 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
2865 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
2866 td->map_active = TRUE;
2876 for (x = min_x; x < max_x; x++)
2878 for (y = min_y; y < max_y; y++)
2880 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
2882 /* Ignore non-graphics */
2883 if ((a & 0x80) && (c & 0x80))
2885 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
2890 /* Hilite the player */
2891 Term_curs_win(px - min_x, py - min_y);
2893 /* Wait for a keypress, flush key buffer */
2894 Term_inkey(&c, TRUE, TRUE);
2897 /* Switch off the map display */
2898 td->map_active = FALSE;
2900 /* Restore screen */
2901 Term_xtra_win_clear();
2906 /*** Other routines ***/
2910 * Create and initialize a "term_data" given a title
2912 static void term_data_link(term_data *td)
2916 /* Initialize the term */
2917 term_init(t, td->cols, td->rows, td->keys);
2919 /* Use a "software" cursor */
2920 t->soft_cursor = TRUE;
2922 /* Use "Term_pict" for "graphic" data */
2923 t->higher_pict = TRUE;
2925 /* Erase with "white space" */
2926 t->attr_blank = TERM_WHITE;
2927 t->char_blank = ' ';
2930 /* Prepare the init/nuke hooks */
2931 t->init_hook = Term_init_win;
2932 t->nuke_hook = Term_nuke_win;
2935 /* Prepare the template hooks */
2936 t->user_hook = Term_user_win;
2937 t->xtra_hook = Term_xtra_win;
2938 t->curs_hook = Term_curs_win;
2939 t->bigcurs_hook = Term_bigcurs_win;
2940 t->wipe_hook = Term_wipe_win;
2941 t->text_hook = Term_text_win;
2942 t->pict_hook = Term_pict_win;
2944 /* Remember where we came from */
2945 t->data = (vptr)(td);
2950 * Create the windows
2952 * First, instantiate the "default" values, then read the "ini_file"
2953 * to over-ride selected values, then create the windows, and fonts.
2955 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
2956 * must make active to realize the palette. XXX XXX XXX
2958 static void init_windows(void)
2964 #if 0 /* #ifndef JP */
2970 WIPE(td, term_data);
2974 td->s = angband_term_name[0];
2988 #if 1 /* #ifdef JP */
2992 for (i = 1; i < MAX_TERM_DATA; i++)
2995 WIPE(td, term_data);
2996 td->s = angband_term_name[i];
3000 td->visible = FALSE;
3005 td->pos_x = (7 - i) * 30;
3006 td->pos_y = (7 - i) * 20;
3008 #if 1 /* #ifdef JP */
3018 /* Main window (need these before term_getsize gets called) */
3020 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
3021 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
3026 /* Sub windows (need these before term_getsize gets called) */
3027 for (i = 1; i < MAX_TERM_DATA; i++)
3030 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
3031 td->dwExStyle = (WS_EX_TOOLWINDOW);
3036 for (i = 0; i < MAX_TERM_DATA; i++)
3040 #if 1 /* #ifdef JP */
3041 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
3042 td->lf.lfCharSet = DEFAULT_CHARSET;
3043 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
3044 /* Activate the chosen font */
3045 term_force_font(td, NULL);
3046 td->tile_wid = td->font_wid;
3047 td->tile_hgt = td->font_hgt;
3049 /* Access the standard font file */
3050 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
3052 /* Activate the chosen font */
3053 if (term_force_font(td, buf))
3055 /* Access the standard font file */
3056 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
3058 /* Force the use of that font */
3059 (void)term_force_font(td, buf);
3065 /* Assume not bizarre */
3066 td->bizarre = FALSE;
3071 /* Analyze the font */
3074 /* Resize the window */
3075 term_window_resize(td);
3079 /* Sub windows (reverse order) */
3080 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
3085 td->w = CreateWindowEx(td->dwExStyle, AngList,
3087 td->pos_x, td->pos_y,
3088 td->size_wid, td->size_hgt,
3089 HWND_DESKTOP, NULL, hInstance, NULL);
3092 if (!td->w) quit("¥µ¥Ö¥¦¥£¥ó¥É¥¦¤ËºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿");
3094 if (!td->w) quit("Failed to create sub-window");
3100 td->size_hack = TRUE;
3101 ShowWindow(td->w, SW_SHOW);
3102 td->size_hack = FALSE;
3106 angband_term[i] = &td->t;
3110 /* Activate the window */
3111 SetActiveWindow(td->w);
3116 term_window_pos(&data[i], HWND_TOPMOST);
3120 term_window_pos(&data[i], td->w);
3130 td->w = CreateWindowEx(td->dwExStyle, AppName,
3132 td->pos_x, td->pos_y,
3133 td->size_wid, td->size_hgt,
3134 HWND_DESKTOP, NULL, hInstance, NULL);
3137 if (!td->w) quit("¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿");
3139 if (!td->w) quit("Failed to create Angband window");
3144 angband_term[0] = &td->t;
3145 normsize.x = td->cols;
3146 normsize.y = td->rows;
3148 /* Activate the main window */
3149 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
3150 else ShowWindow(td->w, SW_SHOW);
3152 /* Bring main window back to top */
3153 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
3156 /* New palette XXX XXX XXX */
3157 (void)new_palette();
3160 /* Create a "brush" for drawing the "cursor" */
3161 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
3164 /* Process pending messages */
3165 (void)Term_xtra_win_flush();
3173 static void setup_menus(void)
3177 HMENU hm = GetMenu(data[0].w);
3180 /* Menu "File", Disable all */
3181 EnableMenuItem(hm, IDM_FILE_NEW,
3182 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3183 EnableMenuItem(hm, IDM_FILE_OPEN,
3184 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3185 EnableMenuItem(hm, IDM_FILE_SAVE,
3186 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3187 EnableMenuItem(hm, IDM_FILE_EXIT,
3188 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3189 EnableMenuItem(hm, IDM_FILE_SCORE,
3190 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3193 /* No character available */
3194 if (!character_generated)
3196 /* Menu "File", Item "New" */
3197 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
3199 /* Menu "File", Item "Open" */
3200 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
3203 /* A character available */
3204 if (character_generated)
3206 /* Menu "File", Item "Save" */
3207 EnableMenuItem(hm, IDM_FILE_SAVE,
3208 MF_BYCOMMAND | MF_ENABLED);
3211 /* Menu "File", Item "Exit" */
3212 EnableMenuItem(hm, IDM_FILE_EXIT,
3213 MF_BYCOMMAND | MF_ENABLED);
3215 EnableMenuItem(hm, IDM_FILE_SCORE,
3216 MF_BYCOMMAND | MF_ENABLED);
3219 /* Menu "Window::Visibility" */
3220 for (i = 0; i < MAX_TERM_DATA; i++)
3222 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3223 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3225 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3226 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
3228 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3229 MF_BYCOMMAND | MF_ENABLED);
3232 /* Menu "Window::Font" */
3233 for (i = 0; i < MAX_TERM_DATA; i++)
3235 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3236 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3238 if (data[i].visible)
3240 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3241 MF_BYCOMMAND | MF_ENABLED);
3245 /* Menu "Window::Window Position Fix" */
3246 for (i = 0; i < MAX_TERM_DATA; i++)
3248 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3249 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3251 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
3252 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
3254 if (data[i].visible)
3256 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3257 MF_BYCOMMAND | MF_ENABLED);
3261 /* Menu "Window::Bizarre Display" */
3262 for (i = 0; i < MAX_TERM_DATA; i++)
3264 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3265 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3267 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3268 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
3270 if (data[i].visible)
3272 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3273 MF_BYCOMMAND | MF_ENABLED);
3278 /* Menu "Window::Increase Tile Width" */
3279 for (i = 0; i < MAX_TERM_DATA; i++)
3281 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3282 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3284 if (data[i].visible)
3286 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3287 MF_BYCOMMAND | MF_ENABLED);
3292 /* Menu "Window::Decrease Tile Width" */
3293 for (i = 0; i < MAX_TERM_DATA; i++)
3295 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3296 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3298 if (data[i].visible)
3300 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3301 MF_BYCOMMAND | MF_ENABLED);
3306 /* Menu "Window::Increase Tile Height" */
3307 for (i = 0; i < MAX_TERM_DATA; i++)
3309 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3310 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3312 if (data[i].visible)
3314 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3315 MF_BYCOMMAND | MF_ENABLED);
3320 /* Menu "Window::Decrease Tile Height" */
3321 for (i = 0; i < MAX_TERM_DATA; i++)
3323 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3324 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3326 if (data[i].visible)
3328 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3329 MF_BYCOMMAND | MF_ENABLED);
3334 /* Menu "Options", disable all */
3335 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3336 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3337 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3338 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3339 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3340 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3341 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
3342 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3343 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
3344 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3346 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3347 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3350 /* Menu "Options", Item "Map" */
3351 if (use_graphics != GRAPHICS_NONE)
3352 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
3354 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
3355 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3357 /* Menu "Options", update all */
3358 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3359 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
3360 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3361 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
3362 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3363 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
3364 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
3365 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
3366 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
3367 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
3368 CheckMenuItem(hm, IDM_OPTIONS_BG,
3369 (use_bg ? MF_CHECKED : MF_UNCHECKED));
3371 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
3372 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
3376 /* Menu "Options", Item "Graphics" */
3377 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
3378 /* Menu "Options", Item "Graphics" */
3379 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
3380 /* Menu "Options", Item "Graphics" */
3381 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
3382 /* Menu "Options", Item "Graphics" */
3383 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
3384 #endif /* USE_GRAPHICS */
3387 /* Menu "Options", Item "Sound" */
3388 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
3389 #endif /* USE_SOUND */
3392 /* Menu "Options", Item "ScreenSaver" */
3393 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3394 MF_BYCOMMAND | MF_ENABLED);
3395 #endif /* USE_SAVER */
3400 * Check for double clicked (or dragged) savefile
3402 * Apparently, Windows copies the entire filename into the first
3403 * piece of the "command line string". Perhaps we should extract
3404 * the "basename" of that filename and append it to the "save" dir.
3406 static void check_for_save_file(LPSTR cmd_line)
3416 /* Extract filename */
3417 strcat(savefile, s);
3419 /* Validate the file */
3420 validate_file(savefile);
3422 /* Game in progress */
3423 game_in_progress = TRUE;
3431 * Process a menu command
3433 static void process_menus(WORD wCmd)
3450 plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
3452 plog("You cannot do that yet...");
3456 else if (game_in_progress)
3459 plog("¥×¥ì¥¤Ãæ¤Ï¿·¤·¤¤¥²¡¼¥à¤ò»Ï¤á¤ë¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
3461 plog("You can't start a new game while you're still playing!");
3467 game_in_progress = TRUE;
3481 plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
3483 plog("You cannot do that yet...");
3487 else if (game_in_progress)
3490 plog("¥×¥ì¥¤Ãæ¤Ï¥²¡¼¥à¤ò¥í¡¼¥É¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
3492 plog("You can't open a new game while you're still playing!");
3498 memset(&ofn, 0, sizeof(ofn));
3499 ofn.lStructSize = sizeof(ofn);
3500 ofn.hwndOwner = data[0].w;
3501 ofn.lpstrFilter = "Save Files (*.)\0*\0";
3502 ofn.nFilterIndex = 1;
3503 ofn.lpstrFile = savefile;
3504 ofn.nMaxFile = 1024;
3505 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
3506 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
3508 if (GetOpenFileName(&ofn))
3510 /* Load 'savefile' */
3511 validate_file(savefile);
3512 game_in_progress = TRUE;
3524 if (game_in_progress && character_generated)
3530 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3532 plog("You may not do that right now.");
3538 /* Hack -- Forget messages */
3543 do_cmd_save_game(FALSE);
3544 #else /* ZANGBAND */
3546 #endif /* ZANGBAND */
3551 plog("º£¡¢¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3553 plog("You may not do that right now.");
3563 if (game_in_progress && character_generated)
3569 plog("º£¤Ï½ªÎ»¤Ç¤¤Þ¤»¤ó¡£");
3571 plog("You may not do that right now.");
3577 /* Hack -- Forget messages */
3586 /* do_cmd_save_game(FALSE); */
3587 #else /* ZANGBAND */
3588 /* do_cmd_save_game(); */
3589 #endif /* ZANGBAND */
3590 Term_key_push(SPECIAL_KEY_QUIT);
3598 case IDM_FILE_SCORE:
3602 /* Build the filename */
3603 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
3605 /* Open the binary high score file, for reading */
3606 highscore_fd = fd_open(buf, O_RDONLY);
3608 /* Paranoia -- No score file */
3609 if (highscore_fd < 0)
3611 msg_print("Score file unavailable.");
3621 /* Display the scores */
3622 display_scores_aux(0, MAX_HISCORES, -1, NULL);
3624 /* Shut the high score file */
3625 (void)fd_close(highscore_fd);
3627 /* Forget the high score fd */
3633 /* Hack - Flush it */
3641 case IDM_WINDOW_VIS_0:
3644 plog("¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤ÏÈóɽ¼¨¤Ë¤Ç¤¤Þ¤»¤ó¡ª");
3646 plog("You are not allowed to do that!");
3653 /* Window visibility */
3654 case IDM_WINDOW_VIS_1:
3655 case IDM_WINDOW_VIS_2:
3656 case IDM_WINDOW_VIS_3:
3657 case IDM_WINDOW_VIS_4:
3658 case IDM_WINDOW_VIS_5:
3659 case IDM_WINDOW_VIS_6:
3660 case IDM_WINDOW_VIS_7:
3662 i = wCmd - IDM_WINDOW_VIS_0;
3664 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3671 ShowWindow(td->w, SW_SHOW);
3672 term_data_redraw(td);
3676 td->visible = FALSE;
3678 ShowWindow(td->w, SW_HIDE);
3685 case IDM_WINDOW_FONT_0:
3686 case IDM_WINDOW_FONT_1:
3687 case IDM_WINDOW_FONT_2:
3688 case IDM_WINDOW_FONT_3:
3689 case IDM_WINDOW_FONT_4:
3690 case IDM_WINDOW_FONT_5:
3691 case IDM_WINDOW_FONT_6:
3692 case IDM_WINDOW_FONT_7:
3694 i = wCmd - IDM_WINDOW_FONT_0;
3696 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3700 term_change_font(td);
3705 /* Window Z Position */
3706 case IDM_WINDOW_POS_1:
3707 case IDM_WINDOW_POS_2:
3708 case IDM_WINDOW_POS_3:
3709 case IDM_WINDOW_POS_4:
3710 case IDM_WINDOW_POS_5:
3711 case IDM_WINDOW_POS_6:
3712 case IDM_WINDOW_POS_7:
3714 i = wCmd - IDM_WINDOW_POS_0;
3716 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3720 if (!td->posfix && td->visible)
3723 term_window_pos(td, HWND_TOPMOST);
3728 term_window_pos(td, data[0].w);
3734 /* Bizarre Display */
3735 case IDM_WINDOW_BIZ_0:
3736 case IDM_WINDOW_BIZ_1:
3737 case IDM_WINDOW_BIZ_2:
3738 case IDM_WINDOW_BIZ_3:
3739 case IDM_WINDOW_BIZ_4:
3740 case IDM_WINDOW_BIZ_5:
3741 case IDM_WINDOW_BIZ_6:
3742 case IDM_WINDOW_BIZ_7:
3744 i = wCmd - IDM_WINDOW_BIZ_0;
3746 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3750 td->bizarre = !td->bizarre;
3754 term_window_resize(td);
3759 /* Increase Tile Width */
3760 case IDM_WINDOW_I_WID_0:
3761 case IDM_WINDOW_I_WID_1:
3762 case IDM_WINDOW_I_WID_2:
3763 case IDM_WINDOW_I_WID_3:
3764 case IDM_WINDOW_I_WID_4:
3765 case IDM_WINDOW_I_WID_5:
3766 case IDM_WINDOW_I_WID_6:
3767 case IDM_WINDOW_I_WID_7:
3769 i = wCmd - IDM_WINDOW_I_WID_0;
3771 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3779 term_window_resize(td);
3784 /* Decrease Tile Height */
3785 case IDM_WINDOW_D_WID_0:
3786 case IDM_WINDOW_D_WID_1:
3787 case IDM_WINDOW_D_WID_2:
3788 case IDM_WINDOW_D_WID_3:
3789 case IDM_WINDOW_D_WID_4:
3790 case IDM_WINDOW_D_WID_5:
3791 case IDM_WINDOW_D_WID_6:
3792 case IDM_WINDOW_D_WID_7:
3794 i = wCmd - IDM_WINDOW_D_WID_0;
3796 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3804 term_window_resize(td);
3809 /* Increase Tile Height */
3810 case IDM_WINDOW_I_HGT_0:
3811 case IDM_WINDOW_I_HGT_1:
3812 case IDM_WINDOW_I_HGT_2:
3813 case IDM_WINDOW_I_HGT_3:
3814 case IDM_WINDOW_I_HGT_4:
3815 case IDM_WINDOW_I_HGT_5:
3816 case IDM_WINDOW_I_HGT_6:
3817 case IDM_WINDOW_I_HGT_7:
3819 i = wCmd - IDM_WINDOW_I_HGT_0;
3821 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3829 term_window_resize(td);
3834 /* Decrease Tile Height */
3835 case IDM_WINDOW_D_HGT_0:
3836 case IDM_WINDOW_D_HGT_1:
3837 case IDM_WINDOW_D_HGT_2:
3838 case IDM_WINDOW_D_HGT_3:
3839 case IDM_WINDOW_D_HGT_4:
3840 case IDM_WINDOW_D_HGT_5:
3841 case IDM_WINDOW_D_HGT_6:
3842 case IDM_WINDOW_D_HGT_7:
3844 i = wCmd - IDM_WINDOW_D_HGT_0;
3846 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3854 term_window_resize(td);
3859 case IDM_OPTIONS_NO_GRAPHICS:
3864 plog("You may not do that right now.");
3868 /* Toggle "arg_graphics" */
3869 if (arg_graphics != GRAPHICS_NONE)
3871 arg_graphics = GRAPHICS_NONE;
3873 /* React to changes */
3874 Term_xtra_win_react();
3876 /* Hack -- Force redraw */
3877 Term_key_push(KTRL('R'));
3883 case IDM_OPTIONS_OLD_GRAPHICS:
3888 plog("You may not do that right now.");
3892 /* Toggle "arg_graphics" */
3893 if (arg_graphics != GRAPHICS_ORIGINAL)
3895 arg_graphics = GRAPHICS_ORIGINAL;
3897 /* React to changes */
3898 Term_xtra_win_react();
3900 /* Hack -- Force redraw */
3901 Term_key_push(KTRL('R'));
3907 case IDM_OPTIONS_NEW_GRAPHICS:
3912 plog("You may not do that right now.");
3916 /* Toggle "arg_graphics" */
3917 if (arg_graphics != GRAPHICS_ADAM_BOLT)
3919 arg_graphics = GRAPHICS_ADAM_BOLT;
3921 /* React to changes */
3922 Term_xtra_win_react();
3924 /* Hack -- Force redraw */
3925 Term_key_push(KTRL('R'));
3931 case IDM_OPTIONS_BIGTILE:
3933 term_data *td = &data[0];
3938 plog("You may not do that right now.");
3942 /* Toggle "arg_sound" */
3943 arg_bigtile = !arg_bigtile;
3946 Term_activate(&td->t);
3948 /* Resize the term */
3949 Term_resize(td->cols, td->rows);
3952 InvalidateRect(td->w, NULL, TRUE);
3957 case IDM_OPTIONS_SOUND:
3962 plog("You may not do that right now.");
3966 /* Toggle "arg_sound" */
3967 arg_sound = !arg_sound;
3969 /* React to changes */
3970 Term_xtra_win_react();
3972 /* Hack -- Force redraw */
3973 Term_key_push(KTRL('R'));
3979 case IDM_OPTIONS_BG:
3984 plog("You may not do that right now.");
3988 /* Toggle "use_bg" */
3993 /* React to changes */
3994 Term_xtra_win_react();
3996 /* Hack -- Force redraw */
3997 Term_key_push(KTRL('R'));
4003 case IDM_OPTIONS_OPEN_BG:
4008 plog("You may not do that right now.");
4013 memset(&ofn, 0, sizeof(ofn));
4014 ofn.lStructSize = sizeof(ofn);
4015 ofn.hwndOwner = data[0].w;
4016 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
4017 ofn.nFilterIndex = 1;
4018 ofn.lpstrFile = bg_bitmap_file;
4019 ofn.nMaxFile = 1023;
4020 ofn.lpstrInitialDir = NULL;
4022 ofn.lpstrTitle = "ÊÉ»æ¤òÁª¤ó¤Ç¤Í¡£";
4024 ofn.lpstrTitle = "Choose wall paper.";
4026 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
4028 if (GetOpenFileName(&ofn))
4030 /* Load 'savefile' */
4035 /* React to changes */
4036 Term_xtra_win_react();
4038 /* Hack -- Force redraw */
4039 Term_key_push(KTRL('R'));
4044 case IDM_DUMP_SCREEN_HTML:
4046 static char buf[1024] = "";
4047 memset(&ofn, 0, sizeof(ofn));
4048 ofn.lStructSize = sizeof(ofn);
4049 ofn.hwndOwner = data[0].w;
4050 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
4051 ofn.nFilterIndex = 1;
4052 ofn.lpstrFile = buf;
4053 ofn.nMaxFile = 1023;
4054 ofn.lpstrDefExt = "html";
4055 ofn.lpstrInitialDir = NULL;
4057 ofn.lpstrTitle = "HTML¤Ç¥¹¥¯¥ê¡¼¥ó¥À¥ó¥×¤òÊݸ";
4059 ofn.lpstrTitle = "Save screen dump as HTML.";
4061 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
4063 if (GetSaveFileName(&ofn))
4065 do_cmd_save_screen_html_aux(buf, 0);
4072 case IDM_OPTIONS_SAVER:
4076 DestroyWindow(hwndSaver);
4081 /* Create a screen scaver window */
4082 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
4083 "Angband Screensaver",
4084 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
4085 0, 0, GetSystemMetrics(SM_CXSCREEN),
4086 GetSystemMetrics(SM_CYSCREEN),
4087 NULL, NULL, hInstance, NULL);
4091 /* Push the window to the bottom XXX XXX XXX */
4092 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
4097 plog("¥¦¥£¥ó¥É¥¦¤òºîÀ®½ÐÍè¤Þ¤»¤ó");
4099 plog("Failed to create saver window");
4109 case IDM_OPTIONS_MAP:
4115 case IDM_HELP_CONTENTS:
4119 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
4120 if (check_file(tmp))
4122 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
4127 plog_fmt("¥Ø¥ë¥×¥Õ¥¡¥¤¥ë[%s]¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó¡£", tmp);
4128 plog("Âå¤ï¤ê¤Ë¥ª¥ó¥é¥¤¥ó¥Ø¥ë¥×¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£");
4130 plog_fmt("Cannot find help file: %s", tmp);
4131 plog("Use the online help files instead.");
4136 #else /* HTML_HELP */
4139 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
4140 if (check_file(tmp))
4142 sprintf(buf, "winhelp.exe %s", tmp);
4143 WinExec(buf, SW_NORMAL);
4148 plog_fmt("¥Ø¥ë¥×¥Õ¥¡¥¤¥ë[%s]¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó¡£", tmp);
4149 plog("Âå¤ï¤ê¤Ë¥ª¥ó¥é¥¤¥ó¥Ø¥ë¥×¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£");
4151 plog_fmt("Cannot find help file: %s", tmp);
4152 plog("Use the online help files instead.");
4157 #endif /* HTML_HELP */
4163 static bool process_keydown(WPARAM wParam, LPARAM lParam)
4170 /* Extract the modifiers */
4171 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
4172 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
4173 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
4175 Term_no_press = (ma) ? TRUE : FALSE;
4177 /* Handle "special" keys */
4178 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
4180 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
4181 bool numpad = FALSE;
4183 /* Begin the macro trigger */
4186 /* Send the modifiers */
4187 if (mc) Term_keypress('C');
4188 if (ms) Term_keypress('S');
4189 if (ma) Term_keypress('A');
4191 /* Extract "scan code" */
4192 i = LOBYTE(HIWORD(lParam));
4194 /* Introduce the scan code */
4197 /* Extended key bit */
4200 /* Numpad Enter and '/' are extended key */
4202 Term_no_press = TRUE;
4203 case VK_RETURN: /* Enter */
4206 /* Other extended keys are on full keyboard */
4222 Term_no_press = TRUE;
4226 case VK_PRIOR: /* Page Up */
4227 case VK_NEXT: /* Page Down */
4237 /* Special modifiers for keypad keys */
4238 if (numpad) Term_keypress('K');
4240 /* Encode the hexidecimal scan code */
4241 Term_keypress(hexsym[i/16]);
4242 Term_keypress(hexsym[i%16]);
4244 /* End the macro trigger */
4255 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4256 WPARAM wParam, LPARAM lParam);
4257 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4258 WPARAM wParam, LPARAM lParam)
4259 #else /* __MWERKS__ */
4260 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4261 WPARAM wParam, LPARAM lParam)
4262 #endif /* __MWERKS__ */
4268 MINMAXINFO FAR *lpmmi;
4274 /* Acquire proper "term_data" info */
4275 td = (term_data *)GetWindowLong(hWnd, 0);
4277 /* Handle message */
4283 SetWindowLong(hWnd, 0, (LONG)(my_td));
4293 case WM_GETMINMAXINFO:
4295 MINMAXINFO FAR *lpmmi;
4298 lpmmi = (MINMAXINFO FAR *)lParam;
4300 /* this message was sent before WM_NCCREATE */
4303 /* Minimum window size is 80x24 */
4304 rc.left = rc.top = 0;
4305 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
4306 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4309 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4311 /* Save minimum size */
4312 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4313 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4320 BeginPaint(hWnd, &ps);
4321 if (td) term_data_redraw(td);
4322 EndPaint(hWnd, &ps);
4323 ValidateRect(hWnd, NULL);
4330 if (process_keydown(wParam, lParam))
4337 if (Term_no_press) Term_no_press = FALSE;
4338 else Term_keypress(wParam);
4350 if (game_in_progress && character_generated)
4355 plog("º£¤Ï½ªÎ»¤Ç¤¤Þ¤»¤ó¡£");
4357 plog("You may not do that right now.");
4362 /* Hack -- Forget messages */
4371 /* do_cmd_save_game(FALSE); */
4372 #else /* ZANGBAND */
4373 /* do_cmd_save_game(); */
4374 #endif /* ZANGBAND */
4375 Term_key_push(SPECIAL_KEY_QUIT);
4382 case WM_QUERYENDSESSION:
4384 if (game_in_progress && character_generated)
4386 /* Hack -- Forget messages */
4389 /* Mega-Hack -- Delay death */
4390 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
4393 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
4395 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
4398 /* Hardcode panic save */
4399 p_ptr->panic_save = 1;
4401 /* Forbid suspend */
4402 signals_ignore_tstp();
4404 /* Indicate panic save */
4406 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
4408 (void)strcpy(p_ptr->died_from, "(panic save)");
4412 (void)save_player();
4426 process_menus(LOWORD(wParam));
4432 /* this message was sent before WM_NCCREATE */
4435 /* it was sent from inside CreateWindowEx */
4436 if (!td->w) return 1;
4438 /* was sent from WM_SIZE */
4439 if (td->size_hack) return 1;
4443 case SIZE_MINIMIZED:
4445 /* Hide sub-windows */
4446 for (i = 1; i < MAX_TERM_DATA; i++)
4448 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
4453 case SIZE_MAXIMIZED:
4455 /* fall through XXX XXX XXX */
4460 uint cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4461 uint rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4464 if ((td->cols != cols) || (td->rows != rows))
4466 /* Save the new size */
4470 if (!IsZoomed(td->w) && !IsIconic(td->w))
4472 normsize.x = td->cols;
4473 normsize.y = td->rows;
4477 Term_activate(&td->t);
4479 /* Resize the term */
4480 Term_resize(td->cols, td->rows);
4483 InvalidateRect(td->w, NULL, TRUE);
4486 td->size_hack = TRUE;
4488 /* Show sub-windows */
4489 for (i = 1; i < MAX_TERM_DATA; i++)
4491 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
4494 td->size_hack = FALSE;
4502 case WM_PALETTECHANGED:
4504 /* Ignore if palette change caused by itself */
4505 if ((HWND)wParam == hWnd) return 0;
4507 /* Fall through... */
4510 case WM_QUERYNEWPALETTE:
4512 if (!paletted) return 0;
4516 SelectPalette(hdc, hPal, FALSE);
4518 i = RealizePalette(hdc);
4520 /* if any palette entries changed, repaint the window. */
4521 if (i) InvalidateRect(hWnd, NULL, TRUE);
4523 ReleaseDC(hWnd, hdc);
4530 if (wParam && !HIWORD(lParam))
4532 /* Do something to sub-windows */
4533 for (i = 1; i < MAX_TERM_DATA; i++)
4535 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
4538 /* Focus on main window */
4547 case WM_ACTIVATEAPP:
4549 if (IsIconic(td->w)) break;
4551 for (i = 1; i < MAX_TERM_DATA; i++)
4557 ShowWindow(data[i].w, SW_SHOW);
4561 ShowWindow(data[i].w, SW_HIDE);
4568 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4573 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4574 WPARAM wParam, LPARAM lParam);
4575 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4576 WPARAM wParam, LPARAM lParam)
4577 #else /* __MWERKS__ */
4578 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4579 WPARAM wParam, LPARAM lParam)
4580 #endif /* __MWERKS__ */
4584 MINMAXINFO FAR *lpmmi;
4592 /* Acquire proper "term_data" info */
4593 td = (term_data *)GetWindowLong(hWnd, 0);
4595 /* Process message */
4601 SetWindowLong(hWnd, 0, (LONG)(my_td));
4611 case WM_GETMINMAXINFO:
4613 MINMAXINFO FAR *lpmmi;
4616 lpmmi = (MINMAXINFO FAR *)lParam;
4618 /* this message was sent before WM_NCCREATE */
4621 /* Minimum window size is 80x24 */
4622 rc.left = rc.top = 0;
4623 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
4624 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4627 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4629 /* Save minimum size */
4630 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4631 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4641 /* this message was sent before WM_NCCREATE */
4644 /* it was sent from inside CreateWindowEx */
4645 if (!td->w) return 1;
4647 /* was sent from inside WM_SIZE */
4648 if (td->size_hack) return 1;
4650 td->size_hack = TRUE;
4652 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4653 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4656 if ((td->cols != cols) || (td->rows != rows))
4659 term *old_term = Term;
4661 /* Save the new size */
4666 Term_activate(&td->t);
4668 /* Resize the term */
4669 Term_resize(td->cols, td->rows);
4672 Term_activate(old_term);
4675 InvalidateRect(td->w, NULL, TRUE);
4677 /* HACK - Redraw all windows */
4678 p_ptr->window = 0xFFFFFFFF;
4682 td->size_hack = FALSE;
4689 BeginPaint(hWnd, &ps);
4690 if (td) term_data_redraw(td);
4691 EndPaint(hWnd, &ps);
4698 if (process_keydown(wParam, lParam))
4705 if (Term_no_press) Term_no_press = FALSE;
4706 else Term_keypress(wParam);
4710 case WM_PALETTECHANGED:
4712 /* ignore if palette change caused by itself */
4713 if ((HWND)wParam == hWnd) return FALSE;
4714 /* otherwise, fall through!!! */
4717 case WM_QUERYNEWPALETTE:
4719 if (!paletted) return 0;
4721 SelectPalette(hdc, hPal, FALSE);
4722 i = RealizePalette(hdc);
4723 /* if any palette entries changed, repaint the window. */
4724 if (i) InvalidateRect(hWnd, NULL, TRUE);
4725 ReleaseDC(hWnd, hdc);
4729 case WM_NCLBUTTONDOWN:
4733 if (wParam == HTCLOSE) wParam = HTSYSMENU;
4734 #endif /* HTCLOSE */
4736 if (wParam == HTSYSMENU)
4740 td->visible = FALSE;
4741 ShowWindow(td->w, SW_HIDE);
4751 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4757 #define MOUSE_SENS 40
4760 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4761 WPARAM wParam, LPARAM lParam);
4762 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4763 WPARAM wParam, LPARAM lParam)
4764 #else /* __MWERKS__ */
4765 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4766 WPARAM wParam, LPARAM lParam)
4767 #endif /* __MWERKS__ */
4769 static int iMouse = 0;
4770 static WORD xMouse = 0;
4771 static WORD yMouse = 0;
4794 if (LOWORD(wParam) == WA_INACTIVE) break;
4796 /* else fall through */
4800 case WM_LBUTTONDOWN:
4801 case WM_MBUTTONDOWN:
4802 case WM_RBUTTONDOWN:
4805 SendMessage(hWnd, WM_CLOSE, 0, 0);
4813 dx = LOWORD(lParam) - xMouse;
4814 dy = HIWORD(lParam) - yMouse;
4816 if (dx < 0) dx = -dx;
4817 if (dy < 0) dy = -dy;
4819 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
4821 SendMessage(hWnd, WM_CLOSE, 0, 0);
4825 /* Save last location */
4827 xMouse = LOWORD(lParam);
4828 yMouse = HIWORD(lParam);
4835 DestroyWindow(hwndSaver);
4842 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4845 #endif /* USE_SAVER */
4851 /*** Temporary Hooks ***/
4855 * Display warning message (see "z-util.c")
4857 static void hack_plog(cptr str)
4859 /* Give a warning */
4863 MessageBox(NULL, str, "·Ù¹ð¡ª",
4864 MB_ICONEXCLAMATION | MB_OK);
4866 MessageBox(NULL, str, "Warning",
4867 MB_ICONEXCLAMATION | MB_OK);
4875 * Display error message and quit (see "z-util.c")
4877 static void hack_quit(cptr str)
4879 /* Give a warning */
4883 MessageBox(NULL, str, "¥¨¥é¡¼¡ª",
4884 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
4886 MessageBox(NULL, str, "Error",
4887 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
4892 /* Unregister the classes */
4893 UnregisterClass(AppName, hInstance);
4895 /* Destroy the icon */
4896 if (hIcon) DestroyIcon(hIcon);
4904 /*** Various hooks ***/
4908 * Display warning message (see "z-util.c")
4910 static void hook_plog(cptr str)
4916 MessageBox(data[0].w, str, "·Ù¹ð¡ª",
4917 MB_ICONEXCLAMATION | MB_OK);
4919 MessageBox(data[0].w, str, "Warning",
4920 MB_ICONEXCLAMATION | MB_OK);
4928 * Display error message and quit (see "z-util.c")
4930 static void hook_quit(cptr str)
4935 /* Give a warning */
4939 MessageBox(data[0].w, str, "¥¨¥é¡¼¡ª",
4940 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
4942 MessageBox(data[0].w, str, "Error",
4943 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
4949 /* Save the preferences */
4953 /*** Could use 'Term_nuke_win()' XXX XXX XXX */
4955 /* Destroy all windows */
4956 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
4958 term_force_font(&data[i], NULL);
4959 if (data[i].font_want) string_free(data[i].font_want);
4960 if (data[i].w) DestroyWindow(data[i].w);
4964 /* Free the bitmap stuff */
4966 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
4967 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
4969 if (infMask.hPalette) DeleteObject(infMask.hPalette);
4970 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
4972 #endif /* USE_GRAPHICS */
4974 /*** Free some other stuff ***/
4976 DeleteObject(hbrYellow);
4981 if (hPal) DeleteObject(hPal);
4983 UnregisterClass(AppName, hInstance);
4985 if (hIcon) DestroyIcon(hIcon);
4992 /*** Initialize ***/
4998 static void init_stuff(void)
5005 /* Get program name with full path */
5006 GetModuleFileName(hInstance, path, 512);
5008 /* Save the "program name" XXX XXX XXX */
5011 /* Get the name of the "*.ini" file */
5012 strcpy(path + strlen(path) - 4, ".INI");
5014 /* Save the the name of the ini-file */
5015 ini_file = string_make(path);
5017 /* Analyze the path */
5023 if (path[i] == '\\')
5030 /* Add "lib" to the path */
5031 strcpy(path + i + 1, "lib\\");
5033 /* Validate the path */
5034 validate_dir(path, TRUE);
5036 /* Init the file paths */
5037 init_file_paths(path);
5039 /* Hack -- Validate the paths */
5040 validate_dir(ANGBAND_DIR_APEX, FALSE);
5041 validate_dir(ANGBAND_DIR_BONE, FALSE);
5043 /* Allow missing 'edit' directory */
5044 if (!check_dir(ANGBAND_DIR_EDIT))
5046 /* Must have 'data'! */
5047 validate_dir(ANGBAND_DIR_DATA, TRUE);
5051 /* Don't need 'data' */
5052 validate_dir(ANGBAND_DIR_DATA, FALSE);
5055 validate_dir(ANGBAND_DIR_FILE, TRUE);
5056 validate_dir(ANGBAND_DIR_HELP, FALSE);
5057 validate_dir(ANGBAND_DIR_INFO, FALSE);
5058 validate_dir(ANGBAND_DIR_PREF, TRUE);
5059 validate_dir(ANGBAND_DIR_SAVE, FALSE);
5060 validate_dir(ANGBAND_DIR_USER, TRUE);
5061 validate_dir(ANGBAND_DIR_XTRA, TRUE);
5063 /* Build the filename */
5065 path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news_j.txt");
5067 path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news.txt");
5071 /* Hack -- Validate the "news.txt" file */
5072 validate_file(path);
5075 #if 0 /* #ifndef JP */
5076 /* Build the "font" path */
5077 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
5079 /* Allocate the path */
5080 ANGBAND_DIR_XTRA_FONT = string_make(path);
5082 /* Validate the "font" directory */
5083 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
5085 /* Build the filename */
5086 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
5088 /* Hack -- Validate the basic font */
5089 validate_file(path);
5095 /* Build the "graf" path */
5096 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
5098 /* Allocate the path */
5099 ANGBAND_DIR_XTRA_GRAF = string_make(path);
5101 /* Validate the "graf" directory */
5102 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
5104 #endif /* USE_GRAPHICS */
5109 /* Build the "sound" path */
5110 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
5112 /* Allocate the path */
5113 ANGBAND_DIR_XTRA_SOUND = string_make(path);
5115 /* Validate the "sound" directory */
5116 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
5118 #endif /* USE_SOUND */
5122 /* Build the "music" path */
5123 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
5125 /* Allocate the path */
5126 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
5128 /* Validate the "music" directory */
5129 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
5131 #endif /* USE_MUSIC */
5133 /* Build the "help" path */
5134 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
5136 /* Allocate the path */
5137 ANGBAND_DIR_XTRA_HELP = string_make(path);
5139 /* Validate the "help" directory */
5140 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
5144 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
5145 LPSTR lpCmdLine, int nCmdShow)
5160 if (hPrevInst == NULL)
5162 wc.style = CS_CLASSDC;
5163 wc.lpfnWndProc = AngbandWndProc;
5165 wc.cbWndExtra = 4; /* one long pointer to term_data */
5166 wc.hInstance = hInst;
5167 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
5168 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
5169 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
5170 wc.lpszMenuName = AppName;
5171 wc.lpszClassName = AppName;
5173 if (!RegisterClass(&wc)) exit(1);
5175 wc.lpfnWndProc = AngbandListProc;
5176 wc.lpszMenuName = NULL;
5177 wc.lpszClassName = AngList;
5179 if (!RegisterClass(&wc)) exit(2);
5183 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
5184 wc.lpfnWndProc = AngbandSaverProc;
5186 wc.lpszMenuName = NULL;
5187 wc.lpszClassName = "WindowsScreenSaverClass";
5189 if (!RegisterClass(&wc)) exit(3);
5195 /* Temporary hooks */
5196 plog_aux = hack_plog;
5197 quit_aux = hack_quit;
5198 core_aux = hack_quit;
5200 /* Prepare the filepaths */
5203 /* Initialize the keypress analyzer */
5204 for (i = 0; special_key_list[i]; ++i)
5206 special_key[special_key_list[i]] = TRUE;
5208 /* Initialize the keypress analyzer */
5209 for (i = 0; ignore_key_list[i]; ++i)
5211 ignore_key[ignore_key_list[i]] = TRUE;
5214 /* Determine if display is 16/256/true color */
5216 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
5217 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
5218 ReleaseDC(NULL, hdc);
5220 /* Initialize the colors */
5221 for (i = 0; i < 256; i++)
5225 /* Extract desired values */
5226 rv = angband_color_table[i][1];
5227 gv = angband_color_table[i][2];
5228 bv = angband_color_table[i][3];
5230 /* Extract the "complex" code */
5231 win_clr[i] = PALETTERGB(rv, gv, bv);
5233 /* Save the "simple" code */
5234 angband_color_table[i][0] = win_pal[i];
5237 /* Prepare the windows */
5243 /* Activate hooks */
5244 plog_aux = hook_plog;
5245 quit_aux = hook_quit;
5246 core_aux = hook_quit;
5248 /* Set the system suffix */
5249 ANGBAND_SYS = "win";
5251 /* Set the keyboard suffix */
5252 if (7 != GetKeyboardType(0))
5253 ANGBAND_KEYBOARD = "0";
5256 /* Japanese keyboard */
5257 switch (GetKeyboardType(1))
5259 case 0x0D01: case 0x0D02:
5260 case 0x0D03: case 0x0D04:
5261 case 0x0D05: case 0x0D06:
5263 ANGBAND_KEYBOARD = "NEC98";
5267 ANGBAND_KEYBOARD = "JAPAN";
5271 /* Catch nasty signals */
5277 /* We are now initialized */
5281 if(lpCmdLine[0] == '-'){
5282 switch(lpCmdLine[1])
5287 if (!lpCmdLine[2]) break;
5288 chuukei_server = TRUE;
5289 if(connect_chuukei_server(&lpCmdLine[2])<0){
5290 msg_print("connect fail");
5293 msg_print("connect");
5301 if (!lpCmdLine[2]) break;
5302 chuukei_client = TRUE;
5303 connect_chuukei_server(&lpCmdLine[2]);
5313 /* Did the user double click on a save file? */
5314 if(!chuukei_server) check_for_save_file(lpCmdLine);
5316 /* Did the user double click on a save file? */
5317 check_for_save_file(lpCmdLine);
5320 /* Prompt the user */
5322 prt("[¥Õ¥¡¥¤¥ë] ¥á¥Ë¥å¡¼¤Î [¿·µ¬] ¤Þ¤¿¤Ï [³«¤¯] ¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£", 23, 8);
5324 prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 17);
5329 /* Process messages forever */
5330 while (GetMessage(&msg, NULL, 0, 0))
5332 TranslateMessage(&msg);
5333 DispatchMessage(&msg);
5344 #endif /* WINDOWS */