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];
1236 int wid, hgt, posx, posy;
1237 int dispx = GetSystemMetrics( SM_CXVIRTUALSCREEN);
1238 int dispy = GetSystemMetrics( SM_CYVIRTUALSCREEN);
1242 /* Make section name */
1243 sprintf(sec_name, "Term-%d", i);
1245 /* Make section name */
1246 sprintf(sec_name, "Term-%d", i);
1251 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
1254 /* Desired font, with default */
1256 GetPrivateProfileString(sec_name, "Font", "£Í£Ó ¥´¥·¥Ã¥¯", tmp, 127, ini_file);
1259 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
1261 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
1267 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
1269 /* Analyze font, save desired font name */
1270 #if 1 /* #ifdef JP */
1271 td->font_want = string_make(tmp);
1273 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
1274 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
1275 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
1277 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
1282 #if 1 /* #ifdef JP */
1283 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
1284 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
1286 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
1287 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
1292 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
1293 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
1294 normsize.x = td->cols; normsize.y = td->rows;
1299 win_maximized = GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file);
1302 /* Window position */
1303 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
1304 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
1305 td->pos_x = MIN(MAX(0, posx), dispx-128);
1306 td->pos_y = MIN(MAX(0, posy), dispy-128);
1308 /* Window Z position */
1311 td->posfix = GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file);
1319 static void load_prefs(void)
1323 /* Extract the "arg_graphics" flag */
1324 arg_graphics = GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
1326 /* Extract the "arg_bigtile" flag */
1327 arg_bigtile = GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file);
1328 use_bigtile = arg_bigtile;
1330 /* Extract the "arg_sound" flag */
1331 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
1334 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
1335 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
1337 /* Load window prefs */
1338 for (i = 0; i < MAX_TERM_DATA; ++i)
1347 * XXX XXX XXX - Taken from files.c.
1349 * Extract "tokens" from a buffer
1351 * This function uses "whitespace" as delimiters, and treats any amount of
1352 * whitespace as a single delimiter. We will never return any empty tokens.
1353 * When given an empty buffer, or a buffer containing only "whitespace", we
1354 * will return no tokens. We will never extract more than "num" tokens.
1356 * By running a token through the "text_to_ascii()" function, you can allow
1357 * that token to include (encoded) whitespace, using "\s" to encode spaces.
1359 * We save pointers to the tokens in "tokens", and return the number found.
1361 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
1373 /* Skip leading whitespace */
1374 for ( ; *s && isspace(*s); ++s) /* loop */;
1379 /* Find next whitespace, if any */
1380 for (t = s; *t && !isspace(*t); ++t) /* loop */;
1382 /* Nuke and advance (if necessary) */
1383 if (*t) *t++ = '\0';
1385 /* Save the token */
1396 static void load_sound_prefs(void)
1400 char ini_path[1024];
1401 char wav_path[1024];
1402 char *zz[SAMPLE_MAX];
1404 /* Access the sound.cfg */
1405 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
1407 for (i = 0; i < SOUND_MAX; i++)
1409 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
1411 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
1413 for (j = 0; j < num; j++)
1415 /* Access the sound */
1416 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
1418 /* Save the sound filename, if it exists */
1419 if (check_file(wav_path))
1420 sound_file[i][j] = string_make(zz[j]);
1425 #endif /* USE_SOUND */
1428 * Create the new global palette based on the bitmap palette
1429 * (if any), and the standard 16 entry palette derived from
1430 * "win_clr[]" which is used for the basic 16 Angband colors.
1432 * This function is never called before all windows are ready.
1434 * This function returns FALSE if the new palette could not be
1435 * prepared, which should normally be a fatal error. XXX XXX
1437 * Note that only some machines actually use a "palette".
1439 static int new_palette(void)
1447 LPLOGPALETTE pLogPal;
1448 LPPALETTEENTRY lppe;
1453 /* This makes no sense */
1454 if (!paletted) return (TRUE);
1464 /* Check the bitmap palette */
1465 hBmPal = infGraph.hPalette;
1467 /* Use the bitmap */
1470 lppeSize = 256 * sizeof(PALETTEENTRY);
1471 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
1472 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
1473 if ((nEntries == 0) || (nEntries > 220))
1477 plog("²èÌ̤ò16¥Ó¥Ã¥È¤«24¥Ó¥Ã¥È¥«¥é¡¼¥â¡¼¥É¤Ë¤·¤Æ²¼¤µ¤¤¡£");
1479 plog("Please switch to high- or true-color mode.");
1484 rnfree(lppe, lppeSize);
1491 #endif /* USE_GRAPHICS */
1493 /* Size of palette */
1494 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
1496 /* Allocate palette */
1497 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
1500 pLogPal->palVersion = 0x300;
1502 /* Make room for bitmap and normal data */
1503 pLogPal->palNumEntries = nEntries + 16;
1505 /* Save the bitmap data */
1506 for (i = 0; i < nEntries; i++)
1508 pLogPal->palPalEntry[i] = lppe[i];
1511 /* Save the normal data */
1512 for (i = 0; i < 16; i++)
1516 /* Access the entry */
1517 p = &(pLogPal->palPalEntry[i+nEntries]);
1519 /* Save the colors */
1520 p->peRed = GetRValue(win_clr[i]);
1521 p->peGreen = GetGValue(win_clr[i]);
1522 p->peBlue = GetBValue(win_clr[i]);
1524 /* Save the flags */
1525 p->peFlags = PC_NOCOLLAPSE;
1528 /* Free something */
1529 if (lppe) rnfree(lppe, lppeSize);
1531 /* Create a new palette, or fail */
1532 hNewPal = CreatePalette(pLogPal);
1534 if (!hNewPal) quit("¥Ñ¥ì¥Ã¥È¤òºîÀ®¤Ç¤¤Þ¤»¤ó¡ª");
1536 if (!hNewPal) quit("Cannot create palette!");
1540 /* Free the palette */
1541 rnfree(pLogPal, pLogPalSize);
1546 /* Realize the palette */
1548 SelectPalette(hdc, hNewPal, 0);
1549 i = RealizePalette(hdc);
1550 ReleaseDC(td->w, hdc);
1552 if (i == 0) quit("¥Ñ¥ì¥Ã¥È¤ò¥·¥¹¥Æ¥à¥¨¥ó¥È¥ê¤Ë¥Þ¥Ã¥×¤Ç¤¤Þ¤»¤ó¡ª");
1554 if (i == 0) quit("Cannot realize palette!");
1559 for (i = 1; i < MAX_TERM_DATA; i++)
1564 SelectPalette(hdc, hNewPal, 0);
1565 ReleaseDC(td->w, hdc);
1568 /* Delete old palette */
1569 if (hPal) DeleteObject(hPal);
1571 /* Save new palette */
1581 * Initialize graphics
1583 static bool init_graphics(void)
1585 /* Initialize once */
1586 /* if (can_use_graphics != arg_graphics) */
1592 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1599 ANGBAND_GRAF = "new";
1607 ANGBAND_GRAF = "old";
1610 /* Access the bitmap file */
1611 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
1613 /* Load the bitmap or quit */
1614 if (!ReadDIB(data[0].w, buf, &infGraph))
1617 plog_fmt("¥Ó¥Ã¥È¥Þ¥Ã¥× '%s' ¤òÆɤ߹þ¤á¤Þ¤»¤ó¡£", name);
1619 plog_fmt("Cannot read bitmap file '%s'", name);
1625 /* Save the new sizes */
1626 infGraph.CellWidth = wid;
1627 infGraph.CellHeight = hgt;
1629 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1631 /* Access the mask file */
1632 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
1634 /* Load the bitmap or quit */
1635 if (!ReadDIB(data[0].w, buf, &infMask))
1637 plog_fmt("Cannot read bitmap file '%s'", buf);
1642 /* Activate a palette */
1645 /* Free bitmap XXX XXX XXX */
1649 plog("¥Ñ¥ì¥Ã¥È¤ò¼Â¸½¤Ç¤¤Þ¤»¤ó¡ª");
1651 plog("Cannot activate palette!");
1657 /* Graphics available */
1658 can_use_graphics = arg_graphics;
1662 return (can_use_graphics);
1664 #endif /* USE_GRAPHICS */
1671 static bool init_sound(void)
1673 /* Initialize once */
1676 /* Load the prefs */
1679 /* Sound available */
1680 can_use_sound = TRUE;
1684 return (can_use_sound);
1686 #endif /* USE_SOUND */
1692 static void term_window_resize(term_data *td)
1694 /* Require window */
1697 /* Resize the window */
1698 SetWindowPos(td->w, 0, 0, 0,
1699 td->size_wid, td->size_hgt,
1700 SWP_NOMOVE | SWP_NOZORDER);
1703 InvalidateRect(td->w, NULL, TRUE);
1708 * Force the use of a new "font file" for a term_data
1710 * This function may be called before the "window" is ready
1712 * This function returns zero only if everything succeeds.
1714 * Note that the "font name" must be capitalized!!!
1716 static errr term_force_font(term_data *td, cptr path)
1720 #if 0 /* #ifndef JP */
1726 /* Forget the old font (if needed) */
1727 if (td->font_id) DeleteObject(td->font_id);
1729 #if 1 /* #ifdef JP */
1733 /* Create the font (using the 'base' of the font file name!) */
1734 td->font_id = CreateFontIndirect(&(td->lf));
1735 wid = td->lf.lfWidth;
1736 hgt = td->lf.lfHeight;
1737 if (!td->font_id) return (1);
1739 /* Forget old font */
1745 for (i = 0; i < MAX_TERM_DATA; i++)
1747 /* Don't check when closing the application */
1750 /* Check "screen" */
1751 if ((td != &data[i]) &&
1752 (data[i].font_file) &&
1753 (streq(data[i].font_file, td->font_file)))
1759 /* Remove unused font resources */
1760 if (!used) RemoveFontResource(td->font_file);
1762 /* Free the old name */
1763 string_free(td->font_file);
1766 td->font_file = NULL;
1770 if (!path) return (1);
1775 /* Analyze font path */
1776 base = analyze_font(buf, &wid, &hgt);
1779 if (!suffix(base, ".FON")) return (1);
1782 if (!check_file(buf)) return (1);
1784 /* Load the new font */
1785 if (!AddFontResource(buf)) return (1);
1787 /* Save new font name */
1788 td->font_file = string_make(base);
1790 /* Remove the "suffix" */
1791 base[strlen(base)-4] = '\0';
1793 /* Create the font (using the 'base' of the font file name!) */
1794 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
1795 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
1796 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
1797 FIXED_PITCH | FF_DONTCARE, base);
1800 /* Hack -- Unknown size */
1807 /* all this trouble to get the cell size */
1808 hdcDesktop = GetDC(HWND_DESKTOP);
1809 hfOld = SelectObject(hdcDesktop, td->font_id);
1810 GetTextMetrics(hdcDesktop, &tm);
1811 SelectObject(hdcDesktop, hfOld);
1812 ReleaseDC(HWND_DESKTOP, hdcDesktop);
1814 /* Font size info */
1815 wid = tm.tmAveCharWidth;
1819 /* Save the size info */
1830 * Allow the user to change the font for this window.
1832 static void term_change_font(term_data *td)
1834 #if 1 /* #ifdef JP */
1837 memset(&cf, 0, sizeof(cf));
1838 cf.lStructSize = sizeof(cf);
1839 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
1840 cf.lpLogFont = &(td->lf);
1842 if (ChooseFont(&cf))
1844 /* Force the font */
1845 term_force_font(td, NULL);
1847 /* Assume not bizarre */
1850 /* Reset the tile info */
1851 td->tile_wid = td->font_wid;
1852 td->tile_hgt = td->font_hgt;
1854 /* Analyze the font */
1857 /* Resize the window */
1858 term_window_resize(td);
1864 char tmp[1024] = "";
1866 /* Extract a default if possible */
1867 if (td->font_file) strcpy(tmp, td->font_file);
1869 /* Ask for a choice */
1870 memset(&ofn, 0, sizeof(ofn));
1871 ofn.lStructSize = sizeof(ofn);
1872 ofn.hwndOwner = data[0].w;
1873 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
1874 ofn.nFilterIndex = 1;
1875 ofn.lpstrFile = tmp;
1877 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
1878 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
1879 ofn.lpstrDefExt = "fon";
1881 /* Force choice if legal */
1882 if (GetOpenFileName(&ofn))
1884 /* Force the font */
1885 if (term_force_font(td, tmp))
1887 /* Access the standard font file */
1888 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
1890 /* Force the use of that font */
1891 (void)term_force_font(td, tmp);
1894 /* Assume not bizarre */
1895 td->bizarre = FALSE;
1897 /* Reset the tile info */
1898 td->tile_wid = td->font_wid;
1899 td->tile_hgt = td->font_hgt;
1901 /* Analyze the font */
1904 /* Resize the window */
1905 term_window_resize(td);
1912 * Allow the user to lock this window.
1914 static void term_window_pos(term_data *td, HWND hWnd)
1916 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
1917 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1920 static void windows_map(void);
1923 * Hack -- redraw a term_data
1925 static void term_data_redraw(term_data *td)
1929 /* Redraw the map */
1934 /* Activate the term */
1935 Term_activate(&td->t);
1937 /* Redraw the contents */
1940 /* Restore the term */
1941 Term_activate(term_screen);
1946 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
1950 HBRUSH myBrush, oldBrush;
1952 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
1953 int tx = td->size_ow1 + x * td->tile_wid;
1954 int ty = td->size_oh1 + y * td->tile_hgt;
1955 int tw = w * td->tile_wid - 1;
1956 int th = h * td->tile_hgt - 1;
1959 myBrush = CreateSolidBrush(RGB(255, 255, 255));
1960 oldBrush = SelectObject(hdc, myBrush);
1961 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
1963 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
1965 SelectObject(hdc, oldBrush);
1966 SelectObject(hdc, oldPen);
1971 /*** Function hooks needed by "Term" ***/
1977 * Initialize a new Term
1979 static void Term_init_win(term *t)
1988 static void Term_nuke_win(term *t)
1997 * Interact with the User
1999 static errr Term_user_win(int n)
2010 * React to global changes
2012 static errr Term_xtra_win_react(void)
2020 /* Save the default colors */
2021 for (i = 0; i < 256; i++)
2023 /* Simply accept the desired colors */
2024 win_pal[i] = angband_color_table[i][0];
2035 bool change = FALSE;
2037 /* Save the default colors */
2038 for (i = 0; i < 256; i++)
2040 /* Extract desired values */
2041 rv = angband_color_table[i][1];
2042 gv = angband_color_table[i][2];
2043 bv = angband_color_table[i][3];
2045 /* Extract a full color code */
2046 code = PALETTERGB(rv, gv, bv);
2048 /* Activate changes */
2049 if (win_clr[i] != code)
2051 /* Note the change */
2054 /* Apply the desired color */
2059 /* Activate the palette if needed */
2060 if (change) (void)new_palette();
2066 /* Handle "arg_sound" */
2067 if (use_sound != arg_sound)
2069 /* Initialize (if needed) */
2070 if (arg_sound && !init_sound())
2074 plog("¥µ¥¦¥ó¥É¤ò½é´ü²½¤Ç¤¤Þ¤»¤ó¡ª");
2076 plog("Cannot initialize sound!");
2084 /* Change setting */
2085 use_sound = arg_sound;
2093 /* Handle "arg_graphics" */
2094 if (use_graphics != arg_graphics)
2096 /* Initialize (if needed) */
2097 if (arg_graphics && !init_graphics())
2101 plog("¥°¥é¥Õ¥£¥Ã¥¯¥¹¤ò½é´ü²½¤Ç¤¤Þ¤»¤ó!");
2103 plog("Cannot initialize graphics!");
2108 arg_graphics = GRAPHICS_NONE;
2111 /* Change setting */
2112 use_graphics = arg_graphics;
2115 #ifdef ANGBAND_2_8_1
2117 #else /* ANGBAND_2_8_1 */
2118 reset_visuals(TRUE);
2119 #endif /* ANGBAND_2_8_1 */
2122 #endif /* USE_GRAPHICS */
2125 /* Clean up windows */
2126 for (i = 0; i < MAX_TERM_DATA; i++)
2130 term_data *td = &data[i];
2132 /* Update resized windows */
2133 if ((td->cols != (uint)td->t.wid) || (td->rows != (uint)td->t.hgt))
2136 Term_activate(&td->t);
2138 /* Hack -- Resize the term */
2139 Term_resize(td->cols, td->rows);
2141 /* Redraw the contents */
2156 * Process at least one event
2158 static errr Term_xtra_win_event(int v)
2162 /* Wait for an event */
2166 if (GetMessage(&msg, NULL, 0, 0))
2168 TranslateMessage(&msg);
2169 DispatchMessage(&msg);
2173 /* Check for an event */
2177 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2179 TranslateMessage(&msg);
2180 DispatchMessage(&msg);
2190 * Process all pending events
2192 static errr Term_xtra_win_flush(void)
2196 /* Process all pending events */
2197 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2199 TranslateMessage(&msg);
2200 DispatchMessage(&msg);
2209 * Hack -- clear the screen
2211 * Make this more efficient XXX XXX XXX
2213 static errr Term_xtra_win_clear(void)
2215 term_data *td = (term_data*)(Term->data);
2220 /* Rectangle to erase */
2221 rc.left = td->size_ow1;
2222 rc.right = rc.left + td->cols * td->tile_wid;
2223 rc.top = td->size_oh1;
2224 rc.bottom = rc.top + td->rows * td->tile_hgt;
2228 SetBkColor(hdc, RGB(0, 0, 0));
2229 SelectObject(hdc, td->font_id);
2230 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2235 rc.left = 0; rc.top = 0;
2238 ReleaseDC(td->w, hdc);
2246 * Hack -- make a noise
2248 static errr Term_xtra_win_noise(void)
2250 MessageBeep(MB_ICONASTERISK);
2256 * Hack -- make a sound
2258 static errr Term_xtra_win_sound(int v)
2263 #endif /* USE_SOUND */
2265 /* Sound disabled */
2266 if (!use_sound) return (1);
2269 if ((v < 0) || (v >= SOUND_MAX)) return (1);
2273 /* Count the samples */
2274 for (i = 0; i < SAMPLE_MAX; i++)
2276 if (!sound_file[v][i])
2281 if (i == 0) return (1);
2283 /* Build the path */
2284 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
2288 /* Play the sound, catch errors */
2289 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
2293 /* Play the sound, catch errors */
2294 return (sndPlaySound(buf, SND_ASYNC));
2298 #else /* USE_SOUND */
2303 #endif /* USE_SOUND */
2308 * Delay for "x" milliseconds
2310 static int Term_xtra_win_delay(int v)
2324 t = GetTickCount() + v;
2327 while (GetTickCount() < t)
2329 /* Handle messages */
2330 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2332 TranslateMessage(&msg);
2333 DispatchMessage(&msg);
2345 * Do a "special thing"
2347 static errr Term_xtra_win(int n, int v)
2349 /* Handle a subset of the legal requests */
2352 /* Make a bell sound */
2353 case TERM_XTRA_NOISE:
2355 return (Term_xtra_win_noise());
2358 /* Make a special sound */
2359 case TERM_XTRA_SOUND:
2361 return (Term_xtra_win_sound(v));
2364 /* Process random events */
2365 case TERM_XTRA_BORED:
2367 return (Term_xtra_win_event(0));
2370 /* Process an event */
2371 case TERM_XTRA_EVENT:
2373 return (Term_xtra_win_event(v));
2376 /* Flush all events */
2377 case TERM_XTRA_FLUSH:
2379 return (Term_xtra_win_flush());
2382 /* Clear the screen */
2383 case TERM_XTRA_CLEAR:
2385 return (Term_xtra_win_clear());
2388 /* React to global changes */
2389 case TERM_XTRA_REACT:
2391 return (Term_xtra_win_react());
2394 /* Delay for some milliseconds */
2395 case TERM_XTRA_DELAY:
2397 return (Term_xtra_win_delay(v));
2408 * Low level graphics (Assumes valid input).
2410 * Draw a "cursor" at (x,y), using a "yellow box".
2412 static errr Term_curs_win(int x, int y)
2414 term_data *td = (term_data*)(Term->data);
2419 int tile_wid, tile_hgt;
2423 tile_wid = td->map_tile_wid;
2424 tile_hgt = td->map_tile_hgt;
2428 tile_wid = td->tile_wid;
2429 tile_hgt = td->tile_hgt;
2432 /* Frame the grid */
2433 rc.left = x * tile_wid + td->size_ow1;
2434 rc.right = rc.left + tile_wid;
2435 rc.top = y * tile_hgt + td->size_oh1;
2436 rc.bottom = rc.top + tile_hgt;
2438 /* Cursor is done as a yellow "box" */
2440 FrameRect(hdc, &rc, hbrYellow);
2441 ReleaseDC(td->w, hdc);
2449 * Low level graphics (Assumes valid input).
2451 * Draw a "big cursor" at (x,y), using a "yellow box".
2453 static errr Term_bigcurs_win(int x, int y)
2455 term_data *td = (term_data*)(Term->data);
2460 int tile_wid, tile_hgt;
2464 /* Normal cursor in map window */
2465 Term_curs_win(x, y);
2470 tile_wid = td->tile_wid;
2471 tile_hgt = td->tile_hgt;
2474 /* Frame the grid */
2475 rc.left = x * tile_wid + td->size_ow1;
2476 rc.right = rc.left + 2 * tile_wid;
2477 rc.top = y * tile_hgt + td->size_oh1;
2478 rc.bottom = rc.top + tile_hgt;
2480 /* Cursor is done as a yellow "box" */
2482 FrameRect(hdc, &rc, hbrYellow);
2483 ReleaseDC(td->w, hdc);
2491 * Low level graphics (Assumes valid input).
2493 * Erase a "block" of "n" characters starting at (x,y).
2495 static errr Term_wipe_win(int x, int y, int n)
2497 term_data *td = (term_data*)(Term->data);
2502 /* Rectangle to erase in client coords */
2503 rc.left = x * td->tile_wid + td->size_ow1;
2504 rc.right = rc.left + n * td->tile_wid;
2505 rc.top = y * td->tile_hgt + td->size_oh1;
2506 rc.bottom = rc.top + td->tile_hgt;
2509 SetBkColor(hdc, RGB(0, 0, 0));
2510 SelectObject(hdc, td->font_id);
2515 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2516 ReleaseDC(td->w, hdc);
2524 * Low level graphics. Assumes valid input.
2526 * Draw several ("n") chars, with an attr, at a given location.
2528 * All "graphic" data is handled by "Term_pict_win()", below.
2530 * One would think there is a more efficient method for telling a window
2531 * what color it should be using to draw with, but perhaps simply changing
2532 * it every time is not too inefficient. XXX XXX XXX
2534 static errr Term_text_win(int x, int y, int n, byte a, const char *s)
2536 term_data *td = (term_data*)(Term->data);
2540 #if 1 /* #ifdef JP */
2541 static HBITMAP WALL;
2542 static HBRUSH myBrush, oldBrush;
2544 static bool init_done = FALSE;
2547 WALL = LoadBitmap(hInstance, AppName);
2548 myBrush = CreatePatternBrush(WALL);
2553 /* Total rectangle */
2554 rc.left = x * td->tile_wid + td->size_ow1;
2555 rc.right = rc.left + n * td->tile_wid;
2556 rc.top = y * td->tile_hgt + td->size_oh1;
2557 rc.bottom = rc.top + td->tile_hgt;
2562 /* Background color */
2563 SetBkColor(hdc, RGB(0, 0, 0));
2565 /* Foreground color */
2568 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
2572 SetTextColor(hdc, win_clr[a&0x0F]);
2576 SetTextColor(hdc, win_clr[a]);
2580 SelectObject(hdc, td->font_id);
2583 if (use_bg) SetBkMode(hdc, TRANSPARENT);
2587 (td->tile_hgt != td->font_hgt) ||
2588 (td->tile_wid != td->font_wid))
2592 /* Erase complete rectangle */
2593 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2596 if (use_bg) DrawBG(hdc, &rc);
2599 rc.left += ((td->tile_wid - td->font_wid) / 2);
2600 rc.right = rc.left + td->font_wid;
2601 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
2602 rc.bottom = rc.top + td->font_hgt;
2604 /* Dump each character */
2605 for (i = 0; i < n; i++)
2608 if (use_bigtile && *(s+i)=="¢£"[0] && *(s+i+1)=="¢£"[1])
2610 rc.right += td->font_wid;
2612 oldBrush = SelectObject(hdc, myBrush);
2613 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2616 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2618 SelectObject(hdc, oldBrush);
2619 SelectObject(hdc, oldPen);
2620 rc.right -= td->font_wid;
2624 rc.left += 2 * td->tile_wid;
2625 rc.right += 2 * td->tile_wid;
2627 else if ( iskanji(*(s+i)) ) /* £²¥Ð¥¤¥Èʸ»ú */
2629 rc.right += td->font_wid;
2631 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2633 rc.right -= td->font_wid;
2637 rc.left += 2 * td->tile_wid;
2638 rc.right += 2 * td->tile_wid;
2639 } else if (*(s+i)==127){
2640 oldBrush = SelectObject(hdc, myBrush);
2641 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2644 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2646 SelectObject(hdc, oldBrush);
2647 SelectObject(hdc, oldPen);
2650 rc.left += td->tile_wid;
2651 rc.right += td->tile_wid;
2654 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
2657 rc.left += td->tile_wid;
2658 rc.right += td->tile_wid;
2663 oldBrush = SelectObject(hdc, myBrush);
2664 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2667 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2669 SelectObject(hdc, oldBrush);
2670 SelectObject(hdc, oldPen);
2673 rc.left += td->tile_wid;
2674 rc.right += td->tile_wid;
2677 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2681 rc.left += td->tile_wid;
2682 rc.right += td->tile_wid;
2686 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
2690 rc.left += td->tile_wid;
2691 rc.right += td->tile_wid;
2702 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
2707 ReleaseDC(td->w, hdc);
2715 * Low level graphics. Assumes valid input.
2717 * Draw an array of "special" attr/char pairs at the given location.
2719 * We use the "Term_pict_win()" function for "graphic" data, which are
2720 * encoded by setting the "high-bits" of both the "attr" and the "char"
2721 * data. We use the "attr" to represent the "row" of the main bitmap,
2722 * and the "char" to represent the "col" of the main bitmap. The use
2723 * of this function is induced by the "higher_pict" flag.
2725 * If "graphics" is not available, we simply "wipe" the given grids.
2727 static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
2729 term_data *td = (term_data*)(Term->data);
2735 int x2, y2, w2, h2, tw2;
2747 /* Erase the grids */
2748 return (Term_wipe_win(x, y, n));
2751 /* Size of bitmap cell */
2752 w1 = infGraph.CellWidth;
2753 h1 = infGraph.CellHeight;
2755 /* Size of window cell */
2758 w2 = td->map_tile_wid;
2759 h2 = td->map_tile_hgt;
2768 if (use_bigtile) tw2 *= 2;
2771 /* Location of window cell */
2772 x2 = x * w2 + td->size_ow1;
2773 y2 = y * h2 + td->size_oh1;
2779 hdcSrc = CreateCompatibleDC(hdc);
2780 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
2782 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2784 hdcMask = CreateCompatibleDC(hdc);
2785 SelectObject(hdcMask, infMask.hBitmap);
2788 /* Draw attr/char pairs */
2789 for (i = 0; i < n; i++, x2 += w2)
2794 /* Extract picture */
2795 int row = (a & 0x7F);
2796 int col = (c & 0x7F);
2798 /* Location of bitmap cell */
2802 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2804 x3 = (tcp[i] & 0x7F) * w1;
2805 y3 = (tap[i] & 0x7F) * h1;
2808 if ((w1 == tw2) && (h1 == h2))
2810 /* Copy the terrain picture from the bitmap to the window */
2811 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
2813 /* Mask out the tile */
2814 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
2817 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
2820 /* Need to stretch */
2823 /* Set the correct mode for stretching the tiles */
2824 SetStretchBltMode(hdc, COLORONCOLOR);
2826 /* Copy the terrain picture from the bitmap to the window */
2827 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCCOPY);
2829 /* Only draw if terrain and overlay are different */
2830 if ((x1 != x3) || (y1 != y3))
2832 /* Mask out the tile */
2833 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
2836 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
2843 if ((w1 == tw2) && (h1 == h2))
2845 /* Copy the picture from the bitmap to the window */
2846 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
2849 /* Need to stretch */
2852 /* Set the correct mode for stretching the tiles */
2853 SetStretchBltMode(hdc, COLORONCOLOR);
2855 /* Copy the picture from the bitmap to the window */
2856 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
2862 SelectObject(hdcSrc, hbmSrcOld);
2865 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2868 SelectObject(hdcMask, hbmSrcOld);
2873 ReleaseDC(td->w, hdc);
2875 #else /* USE_GRAPHICS */
2877 /* Just erase this grid */
2878 return (Term_wipe_win(x, y, n));
2880 #endif /* USE_GRAPHICS */
2887 static void windows_map(void)
2889 term_data *td = &data[0];
2891 int x, min_x, max_x;
2892 int y, min_y, max_y;
2896 /* Only in graphics mode */
2897 if (!use_graphics) return;
2900 Term_xtra_win_clear();
2902 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
2903 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
2904 td->map_active = TRUE;
2914 for (x = min_x; x < max_x; x++)
2916 for (y = min_y; y < max_y; y++)
2918 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
2920 /* Ignore non-graphics */
2921 if ((a & 0x80) && (c & 0x80))
2923 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
2928 /* Hilite the player */
2929 Term_curs_win(px - min_x, py - min_y);
2931 /* Wait for a keypress, flush key buffer */
2932 Term_inkey(&c, TRUE, TRUE);
2935 /* Switch off the map display */
2936 td->map_active = FALSE;
2938 /* Restore screen */
2939 Term_xtra_win_clear();
2944 /*** Other routines ***/
2948 * Create and initialize a "term_data" given a title
2950 static void term_data_link(term_data *td)
2954 /* Initialize the term */
2955 term_init(t, td->cols, td->rows, td->keys);
2957 /* Use a "software" cursor */
2958 t->soft_cursor = TRUE;
2960 /* Use "Term_pict" for "graphic" data */
2961 t->higher_pict = TRUE;
2963 /* Erase with "white space" */
2964 t->attr_blank = TERM_WHITE;
2965 t->char_blank = ' ';
2968 /* Prepare the init/nuke hooks */
2969 t->init_hook = Term_init_win;
2970 t->nuke_hook = Term_nuke_win;
2973 /* Prepare the template hooks */
2974 t->user_hook = Term_user_win;
2975 t->xtra_hook = Term_xtra_win;
2976 t->curs_hook = Term_curs_win;
2977 t->bigcurs_hook = Term_bigcurs_win;
2978 t->wipe_hook = Term_wipe_win;
2979 t->text_hook = Term_text_win;
2980 t->pict_hook = Term_pict_win;
2982 /* Remember where we came from */
2983 t->data = (vptr)(td);
2988 * Create the windows
2990 * First, instantiate the "default" values, then read the "ini_file"
2991 * to over-ride selected values, then create the windows, and fonts.
2993 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
2994 * must make active to realize the palette. XXX XXX XXX
2996 static void init_windows(void)
3002 #if 0 /* #ifndef JP */
3008 WIPE(td, term_data);
3012 td->s = angband_term_name[0];
3026 #if 1 /* #ifdef JP */
3030 for (i = 1; i < MAX_TERM_DATA; i++)
3033 WIPE(td, term_data);
3034 td->s = angband_term_name[i];
3038 td->visible = FALSE;
3043 td->pos_x = (7 - i) * 30;
3044 td->pos_y = (7 - i) * 20;
3046 #if 1 /* #ifdef JP */
3056 /* Main window (need these before term_getsize gets called) */
3058 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
3059 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
3064 /* Sub windows (need these before term_getsize gets called) */
3065 for (i = 1; i < MAX_TERM_DATA; i++)
3068 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
3069 td->dwExStyle = (WS_EX_TOOLWINDOW);
3074 for (i = 0; i < MAX_TERM_DATA; i++)
3078 #if 1 /* #ifdef JP */
3079 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
3080 td->lf.lfCharSet = DEFAULT_CHARSET;
3081 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
3082 /* Activate the chosen font */
3083 term_force_font(td, NULL);
3084 td->tile_wid = td->font_wid;
3085 td->tile_hgt = td->font_hgt;
3087 /* Access the standard font file */
3088 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
3090 /* Activate the chosen font */
3091 if (term_force_font(td, buf))
3093 /* Access the standard font file */
3094 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
3096 /* Force the use of that font */
3097 (void)term_force_font(td, buf);
3103 /* Assume not bizarre */
3104 td->bizarre = FALSE;
3109 /* Analyze the font */
3112 /* Resize the window */
3113 term_window_resize(td);
3117 /* Sub windows (reverse order) */
3118 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
3123 td->w = CreateWindowEx(td->dwExStyle, AngList,
3125 td->pos_x, td->pos_y,
3126 td->size_wid, td->size_hgt,
3127 HWND_DESKTOP, NULL, hInstance, NULL);
3130 if (!td->w) quit("¥µ¥Ö¥¦¥£¥ó¥É¥¦¤ËºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿");
3132 if (!td->w) quit("Failed to create sub-window");
3138 td->size_hack = TRUE;
3139 ShowWindow(td->w, SW_SHOW);
3140 td->size_hack = FALSE;
3144 angband_term[i] = &td->t;
3148 /* Activate the window */
3149 SetActiveWindow(td->w);
3154 term_window_pos(&data[i], HWND_TOPMOST);
3158 term_window_pos(&data[i], td->w);
3168 td->w = CreateWindowEx(td->dwExStyle, AppName,
3170 td->pos_x, td->pos_y,
3171 td->size_wid, td->size_hgt,
3172 HWND_DESKTOP, NULL, hInstance, NULL);
3175 if (!td->w) quit("¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿");
3177 if (!td->w) quit("Failed to create Angband window");
3182 angband_term[0] = &td->t;
3183 normsize.x = td->cols;
3184 normsize.y = td->rows;
3186 /* Activate the main window */
3187 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
3188 else ShowWindow(td->w, SW_SHOW);
3190 /* Bring main window back to top */
3191 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
3194 /* New palette XXX XXX XXX */
3195 (void)new_palette();
3198 /* Create a "brush" for drawing the "cursor" */
3199 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
3202 /* Process pending messages */
3203 (void)Term_xtra_win_flush();
3211 static void setup_menus(void)
3215 HMENU hm = GetMenu(data[0].w);
3218 /* Menu "File", Disable all */
3219 EnableMenuItem(hm, IDM_FILE_NEW,
3220 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3221 EnableMenuItem(hm, IDM_FILE_OPEN,
3222 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3223 EnableMenuItem(hm, IDM_FILE_SAVE,
3224 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3225 EnableMenuItem(hm, IDM_FILE_EXIT,
3226 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3227 EnableMenuItem(hm, IDM_FILE_SCORE,
3228 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3231 /* No character available */
3232 if (!character_generated)
3234 /* Menu "File", Item "New" */
3235 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
3237 /* Menu "File", Item "Open" */
3238 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
3241 /* A character available */
3242 if (character_generated)
3244 /* Menu "File", Item "Save" */
3245 EnableMenuItem(hm, IDM_FILE_SAVE,
3246 MF_BYCOMMAND | MF_ENABLED);
3249 /* Menu "File", Item "Exit" */
3250 EnableMenuItem(hm, IDM_FILE_EXIT,
3251 MF_BYCOMMAND | MF_ENABLED);
3253 EnableMenuItem(hm, IDM_FILE_SCORE,
3254 MF_BYCOMMAND | MF_ENABLED);
3257 /* Menu "Window::Visibility" */
3258 for (i = 0; i < MAX_TERM_DATA; i++)
3260 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3261 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3263 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3264 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
3266 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3267 MF_BYCOMMAND | MF_ENABLED);
3270 /* Menu "Window::Font" */
3271 for (i = 0; i < MAX_TERM_DATA; i++)
3273 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3274 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3276 if (data[i].visible)
3278 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3279 MF_BYCOMMAND | MF_ENABLED);
3283 /* Menu "Window::Window Position Fix" */
3284 for (i = 0; i < MAX_TERM_DATA; i++)
3286 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3287 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3289 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
3290 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
3292 if (data[i].visible)
3294 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3295 MF_BYCOMMAND | MF_ENABLED);
3299 /* Menu "Window::Bizarre Display" */
3300 for (i = 0; i < MAX_TERM_DATA; i++)
3302 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3303 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3305 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3306 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
3308 if (data[i].visible)
3310 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3311 MF_BYCOMMAND | MF_ENABLED);
3316 /* Menu "Window::Increase Tile Width" */
3317 for (i = 0; i < MAX_TERM_DATA; i++)
3319 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3320 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3322 if (data[i].visible)
3324 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3325 MF_BYCOMMAND | MF_ENABLED);
3330 /* Menu "Window::Decrease Tile Width" */
3331 for (i = 0; i < MAX_TERM_DATA; i++)
3333 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3334 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3336 if (data[i].visible)
3338 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3339 MF_BYCOMMAND | MF_ENABLED);
3344 /* Menu "Window::Increase Tile Height" */
3345 for (i = 0; i < MAX_TERM_DATA; i++)
3347 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3348 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3350 if (data[i].visible)
3352 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3353 MF_BYCOMMAND | MF_ENABLED);
3358 /* Menu "Window::Decrease Tile Height" */
3359 for (i = 0; i < MAX_TERM_DATA; i++)
3361 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3362 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3364 if (data[i].visible)
3366 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3367 MF_BYCOMMAND | MF_ENABLED);
3372 /* Menu "Options", disable all */
3373 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3374 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3375 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3376 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3377 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3378 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3379 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
3380 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3381 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
3382 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3384 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3385 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3388 /* Menu "Options", Item "Map" */
3389 if (use_graphics != GRAPHICS_NONE)
3390 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
3392 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
3393 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3395 /* Menu "Options", update all */
3396 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3397 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
3398 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3399 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
3400 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3401 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
3402 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
3403 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
3404 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
3405 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
3406 CheckMenuItem(hm, IDM_OPTIONS_BG,
3407 (use_bg ? MF_CHECKED : MF_UNCHECKED));
3409 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
3410 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
3414 /* Menu "Options", Item "Graphics" */
3415 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
3416 /* Menu "Options", Item "Graphics" */
3417 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
3418 /* Menu "Options", Item "Graphics" */
3419 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
3420 /* Menu "Options", Item "Graphics" */
3421 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
3422 #endif /* USE_GRAPHICS */
3425 /* Menu "Options", Item "Sound" */
3426 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
3427 #endif /* USE_SOUND */
3430 /* Menu "Options", Item "ScreenSaver" */
3431 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3432 MF_BYCOMMAND | MF_ENABLED);
3433 #endif /* USE_SAVER */
3438 * Check for double clicked (or dragged) savefile
3440 * Apparently, Windows copies the entire filename into the first
3441 * piece of the "command line string". Perhaps we should extract
3442 * the "basename" of that filename and append it to the "save" dir.
3444 static void check_for_save_file(LPSTR cmd_line)
3454 /* Extract filename */
3455 strcat(savefile, s);
3457 /* Validate the file */
3458 validate_file(savefile);
3460 /* Game in progress */
3461 game_in_progress = TRUE;
3469 * Process a menu command
3471 static void process_menus(WORD wCmd)
3488 plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
3490 plog("You cannot do that yet...");
3494 else if (game_in_progress)
3497 plog("¥×¥ì¥¤Ãæ¤Ï¿·¤·¤¤¥²¡¼¥à¤ò»Ï¤á¤ë¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
3499 plog("You can't start a new game while you're still playing!");
3505 game_in_progress = TRUE;
3519 plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
3521 plog("You cannot do that yet...");
3525 else if (game_in_progress)
3528 plog("¥×¥ì¥¤Ãæ¤Ï¥²¡¼¥à¤ò¥í¡¼¥É¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
3530 plog("You can't open a new game while you're still playing!");
3536 memset(&ofn, 0, sizeof(ofn));
3537 ofn.lStructSize = sizeof(ofn);
3538 ofn.hwndOwner = data[0].w;
3539 ofn.lpstrFilter = "Save Files (*.)\0*\0";
3540 ofn.nFilterIndex = 1;
3541 ofn.lpstrFile = savefile;
3542 ofn.nMaxFile = 1024;
3543 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
3544 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
3546 if (GetOpenFileName(&ofn))
3548 /* Load 'savefile' */
3549 validate_file(savefile);
3550 game_in_progress = TRUE;
3562 if (game_in_progress && character_generated)
3568 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3570 plog("You may not do that right now.");
3576 /* Hack -- Forget messages */
3581 do_cmd_save_game(FALSE);
3582 #else /* ZANGBAND */
3584 #endif /* ZANGBAND */
3589 plog("º£¡¢¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3591 plog("You may not do that right now.");
3601 if (game_in_progress && character_generated)
3607 plog("º£¤Ï½ªÎ»¤Ç¤¤Þ¤»¤ó¡£");
3609 plog("You may not do that right now.");
3615 /* Hack -- Forget messages */
3624 /* do_cmd_save_game(FALSE); */
3625 #else /* ZANGBAND */
3626 /* do_cmd_save_game(); */
3627 #endif /* ZANGBAND */
3628 Term_key_push(SPECIAL_KEY_QUIT);
3636 case IDM_FILE_SCORE:
3640 /* Build the filename */
3641 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
3643 /* Open the binary high score file, for reading */
3644 highscore_fd = fd_open(buf, O_RDONLY);
3646 /* Paranoia -- No score file */
3647 if (highscore_fd < 0)
3649 msg_print("Score file unavailable.");
3659 /* Display the scores */
3660 display_scores_aux(0, MAX_HISCORES, -1, NULL);
3662 /* Shut the high score file */
3663 (void)fd_close(highscore_fd);
3665 /* Forget the high score fd */
3671 /* Hack - Flush it */
3679 case IDM_FILE_MOVIE:
3684 plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
3686 plog("You cannot do that yet...");
3689 else if (game_in_progress)
3692 plog("¥×¥ì¥¤Ãæ¤Ï¥à¡¼¥Ó¡¼¤ò¥í¡¼¥É¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
3694 plog("You can't open a movie while you're playing!");
3699 memset(&ofn, 0, sizeof(ofn));
3700 ofn.lStructSize = sizeof(ofn);
3701 ofn.hwndOwner = data[0].w;
3702 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
3703 ofn.nFilterIndex = 1;
3704 ofn.lpstrFile = savefile;
3705 ofn.nMaxFile = 1024;
3706 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
3707 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
3709 if (GetOpenFileName(&ofn))
3711 /* Load 'savefile' */
3712 prepare_browse_movie_aux(savefile);
3722 case IDM_WINDOW_VIS_0:
3725 plog("¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤ÏÈóɽ¼¨¤Ë¤Ç¤¤Þ¤»¤ó¡ª");
3727 plog("You are not allowed to do that!");
3734 /* Window visibility */
3735 case IDM_WINDOW_VIS_1:
3736 case IDM_WINDOW_VIS_2:
3737 case IDM_WINDOW_VIS_3:
3738 case IDM_WINDOW_VIS_4:
3739 case IDM_WINDOW_VIS_5:
3740 case IDM_WINDOW_VIS_6:
3741 case IDM_WINDOW_VIS_7:
3743 i = wCmd - IDM_WINDOW_VIS_0;
3745 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3752 ShowWindow(td->w, SW_SHOW);
3753 term_data_redraw(td);
3757 td->visible = FALSE;
3759 ShowWindow(td->w, SW_HIDE);
3766 case IDM_WINDOW_FONT_0:
3767 case IDM_WINDOW_FONT_1:
3768 case IDM_WINDOW_FONT_2:
3769 case IDM_WINDOW_FONT_3:
3770 case IDM_WINDOW_FONT_4:
3771 case IDM_WINDOW_FONT_5:
3772 case IDM_WINDOW_FONT_6:
3773 case IDM_WINDOW_FONT_7:
3775 i = wCmd - IDM_WINDOW_FONT_0;
3777 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3781 term_change_font(td);
3786 /* Window Z Position */
3787 case IDM_WINDOW_POS_1:
3788 case IDM_WINDOW_POS_2:
3789 case IDM_WINDOW_POS_3:
3790 case IDM_WINDOW_POS_4:
3791 case IDM_WINDOW_POS_5:
3792 case IDM_WINDOW_POS_6:
3793 case IDM_WINDOW_POS_7:
3795 i = wCmd - IDM_WINDOW_POS_0;
3797 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3801 if (!td->posfix && td->visible)
3804 term_window_pos(td, HWND_TOPMOST);
3809 term_window_pos(td, data[0].w);
3815 /* Bizarre Display */
3816 case IDM_WINDOW_BIZ_0:
3817 case IDM_WINDOW_BIZ_1:
3818 case IDM_WINDOW_BIZ_2:
3819 case IDM_WINDOW_BIZ_3:
3820 case IDM_WINDOW_BIZ_4:
3821 case IDM_WINDOW_BIZ_5:
3822 case IDM_WINDOW_BIZ_6:
3823 case IDM_WINDOW_BIZ_7:
3825 i = wCmd - IDM_WINDOW_BIZ_0;
3827 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3831 td->bizarre = !td->bizarre;
3835 term_window_resize(td);
3840 /* Increase Tile Width */
3841 case IDM_WINDOW_I_WID_0:
3842 case IDM_WINDOW_I_WID_1:
3843 case IDM_WINDOW_I_WID_2:
3844 case IDM_WINDOW_I_WID_3:
3845 case IDM_WINDOW_I_WID_4:
3846 case IDM_WINDOW_I_WID_5:
3847 case IDM_WINDOW_I_WID_6:
3848 case IDM_WINDOW_I_WID_7:
3850 i = wCmd - IDM_WINDOW_I_WID_0;
3852 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3860 term_window_resize(td);
3865 /* Decrease Tile Height */
3866 case IDM_WINDOW_D_WID_0:
3867 case IDM_WINDOW_D_WID_1:
3868 case IDM_WINDOW_D_WID_2:
3869 case IDM_WINDOW_D_WID_3:
3870 case IDM_WINDOW_D_WID_4:
3871 case IDM_WINDOW_D_WID_5:
3872 case IDM_WINDOW_D_WID_6:
3873 case IDM_WINDOW_D_WID_7:
3875 i = wCmd - IDM_WINDOW_D_WID_0;
3877 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3885 term_window_resize(td);
3890 /* Increase Tile Height */
3891 case IDM_WINDOW_I_HGT_0:
3892 case IDM_WINDOW_I_HGT_1:
3893 case IDM_WINDOW_I_HGT_2:
3894 case IDM_WINDOW_I_HGT_3:
3895 case IDM_WINDOW_I_HGT_4:
3896 case IDM_WINDOW_I_HGT_5:
3897 case IDM_WINDOW_I_HGT_6:
3898 case IDM_WINDOW_I_HGT_7:
3900 i = wCmd - IDM_WINDOW_I_HGT_0;
3902 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3910 term_window_resize(td);
3915 /* Decrease Tile Height */
3916 case IDM_WINDOW_D_HGT_0:
3917 case IDM_WINDOW_D_HGT_1:
3918 case IDM_WINDOW_D_HGT_2:
3919 case IDM_WINDOW_D_HGT_3:
3920 case IDM_WINDOW_D_HGT_4:
3921 case IDM_WINDOW_D_HGT_5:
3922 case IDM_WINDOW_D_HGT_6:
3923 case IDM_WINDOW_D_HGT_7:
3925 i = wCmd - IDM_WINDOW_D_HGT_0;
3927 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3935 term_window_resize(td);
3940 case IDM_OPTIONS_NO_GRAPHICS:
3945 plog("You may not do that right now.");
3949 /* Toggle "arg_graphics" */
3950 if (arg_graphics != GRAPHICS_NONE)
3952 arg_graphics = GRAPHICS_NONE;
3954 /* React to changes */
3955 Term_xtra_win_react();
3957 /* Hack -- Force redraw */
3958 Term_key_push(KTRL('R'));
3964 case IDM_OPTIONS_OLD_GRAPHICS:
3969 plog("You may not do that right now.");
3973 /* Toggle "arg_graphics" */
3974 if (arg_graphics != GRAPHICS_ORIGINAL)
3976 arg_graphics = GRAPHICS_ORIGINAL;
3978 /* React to changes */
3979 Term_xtra_win_react();
3981 /* Hack -- Force redraw */
3982 Term_key_push(KTRL('R'));
3988 case IDM_OPTIONS_NEW_GRAPHICS:
3993 plog("You may not do that right now.");
3997 /* Toggle "arg_graphics" */
3998 if (arg_graphics != GRAPHICS_ADAM_BOLT)
4000 arg_graphics = GRAPHICS_ADAM_BOLT;
4002 /* React to changes */
4003 Term_xtra_win_react();
4005 /* Hack -- Force redraw */
4006 Term_key_push(KTRL('R'));
4012 case IDM_OPTIONS_BIGTILE:
4014 term_data *td = &data[0];
4019 plog("You may not do that right now.");
4023 /* Toggle "arg_sound" */
4024 arg_bigtile = !arg_bigtile;
4027 Term_activate(&td->t);
4029 /* Resize the term */
4030 Term_resize(td->cols, td->rows);
4033 InvalidateRect(td->w, NULL, TRUE);
4038 case IDM_OPTIONS_SOUND:
4043 plog("You may not do that right now.");
4047 /* Toggle "arg_sound" */
4048 arg_sound = !arg_sound;
4050 /* React to changes */
4051 Term_xtra_win_react();
4053 /* Hack -- Force redraw */
4054 Term_key_push(KTRL('R'));
4060 case IDM_OPTIONS_BG:
4065 plog("You may not do that right now.");
4069 /* Toggle "use_bg" */
4074 /* React to changes */
4075 Term_xtra_win_react();
4077 /* Hack -- Force redraw */
4078 Term_key_push(KTRL('R'));
4084 case IDM_OPTIONS_OPEN_BG:
4089 plog("You may not do that right now.");
4094 memset(&ofn, 0, sizeof(ofn));
4095 ofn.lStructSize = sizeof(ofn);
4096 ofn.hwndOwner = data[0].w;
4097 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
4098 ofn.nFilterIndex = 1;
4099 ofn.lpstrFile = bg_bitmap_file;
4100 ofn.nMaxFile = 1023;
4101 ofn.lpstrInitialDir = NULL;
4103 ofn.lpstrTitle = "ÊÉ»æ¤òÁª¤ó¤Ç¤Í¡£";
4105 ofn.lpstrTitle = "Choose wall paper.";
4107 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
4109 if (GetOpenFileName(&ofn))
4111 /* Load 'savefile' */
4116 /* React to changes */
4117 Term_xtra_win_react();
4119 /* Hack -- Force redraw */
4120 Term_key_push(KTRL('R'));
4125 case IDM_DUMP_SCREEN_HTML:
4127 static char buf[1024] = "";
4128 memset(&ofn, 0, sizeof(ofn));
4129 ofn.lStructSize = sizeof(ofn);
4130 ofn.hwndOwner = data[0].w;
4131 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
4132 ofn.nFilterIndex = 1;
4133 ofn.lpstrFile = buf;
4134 ofn.nMaxFile = 1023;
4135 ofn.lpstrDefExt = "html";
4136 ofn.lpstrInitialDir = NULL;
4138 ofn.lpstrTitle = "HTML¤Ç¥¹¥¯¥ê¡¼¥ó¥À¥ó¥×¤òÊݸ";
4140 ofn.lpstrTitle = "Save screen dump as HTML.";
4142 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
4144 if (GetSaveFileName(&ofn))
4146 do_cmd_save_screen_html_aux(buf, 0);
4153 case IDM_OPTIONS_SAVER:
4157 DestroyWindow(hwndSaver);
4162 /* Create a screen scaver window */
4163 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
4164 "Angband Screensaver",
4165 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
4166 0, 0, GetSystemMetrics(SM_CXSCREEN),
4167 GetSystemMetrics(SM_CYSCREEN),
4168 NULL, NULL, hInstance, NULL);
4172 /* Push the window to the bottom XXX XXX XXX */
4173 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
4178 plog("¥¦¥£¥ó¥É¥¦¤òºîÀ®½ÐÍè¤Þ¤»¤ó");
4180 plog("Failed to create saver window");
4190 case IDM_OPTIONS_MAP:
4196 case IDM_HELP_CONTENTS:
4200 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
4201 if (check_file(tmp))
4203 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
4208 plog_fmt("¥Ø¥ë¥×¥Õ¥¡¥¤¥ë[%s]¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó¡£", tmp);
4209 plog("Âå¤ï¤ê¤Ë¥ª¥ó¥é¥¤¥ó¥Ø¥ë¥×¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£");
4211 plog_fmt("Cannot find help file: %s", tmp);
4212 plog("Use the online help files instead.");
4217 #else /* HTML_HELP */
4220 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
4221 if (check_file(tmp))
4223 sprintf(buf, "winhelp.exe %s", tmp);
4224 WinExec(buf, SW_NORMAL);
4229 plog_fmt("¥Ø¥ë¥×¥Õ¥¡¥¤¥ë[%s]¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó¡£", tmp);
4230 plog("Âå¤ï¤ê¤Ë¥ª¥ó¥é¥¤¥ó¥Ø¥ë¥×¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£");
4232 plog_fmt("Cannot find help file: %s", tmp);
4233 plog("Use the online help files instead.");
4238 #endif /* HTML_HELP */
4244 static bool process_keydown(WPARAM wParam, LPARAM lParam)
4251 /* Extract the modifiers */
4252 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
4253 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
4254 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
4256 Term_no_press = (ma) ? TRUE : FALSE;
4258 /* Handle "special" keys */
4259 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
4261 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
4262 bool numpad = FALSE;
4264 /* Begin the macro trigger */
4267 /* Send the modifiers */
4268 if (mc) Term_keypress('C');
4269 if (ms) Term_keypress('S');
4270 if (ma) Term_keypress('A');
4272 /* Extract "scan code" */
4273 i = LOBYTE(HIWORD(lParam));
4275 /* Introduce the scan code */
4278 /* Extended key bit */
4281 /* Numpad Enter and '/' are extended key */
4283 Term_no_press = TRUE;
4284 case VK_RETURN: /* Enter */
4287 /* Other extended keys are on full keyboard */
4303 Term_no_press = TRUE;
4307 case VK_PRIOR: /* Page Up */
4308 case VK_NEXT: /* Page Down */
4318 /* Special modifiers for keypad keys */
4319 if (numpad) Term_keypress('K');
4321 /* Encode the hexidecimal scan code */
4322 Term_keypress(hexsym[i/16]);
4323 Term_keypress(hexsym[i%16]);
4325 /* End the macro trigger */
4336 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4337 WPARAM wParam, LPARAM lParam);
4338 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4339 WPARAM wParam, LPARAM lParam)
4340 #else /* __MWERKS__ */
4341 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4342 WPARAM wParam, LPARAM lParam)
4343 #endif /* __MWERKS__ */
4349 MINMAXINFO FAR *lpmmi;
4355 /* Acquire proper "term_data" info */
4356 td = (term_data *)GetWindowLong(hWnd, 0);
4358 /* Handle message */
4364 SetWindowLong(hWnd, 0, (LONG)(my_td));
4374 case WM_GETMINMAXINFO:
4376 MINMAXINFO FAR *lpmmi;
4379 lpmmi = (MINMAXINFO FAR *)lParam;
4381 /* this message was sent before WM_NCCREATE */
4384 /* Minimum window size is 80x24 */
4385 rc.left = rc.top = 0;
4386 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
4387 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4390 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4392 /* Save minimum size */
4393 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4394 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4401 BeginPaint(hWnd, &ps);
4402 if (td) term_data_redraw(td);
4403 EndPaint(hWnd, &ps);
4404 ValidateRect(hWnd, NULL);
4411 if (process_keydown(wParam, lParam))
4418 if (Term_no_press) Term_no_press = FALSE;
4419 else Term_keypress(wParam);
4423 case WM_LBUTTONDOWN:
4425 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
4426 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
4438 int dx = abs(oldx - mousex) + 1;
4439 int dy = abs(oldy - mousey) + 1;
4440 int ox = (oldx > mousex) ? mousex : oldx;
4441 int oy = (oldy > mousey) ? mousey : oldy;
4451 hGlobal = GlobalAlloc(GHND, sz + 1);
4452 if (hGlobal == NULL) return 0;
4453 lpStr = (LPSTR)GlobalLock(hGlobal);
4455 for (i = 0; i < dy; i++)
4459 char **scr = data[0].t.scr->c;
4461 C_MAKE(s, (dx + 1), char);
4462 strncpy(s, &scr[oy + i][ox], dx);
4466 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
4469 if (ox + dx < data[0].cols)
4471 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
4474 for (j = 0; j < dx; j++)
4476 if (s[j] == 127) s[j] = '#';
4480 for (j = 0; j < dx; j++)
4482 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
4492 GlobalUnlock(hGlobal);
4493 if (OpenClipboard(hWnd) == 0)
4495 GlobalFree(hGlobal);
4499 SetClipboardData(CF_TEXT, hGlobal);
4512 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
4513 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
4518 dx = abs(oldx - mousex) + 1;
4519 dy = abs(oldy - mousey) + 1;
4520 ox = (oldx > mousex) ? mousex : oldx;
4521 oy = (oldy > mousey) ? mousey : oldy;
4522 Term_inversed_area(hWnd, ox, oy, dx, dy);
4529 dx = abs(cx - mousex) + 1;
4530 dy = abs(cy - mousey) + 1;
4531 ox = (cx > mousex) ? mousex : cx;
4532 oy = (cy > mousey) ? mousey : cy;
4533 Term_inversed_area(hWnd, ox, oy, dx, dy);
4549 if (game_in_progress && character_generated)
4554 plog("º£¤Ï½ªÎ»¤Ç¤¤Þ¤»¤ó¡£");
4556 plog("You may not do that right now.");
4561 /* Hack -- Forget messages */
4570 /* do_cmd_save_game(FALSE); */
4571 #else /* ZANGBAND */
4572 /* do_cmd_save_game(); */
4573 #endif /* ZANGBAND */
4574 Term_key_push(SPECIAL_KEY_QUIT);
4581 case WM_QUERYENDSESSION:
4583 if (game_in_progress && character_generated)
4585 /* Hack -- Forget messages */
4588 /* Mega-Hack -- Delay death */
4589 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
4592 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
4594 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
4597 /* Hardcode panic save */
4598 p_ptr->panic_save = 1;
4600 /* Forbid suspend */
4601 signals_ignore_tstp();
4603 /* Indicate panic save */
4605 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
4607 (void)strcpy(p_ptr->died_from, "(panic save)");
4611 (void)save_player();
4625 process_menus(LOWORD(wParam));
4631 /* this message was sent before WM_NCCREATE */
4634 /* it was sent from inside CreateWindowEx */
4635 if (!td->w) return 1;
4637 /* was sent from WM_SIZE */
4638 if (td->size_hack) return 1;
4642 case SIZE_MINIMIZED:
4644 /* Hide sub-windows */
4645 for (i = 1; i < MAX_TERM_DATA; i++)
4647 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
4652 case SIZE_MAXIMIZED:
4654 /* fall through XXX XXX XXX */
4659 uint cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4660 uint rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4663 if ((td->cols != cols) || (td->rows != rows))
4665 /* Save the new size */
4669 if (!IsZoomed(td->w) && !IsIconic(td->w))
4671 normsize.x = td->cols;
4672 normsize.y = td->rows;
4676 Term_activate(&td->t);
4678 /* Resize the term */
4679 Term_resize(td->cols, td->rows);
4682 InvalidateRect(td->w, NULL, TRUE);
4685 td->size_hack = TRUE;
4687 /* Show sub-windows */
4688 for (i = 1; i < MAX_TERM_DATA; i++)
4690 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
4693 td->size_hack = FALSE;
4701 case WM_PALETTECHANGED:
4703 /* Ignore if palette change caused by itself */
4704 if ((HWND)wParam == hWnd) return 0;
4706 /* Fall through... */
4709 case WM_QUERYNEWPALETTE:
4711 if (!paletted) return 0;
4715 SelectPalette(hdc, hPal, FALSE);
4717 i = RealizePalette(hdc);
4719 /* if any palette entries changed, repaint the window. */
4720 if (i) InvalidateRect(hWnd, NULL, TRUE);
4722 ReleaseDC(hWnd, hdc);
4729 if (wParam && !HIWORD(lParam))
4731 /* Do something to sub-windows */
4732 for (i = 1; i < MAX_TERM_DATA; i++)
4734 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
4737 /* Focus on main window */
4746 case WM_ACTIVATEAPP:
4748 if (IsIconic(td->w)) break;
4750 for (i = 1; i < MAX_TERM_DATA; i++)
4756 ShowWindow(data[i].w, SW_SHOW);
4760 ShowWindow(data[i].w, SW_HIDE);
4767 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4772 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4773 WPARAM wParam, LPARAM lParam);
4774 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4775 WPARAM wParam, LPARAM lParam)
4776 #else /* __MWERKS__ */
4777 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4778 WPARAM wParam, LPARAM lParam)
4779 #endif /* __MWERKS__ */
4783 MINMAXINFO FAR *lpmmi;
4791 /* Acquire proper "term_data" info */
4792 td = (term_data *)GetWindowLong(hWnd, 0);
4794 /* Process message */
4800 SetWindowLong(hWnd, 0, (LONG)(my_td));
4810 case WM_GETMINMAXINFO:
4812 MINMAXINFO FAR *lpmmi;
4815 lpmmi = (MINMAXINFO FAR *)lParam;
4817 /* this message was sent before WM_NCCREATE */
4820 /* Minimum window size is 80x24 */
4821 rc.left = rc.top = 0;
4822 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
4823 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4826 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4828 /* Save minimum size */
4829 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4830 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4840 /* this message was sent before WM_NCCREATE */
4843 /* it was sent from inside CreateWindowEx */
4844 if (!td->w) return 1;
4846 /* was sent from inside WM_SIZE */
4847 if (td->size_hack) return 1;
4849 td->size_hack = TRUE;
4851 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4852 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4855 if ((td->cols != cols) || (td->rows != rows))
4858 term *old_term = Term;
4860 /* Save the new size */
4865 Term_activate(&td->t);
4867 /* Resize the term */
4868 Term_resize(td->cols, td->rows);
4871 Term_activate(old_term);
4874 InvalidateRect(td->w, NULL, TRUE);
4876 /* HACK - Redraw all windows */
4877 p_ptr->window = 0xFFFFFFFF;
4881 td->size_hack = FALSE;
4888 BeginPaint(hWnd, &ps);
4889 if (td) term_data_redraw(td);
4890 EndPaint(hWnd, &ps);
4897 if (process_keydown(wParam, lParam))
4904 if (Term_no_press) Term_no_press = FALSE;
4905 else Term_keypress(wParam);
4909 case WM_PALETTECHANGED:
4911 /* ignore if palette change caused by itself */
4912 if ((HWND)wParam == hWnd) return FALSE;
4913 /* otherwise, fall through!!! */
4916 case WM_QUERYNEWPALETTE:
4918 if (!paletted) return 0;
4920 SelectPalette(hdc, hPal, FALSE);
4921 i = RealizePalette(hdc);
4922 /* if any palette entries changed, repaint the window. */
4923 if (i) InvalidateRect(hWnd, NULL, TRUE);
4924 ReleaseDC(hWnd, hdc);
4928 case WM_NCLBUTTONDOWN:
4932 if (wParam == HTCLOSE) wParam = HTSYSMENU;
4933 #endif /* HTCLOSE */
4935 if (wParam == HTSYSMENU)
4939 td->visible = FALSE;
4940 ShowWindow(td->w, SW_HIDE);
4950 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4956 #define MOUSE_SENS 40
4959 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4960 WPARAM wParam, LPARAM lParam);
4961 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4962 WPARAM wParam, LPARAM lParam)
4963 #else /* __MWERKS__ */
4964 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4965 WPARAM wParam, LPARAM lParam)
4966 #endif /* __MWERKS__ */
4968 static int iMouse = 0;
4969 static WORD xMouse = 0;
4970 static WORD yMouse = 0;
4993 if (LOWORD(wParam) == WA_INACTIVE) break;
4995 /* else fall through */
4999 case WM_LBUTTONDOWN:
5000 case WM_MBUTTONDOWN:
5001 case WM_RBUTTONDOWN:
5004 SendMessage(hWnd, WM_CLOSE, 0, 0);
5012 dx = LOWORD(lParam) - xMouse;
5013 dy = HIWORD(lParam) - yMouse;
5015 if (dx < 0) dx = -dx;
5016 if (dy < 0) dy = -dy;
5018 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
5020 SendMessage(hWnd, WM_CLOSE, 0, 0);
5024 /* Save last location */
5026 xMouse = LOWORD(lParam);
5027 yMouse = HIWORD(lParam);
5034 DestroyWindow(hwndSaver);
5041 return DefWindowProc(hWnd, uMsg, wParam, lParam);
5044 #endif /* USE_SAVER */
5050 /*** Temporary Hooks ***/
5054 * Display warning message (see "z-util.c")
5056 static void hack_plog(cptr str)
5058 /* Give a warning */
5062 MessageBox(NULL, str, "·Ù¹ð¡ª",
5063 MB_ICONEXCLAMATION | MB_OK);
5065 MessageBox(NULL, str, "Warning",
5066 MB_ICONEXCLAMATION | MB_OK);
5074 * Display error message and quit (see "z-util.c")
5076 static void hack_quit(cptr str)
5078 /* Give a warning */
5082 MessageBox(NULL, str, "¥¨¥é¡¼¡ª",
5083 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5085 MessageBox(NULL, str, "Error",
5086 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5091 /* Unregister the classes */
5092 UnregisterClass(AppName, hInstance);
5094 /* Destroy the icon */
5095 if (hIcon) DestroyIcon(hIcon);
5103 /*** Various hooks ***/
5107 * Display warning message (see "z-util.c")
5109 static void hook_plog(cptr str)
5115 MessageBox(data[0].w, str, "·Ù¹ð¡ª",
5116 MB_ICONEXCLAMATION | MB_OK);
5118 MessageBox(data[0].w, str, "Warning",
5119 MB_ICONEXCLAMATION | MB_OK);
5127 * Display error message and quit (see "z-util.c")
5129 static void hook_quit(cptr str)
5134 /* Give a warning */
5138 MessageBox(data[0].w, str, "¥¨¥é¡¼¡ª",
5139 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5141 MessageBox(data[0].w, str, "Error",
5142 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5148 /* Save the preferences */
5152 /*** Could use 'Term_nuke_win()' XXX XXX XXX */
5154 /* Destroy all windows */
5155 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
5157 term_force_font(&data[i], NULL);
5158 if (data[i].font_want) string_free(data[i].font_want);
5159 if (data[i].w) DestroyWindow(data[i].w);
5163 /* Free the bitmap stuff */
5165 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
5166 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
5168 if (infMask.hPalette) DeleteObject(infMask.hPalette);
5169 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
5171 #endif /* USE_GRAPHICS */
5173 /*** Free some other stuff ***/
5175 DeleteObject(hbrYellow);
5180 if (hPal) DeleteObject(hPal);
5182 UnregisterClass(AppName, hInstance);
5184 if (hIcon) DestroyIcon(hIcon);
5191 /*** Initialize ***/
5197 static void init_stuff(void)
5204 /* Get program name with full path */
5205 GetModuleFileName(hInstance, path, 512);
5207 /* Save the "program name" XXX XXX XXX */
5210 /* Get the name of the "*.ini" file */
5211 strcpy(path + strlen(path) - 4, ".INI");
5213 /* Save the the name of the ini-file */
5214 ini_file = string_make(path);
5216 /* Analyze the path */
5222 if (path[i] == '\\')
5229 /* Add "lib" to the path */
5230 strcpy(path + i + 1, "lib\\");
5232 /* Validate the path */
5233 validate_dir(path, TRUE);
5235 /* Init the file paths */
5236 init_file_paths(path);
5238 /* Hack -- Validate the paths */
5239 validate_dir(ANGBAND_DIR_APEX, FALSE);
5240 validate_dir(ANGBAND_DIR_BONE, FALSE);
5242 /* Allow missing 'edit' directory */
5243 if (!check_dir(ANGBAND_DIR_EDIT))
5245 /* Must have 'data'! */
5246 validate_dir(ANGBAND_DIR_DATA, TRUE);
5250 /* Don't need 'data' */
5251 validate_dir(ANGBAND_DIR_DATA, FALSE);
5254 validate_dir(ANGBAND_DIR_FILE, TRUE);
5255 validate_dir(ANGBAND_DIR_HELP, FALSE);
5256 validate_dir(ANGBAND_DIR_INFO, FALSE);
5257 validate_dir(ANGBAND_DIR_PREF, TRUE);
5258 validate_dir(ANGBAND_DIR_SAVE, FALSE);
5259 validate_dir(ANGBAND_DIR_USER, TRUE);
5260 validate_dir(ANGBAND_DIR_XTRA, TRUE);
5262 /* Build the filename */
5264 path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news_j.txt");
5266 path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news.txt");
5270 /* Hack -- Validate the "news.txt" file */
5271 validate_file(path);
5274 #if 0 /* #ifndef JP */
5275 /* Build the "font" path */
5276 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
5278 /* Allocate the path */
5279 ANGBAND_DIR_XTRA_FONT = string_make(path);
5281 /* Validate the "font" directory */
5282 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
5284 /* Build the filename */
5285 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
5287 /* Hack -- Validate the basic font */
5288 validate_file(path);
5294 /* Build the "graf" path */
5295 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
5297 /* Allocate the path */
5298 ANGBAND_DIR_XTRA_GRAF = string_make(path);
5300 /* Validate the "graf" directory */
5301 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
5303 #endif /* USE_GRAPHICS */
5308 /* Build the "sound" path */
5309 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
5311 /* Allocate the path */
5312 ANGBAND_DIR_XTRA_SOUND = string_make(path);
5314 /* Validate the "sound" directory */
5315 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
5317 #endif /* USE_SOUND */
5321 /* Build the "music" path */
5322 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
5324 /* Allocate the path */
5325 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
5327 /* Validate the "music" directory */
5328 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
5330 #endif /* USE_MUSIC */
5332 /* Build the "help" path */
5333 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
5335 /* Allocate the path */
5336 ANGBAND_DIR_XTRA_HELP = string_make(path);
5338 /* Validate the "help" directory */
5339 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
5343 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
5344 LPSTR lpCmdLine, int nCmdShow)
5359 if (hPrevInst == NULL)
5361 wc.style = CS_CLASSDC;
5362 wc.lpfnWndProc = AngbandWndProc;
5364 wc.cbWndExtra = 4; /* one long pointer to term_data */
5365 wc.hInstance = hInst;
5366 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
5367 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
5368 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
5369 wc.lpszMenuName = AppName;
5370 wc.lpszClassName = AppName;
5372 if (!RegisterClass(&wc)) exit(1);
5374 wc.lpfnWndProc = AngbandListProc;
5375 wc.lpszMenuName = NULL;
5376 wc.lpszClassName = AngList;
5378 if (!RegisterClass(&wc)) exit(2);
5382 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
5383 wc.lpfnWndProc = AngbandSaverProc;
5385 wc.lpszMenuName = NULL;
5386 wc.lpszClassName = "WindowsScreenSaverClass";
5388 if (!RegisterClass(&wc)) exit(3);
5394 /* Temporary hooks */
5395 plog_aux = hack_plog;
5396 quit_aux = hack_quit;
5397 core_aux = hack_quit;
5399 /* Prepare the filepaths */
5402 /* Initialize the keypress analyzer */
5403 for (i = 0; special_key_list[i]; ++i)
5405 special_key[special_key_list[i]] = TRUE;
5407 /* Initialize the keypress analyzer */
5408 for (i = 0; ignore_key_list[i]; ++i)
5410 ignore_key[ignore_key_list[i]] = TRUE;
5413 /* Determine if display is 16/256/true color */
5415 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
5416 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
5417 ReleaseDC(NULL, hdc);
5419 /* Initialize the colors */
5420 for (i = 0; i < 256; i++)
5424 /* Extract desired values */
5425 rv = angband_color_table[i][1];
5426 gv = angband_color_table[i][2];
5427 bv = angband_color_table[i][3];
5429 /* Extract the "complex" code */
5430 win_clr[i] = PALETTERGB(rv, gv, bv);
5432 /* Save the "simple" code */
5433 angband_color_table[i][0] = win_pal[i];
5436 /* Prepare the windows */
5442 /* Activate hooks */
5443 plog_aux = hook_plog;
5444 quit_aux = hook_quit;
5445 core_aux = hook_quit;
5447 /* Set the system suffix */
5448 ANGBAND_SYS = "win";
5450 /* Set the keyboard suffix */
5451 if (7 != GetKeyboardType(0))
5452 ANGBAND_KEYBOARD = "0";
5455 /* Japanese keyboard */
5456 switch (GetKeyboardType(1))
5458 case 0x0D01: case 0x0D02:
5459 case 0x0D03: case 0x0D04:
5460 case 0x0D05: case 0x0D06:
5462 ANGBAND_KEYBOARD = "NEC98";
5466 ANGBAND_KEYBOARD = "JAPAN";
5470 /* Catch nasty signals */
5476 /* We are now initialized */
5479 if(lpCmdLine[0] == '-'){
5480 switch(lpCmdLine[1])
5485 if (!lpCmdLine[2]) break;
5486 chuukei_server = TRUE;
5487 if(connect_chuukei_server(&lpCmdLine[2])<0){
5488 msg_print("connect fail");
5491 msg_print("connect");
5499 if (!lpCmdLine[2]) break;
5500 chuukei_client = TRUE;
5501 connect_chuukei_server(&lpCmdLine[2]);
5509 if (!lpCmdLine[2]) break;
5510 prepare_browse_movie(&lpCmdLine[2]);
5520 /* Did the user double click on a save file? */
5521 if(!chuukei_server) check_for_save_file(lpCmdLine);
5523 /* Did the user double click on a save file? */
5524 check_for_save_file(lpCmdLine);
5527 /* Prompt the user */
5529 prt("[¥Õ¥¡¥¤¥ë] ¥á¥Ë¥å¡¼¤Î [¿·µ¬] ¤Þ¤¿¤Ï [³«¤¯] ¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£", 23, 8);
5531 prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 17);
5536 /* Process messages forever */
5537 while (GetMessage(&msg, NULL, 0, 0))
5539 TranslateMessage(&msg);
5540 DispatchMessage(&msg);
5551 #endif /* WINDOWS */