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);
1240 /* Make section name */
1241 sprintf(sec_name, "Term-%d", i);
1243 /* Make section name */
1244 sprintf(sec_name, "Term-%d", i);
1249 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
1252 /* Desired font, with default */
1254 GetPrivateProfileString(sec_name, "Font", "£Í£Ó ¥´¥·¥Ã¥¯", tmp, 127, ini_file);
1257 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
1259 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
1265 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
1267 /* Analyze font, save desired font name */
1268 #if 1 /* #ifdef JP */
1269 td->font_want = string_make(tmp);
1271 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
1272 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
1273 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
1275 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
1280 #if 1 /* #ifdef JP */
1281 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
1282 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
1284 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
1285 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
1290 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
1291 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
1292 normsize.x = td->cols; normsize.y = td->rows;
1297 win_maximized = GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file);
1300 /* Window position */
1301 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
1302 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
1303 td->pos_x = MIN(MAX(0, posx), dispx-128);
1304 td->pos_y = MIN(MAX(0, posy), dispy-128);
1306 /* Window Z position */
1309 td->posfix = GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file);
1317 static void load_prefs(void)
1321 /* Extract the "arg_graphics" flag */
1322 arg_graphics = GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
1324 /* Extract the "arg_bigtile" flag */
1325 arg_bigtile = GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file);
1326 use_bigtile = arg_bigtile;
1328 /* Extract the "arg_sound" flag */
1329 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
1332 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
1333 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
1335 /* Load window prefs */
1336 for (i = 0; i < MAX_TERM_DATA; ++i)
1345 * XXX XXX XXX - Taken from files.c.
1347 * Extract "tokens" from a buffer
1349 * This function uses "whitespace" as delimiters, and treats any amount of
1350 * whitespace as a single delimiter. We will never return any empty tokens.
1351 * When given an empty buffer, or a buffer containing only "whitespace", we
1352 * will return no tokens. We will never extract more than "num" tokens.
1354 * By running a token through the "text_to_ascii()" function, you can allow
1355 * that token to include (encoded) whitespace, using "\s" to encode spaces.
1357 * We save pointers to the tokens in "tokens", and return the number found.
1359 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
1371 /* Skip leading whitespace */
1372 for ( ; *s && isspace(*s); ++s) /* loop */;
1377 /* Find next whitespace, if any */
1378 for (t = s; *t && !isspace(*t); ++t) /* loop */;
1380 /* Nuke and advance (if necessary) */
1381 if (*t) *t++ = '\0';
1383 /* Save the token */
1394 static void load_sound_prefs(void)
1398 char ini_path[1024];
1399 char wav_path[1024];
1400 char *zz[SAMPLE_MAX];
1402 /* Access the sound.cfg */
1403 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
1405 for (i = 0; i < SOUND_MAX; i++)
1407 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
1409 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
1411 for (j = 0; j < num; j++)
1413 /* Access the sound */
1414 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
1416 /* Save the sound filename, if it exists */
1417 if (check_file(wav_path))
1418 sound_file[i][j] = string_make(zz[j]);
1423 #endif /* USE_SOUND */
1426 * Create the new global palette based on the bitmap palette
1427 * (if any), and the standard 16 entry palette derived from
1428 * "win_clr[]" which is used for the basic 16 Angband colors.
1430 * This function is never called before all windows are ready.
1432 * This function returns FALSE if the new palette could not be
1433 * prepared, which should normally be a fatal error. XXX XXX
1435 * Note that only some machines actually use a "palette".
1437 static int new_palette(void)
1445 LPLOGPALETTE pLogPal;
1446 LPPALETTEENTRY lppe;
1451 /* This makes no sense */
1452 if (!paletted) return (TRUE);
1462 /* Check the bitmap palette */
1463 hBmPal = infGraph.hPalette;
1465 /* Use the bitmap */
1468 lppeSize = 256 * sizeof(PALETTEENTRY);
1469 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
1470 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
1471 if ((nEntries == 0) || (nEntries > 220))
1475 plog("²èÌ̤ò16¥Ó¥Ã¥È¤«24¥Ó¥Ã¥È¥«¥é¡¼¥â¡¼¥É¤Ë¤·¤Æ²¼¤µ¤¤¡£");
1477 plog("Please switch to high- or true-color mode.");
1482 rnfree(lppe, lppeSize);
1489 #endif /* USE_GRAPHICS */
1491 /* Size of palette */
1492 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
1494 /* Allocate palette */
1495 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
1498 pLogPal->palVersion = 0x300;
1500 /* Make room for bitmap and normal data */
1501 pLogPal->palNumEntries = nEntries + 16;
1503 /* Save the bitmap data */
1504 for (i = 0; i < nEntries; i++)
1506 pLogPal->palPalEntry[i] = lppe[i];
1509 /* Save the normal data */
1510 for (i = 0; i < 16; i++)
1514 /* Access the entry */
1515 p = &(pLogPal->palPalEntry[i+nEntries]);
1517 /* Save the colors */
1518 p->peRed = GetRValue(win_clr[i]);
1519 p->peGreen = GetGValue(win_clr[i]);
1520 p->peBlue = GetBValue(win_clr[i]);
1522 /* Save the flags */
1523 p->peFlags = PC_NOCOLLAPSE;
1526 /* Free something */
1527 if (lppe) rnfree(lppe, lppeSize);
1529 /* Create a new palette, or fail */
1530 hNewPal = CreatePalette(pLogPal);
1532 if (!hNewPal) quit("¥Ñ¥ì¥Ã¥È¤òºîÀ®¤Ç¤¤Þ¤»¤ó¡ª");
1534 if (!hNewPal) quit("Cannot create palette!");
1538 /* Free the palette */
1539 rnfree(pLogPal, pLogPalSize);
1544 /* Realize the palette */
1546 SelectPalette(hdc, hNewPal, 0);
1547 i = RealizePalette(hdc);
1548 ReleaseDC(td->w, hdc);
1550 if (i == 0) quit("¥Ñ¥ì¥Ã¥È¤ò¥·¥¹¥Æ¥à¥¨¥ó¥È¥ê¤Ë¥Þ¥Ã¥×¤Ç¤¤Þ¤»¤ó¡ª");
1552 if (i == 0) quit("Cannot realize palette!");
1557 for (i = 1; i < MAX_TERM_DATA; i++)
1562 SelectPalette(hdc, hNewPal, 0);
1563 ReleaseDC(td->w, hdc);
1566 /* Delete old palette */
1567 if (hPal) DeleteObject(hPal);
1569 /* Save new palette */
1579 * Initialize graphics
1581 static bool init_graphics(void)
1583 /* Initialize once */
1584 /* if (can_use_graphics != arg_graphics) */
1590 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1597 ANGBAND_GRAF = "new";
1605 ANGBAND_GRAF = "old";
1608 /* Access the bitmap file */
1609 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
1611 /* Load the bitmap or quit */
1612 if (!ReadDIB(data[0].w, buf, &infGraph))
1615 plog_fmt("¥Ó¥Ã¥È¥Þ¥Ã¥× '%s' ¤òÆɤ߹þ¤á¤Þ¤»¤ó¡£", name);
1617 plog_fmt("Cannot read bitmap file '%s'", name);
1623 /* Save the new sizes */
1624 infGraph.CellWidth = wid;
1625 infGraph.CellHeight = hgt;
1627 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1629 /* Access the mask file */
1630 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
1632 /* Load the bitmap or quit */
1633 if (!ReadDIB(data[0].w, buf, &infMask))
1635 plog_fmt("Cannot read bitmap file '%s'", buf);
1640 /* Activate a palette */
1643 /* Free bitmap XXX XXX XXX */
1647 plog("¥Ñ¥ì¥Ã¥È¤ò¼Â¸½¤Ç¤¤Þ¤»¤ó¡ª");
1649 plog("Cannot activate palette!");
1655 /* Graphics available */
1656 can_use_graphics = arg_graphics;
1660 return (can_use_graphics);
1662 #endif /* USE_GRAPHICS */
1669 static bool init_sound(void)
1671 /* Initialize once */
1674 /* Load the prefs */
1677 /* Sound available */
1678 can_use_sound = TRUE;
1682 return (can_use_sound);
1684 #endif /* USE_SOUND */
1690 static void term_window_resize(term_data *td)
1692 /* Require window */
1695 /* Resize the window */
1696 SetWindowPos(td->w, 0, 0, 0,
1697 td->size_wid, td->size_hgt,
1698 SWP_NOMOVE | SWP_NOZORDER);
1701 InvalidateRect(td->w, NULL, TRUE);
1706 * Force the use of a new "font file" for a term_data
1708 * This function may be called before the "window" is ready
1710 * This function returns zero only if everything succeeds.
1712 * Note that the "font name" must be capitalized!!!
1714 static errr term_force_font(term_data *td, cptr path)
1718 #if 0 /* #ifndef JP */
1724 /* Forget the old font (if needed) */
1725 if (td->font_id) DeleteObject(td->font_id);
1727 #if 1 /* #ifdef JP */
1731 /* Create the font (using the 'base' of the font file name!) */
1732 td->font_id = CreateFontIndirect(&(td->lf));
1733 wid = td->lf.lfWidth;
1734 hgt = td->lf.lfHeight;
1735 if (!td->font_id) return (1);
1737 /* Forget old font */
1743 for (i = 0; i < MAX_TERM_DATA; i++)
1745 /* Don't check when closing the application */
1748 /* Check "screen" */
1749 if ((td != &data[i]) &&
1750 (data[i].font_file) &&
1751 (streq(data[i].font_file, td->font_file)))
1757 /* Remove unused font resources */
1758 if (!used) RemoveFontResource(td->font_file);
1760 /* Free the old name */
1761 string_free(td->font_file);
1764 td->font_file = NULL;
1768 if (!path) return (1);
1773 /* Analyze font path */
1774 base = analyze_font(buf, &wid, &hgt);
1777 if (!suffix(base, ".FON")) return (1);
1780 if (!check_file(buf)) return (1);
1782 /* Load the new font */
1783 if (!AddFontResource(buf)) return (1);
1785 /* Save new font name */
1786 td->font_file = string_make(base);
1788 /* Remove the "suffix" */
1789 base[strlen(base)-4] = '\0';
1791 /* Create the font (using the 'base' of the font file name!) */
1792 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
1793 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
1794 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
1795 FIXED_PITCH | FF_DONTCARE, base);
1798 /* Hack -- Unknown size */
1805 /* all this trouble to get the cell size */
1806 hdcDesktop = GetDC(HWND_DESKTOP);
1807 hfOld = SelectObject(hdcDesktop, td->font_id);
1808 GetTextMetrics(hdcDesktop, &tm);
1809 SelectObject(hdcDesktop, hfOld);
1810 ReleaseDC(HWND_DESKTOP, hdcDesktop);
1812 /* Font size info */
1813 wid = tm.tmAveCharWidth;
1817 /* Save the size info */
1828 * Allow the user to change the font for this window.
1830 static void term_change_font(term_data *td)
1832 #if 1 /* #ifdef JP */
1835 memset(&cf, 0, sizeof(cf));
1836 cf.lStructSize = sizeof(cf);
1837 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
1838 cf.lpLogFont = &(td->lf);
1840 if (ChooseFont(&cf))
1842 /* Force the font */
1843 term_force_font(td, NULL);
1845 /* Assume not bizarre */
1848 /* Reset the tile info */
1849 td->tile_wid = td->font_wid;
1850 td->tile_hgt = td->font_hgt;
1852 /* Analyze the font */
1855 /* Resize the window */
1856 term_window_resize(td);
1862 char tmp[1024] = "";
1864 /* Extract a default if possible */
1865 if (td->font_file) strcpy(tmp, td->font_file);
1867 /* Ask for a choice */
1868 memset(&ofn, 0, sizeof(ofn));
1869 ofn.lStructSize = sizeof(ofn);
1870 ofn.hwndOwner = data[0].w;
1871 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
1872 ofn.nFilterIndex = 1;
1873 ofn.lpstrFile = tmp;
1875 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
1876 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
1877 ofn.lpstrDefExt = "fon";
1879 /* Force choice if legal */
1880 if (GetOpenFileName(&ofn))
1882 /* Force the font */
1883 if (term_force_font(td, tmp))
1885 /* Access the standard font file */
1886 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
1888 /* Force the use of that font */
1889 (void)term_force_font(td, tmp);
1892 /* Assume not bizarre */
1893 td->bizarre = FALSE;
1895 /* Reset the tile info */
1896 td->tile_wid = td->font_wid;
1897 td->tile_hgt = td->font_hgt;
1899 /* Analyze the font */
1902 /* Resize the window */
1903 term_window_resize(td);
1910 * Allow the user to lock this window.
1912 static void term_window_pos(term_data *td, HWND hWnd)
1914 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
1915 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1918 static void windows_map(void);
1921 * Hack -- redraw a term_data
1923 static void term_data_redraw(term_data *td)
1927 /* Redraw the map */
1932 /* Activate the term */
1933 Term_activate(&td->t);
1935 /* Redraw the contents */
1938 /* Restore the term */
1939 Term_activate(term_screen);
1944 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
1948 HBRUSH myBrush, oldBrush;
1950 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
1951 int tx = td->size_ow1 + x * td->tile_wid;
1952 int ty = td->size_oh1 + y * td->tile_hgt;
1953 int tw = w * td->tile_wid - 1;
1954 int th = h * td->tile_hgt - 1;
1957 myBrush = CreateSolidBrush(RGB(255, 255, 255));
1958 oldBrush = SelectObject(hdc, myBrush);
1959 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
1961 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
1963 SelectObject(hdc, oldBrush);
1964 SelectObject(hdc, oldPen);
1969 /*** Function hooks needed by "Term" ***/
1975 * Initialize a new Term
1977 static void Term_init_win(term *t)
1986 static void Term_nuke_win(term *t)
1995 * Interact with the User
1997 static errr Term_user_win(int n)
2008 * React to global changes
2010 static errr Term_xtra_win_react(void)
2018 /* Save the default colors */
2019 for (i = 0; i < 256; i++)
2021 /* Simply accept the desired colors */
2022 win_pal[i] = angband_color_table[i][0];
2033 bool change = FALSE;
2035 /* Save the default colors */
2036 for (i = 0; i < 256; i++)
2038 /* Extract desired values */
2039 rv = angband_color_table[i][1];
2040 gv = angband_color_table[i][2];
2041 bv = angband_color_table[i][3];
2043 /* Extract a full color code */
2044 code = PALETTERGB(rv, gv, bv);
2046 /* Activate changes */
2047 if (win_clr[i] != code)
2049 /* Note the change */
2052 /* Apply the desired color */
2057 /* Activate the palette if needed */
2058 if (change) (void)new_palette();
2064 /* Handle "arg_sound" */
2065 if (use_sound != arg_sound)
2067 /* Initialize (if needed) */
2068 if (arg_sound && !init_sound())
2072 plog("¥µ¥¦¥ó¥É¤ò½é´ü²½¤Ç¤¤Þ¤»¤ó¡ª");
2074 plog("Cannot initialize sound!");
2082 /* Change setting */
2083 use_sound = arg_sound;
2091 /* Handle "arg_graphics" */
2092 if (use_graphics != arg_graphics)
2094 /* Initialize (if needed) */
2095 if (arg_graphics && !init_graphics())
2099 plog("¥°¥é¥Õ¥£¥Ã¥¯¥¹¤ò½é´ü²½¤Ç¤¤Þ¤»¤ó!");
2101 plog("Cannot initialize graphics!");
2106 arg_graphics = GRAPHICS_NONE;
2109 /* Change setting */
2110 use_graphics = arg_graphics;
2113 #ifdef ANGBAND_2_8_1
2115 #else /* ANGBAND_2_8_1 */
2116 reset_visuals(TRUE);
2117 #endif /* ANGBAND_2_8_1 */
2120 #endif /* USE_GRAPHICS */
2123 /* Clean up windows */
2124 for (i = 0; i < MAX_TERM_DATA; i++)
2128 term_data *td = &data[i];
2130 /* Update resized windows */
2131 if ((td->cols != (uint)td->t.wid) || (td->rows != (uint)td->t.hgt))
2134 Term_activate(&td->t);
2136 /* Hack -- Resize the term */
2137 Term_resize(td->cols, td->rows);
2139 /* Redraw the contents */
2154 * Process at least one event
2156 static errr Term_xtra_win_event(int v)
2160 /* Wait for an event */
2164 if (GetMessage(&msg, NULL, 0, 0))
2166 TranslateMessage(&msg);
2167 DispatchMessage(&msg);
2171 /* Check for an event */
2175 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2177 TranslateMessage(&msg);
2178 DispatchMessage(&msg);
2188 * Process all pending events
2190 static errr Term_xtra_win_flush(void)
2194 /* Process all pending events */
2195 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2197 TranslateMessage(&msg);
2198 DispatchMessage(&msg);
2207 * Hack -- clear the screen
2209 * Make this more efficient XXX XXX XXX
2211 static errr Term_xtra_win_clear(void)
2213 term_data *td = (term_data*)(Term->data);
2218 /* Rectangle to erase */
2219 rc.left = td->size_ow1;
2220 rc.right = rc.left + td->cols * td->tile_wid;
2221 rc.top = td->size_oh1;
2222 rc.bottom = rc.top + td->rows * td->tile_hgt;
2226 SetBkColor(hdc, RGB(0, 0, 0));
2227 SelectObject(hdc, td->font_id);
2228 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2233 rc.left = 0; rc.top = 0;
2236 ReleaseDC(td->w, hdc);
2244 * Hack -- make a noise
2246 static errr Term_xtra_win_noise(void)
2248 MessageBeep(MB_ICONASTERISK);
2254 * Hack -- make a sound
2256 static errr Term_xtra_win_sound(int v)
2261 #endif /* USE_SOUND */
2263 /* Sound disabled */
2264 if (!use_sound) return (1);
2267 if ((v < 0) || (v >= SOUND_MAX)) return (1);
2271 /* Count the samples */
2272 for (i = 0; i < SAMPLE_MAX; i++)
2274 if (!sound_file[v][i])
2279 if (i == 0) return (1);
2281 /* Build the path */
2282 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_simple(i)]);
2286 /* Play the sound, catch errors */
2287 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
2291 /* Play the sound, catch errors */
2292 return (sndPlaySound(buf, SND_ASYNC));
2296 #else /* USE_SOUND */
2301 #endif /* USE_SOUND */
2306 * Delay for "x" milliseconds
2308 static int Term_xtra_win_delay(int v)
2322 t = GetTickCount() + v;
2325 while (GetTickCount() < t)
2327 /* Handle messages */
2328 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2330 TranslateMessage(&msg);
2331 DispatchMessage(&msg);
2343 * Do a "special thing"
2345 static errr Term_xtra_win(int n, int v)
2347 /* Handle a subset of the legal requests */
2350 /* Make a bell sound */
2351 case TERM_XTRA_NOISE:
2353 return (Term_xtra_win_noise());
2356 /* Make a special sound */
2357 case TERM_XTRA_SOUND:
2359 return (Term_xtra_win_sound(v));
2362 /* Process random events */
2363 case TERM_XTRA_BORED:
2365 return (Term_xtra_win_event(0));
2368 /* Process an event */
2369 case TERM_XTRA_EVENT:
2371 return (Term_xtra_win_event(v));
2374 /* Flush all events */
2375 case TERM_XTRA_FLUSH:
2377 return (Term_xtra_win_flush());
2380 /* Clear the screen */
2381 case TERM_XTRA_CLEAR:
2383 return (Term_xtra_win_clear());
2386 /* React to global changes */
2387 case TERM_XTRA_REACT:
2389 return (Term_xtra_win_react());
2392 /* Delay for some milliseconds */
2393 case TERM_XTRA_DELAY:
2395 return (Term_xtra_win_delay(v));
2406 * Low level graphics (Assumes valid input).
2408 * Draw a "cursor" at (x,y), using a "yellow box".
2410 static errr Term_curs_win(int x, int y)
2412 term_data *td = (term_data*)(Term->data);
2417 int tile_wid, tile_hgt;
2421 tile_wid = td->map_tile_wid;
2422 tile_hgt = td->map_tile_hgt;
2426 tile_wid = td->tile_wid;
2427 tile_hgt = td->tile_hgt;
2430 /* Frame the grid */
2431 rc.left = x * tile_wid + td->size_ow1;
2432 rc.right = rc.left + tile_wid;
2433 rc.top = y * tile_hgt + td->size_oh1;
2434 rc.bottom = rc.top + tile_hgt;
2436 /* Cursor is done as a yellow "box" */
2438 FrameRect(hdc, &rc, hbrYellow);
2439 ReleaseDC(td->w, hdc);
2447 * Low level graphics (Assumes valid input).
2449 * Draw a "big cursor" at (x,y), using a "yellow box".
2451 static errr Term_bigcurs_win(int x, int y)
2453 term_data *td = (term_data*)(Term->data);
2458 int tile_wid, tile_hgt;
2462 /* Normal cursor in map window */
2463 Term_curs_win(x, y);
2468 tile_wid = td->tile_wid;
2469 tile_hgt = td->tile_hgt;
2472 /* Frame the grid */
2473 rc.left = x * tile_wid + td->size_ow1;
2474 rc.right = rc.left + 2 * tile_wid;
2475 rc.top = y * tile_hgt + td->size_oh1;
2476 rc.bottom = rc.top + tile_hgt;
2478 /* Cursor is done as a yellow "box" */
2480 FrameRect(hdc, &rc, hbrYellow);
2481 ReleaseDC(td->w, hdc);
2489 * Low level graphics (Assumes valid input).
2491 * Erase a "block" of "n" characters starting at (x,y).
2493 static errr Term_wipe_win(int x, int y, int n)
2495 term_data *td = (term_data*)(Term->data);
2500 /* Rectangle to erase in client coords */
2501 rc.left = x * td->tile_wid + td->size_ow1;
2502 rc.right = rc.left + n * td->tile_wid;
2503 rc.top = y * td->tile_hgt + td->size_oh1;
2504 rc.bottom = rc.top + td->tile_hgt;
2507 SetBkColor(hdc, RGB(0, 0, 0));
2508 SelectObject(hdc, td->font_id);
2513 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2514 ReleaseDC(td->w, hdc);
2522 * Low level graphics. Assumes valid input.
2524 * Draw several ("n") chars, with an attr, at a given location.
2526 * All "graphic" data is handled by "Term_pict_win()", below.
2528 * One would think there is a more efficient method for telling a window
2529 * what color it should be using to draw with, but perhaps simply changing
2530 * it every time is not too inefficient. XXX XXX XXX
2532 static errr Term_text_win(int x, int y, int n, byte a, const char *s)
2534 term_data *td = (term_data*)(Term->data);
2538 #if 1 /* #ifdef JP */
2539 static HBITMAP WALL;
2540 static HBRUSH myBrush, oldBrush;
2542 static bool init_done = FALSE;
2545 WALL = LoadBitmap(hInstance, AppName);
2546 myBrush = CreatePatternBrush(WALL);
2551 /* Total rectangle */
2552 rc.left = x * td->tile_wid + td->size_ow1;
2553 rc.right = rc.left + n * td->tile_wid;
2554 rc.top = y * td->tile_hgt + td->size_oh1;
2555 rc.bottom = rc.top + td->tile_hgt;
2560 /* Background color */
2561 SetBkColor(hdc, RGB(0, 0, 0));
2563 /* Foreground color */
2566 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
2570 SetTextColor(hdc, win_clr[a&0x0F]);
2574 SetTextColor(hdc, win_clr[a]);
2578 SelectObject(hdc, td->font_id);
2581 if (use_bg) SetBkMode(hdc, TRANSPARENT);
2585 (td->tile_hgt != td->font_hgt) ||
2586 (td->tile_wid != td->font_wid))
2590 /* Erase complete rectangle */
2591 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2594 if (use_bg) DrawBG(hdc, &rc);
2597 rc.left += ((td->tile_wid - td->font_wid) / 2);
2598 rc.right = rc.left + td->font_wid;
2599 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
2600 rc.bottom = rc.top + td->font_hgt;
2602 /* Dump each character */
2603 for (i = 0; i < n; i++)
2606 if (use_bigtile && *(s+i)=="¢£"[0] && *(s+i+1)=="¢£"[1])
2608 rc.right += td->font_wid;
2610 oldBrush = SelectObject(hdc, myBrush);
2611 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2614 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2616 SelectObject(hdc, oldBrush);
2617 SelectObject(hdc, oldPen);
2618 rc.right -= td->font_wid;
2622 rc.left += 2 * td->tile_wid;
2623 rc.right += 2 * td->tile_wid;
2625 else if ( iskanji(*(s+i)) ) /* £²¥Ð¥¤¥Èʸ»ú */
2627 rc.right += td->font_wid;
2629 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2631 rc.right -= td->font_wid;
2635 rc.left += 2 * td->tile_wid;
2636 rc.right += 2 * td->tile_wid;
2637 } else if (*(s+i)==127){
2638 oldBrush = SelectObject(hdc, myBrush);
2639 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2642 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2644 SelectObject(hdc, oldBrush);
2645 SelectObject(hdc, oldPen);
2648 rc.left += td->tile_wid;
2649 rc.right += td->tile_wid;
2652 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
2655 rc.left += td->tile_wid;
2656 rc.right += td->tile_wid;
2661 oldBrush = SelectObject(hdc, myBrush);
2662 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
2665 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
2667 SelectObject(hdc, oldBrush);
2668 SelectObject(hdc, oldPen);
2671 rc.left += td->tile_wid;
2672 rc.right += td->tile_wid;
2675 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2679 rc.left += td->tile_wid;
2680 rc.right += td->tile_wid;
2684 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
2688 rc.left += td->tile_wid;
2689 rc.right += td->tile_wid;
2700 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
2705 ReleaseDC(td->w, hdc);
2713 * Low level graphics. Assumes valid input.
2715 * Draw an array of "special" attr/char pairs at the given location.
2717 * We use the "Term_pict_win()" function for "graphic" data, which are
2718 * encoded by setting the "high-bits" of both the "attr" and the "char"
2719 * data. We use the "attr" to represent the "row" of the main bitmap,
2720 * and the "char" to represent the "col" of the main bitmap. The use
2721 * of this function is induced by the "higher_pict" flag.
2723 * If "graphics" is not available, we simply "wipe" the given grids.
2725 static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
2727 term_data *td = (term_data*)(Term->data);
2733 int x2, y2, w2, h2, tw2;
2745 /* Erase the grids */
2746 return (Term_wipe_win(x, y, n));
2749 /* Size of bitmap cell */
2750 w1 = infGraph.CellWidth;
2751 h1 = infGraph.CellHeight;
2753 /* Size of window cell */
2756 w2 = td->map_tile_wid;
2757 h2 = td->map_tile_hgt;
2766 if (use_bigtile) tw2 *= 2;
2769 /* Location of window cell */
2770 x2 = x * w2 + td->size_ow1;
2771 y2 = y * h2 + td->size_oh1;
2777 hdcSrc = CreateCompatibleDC(hdc);
2778 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
2780 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2782 hdcMask = CreateCompatibleDC(hdc);
2783 SelectObject(hdcMask, infMask.hBitmap);
2786 /* Draw attr/char pairs */
2787 for (i = 0; i < n; i++, x2 += w2)
2792 /* Extract picture */
2793 int row = (a & 0x7F);
2794 int col = (c & 0x7F);
2796 /* Location of bitmap cell */
2800 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2802 x3 = (tcp[i] & 0x7F) * w1;
2803 y3 = (tap[i] & 0x7F) * h1;
2806 if ((w1 == tw2) && (h1 == h2))
2808 /* Copy the terrain picture from the bitmap to the window */
2809 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
2811 /* Mask out the tile */
2812 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
2815 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
2818 /* Need to stretch */
2821 /* Set the correct mode for stretching the tiles */
2822 SetStretchBltMode(hdc, COLORONCOLOR);
2824 /* Copy the terrain picture from the bitmap to the window */
2825 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCCOPY);
2827 /* Only draw if terrain and overlay are different */
2828 if ((x1 != x3) || (y1 != y3))
2830 /* Mask out the tile */
2831 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
2834 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
2841 if ((w1 == tw2) && (h1 == h2))
2843 /* Copy the picture from the bitmap to the window */
2844 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
2847 /* Need to stretch */
2850 /* Set the correct mode for stretching the tiles */
2851 SetStretchBltMode(hdc, COLORONCOLOR);
2853 /* Copy the picture from the bitmap to the window */
2854 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
2860 SelectObject(hdcSrc, hbmSrcOld);
2863 if (arg_graphics == GRAPHICS_ADAM_BOLT)
2866 SelectObject(hdcMask, hbmSrcOld);
2871 ReleaseDC(td->w, hdc);
2873 #else /* USE_GRAPHICS */
2875 /* Just erase this grid */
2876 return (Term_wipe_win(x, y, n));
2878 #endif /* USE_GRAPHICS */
2885 static void windows_map(void)
2887 term_data *td = &data[0];
2889 int x, min_x, max_x;
2890 int y, min_y, max_y;
2894 /* Only in graphics mode */
2895 if (!use_graphics) return;
2898 Term_xtra_win_clear();
2900 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
2901 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
2902 td->map_active = TRUE;
2912 for (x = min_x; x < max_x; x++)
2914 for (y = min_y; y < max_y; y++)
2916 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
2918 /* Ignore non-graphics */
2919 if ((a & 0x80) && (c & 0x80))
2921 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
2926 /* Hilite the player */
2927 Term_curs_win(px - min_x, py - min_y);
2929 /* Wait for a keypress, flush key buffer */
2930 Term_inkey(&c, TRUE, TRUE);
2933 /* Switch off the map display */
2934 td->map_active = FALSE;
2936 /* Restore screen */
2937 Term_xtra_win_clear();
2942 /*** Other routines ***/
2946 * Create and initialize a "term_data" given a title
2948 static void term_data_link(term_data *td)
2952 /* Initialize the term */
2953 term_init(t, td->cols, td->rows, td->keys);
2955 /* Use a "software" cursor */
2956 t->soft_cursor = TRUE;
2958 /* Use "Term_pict" for "graphic" data */
2959 t->higher_pict = TRUE;
2961 /* Erase with "white space" */
2962 t->attr_blank = TERM_WHITE;
2963 t->char_blank = ' ';
2966 /* Prepare the init/nuke hooks */
2967 t->init_hook = Term_init_win;
2968 t->nuke_hook = Term_nuke_win;
2971 /* Prepare the template hooks */
2972 t->user_hook = Term_user_win;
2973 t->xtra_hook = Term_xtra_win;
2974 t->curs_hook = Term_curs_win;
2975 t->bigcurs_hook = Term_bigcurs_win;
2976 t->wipe_hook = Term_wipe_win;
2977 t->text_hook = Term_text_win;
2978 t->pict_hook = Term_pict_win;
2980 /* Remember where we came from */
2981 t->data = (vptr)(td);
2986 * Create the windows
2988 * First, instantiate the "default" values, then read the "ini_file"
2989 * to over-ride selected values, then create the windows, and fonts.
2991 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
2992 * must make active to realize the palette. XXX XXX XXX
2994 static void init_windows(void)
3000 #if 0 /* #ifndef JP */
3006 WIPE(td, term_data);
3010 td->s = angband_term_name[0];
3024 #if 1 /* #ifdef JP */
3028 for (i = 1; i < MAX_TERM_DATA; i++)
3031 WIPE(td, term_data);
3032 td->s = angband_term_name[i];
3036 td->visible = FALSE;
3041 td->pos_x = (7 - i) * 30;
3042 td->pos_y = (7 - i) * 20;
3044 #if 1 /* #ifdef JP */
3054 /* Main window (need these before term_getsize gets called) */
3056 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
3057 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
3062 /* Sub windows (need these before term_getsize gets called) */
3063 for (i = 1; i < MAX_TERM_DATA; i++)
3066 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
3067 td->dwExStyle = (WS_EX_TOOLWINDOW);
3072 for (i = 0; i < MAX_TERM_DATA; i++)
3076 #if 1 /* #ifdef JP */
3077 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
3078 td->lf.lfCharSet = DEFAULT_CHARSET;
3079 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
3080 /* Activate the chosen font */
3081 term_force_font(td, NULL);
3082 td->tile_wid = td->font_wid;
3083 td->tile_hgt = td->font_hgt;
3085 /* Access the standard font file */
3086 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
3088 /* Activate the chosen font */
3089 if (term_force_font(td, buf))
3091 /* Access the standard font file */
3092 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
3094 /* Force the use of that font */
3095 (void)term_force_font(td, buf);
3101 /* Assume not bizarre */
3102 td->bizarre = FALSE;
3107 /* Analyze the font */
3110 /* Resize the window */
3111 term_window_resize(td);
3115 /* Sub windows (reverse order) */
3116 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
3121 td->w = CreateWindowEx(td->dwExStyle, AngList,
3123 td->pos_x, td->pos_y,
3124 td->size_wid, td->size_hgt,
3125 HWND_DESKTOP, NULL, hInstance, NULL);
3128 if (!td->w) quit("¥µ¥Ö¥¦¥£¥ó¥É¥¦¤ËºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿");
3130 if (!td->w) quit("Failed to create sub-window");
3136 td->size_hack = TRUE;
3137 ShowWindow(td->w, SW_SHOW);
3138 td->size_hack = FALSE;
3142 angband_term[i] = &td->t;
3146 /* Activate the window */
3147 SetActiveWindow(td->w);
3152 term_window_pos(&data[i], HWND_TOPMOST);
3156 term_window_pos(&data[i], td->w);
3166 td->w = CreateWindowEx(td->dwExStyle, AppName,
3168 td->pos_x, td->pos_y,
3169 td->size_wid, td->size_hgt,
3170 HWND_DESKTOP, NULL, hInstance, NULL);
3173 if (!td->w) quit("¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿");
3175 if (!td->w) quit("Failed to create Angband window");
3180 angband_term[0] = &td->t;
3181 normsize.x = td->cols;
3182 normsize.y = td->rows;
3184 /* Activate the main window */
3185 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
3186 else ShowWindow(td->w, SW_SHOW);
3188 /* Bring main window back to top */
3189 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
3192 /* New palette XXX XXX XXX */
3193 (void)new_palette();
3196 /* Create a "brush" for drawing the "cursor" */
3197 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
3200 /* Process pending messages */
3201 (void)Term_xtra_win_flush();
3209 static void setup_menus(void)
3213 HMENU hm = GetMenu(data[0].w);
3216 /* Menu "File", Disable all */
3217 EnableMenuItem(hm, IDM_FILE_NEW,
3218 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3219 EnableMenuItem(hm, IDM_FILE_OPEN,
3220 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3221 EnableMenuItem(hm, IDM_FILE_SAVE,
3222 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3223 EnableMenuItem(hm, IDM_FILE_EXIT,
3224 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3225 EnableMenuItem(hm, IDM_FILE_SCORE,
3226 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3229 /* No character available */
3230 if (!character_generated)
3232 /* Menu "File", Item "New" */
3233 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
3235 /* Menu "File", Item "Open" */
3236 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
3239 /* A character available */
3240 if (character_generated)
3242 /* Menu "File", Item "Save" */
3243 EnableMenuItem(hm, IDM_FILE_SAVE,
3244 MF_BYCOMMAND | MF_ENABLED);
3247 /* Menu "File", Item "Exit" */
3248 EnableMenuItem(hm, IDM_FILE_EXIT,
3249 MF_BYCOMMAND | MF_ENABLED);
3251 EnableMenuItem(hm, IDM_FILE_SCORE,
3252 MF_BYCOMMAND | MF_ENABLED);
3255 /* Menu "Window::Visibility" */
3256 for (i = 0; i < MAX_TERM_DATA; i++)
3258 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3259 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3261 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3262 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
3264 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3265 MF_BYCOMMAND | MF_ENABLED);
3268 /* Menu "Window::Font" */
3269 for (i = 0; i < MAX_TERM_DATA; i++)
3271 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3272 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3274 if (data[i].visible)
3276 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3277 MF_BYCOMMAND | MF_ENABLED);
3281 /* Menu "Window::Window Position Fix" */
3282 for (i = 0; i < MAX_TERM_DATA; i++)
3284 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3285 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3287 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
3288 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
3290 if (data[i].visible)
3292 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3293 MF_BYCOMMAND | MF_ENABLED);
3297 /* Menu "Window::Bizarre Display" */
3298 for (i = 0; i < MAX_TERM_DATA; i++)
3300 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3301 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3303 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3304 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
3306 if (data[i].visible)
3308 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3309 MF_BYCOMMAND | MF_ENABLED);
3314 /* Menu "Window::Increase Tile Width" */
3315 for (i = 0; i < MAX_TERM_DATA; i++)
3317 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3318 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3320 if (data[i].visible)
3322 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3323 MF_BYCOMMAND | MF_ENABLED);
3328 /* Menu "Window::Decrease Tile Width" */
3329 for (i = 0; i < MAX_TERM_DATA; i++)
3331 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3332 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3334 if (data[i].visible)
3336 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3337 MF_BYCOMMAND | MF_ENABLED);
3342 /* Menu "Window::Increase Tile Height" */
3343 for (i = 0; i < MAX_TERM_DATA; i++)
3345 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3346 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3348 if (data[i].visible)
3350 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3351 MF_BYCOMMAND | MF_ENABLED);
3356 /* Menu "Window::Decrease Tile Height" */
3357 for (i = 0; i < MAX_TERM_DATA; i++)
3359 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3360 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3362 if (data[i].visible)
3364 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3365 MF_BYCOMMAND | MF_ENABLED);
3370 /* Menu "Options", disable all */
3371 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3372 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3373 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3374 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3375 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3376 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3377 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
3378 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3379 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
3380 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3382 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3383 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3386 /* Menu "Options", Item "Map" */
3387 if (use_graphics != GRAPHICS_NONE)
3388 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
3390 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
3391 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3393 /* Menu "Options", update all */
3394 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3395 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
3396 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3397 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
3398 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3399 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
3400 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
3401 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
3402 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
3403 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
3404 CheckMenuItem(hm, IDM_OPTIONS_BG,
3405 (use_bg ? MF_CHECKED : MF_UNCHECKED));
3407 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
3408 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
3412 /* Menu "Options", Item "Graphics" */
3413 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
3414 /* Menu "Options", Item "Graphics" */
3415 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
3416 /* Menu "Options", Item "Graphics" */
3417 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
3418 /* Menu "Options", Item "Graphics" */
3419 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
3420 #endif /* USE_GRAPHICS */
3423 /* Menu "Options", Item "Sound" */
3424 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
3425 #endif /* USE_SOUND */
3428 /* Menu "Options", Item "ScreenSaver" */
3429 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3430 MF_BYCOMMAND | MF_ENABLED);
3431 #endif /* USE_SAVER */
3436 * Check for double clicked (or dragged) savefile
3438 * Apparently, Windows copies the entire filename into the first
3439 * piece of the "command line string". Perhaps we should extract
3440 * the "basename" of that filename and append it to the "save" dir.
3442 static void check_for_save_file(LPSTR cmd_line)
3452 /* Extract filename */
3453 strcat(savefile, s);
3455 /* Validate the file */
3456 validate_file(savefile);
3458 /* Game in progress */
3459 game_in_progress = TRUE;
3467 * Process a menu command
3469 static void process_menus(WORD wCmd)
3486 plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
3488 plog("You cannot do that yet...");
3492 else if (game_in_progress)
3495 plog("¥×¥ì¥¤Ãæ¤Ï¿·¤·¤¤¥²¡¼¥à¤ò»Ï¤á¤ë¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
3497 plog("You can't start a new game while you're still playing!");
3503 game_in_progress = TRUE;
3517 plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
3519 plog("You cannot do that yet...");
3523 else if (game_in_progress)
3526 plog("¥×¥ì¥¤Ãæ¤Ï¥²¡¼¥à¤ò¥í¡¼¥É¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
3528 plog("You can't open a new game while you're still playing!");
3534 memset(&ofn, 0, sizeof(ofn));
3535 ofn.lStructSize = sizeof(ofn);
3536 ofn.hwndOwner = data[0].w;
3537 ofn.lpstrFilter = "Save Files (*.)\0*\0";
3538 ofn.nFilterIndex = 1;
3539 ofn.lpstrFile = savefile;
3540 ofn.nMaxFile = 1024;
3541 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
3542 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
3544 if (GetOpenFileName(&ofn))
3546 /* Load 'savefile' */
3547 validate_file(savefile);
3548 game_in_progress = TRUE;
3560 if (game_in_progress && character_generated)
3566 plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3568 plog("You may not do that right now.");
3574 /* Hack -- Forget messages */
3579 do_cmd_save_game(FALSE);
3580 #else /* ZANGBAND */
3582 #endif /* ZANGBAND */
3587 plog("º£¡¢¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
3589 plog("You may not do that right now.");
3599 if (game_in_progress && character_generated)
3605 plog("º£¤Ï½ªÎ»¤Ç¤¤Þ¤»¤ó¡£");
3607 plog("You may not do that right now.");
3613 /* Hack -- Forget messages */
3622 /* do_cmd_save_game(FALSE); */
3623 #else /* ZANGBAND */
3624 /* do_cmd_save_game(); */
3625 #endif /* ZANGBAND */
3626 Term_key_push(SPECIAL_KEY_QUIT);
3634 case IDM_FILE_SCORE:
3638 /* Build the filename */
3639 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
3641 /* Open the binary high score file, for reading */
3642 highscore_fd = fd_open(buf, O_RDONLY);
3644 /* Paranoia -- No score file */
3645 if (highscore_fd < 0)
3647 msg_print("Score file unavailable.");
3657 /* Display the scores */
3658 display_scores_aux(0, MAX_HISCORES, -1, NULL);
3660 /* Shut the high score file */
3661 (void)fd_close(highscore_fd);
3663 /* Forget the high score fd */
3669 /* Hack - Flush it */
3677 case IDM_FILE_MOVIE:
3682 plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
3684 plog("You cannot do that yet...");
3687 else if (game_in_progress)
3690 plog("¥×¥ì¥¤Ãæ¤Ï¥à¡¼¥Ó¡¼¤ò¥í¡¼¥É¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
3692 plog("You can't open a movie while you're playing!");
3697 memset(&ofn, 0, sizeof(ofn));
3698 ofn.lStructSize = sizeof(ofn);
3699 ofn.hwndOwner = data[0].w;
3700 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
3701 ofn.nFilterIndex = 1;
3702 ofn.lpstrFile = savefile;
3703 ofn.nMaxFile = 1024;
3704 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
3705 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
3707 if (GetOpenFileName(&ofn))
3709 /* Load 'savefile' */
3710 prepare_browse_movie_aux(savefile);
3720 case IDM_WINDOW_VIS_0:
3723 plog("¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤ÏÈóɽ¼¨¤Ë¤Ç¤¤Þ¤»¤ó¡ª");
3725 plog("You are not allowed to do that!");
3732 /* Window visibility */
3733 case IDM_WINDOW_VIS_1:
3734 case IDM_WINDOW_VIS_2:
3735 case IDM_WINDOW_VIS_3:
3736 case IDM_WINDOW_VIS_4:
3737 case IDM_WINDOW_VIS_5:
3738 case IDM_WINDOW_VIS_6:
3739 case IDM_WINDOW_VIS_7:
3741 i = wCmd - IDM_WINDOW_VIS_0;
3743 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3750 ShowWindow(td->w, SW_SHOW);
3751 term_data_redraw(td);
3755 td->visible = FALSE;
3757 ShowWindow(td->w, SW_HIDE);
3764 case IDM_WINDOW_FONT_0:
3765 case IDM_WINDOW_FONT_1:
3766 case IDM_WINDOW_FONT_2:
3767 case IDM_WINDOW_FONT_3:
3768 case IDM_WINDOW_FONT_4:
3769 case IDM_WINDOW_FONT_5:
3770 case IDM_WINDOW_FONT_6:
3771 case IDM_WINDOW_FONT_7:
3773 i = wCmd - IDM_WINDOW_FONT_0;
3775 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3779 term_change_font(td);
3784 /* Window Z Position */
3785 case IDM_WINDOW_POS_1:
3786 case IDM_WINDOW_POS_2:
3787 case IDM_WINDOW_POS_3:
3788 case IDM_WINDOW_POS_4:
3789 case IDM_WINDOW_POS_5:
3790 case IDM_WINDOW_POS_6:
3791 case IDM_WINDOW_POS_7:
3793 i = wCmd - IDM_WINDOW_POS_0;
3795 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3799 if (!td->posfix && td->visible)
3802 term_window_pos(td, HWND_TOPMOST);
3807 term_window_pos(td, data[0].w);
3813 /* Bizarre Display */
3814 case IDM_WINDOW_BIZ_0:
3815 case IDM_WINDOW_BIZ_1:
3816 case IDM_WINDOW_BIZ_2:
3817 case IDM_WINDOW_BIZ_3:
3818 case IDM_WINDOW_BIZ_4:
3819 case IDM_WINDOW_BIZ_5:
3820 case IDM_WINDOW_BIZ_6:
3821 case IDM_WINDOW_BIZ_7:
3823 i = wCmd - IDM_WINDOW_BIZ_0;
3825 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3829 td->bizarre = !td->bizarre;
3833 term_window_resize(td);
3838 /* Increase Tile Width */
3839 case IDM_WINDOW_I_WID_0:
3840 case IDM_WINDOW_I_WID_1:
3841 case IDM_WINDOW_I_WID_2:
3842 case IDM_WINDOW_I_WID_3:
3843 case IDM_WINDOW_I_WID_4:
3844 case IDM_WINDOW_I_WID_5:
3845 case IDM_WINDOW_I_WID_6:
3846 case IDM_WINDOW_I_WID_7:
3848 i = wCmd - IDM_WINDOW_I_WID_0;
3850 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3858 term_window_resize(td);
3863 /* Decrease Tile Height */
3864 case IDM_WINDOW_D_WID_0:
3865 case IDM_WINDOW_D_WID_1:
3866 case IDM_WINDOW_D_WID_2:
3867 case IDM_WINDOW_D_WID_3:
3868 case IDM_WINDOW_D_WID_4:
3869 case IDM_WINDOW_D_WID_5:
3870 case IDM_WINDOW_D_WID_6:
3871 case IDM_WINDOW_D_WID_7:
3873 i = wCmd - IDM_WINDOW_D_WID_0;
3875 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3883 term_window_resize(td);
3888 /* Increase Tile Height */
3889 case IDM_WINDOW_I_HGT_0:
3890 case IDM_WINDOW_I_HGT_1:
3891 case IDM_WINDOW_I_HGT_2:
3892 case IDM_WINDOW_I_HGT_3:
3893 case IDM_WINDOW_I_HGT_4:
3894 case IDM_WINDOW_I_HGT_5:
3895 case IDM_WINDOW_I_HGT_6:
3896 case IDM_WINDOW_I_HGT_7:
3898 i = wCmd - IDM_WINDOW_I_HGT_0;
3900 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3908 term_window_resize(td);
3913 /* Decrease Tile Height */
3914 case IDM_WINDOW_D_HGT_0:
3915 case IDM_WINDOW_D_HGT_1:
3916 case IDM_WINDOW_D_HGT_2:
3917 case IDM_WINDOW_D_HGT_3:
3918 case IDM_WINDOW_D_HGT_4:
3919 case IDM_WINDOW_D_HGT_5:
3920 case IDM_WINDOW_D_HGT_6:
3921 case IDM_WINDOW_D_HGT_7:
3923 i = wCmd - IDM_WINDOW_D_HGT_0;
3925 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3933 term_window_resize(td);
3938 case IDM_OPTIONS_NO_GRAPHICS:
3943 plog("You may not do that right now.");
3947 /* Toggle "arg_graphics" */
3948 if (arg_graphics != GRAPHICS_NONE)
3950 arg_graphics = GRAPHICS_NONE;
3952 /* React to changes */
3953 Term_xtra_win_react();
3955 /* Hack -- Force redraw */
3956 Term_key_push(KTRL('R'));
3962 case IDM_OPTIONS_OLD_GRAPHICS:
3967 plog("You may not do that right now.");
3971 /* Toggle "arg_graphics" */
3972 if (arg_graphics != GRAPHICS_ORIGINAL)
3974 arg_graphics = GRAPHICS_ORIGINAL;
3976 /* React to changes */
3977 Term_xtra_win_react();
3979 /* Hack -- Force redraw */
3980 Term_key_push(KTRL('R'));
3986 case IDM_OPTIONS_NEW_GRAPHICS:
3991 plog("You may not do that right now.");
3995 /* Toggle "arg_graphics" */
3996 if (arg_graphics != GRAPHICS_ADAM_BOLT)
3998 arg_graphics = GRAPHICS_ADAM_BOLT;
4000 /* React to changes */
4001 Term_xtra_win_react();
4003 /* Hack -- Force redraw */
4004 Term_key_push(KTRL('R'));
4010 case IDM_OPTIONS_BIGTILE:
4012 term_data *td = &data[0];
4017 plog("You may not do that right now.");
4021 /* Toggle "arg_sound" */
4022 arg_bigtile = !arg_bigtile;
4025 Term_activate(&td->t);
4027 /* Resize the term */
4028 Term_resize(td->cols, td->rows);
4031 InvalidateRect(td->w, NULL, TRUE);
4036 case IDM_OPTIONS_SOUND:
4041 plog("You may not do that right now.");
4045 /* Toggle "arg_sound" */
4046 arg_sound = !arg_sound;
4048 /* React to changes */
4049 Term_xtra_win_react();
4051 /* Hack -- Force redraw */
4052 Term_key_push(KTRL('R'));
4058 case IDM_OPTIONS_BG:
4063 plog("You may not do that right now.");
4067 /* Toggle "use_bg" */
4072 /* React to changes */
4073 Term_xtra_win_react();
4075 /* Hack -- Force redraw */
4076 Term_key_push(KTRL('R'));
4082 case IDM_OPTIONS_OPEN_BG:
4087 plog("You may not do that right now.");
4092 memset(&ofn, 0, sizeof(ofn));
4093 ofn.lStructSize = sizeof(ofn);
4094 ofn.hwndOwner = data[0].w;
4095 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
4096 ofn.nFilterIndex = 1;
4097 ofn.lpstrFile = bg_bitmap_file;
4098 ofn.nMaxFile = 1023;
4099 ofn.lpstrInitialDir = NULL;
4101 ofn.lpstrTitle = "ÊÉ»æ¤òÁª¤ó¤Ç¤Í¡£";
4103 ofn.lpstrTitle = "Choose wall paper.";
4105 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
4107 if (GetOpenFileName(&ofn))
4109 /* Load 'savefile' */
4114 /* React to changes */
4115 Term_xtra_win_react();
4117 /* Hack -- Force redraw */
4118 Term_key_push(KTRL('R'));
4123 case IDM_DUMP_SCREEN_HTML:
4125 static char buf[1024] = "";
4126 memset(&ofn, 0, sizeof(ofn));
4127 ofn.lStructSize = sizeof(ofn);
4128 ofn.hwndOwner = data[0].w;
4129 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
4130 ofn.nFilterIndex = 1;
4131 ofn.lpstrFile = buf;
4132 ofn.nMaxFile = 1023;
4133 ofn.lpstrDefExt = "html";
4134 ofn.lpstrInitialDir = NULL;
4136 ofn.lpstrTitle = "HTML¤Ç¥¹¥¯¥ê¡¼¥ó¥À¥ó¥×¤òÊݸ";
4138 ofn.lpstrTitle = "Save screen dump as HTML.";
4140 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
4142 if (GetSaveFileName(&ofn))
4144 do_cmd_save_screen_html_aux(buf, 0);
4151 case IDM_OPTIONS_SAVER:
4155 DestroyWindow(hwndSaver);
4160 /* Create a screen scaver window */
4161 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
4162 "Angband Screensaver",
4163 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
4164 0, 0, GetSystemMetrics(SM_CXSCREEN),
4165 GetSystemMetrics(SM_CYSCREEN),
4166 NULL, NULL, hInstance, NULL);
4170 /* Push the window to the bottom XXX XXX XXX */
4171 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
4176 plog("¥¦¥£¥ó¥É¥¦¤òºîÀ®½ÐÍè¤Þ¤»¤ó");
4178 plog("Failed to create saver window");
4188 case IDM_OPTIONS_MAP:
4194 case IDM_HELP_CONTENTS:
4198 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
4199 if (check_file(tmp))
4201 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
4206 plog_fmt("¥Ø¥ë¥×¥Õ¥¡¥¤¥ë[%s]¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó¡£", tmp);
4207 plog("Âå¤ï¤ê¤Ë¥ª¥ó¥é¥¤¥ó¥Ø¥ë¥×¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£");
4209 plog_fmt("Cannot find help file: %s", tmp);
4210 plog("Use the online help files instead.");
4215 #else /* HTML_HELP */
4218 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
4219 if (check_file(tmp))
4221 sprintf(buf, "winhelp.exe %s", tmp);
4222 WinExec(buf, SW_NORMAL);
4227 plog_fmt("¥Ø¥ë¥×¥Õ¥¡¥¤¥ë[%s]¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó¡£", tmp);
4228 plog("Âå¤ï¤ê¤Ë¥ª¥ó¥é¥¤¥ó¥Ø¥ë¥×¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£");
4230 plog_fmt("Cannot find help file: %s", tmp);
4231 plog("Use the online help files instead.");
4236 #endif /* HTML_HELP */
4242 static bool process_keydown(WPARAM wParam, LPARAM lParam)
4249 /* Extract the modifiers */
4250 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
4251 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
4252 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
4254 Term_no_press = (ma) ? TRUE : FALSE;
4256 /* Handle "special" keys */
4257 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
4259 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
4260 bool numpad = FALSE;
4262 /* Begin the macro trigger */
4265 /* Send the modifiers */
4266 if (mc) Term_keypress('C');
4267 if (ms) Term_keypress('S');
4268 if (ma) Term_keypress('A');
4270 /* Extract "scan code" */
4271 i = LOBYTE(HIWORD(lParam));
4273 /* Introduce the scan code */
4276 /* Extended key bit */
4279 /* Numpad Enter and '/' are extended key */
4281 Term_no_press = TRUE;
4282 case VK_RETURN: /* Enter */
4285 /* Other extended keys are on full keyboard */
4301 Term_no_press = TRUE;
4305 case VK_PRIOR: /* Page Up */
4306 case VK_NEXT: /* Page Down */
4316 /* Special modifiers for keypad keys */
4317 if (numpad) Term_keypress('K');
4319 /* Encode the hexidecimal scan code */
4320 Term_keypress(hexsym[i/16]);
4321 Term_keypress(hexsym[i%16]);
4323 /* End the macro trigger */
4334 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4335 WPARAM wParam, LPARAM lParam);
4336 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4337 WPARAM wParam, LPARAM lParam)
4338 #else /* __MWERKS__ */
4339 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4340 WPARAM wParam, LPARAM lParam)
4341 #endif /* __MWERKS__ */
4347 MINMAXINFO FAR *lpmmi;
4353 /* Acquire proper "term_data" info */
4354 td = (term_data *)GetWindowLong(hWnd, 0);
4356 /* Handle message */
4362 SetWindowLong(hWnd, 0, (LONG)(my_td));
4372 case WM_GETMINMAXINFO:
4374 MINMAXINFO FAR *lpmmi;
4377 lpmmi = (MINMAXINFO FAR *)lParam;
4379 /* this message was sent before WM_NCCREATE */
4382 /* Minimum window size is 80x24 */
4383 rc.left = rc.top = 0;
4384 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
4385 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4388 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4390 /* Save minimum size */
4391 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4392 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4399 BeginPaint(hWnd, &ps);
4400 if (td) term_data_redraw(td);
4401 EndPaint(hWnd, &ps);
4402 ValidateRect(hWnd, NULL);
4409 if (process_keydown(wParam, lParam))
4416 if (Term_no_press) Term_no_press = FALSE;
4417 else Term_keypress(wParam);
4421 case WM_LBUTTONDOWN:
4423 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
4424 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
4436 int dx = abs(oldx - mousex) + 1;
4437 int dy = abs(oldy - mousey) + 1;
4438 int ox = (oldx > mousex) ? mousex : oldx;
4439 int oy = (oldy > mousey) ? mousey : oldy;
4449 hGlobal = GlobalAlloc(GHND, sz + 1);
4450 if (hGlobal == NULL) return 0;
4451 lpStr = (LPSTR)GlobalLock(hGlobal);
4453 for (i = 0; i < dy; i++)
4457 char **scr = data[0].t.scr->c;
4459 C_MAKE(s, (dx + 1), char);
4460 strncpy(s, &scr[oy + i][ox], dx);
4464 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
4467 if (ox + dx < data[0].cols)
4469 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
4472 for (j = 0; j < dx; j++)
4474 if (s[j] == 127) s[j] = '#';
4478 for (j = 0; j < dx; j++)
4480 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
4490 GlobalUnlock(hGlobal);
4491 if (OpenClipboard(hWnd) == 0)
4493 GlobalFree(hGlobal);
4497 SetClipboardData(CF_TEXT, hGlobal);
4510 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
4511 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
4516 dx = abs(oldx - mousex) + 1;
4517 dy = abs(oldy - mousey) + 1;
4518 ox = (oldx > mousex) ? mousex : oldx;
4519 oy = (oldy > mousey) ? mousey : oldy;
4520 Term_inversed_area(hWnd, ox, oy, dx, dy);
4527 dx = abs(cx - mousex) + 1;
4528 dy = abs(cy - mousey) + 1;
4529 ox = (cx > mousex) ? mousex : cx;
4530 oy = (cy > mousey) ? mousey : cy;
4531 Term_inversed_area(hWnd, ox, oy, dx, dy);
4547 if (game_in_progress && character_generated)
4552 plog("º£¤Ï½ªÎ»¤Ç¤¤Þ¤»¤ó¡£");
4554 plog("You may not do that right now.");
4559 /* Hack -- Forget messages */
4568 /* do_cmd_save_game(FALSE); */
4569 #else /* ZANGBAND */
4570 /* do_cmd_save_game(); */
4571 #endif /* ZANGBAND */
4572 Term_key_push(SPECIAL_KEY_QUIT);
4579 case WM_QUERYENDSESSION:
4581 if (game_in_progress && character_generated)
4583 /* Hack -- Forget messages */
4586 /* Mega-Hack -- Delay death */
4587 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
4590 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
4592 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
4595 /* Hardcode panic save */
4596 p_ptr->panic_save = 1;
4598 /* Forbid suspend */
4599 signals_ignore_tstp();
4601 /* Indicate panic save */
4603 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
4605 (void)strcpy(p_ptr->died_from, "(panic save)");
4609 (void)save_player();
4623 process_menus(LOWORD(wParam));
4629 /* this message was sent before WM_NCCREATE */
4632 /* it was sent from inside CreateWindowEx */
4633 if (!td->w) return 1;
4635 /* was sent from WM_SIZE */
4636 if (td->size_hack) return 1;
4640 case SIZE_MINIMIZED:
4642 /* Hide sub-windows */
4643 for (i = 1; i < MAX_TERM_DATA; i++)
4645 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
4650 case SIZE_MAXIMIZED:
4652 /* fall through XXX XXX XXX */
4657 uint cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4658 uint rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4661 if ((td->cols != cols) || (td->rows != rows))
4663 /* Save the new size */
4667 if (!IsZoomed(td->w) && !IsIconic(td->w))
4669 normsize.x = td->cols;
4670 normsize.y = td->rows;
4674 Term_activate(&td->t);
4676 /* Resize the term */
4677 Term_resize(td->cols, td->rows);
4680 InvalidateRect(td->w, NULL, TRUE);
4683 td->size_hack = TRUE;
4685 /* Show sub-windows */
4686 for (i = 1; i < MAX_TERM_DATA; i++)
4688 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
4691 td->size_hack = FALSE;
4699 case WM_PALETTECHANGED:
4701 /* Ignore if palette change caused by itself */
4702 if ((HWND)wParam == hWnd) return 0;
4704 /* Fall through... */
4707 case WM_QUERYNEWPALETTE:
4709 if (!paletted) return 0;
4713 SelectPalette(hdc, hPal, FALSE);
4715 i = RealizePalette(hdc);
4717 /* if any palette entries changed, repaint the window. */
4718 if (i) InvalidateRect(hWnd, NULL, TRUE);
4720 ReleaseDC(hWnd, hdc);
4727 if (wParam && !HIWORD(lParam))
4729 /* Do something to sub-windows */
4730 for (i = 1; i < MAX_TERM_DATA; i++)
4732 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
4735 /* Focus on main window */
4744 case WM_ACTIVATEAPP:
4746 if (IsIconic(td->w)) break;
4748 for (i = 1; i < MAX_TERM_DATA; i++)
4754 ShowWindow(data[i].w, SW_SHOW);
4758 ShowWindow(data[i].w, SW_HIDE);
4765 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4770 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4771 WPARAM wParam, LPARAM lParam);
4772 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4773 WPARAM wParam, LPARAM lParam)
4774 #else /* __MWERKS__ */
4775 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4776 WPARAM wParam, LPARAM lParam)
4777 #endif /* __MWERKS__ */
4781 MINMAXINFO FAR *lpmmi;
4789 /* Acquire proper "term_data" info */
4790 td = (term_data *)GetWindowLong(hWnd, 0);
4792 /* Process message */
4798 SetWindowLong(hWnd, 0, (LONG)(my_td));
4808 case WM_GETMINMAXINFO:
4810 MINMAXINFO FAR *lpmmi;
4813 lpmmi = (MINMAXINFO FAR *)lParam;
4815 /* this message was sent before WM_NCCREATE */
4818 /* Minimum window size is 80x24 */
4819 rc.left = rc.top = 0;
4820 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
4821 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4824 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4826 /* Save minimum size */
4827 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4828 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4838 /* this message was sent before WM_NCCREATE */
4841 /* it was sent from inside CreateWindowEx */
4842 if (!td->w) return 1;
4844 /* was sent from inside WM_SIZE */
4845 if (td->size_hack) return 1;
4847 td->size_hack = TRUE;
4849 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4850 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4853 if ((td->cols != cols) || (td->rows != rows))
4856 term *old_term = Term;
4858 /* Save the new size */
4863 Term_activate(&td->t);
4865 /* Resize the term */
4866 Term_resize(td->cols, td->rows);
4869 Term_activate(old_term);
4872 InvalidateRect(td->w, NULL, TRUE);
4874 /* HACK - Redraw all windows */
4875 p_ptr->window = 0xFFFFFFFF;
4879 td->size_hack = FALSE;
4886 BeginPaint(hWnd, &ps);
4887 if (td) term_data_redraw(td);
4888 EndPaint(hWnd, &ps);
4895 if (process_keydown(wParam, lParam))
4902 if (Term_no_press) Term_no_press = FALSE;
4903 else Term_keypress(wParam);
4907 case WM_PALETTECHANGED:
4909 /* ignore if palette change caused by itself */
4910 if ((HWND)wParam == hWnd) return FALSE;
4911 /* otherwise, fall through!!! */
4914 case WM_QUERYNEWPALETTE:
4916 if (!paletted) return 0;
4918 SelectPalette(hdc, hPal, FALSE);
4919 i = RealizePalette(hdc);
4920 /* if any palette entries changed, repaint the window. */
4921 if (i) InvalidateRect(hWnd, NULL, TRUE);
4922 ReleaseDC(hWnd, hdc);
4926 case WM_NCLBUTTONDOWN:
4930 if (wParam == HTCLOSE) wParam = HTSYSMENU;
4931 #endif /* HTCLOSE */
4933 if (wParam == HTSYSMENU)
4937 td->visible = FALSE;
4938 ShowWindow(td->w, SW_HIDE);
4948 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4954 #define MOUSE_SENS 40
4957 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4958 WPARAM wParam, LPARAM lParam);
4959 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4960 WPARAM wParam, LPARAM lParam)
4961 #else /* __MWERKS__ */
4962 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4963 WPARAM wParam, LPARAM lParam)
4964 #endif /* __MWERKS__ */
4966 static int iMouse = 0;
4967 static WORD xMouse = 0;
4968 static WORD yMouse = 0;
4991 if (LOWORD(wParam) == WA_INACTIVE) break;
4993 /* else fall through */
4997 case WM_LBUTTONDOWN:
4998 case WM_MBUTTONDOWN:
4999 case WM_RBUTTONDOWN:
5002 SendMessage(hWnd, WM_CLOSE, 0, 0);
5010 dx = LOWORD(lParam) - xMouse;
5011 dy = HIWORD(lParam) - yMouse;
5013 if (dx < 0) dx = -dx;
5014 if (dy < 0) dy = -dy;
5016 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
5018 SendMessage(hWnd, WM_CLOSE, 0, 0);
5022 /* Save last location */
5024 xMouse = LOWORD(lParam);
5025 yMouse = HIWORD(lParam);
5032 DestroyWindow(hwndSaver);
5039 return DefWindowProc(hWnd, uMsg, wParam, lParam);
5042 #endif /* USE_SAVER */
5048 /*** Temporary Hooks ***/
5052 * Display warning message (see "z-util.c")
5054 static void hack_plog(cptr str)
5056 /* Give a warning */
5060 MessageBox(NULL, str, "·Ù¹ð¡ª",
5061 MB_ICONEXCLAMATION | MB_OK);
5063 MessageBox(NULL, str, "Warning",
5064 MB_ICONEXCLAMATION | MB_OK);
5072 * Display error message and quit (see "z-util.c")
5074 static void hack_quit(cptr str)
5076 /* Give a warning */
5080 MessageBox(NULL, str, "¥¨¥é¡¼¡ª",
5081 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5083 MessageBox(NULL, str, "Error",
5084 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5089 /* Unregister the classes */
5090 UnregisterClass(AppName, hInstance);
5092 /* Destroy the icon */
5093 if (hIcon) DestroyIcon(hIcon);
5101 /*** Various hooks ***/
5105 * Display warning message (see "z-util.c")
5107 static void hook_plog(cptr str)
5113 MessageBox(data[0].w, str, "·Ù¹ð¡ª",
5114 MB_ICONEXCLAMATION | MB_OK);
5116 MessageBox(data[0].w, str, "Warning",
5117 MB_ICONEXCLAMATION | MB_OK);
5125 * Display error message and quit (see "z-util.c")
5127 static void hook_quit(cptr str)
5132 /* Give a warning */
5136 MessageBox(data[0].w, str, "¥¨¥é¡¼¡ª",
5137 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5139 MessageBox(data[0].w, str, "Error",
5140 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5146 /* Save the preferences */
5150 /*** Could use 'Term_nuke_win()' XXX XXX XXX */
5152 /* Destroy all windows */
5153 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
5155 term_force_font(&data[i], NULL);
5156 if (data[i].font_want) string_free(data[i].font_want);
5157 if (data[i].w) DestroyWindow(data[i].w);
5161 /* Free the bitmap stuff */
5163 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
5164 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
5166 if (infMask.hPalette) DeleteObject(infMask.hPalette);
5167 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
5169 #endif /* USE_GRAPHICS */
5171 /*** Free some other stuff ***/
5173 DeleteObject(hbrYellow);
5178 if (hPal) DeleteObject(hPal);
5180 UnregisterClass(AppName, hInstance);
5182 if (hIcon) DestroyIcon(hIcon);
5189 /*** Initialize ***/
5195 static void init_stuff(void)
5202 /* Get program name with full path */
5203 GetModuleFileName(hInstance, path, 512);
5205 /* Save the "program name" XXX XXX XXX */
5208 /* Get the name of the "*.ini" file */
5209 strcpy(path + strlen(path) - 4, ".INI");
5211 /* Save the the name of the ini-file */
5212 ini_file = string_make(path);
5214 /* Analyze the path */
5220 if (path[i] == '\\')
5227 /* Add "lib" to the path */
5228 strcpy(path + i + 1, "lib\\");
5230 /* Validate the path */
5231 validate_dir(path, TRUE);
5233 /* Init the file paths */
5234 init_file_paths(path);
5236 /* Hack -- Validate the paths */
5237 validate_dir(ANGBAND_DIR_APEX, FALSE);
5238 validate_dir(ANGBAND_DIR_BONE, FALSE);
5240 /* Allow missing 'edit' directory */
5241 if (!check_dir(ANGBAND_DIR_EDIT))
5243 /* Must have 'data'! */
5244 validate_dir(ANGBAND_DIR_DATA, TRUE);
5248 /* Don't need 'data' */
5249 validate_dir(ANGBAND_DIR_DATA, FALSE);
5252 validate_dir(ANGBAND_DIR_FILE, TRUE);
5253 validate_dir(ANGBAND_DIR_HELP, FALSE);
5254 validate_dir(ANGBAND_DIR_INFO, FALSE);
5255 validate_dir(ANGBAND_DIR_PREF, TRUE);
5256 validate_dir(ANGBAND_DIR_SAVE, FALSE);
5257 validate_dir(ANGBAND_DIR_USER, TRUE);
5258 validate_dir(ANGBAND_DIR_XTRA, TRUE);
5260 /* Build the filename */
5262 path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news_j.txt");
5264 path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news.txt");
5268 /* Hack -- Validate the "news.txt" file */
5269 validate_file(path);
5272 #if 0 /* #ifndef JP */
5273 /* Build the "font" path */
5274 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
5276 /* Allocate the path */
5277 ANGBAND_DIR_XTRA_FONT = string_make(path);
5279 /* Validate the "font" directory */
5280 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
5282 /* Build the filename */
5283 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
5285 /* Hack -- Validate the basic font */
5286 validate_file(path);
5292 /* Build the "graf" path */
5293 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
5295 /* Allocate the path */
5296 ANGBAND_DIR_XTRA_GRAF = string_make(path);
5298 /* Validate the "graf" directory */
5299 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
5301 #endif /* USE_GRAPHICS */
5306 /* Build the "sound" path */
5307 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
5309 /* Allocate the path */
5310 ANGBAND_DIR_XTRA_SOUND = string_make(path);
5312 /* Validate the "sound" directory */
5313 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
5315 #endif /* USE_SOUND */
5319 /* Build the "music" path */
5320 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
5322 /* Allocate the path */
5323 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
5325 /* Validate the "music" directory */
5326 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
5328 #endif /* USE_MUSIC */
5330 /* Build the "help" path */
5331 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
5333 /* Allocate the path */
5334 ANGBAND_DIR_XTRA_HELP = string_make(path);
5336 /* Validate the "help" directory */
5337 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
5341 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
5342 LPSTR lpCmdLine, int nCmdShow)
5357 if (hPrevInst == NULL)
5359 wc.style = CS_CLASSDC;
5360 wc.lpfnWndProc = AngbandWndProc;
5362 wc.cbWndExtra = 4; /* one long pointer to term_data */
5363 wc.hInstance = hInst;
5364 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
5365 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
5366 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
5367 wc.lpszMenuName = AppName;
5368 wc.lpszClassName = AppName;
5370 if (!RegisterClass(&wc)) exit(1);
5372 wc.lpfnWndProc = AngbandListProc;
5373 wc.lpszMenuName = NULL;
5374 wc.lpszClassName = AngList;
5376 if (!RegisterClass(&wc)) exit(2);
5380 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
5381 wc.lpfnWndProc = AngbandSaverProc;
5383 wc.lpszMenuName = NULL;
5384 wc.lpszClassName = "WindowsScreenSaverClass";
5386 if (!RegisterClass(&wc)) exit(3);
5392 /* Temporary hooks */
5393 plog_aux = hack_plog;
5394 quit_aux = hack_quit;
5395 core_aux = hack_quit;
5397 /* Prepare the filepaths */
5400 /* Initialize the keypress analyzer */
5401 for (i = 0; special_key_list[i]; ++i)
5403 special_key[special_key_list[i]] = TRUE;
5405 /* Initialize the keypress analyzer */
5406 for (i = 0; ignore_key_list[i]; ++i)
5408 ignore_key[ignore_key_list[i]] = TRUE;
5411 /* Determine if display is 16/256/true color */
5413 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
5414 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
5415 ReleaseDC(NULL, hdc);
5417 /* Initialize the colors */
5418 for (i = 0; i < 256; i++)
5422 /* Extract desired values */
5423 rv = angband_color_table[i][1];
5424 gv = angband_color_table[i][2];
5425 bv = angband_color_table[i][3];
5427 /* Extract the "complex" code */
5428 win_clr[i] = PALETTERGB(rv, gv, bv);
5430 /* Save the "simple" code */
5431 angband_color_table[i][0] = win_pal[i];
5434 /* Prepare the windows */
5440 /* Activate hooks */
5441 plog_aux = hook_plog;
5442 quit_aux = hook_quit;
5443 core_aux = hook_quit;
5445 /* Set the system suffix */
5446 ANGBAND_SYS = "win";
5448 /* Set the keyboard suffix */
5449 if (7 != GetKeyboardType(0))
5450 ANGBAND_KEYBOARD = "0";
5453 /* Japanese keyboard */
5454 switch (GetKeyboardType(1))
5456 case 0x0D01: case 0x0D02:
5457 case 0x0D03: case 0x0D04:
5458 case 0x0D05: case 0x0D06:
5460 ANGBAND_KEYBOARD = "NEC98";
5464 ANGBAND_KEYBOARD = "JAPAN";
5468 /* Catch nasty signals */
5474 /* We are now initialized */
5477 if(lpCmdLine[0] == '-'){
5478 switch(lpCmdLine[1])
5483 if (!lpCmdLine[2]) break;
5484 chuukei_server = TRUE;
5485 if(connect_chuukei_server(&lpCmdLine[2])<0){
5486 msg_print("connect fail");
5489 msg_print("connect");
5497 if (!lpCmdLine[2]) break;
5498 chuukei_client = TRUE;
5499 connect_chuukei_server(&lpCmdLine[2]);
5507 if (!lpCmdLine[2]) break;
5508 prepare_browse_movie(&lpCmdLine[2]);
5518 /* Did the user double click on a save file? */
5519 if(!chuukei_server) check_for_save_file(lpCmdLine);
5521 /* Did the user double click on a save file? */
5522 check_for_save_file(lpCmdLine);
5525 /* Prompt the user */
5527 prt("[¥Õ¥¡¥¤¥ë] ¥á¥Ë¥å¡¼¤Î [¿·µ¬] ¤Þ¤¿¤Ï [³«¤¯] ¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£", 23, 8);
5529 prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 17);
5534 /* Process messages forever */
5535 while (GetMessage(&msg, NULL, 0, 0))
5537 TranslateMessage(&msg);
5538 DispatchMessage(&msg);
5549 #endif /* WINDOWS */