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_MOVIE 121
107 #define IDM_FILE_EXIT 130
109 #define IDM_WINDOW_VIS_0 200
110 #define IDM_WINDOW_VIS_1 201
111 #define IDM_WINDOW_VIS_2 202
112 #define IDM_WINDOW_VIS_3 203
113 #define IDM_WINDOW_VIS_4 204
114 #define IDM_WINDOW_VIS_5 205
115 #define IDM_WINDOW_VIS_6 206
116 #define IDM_WINDOW_VIS_7 207
118 #define IDM_WINDOW_FONT_0 210
119 #define IDM_WINDOW_FONT_1 211
120 #define IDM_WINDOW_FONT_2 212
121 #define IDM_WINDOW_FONT_3 213
122 #define IDM_WINDOW_FONT_4 214
123 #define IDM_WINDOW_FONT_5 215
124 #define IDM_WINDOW_FONT_6 216
125 #define IDM_WINDOW_FONT_7 217
127 #define IDM_WINDOW_POS_0 220
128 #define IDM_WINDOW_POS_1 221
129 #define IDM_WINDOW_POS_2 222
130 #define IDM_WINDOW_POS_3 223
131 #define IDM_WINDOW_POS_4 224
132 #define IDM_WINDOW_POS_5 225
133 #define IDM_WINDOW_POS_6 226
134 #define IDM_WINDOW_POS_7 227
136 #define IDM_WINDOW_BIZ_0 230
137 #define IDM_WINDOW_BIZ_1 231
138 #define IDM_WINDOW_BIZ_2 232
139 #define IDM_WINDOW_BIZ_3 233
140 #define IDM_WINDOW_BIZ_4 234
141 #define IDM_WINDOW_BIZ_5 235
142 #define IDM_WINDOW_BIZ_6 236
143 #define IDM_WINDOW_BIZ_7 237
145 #define IDM_WINDOW_I_WID_0 240
146 #define IDM_WINDOW_I_WID_1 241
147 #define IDM_WINDOW_I_WID_2 242
148 #define IDM_WINDOW_I_WID_3 243
149 #define IDM_WINDOW_I_WID_4 244
150 #define IDM_WINDOW_I_WID_5 245
151 #define IDM_WINDOW_I_WID_6 246
152 #define IDM_WINDOW_I_WID_7 247
154 #define IDM_WINDOW_D_WID_0 250
155 #define IDM_WINDOW_D_WID_1 251
156 #define IDM_WINDOW_D_WID_2 252
157 #define IDM_WINDOW_D_WID_3 253
158 #define IDM_WINDOW_D_WID_4 254
159 #define IDM_WINDOW_D_WID_5 255
160 #define IDM_WINDOW_D_WID_6 256
161 #define IDM_WINDOW_D_WID_7 257
163 #define IDM_WINDOW_I_HGT_0 260
164 #define IDM_WINDOW_I_HGT_1 261
165 #define IDM_WINDOW_I_HGT_2 262
166 #define IDM_WINDOW_I_HGT_3 263
167 #define IDM_WINDOW_I_HGT_4 264
168 #define IDM_WINDOW_I_HGT_5 265
169 #define IDM_WINDOW_I_HGT_6 266
170 #define IDM_WINDOW_I_HGT_7 267
172 #define IDM_WINDOW_D_HGT_0 270
173 #define IDM_WINDOW_D_HGT_1 271
174 #define IDM_WINDOW_D_HGT_2 272
175 #define IDM_WINDOW_D_HGT_3 273
176 #define IDM_WINDOW_D_HGT_4 274
177 #define IDM_WINDOW_D_HGT_5 275
178 #define IDM_WINDOW_D_HGT_6 276
179 #define IDM_WINDOW_D_HGT_7 277
181 #define IDM_OPTIONS_NO_GRAPHICS 400
182 #define IDM_OPTIONS_OLD_GRAPHICS 401
183 #define IDM_OPTIONS_NEW_GRAPHICS 402
184 #define IDM_OPTIONS_BIGTILE 409
185 #define IDM_OPTIONS_SOUND 410
186 #define IDM_OPTIONS_SAVER 420
187 #define IDM_OPTIONS_MAP 430
188 #define IDM_OPTIONS_BG 440
189 #define IDM_OPTIONS_OPEN_BG 441
191 #define IDM_DUMP_SCREEN_HTML 450
193 #define IDM_HELP_CONTENTS 901
198 * This may need to be removed for some compilers XXX XXX XXX
205 * Exclude parts of WINDOWS.H that are not needed
207 #define NOCOMM /* Comm driver APIs and definitions */
208 #define NOLOGERROR /* LogError() and related definitions */
209 #define NOPROFILER /* Profiler APIs */
210 #define NOLFILEIO /* _l* file I/O routines */
211 #define NOOPENFILE /* OpenFile and related definitions */
212 #define NORESOURCE /* Resource management */
213 #define NOATOM /* Atom management */
214 #define NOLANGUAGE /* Character test routines */
215 #define NOLSTRING /* lstr* string management routines */
216 #define NODBCS /* Double-byte character set routines */
217 #define NOKEYBOARDINFO /* Keyboard driver routines */
218 #define NOCOLOR /* COLOR_* color values */
219 #define NODRAWTEXT /* DrawText() and related definitions */
220 #define NOSCALABLEFONT /* Truetype scalable font support */
221 #define NOMETAFILE /* Metafile support */
222 #define NOSYSTEMPARAMSINFO /* SystemParametersInfo() and SPI_* definitions */
223 #define NODEFERWINDOWPOS /* DeferWindowPos and related definitions */
224 #define NOKEYSTATES /* MK_* message key state flags */
225 #define NOWH /* SetWindowsHook and related WH_* definitions */
226 #define NOCLIPBOARD /* Clipboard APIs and definitions */
227 #define NOICONS /* IDI_* icon IDs */
228 #define NOMDI /* MDI support */
229 #define NOHELP /* Help support */
231 /* Not defined since it breaks Borland C++ 5.5 */
232 /* #define NOCTLMGR */ /* Control management and controls */
235 * Exclude parts of WINDOWS.H that are not needed (Win32)
237 #define WIN32_LEAN_AND_MEAN
238 #define NONLS /* All NLS defines and routines */
239 #define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
240 #define NOKANJI /* Kanji support stuff. */
241 #define NOMCX /* Modem Configuration Extensions */
244 * Include the "windows" support file
249 * Exclude parts of MMSYSTEM.H that are not needed
251 #define MMNODRV /* Installable driver support */
252 #define MMNOWAVE /* Waveform support */
253 #define MMNOMIDI /* MIDI support */
254 #define MMNOAUX /* Auxiliary audio support */
255 #define MMNOTIMER /* Timer support */
256 #define MMNOJOY /* Joystick support */
257 #define MMNOMCI /* MCI support */
258 #define MMNOMMIO /* Multimedia file I/O support */
259 #define MMNOMMSYSTEM /* General MMSYSTEM functions */
262 * Include some more files. Note: the Cygnus Cygwin compiler
263 * doesn't use mmsystem.h instead it includes the winmm library
264 * which performs a similar function.
266 #include <mmsystem.h>
270 * HTML-Help requires htmlhelp.h and htmlhelp.lib from Microsoft's
271 * HTML Workshop < http://msdn.microsoft.com/workshop/author/htmlhelp/ >.
273 /* #define HTML_HELP */
276 #include <htmlhelp.h>
277 #endif /* HTML_HELP */
280 * Include the support for loading bitmaps
283 # include "readdib.h"
287 * Hack -- Fake declarations from "dos.h" XXX XXX XXX
290 #define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
292 #define FA_LABEL 0x08 /* Volume label */
293 #define FA_DIREC 0x10 /* Directory */
294 unsigned _cdecl _dos_getfileattr(const char *, unsigned *);
298 * Silliness in WIN32 drawing routine
301 # define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL)
305 * Silliness for Windows 95
307 #ifndef WS_EX_TOOLWINDOW
308 # define WS_EX_TOOLWINDOW 0
312 * Foreground color bits (hard-coded by DOS)
314 #define VID_BLACK 0x00
315 #define VID_BLUE 0x01
316 #define VID_GREEN 0x02
317 #define VID_CYAN 0x03
319 #define VID_MAGENTA 0x05
320 #define VID_YELLOW 0x06
321 #define VID_WHITE 0x07
324 * Bright text (hard-coded by DOS)
326 #define VID_BRIGHT 0x08
329 * Background color bits (hard-coded by DOS)
331 #define VUD_BLACK 0x00
332 #define VUD_BLUE 0x10
333 #define VUD_GREEN 0x20
334 #define VUD_CYAN 0x30
336 #define VUD_MAGENTA 0x50
337 #define VUD_YELLOW 0x60
338 #define VUD_WHITE 0x70
341 * Blinking text (hard-coded by DOS)
343 #define VUD_BRIGHT 0x80
349 typedef struct _term_data term_data;
354 * Note the use of "font_want" for the names of the font file requested by
355 * the user, and the use of "font_file" for the currently active font file.
357 * The "font_file" is uppercased, and takes the form "8X13.FON", while
358 * "font_want" can be in almost any form as long as it could be construed
359 * as attempting to represent the name of a font.
374 uint rows; /* int -> uint */
410 #if 1 /* #ifdef JP */
425 * Maximum number of windows XXX XXX XXX
427 #define MAX_TERM_DATA 8
430 * An array of term_data's
432 static term_data data[MAX_TERM_DATA];
435 * Hack -- global "window creation" pointer
437 static term_data *my_td;
440 * Remember normal size of main window when maxmized
445 * was main window maximized on previous playing
447 bool win_maximized = FALSE;
452 bool game_in_progress = FALSE;
455 * note when "open"/"new" become valid
457 bool initialized = FALSE;
460 * screen paletted, i.e. 256 colors
462 bool paletted = FALSE;
465 * 16 colors screen, don't use RGB()
467 bool colors16 = FALSE;
470 * Saved instance handle
472 static HINSTANCE hInstance;
475 * Yellow brush for the cursor
477 static HBRUSH hbrYellow;
487 static HPALETTE hPal;
490 static HBITMAP hBG = NULL;
491 static int use_bg = 0;
492 static char bg_bitmap_file[1024] = "bg.bmp";
497 * The screen saver window
499 static HWND hwndSaver;
501 #endif /* USE_SAVER */
507 * Flag set once "graphics" has been initialized
509 static bool can_use_graphics = FALSE;
514 static DIBINIT infGraph;
517 * The global bitmap mask
519 static DIBINIT infMask;
521 #endif /* USE_GRAPHICS */
527 * Flag set once "sound" has been initialized
529 static bool can_use_sound = FALSE;
534 * An array of sound file names
536 static cptr sound_file[SOUND_MAX][SAMPLE_MAX];
538 #endif /* USE_SOUND */
542 * Full path to ANGBAND.INI
544 static cptr ini_file = NULL;
547 * Name of application
549 static cptr AppName = "ANGBAND";
552 * Name of sub-window type
554 static cptr AngList = "AngList";
559 static cptr ANGBAND_DIR_XTRA_GRAF;
560 static cptr ANGBAND_DIR_XTRA_SOUND;
561 static cptr ANGBAND_DIR_XTRA_HELP;
562 #if 0 /* #ifndef JP */
563 static cptr ANGBAND_DIR_XTRA_FONT;
566 static cptr ANGBAND_DIR_XTRA_MUSIC;
571 * The "complex" color values
573 static COLORREF win_clr[256];
577 * Flag for macro trigger with dump ASCII
579 static bool Term_no_press = FALSE;
584 static bool mouse_down = FALSE;
585 static bool paint_rect = FALSE;
586 static int mousex = 0, mousey = 0;
587 static int oldx, oldy;
591 * The "simple" color values
593 * See "main-ibm.c" for original table information
595 * The entries below are taken from the "color bits" defined above.
597 * Note that many of the choices below suck, but so do crappy monitors.
599 static BYTE win_pal[256] =
601 VID_BLACK, /* Dark */
602 VID_WHITE, /* White */
603 VID_CYAN, /* Slate XXX */
604 VID_RED | VID_BRIGHT, /* Orange XXX */
606 VID_GREEN, /* Green */
608 VID_YELLOW, /* Umber XXX */
609 VID_BLACK | VID_BRIGHT, /* Light Dark */
610 VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
611 VID_MAGENTA, /* Violet XXX */
612 VID_YELLOW | VID_BRIGHT, /* Yellow */
613 VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
614 VID_GREEN | VID_BRIGHT, /* Light Green */
615 VID_BLUE | VID_BRIGHT, /* Light Blue */
616 VID_YELLOW /* Light Umber XXX */
621 * Hack -- define which keys are "special"
623 static bool special_key[256];
624 static bool ignore_key[256];
628 * Hack -- initialization list for "special_key"
630 static byte special_key_list[] = {
631 VK_CLEAR, VK_PAUSE, VK_CAPITAL,
632 VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI,
633 VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE,
634 VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
635 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN,
636 VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT,
637 VK_INSERT, VK_DELETE, VK_HELP, VK_APPS,
638 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
639 VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
640 VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD,
641 VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE,
642 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
643 VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
644 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
645 VK_F19,VK_F20, VK_F21, VK_F22, VK_F23, VK_F24,
646 VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL,
647 VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM,
652 static byte ignore_key_list[] = {
653 VK_ESCAPE, VK_TAB, VK_SPACE,
654 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
655 VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN,
656 VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL,
662 * Hack -- initialization list for "special_key"
664 * We ignore the modifier keys (shift, control, alt, num lock, scroll lock),
665 * and the normal keys (escape, tab, return, letters, numbers, etc), but we
666 * catch the keypad keys (with and without numlock set, including keypad 5),
667 * the function keys (including the "menu" key which maps to F10), and the
668 * "pause" key (between scroll lock and numlock). We also catch a few odd
669 * keys which I do not recognize, but which are listed among keys which we
670 * do catch, so they should be harmless to catch.
672 static byte special_key_list[] =
674 VK_CLEAR, /* 0x0C (KP<5>) */
676 VK_PAUSE, /* 0x13 (pause) */
678 VK_PRIOR, /* 0x21 (KP<9>) */
679 VK_NEXT, /* 0x22 (KP<3>) */
680 VK_END, /* 0x23 (KP<1>) */
681 VK_HOME, /* 0x24 (KP<7>) */
682 VK_LEFT, /* 0x25 (KP<4>) */
683 VK_UP, /* 0x26 (KP<8>) */
684 VK_RIGHT, /* 0x27 (KP<6>) */
685 VK_DOWN, /* 0x28 (KP<2>) */
686 VK_SELECT, /* 0x29 (?????) */
687 VK_PRINT, /* 0x2A (?????) */
688 VK_EXECUTE, /* 0x2B (?????) */
689 VK_SNAPSHOT, /* 0x2C (?????) */
690 VK_INSERT, /* 0x2D (KP<0>) */
691 VK_DELETE, /* 0x2E (KP<.>) */
692 VK_HELP, /* 0x2F (?????) */
694 VK_NUMPAD0, /* 0x60 (KP<0>) */
695 VK_NUMPAD1, /* 0x61 (KP<1>) */
696 VK_NUMPAD2, /* 0x62 (KP<2>) */
697 VK_NUMPAD3, /* 0x63 (KP<3>) */
698 VK_NUMPAD4, /* 0x64 (KP<4>) */
699 VK_NUMPAD5, /* 0x65 (KP<5>) */
700 VK_NUMPAD6, /* 0x66 (KP<6>) */
701 VK_NUMPAD7, /* 0x67 (KP<7>) */
702 VK_NUMPAD8, /* 0x68 (KP<8>) */
703 VK_NUMPAD9, /* 0x69 (KP<9>) */
704 VK_MULTIPLY, /* 0x6A (KP<*>) */
705 VK_ADD, /* 0x6B (KP<+>) */
706 VK_SEPARATOR, /* 0x6C (?????) */
707 VK_SUBTRACT, /* 0x6D (KP<->) */
708 VK_DECIMAL, /* 0x6E (KP<.>) */
709 VK_DIVIDE, /* 0x6F (KP</>) */
740 static void delete_bg(void)
749 static int init_bg(void)
751 char * bmfile = bg_bitmap_file;
754 if (use_bg == 0) return 0;
756 hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
759 plog_fmt("ÊÉ»æÍÑ¥Ó¥Ã¥È¥Þ¥Ã¥× '%s' ¤òÆɤ߹þ¤á¤Þ¤»¤ó¡£", bmfile);
761 plog_fmt("Can't load the bitmap file '%s'.", bmfile);
767 HDC wnddc, dcimage, dcbg;
768 HBITMAP bmimage, bmimage_old, bmbg_old;
774 dcimage = CreateCompatibleDC(wnddc);
775 dcbg = CreateCompatibleDC(wnddc);
777 bmimage = LoadImage(NULL, "bg.bmp", LR_LOADFROMFILE, 0, 0, 0);
778 if (!bmimage) quit("bg.bmp¤¬Æɤߤ³¤á¤Ê¤¤¡ª");
779 bmimage_old = SelectObject(dcimage, bmimage);
781 CreateCompatibleBitmap();
783 ReleaseDC(hwnd, wnddc);
789 static void DrawBG(HDC hdc, RECT *r)
794 int x = r->left, y = r->top;
795 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
801 GetObject(hBG, sizeof(bm), &bm);
802 swid = bm.bmWidth; shgt = bm.bmHeight;
804 hdcSrc = CreateCompatibleDC(hdc);
805 hOld = SelectObject(hdcSrc, hBG);
809 cwid = MIN(swid - sx, r->right - nx);
812 chgt = MIN(shgt - sy, r->bottom - ny);
813 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
815 } while (ny < r->bottom);
818 } while (nx < r->right);
820 SelectObject(hdcSrc, hOld);
826 * Hack -- given a pathname, point at the filename
828 static cptr extract_file_name(cptr s)
832 /* Start at the end */
833 p = s + strlen(s) - 1;
835 /* Back up to divider */
836 while ((p >= s) && (*p != ':') && (*p != '\\')) p--;
838 /* Return file name */
845 * Hack -- given a simple filename, extract the "font size" info
847 * Return a pointer to a static buffer holding the capitalized base name.
849 #if 0 /* #ifndef JP */
850 static char *analyze_font(char *path, int *wp, int *hp)
856 /* Start at the end */
857 p = path + strlen(path) - 1;
859 /* Back up to divider */
860 while ((p >= path) && (*p != ':') && (*p != '\\')) --p;
862 /* Advance to file name */
868 /* Capitalize (be paranoid) */
869 if (islower(*s)) *s = toupper(*s);
873 s = my_strchr(p, 'X');
875 /* Extract font width */
879 hgt = s ? atoi(s+1) : 0;
892 * Check for existance of a file
894 static bool check_file(cptr s)
914 attrib = GetFileAttributes(path);
916 /* Require valid filename */
917 if (attrib == INVALID_FILE_NAME) return (FALSE);
919 /* Prohibit directory */
920 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return (FALSE);
924 /* Examine and verify */
925 if (_dos_getfileattr(path, &attrib)) return (FALSE);
927 /* Prohibit something */
928 if (attrib & FA_LABEL) return (FALSE);
930 /* Prohibit directory */
931 if (attrib & FA_DIREC) return (FALSE);
941 * Check for existance of a directory
943 static bool check_dir(cptr s)
965 /* Remove trailing backslash */
966 if (i && (path[i-1] == '\\')) path[--i] = '\0';
971 attrib = GetFileAttributes(path);
973 /* Require valid filename */
974 if (attrib == INVALID_FILE_NAME) return (FALSE);
976 /* Require directory */
977 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE);
981 /* Examine and verify */
982 if (_dos_getfileattr(path, &attrib)) return (FALSE);
984 /* Prohibit something */
985 if (attrib & FA_LABEL) return (FALSE);
987 /* Require directory */
988 if (!(attrib & FA_DIREC)) return (FALSE);
1000 static void validate_file(cptr s)
1002 /* Verify or fail */
1006 quit_fmt("ɬÍפʥե¡¥¤¥ë[%s]¤¬¸«¤¢¤¿¤ê¤Þ¤»¤ó¡£", s);
1008 quit_fmt("Cannot find required file:\n%s", s);
1016 * Validate a directory
1018 static void validate_dir(cptr s, bool vital)
1020 /* Verify or fail */
1023 /* This directory contains needed data */
1027 quit_fmt("ɬÍפʥǥ£¥ì¥¯¥È¥ê[%s]¤¬¸«¤¢¤¿¤ê¤Þ¤»¤ó¡£", s);
1029 quit_fmt("Cannot find required directory:\n%s", s);
1033 /* Attempt to create this directory */
1036 quit_fmt("Unable to create directory:\n%s", s);
1043 * Get the "size" for a window
1045 static void term_getsize(term_data *td)
1052 if (td->cols < 1) td->cols = 1;
1053 if (td->rows < 1) td->rows = 1;
1056 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
1057 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
1059 /* Fake window size */
1061 rc.right = rc.left + wid;
1063 rc.bottom = rc.top + hgt;
1066 /* rc.right += 1; */
1067 /* rc.bottom += 1; */
1070 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
1073 td->size_wid = rc.right - rc.left;
1074 td->size_hgt = rc.bottom - rc.top;
1076 /* See CreateWindowEx */
1079 /* Extract actual location */
1080 GetWindowRect(td->w, &rc);
1082 /* Save the location */
1083 td->pos_x = rc.left;
1089 * Write the "prefs" for a single term
1091 static void save_prefs_aux(int i)
1093 term_data *td = &data[i];
1098 WINDOWPLACEMENT lpwndpl;
1103 /* Make section name */
1104 sprintf(sec_name, "Term-%d", i);
1109 strcpy(buf, td->visible ? "1" : "0");
1110 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
1115 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "£Í£Ó ¥´¥·¥Ã¥¯");
1118 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
1120 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
1124 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
1126 #if 1 /* #ifdef JP */
1127 wsprintf(buf, "%d", td->lf.lfWidth);
1128 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
1129 wsprintf(buf, "%d", td->lf.lfHeight);
1130 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
1131 wsprintf(buf, "%d", td->lf.lfWeight);
1132 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
1135 strcpy(buf, td->bizarre ? "1" : "0");
1136 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
1139 wsprintf(buf, "%d", td->tile_wid);
1140 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
1143 wsprintf(buf, "%d", td->tile_hgt);
1144 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
1146 /* Get window placement and dimensions */
1147 lpwndpl.length = sizeof(WINDOWPLACEMENT);
1148 GetWindowPlacement(td->w, &lpwndpl);
1150 /* Acquire position in *normal* mode (not minimized) */
1151 rc = lpwndpl.rcNormalPosition;
1153 /* Window size (x) */
1154 if (i == 0) wsprintf(buf, "%d", normsize.x);
1155 else wsprintf(buf, "%d", td->cols);
1156 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
1158 /* Window size (y) */
1159 if (i == 0) wsprintf(buf, "%d", normsize.y);
1160 else wsprintf(buf, "%d", td->rows);
1161 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
1163 /* Maxmized (only main window) */
1166 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
1167 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
1170 /* Acquire position */
1171 GetWindowRect(td->w, &rc);
1173 /* Window position (x) */
1174 wsprintf(buf, "%d", rc.left);
1175 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
1177 /* Window position (y) */
1178 wsprintf(buf, "%d", rc.top);
1179 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
1181 /* Window Z position */
1184 strcpy(buf, td->posfix ? "1" : "0");
1185 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
1193 * We assume that the windows have all been initialized
1195 static void save_prefs(void)
1201 /* Save the "arg_graphics" flag */
1202 sprintf(buf, "%d", arg_graphics);
1203 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
1205 /* Save the "arg_bigtile" flag */
1206 strcpy(buf, arg_bigtile ? "1" : "0");
1207 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
1209 /* Save the "arg_sound" flag */
1210 strcpy(buf, arg_sound ? "1" : "0");
1211 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
1214 strcpy(buf, use_bg ? "1" : "0");
1215 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
1216 WritePrivateProfileString("Angband", "BackGroundBitmap",
1217 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
1219 /* Save window prefs */
1220 for (i = 0; i < MAX_TERM_DATA; ++i)
1228 * Load the "prefs" for a single term
1230 static void load_prefs_aux(int i)
1232 term_data *td = &data[i];
1238 /* Make section name */
1239 sprintf(sec_name, "Term-%d", i);
1241 /* Make section name */
1242 sprintf(sec_name, "Term-%d", i);
1247 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
1250 /* Desired font, with default */
1252 GetPrivateProfileString(sec_name, "Font", "£Í£Ó ¥´¥·¥Ã¥¯", tmp, 127, ini_file);
1255 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
1257 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
1263 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
1265 /* Analyze font, save desired font name */
1266 #if 1 /* #ifdef JP */
1267 td->font_want = string_make(tmp);
1269 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
1270 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
1271 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
1273 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
1278 #if 1 /* #ifdef JP */
1279 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
1280 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
1282 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
1283 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
1288 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
1289 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
1290 normsize.x = td->cols; normsize.y = td->rows;
1295 win_maximized = GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file);
1298 /* Window position */
1299 td->pos_x = GetPrivateProfileInt(sec_name, "PositionX", td->pos_x, ini_file);
1300 td->pos_y = GetPrivateProfileInt(sec_name, "PositionY", td->pos_y, ini_file);
1302 /* Window Z position */
1305 td->posfix = GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file);
1313 static void load_prefs(void)
1317 /* Extract the "arg_graphics" flag */
1318 arg_graphics = GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
1320 /* Extract the "arg_bigtile" flag */
1321 arg_bigtile = GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file);
1322 use_bigtile = arg_bigtile;
1324 /* Extract the "arg_sound" flag */
1325 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
1328 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
1329 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
1331 /* Load window prefs */
1332 for (i = 0; i < MAX_TERM_DATA; ++i)
1341 * XXX XXX XXX - Taken from files.c.
1343 * Extract "tokens" from a buffer
1345 * This function uses "whitespace" as delimiters, and treats any amount of
1346 * whitespace as a single delimiter. We will never return any empty tokens.
1347 * When given an empty buffer, or a buffer containing only "whitespace", we
1348 * will return no tokens. We will never extract more than "num" tokens.
1350 * By running a token through the "text_to_ascii()" function, you can allow
1351 * that token to include (encoded) whitespace, using "\s" to encode spaces.
1353 * We save pointers to the tokens in "tokens", and return the number found.
1355 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
1367 /* Skip leading whitespace */
1368 for ( ; *s && isspace(*s); ++s) /* loop */;
1373 /* Find next whitespace, if any */
1374 for (t = s; *t && !isspace(*t); ++t) /* loop */;
1376 /* Nuke and advance (if necessary) */
1377 if (*t) *t++ = '\0';
1379 /* Save the token */
1390 static void load_sound_prefs(void)
1394 char ini_path[1024];
1395 char wav_path[1024];
1396 char *zz[SAMPLE_MAX];
1398 /* Access the sound.cfg */
1399 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
1401 for (i = 0; i < SOUND_MAX; i++)
1403 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
1405 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
1407 for (j = 0; j < num; j++)
1409 /* Access the sound */
1410 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
1412 /* Save the sound filename, if it exists */
1413 if (check_file(wav_path))
1414 sound_file[i][j] = string_make(zz[j]);
1419 #endif /* USE_SOUND */
1422 * Create the new global palette based on the bitmap palette
1423 * (if any), and the standard 16 entry palette derived from
1424 * "win_clr[]" which is used for the basic 16 Angband colors.
1426 * This function is never called before all windows are ready.
1428 * This function returns FALSE if the new palette could not be
1429 * prepared, which should normally be a fatal error. XXX XXX
1431 * Note that only some machines actually use a "palette".
1433 static int new_palette(void)
1441 LPLOGPALETTE pLogPal;
1442 LPPALETTEENTRY lppe;
1447 /* This makes no sense */
1448 if (!paletted) return (TRUE);
1458 /* Check the bitmap palette */
1459 hBmPal = infGraph.hPalette;
1461 /* Use the bitmap */
1464 lppeSize = 256 * sizeof(PALETTEENTRY);
1465 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
1466 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
1467 if ((nEntries == 0) || (nEntries > 220))
1471 plog("²èÌ̤ò16¥Ó¥Ã¥È¤«24¥Ó¥Ã¥È¥«¥é¡¼¥â¡¼¥É¤Ë¤·¤Æ²¼¤µ¤¤¡£");
1473 plog("Please switch to high- or true-color mode.");
1478 rnfree(lppe, lppeSize);
1485 #endif /* USE_GRAPHICS */
1487 /* Size of palette */
1488 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
1490 /* Allocate palette */
1491 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
1494 pLogPal->palVersion = 0x300;
1496 /* Make room for bitmap and normal data */
1497 pLogPal->palNumEntries = nEntries + 16;
1499 /* Save the bitmap data */
1500 for (i = 0; i < nEntries; i++)
1502 pLogPal->palPalEntry[i] = lppe[i];
1505 /* Save the normal data */
1506 for (i = 0; i < 16; i++)
1510 /* Access the entry */
1511 p = &(pLogPal->palPalEntry[i+nEntries]);
1513 /* Save the colors */
1514 p->peRed = GetRValue(win_clr[i]);
1515 p->peGreen = GetGValue(win_clr[i]);
1516 p->peBlue = GetBValue(win_clr[i]);
1518 /* Save the flags */
1519 p->peFlags = PC_NOCOLLAPSE;
1522 /* Free something */
1523 if (lppe) rnfree(lppe, lppeSize);
1525 /* Create a new palette, or fail */
1526 hNewPal = CreatePalette(pLogPal);
1528 if (!hNewPal) quit("¥Ñ¥ì¥Ã¥È¤òºîÀ®¤Ç¤¤Þ¤»¤ó¡ª");
1530 if (!hNewPal) quit("Cannot create palette!");
1534 /* Free the palette */
1535 rnfree(pLogPal, pLogPalSize);
1540 /* Realize the palette */
1542 SelectPalette(hdc, hNewPal, 0);
1543 i = RealizePalette(hdc);
1544 ReleaseDC(td->w, hdc);
1546 if (i == 0) quit("¥Ñ¥ì¥Ã¥È¤ò¥·¥¹¥Æ¥à¥¨¥ó¥È¥ê¤Ë¥Þ¥Ã¥×¤Ç¤¤Þ¤»¤ó¡ª");
1548 if (i == 0) quit("Cannot realize palette!");
1553 for (i = 1; i < MAX_TERM_DATA; i++)
1558 SelectPalette(hdc, hNewPal, 0);
1559 ReleaseDC(td->w, hdc);
1562 /* Delete old palette */
1563 if (hPal) DeleteObject(hPal);
1565 /* Save new palette */
1575 * Initialize graphics
1577 static bool init_graphics(void)
1579 /* Initialize once */
1580 /* if (can_use_graphics != arg_graphics) */
1586 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1593 ANGBAND_GRAF = "new";
1601 ANGBAND_GRAF = "old";
1604 /* Access the bitmap file */
1605 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
1607 /* Load the bitmap or quit */
1608 if (!ReadDIB(data[0].w, buf, &infGraph))
1611 plog_fmt("¥Ó¥Ã¥È¥Þ¥Ã¥× '%s' ¤òÆɤ߹þ¤á¤Þ¤»¤ó¡£", name);
1613 plog_fmt("Cannot read bitmap file '%s'", name);
1619 /* Save the new sizes */
1620 infGraph.CellWidth = wid;
1621 infGraph.CellHeight = hgt;
1623 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1625 /* Access the mask file */
1626 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
1628 /* Load the bitmap or quit */
1629 if (!ReadDIB(data[0].w, buf, &infMask))
1631 plog_fmt("Cannot read bitmap file '%s'", buf);
1636 /* Activate a palette */
1639 /* Free bitmap XXX XXX XXX */
1643 plog("¥Ñ¥ì¥Ã¥È¤ò¼Â¸½¤Ç¤¤Þ¤»¤ó¡ª");
1645 plog("Cannot activate palette!");
1651 /* Graphics available */
1652 can_use_graphics = arg_graphics;
1656 return (can_use_graphics);
1658 #endif /* USE_GRAPHICS */
1665 static bool init_sound(void)
1667 /* Initialize once */
1670 /* Load the prefs */
1673 /* Sound available */
1674 can_use_sound = TRUE;
1678 return (can_use_sound);
1680 #endif /* USE_SOUND */
1686 static void term_window_resize(term_data *td)
1688 /* Require window */
1691 /* Resize the window */
1692 SetWindowPos(td->w, 0, 0, 0,
1693 td->size_wid, td->size_hgt,
1694 SWP_NOMOVE | SWP_NOZORDER);
1697 InvalidateRect(td->w, NULL, TRUE);
1702 * Force the use of a new "font file" for a term_data
1704 * This function may be called before the "window" is ready
1706 * This function returns zero only if everything succeeds.
1708 * Note that the "font name" must be capitalized!!!
1710 static errr term_force_font(term_data *td, cptr path)
1714 #if 0 /* #ifndef JP */
1720 /* Forget the old font (if needed) */
1721 if (td->font_id) DeleteObject(td->font_id);
1723 #if 1 /* #ifdef JP */
1727 /* Create the font (using the 'base' of the font file name!) */
1728 td->font_id = CreateFontIndirect(&(td->lf));
1729 wid = td->lf.lfWidth;
1730 hgt = td->lf.lfHeight;
1731 if (!td->font_id) return (1);
1733 /* Forget old font */
1739 for (i = 0; i < MAX_TERM_DATA; i++)
1741 /* Don't check when closing the application */
1744 /* Check "screen" */
1745 if ((td != &data[i]) &&
1746 (data[i].font_file) &&
1747 (streq(data[i].font_file, td->font_file)))
1753 /* Remove unused font resources */
1754 if (!used) RemoveFontResource(td->font_file);
1756 /* Free the old name */
1757 string_free(td->font_file);
1760 td->font_file = NULL;
1764 if (!path) return (1);
1769 /* Analyze font path */
1770 base = analyze_font(buf, &wid, &hgt);
1773 if (!suffix(base, ".FON")) return (1);
1776 if (!check_file(buf)) return (1);
1778 /* Load the new font */
1779 if (!AddFontResource(buf)) return (1);
1781 /* Save new font name */
1782 td->font_file = string_make(base);
1784 /* Remove the "suffix" */
1785 base[strlen(base)-4] = '\0';
1787 /* Create the font (using the 'base' of the font file name!) */
1788 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
1789 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
1790 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
1791 FIXED_PITCH | FF_DONTCARE, base);
1794 /* Hack -- Unknown size */
1801 /* all this trouble to get the cell size */
1802 hdcDesktop = GetDC(HWND_DESKTOP);
1803 hfOld = SelectObject(hdcDesktop, td->font_id);
1804 GetTextMetrics(hdcDesktop, &tm);
1805 SelectObject(hdcDesktop, hfOld);
1806 ReleaseDC(HWND_DESKTOP, hdcDesktop);
1808 /* Font size info */
1809 wid = tm.tmAveCharWidth;
1813 /* Save the size info */
1824 * Allow the user to change the font for this window.
1826 static void term_change_font(term_data *td)
1828 #if 1 /* #ifdef JP */
1831 memset(&cf, 0, sizeof(cf));
1832 cf.lStructSize = sizeof(cf);
1833 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
1834 cf.lpLogFont = &(td->lf);
1836 if (ChooseFont(&cf))
1838 /* Force the font */
1839 term_force_font(td, NULL);
1841 /* Assume not bizarre */
1844 /* Reset the tile info */
1845 td->tile_wid = td->font_wid;
1846 td->tile_hgt = td->font_hgt;
1848 /* Analyze the font */
1851 /* Resize the window */
1852 term_window_resize(td);
1858 char tmp[1024] = "";
1860 /* Extract a default if possible */
1861 if (td->font_file) strcpy(tmp, td->font_file);
1863 /* Ask for a choice */
1864 memset(&ofn, 0, sizeof(ofn));
1865 ofn.lStructSize = sizeof(ofn);
1866 ofn.hwndOwner = data[0].w;
1867 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
1868 ofn.nFilterIndex = 1;
1869 ofn.lpstrFile = tmp;
1871 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
1872 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
1873 ofn.lpstrDefExt = "fon";
1875 /* Force choice if legal */
1876 if (GetOpenFileName(&ofn))
1878 /* Force the font */
1879 if (term_force_font(td, tmp))
1881 /* Access the standard font file */
1882 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
1884 /* Force the use of that font */
1885 (void)term_force_font(td, tmp);
1888 /* Assume not bizarre */
1889 td->bizarre = FALSE;
1891 /* Reset the tile info */
1892 td->tile_wid = td->font_wid;
1893 td->tile_hgt = td->font_hgt;
1895 /* Analyze the font */
1898 /* Resize the window */
1899 term_window_resize(td);
1906 * Allow the user to lock this window.
1908 static void term_window_pos(term_data *td, HWND hWnd)
1910 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
1911 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1914 static void windows_map(void);
1917 * Hack -- redraw a term_data
1919 static void term_data_redraw(term_data *td)
1923 /* Redraw the map */
1928 /* Activate the term */
1929 Term_activate(&td->t);
1931 /* Redraw the contents */
1934 /* Restore the term */
1935 Term_activate(term_screen);
1940 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
1944 HBRUSH myBrush, oldBrush;
1946 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
1947 int tx = td->size_ow1 + x * td->tile_wid;
1948 int ty = td->size_oh1 + y * td->tile_hgt;
1949 int tw = w * td->tile_wid - 1;
1950 int th = h * td->tile_hgt - 1;
1953 myBrush = CreateSolidBrush(RGB(255, 255, 255));
1954 oldBrush = SelectObject(hdc, myBrush);
1955 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
1957 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
1959 SelectObject(hdc, oldBrush);
1960 SelectObject(hdc, oldPen);
1965 /*** Function hooks needed by "Term" ***/
1971 * Initialize a new Term
1973 static void Term_init_win(term *t)
1982 static void Term_nuke_win(term *t)
1991 * Interact with the User
1993 static errr Term_user_win(int n)
2004 * React to global changes
2006 static errr Term_xtra_win_react(void)
2014 /* Save the default colors */
2015 for (i = 0; i < 256; i++)
2017 /* Simply accept the desired colors */
2018 win_pal[i] = angband_color_table[i][0];
2029 bool change = FALSE;
2031 /* Save the default colors */
2032 for (i = 0; i < 256; i++)
2034 /* Extract desired values */
2035 rv = angband_color_table[i][1];
2036 gv = angband_color_table[i][2];
2037 bv = angband_color_table[i][3];
2039 /* Extract a full color code */
2040 code = PALETTERGB(rv, gv, bv);
2042 /* Activate changes */
2043 if (win_clr[i] != code)
2045 /* Note the change */
2048 /* Apply the desired color */
2053 /* Activate the palette if needed */
2054 if (change) (void)new_palette();
2060 /* Handle "arg_sound" */
2061 if (use_sound != arg_sound)
2063 /* Initialize (if needed) */
2064 if (arg_sound && !init_sound())
2068 plog("¥µ¥¦¥ó¥É¤ò½é´ü²½¤Ç¤¤Þ¤»¤ó¡ª");
2070 plog("Cannot initialize sound!");
2078 /* Change setting */
2079 use_sound = arg_sound;
2087 /* Handle "arg_graphics" */
2088 if (use_graphics != arg_graphics)
2090 /* Initialize (if needed) */
2091 if (arg_graphics && !init_graphics())
2095 plog("¥°¥é¥Õ¥£¥Ã¥¯¥¹¤ò½é´ü²½¤Ç¤¤Þ¤»¤ó!");
2097 plog("Cannot initialize graphics!");
2102 arg_graphics = GRAPHICS_NONE;
2105 /* Change setting */
2106 use_graphics = arg_graphics;
2109 #ifdef ANGBAND_2_8_1
2111 #else /* ANGBAND_2_8_1 */
2112 reset_visuals(TRUE);
2113 #endif /* ANGBAND_2_8_1 */
2116 #endif /* USE_GRAPHICS */
2119 /* Clean up windows */
2120 for (i = 0; i < MAX_TERM_DATA; i++)
2124 term_data *td = &data[i];
2126 /* Update resized windows */
2127 if ((td->cols != (uint)td->t.wid) || (td->rows != (uint)td->t.hgt))
2130 Term_activate(&td->t);
2132 /* Hack -- Resize the term */
2133 Term_resize(td->cols, td->rows);
2135 /* Redraw the contents */
2150 * Process at least one event
2152 static errr Term_xtra_win_event(int v)
2156 /* Wait for an event */
2160 if (GetMessage(&msg, NULL, 0, 0))
2162 TranslateMessage(&msg);
2163 DispatchMessage(&msg);
2167 /* Check for an event */
2171 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2173 TranslateMessage(&msg);
2174 DispatchMessage(&msg);
2184 * Process all pending events
2186 static errr Term_xtra_win_flush(void)
2190 /* Process all pending events */
2191 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2193 TranslateMessage(&msg);
2194 DispatchMessage(&msg);
2203 * Hack -- clear the screen
2205 * Make this more efficient XXX XXX XXX
2207 static errr Term_xtra_win_clear(void)
2209 term_data *td = (term_data*)(Term->data);
2214 /* Rectangle to erase */
2215 rc.left = td->size_ow1;
2216 rc.right = rc.left + td->cols * td->tile_wid;
2217 rc.top = td->size_oh1;
2218 rc.bottom = rc.top + td->rows * td->tile_hgt;
2222 SetBkColor(hdc, RGB(0, 0, 0));
2223 SelectObject(hdc, td->font_id);
2224 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2229 rc.left = 0; rc.top = 0;
2232 ReleaseDC(td->w, hdc);
2240 * Hack -- make a noise
2242 static errr Term_xtra_win_noise(void)
2244 MessageBeep(MB_ICONASTERISK);
2250 * Hack -- make a sound
2252 static errr Term_xtra_win_sound(int v)
2257 #endif /* USE_SOUND */
2259 /* Sound disabled */
2260 if (!use_sound) return (1);
2263 if ((v < 0) || (v >= SOUND_MAX)) return (1);
2267 /* Count the samples */
2268 for (i = 0; i < SAMPLE_MAX; i++)
2270 if (!sound_file[v][i])
2275 if (i == 0) return (1);
2277 /* Build the path */
2278 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_simple(i)]);
2282 /* Play the sound, catch errors */
2283 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
2287 /* Play the sound, catch errors */
2288 return (sndPlaySound(buf, SND_ASYNC));
2292 #else /* USE_SOUND */
2297 #endif /* USE_SOUND */
2302 * Delay for "x" milliseconds
2304 static int Term_xtra_win_delay(int v)
2318 t = GetTickCount() + v;
2321 while (GetTickCount() < t)
2323 /* Handle messages */
2324 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2326 TranslateMessage(&msg);
2327 DispatchMessage(&msg);
2339 * Do a "special thing"
2341 static errr Term_xtra_win(int n, int v)
2343 /* Handle a subset of the legal requests */
2346 /* Make a bell sound */
2347 case TERM_XTRA_NOISE:
2349 return (Term_xtra_win_noise());
2352 /* Make a special sound */
2353 case TERM_XTRA_SOUND:
2355 return (Term_xtra_win_sound(v));
2358 /* Process random events */
2359 case TERM_XTRA_BORED:
2361 return (Term_xtra_win_event(0));
2364 /* Process an event */
2365 case TERM_XTRA_EVENT:
2367 return (Term_xtra_win_event(v));
2370 /* Flush all events */
2371 case TERM_XTRA_FLUSH:
2373 return (Term_xtra_win_flush());
2376 /* Clear the screen */
2377 case TERM_XTRA_CLEAR:
2379 return (Term_xtra_win_clear());
2382 /* React to global changes */
2383 case TERM_XTRA_REACT:
2385 return (Term_xtra_win_react());
2388 /* Delay for some milliseconds */
2389 case TERM_XTRA_DELAY:
2391 return (Term_xtra_win_delay(v));
2402 * Low level graphics (Assumes valid input).
2404 * Draw a "cursor" at (x,y), using a "yellow box".
2406 static errr Term_curs_win(int x, int y)
2408 term_data *td = (term_data*)(Term->data);
2413 int tile_wid, tile_hgt;
2417 tile_wid = td->map_tile_wid;
2418 tile_hgt = td->map_tile_hgt;
2422 tile_wid = td->tile_wid;
2423 tile_hgt = td->tile_hgt;
2426 /* Frame the grid */
2427 rc.left = x * tile_wid + td->size_ow1;
2428 rc.right = rc.left + tile_wid;
2429 rc.top = y * tile_hgt + td->size_oh1;
2430 rc.bottom = rc.top + tile_hgt;
2432 /* Cursor is done as a yellow "box" */
2434 FrameRect(hdc, &rc, hbrYellow);
2435 ReleaseDC(td->w, hdc);
2443 * Low level graphics (Assumes valid input).
2445 * Draw a "big cursor" at (x,y), using a "yellow box".
2447 static errr Term_bigcurs_win(int x, int y)
2449 term_data *td = (term_data*)(Term->data);
2454 int tile_wid, tile_hgt;
2458 /* Normal cursor in map window */
2459 Term_curs_win(x, y);
2464 tile_wid = td->tile_wid;
2465 tile_hgt = td->tile_hgt;
2468 /* Frame the grid */
2469 rc.left = x * tile_wid + td->size_ow1;
2470 rc.right = rc.left + 2 * tile_wid;
2471 rc.top = y * tile_hgt + td->size_oh1;
2472 rc.bottom = rc.top + tile_hgt;
2474 /* Cursor is done as a yellow "box" */
2476 FrameRect(hdc, &rc, hbrYellow);
2477 ReleaseDC(td->w, hdc);
2485 * Low level graphics (Assumes valid input).
2487 * Erase a "block" of "n" characters starting at (x,y).
2489 static errr Term_wipe_win(int x, int y, int n)
2491 term_data *td = (term_data*)(Term->data);
2496 /* Rectangle to erase in client coords */
2497 rc.left = x * td->tile_wid + td->size_ow1;
2498 rc.right = rc.left + n * td->tile_wid;
2499 rc.top = y * td->tile_hgt + td->size_oh1;
2500 rc.bottom = rc.top + td->tile_hgt;
2503 SetBkColor(hdc, RGB(0, 0, 0));
2504 SelectObject(hdc, td->font_id);
2509 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2510 ReleaseDC(td->w, hdc);
2518 * Low level graphics. Assumes valid input.
2520 * Draw several ("n") chars, with an attr, at a given location.
2522 * All "graphic" data is handled by "Term_pict_win()", below.
2524 * One would think there is a more efficient method for telling a window
2525 * what color it should be using to draw with, but perhaps simply changing
2526 * it every time is not too inefficient. XXX XXX XXX
2528 static errr Term_text_win(int x, int y, int n, byte a, const char *s)
2530 term_data *td = (term_data*)(Term->data);
2534 #if 1 /* #ifdef JP */
2535 static HBITMAP WALL;
2536 static HBRUSH myBrush, oldBrush;
2538 static bool init_done = FALSE;
2541 WALL = LoadBitmap(hInstance, AppName);
2542 myBrush = CreatePatternBrush(WALL);
2547 /* Total rectangle */
2548 rc.left = x * td->tile_wid + td->size_ow1;
2549 rc.right = rc.left + n * td->tile_wid;
2550 rc.top = y * td->tile_hgt + td->size_oh1;
2551 rc.bottom = rc.top + td->tile_hgt;
2556 /* Background color */
2557 SetBkColor(hdc, RGB(0, 0, 0));
2559 /* Foreground color */
2562 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
2566 SetTextColor(hdc, win_clr[a&0x0F]);
2570 SetTextColor(hdc, win_clr[a]);
2574 SelectObject(hdc, td->font_id);
2577 if (use_bg) SetBkMode(hdc, TRANSPARENT);
2581 (td->tile_hgt != td->font_hgt) ||
2582 (td->tile_wid != td->font_wid))
2586 /* Erase complete rectangle */
2587 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2590 if (use_bg) DrawBG(hdc, &rc);
2593 rc.left += ((td->tile_wid - td->font_wid) / 2);
2594 rc.right = rc.left + td->font_wid;
2595 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
2596 rc.bottom = rc.top + td->font_hgt;
2598 /* Dump each character */
2599 for (i = 0; i < n; i++)
2602 if (use_bigtile && *(s+i)=="¢£"[0] && *(s+i+1)=="¢£"[1])
2604 rc.right += td->font_wid;
2606 oldBrush = SelectObject(hdc, myBrush);
2607 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2610 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2612 SelectObject(hdc, oldBrush);
2613 SelectObject(hdc, oldPen);
2614 rc.right -= td->font_wid;
2618 rc.left += 2 * td->tile_wid;
2619 rc.right += 2 * td->tile_wid;
2621 else if ( iskanji(*(s+i)) ) /* £²¥Ð¥¤¥Èʸ»ú */
2623 rc.right += td->font_wid;
2625 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2627 rc.right -= td->font_wid;
2631 rc.left += 2 * td->tile_wid;
2632 rc.right += 2 * td->tile_wid;
2633 } else if (*(s+i)==127){
2634 oldBrush = SelectObject(hdc, myBrush);
2635 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2638 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2640 SelectObject(hdc, oldBrush);
2641 SelectObject(hdc, oldPen);
2644 rc.left += td->tile_wid;
2645 rc.right += td->tile_wid;
2648 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
2651 rc.left += td->tile_wid;
2652 rc.right += td->tile_wid;
2657 oldBrush = SelectObject(hdc, myBrush);
2658 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2661 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2663 SelectObject(hdc, oldBrush);
2664 SelectObject(hdc, oldPen);
2667 rc.left += td->tile_wid;
2668 rc.right += td->tile_wid;
2671 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2675 rc.left += td->tile_wid;
2676 rc.right += td->tile_wid;
2680 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
2684 rc.left += td->tile_wid;
2685 rc.right += td->tile_wid;
2696 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
2701 ReleaseDC(td->w, hdc);
2709 * Low level graphics. Assumes valid input.
2711 * Draw an array of "special" attr/char pairs at the given location.
2713 * We use the "Term_pict_win()" function for "graphic" data, which are
2714 * encoded by setting the "high-bits" of both the "attr" and the "char"
2715 * data. We use the "attr" to represent the "row" of the main bitmap,
2716 * and the "char" to represent the "col" of the main bitmap. The use
2717 * of this function is induced by the "higher_pict" flag.
2719 * If "graphics" is not available, we simply "wipe" the given grids.
2721 static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
2723 term_data *td = (term_data*)(Term->data);
2729 int x2, y2, w2, h2, tw2;
2741 /* Erase the grids */
2742 return (Term_wipe_win(x, y, n));
2745 /* Size of bitmap cell */
2746 w1 = infGraph.CellWidth;
2747 h1 = infGraph.CellHeight;
2749 /* Size of window cell */
2752 w2 = td->map_tile_wid;
2753 h2 = td->map_tile_hgt;
2762 if (use_bigtile) tw2 *= 2;
2765 /* Location of window cell */
2766 x2 = x * w2 + td->size_ow1;
2767 y2 = y * h2 + td->size_oh1;
2773 hdcSrc = CreateCompatibleDC(hdc);
2774 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
2776 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2778 hdcMask = CreateCompatibleDC(hdc);
2779 SelectObject(hdcMask, infMask.hBitmap);
2782 /* Draw attr/char pairs */
2783 for (i = 0; i < n; i++, x2 += w2)
2788 /* Extract picture */
2789 int row = (a & 0x7F);
2790 int col = (c & 0x7F);
2792 /* Location of bitmap cell */
2796 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2798 x3 = (tcp[i] & 0x7F) * w1;
2799 y3 = (tap[i] & 0x7F) * h1;
2802 if ((w1 == tw2) && (h1 == h2))
2804 /* Copy the terrain picture from the bitmap to the window */
2805 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
2807 /* Mask out the tile */
2808 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
2811 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
2814 /* Need to stretch */
2817 /* Set the correct mode for stretching the tiles */
2818 SetStretchBltMode(hdc, COLORONCOLOR);
2820 /* Copy the terrain picture from the bitmap to the window */
2821 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCCOPY);
2823 /* Only draw if terrain and overlay are different */
2824 if ((x1 != x3) || (y1 != y3))
2826 /* Mask out the tile */
2827 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
2830 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
2837 if ((w1 == tw2) && (h1 == h2))
2839 /* Copy the picture from the bitmap to the window */
2840 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
2843 /* Need to stretch */
2846 /* Set the correct mode for stretching the tiles */
2847 SetStretchBltMode(hdc, COLORONCOLOR);
2849 /* Copy the picture from the bitmap to the window */
2850 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
2856 SelectObject(hdcSrc, hbmSrcOld);
2859 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2862 SelectObject(hdcMask, hbmSrcOld);
2867 ReleaseDC(td->w, hdc);
2869 #else /* USE_GRAPHICS */
2871 /* Just erase this grid */
2872 return (Term_wipe_win(x, y, n));
2874 #endif /* USE_GRAPHICS */
2881 static void windows_map(void)
2883 term_data *td = &data[0];
2885 int x, min_x, max_x;
2886 int y, min_y, max_y;
2890 /* Only in graphics mode */
2891 if (!use_graphics) return;
2894 Term_xtra_win_clear();
2896 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
2897 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
2898 td->map_active = TRUE;
2908 for (x = min_x; x < max_x; x++)
2910 for (y = min_y; y < max_y; y++)
2912 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
2914 /* Ignore non-graphics */
2915 if ((a & 0x80) && (c & 0x80))
2917 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
2922 /* Hilite the player */
2923 Term_curs_win(px - min_x, py - min_y);
2925 /* Wait for a keypress, flush key buffer */
2926 Term_inkey(&c, TRUE, TRUE);
2929 /* Switch off the map display */
2930 td->map_active = FALSE;
2932 /* Restore screen */
2933 Term_xtra_win_clear();
2938 /*** Other routines ***/
2942 * Create and initialize a "term_data" given a title
2944 static void term_data_link(term_data *td)
2948 /* Initialize the term */
2949 term_init(t, td->cols, td->rows, td->keys);
2951 /* Use a "software" cursor */
2952 t->soft_cursor = TRUE;
2954 /* Use "Term_pict" for "graphic" data */
2955 t->higher_pict = TRUE;
2957 /* Erase with "white space" */
2958 t->attr_blank = TERM_WHITE;
2959 t->char_blank = ' ';
2962 /* Prepare the init/nuke hooks */
2963 t->init_hook = Term_init_win;
2964 t->nuke_hook = Term_nuke_win;
2967 /* Prepare the template hooks */
2968 t->user_hook = Term_user_win;
2969 t->xtra_hook = Term_xtra_win;
2970 t->curs_hook = Term_curs_win;
2971 t->bigcurs_hook = Term_bigcurs_win;
2972 t->wipe_hook = Term_wipe_win;
2973 t->text_hook = Term_text_win;
2974 t->pict_hook = Term_pict_win;
2976 /* Remember where we came from */
2977 t->data = (vptr)(td);
2982 * Create the windows
2984 * First, instantiate the "default" values, then read the "ini_file"
2985 * to over-ride selected values, then create the windows, and fonts.
2987 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
2988 * must make active to realize the palette. XXX XXX XXX
2990 static void init_windows(void)
2996 #if 0 /* #ifndef JP */
3002 WIPE(td, term_data);
3006 td->s = angband_term_name[0];
3020 #if 1 /* #ifdef JP */
3024 for (i = 1; i < MAX_TERM_DATA; i++)
3027 WIPE(td, term_data);
3028 td->s = angband_term_name[i];
3032 td->visible = FALSE;
3037 td->pos_x = (7 - i) * 30;
3038 td->pos_y = (7 - i) * 20;
3040 #if 1 /* #ifdef JP */
3050 /* Main window (need these before term_getsize gets called) */
3052 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
3053 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
3058 /* Sub windows (need these before term_getsize gets called) */
3059 for (i = 1; i < MAX_TERM_DATA; i++)
3062 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
3063 td->dwExStyle = (WS_EX_TOOLWINDOW);
3068 for (i = 0; i < MAX_TERM_DATA; i++)
3072 #if 1 /* #ifdef JP */
3073 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
3074 td->lf.lfCharSet = DEFAULT_CHARSET;
3075 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
3076 /* Activate the chosen font */
3077 term_force_font(td, NULL);
3078 td->tile_wid = td->font_wid;
3079 td->tile_hgt = td->font_hgt;
3081 /* Access the standard font file */
3082 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
3084 /* Activate the chosen font */
3085 if (term_force_font(td, buf))
3087 /* Access the standard font file */
3088 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
3090 /* Force the use of that font */
3091 (void)term_force_font(td, buf);
3097 /* Assume not bizarre */
3098 td->bizarre = FALSE;
3103 /* Analyze the font */
3106 /* Resize the window */
3107 term_window_resize(td);
3111 /* Sub windows (reverse order) */
3112 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
3117 td->w = CreateWindowEx(td->dwExStyle, AngList,
3119 td->pos_x, td->pos_y,
3120 td->size_wid, td->size_hgt,
3121 HWND_DESKTOP, NULL, hInstance, NULL);
3124 if (!td->w) quit("¥µ¥Ö¥¦¥£¥ó¥É¥¦¤ËºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿");
3126 if (!td->w) quit("Failed to create sub-window");
3132 td->size_hack = TRUE;
3133 ShowWindow(td->w, SW_SHOW);
3134 td->size_hack = FALSE;
3138 angband_term[i] = &td->t;
3142 /* Activate the window */
3143 SetActiveWindow(td->w);
3148 term_window_pos(&data[i], HWND_TOPMOST);
3152 term_window_pos(&data[i], td->w);
3162 td->w = CreateWindowEx(td->dwExStyle, AppName,
3164 td->pos_x, td->pos_y,
3165 td->size_wid, td->size_hgt,
3166 HWND_DESKTOP, NULL, hInstance, NULL);
3169 if (!td->w) quit("¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿");
3171 if (!td->w) quit("Failed to create Angband window");
3176 angband_term[0] = &td->t;
3177 normsize.x = td->cols;
3178 normsize.y = td->rows;
3180 /* Activate the main window */
3181 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
3182 else ShowWindow(td->w, SW_SHOW);
3184 /* Bring main window back to top */
3185 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
3188 /* New palette XXX XXX XXX */
3189 (void)new_palette();
3192 /* Create a "brush" for drawing the "cursor" */
3193 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
3196 /* Process pending messages */
3197 (void)Term_xtra_win_flush();
3205 static void setup_menus(void)
3209 HMENU hm = GetMenu(data[0].w);
3212 /* Menu "File", Disable all */
3213 EnableMenuItem(hm, IDM_FILE_NEW,
3214 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3215 EnableMenuItem(hm, IDM_FILE_OPEN,
3216 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3217 EnableMenuItem(hm, IDM_FILE_SAVE,
3218 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3219 EnableMenuItem(hm, IDM_FILE_EXIT,
3220 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3221 EnableMenuItem(hm, IDM_FILE_SCORE,
3222 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3225 /* No character available */
3226 if (!character_generated)
3228 /* Menu "File", Item "New" */
3229 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
3231 /* Menu "File", Item "Open" */
3232 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
3235 /* A character available */
3236 if (character_generated)
3238 /* Menu "File", Item "Save" */
3239 EnableMenuItem(hm, IDM_FILE_SAVE,
3240 MF_BYCOMMAND | MF_ENABLED);
3243 /* Menu "File", Item "Exit" */
3244 EnableMenuItem(hm, IDM_FILE_EXIT,
3245 MF_BYCOMMAND | MF_ENABLED);
3247 EnableMenuItem(hm, IDM_FILE_SCORE,
3248 MF_BYCOMMAND | MF_ENABLED);
3251 /* Menu "Window::Visibility" */
3252 for (i = 0; i < MAX_TERM_DATA; i++)
3254 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3255 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3257 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3258 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
3260 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3261 MF_BYCOMMAND | MF_ENABLED);
3264 /* Menu "Window::Font" */
3265 for (i = 0; i < MAX_TERM_DATA; i++)
3267 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3268 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3270 if (data[i].visible)
3272 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3273 MF_BYCOMMAND | MF_ENABLED);
3277 /* Menu "Window::Window Position Fix" */
3278 for (i = 0; i < MAX_TERM_DATA; i++)
3280 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3281 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3283 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
3284 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
3286 if (data[i].visible)
3288 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3289 MF_BYCOMMAND | MF_ENABLED);
3293 /* Menu "Window::Bizarre Display" */
3294 for (i = 0; i < MAX_TERM_DATA; i++)
3296 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3297 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3299 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3300 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
3302 if (data[i].visible)
3304 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3305 MF_BYCOMMAND | MF_ENABLED);
3310 /* Menu "Window::Increase Tile Width" */
3311 for (i = 0; i < MAX_TERM_DATA; i++)
3313 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3314 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3316 if (data[i].visible)
3318 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3319 MF_BYCOMMAND | MF_ENABLED);
3324 /* Menu "Window::Decrease Tile Width" */
3325 for (i = 0; i < MAX_TERM_DATA; i++)
3327 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3328 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3330 if (data[i].visible)
3332 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3333 MF_BYCOMMAND | MF_ENABLED);
3338 /* Menu "Window::Increase Tile Height" */
3339 for (i = 0; i < MAX_TERM_DATA; i++)
3341 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3342 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3344 if (data[i].visible)
3346 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3347 MF_BYCOMMAND | MF_ENABLED);
3352 /* Menu "Window::Decrease Tile Height" */
3353 for (i = 0; i < MAX_TERM_DATA; i++)
3355 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3356 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3358 if (data[i].visible)
3360 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3361 MF_BYCOMMAND | MF_ENABLED);
3366 /* Menu "Options", disable all */
3367 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3368 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3369 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3370 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3371 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3372 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3373 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
3374 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3375 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
3376 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3378 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3379 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3382 /* Menu "Options", Item "Map" */
3383 if (use_graphics != GRAPHICS_NONE)
3384 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
3386 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
3387 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3389 /* Menu "Options", update all */
3390 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3391 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
3392 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3393 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
3394 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3395 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
3396 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
3397 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
3398 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
3399 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
3400 CheckMenuItem(hm, IDM_OPTIONS_BG,
3401 (use_bg ? MF_CHECKED : MF_UNCHECKED));
3403 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
3404 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
3408 /* Menu "Options", Item "Graphics" */
3409 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
3410 /* Menu "Options", Item "Graphics" */
3411 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
3412 /* Menu "Options", Item "Graphics" */
3413 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
3414 /* Menu "Options", Item "Graphics" */
3415 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
3416 #endif /* USE_GRAPHICS */
3419 /* Menu "Options", Item "Sound" */
3420 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
3421 #endif /* USE_SOUND */
3424 /* Menu "Options", Item "ScreenSaver" */
3425 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3426 MF_BYCOMMAND | MF_ENABLED);
3427 #endif /* USE_SAVER */
3432 * Check for double clicked (or dragged) savefile
3434 * Apparently, Windows copies the entire filename into the first
3435 * piece of the "command line string". Perhaps we should extract
3436 * the "basename" of that filename and append it to the "save" dir.
3438 static void check_for_save_file(LPSTR cmd_line)
3448 /* Extract filename */
3449 strcat(savefile, s);
3451 /* Validate the file */
3452 validate_file(savefile);
3454 /* Game in progress */
3455 game_in_progress = TRUE;
3463 * Process a menu command
3465 static void process_menus(WORD wCmd)
3482 plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
3484 plog("You cannot do that yet...");
3488 else if (game_in_progress)
3491 plog("¥×¥ì¥¤Ãæ¤Ï¿·¤·¤¤¥²¡¼¥à¤ò»Ï¤á¤ë¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
3493 plog("You can't start a new game while you're still playing!");
3499 game_in_progress = TRUE;
3513 plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
3515 plog("You cannot do that yet...");
3519 else if (game_in_progress)
3522 plog("¥×¥ì¥¤Ãæ¤Ï¥²¡¼¥à¤ò¥í¡¼¥É¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
3524 plog("You can't open a new game while you're still playing!");
3530 memset(&ofn, 0, sizeof(ofn));
3531 ofn.lStructSize = sizeof(ofn);
3532 ofn.hwndOwner = data[0].w;
3533 ofn.lpstrFilter = "Save Files (*.)\0*\0";
3534 ofn.nFilterIndex = 1;
3535 ofn.lpstrFile = savefile;
3536 ofn.nMaxFile = 1024;
3537 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
3538 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
3540 if (GetOpenFileName(&ofn))
3542 /* Load 'savefile' */
3543 validate_file(savefile);
3544 game_in_progress = TRUE;
3556 if (game_in_progress && character_generated)
3562 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3564 plog("You may not do that right now.");
3570 /* Hack -- Forget messages */
3575 do_cmd_save_game(FALSE);
3576 #else /* ZANGBAND */
3578 #endif /* ZANGBAND */
3583 plog("º£¡¢¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3585 plog("You may not do that right now.");
3595 if (game_in_progress && character_generated)
3601 plog("º£¤Ï½ªÎ»¤Ç¤¤Þ¤»¤ó¡£");
3603 plog("You may not do that right now.");
3609 /* Hack -- Forget messages */
3618 /* do_cmd_save_game(FALSE); */
3619 #else /* ZANGBAND */
3620 /* do_cmd_save_game(); */
3621 #endif /* ZANGBAND */
3622 Term_key_push(SPECIAL_KEY_QUIT);
3630 case IDM_FILE_SCORE:
3634 /* Build the filename */
3635 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
3637 /* Open the binary high score file, for reading */
3638 highscore_fd = fd_open(buf, O_RDONLY);
3640 /* Paranoia -- No score file */
3641 if (highscore_fd < 0)
3643 msg_print("Score file unavailable.");
3653 /* Display the scores */
3654 display_scores_aux(0, MAX_HISCORES, -1, NULL);
3656 /* Shut the high score file */
3657 (void)fd_close(highscore_fd);
3659 /* Forget the high score fd */
3665 /* Hack - Flush it */
3673 case IDM_FILE_MOVIE:
3678 plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
3680 plog("You cannot do that yet...");
3683 else if (game_in_progress)
3686 plog("¥×¥ì¥¤Ãæ¤Ï¥à¡¼¥Ó¡¼¤ò¥í¡¼¥É¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
3688 plog("You can't open a movie while you're playing!");
3693 memset(&ofn, 0, sizeof(ofn));
3694 ofn.lStructSize = sizeof(ofn);
3695 ofn.hwndOwner = data[0].w;
3696 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
3697 ofn.nFilterIndex = 1;
3698 ofn.lpstrFile = savefile;
3699 ofn.nMaxFile = 1024;
3700 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
3701 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
3703 if (GetOpenFileName(&ofn))
3705 /* Load 'savefile' */
3706 prepare_browse_movie_aux(savefile);
3716 case IDM_WINDOW_VIS_0:
3719 plog("¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤ÏÈóɽ¼¨¤Ë¤Ç¤¤Þ¤»¤ó¡ª");
3721 plog("You are not allowed to do that!");
3728 /* Window visibility */
3729 case IDM_WINDOW_VIS_1:
3730 case IDM_WINDOW_VIS_2:
3731 case IDM_WINDOW_VIS_3:
3732 case IDM_WINDOW_VIS_4:
3733 case IDM_WINDOW_VIS_5:
3734 case IDM_WINDOW_VIS_6:
3735 case IDM_WINDOW_VIS_7:
3737 i = wCmd - IDM_WINDOW_VIS_0;
3739 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3746 ShowWindow(td->w, SW_SHOW);
3747 term_data_redraw(td);
3751 td->visible = FALSE;
3753 ShowWindow(td->w, SW_HIDE);
3760 case IDM_WINDOW_FONT_0:
3761 case IDM_WINDOW_FONT_1:
3762 case IDM_WINDOW_FONT_2:
3763 case IDM_WINDOW_FONT_3:
3764 case IDM_WINDOW_FONT_4:
3765 case IDM_WINDOW_FONT_5:
3766 case IDM_WINDOW_FONT_6:
3767 case IDM_WINDOW_FONT_7:
3769 i = wCmd - IDM_WINDOW_FONT_0;
3771 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3775 term_change_font(td);
3780 /* Window Z Position */
3781 case IDM_WINDOW_POS_1:
3782 case IDM_WINDOW_POS_2:
3783 case IDM_WINDOW_POS_3:
3784 case IDM_WINDOW_POS_4:
3785 case IDM_WINDOW_POS_5:
3786 case IDM_WINDOW_POS_6:
3787 case IDM_WINDOW_POS_7:
3789 i = wCmd - IDM_WINDOW_POS_0;
3791 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3795 if (!td->posfix && td->visible)
3798 term_window_pos(td, HWND_TOPMOST);
3803 term_window_pos(td, data[0].w);
3809 /* Bizarre Display */
3810 case IDM_WINDOW_BIZ_0:
3811 case IDM_WINDOW_BIZ_1:
3812 case IDM_WINDOW_BIZ_2:
3813 case IDM_WINDOW_BIZ_3:
3814 case IDM_WINDOW_BIZ_4:
3815 case IDM_WINDOW_BIZ_5:
3816 case IDM_WINDOW_BIZ_6:
3817 case IDM_WINDOW_BIZ_7:
3819 i = wCmd - IDM_WINDOW_BIZ_0;
3821 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3825 td->bizarre = !td->bizarre;
3829 term_window_resize(td);
3834 /* Increase Tile Width */
3835 case IDM_WINDOW_I_WID_0:
3836 case IDM_WINDOW_I_WID_1:
3837 case IDM_WINDOW_I_WID_2:
3838 case IDM_WINDOW_I_WID_3:
3839 case IDM_WINDOW_I_WID_4:
3840 case IDM_WINDOW_I_WID_5:
3841 case IDM_WINDOW_I_WID_6:
3842 case IDM_WINDOW_I_WID_7:
3844 i = wCmd - IDM_WINDOW_I_WID_0;
3846 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3854 term_window_resize(td);
3859 /* Decrease Tile Height */
3860 case IDM_WINDOW_D_WID_0:
3861 case IDM_WINDOW_D_WID_1:
3862 case IDM_WINDOW_D_WID_2:
3863 case IDM_WINDOW_D_WID_3:
3864 case IDM_WINDOW_D_WID_4:
3865 case IDM_WINDOW_D_WID_5:
3866 case IDM_WINDOW_D_WID_6:
3867 case IDM_WINDOW_D_WID_7:
3869 i = wCmd - IDM_WINDOW_D_WID_0;
3871 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3879 term_window_resize(td);
3884 /* Increase Tile Height */
3885 case IDM_WINDOW_I_HGT_0:
3886 case IDM_WINDOW_I_HGT_1:
3887 case IDM_WINDOW_I_HGT_2:
3888 case IDM_WINDOW_I_HGT_3:
3889 case IDM_WINDOW_I_HGT_4:
3890 case IDM_WINDOW_I_HGT_5:
3891 case IDM_WINDOW_I_HGT_6:
3892 case IDM_WINDOW_I_HGT_7:
3894 i = wCmd - IDM_WINDOW_I_HGT_0;
3896 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3904 term_window_resize(td);
3909 /* Decrease Tile Height */
3910 case IDM_WINDOW_D_HGT_0:
3911 case IDM_WINDOW_D_HGT_1:
3912 case IDM_WINDOW_D_HGT_2:
3913 case IDM_WINDOW_D_HGT_3:
3914 case IDM_WINDOW_D_HGT_4:
3915 case IDM_WINDOW_D_HGT_5:
3916 case IDM_WINDOW_D_HGT_6:
3917 case IDM_WINDOW_D_HGT_7:
3919 i = wCmd - IDM_WINDOW_D_HGT_0;
3921 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3929 term_window_resize(td);
3934 case IDM_OPTIONS_NO_GRAPHICS:
3939 plog("You may not do that right now.");
3943 /* Toggle "arg_graphics" */
3944 if (arg_graphics != GRAPHICS_NONE)
3946 arg_graphics = GRAPHICS_NONE;
3948 /* React to changes */
3949 Term_xtra_win_react();
3951 /* Hack -- Force redraw */
3952 Term_key_push(KTRL('R'));
3958 case IDM_OPTIONS_OLD_GRAPHICS:
3963 plog("You may not do that right now.");
3967 /* Toggle "arg_graphics" */
3968 if (arg_graphics != GRAPHICS_ORIGINAL)
3970 arg_graphics = GRAPHICS_ORIGINAL;
3972 /* React to changes */
3973 Term_xtra_win_react();
3975 /* Hack -- Force redraw */
3976 Term_key_push(KTRL('R'));
3982 case IDM_OPTIONS_NEW_GRAPHICS:
3987 plog("You may not do that right now.");
3991 /* Toggle "arg_graphics" */
3992 if (arg_graphics != GRAPHICS_ADAM_BOLT)
3994 arg_graphics = GRAPHICS_ADAM_BOLT;
3996 /* React to changes */
3997 Term_xtra_win_react();
3999 /* Hack -- Force redraw */
4000 Term_key_push(KTRL('R'));
4006 case IDM_OPTIONS_BIGTILE:
4008 term_data *td = &data[0];
4013 plog("You may not do that right now.");
4017 /* Toggle "arg_sound" */
4018 arg_bigtile = !arg_bigtile;
4021 Term_activate(&td->t);
4023 /* Resize the term */
4024 Term_resize(td->cols, td->rows);
4027 InvalidateRect(td->w, NULL, TRUE);
4032 case IDM_OPTIONS_SOUND:
4037 plog("You may not do that right now.");
4041 /* Toggle "arg_sound" */
4042 arg_sound = !arg_sound;
4044 /* React to changes */
4045 Term_xtra_win_react();
4047 /* Hack -- Force redraw */
4048 Term_key_push(KTRL('R'));
4054 case IDM_OPTIONS_BG:
4059 plog("You may not do that right now.");
4063 /* Toggle "use_bg" */
4068 /* React to changes */
4069 Term_xtra_win_react();
4071 /* Hack -- Force redraw */
4072 Term_key_push(KTRL('R'));
4078 case IDM_OPTIONS_OPEN_BG:
4083 plog("You may not do that right now.");
4088 memset(&ofn, 0, sizeof(ofn));
4089 ofn.lStructSize = sizeof(ofn);
4090 ofn.hwndOwner = data[0].w;
4091 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
4092 ofn.nFilterIndex = 1;
4093 ofn.lpstrFile = bg_bitmap_file;
4094 ofn.nMaxFile = 1023;
4095 ofn.lpstrInitialDir = NULL;
4097 ofn.lpstrTitle = "ÊÉ»æ¤òÁª¤ó¤Ç¤Í¡£";
4099 ofn.lpstrTitle = "Choose wall paper.";
4101 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
4103 if (GetOpenFileName(&ofn))
4105 /* Load 'savefile' */
4110 /* React to changes */
4111 Term_xtra_win_react();
4113 /* Hack -- Force redraw */
4114 Term_key_push(KTRL('R'));
4119 case IDM_DUMP_SCREEN_HTML:
4121 static char buf[1024] = "";
4122 memset(&ofn, 0, sizeof(ofn));
4123 ofn.lStructSize = sizeof(ofn);
4124 ofn.hwndOwner = data[0].w;
4125 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
4126 ofn.nFilterIndex = 1;
4127 ofn.lpstrFile = buf;
4128 ofn.nMaxFile = 1023;
4129 ofn.lpstrDefExt = "html";
4130 ofn.lpstrInitialDir = NULL;
4132 ofn.lpstrTitle = "HTML¤Ç¥¹¥¯¥ê¡¼¥ó¥À¥ó¥×¤òÊݸ";
4134 ofn.lpstrTitle = "Save screen dump as HTML.";
4136 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
4138 if (GetSaveFileName(&ofn))
4140 do_cmd_save_screen_html_aux(buf, 0);
4147 case IDM_OPTIONS_SAVER:
4151 DestroyWindow(hwndSaver);
4156 /* Create a screen scaver window */
4157 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
4158 "Angband Screensaver",
4159 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
4160 0, 0, GetSystemMetrics(SM_CXSCREEN),
4161 GetSystemMetrics(SM_CYSCREEN),
4162 NULL, NULL, hInstance, NULL);
4166 /* Push the window to the bottom XXX XXX XXX */
4167 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
4172 plog("¥¦¥£¥ó¥É¥¦¤òºîÀ®½ÐÍè¤Þ¤»¤ó");
4174 plog("Failed to create saver window");
4184 case IDM_OPTIONS_MAP:
4190 case IDM_HELP_CONTENTS:
4194 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
4195 if (check_file(tmp))
4197 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
4202 plog_fmt("¥Ø¥ë¥×¥Õ¥¡¥¤¥ë[%s]¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó¡£", tmp);
4203 plog("Âå¤ï¤ê¤Ë¥ª¥ó¥é¥¤¥ó¥Ø¥ë¥×¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£");
4205 plog_fmt("Cannot find help file: %s", tmp);
4206 plog("Use the online help files instead.");
4211 #else /* HTML_HELP */
4214 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
4215 if (check_file(tmp))
4217 sprintf(buf, "winhelp.exe %s", tmp);
4218 WinExec(buf, SW_NORMAL);
4223 plog_fmt("¥Ø¥ë¥×¥Õ¥¡¥¤¥ë[%s]¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó¡£", tmp);
4224 plog("Âå¤ï¤ê¤Ë¥ª¥ó¥é¥¤¥ó¥Ø¥ë¥×¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£");
4226 plog_fmt("Cannot find help file: %s", tmp);
4227 plog("Use the online help files instead.");
4232 #endif /* HTML_HELP */
4238 static bool process_keydown(WPARAM wParam, LPARAM lParam)
4245 /* Extract the modifiers */
4246 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
4247 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
4248 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
4250 Term_no_press = (ma) ? TRUE : FALSE;
4252 /* Handle "special" keys */
4253 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
4255 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
4256 bool numpad = FALSE;
4258 /* Begin the macro trigger */
4261 /* Send the modifiers */
4262 if (mc) Term_keypress('C');
4263 if (ms) Term_keypress('S');
4264 if (ma) Term_keypress('A');
4266 /* Extract "scan code" */
4267 i = LOBYTE(HIWORD(lParam));
4269 /* Introduce the scan code */
4272 /* Extended key bit */
4275 /* Numpad Enter and '/' are extended key */
4277 Term_no_press = TRUE;
4278 case VK_RETURN: /* Enter */
4281 /* Other extended keys are on full keyboard */
4297 Term_no_press = TRUE;
4301 case VK_PRIOR: /* Page Up */
4302 case VK_NEXT: /* Page Down */
4312 /* Special modifiers for keypad keys */
4313 if (numpad) Term_keypress('K');
4315 /* Encode the hexidecimal scan code */
4316 Term_keypress(hexsym[i/16]);
4317 Term_keypress(hexsym[i%16]);
4319 /* End the macro trigger */
4330 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4331 WPARAM wParam, LPARAM lParam);
4332 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4333 WPARAM wParam, LPARAM lParam)
4334 #else /* __MWERKS__ */
4335 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4336 WPARAM wParam, LPARAM lParam)
4337 #endif /* __MWERKS__ */
4343 MINMAXINFO FAR *lpmmi;
4349 /* Acquire proper "term_data" info */
4350 td = (term_data *)GetWindowLong(hWnd, 0);
4352 /* Handle message */
4358 SetWindowLong(hWnd, 0, (LONG)(my_td));
4368 case WM_GETMINMAXINFO:
4370 MINMAXINFO FAR *lpmmi;
4373 lpmmi = (MINMAXINFO FAR *)lParam;
4375 /* this message was sent before WM_NCCREATE */
4378 /* Minimum window size is 80x24 */
4379 rc.left = rc.top = 0;
4380 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
4381 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4384 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4386 /* Save minimum size */
4387 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4388 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4395 BeginPaint(hWnd, &ps);
4396 if (td) term_data_redraw(td);
4397 EndPaint(hWnd, &ps);
4398 ValidateRect(hWnd, NULL);
4405 if (process_keydown(wParam, lParam))
4412 if (Term_no_press) Term_no_press = FALSE;
4413 else Term_keypress(wParam);
4417 case WM_LBUTTONDOWN:
4419 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
4420 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
4432 int dx = abs(oldx - mousex) + 1;
4433 int dy = abs(oldy - mousey) + 1;
4434 int ox = (oldx > mousex) ? mousex : oldx;
4435 int oy = (oldy > mousey) ? mousey : oldy;
4445 hGlobal = GlobalAlloc(GHND, sz + 1);
4446 if (hGlobal == NULL) return 0;
4447 lpStr = (LPSTR)GlobalLock(hGlobal);
4449 for (i = 0; i < dy; i++)
4453 char **scr = data[0].t.scr->c;
4455 C_MAKE(s, (dx + 1), char);
4456 strncpy(s, &scr[oy + i][ox], dx);
4460 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
4463 if (ox + dx < data[0].cols)
4465 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
4468 for (j = 0; j < dx; j++)
4470 if (s[j] == 127) s[j] = '#';
4474 for (j = 0; j < dx; j++)
4476 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
4486 GlobalUnlock(hGlobal);
4487 if (OpenClipboard(hWnd) == 0)
4489 GlobalFree(hGlobal);
4493 SetClipboardData(CF_TEXT, hGlobal);
4506 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
4507 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
4512 dx = abs(oldx - mousex) + 1;
4513 dy = abs(oldy - mousey) + 1;
4514 ox = (oldx > mousex) ? mousex : oldx;
4515 oy = (oldy > mousey) ? mousey : oldy;
4516 Term_inversed_area(hWnd, ox, oy, dx, dy);
4523 dx = abs(cx - mousex) + 1;
4524 dy = abs(cy - mousey) + 1;
4525 ox = (cx > mousex) ? mousex : cx;
4526 oy = (cy > mousey) ? mousey : cy;
4527 Term_inversed_area(hWnd, ox, oy, dx, dy);
4543 if (game_in_progress && character_generated)
4548 plog("º£¤Ï½ªÎ»¤Ç¤¤Þ¤»¤ó¡£");
4550 plog("You may not do that right now.");
4555 /* Hack -- Forget messages */
4564 /* do_cmd_save_game(FALSE); */
4565 #else /* ZANGBAND */
4566 /* do_cmd_save_game(); */
4567 #endif /* ZANGBAND */
4568 Term_key_push(SPECIAL_KEY_QUIT);
4575 case WM_QUERYENDSESSION:
4577 if (game_in_progress && character_generated)
4579 /* Hack -- Forget messages */
4582 /* Mega-Hack -- Delay death */
4583 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
4586 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
4588 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
4591 /* Hardcode panic save */
4592 p_ptr->panic_save = 1;
4594 /* Forbid suspend */
4595 signals_ignore_tstp();
4597 /* Indicate panic save */
4599 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
4601 (void)strcpy(p_ptr->died_from, "(panic save)");
4605 (void)save_player();
4619 process_menus(LOWORD(wParam));
4625 /* this message was sent before WM_NCCREATE */
4628 /* it was sent from inside CreateWindowEx */
4629 if (!td->w) return 1;
4631 /* was sent from WM_SIZE */
4632 if (td->size_hack) return 1;
4636 case SIZE_MINIMIZED:
4638 /* Hide sub-windows */
4639 for (i = 1; i < MAX_TERM_DATA; i++)
4641 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
4646 case SIZE_MAXIMIZED:
4648 /* fall through XXX XXX XXX */
4653 uint cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4654 uint rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4657 if ((td->cols != cols) || (td->rows != rows))
4659 /* Save the new size */
4663 if (!IsZoomed(td->w) && !IsIconic(td->w))
4665 normsize.x = td->cols;
4666 normsize.y = td->rows;
4670 Term_activate(&td->t);
4672 /* Resize the term */
4673 Term_resize(td->cols, td->rows);
4676 InvalidateRect(td->w, NULL, TRUE);
4679 td->size_hack = TRUE;
4681 /* Show sub-windows */
4682 for (i = 1; i < MAX_TERM_DATA; i++)
4684 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
4687 td->size_hack = FALSE;
4695 case WM_PALETTECHANGED:
4697 /* Ignore if palette change caused by itself */
4698 if ((HWND)wParam == hWnd) return 0;
4700 /* Fall through... */
4703 case WM_QUERYNEWPALETTE:
4705 if (!paletted) return 0;
4709 SelectPalette(hdc, hPal, FALSE);
4711 i = RealizePalette(hdc);
4713 /* if any palette entries changed, repaint the window. */
4714 if (i) InvalidateRect(hWnd, NULL, TRUE);
4716 ReleaseDC(hWnd, hdc);
4723 if (wParam && !HIWORD(lParam))
4725 /* Do something to sub-windows */
4726 for (i = 1; i < MAX_TERM_DATA; i++)
4728 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
4731 /* Focus on main window */
4740 case WM_ACTIVATEAPP:
4742 if (IsIconic(td->w)) break;
4744 for (i = 1; i < MAX_TERM_DATA; i++)
4750 ShowWindow(data[i].w, SW_SHOW);
4754 ShowWindow(data[i].w, SW_HIDE);
4761 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4766 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4767 WPARAM wParam, LPARAM lParam);
4768 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4769 WPARAM wParam, LPARAM lParam)
4770 #else /* __MWERKS__ */
4771 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4772 WPARAM wParam, LPARAM lParam)
4773 #endif /* __MWERKS__ */
4777 MINMAXINFO FAR *lpmmi;
4785 /* Acquire proper "term_data" info */
4786 td = (term_data *)GetWindowLong(hWnd, 0);
4788 /* Process message */
4794 SetWindowLong(hWnd, 0, (LONG)(my_td));
4804 case WM_GETMINMAXINFO:
4806 MINMAXINFO FAR *lpmmi;
4809 lpmmi = (MINMAXINFO FAR *)lParam;
4811 /* this message was sent before WM_NCCREATE */
4814 /* Minimum window size is 80x24 */
4815 rc.left = rc.top = 0;
4816 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
4817 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4820 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4822 /* Save minimum size */
4823 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4824 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4834 /* this message was sent before WM_NCCREATE */
4837 /* it was sent from inside CreateWindowEx */
4838 if (!td->w) return 1;
4840 /* was sent from inside WM_SIZE */
4841 if (td->size_hack) return 1;
4843 td->size_hack = TRUE;
4845 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4846 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4849 if ((td->cols != cols) || (td->rows != rows))
4852 term *old_term = Term;
4854 /* Save the new size */
4859 Term_activate(&td->t);
4861 /* Resize the term */
4862 Term_resize(td->cols, td->rows);
4865 Term_activate(old_term);
4868 InvalidateRect(td->w, NULL, TRUE);
4870 /* HACK - Redraw all windows */
4871 p_ptr->window = 0xFFFFFFFF;
4875 td->size_hack = FALSE;
4882 BeginPaint(hWnd, &ps);
4883 if (td) term_data_redraw(td);
4884 EndPaint(hWnd, &ps);
4891 if (process_keydown(wParam, lParam))
4898 if (Term_no_press) Term_no_press = FALSE;
4899 else Term_keypress(wParam);
4903 case WM_PALETTECHANGED:
4905 /* ignore if palette change caused by itself */
4906 if ((HWND)wParam == hWnd) return FALSE;
4907 /* otherwise, fall through!!! */
4910 case WM_QUERYNEWPALETTE:
4912 if (!paletted) return 0;
4914 SelectPalette(hdc, hPal, FALSE);
4915 i = RealizePalette(hdc);
4916 /* if any palette entries changed, repaint the window. */
4917 if (i) InvalidateRect(hWnd, NULL, TRUE);
4918 ReleaseDC(hWnd, hdc);
4922 case WM_NCLBUTTONDOWN:
4926 if (wParam == HTCLOSE) wParam = HTSYSMENU;
4927 #endif /* HTCLOSE */
4929 if (wParam == HTSYSMENU)
4933 td->visible = FALSE;
4934 ShowWindow(td->w, SW_HIDE);
4944 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4950 #define MOUSE_SENS 40
4953 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4954 WPARAM wParam, LPARAM lParam);
4955 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4956 WPARAM wParam, LPARAM lParam)
4957 #else /* __MWERKS__ */
4958 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4959 WPARAM wParam, LPARAM lParam)
4960 #endif /* __MWERKS__ */
4962 static int iMouse = 0;
4963 static WORD xMouse = 0;
4964 static WORD yMouse = 0;
4987 if (LOWORD(wParam) == WA_INACTIVE) break;
4989 /* else fall through */
4993 case WM_LBUTTONDOWN:
4994 case WM_MBUTTONDOWN:
4995 case WM_RBUTTONDOWN:
4998 SendMessage(hWnd, WM_CLOSE, 0, 0);
5006 dx = LOWORD(lParam) - xMouse;
5007 dy = HIWORD(lParam) - yMouse;
5009 if (dx < 0) dx = -dx;
5010 if (dy < 0) dy = -dy;
5012 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
5014 SendMessage(hWnd, WM_CLOSE, 0, 0);
5018 /* Save last location */
5020 xMouse = LOWORD(lParam);
5021 yMouse = HIWORD(lParam);
5028 DestroyWindow(hwndSaver);
5035 return DefWindowProc(hWnd, uMsg, wParam, lParam);
5038 #endif /* USE_SAVER */
5044 /*** Temporary Hooks ***/
5048 * Display warning message (see "z-util.c")
5050 static void hack_plog(cptr str)
5052 /* Give a warning */
5056 MessageBox(NULL, str, "·Ù¹ð¡ª",
5057 MB_ICONEXCLAMATION | MB_OK);
5059 MessageBox(NULL, str, "Warning",
5060 MB_ICONEXCLAMATION | MB_OK);
5068 * Display error message and quit (see "z-util.c")
5070 static void hack_quit(cptr str)
5072 /* Give a warning */
5076 MessageBox(NULL, str, "¥¨¥é¡¼¡ª",
5077 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5079 MessageBox(NULL, str, "Error",
5080 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5085 /* Unregister the classes */
5086 UnregisterClass(AppName, hInstance);
5088 /* Destroy the icon */
5089 if (hIcon) DestroyIcon(hIcon);
5097 /*** Various hooks ***/
5101 * Display warning message (see "z-util.c")
5103 static void hook_plog(cptr str)
5109 MessageBox(data[0].w, str, "·Ù¹ð¡ª",
5110 MB_ICONEXCLAMATION | MB_OK);
5112 MessageBox(data[0].w, str, "Warning",
5113 MB_ICONEXCLAMATION | MB_OK);
5121 * Display error message and quit (see "z-util.c")
5123 static void hook_quit(cptr str)
5128 /* Give a warning */
5132 MessageBox(data[0].w, str, "¥¨¥é¡¼¡ª",
5133 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5135 MessageBox(data[0].w, str, "Error",
5136 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5142 /* Save the preferences */
5146 /*** Could use 'Term_nuke_win()' XXX XXX XXX */
5148 /* Destroy all windows */
5149 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
5151 term_force_font(&data[i], NULL);
5152 if (data[i].font_want) string_free(data[i].font_want);
5153 if (data[i].w) DestroyWindow(data[i].w);
5157 /* Free the bitmap stuff */
5159 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
5160 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
5162 if (infMask.hPalette) DeleteObject(infMask.hPalette);
5163 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
5165 #endif /* USE_GRAPHICS */
5167 /*** Free some other stuff ***/
5169 DeleteObject(hbrYellow);
5174 if (hPal) DeleteObject(hPal);
5176 UnregisterClass(AppName, hInstance);
5178 if (hIcon) DestroyIcon(hIcon);
5185 /*** Initialize ***/
5191 static void init_stuff(void)
5198 /* Get program name with full path */
5199 GetModuleFileName(hInstance, path, 512);
5201 /* Save the "program name" XXX XXX XXX */
5204 /* Get the name of the "*.ini" file */
5205 strcpy(path + strlen(path) - 4, ".INI");
5207 /* Save the the name of the ini-file */
5208 ini_file = string_make(path);
5210 /* Analyze the path */
5216 if (path[i] == '\\')
5223 /* Add "lib" to the path */
5224 strcpy(path + i + 1, "lib\\");
5226 /* Validate the path */
5227 validate_dir(path, TRUE);
5229 /* Init the file paths */
5230 init_file_paths(path);
5232 /* Hack -- Validate the paths */
5233 validate_dir(ANGBAND_DIR_APEX, FALSE);
5234 validate_dir(ANGBAND_DIR_BONE, FALSE);
5236 /* Allow missing 'edit' directory */
5237 if (!check_dir(ANGBAND_DIR_EDIT))
5239 /* Must have 'data'! */
5240 validate_dir(ANGBAND_DIR_DATA, TRUE);
5244 /* Don't need 'data' */
5245 validate_dir(ANGBAND_DIR_DATA, FALSE);
5248 validate_dir(ANGBAND_DIR_FILE, TRUE);
5249 validate_dir(ANGBAND_DIR_HELP, FALSE);
5250 validate_dir(ANGBAND_DIR_INFO, FALSE);
5251 validate_dir(ANGBAND_DIR_PREF, TRUE);
5252 validate_dir(ANGBAND_DIR_SAVE, FALSE);
5253 validate_dir(ANGBAND_DIR_USER, TRUE);
5254 validate_dir(ANGBAND_DIR_XTRA, TRUE);
5256 /* Build the filename */
5258 path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news_j.txt");
5260 path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news.txt");
5264 /* Hack -- Validate the "news.txt" file */
5265 validate_file(path);
5268 #if 0 /* #ifndef JP */
5269 /* Build the "font" path */
5270 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
5272 /* Allocate the path */
5273 ANGBAND_DIR_XTRA_FONT = string_make(path);
5275 /* Validate the "font" directory */
5276 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
5278 /* Build the filename */
5279 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
5281 /* Hack -- Validate the basic font */
5282 validate_file(path);
5288 /* Build the "graf" path */
5289 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
5291 /* Allocate the path */
5292 ANGBAND_DIR_XTRA_GRAF = string_make(path);
5294 /* Validate the "graf" directory */
5295 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
5297 #endif /* USE_GRAPHICS */
5302 /* Build the "sound" path */
5303 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
5305 /* Allocate the path */
5306 ANGBAND_DIR_XTRA_SOUND = string_make(path);
5308 /* Validate the "sound" directory */
5309 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
5311 #endif /* USE_SOUND */
5315 /* Build the "music" path */
5316 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
5318 /* Allocate the path */
5319 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
5321 /* Validate the "music" directory */
5322 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
5324 #endif /* USE_MUSIC */
5326 /* Build the "help" path */
5327 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
5329 /* Allocate the path */
5330 ANGBAND_DIR_XTRA_HELP = string_make(path);
5332 /* Validate the "help" directory */
5333 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
5337 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
5338 LPSTR lpCmdLine, int nCmdShow)
5353 if (hPrevInst == NULL)
5355 wc.style = CS_CLASSDC;
5356 wc.lpfnWndProc = AngbandWndProc;
5358 wc.cbWndExtra = 4; /* one long pointer to term_data */
5359 wc.hInstance = hInst;
5360 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
5361 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
5362 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
5363 wc.lpszMenuName = AppName;
5364 wc.lpszClassName = AppName;
5366 if (!RegisterClass(&wc)) exit(1);
5368 wc.lpfnWndProc = AngbandListProc;
5369 wc.lpszMenuName = NULL;
5370 wc.lpszClassName = AngList;
5372 if (!RegisterClass(&wc)) exit(2);
5376 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
5377 wc.lpfnWndProc = AngbandSaverProc;
5379 wc.lpszMenuName = NULL;
5380 wc.lpszClassName = "WindowsScreenSaverClass";
5382 if (!RegisterClass(&wc)) exit(3);
5388 /* Temporary hooks */
5389 plog_aux = hack_plog;
5390 quit_aux = hack_quit;
5391 core_aux = hack_quit;
5393 /* Prepare the filepaths */
5396 /* Initialize the keypress analyzer */
5397 for (i = 0; special_key_list[i]; ++i)
5399 special_key[special_key_list[i]] = TRUE;
5401 /* Initialize the keypress analyzer */
5402 for (i = 0; ignore_key_list[i]; ++i)
5404 ignore_key[ignore_key_list[i]] = TRUE;
5407 /* Determine if display is 16/256/true color */
5409 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
5410 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
5411 ReleaseDC(NULL, hdc);
5413 /* Initialize the colors */
5414 for (i = 0; i < 256; i++)
5418 /* Extract desired values */
5419 rv = angband_color_table[i][1];
5420 gv = angband_color_table[i][2];
5421 bv = angband_color_table[i][3];
5423 /* Extract the "complex" code */
5424 win_clr[i] = PALETTERGB(rv, gv, bv);
5426 /* Save the "simple" code */
5427 angband_color_table[i][0] = win_pal[i];
5430 /* Prepare the windows */
5436 /* Activate hooks */
5437 plog_aux = hook_plog;
5438 quit_aux = hook_quit;
5439 core_aux = hook_quit;
5441 /* Set the system suffix */
5442 ANGBAND_SYS = "win";
5444 /* Set the keyboard suffix */
5445 if (7 != GetKeyboardType(0))
5446 ANGBAND_KEYBOARD = "0";
5449 /* Japanese keyboard */
5450 switch (GetKeyboardType(1))
5452 case 0x0D01: case 0x0D02:
5453 case 0x0D03: case 0x0D04:
5454 case 0x0D05: case 0x0D06:
5456 ANGBAND_KEYBOARD = "NEC98";
5460 ANGBAND_KEYBOARD = "JAPAN";
5464 /* Catch nasty signals */
5470 /* We are now initialized */
5473 if(lpCmdLine[0] == '-'){
5474 switch(lpCmdLine[1])
5479 if (!lpCmdLine[2]) break;
5480 chuukei_server = TRUE;
5481 if(connect_chuukei_server(&lpCmdLine[2])<0){
5482 msg_print("connect fail");
5485 msg_print("connect");
5493 if (!lpCmdLine[2]) break;
5494 chuukei_client = TRUE;
5495 connect_chuukei_server(&lpCmdLine[2]);
5503 if (!lpCmdLine[2]) break;
5504 prepare_browse_movie(&lpCmdLine[2]);
5514 /* Did the user double click on a save file? */
5515 if(!chuukei_server) check_for_save_file(lpCmdLine);
5517 /* Did the user double click on a save file? */
5518 check_for_save_file(lpCmdLine);
5521 /* Prompt the user */
5523 prt("[¥Õ¥¡¥¤¥ë] ¥á¥Ë¥å¡¼¤Î [¿·µ¬] ¤Þ¤¿¤Ï [³«¤¯] ¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£", 23, 8);
5525 prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 17);
5530 /* Process messages forever */
5531 while (GetMessage(&msg, NULL, 0, 0))
5533 TranslateMessage(&msg);
5534 DispatchMessage(&msg);
5545 #endif /* WINDOWS */