3 * @brief Windows版固有実装(メインエントリポイント含む)
\r
5 * @author Hengband Team
\r
9 * Windows98かその前後の頃を起点としたAPI実装。
\r
11 * DirectXといった昨今描画に標準的となったライブラリも用いていない。
\r
12 * タイルの描画処理などについては、現在動作の詳細を検証中。
\r
16 * Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others
\r
18 * This software may be copied and distributed for educational, research,
\r
19 * and not for profit purposes provided that this copyright and statement
\r
20 * are included in all such copies.
\r
23 * This file helps Angband work with Windows computers.
\r
25 * To use this file, use an appropriate "Makefile" or "Project File",
\r
26 * make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and
\r
27 * make sure to obtain various extra files as described below.
\r
29 * The official compilation uses the CodeWarrior Pro compiler, which
\r
30 * includes a special project file and precompilable header file.
\r
34 * <del>See also "main-dos.c" and "main-ibm.c".</del>
\r
38 * The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
\r
39 * and/or color redefinitions.
\r
43 * The "lib/user/font-win.prf" contains attr/char mappings for use with the
\r
44 * normal "lib/xtra/font/*.fon" font files.
\r
48 * The "lib/user/graf-win.prf" contains attr/char mappings for use with the
\r
49 * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
\r
54 * Compiling this file, and using the resulting executable, requires
\r
55 * several extra files not distributed with the standard Angband code.
\r
56 * If "USE_GRAPHICS" is defined, then "readdib.h" and "readdib.c" must
\r
57 * be placed into "src/", and the "8X8.BMP" bitmap file must be placed
\r
58 * into "lib/xtra/graf". In any case, some "*.fon" files (including
\r
59 * "8X13.FON" if nothing else) must be placed into "lib/xtra/font/".
\r
60 * If "USE_SOUND" is defined, then some special library (for example,
\r
61 * "winmm.lib") may need to be linked in, and desired "*.WAV" sound
\r
62 * files must be placed into "lib/xtra/sound/". All of these extra
\r
63 * files can be found in the "ext-win" archive.
\r
67 * The "Term_xtra_win_clear()" function should probably do a low-level
\r
68 * clear of the current window, and redraw the borders and other things,
\r
69 * if only for efficiency. XXX XXX XXX
\r
73 * A simpler method is needed for selecting the "tile size" for windows.
\r
78 * The various "warning" messages assume the existance of the "screen.w"
\r
79 * window, I think, and only a few calls actually check for its existance,
\r
80 * this may be okay since "NULL" means "on top of all windows". (?) The
\r
81 * user must never be allowed to "hide" the main window, or the "menubar"
\r
82 * will disappear. XXX XXX XXX
\r
86 * Special "Windows Help Files" can be placed into "lib/xtra/help/" for
\r
87 * use with the "winhelp.exe" program. These files *may* be available
\r
88 * at the ftp site somewhere, but I have not seen them. XXX XXX XXX
\r
92 * Initial framework (and most code) by Ben Harrison (benh@phial.com).
\r
94 * Original code by Skirmantas Kligys (kligys@scf.usc.edu).
\r
96 * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
\r
97 * and Chris R. Martin (crm7479@tam2000.tamu.edu).
\r
101 #include "angband.h"
\r
104 #include <windows.h>
\r
105 #include <direct.h>
\r
106 #include <locale.h>
\r
107 #include "z-term.h"
\r
110 * Extract the "WIN32" flag from the compiler
\r
112 #if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__)
\r
120 * Hack -- allow use of "screen saver" mode
\r
126 * Menu constants -- see "ANGBAND.RC"
\r
129 #define IDM_FILE_NEW 100
\r
130 #define IDM_FILE_OPEN 101
\r
131 #define IDM_FILE_SAVE 110
\r
132 #define IDM_FILE_SCORE 120
\r
133 #define IDM_FILE_MOVIE 121
\r
134 #define IDM_FILE_EXIT 130
\r
136 #define IDM_WINDOW_VIS_0 200
\r
137 #define IDM_WINDOW_VIS_1 201
\r
138 #define IDM_WINDOW_VIS_2 202
\r
139 #define IDM_WINDOW_VIS_3 203
\r
140 #define IDM_WINDOW_VIS_4 204
\r
141 #define IDM_WINDOW_VIS_5 205
\r
142 #define IDM_WINDOW_VIS_6 206
\r
143 #define IDM_WINDOW_VIS_7 207
\r
145 #define IDM_WINDOW_FONT_0 210
\r
146 #define IDM_WINDOW_FONT_1 211
\r
147 #define IDM_WINDOW_FONT_2 212
\r
148 #define IDM_WINDOW_FONT_3 213
\r
149 #define IDM_WINDOW_FONT_4 214
\r
150 #define IDM_WINDOW_FONT_5 215
\r
151 #define IDM_WINDOW_FONT_6 216
\r
152 #define IDM_WINDOW_FONT_7 217
\r
154 #define IDM_WINDOW_POS_0 220
\r
155 #define IDM_WINDOW_POS_1 221
\r
156 #define IDM_WINDOW_POS_2 222
\r
157 #define IDM_WINDOW_POS_3 223
\r
158 #define IDM_WINDOW_POS_4 224
\r
159 #define IDM_WINDOW_POS_5 225
\r
160 #define IDM_WINDOW_POS_6 226
\r
161 #define IDM_WINDOW_POS_7 227
\r
163 #define IDM_WINDOW_BIZ_0 230
\r
164 #define IDM_WINDOW_BIZ_1 231
\r
165 #define IDM_WINDOW_BIZ_2 232
\r
166 #define IDM_WINDOW_BIZ_3 233
\r
167 #define IDM_WINDOW_BIZ_4 234
\r
168 #define IDM_WINDOW_BIZ_5 235
\r
169 #define IDM_WINDOW_BIZ_6 236
\r
170 #define IDM_WINDOW_BIZ_7 237
\r
172 #define IDM_WINDOW_I_WID_0 240
\r
173 #define IDM_WINDOW_I_WID_1 241
\r
174 #define IDM_WINDOW_I_WID_2 242
\r
175 #define IDM_WINDOW_I_WID_3 243
\r
176 #define IDM_WINDOW_I_WID_4 244
\r
177 #define IDM_WINDOW_I_WID_5 245
\r
178 #define IDM_WINDOW_I_WID_6 246
\r
179 #define IDM_WINDOW_I_WID_7 247
\r
181 #define IDM_WINDOW_D_WID_0 250
\r
182 #define IDM_WINDOW_D_WID_1 251
\r
183 #define IDM_WINDOW_D_WID_2 252
\r
184 #define IDM_WINDOW_D_WID_3 253
\r
185 #define IDM_WINDOW_D_WID_4 254
\r
186 #define IDM_WINDOW_D_WID_5 255
\r
187 #define IDM_WINDOW_D_WID_6 256
\r
188 #define IDM_WINDOW_D_WID_7 257
\r
190 #define IDM_WINDOW_I_HGT_0 260
\r
191 #define IDM_WINDOW_I_HGT_1 261
\r
192 #define IDM_WINDOW_I_HGT_2 262
\r
193 #define IDM_WINDOW_I_HGT_3 263
\r
194 #define IDM_WINDOW_I_HGT_4 264
\r
195 #define IDM_WINDOW_I_HGT_5 265
\r
196 #define IDM_WINDOW_I_HGT_6 266
\r
197 #define IDM_WINDOW_I_HGT_7 267
\r
199 #define IDM_WINDOW_D_HGT_0 270
\r
200 #define IDM_WINDOW_D_HGT_1 271
\r
201 #define IDM_WINDOW_D_HGT_2 272
\r
202 #define IDM_WINDOW_D_HGT_3 273
\r
203 #define IDM_WINDOW_D_HGT_4 274
\r
204 #define IDM_WINDOW_D_HGT_5 275
\r
205 #define IDM_WINDOW_D_HGT_6 276
\r
206 #define IDM_WINDOW_D_HGT_7 277
\r
208 #define IDM_OPTIONS_NO_GRAPHICS 400
\r
209 #define IDM_OPTIONS_OLD_GRAPHICS 401
\r
210 #define IDM_OPTIONS_NEW_GRAPHICS 402
\r
211 #define IDM_OPTIONS_NEW2_GRAPHICS 403
\r
212 #define IDM_OPTIONS_BIGTILE 409
\r
213 #define IDM_OPTIONS_SOUND 410
\r
214 #define IDM_OPTIONS_MUSIC 411
\r
215 #define IDM_OPTIONS_SAVER 420
\r
216 #define IDM_OPTIONS_MAP 430
\r
217 #define IDM_OPTIONS_BG 440
\r
218 #define IDM_OPTIONS_OPEN_BG 441
\r
220 #define IDM_DUMP_SCREEN_HTML 450
\r
222 #define IDM_HELP_CONTENTS 901
\r
227 * This may need to be removed for some compilers XXX XXX XXX
\r
234 * Exclude parts of WINDOWS.H that are not needed
\r
236 #define NOCOMM /* Comm driver APIs and definitions */
\r
237 #define NOLOGERROR /* LogError() and related definitions */
\r
238 #define NOPROFILER /* Profiler APIs */
\r
239 #define NOLFILEIO /* _l* file I/O routines */
\r
240 #define NOOPENFILE /* OpenFile and related definitions */
\r
241 #define NORESOURCE /* Resource management */
\r
242 #define NOATOM /* Atom management */
\r
243 #define NOLANGUAGE /* Character test routines */
\r
244 #define NOLSTRING /* lstr* string management routines */
\r
245 #define NODBCS /* Double-byte character set routines */
\r
246 #define NOKEYBOARDINFO /* Keyboard driver routines */
\r
247 #define NOCOLOR /* COLOR_* color values */
\r
248 #define NODRAWTEXT /* DrawText() and related definitions */
\r
249 #define NOSCALABLEFONT /* Truetype scalable font support */
\r
250 #define NOMETAFILE /* Metafile support */
\r
251 #define NOSYSTEMPARAMSINFO /* SystemParametersInfo() and SPI_* definitions */
\r
252 #define NODEFERWINDOWPOS /* DeferWindowPos and related definitions */
\r
253 #define NOKEYSTATES /* MK_* message key state flags */
\r
254 #define NOWH /* SetWindowsHook and related WH_* definitions */
\r
255 #define NOCLIPBOARD /* Clipboard APIs and definitions */
\r
256 #define NOICONS /* IDI_* icon IDs */
\r
257 #define NOMDI /* MDI support */
\r
258 #define NOHELP /* Help support */
\r
260 /* Not defined since it breaks Borland C++ 5.5 */
\r
261 /* #define NOCTLMGR */ /* Control management and controls */
\r
264 * Exclude parts of WINDOWS.H that are not needed (Win32)
\r
266 #define WIN32_LEAN_AND_MEAN
\r
267 #define NONLS /* All NLS defines and routines */
\r
268 #define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
\r
269 #define NOKANJI /* Kanji support stuff. */
\r
270 #define NOMCX /* Modem Configuration Extensions */
\r
273 * Include the "windows" support file
\r
275 #include <windows.h>
\r
278 * Exclude parts of MMSYSTEM.H that are not needed
\r
280 #define MMNODRV /* Installable driver support */
\r
281 #define MMNOWAVE /* Waveform support */
\r
282 #define MMNOMIDI /* MIDI support */
\r
283 #define MMNOAUX /* Auxiliary audio support */
\r
284 #define MMNOTIMER /* Timer support */
\r
285 #define MMNOJOY /* Joystick support */
\r
286 #define MMNOMCI /* MCI support */
\r
287 #define MMNOMMIO /* Multimedia file I/O support */
\r
288 #define MMNOMMSYSTEM /* General MMSYSTEM functions */
\r
291 * Include some more files. Note: the Cygnus Cygwin compiler
\r
292 * doesn't use mmsystem.h instead it includes the winmm library
\r
293 * which performs a similar function.
\r
295 #include <mmsystem.h>
\r
296 #include <commdlg.h>
\r
299 * HTML-Help requires htmlhelp.h and htmlhelp.lib from Microsoft's
\r
300 * HTML Workshop < http://msdn.microsoft.com/workshop/author/htmlhelp/ >.
\r
302 /* #define HTML_HELP */
\r
305 #include <htmlhelp.h>
\r
306 #endif /* HTML_HELP */
\r
309 * Include the support for loading bitmaps
\r
311 #ifdef USE_GRAPHICS
\r
312 # include "readdib.h"
\r
316 * Hack -- Fake declarations from "dos.h" XXX XXX XXX
\r
319 #define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
\r
321 #define FA_LABEL 0x08 /* Volume label */
\r
322 #define FA_DIREC 0x10 /* Directory */
\r
323 unsigned _cdecl _dos_getfileattr(const char *, unsigned *);
\r
327 * Silliness in WIN32 drawing routine
\r
330 # define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL)
\r
334 * Silliness for Windows 95
\r
336 #ifndef WS_EX_TOOLWINDOW
\r
337 # define WS_EX_TOOLWINDOW 0
\r
341 * Foreground color bits (hard-coded by DOS)
\r
343 #define VID_BLACK 0x00
\r
344 #define VID_BLUE 0x01
\r
345 #define VID_GREEN 0x02
\r
346 #define VID_CYAN 0x03
\r
347 #define VID_RED 0x04
\r
348 #define VID_MAGENTA 0x05
\r
349 #define VID_YELLOW 0x06
\r
350 #define VID_WHITE 0x07
\r
353 * Bright text (hard-coded by DOS)
\r
355 #define VID_BRIGHT 0x08
\r
358 * Background color bits (hard-coded by DOS)
\r
360 #define VUD_BLACK 0x00
\r
361 #define VUD_BLUE 0x10
\r
362 #define VUD_GREEN 0x20
\r
363 #define VUD_CYAN 0x30
\r
364 #define VUD_RED 0x40
\r
365 #define VUD_MAGENTA 0x50
\r
366 #define VUD_YELLOW 0x60
\r
367 #define VUD_WHITE 0x70
\r
370 * Blinking text (hard-coded by DOS)
\r
372 #define VUD_BRIGHT 0x80
\r
378 typedef struct _term_data term_data;
\r
381 * Extra "term" data
\r
383 * Note the use of "font_want" for the names of the font file requested by
\r
384 * the user, and the use of "font_file" for the currently active font file.
\r
386 * The "font_file" is uppercased, and takes the form "8X13.FON", while
\r
387 * "font_want" can be in almost any form as long as it could be construed
\r
388 * as attempting to represent the name of a font.
\r
403 TERM_POSITION rows; /* int -> uint */
\r
404 TERM_POSITION cols;
\r
439 #if 1 /* #ifdef JP */
\r
454 * Maximum number of windows XXX XXX XXX
\r
456 #define MAX_TERM_DATA 8
\r
459 * An array of term_data's
\r
461 static term_data data[MAX_TERM_DATA];
\r
464 * Hack -- global "window creation" pointer
\r
466 static term_data *my_td;
\r
469 * Remember normal size of main window when maxmized
\r
474 * was main window maximized on previous playing
\r
476 bool win_maximized = FALSE;
\r
481 bool game_in_progress = FALSE;
\r
484 * note when "open"/"new" become valid
\r
486 bool initialized = FALSE;
\r
489 * screen paletted, i.e. 256 colors
\r
491 bool paletted = FALSE;
\r
494 * 16 colors screen, don't use RGB()
\r
496 bool colors16 = FALSE;
\r
499 * Saved instance handle
\r
501 static HINSTANCE hInstance;
\r
504 * Yellow brush for the cursor
\r
506 static HBRUSH hbrYellow;
\r
511 static HICON hIcon;
\r
516 static HPALETTE hPal;
\r
519 static HBITMAP hBG = NULL;
\r
520 static int use_bg = 0;
\r
521 static char bg_bitmap_file[1024] = "bg.bmp";
\r
526 * The screen saver window
\r
528 static HWND hwndSaver;
\r
530 #endif /* USE_SAVER */
\r
533 #ifdef USE_GRAPHICS
\r
536 * Flag set once "graphics" has been initialized
\r
538 static bool can_use_graphics = FALSE;
\r
541 * The global bitmap
\r
543 static DIBINIT infGraph;
\r
546 * The global bitmap mask
\r
548 static DIBINIT infMask;
\r
550 #endif /* USE_GRAPHICS */
\r
556 * Flag set once "sound" has been initialized
\r
558 static bool can_use_sound = FALSE;
\r
560 #define SAMPLE_MAX 8
\r
562 * An array of sound file names
\r
564 static cptr sound_file[SOUND_MAX][SAMPLE_MAX];
\r
566 #endif /* USE_SOUND */
\r
572 #define SAMPLE_MUSIC_MAX 16
\r
573 static cptr music_file[MUSIC_BASIC_MAX][SAMPLE_MUSIC_MAX];
\r
574 static cptr dungeon_music_file[1000][SAMPLE_MUSIC_MAX];
\r
575 static cptr town_music_file[1000][SAMPLE_MUSIC_MAX];
\r
576 static cptr quest_music_file[1000][SAMPLE_MUSIC_MAX];
\r
577 static bool can_use_music = FALSE;
\r
579 static MCI_OPEN_PARMS mop;
\r
580 static char mci_device_type[256];
\r
582 int current_music_type = 0;
\r
583 int current_music_id = 0;
\r
585 #endif /* USE_MUSIC */
\r
589 * Full path to ANGBAND.INI
\r
591 static cptr ini_file = NULL;
\r
594 * Name of application
\r
596 static cptr AppName = "ANGBAND";
\r
599 * Name of sub-window type
\r
601 static cptr AngList = "AngList";
\r
606 static cptr ANGBAND_DIR_XTRA_GRAF;
\r
607 static cptr ANGBAND_DIR_XTRA_SOUND;
\r
608 static cptr ANGBAND_DIR_XTRA_MUSIC;
\r
609 static cptr ANGBAND_DIR_XTRA_HELP;
\r
610 #if 0 /* #ifndef JP */
\r
611 static cptr ANGBAND_DIR_XTRA_FONT;
\r
614 static cptr ANGBAND_DIR_XTRA_MUSIC;
\r
619 * The "complex" color values
\r
621 static COLORREF win_clr[256];
\r
625 * Flag for macro trigger with dump ASCII
\r
627 static bool Term_no_press = FALSE;
\r
632 static bool mouse_down = FALSE;
\r
633 static bool paint_rect = FALSE;
\r
634 static TERM_POSITION mousex = 0, mousey = 0;
\r
635 static TERM_POSITION oldx, oldy;
\r
639 * The "simple" color values
\r
641 * See "main-ibm.c" for original table information
\r
643 * The entries below are taken from the "color bits" defined above.
\r
645 * Note that many of the choices below suck, but so do crappy monitors.
\r
647 static BYTE win_pal[256] =
\r
649 VID_BLACK, /* Dark */
\r
650 VID_WHITE, /* White */
\r
651 VID_CYAN, /* Slate XXX */
\r
652 VID_RED | VID_BRIGHT, /* Orange XXX */
\r
654 VID_GREEN, /* Green */
\r
655 VID_BLUE, /* Blue */
\r
656 VID_YELLOW, /* Umber XXX */
\r
657 VID_BLACK | VID_BRIGHT, /* Light Dark */
\r
658 VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
\r
659 VID_MAGENTA, /* Violet XXX */
\r
660 VID_YELLOW | VID_BRIGHT, /* Yellow */
\r
661 VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
\r
662 VID_GREEN | VID_BRIGHT, /* Light Green */
\r
663 VID_BLUE | VID_BRIGHT, /* Light Blue */
\r
664 VID_YELLOW /* Light Umber XXX */
\r
669 * Hack -- define which keys are "special"
\r
671 static bool special_key[256];
\r
672 static bool ignore_key[256];
\r
676 * Hack -- initialization list for "special_key"
\r
678 static byte special_key_list[] = {
\r
679 VK_CLEAR, VK_PAUSE, VK_CAPITAL,
\r
680 VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI,
\r
681 VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE,
\r
682 VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
\r
683 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN,
\r
684 VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT,
\r
685 VK_INSERT, VK_DELETE, VK_HELP, VK_APPS,
\r
686 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
\r
687 VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
\r
688 VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD,
\r
689 VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE,
\r
690 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
\r
691 VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
\r
692 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
\r
693 VK_F19,VK_F20, VK_F21, VK_F22, VK_F23, VK_F24,
\r
694 VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL,
\r
695 VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM,
\r
697 0 /* End of List */
\r
700 static byte ignore_key_list[] = {
\r
701 VK_ESCAPE, VK_TAB, VK_SPACE,
\r
702 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
\r
703 VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN,
\r
704 VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL,
\r
705 VK_LMENU, VK_RMENU,
\r
706 0 /* End of List */
\r
710 * Hack -- initialization list for "special_key"
\r
712 * We ignore the modifier keys (shift, control, alt, num lock, scroll lock),
\r
713 * and the normal keys (escape, tab, return, letters, numbers, etc), but we
\r
714 * catch the keypad keys (with and without numlock set, including keypad 5),
\r
715 * the function keys (including the "menu" key which maps to F10), and the
\r
716 * "pause" key (between scroll lock and numlock). We also catch a few odd
\r
717 * keys which I do not recognize, but which are listed among keys which we
\r
718 * do catch, so they should be harmless to catch.
\r
720 static byte special_key_list[] =
\r
722 VK_CLEAR, /* 0x0C (KP<5>) */
\r
724 VK_PAUSE, /* 0x13 (pause) */
\r
726 VK_PRIOR, /* 0x21 (KP<9>) */
\r
727 VK_NEXT, /* 0x22 (KP<3>) */
\r
728 VK_END, /* 0x23 (KP<1>) */
\r
729 VK_HOME, /* 0x24 (KP<7>) */
\r
730 VK_LEFT, /* 0x25 (KP<4>) */
\r
731 VK_UP, /* 0x26 (KP<8>) */
\r
732 VK_RIGHT, /* 0x27 (KP<6>) */
\r
733 VK_DOWN, /* 0x28 (KP<2>) */
\r
734 VK_SELECT, /* 0x29 (?????) */
\r
735 VK_PRINT, /* 0x2A (?????) */
\r
736 VK_EXECUTE, /* 0x2B (?????) */
\r
737 VK_SNAPSHOT, /* 0x2C (?????) */
\r
738 VK_INSERT, /* 0x2D (KP<0>) */
\r
739 VK_DELETE, /* 0x2E (KP<.>) */
\r
740 VK_HELP, /* 0x2F (?????) */
\r
742 VK_NUMPAD0, /* 0x60 (KP<0>) */
\r
743 VK_NUMPAD1, /* 0x61 (KP<1>) */
\r
744 VK_NUMPAD2, /* 0x62 (KP<2>) */
\r
745 VK_NUMPAD3, /* 0x63 (KP<3>) */
\r
746 VK_NUMPAD4, /* 0x64 (KP<4>) */
\r
747 VK_NUMPAD5, /* 0x65 (KP<5>) */
\r
748 VK_NUMPAD6, /* 0x66 (KP<6>) */
\r
749 VK_NUMPAD7, /* 0x67 (KP<7>) */
\r
750 VK_NUMPAD8, /* 0x68 (KP<8>) */
\r
751 VK_NUMPAD9, /* 0x69 (KP<9>) */
\r
752 VK_MULTIPLY, /* 0x6A (KP<*>) */
\r
753 VK_ADD, /* 0x6B (KP<+>) */
\r
754 VK_SEPARATOR, /* 0x6C (?????) */
\r
755 VK_SUBTRACT, /* 0x6D (KP<->) */
\r
756 VK_DECIMAL, /* 0x6E (KP<.>) */
\r
757 VK_DIVIDE, /* 0x6F (KP</>) */
\r
788 /* Function prototype */
\r
790 static bool is_already_running(void);
\r
794 static void delete_bg(void)
\r
803 static int init_bg(void)
\r
805 char * bmfile = bg_bitmap_file;
\r
808 if (use_bg == 0) return 0;
\r
810 hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
\r
812 plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
\r
817 HDC wnddc, dcimage, dcbg;
\r
818 HBITMAP bmimage, bmimage_old, bmbg_old;
\r
823 wnddc = GetDC(hwnd);
\r
824 dcimage = CreateCompatibleDC(wnddc);
\r
825 dcbg = CreateCompatibleDC(wnddc);
\r
827 bmimage = LoadImage(NULL, "bg.bmp", LR_LOADFROMFILE, 0, 0, 0);
\r
828 if (!bmimage) quit("bg.bmpが読みこめない!");
\r
829 bmimage_old = SelectObject(dcimage, bmimage);
\r
831 CreateCompatibleBitmap();
\r
833 ReleaseDC(hwnd, wnddc);
\r
839 static void DrawBG(HDC hdc, RECT *r)
\r
844 int x = r->left, y = r->top;
\r
845 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
\r
847 if (!use_bg || !hBG)
\r
851 GetObject(hBG, sizeof(bm), &bm);
\r
852 swid = bm.bmWidth; shgt = bm.bmHeight;
\r
854 hdcSrc = CreateCompatibleDC(hdc);
\r
855 hOld = SelectObject(hdcSrc, hBG);
\r
859 cwid = MIN(swid - sx, r->right - nx);
\r
862 chgt = MIN(shgt - sy, r->bottom - ny);
\r
863 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
\r
865 } while (ny < r->bottom);
\r
868 } while (nx < r->right);
\r
870 SelectObject(hdcSrc, hOld);
\r
876 * Hack -- given a pathname, point at the filename
\r
878 static cptr extract_file_name(cptr s)
\r
882 /* Start at the end */
\r
883 p = s + strlen(s) - 1;
\r
885 /* Back up to divider */
\r
886 while ((p >= s) && (*p != ':') && (*p != '\\')) p--;
\r
888 /* Return file name */
\r
895 * Hack -- given a simple filename, extract the "font size" info
\r
897 * Return a pointer to a static buffer holding the capitalized base name.
\r
899 #if 0 /* #ifndef JP */
\r
900 static char *analyze_font(char *path, int *wp, int *hp)
\r
906 /* Start at the end */
\r
907 p = path + strlen(path) - 1;
\r
909 /* Back up to divider */
\r
910 while ((p >= path) && (*p != ':') && (*p != '\\')) --p;
\r
912 /* Advance to file name */
\r
916 for (s = p; *s; ++s)
\r
918 /* Capitalize (be paranoid) */
\r
919 if (islower(*s)) *s = toupper(*s);
\r
922 /* Find first 'X' */
\r
923 s = my_strchr(p, 'X');
\r
925 /* Extract font width */
\r
928 /* Extract height */
\r
929 hgt = s ? atoi(s+1) : 0;
\r
942 * Check for existance of a file
\r
944 static bool check_file(cptr s)
\r
954 unsigned int attrib;
\r
964 attrib = GetFileAttributes(path);
\r
966 /* Require valid filename */
\r
967 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
969 /* Prohibit directory */
\r
970 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return (FALSE);
\r
974 /* Examine and verify */
\r
975 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
977 /* Prohibit something */
\r
978 if (attrib & FA_LABEL) return (FALSE);
\r
980 /* Prohibit directory */
\r
981 if (attrib & FA_DIREC) return (FALSE);
\r
991 * Check for existance of a directory
\r
993 static bool check_dir(cptr s)
\r
1005 unsigned int attrib;
\r
1007 #endif /* WIN32 */
\r
1012 /* Check length */
\r
1015 /* Remove trailing backslash */
\r
1016 if (i && (path[i-1] == '\\')) path[--i] = '\0';
\r
1021 attrib = GetFileAttributes(path);
\r
1023 /* Require valid filename */
\r
1024 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
1026 /* Require directory */
\r
1027 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE);
\r
1031 /* Examine and verify */
\r
1032 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
1034 /* Prohibit something */
\r
1035 if (attrib & FA_LABEL) return (FALSE);
\r
1037 /* Require directory */
\r
1038 if (!(attrib & FA_DIREC)) return (FALSE);
\r
1040 #endif /* WIN32 */
\r
1050 static void validate_file(cptr s)
\r
1052 /* Verify or fail */
\r
1053 if (!check_file(s))
\r
1055 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
\r
1061 * Validate a directory
\r
1063 static void validate_dir(cptr s, bool vital)
\r
1065 /* Verify or fail */
\r
1066 if (!check_dir(s))
\r
1068 /* This directory contains needed data */
\r
1071 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
\r
1073 /* Attempt to create this directory */
\r
1074 else if (mkdir(s))
\r
1076 quit_fmt("Unable to create directory:\n%s", s);
\r
1083 * Get the "size" for a window
\r
1085 static void term_getsize(term_data *td)
\r
1092 if (td->cols < 1) td->cols = 1;
\r
1093 if (td->rows < 1) td->rows = 1;
\r
1095 /* Window sizes */
\r
1096 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
1097 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
\r
1099 /* Fake window size */
\r
1101 rc.right = rc.left + wid;
\r
1103 rc.bottom = rc.top + hgt;
\r
1106 /* rc.right += 1; */
\r
1107 /* rc.bottom += 1; */
\r
1110 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
1113 td->size_wid = rc.right - rc.left;
\r
1114 td->size_hgt = rc.bottom - rc.top;
\r
1116 /* See CreateWindowEx */
\r
1117 if (!td->w) return;
\r
1119 /* Extract actual location */
\r
1120 GetWindowRect(td->w, &rc);
\r
1122 /* Save the location */
\r
1123 td->pos_x = rc.left;
\r
1124 td->pos_y = rc.top;
\r
1129 * Write the "prefs" for a single term
\r
1131 static void save_prefs_aux(int i)
\r
1133 term_data *td = &data[i];
\r
1134 char sec_name[128];
\r
1138 WINDOWPLACEMENT lpwndpl;
\r
1141 if (!td->w) return;
\r
1143 /* Make section name */
\r
1144 sprintf(sec_name, "Term-%d", i);
\r
1149 strcpy(buf, td->visible ? "1" : "0");
\r
1150 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
\r
1155 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "MS ゴシック");
\r
1158 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
\r
1160 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
\r
1164 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
\r
1166 #if 1 /* #ifdef JP */
\r
1167 wsprintf(buf, "%d", td->lf.lfWidth);
\r
1168 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
\r
1169 wsprintf(buf, "%d", td->lf.lfHeight);
\r
1170 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
\r
1171 wsprintf(buf, "%d", td->lf.lfWeight);
\r
1172 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
\r
1175 strcpy(buf, td->bizarre ? "1" : "0");
\r
1176 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
\r
1178 /* Tile size (x) */
\r
1179 wsprintf(buf, "%d", td->tile_wid);
\r
1180 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
\r
1182 /* Tile size (y) */
\r
1183 wsprintf(buf, "%d", td->tile_hgt);
\r
1184 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
\r
1186 /* Get window placement and dimensions */
\r
1187 lpwndpl.length = sizeof(WINDOWPLACEMENT);
\r
1188 GetWindowPlacement(td->w, &lpwndpl);
\r
1190 /* Acquire position in *normal* mode (not minimized) */
\r
1191 rc = lpwndpl.rcNormalPosition;
\r
1193 /* Window size (x) */
\r
1194 if (i == 0) wsprintf(buf, "%d", normsize.x);
\r
1195 else wsprintf(buf, "%d", td->cols);
\r
1196 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
\r
1198 /* Window size (y) */
\r
1199 if (i == 0) wsprintf(buf, "%d", normsize.y);
\r
1200 else wsprintf(buf, "%d", td->rows);
\r
1201 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
\r
1203 /* Maxmized (only main window) */
\r
1206 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
\r
1207 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
\r
1210 /* Acquire position */
\r
1211 GetWindowRect(td->w, &rc);
\r
1213 /* Window position (x) */
\r
1214 wsprintf(buf, "%d", rc.left);
\r
1215 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
\r
1217 /* Window position (y) */
\r
1218 wsprintf(buf, "%d", rc.top);
\r
1219 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
\r
1221 /* Window Z position */
\r
1224 strcpy(buf, td->posfix ? "1" : "0");
\r
1225 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
\r
1231 * Write the "prefs"
\r
1233 * We assume that the windows have all been initialized
\r
1235 static void save_prefs(void)
\r
1241 /* Save the "arg_graphics" flag */
\r
1242 sprintf(buf, "%d", arg_graphics);
\r
1243 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
\r
1245 /* Save the "arg_bigtile" flag */
\r
1246 strcpy(buf, arg_bigtile ? "1" : "0");
\r
1247 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
\r
1249 /* Save the "arg_sound" flag */
\r
1250 strcpy(buf, arg_sound ? "1" : "0");
\r
1251 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
\r
1253 /* Save the "arg_sound" flag */
\r
1254 strcpy(buf, arg_music ? "1" : "0");
\r
1255 WritePrivateProfileString("Angband", "Music", buf, ini_file);
\r
1258 strcpy(buf, use_bg ? "1" : "0");
\r
1259 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
\r
1260 WritePrivateProfileString("Angband", "BackGroundBitmap",
\r
1261 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
\r
1263 /* Save window prefs */
\r
1264 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1266 save_prefs_aux(i);
\r
1272 * Load the "prefs" for a single term
\r
1274 static void load_prefs_aux(int i)
\r
1276 term_data *td = &data[i];
\r
1277 char sec_name[128];
\r
1280 int wid, hgt, posx, posy;
\r
1281 int dispx = GetSystemMetrics( SM_CXVIRTUALSCREEN);
\r
1282 int dispy = GetSystemMetrics( SM_CYVIRTUALSCREEN);
\r
1286 /* Make section name */
\r
1287 sprintf(sec_name, "Term-%d", i);
\r
1289 /* Make section name */
\r
1290 sprintf(sec_name, "Term-%d", i);
\r
1295 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
\r
1298 /* Desired font, with default */
\r
1300 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
\r
1303 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
\r
1305 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
\r
1311 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
\r
1313 /* Analyze font, save desired font name */
\r
1314 #if 1 /* #ifdef JP */
\r
1315 td->font_want = string_make(tmp);
\r
1316 hgt = 15; wid = 0;
\r
1317 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
\r
1318 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
\r
1319 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
\r
1321 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
\r
1326 #if 1 /* #ifdef JP */
\r
1327 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
\r
1328 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
\r
1330 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
\r
1331 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
\r
1336 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
\r
1337 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
\r
1338 normsize.x = td->cols; normsize.y = td->rows;
\r
1343 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
\r
1346 /* Window position */
\r
1347 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
\r
1348 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
\r
1349 td->pos_x = MIN(MAX(0, posx), dispx-128);
\r
1350 td->pos_y = MIN(MAX(0, posy), dispy-128);
\r
1352 /* Window Z position */
\r
1355 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
\r
1361 * Load the "prefs"
\r
1363 static void load_prefs(void)
\r
1367 /* Extract the "arg_graphics" flag */
\r
1368 arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
\r
1370 /* Extract the "arg_bigtile" flag */
\r
1371 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
\r
1372 use_bigtile = arg_bigtile;
\r
1374 /* Extract the "arg_sound" flag */
\r
1375 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
\r
1377 /* Extract the "arg_sound" flag */
\r
1378 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
\r
1381 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
\r
1382 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
\r
1384 /* Load window prefs */
\r
1385 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1387 load_prefs_aux(i);
\r
1391 #if defined(USE_SOUND) || defined(USE_MUSIC)
\r
1394 * XXX XXX XXX - Taken from files.c.
\r
1396 * Extract "tokens" from a buffer
\r
1398 * This function uses "whitespace" as delimiters, and treats any amount of
\r
1399 * whitespace as a single delimiter. We will never return any empty tokens.
\r
1400 * When given an empty buffer, or a buffer containing only "whitespace", we
\r
1401 * will return no tokens. We will never extract more than "num" tokens.
\r
1403 * By running a token through the "text_to_ascii()" function, you can allow
\r
1404 * that token to include (encoded) whitespace, using "\s" to encode spaces.
\r
1406 * We save pointers to the tokens in "tokens", and return the number found.
\r
1408 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
\r
1418 /* Skip leading whitespace */
\r
1419 for ( ; *s && iswspace(*s); ++s) /* loop */;
\r
1424 /* Find next whitespace, if any */
\r
1425 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
\r
1427 /* Nuke and advance (if necessary) */
\r
1428 if (*t) *t++ = '\0';
\r
1430 /* Save the token */
\r
1441 #endif /* USE_SOUND || USE_MUSIC */
\r
1445 static void load_sound_prefs(void)
\r
1449 char ini_path[1024];
\r
1450 char wav_path[1024];
\r
1451 char *zz[SAMPLE_MAX];
\r
1453 /* Access the sound.cfg */
\r
1455 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
\r
1457 for (i = 0; i < SOUND_MAX; i++)
\r
1459 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
\r
1461 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
\r
1463 for (j = 0; j < num; j++)
\r
1465 /* Access the sound */
\r
1466 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
\r
1468 /* Save the sound filename, if it exists */
\r
1469 if (check_file(wav_path))
\r
1470 sound_file[i][j] = string_make(zz[j]);
\r
1475 #endif /* USE_SOUND */
\r
1479 static void load_music_prefs(void)
\r
1483 char ini_path[1024];
\r
1484 char wav_path[1024];
\r
1485 char *zz[SAMPLE_MAX];
\r
1488 /* Access the music.cfg */
\r
1490 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
\r
1492 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
\r
1494 for (i = 0; i < MUSIC_BASIC_MAX; i++)
\r
1496 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
\r
1498 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1500 for (j = 0; j < num; j++)
\r
1502 /* Access the sound */
\r
1503 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1505 /* Save the sound filename, if it exists */
\r
1506 if (check_file(wav_path))
\r
1507 music_file[i][j] = string_make(zz[j]);
\r
1511 for (i = 0; i < max_d_idx; i++)
\r
1513 sprintf(key, "dungeon%03d", i);
\r
1514 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
\r
1516 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1518 for (j = 0; j < num; j++)
\r
1520 /* Access the sound */
\r
1521 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1523 /* Save the sound filename, if it exists */
\r
1524 if (check_file(wav_path))
\r
1525 dungeon_music_file[i][j] = string_make(zz[j]);
\r
1529 for (i = 0; i < 1000; i++) /*!< @todo クエスト最大数指定 */
\r
1531 sprintf(key, "quest%03d", i);
\r
1532 GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
\r
1534 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1536 for (j = 0; j < num; j++)
\r
1538 /* Access the sound */
\r
1539 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1541 /* Save the sound filename, if it exists */
\r
1542 if (check_file(wav_path))
\r
1543 quest_music_file[i][j] = string_make(zz[j]);
\r
1547 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
\r
1549 sprintf(key, "town%03d", i);
\r
1550 GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
\r
1552 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1554 for (j = 0; j < num; j++)
\r
1556 /* Access the sound */
\r
1557 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1559 /* Save the sound filename, if it exists */
\r
1560 if (check_file(wav_path))
\r
1561 town_music_file[i][j] = string_make(zz[j]);
\r
1568 #endif /* USE_MUSIC */
\r
1571 * Create the new global palette based on the bitmap palette
\r
1572 * (if any), and the standard 16 entry palette derived from
\r
1573 * "win_clr[]" which is used for the basic 16 Angband colors.
\r
1575 * This function is never called before all windows are ready.
\r
1577 * This function returns FALSE if the new palette could not be
\r
1578 * prepared, which should normally be a fatal error. XXX XXX
\r
1580 * Note that only some machines actually use a "palette".
\r
1582 static int new_palette(void)
\r
1590 LPLOGPALETTE pLogPal;
\r
1591 LPPALETTEENTRY lppe;
\r
1596 /* This makes no sense */
\r
1597 if (!paletted) return (TRUE);
\r
1605 #ifdef USE_GRAPHICS
\r
1607 /* Check the bitmap palette */
\r
1608 hBmPal = infGraph.hPalette;
\r
1610 /* Use the bitmap */
\r
1613 lppeSize = 256 * sizeof(PALETTEENTRY);
\r
1614 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
\r
1615 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
\r
1616 if ((nEntries == 0) || (nEntries > 220))
\r
1618 /* Warn the user */
\r
1619 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
\r
1622 rnfree(lppe, lppeSize);
\r
1629 #endif /* USE_GRAPHICS */
\r
1631 /* Size of palette */
\r
1632 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
\r
1634 /* Allocate palette */
\r
1635 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
\r
1638 pLogPal->palVersion = 0x300;
\r
1640 /* Make room for bitmap and normal data */
\r
1641 pLogPal->palNumEntries = nEntries + 16;
\r
1643 /* Save the bitmap data */
\r
1644 for (i = 0; i < nEntries; i++)
\r
1646 pLogPal->palPalEntry[i] = lppe[i];
\r
1649 /* Save the normal data */
\r
1650 for (i = 0; i < 16; i++)
\r
1654 /* Access the entry */
\r
1655 p = &(pLogPal->palPalEntry[i+nEntries]);
\r
1657 /* Save the colors */
\r
1658 p->peRed = GetRValue(win_clr[i]);
\r
1659 p->peGreen = GetGValue(win_clr[i]);
\r
1660 p->peBlue = GetBValue(win_clr[i]);
\r
1662 /* Save the flags */
\r
1663 p->peFlags = PC_NOCOLLAPSE;
\r
1666 /* Free something */
\r
1667 if (lppe) rnfree(lppe, lppeSize);
\r
1669 /* Create a new palette, or fail */
\r
1670 hNewPal = CreatePalette(pLogPal);
\r
1671 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
\r
1673 /* Free the palette */
\r
1674 rnfree(pLogPal, pLogPalSize);
\r
1679 /* Realize the palette */
\r
1680 hdc = GetDC(td->w);
\r
1681 SelectPalette(hdc, hNewPal, 0);
\r
1682 i = RealizePalette(hdc);
\r
1683 ReleaseDC(td->w, hdc);
\r
1684 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
\r
1688 for (i = 1; i < MAX_TERM_DATA; i++)
\r
1692 hdc = GetDC(td->w);
\r
1693 SelectPalette(hdc, hNewPal, 0);
\r
1694 ReleaseDC(td->w, hdc);
\r
1697 /* Delete old palette */
\r
1698 if (hPal) DeleteObject(hPal);
\r
1700 /* Save new palette */
\r
1708 #ifdef USE_GRAPHICS
\r
1710 * Initialize graphics
\r
1712 static bool init_graphics(void)
\r
1714 /* Initialize once */
\r
1715 /* if (can_use_graphics != arg_graphics) */
\r
1718 BYTE wid, hgt, twid, thgt, ox, oy;
\r
1721 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1729 name = "16X16.BMP";
\r
1731 ANGBAND_GRAF = "new";
\r
1733 else if (arg_graphics == GRAPHICS_HENGBAND)
\r
1742 name = "64X64.BMP";
\r
1751 name = "32X32.BMP";
\r
1753 ANGBAND_GRAF = "ne2";
\r
1764 ANGBAND_GRAF = "old";
\r
1767 /* Access the bitmap file */
\r
1768 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
\r
1770 /* Load the bitmap or quit */
\r
1771 if (!ReadDIB(data[0].w, buf, &infGraph))
\r
1773 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
\r
1777 /* Save the new sizes */
\r
1778 infGraph.CellWidth = wid;
\r
1779 infGraph.CellHeight = hgt;
\r
1780 infGraph.TileWidth = twid;
\r
1781 infGraph.TileHeight = thgt;
\r
1782 infGraph.OffsetX = ox;
\r
1783 infGraph.OffsetY = oy;
\r
1785 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1787 /* Access the mask file */
\r
1788 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
\r
1790 /* Load the bitmap or quit */
\r
1791 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1793 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1797 if (arg_graphics == GRAPHICS_HENGBAND)
\r
1799 /* Access the mask file */
\r
1800 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
\r
1802 /* Load the bitmap or quit */
\r
1803 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1805 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1810 /* Activate a palette */
\r
1811 if (!new_palette())
\r
1813 /* Free bitmap XXX XXX XXX */
\r
1816 plog(_("パレットを実現できません!", "Cannot activate palette!"));
\r
1820 /* Graphics available */
\r
1821 can_use_graphics = arg_graphics;
\r
1825 return (can_use_graphics);
\r
1827 #endif /* USE_GRAPHICS */
\r
1832 * Initialize music
\r
1834 static bool init_music(void)
\r
1836 /* Initialize once */
\r
1837 if (!can_use_music)
\r
1839 /* Load the prefs */
\r
1840 load_music_prefs();
\r
1842 /* Sound available */
\r
1843 can_use_music = TRUE;
\r
1847 return (can_use_music);
\r
1851 * Hack -- Stop a music
\r
1853 static void stop_music(void)
\r
1855 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
1856 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
1859 #endif /* USE_MUSIC */
\r
1863 * Initialize sound
\r
1865 static bool init_sound(void)
\r
1867 /* Initialize once */
\r
1868 if (!can_use_sound)
\r
1870 /* Load the prefs */
\r
1871 load_sound_prefs();
\r
1873 /* Sound available */
\r
1874 can_use_sound = TRUE;
\r
1878 return (can_use_sound);
\r
1880 #endif /* USE_SOUND */
\r
1886 static void term_window_resize(term_data *td)
\r
1888 /* Require window */
\r
1889 if (!td->w) return;
\r
1891 /* Resize the window */
\r
1892 SetWindowPos(td->w, 0, 0, 0,
\r
1893 td->size_wid, td->size_hgt,
\r
1894 SWP_NOMOVE | SWP_NOZORDER);
\r
1896 /* Redraw later */
\r
1897 InvalidateRect(td->w, NULL, TRUE);
\r
1902 * Force the use of a new "font file" for a term_data
\r
1904 * This function may be called before the "window" is ready
\r
1906 * This function returns zero only if everything succeeds.
\r
1908 * Note that the "font name" must be capitalized!!!
\r
1910 static errr term_force_font(term_data *td, cptr path)
\r
1914 #if 0 /* #ifndef JP */
\r
1920 /* Forget the old font (if needed) */
\r
1921 if (td->font_id) DeleteObject(td->font_id);
\r
1923 #if 1 /* #ifdef JP */
\r
1927 /* Create the font (using the 'base' of the font file name!) */
\r
1928 td->font_id = CreateFontIndirect(&(td->lf));
\r
1929 wid = td->lf.lfWidth;
\r
1930 hgt = td->lf.lfHeight;
\r
1931 if (!td->font_id) return (1);
\r
1933 /* Forget old font */
\r
1934 if (td->font_file)
\r
1936 bool used = FALSE;
\r
1938 /* Scan windows */
\r
1939 for (i = 0; i < MAX_TERM_DATA; i++)
\r
1941 /* Don't check when closing the application */
\r
1944 /* Check "screen" */
\r
1945 if ((td != &data[i]) &&
\r
1946 (data[i].font_file) &&
\r
1947 (streq(data[i].font_file, td->font_file)))
\r
1953 /* Remove unused font resources */
\r
1954 if (!used) RemoveFontResource(td->font_file);
\r
1956 /* Free the old name */
\r
1957 string_free(td->font_file);
\r
1960 td->font_file = NULL;
\r
1963 /* No path given */
\r
1964 if (!path) return (1);
\r
1967 strcpy(buf, path);
\r
1969 /* Analyze font path */
\r
1970 base = analyze_font(buf, &wid, &hgt);
\r
1972 /* Verify suffix */
\r
1973 if (!suffix(base, ".FON")) return (1);
\r
1976 if (!check_file(buf)) return (1);
\r
1978 /* Load the new font */
\r
1979 if (!AddFontResource(buf)) return (1);
\r
1981 /* Save new font name */
\r
1982 td->font_file = string_make(base);
\r
1984 /* Remove the "suffix" */
\r
1985 base[strlen(base)-4] = '\0';
\r
1987 /* Create the font (using the 'base' of the font file name!) */
\r
1988 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
\r
1989 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
\r
1990 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
\r
1991 FIXED_PITCH | FF_DONTCARE, base);
\r
1994 /* Hack -- Unknown size */
\r
2001 /* all this trouble to get the cell size */
\r
2002 hdcDesktop = GetDC(HWND_DESKTOP);
\r
2003 hfOld = SelectObject(hdcDesktop, td->font_id);
\r
2004 GetTextMetrics(hdcDesktop, &tm);
\r
2005 SelectObject(hdcDesktop, hfOld);
\r
2006 ReleaseDC(HWND_DESKTOP, hdcDesktop);
\r
2008 /* Font size info */
\r
2009 wid = tm.tmAveCharWidth;
\r
2010 hgt = tm.tmHeight;
\r
2013 /* Save the size info */
\r
2014 td->font_wid = wid;
\r
2015 td->font_hgt = hgt;
\r
2024 * Allow the user to change the font for this window.
\r
2026 static void term_change_font(term_data *td)
\r
2028 #if 1 /* #ifdef JP */
\r
2031 memset(&cf, 0, sizeof(cf));
\r
2032 cf.lStructSize = sizeof(cf);
\r
2033 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
\r
2034 cf.lpLogFont = &(td->lf);
\r
2036 if (ChooseFont(&cf))
\r
2038 /* Force the font */
\r
2039 term_force_font(td, NULL);
\r
2041 /* Assume not bizarre */
\r
2042 td->bizarre = TRUE;
\r
2044 /* Reset the tile info */
\r
2045 td->tile_wid = td->font_wid;
\r
2046 td->tile_hgt = td->font_hgt;
\r
2048 /* Analyze the font */
\r
2051 /* Resize the window */
\r
2052 term_window_resize(td);
\r
2058 char tmp[1024] = "";
\r
2060 /* Extract a default if possible */
\r
2061 if (td->font_file) strcpy(tmp, td->font_file);
\r
2063 /* Ask for a choice */
\r
2064 memset(&ofn, 0, sizeof(ofn));
\r
2065 ofn.lStructSize = sizeof(ofn);
\r
2066 ofn.hwndOwner = data[0].w;
\r
2067 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
\r
2068 ofn.nFilterIndex = 1;
\r
2069 ofn.lpstrFile = tmp;
\r
2070 ofn.nMaxFile = 128;
\r
2071 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
\r
2072 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
2073 ofn.lpstrDefExt = "fon";
\r
2075 /* Force choice if legal */
\r
2076 if (GetOpenFileName(&ofn))
\r
2078 /* Force the font */
\r
2079 if (term_force_font(td, tmp))
\r
2081 /* Access the standard font file */
\r
2082 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
2084 /* Force the use of that font */
\r
2085 (void)term_force_font(td, tmp);
\r
2088 /* Assume not bizarre */
\r
2089 td->bizarre = FALSE;
\r
2091 /* Reset the tile info */
\r
2092 td->tile_wid = td->font_wid;
\r
2093 td->tile_hgt = td->font_hgt;
\r
2095 /* Analyze the font */
\r
2098 /* Resize the window */
\r
2099 term_window_resize(td);
\r
2106 * Allow the user to lock this window.
\r
2108 static void term_window_pos(term_data *td, HWND hWnd)
\r
2110 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
\r
2111 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
\r
2114 static void windows_map(void);
\r
2117 * Hack -- redraw a term_data
\r
2119 static void term_data_redraw(term_data *td)
\r
2121 if (td->map_active)
\r
2123 /* Redraw the map */
\r
2128 /* Activate the term */
\r
2129 Term_activate(&td->t);
\r
2131 /* Redraw the contents */
\r
2134 /* Restore the term */
\r
2135 Term_activate(term_screen);
\r
2140 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
\r
2144 HBRUSH myBrush, oldBrush;
\r
2146 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
\r
2147 int tx = td->size_ow1 + x * td->tile_wid;
\r
2148 int ty = td->size_oh1 + y * td->tile_hgt;
\r
2149 int tw = w * td->tile_wid - 1;
\r
2150 int th = h * td->tile_hgt - 1;
\r
2152 hdc = GetDC(hWnd);
\r
2153 myBrush = CreateSolidBrush(RGB(255, 255, 255));
\r
2154 oldBrush = SelectObject(hdc, myBrush);
\r
2155 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2157 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
\r
2159 SelectObject(hdc, oldBrush);
\r
2160 SelectObject(hdc, oldPen);
\r
2165 /*** Function hooks needed by "Term" ***/
\r
2171 * Initialize a new Term
\r
2173 static void Term_init_win(term *t)
\r
2180 * Nuke an old Term
\r
2182 static void Term_nuke_win(term *t)
\r
2191 * Interact with the User
\r
2193 static errr Term_user_win(int n)
\r
2204 * React to global changes
\r
2206 static errr Term_xtra_win_react(void)
\r
2211 /* Simple color */
\r
2214 /* Save the default colors */
\r
2215 for (i = 0; i < 256; i++)
\r
2217 /* Simply accept the desired colors */
\r
2218 win_pal[i] = angband_color_table[i][0];
\r
2222 /* Complex color */
\r
2229 bool change = FALSE;
\r
2231 /* Save the default colors */
\r
2232 for (i = 0; i < 256; i++)
\r
2234 /* Extract desired values */
\r
2235 rv = angband_color_table[i][1];
\r
2236 gv = angband_color_table[i][2];
\r
2237 bv = angband_color_table[i][3];
\r
2239 /* Extract a full color code */
\r
2240 code = PALETTERGB(rv, gv, bv);
\r
2242 /* Activate changes */
\r
2243 if (win_clr[i] != code)
\r
2245 /* Note the change */
\r
2248 /* Apply the desired color */
\r
2249 win_clr[i] = code;
\r
2253 /* Activate the palette if needed */
\r
2254 if (change) (void)new_palette();
\r
2260 /* Handle "arg_sound" */
\r
2261 if (use_sound != arg_sound)
\r
2263 /* Initialize (if needed) */
\r
2264 if (arg_sound && !init_sound())
\r
2267 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
\r
2269 /* Cannot enable */
\r
2270 arg_sound = FALSE;
\r
2273 /* Change setting */
\r
2274 use_sound = arg_sound;
\r
2281 /* Handle "arg_sound" */
\r
2282 if (use_music != arg_music)
\r
2284 /* Initialize (if needed) */
\r
2285 if (arg_music && !init_music())
\r
2288 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
\r
2289 /* Cannot enable */
\r
2290 arg_music = FALSE;
\r
2293 /* Change setting */
\r
2294 use_music = arg_music;
\r
2296 if(!arg_music) stop_music();
\r
2297 else select_floor_music();
\r
2304 #ifdef USE_GRAPHICS
\r
2306 /* Handle "arg_graphics" */
\r
2307 if (use_graphics != arg_graphics)
\r
2309 /* Initialize (if needed) */
\r
2310 if (arg_graphics && !init_graphics())
\r
2313 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
\r
2315 /* Cannot enable */
\r
2316 arg_graphics = GRAPHICS_NONE;
\r
2319 /* Change setting */
\r
2320 use_graphics = arg_graphics;
\r
2322 /* Reset visuals */
\r
2323 #ifdef ANGBAND_2_8_1
\r
2325 #else /* ANGBAND_2_8_1 */
\r
2326 reset_visuals(TRUE);
\r
2327 #endif /* ANGBAND_2_8_1 */
\r
2330 #endif /* USE_GRAPHICS */
\r
2333 /* Clean up windows */
\r
2334 for (i = 0; i < MAX_TERM_DATA; i++)
\r
2338 term_data *td = &data[i];
\r
2340 /* Update resized windows */
\r
2341 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
\r
2344 Term_activate(&td->t);
\r
2346 /* Hack -- Resize the term */
\r
2347 Term_resize(td->cols, td->rows);
\r
2349 /* Redraw the contents */
\r
2353 Term_activate(old);
\r
2364 * Process at least one event
\r
2366 static errr Term_xtra_win_event(int v)
\r
2370 /* Wait for an event */
\r
2374 if (GetMessage(&msg, NULL, 0, 0))
\r
2376 TranslateMessage(&msg);
\r
2377 DispatchMessage(&msg);
\r
2381 /* Check for an event */
\r
2385 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2387 TranslateMessage(&msg);
\r
2388 DispatchMessage(&msg);
\r
2398 * Process all pending events
\r
2400 static errr Term_xtra_win_flush(void)
\r
2404 /* Process all pending events */
\r
2405 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2407 TranslateMessage(&msg);
\r
2408 DispatchMessage(&msg);
\r
2417 * Hack -- clear the screen
\r
2419 * Make this more efficient XXX XXX XXX
\r
2421 static errr Term_xtra_win_clear(void)
\r
2423 term_data *td = (term_data*)(Term->data);
\r
2428 /* Rectangle to erase */
\r
2429 rc.left = td->size_ow1;
\r
2430 rc.right = rc.left + td->cols * td->tile_wid;
\r
2431 rc.top = td->size_oh1;
\r
2432 rc.bottom = rc.top + td->rows * td->tile_hgt;
\r
2435 hdc = GetDC(td->w);
\r
2436 SetBkColor(hdc, RGB(0, 0, 0));
\r
2437 SelectObject(hdc, td->font_id);
\r
2438 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2443 rc.left = 0; rc.top = 0;
\r
2446 ReleaseDC(td->w, hdc);
\r
2454 * Hack -- make a noise
\r
2456 static errr Term_xtra_win_noise(void)
\r
2458 MessageBeep(MB_ICONASTERISK);
\r
2464 * Hack -- make a sound
\r
2466 static errr Term_xtra_win_sound(int v)
\r
2471 #endif /* USE_SOUND */
\r
2473 /* Sound disabled */
\r
2474 if (!use_sound) return (1);
\r
2476 /* Illegal sound */
\r
2477 if ((v < 0) || (v >= SOUND_MAX)) return (1);
\r
2481 /* Count the samples */
\r
2482 for (i = 0; i < SAMPLE_MAX; i++)
\r
2484 if (!sound_file[v][i])
\r
2489 if (i == 0) return (1);
\r
2491 /* Build the path */
\r
2492 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
\r
2496 /* Play the sound, catch errors */
\r
2497 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
\r
2501 /* Play the sound, catch errors */
\r
2502 return (sndPlaySound(buf, SND_ASYNC));
\r
2504 #endif /* WIN32 */
\r
2506 #else /* USE_SOUND */
\r
2511 #endif /* USE_SOUND */
\r
2515 * Hack -- play a music
\r
2517 static errr Term_xtra_win_music(int n, int v)
\r
2522 #endif /* USE_MUSIC */
\r
2524 /* Sound disabled */
\r
2526 if(!use_music) return (1);
\r
2528 /* Illegal sound */
\r
2529 if(n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return (1);
\r
2530 else if(v < 0 || v >= 1000) return(1); /*!< TODO */
\r
2536 case TERM_XTRA_MUSIC_BASIC:
\r
2537 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2539 case TERM_XTRA_MUSIC_DUNGEON:
\r
2540 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2542 case TERM_XTRA_MUSIC_QUEST:
\r
2543 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2545 case TERM_XTRA_MUSIC_TOWN:
\r
2546 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2553 //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2554 //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2560 case TERM_XTRA_MUSIC_BASIC:
\r
2561 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2563 case TERM_XTRA_MUSIC_DUNGEON:
\r
2564 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2566 case TERM_XTRA_MUSIC_QUEST:
\r
2567 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2569 case TERM_XTRA_MUSIC_TOWN:
\r
2570 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2577 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2578 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2584 case TERM_XTRA_MUSIC_BASIC:
\r
2585 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
\r
2587 case TERM_XTRA_MUSIC_DUNGEON:
\r
2588 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
\r
2590 case TERM_XTRA_MUSIC_QUEST:
\r
2591 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
\r
2593 case TERM_XTRA_MUSIC_TOWN:
\r
2594 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
\r
2598 if(current_music_type == n && current_music_id == v)
\r
2602 current_music_type = n;
\r
2603 current_music_id = v;
\r
2607 mop.lpstrDeviceType = mci_device_type;
\r
2608 mop.lpstrElementName = buf;
\r
2609 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2610 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2611 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
\r
2612 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
2613 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
2616 #endif /* WIN32 */
\r
2618 #else /* USE_MUSIC */
\r
2622 #endif /* USE_MUSIC */
\r
2628 * Delay for "x" milliseconds
\r
2630 static int Term_xtra_win_delay(int v)
\r
2644 t = GetTickCount() + v;
\r
2647 while (GetTickCount() < t)
\r
2649 /* Handle messages */
\r
2650 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2652 TranslateMessage(&msg);
\r
2653 DispatchMessage(&msg);
\r
2657 #endif /* WIN32 */
\r
2665 * Do a "special thing"
\r
2667 static errr Term_xtra_win(int n, int v)
\r
2669 /* Handle a subset of the legal requests */
\r
2672 /* Make a bell sound */
\r
2673 case TERM_XTRA_NOISE:
\r
2675 return (Term_xtra_win_noise());
\r
2678 /* Play a music */
\r
2679 case TERM_XTRA_MUSIC_BASIC:
\r
2680 case TERM_XTRA_MUSIC_DUNGEON:
\r
2681 case TERM_XTRA_MUSIC_QUEST:
\r
2682 case TERM_XTRA_MUSIC_TOWN:
\r
2684 return (Term_xtra_win_music(n, v));
\r
2687 /* Make a special sound */
\r
2688 case TERM_XTRA_SOUND:
\r
2690 return (Term_xtra_win_sound(v));
\r
2693 /* Process random events */
\r
2694 case TERM_XTRA_BORED:
\r
2696 return (Term_xtra_win_event(0));
\r
2699 /* Process an event */
\r
2700 case TERM_XTRA_EVENT:
\r
2702 return (Term_xtra_win_event(v));
\r
2705 /* Flush all events */
\r
2706 case TERM_XTRA_FLUSH:
\r
2708 return (Term_xtra_win_flush());
\r
2711 /* Clear the screen */
\r
2712 case TERM_XTRA_CLEAR:
\r
2714 return (Term_xtra_win_clear());
\r
2717 /* React to global changes */
\r
2718 case TERM_XTRA_REACT:
\r
2720 return (Term_xtra_win_react());
\r
2723 /* Delay for some milliseconds */
\r
2724 case TERM_XTRA_DELAY:
\r
2726 return (Term_xtra_win_delay(v));
\r
2737 * Low level graphics (Assumes valid input).
\r
2739 * Draw a "cursor" at (x,y), using a "yellow box".
\r
2741 static errr Term_curs_win(int x, int y)
\r
2743 term_data *td = (term_data*)(Term->data);
\r
2748 int tile_wid, tile_hgt;
\r
2750 if (td->map_active)
\r
2752 tile_wid = td->map_tile_wid;
\r
2753 tile_hgt = td->map_tile_hgt;
\r
2757 tile_wid = td->tile_wid;
\r
2758 tile_hgt = td->tile_hgt;
\r
2761 /* Frame the grid */
\r
2762 rc.left = x * tile_wid + td->size_ow1;
\r
2763 rc.right = rc.left + tile_wid;
\r
2764 rc.top = y * tile_hgt + td->size_oh1;
\r
2765 rc.bottom = rc.top + tile_hgt;
\r
2767 /* Cursor is done as a yellow "box" */
\r
2768 hdc = GetDC(td->w);
\r
2769 FrameRect(hdc, &rc, hbrYellow);
\r
2770 ReleaseDC(td->w, hdc);
\r
2778 * Low level graphics (Assumes valid input).
\r
2780 * Draw a "big cursor" at (x,y), using a "yellow box".
\r
2782 static errr Term_bigcurs_win(int x, int y)
\r
2784 term_data *td = (term_data*)(Term->data);
\r
2789 int tile_wid, tile_hgt;
\r
2791 if (td->map_active)
\r
2793 /* Normal cursor in map window */
\r
2794 Term_curs_win(x, y);
\r
2799 tile_wid = td->tile_wid;
\r
2800 tile_hgt = td->tile_hgt;
\r
2803 /* Frame the grid */
\r
2804 rc.left = x * tile_wid + td->size_ow1;
\r
2805 rc.right = rc.left + 2 * tile_wid;
\r
2806 rc.top = y * tile_hgt + td->size_oh1;
\r
2807 rc.bottom = rc.top + tile_hgt;
\r
2809 /* Cursor is done as a yellow "box" */
\r
2810 hdc = GetDC(td->w);
\r
2811 FrameRect(hdc, &rc, hbrYellow);
\r
2812 ReleaseDC(td->w, hdc);
\r
2820 * Low level graphics (Assumes valid input).
\r
2822 * Erase a "block" of "n" characters starting at (x,y).
\r
2824 static errr Term_wipe_win(int x, int y, int n)
\r
2826 term_data *td = (term_data*)(Term->data);
\r
2831 /* Rectangle to erase in client coords */
\r
2832 rc.left = x * td->tile_wid + td->size_ow1;
\r
2833 rc.right = rc.left + n * td->tile_wid;
\r
2834 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2835 rc.bottom = rc.top + td->tile_hgt;
\r
2837 hdc = GetDC(td->w);
\r
2838 SetBkColor(hdc, RGB(0, 0, 0));
\r
2839 SelectObject(hdc, td->font_id);
\r
2844 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2845 ReleaseDC(td->w, hdc);
\r
2853 * Low level graphics. Assumes valid input.
\r
2855 * Draw several ("n") chars, with an attr, at a given location.
\r
2857 * All "graphic" data is handled by "Term_pict_win()", below.
\r
2859 * One would think there is a more efficient method for telling a window
\r
2860 * what color it should be using to draw with, but perhaps simply changing
\r
2861 * it every time is not too inefficient. XXX XXX XXX
\r
2863 static errr Term_text_win(int x, int y, int n, byte a, const char *s)
\r
2865 term_data *td = (term_data*)(Term->data);
\r
2869 #if 1 /* #ifdef JP */
\r
2870 static HBITMAP WALL;
\r
2871 static HBRUSH myBrush, oldBrush;
\r
2872 static HPEN oldPen;
\r
2873 static bool init_done = FALSE;
\r
2876 WALL = LoadBitmap(hInstance, AppName);
\r
2877 myBrush = CreatePatternBrush(WALL);
\r
2882 /* Total rectangle */
\r
2883 rc.left = x * td->tile_wid + td->size_ow1;
\r
2884 rc.right = rc.left + n * td->tile_wid;
\r
2885 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2886 rc.bottom = rc.top + td->tile_hgt;
\r
2889 hdc = GetDC(td->w);
\r
2891 /* Background color */
\r
2892 SetBkColor(hdc, RGB(0, 0, 0));
\r
2894 /* Foreground color */
\r
2897 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
\r
2899 else if (paletted)
\r
2901 SetTextColor(hdc, win_clr[a&0x0F]);
\r
2905 SetTextColor(hdc, win_clr[a]);
\r
2908 /* Use the font */
\r
2909 SelectObject(hdc, td->font_id);
\r
2912 if (use_bg) SetBkMode(hdc, TRANSPARENT);
\r
2914 /* Bizarre size */
\r
2915 if (td->bizarre ||
\r
2916 (td->tile_hgt != td->font_hgt) ||
\r
2917 (td->tile_wid != td->font_wid))
\r
2921 /* Erase complete rectangle */
\r
2922 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2925 if (use_bg) DrawBG(hdc, &rc);
\r
2927 /* New rectangle */
\r
2928 rc.left += ((td->tile_wid - td->font_wid) / 2);
\r
2929 rc.right = rc.left + td->font_wid;
\r
2930 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
\r
2931 rc.bottom = rc.top + td->font_hgt;
\r
2933 /* Dump each character */
\r
2934 for (i = 0; i < n; i++)
\r
2937 if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
\r
2939 rc.right += td->font_wid;
\r
2941 oldBrush = SelectObject(hdc, myBrush);
\r
2942 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2944 /* Dump the wall */
\r
2945 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2947 SelectObject(hdc, oldBrush);
\r
2948 SelectObject(hdc, oldPen);
\r
2949 rc.right -= td->font_wid;
\r
2953 rc.left += 2 * td->tile_wid;
\r
2954 rc.right += 2 * td->tile_wid;
\r
2956 else if ( iskanji(*(s+i)) ) /* 2バイト文字 */
\r
2958 rc.right += td->font_wid;
\r
2959 /* Dump the text */
\r
2960 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2962 rc.right -= td->font_wid;
\r
2966 rc.left += 2 * td->tile_wid;
\r
2967 rc.right += 2 * td->tile_wid;
\r
2968 } else if (*(s+i)==127){
\r
2969 oldBrush = SelectObject(hdc, myBrush);
\r
2970 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2972 /* Dump the wall */
\r
2973 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2975 SelectObject(hdc, oldBrush);
\r
2976 SelectObject(hdc, oldPen);
\r
2979 rc.left += td->tile_wid;
\r
2980 rc.right += td->tile_wid;
\r
2982 /* Dump the text */
\r
2983 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
\r
2986 rc.left += td->tile_wid;
\r
2987 rc.right += td->tile_wid;
\r
2992 oldBrush = SelectObject(hdc, myBrush);
\r
2993 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2995 /* Dump the wall */
\r
2996 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2998 SelectObject(hdc, oldBrush);
\r
2999 SelectObject(hdc, oldPen);
\r
3002 rc.left += td->tile_wid;
\r
3003 rc.right += td->tile_wid;
\r
3005 /* Dump the text */
\r
3006 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
3010 rc.left += td->tile_wid;
\r
3011 rc.right += td->tile_wid;
\r
3014 /* Dump the text */
\r
3015 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
\r
3019 rc.left += td->tile_wid;
\r
3020 rc.right += td->tile_wid;
\r
3030 /* Dump the text */
\r
3031 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
\r
3036 ReleaseDC(td->w, hdc);
\r
3044 * Low level graphics. Assumes valid input.
\r
3046 * Draw an array of "special" attr/char pairs at the given location.
\r
3048 * We use the "Term_pict_win()" function for "graphic" data, which are
\r
3049 * encoded by setting the "high-bits" of both the "attr" and the "char"
\r
3050 * data. We use the "attr" to represent the "row" of the main bitmap,
\r
3051 * and the "char" to represent the "col" of the main bitmap. The use
\r
3052 * of this function is induced by the "higher_pict" flag.
\r
3054 * If "graphics" is not available, we simply "wipe" the given grids.
\r
3056 static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
\r
3058 term_data *td = (term_data*)(Term->data);
\r
3060 #ifdef USE_GRAPHICS
\r
3063 int x1, y1, w1, h1, tw1, th1;
\r
3064 int x2, y2, w2, h2, tw2 = 0;
\r
3067 HDC hdcMask = NULL;
\r
3071 HBITMAP hbmSrcOld;
\r
3074 if (!use_graphics)
\r
3076 /* Erase the grids */
\r
3077 return (Term_wipe_win(x, y, n));
\r
3080 /* Size of bitmap cell */
\r
3081 w1 = infGraph.CellWidth;
\r
3082 h1 = infGraph.CellHeight;
\r
3083 tw1 = infGraph.TileWidth;
\r
3084 th1 = infGraph.TileHeight;
\r
3086 /* Size of window cell */
\r
3087 if (td->map_active)
\r
3089 w2 = td->map_tile_wid;
\r
3090 h2 = td->map_tile_hgt;
\r
3094 w2 = td->tile_wid;
\r
3095 h2 = td->tile_hgt;
\r
3098 /* big tile mode */
\r
3099 if (use_bigtile) tw2 *= 2;
\r
3102 /* Location of window cell */
\r
3103 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
\r
3104 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
\r
3107 hdc = GetDC(td->w);
\r
3110 hdcSrc = CreateCompatibleDC(hdc);
\r
3111 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
\r
3113 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3115 hdcMask = CreateCompatibleDC(hdc);
\r
3116 SelectObject(hdcMask, infMask.hBitmap);
\r
3119 /* Draw attr/char pairs */
\r
3120 for (i = 0; i < n; i++, x2 += w2)
\r
3126 /* Extract picture */
\r
3127 int row = (a & 0x7F);
\r
3128 int col = (c & 0x7F);
\r
3130 /* Location of bitmap cell */
\r
3134 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3136 x3 = (tcp[i] & 0x7F) * w1;
\r
3137 y3 = (tap[i] & 0x7F) * h1;
\r
3138 tw2 = tw2 * w1 / tw1;
\r
3139 h2 = h2 * h1 / th1;
\r
3141 /* Perfect size */
\r
3142 if ((tw1 == tw2) && (th1 == h2))
\r
3144 /* Copy the terrain picture from the bitmap to the window */
\r
3145 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
\r
3147 /* Mask out the tile */
\r
3148 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
\r
3150 /* Draw the tile */
\r
3151 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
\r
3154 /* Need to stretch */
\r
3157 /* Set the correct mode for stretching the tiles */
\r
3158 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3160 /* Copy the terrain picture from the bitmap to the window */
\r
3161 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
\r
3163 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
\r
3165 /* Only draw if terrain and overlay are different */
\r
3166 if ((x1 != x3) || (y1 != y3))
\r
3168 /* Mask out the tile */
\r
3169 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
\r
3171 /* Draw the tile */
\r
3172 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
\r
3178 /* Perfect size */
\r
3179 if ((w1 == tw2) && (h1 == h2))
\r
3181 /* Copy the picture from the bitmap to the window */
\r
3182 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
\r
3185 /* Need to stretch */
\r
3188 /* Set the correct mode for stretching the tiles */
\r
3189 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3191 /* Copy the picture from the bitmap to the window */
\r
3192 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
\r
3198 SelectObject(hdcSrc, hbmSrcOld);
\r
3201 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3204 SelectObject(hdcMask, hbmSrcOld);
\r
3205 DeleteDC(hdcMask);
\r
3209 ReleaseDC(td->w, hdc);
\r
3211 #else /* USE_GRAPHICS */
\r
3213 /* Just erase this grid */
\r
3214 return (Term_wipe_win(x, y, n));
\r
3216 #endif /* USE_GRAPHICS */
\r
3223 static void windows_map(void)
\r
3225 term_data *td = &data[0];
\r
3228 int x, min_x, max_x;
\r
3229 int y, min_y, max_y;
\r
3234 /* Only in graphics mode */
\r
3235 if (!use_graphics) return;
\r
3237 /* Clear screen */
\r
3238 Term_xtra_win_clear();
\r
3240 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
\r
3241 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
\r
3242 td->map_active = TRUE;
\r
3251 /* Draw the map */
\r
3252 for (x = min_x; x < max_x; x++)
\r
3254 for (y = min_y; y < max_y; y++)
\r
3256 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
\r
3258 /* Ignore non-graphics */
\r
3259 if ((a & 0x80) && (c & 0x80))
\r
3261 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
\r
3266 /* Hilite the player */
\r
3267 Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
\r
3269 /* Wait for a keypress, flush key buffer */
\r
3270 Term_inkey(&c, TRUE, TRUE);
\r
3273 /* Switch off the map display */
\r
3274 td->map_active = FALSE;
\r
3276 /* Restore screen */
\r
3277 Term_xtra_win_clear();
\r
3282 /*** Other routines ***/
\r
3286 * Create and initialize a "term_data" given a title
\r
3288 static void term_data_link(term_data *td)
\r
3292 /* Initialize the term */
\r
3293 term_init(t, td->cols, td->rows, td->keys);
\r
3295 /* Use a "software" cursor */
\r
3296 t->soft_cursor = TRUE;
\r
3298 /* Use "Term_pict" for "graphic" data */
\r
3299 t->higher_pict = TRUE;
\r
3301 /* Erase with "white space" */
\r
3302 t->attr_blank = TERM_WHITE;
\r
3303 t->char_blank = ' ';
\r
3306 /* Prepare the init/nuke hooks */
\r
3307 t->init_hook = Term_init_win;
\r
3308 t->nuke_hook = Term_nuke_win;
\r
3311 /* Prepare the template hooks */
\r
3312 t->user_hook = Term_user_win;
\r
3313 t->xtra_hook = Term_xtra_win;
\r
3314 t->curs_hook = Term_curs_win;
\r
3315 t->bigcurs_hook = Term_bigcurs_win;
\r
3316 t->wipe_hook = Term_wipe_win;
\r
3317 t->text_hook = Term_text_win;
\r
3318 t->pict_hook = Term_pict_win;
\r
3320 /* Remember where we came from */
\r
3321 t->data = (vptr)(td);
\r
3326 * Create the windows
\r
3328 * First, instantiate the "default" values, then read the "ini_file"
\r
3329 * to over-ride selected values, then create the windows, and fonts.
\r
3331 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
\r
3332 * must make active to realize the palette. XXX XXX XXX
\r
3334 static void init_windows(void)
\r
3340 #if 0 /* #ifndef JP */
\r
3346 WIPE(td, term_data);
\r
3350 td->s = angband_term_name[0];
\r
3356 td->visible = TRUE;
\r
3361 td->pos_x = 7 * 30;
\r
3362 td->pos_y = 7 * 20;
\r
3363 td->posfix = FALSE;
\r
3364 #if 1 /* #ifdef JP */
\r
3365 td->bizarre = TRUE;
\r
3368 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3371 WIPE(td, term_data);
\r
3372 td->s = angband_term_name[i];
\r
3376 td->visible = FALSE;
\r
3381 td->pos_x = (7 - i) * 30;
\r
3382 td->pos_y = (7 - i) * 20;
\r
3383 td->posfix = FALSE;
\r
3384 #if 1 /* #ifdef JP */
\r
3385 td->bizarre = TRUE;
\r
3394 /* Main window (need these before term_getsize gets called) */
\r
3396 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
\r
3397 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
\r
3399 td->dwExStyle = 0;
\r
3400 td->visible = TRUE;
\r
3402 /* Sub windows (need these before term_getsize gets called) */
\r
3403 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3406 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
\r
3407 td->dwExStyle = (WS_EX_TOOLWINDOW);
\r
3412 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3416 #if 1 /* #ifdef JP */
\r
3417 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
\r
3418 td->lf.lfCharSet = DEFAULT_CHARSET;
\r
3419 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
\r
3420 /* Activate the chosen font */
\r
3421 term_force_font(td, NULL);
\r
3422 if(!td->tile_wid) td->tile_wid = td->font_wid;
\r
3423 if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
\r
3425 /* Access the standard font file */
\r
3426 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
\r
3428 /* Activate the chosen font */
\r
3429 if (term_force_font(td, buf))
\r
3431 /* Access the standard font file */
\r
3432 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
3434 /* Force the use of that font */
\r
3435 (void)term_force_font(td, buf);
\r
3439 td->tile_hgt = 13;
\r
3441 /* Assume not bizarre */
\r
3442 td->bizarre = FALSE;
\r
3447 /* Analyze the font */
\r
3450 /* Resize the window */
\r
3451 term_window_resize(td);
\r
3455 /* Sub windows (reverse order) */
\r
3456 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
\r
3461 td->w = CreateWindowEx(td->dwExStyle, AngList,
\r
3462 td->s, td->dwStyle,
\r
3463 td->pos_x, td->pos_y,
\r
3464 td->size_wid, td->size_hgt,
\r
3465 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3467 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
\r
3471 td->size_hack = TRUE;
\r
3472 ShowWindow(td->w, SW_SHOW);
\r
3473 td->size_hack = FALSE;
\r
3476 term_data_link(td);
\r
3477 angband_term[i] = &td->t;
\r
3481 /* Activate the window */
\r
3482 SetActiveWindow(td->w);
\r
3485 if (data[i].posfix)
\r
3487 term_window_pos(&data[i], HWND_TOPMOST);
\r
3491 term_window_pos(&data[i], td->w);
\r
3501 td->w = CreateWindowEx(td->dwExStyle, AppName,
\r
3502 td->s, td->dwStyle,
\r
3503 td->pos_x, td->pos_y,
\r
3504 td->size_wid, td->size_hgt,
\r
3505 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3507 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
\r
3509 term_data_link(td);
\r
3510 angband_term[0] = &td->t;
\r
3511 normsize.x = td->cols;
\r
3512 normsize.y = td->rows;
\r
3514 /* Activate the main window */
\r
3515 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
\r
3516 else ShowWindow(td->w, SW_SHOW);
\r
3518 /* Bring main window back to top */
\r
3519 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
3522 /* New palette XXX XXX XXX */
\r
3523 (void)new_palette();
\r
3526 /* Create a "brush" for drawing the "cursor" */
\r
3527 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
\r
3530 /* Process pending messages */
\r
3531 (void)Term_xtra_win_flush();
\r
3537 * Prepare the menus
\r
3539 static void setup_menus(void)
\r
3543 HMENU hm = GetMenu(data[0].w);
\r
3546 /* Menu "File", Disable all */
\r
3547 EnableMenuItem(hm, IDM_FILE_NEW,
\r
3548 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3549 EnableMenuItem(hm, IDM_FILE_OPEN,
\r
3550 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3551 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3552 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3553 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3554 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3555 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3556 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3559 /* No character available */
\r
3560 if (!character_generated)
\r
3562 /* Menu "File", Item "New" */
\r
3563 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
\r
3565 /* Menu "File", Item "Open" */
\r
3566 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
\r
3569 /* A character available */
\r
3570 if (character_generated)
\r
3572 /* Menu "File", Item "Save" */
\r
3573 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3574 MF_BYCOMMAND | MF_ENABLED);
\r
3577 /* Menu "File", Item "Exit" */
\r
3578 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3579 MF_BYCOMMAND | MF_ENABLED);
\r
3581 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3582 MF_BYCOMMAND | MF_ENABLED);
\r
3585 /* Menu "Window::Visibility" */
\r
3586 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3588 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3589 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3591 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3592 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
\r
3594 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3595 MF_BYCOMMAND | MF_ENABLED);
\r
3598 /* Menu "Window::Font" */
\r
3599 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3601 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3602 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3604 if (data[i].visible)
\r
3606 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3607 MF_BYCOMMAND | MF_ENABLED);
\r
3611 /* Menu "Window::Window Position Fix" */
\r
3612 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3614 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3615 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3617 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3618 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
\r
3620 if (data[i].visible)
\r
3622 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3623 MF_BYCOMMAND | MF_ENABLED);
\r
3627 /* Menu "Window::Bizarre Display" */
\r
3628 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3630 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3631 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3633 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3634 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
\r
3636 if (data[i].visible)
\r
3638 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3639 MF_BYCOMMAND | MF_ENABLED);
\r
3644 /* Menu "Window::Increase Tile Width" */
\r
3645 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3647 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3648 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3650 if (data[i].visible)
\r
3652 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3653 MF_BYCOMMAND | MF_ENABLED);
\r
3658 /* Menu "Window::Decrease Tile Width" */
\r
3659 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3661 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3662 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3664 if (data[i].visible)
\r
3666 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3667 MF_BYCOMMAND | MF_ENABLED);
\r
3672 /* Menu "Window::Increase Tile Height" */
\r
3673 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3675 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3676 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3678 if (data[i].visible)
\r
3680 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3681 MF_BYCOMMAND | MF_ENABLED);
\r
3686 /* Menu "Window::Decrease Tile Height" */
\r
3687 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3689 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3690 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3692 if (data[i].visible)
\r
3694 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3695 MF_BYCOMMAND | MF_ENABLED);
\r
3700 /* Menu "Options", disable all */
\r
3701 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3702 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3703 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3704 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3705 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3706 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3707 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3708 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3709 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3710 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3712 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3713 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3716 /* Menu "Options", Item "Map" */
\r
3717 if (use_graphics != GRAPHICS_NONE)
\r
3718 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
\r
3720 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
\r
3721 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3723 /* Menu "Options", update all */
\r
3724 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3725 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
\r
3726 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3727 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
\r
3728 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3729 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
\r
3730 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
\r
3731 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
\r
3732 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3733 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
\r
3734 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
\r
3735 (arg_music ? MF_CHECKED : MF_UNCHECKED));
\r
3736 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3737 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
\r
3738 CheckMenuItem(hm, IDM_OPTIONS_BG,
\r
3739 (use_bg ? MF_CHECKED : MF_UNCHECKED));
\r
3741 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3742 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
\r
3745 #ifdef USE_GRAPHICS
\r
3746 /* Menu "Options", Item "Graphics" */
\r
3747 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
\r
3748 /* Menu "Options", Item "Graphics" */
\r
3749 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
\r
3750 /* Menu "Options", Item "Graphics" */
\r
3751 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
\r
3752 /* Menu "Options", Item "Graphics" */
\r
3753 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
\r
3754 #endif /* USE_GRAPHICS */
\r
3757 /* Menu "Options", Item "Sound" */
\r
3758 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
\r
3759 #endif /* USE_SOUND */
\r
3762 /* Menu "Options", Item "ScreenSaver" */
\r
3763 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3764 MF_BYCOMMAND | MF_ENABLED);
\r
3765 #endif /* USE_SAVER */
\r
3770 * Check for double clicked (or dragged) savefile
\r
3772 * Apparently, Windows copies the entire filename into the first
\r
3773 * piece of the "command line string". Perhaps we should extract
\r
3774 * the "basename" of that filename and append it to the "save" dir.
\r
3776 static void check_for_save_file(LPSTR cmd_line)
\r
3786 /* Extract filename */
\r
3787 strcat(savefile, s);
\r
3789 /* Validate the file */
\r
3790 validate_file(savefile);
\r
3792 /* Game in progress */
\r
3793 game_in_progress = TRUE;
\r
3801 * Process a menu command
\r
3803 static void process_menus(WORD wCmd)
\r
3815 case IDM_FILE_NEW:
\r
3819 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3821 else if (game_in_progress)
\r
3823 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
\r
3827 game_in_progress = TRUE;
\r
3836 case IDM_FILE_OPEN:
\r
3840 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3842 else if (game_in_progress)
\r
3844 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
\r
3848 memset(&ofn, 0, sizeof(ofn));
\r
3849 ofn.lStructSize = sizeof(ofn);
\r
3850 ofn.hwndOwner = data[0].w;
\r
3851 ofn.lpstrFilter = "Save Files (*.)\0*\0";
\r
3852 ofn.nFilterIndex = 1;
\r
3853 ofn.lpstrFile = savefile;
\r
3854 ofn.nMaxFile = 1024;
\r
3855 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
\r
3856 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
\r
3858 if (GetOpenFileName(&ofn))
\r
3860 /* Load 'savefile' */
\r
3861 validate_file(savefile);
\r
3862 game_in_progress = TRUE;
\r
3872 case IDM_FILE_SAVE:
\r
3874 if (game_in_progress && character_generated)
\r
3879 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
\r
3883 /* Hack -- Forget messages */
\r
3886 /* Save the game */
\r
3888 do_cmd_save_game(FALSE);
\r
3889 #else /* ZANGBAND */
\r
3890 do_cmd_save_game();
\r
3891 #endif /* ZANGBAND */
\r
3895 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
\r
3901 case IDM_FILE_EXIT:
\r
3903 if (game_in_progress && character_generated)
\r
3908 plog(_("今は終了できません。", "You may not do that right now."));
\r
3912 /* Hack -- Forget messages */
\r
3919 /* Save the game */
\r
3921 /* do_cmd_save_game(FALSE); */
\r
3922 #else /* ZANGBAND */
\r
3923 /* do_cmd_save_game(); */
\r
3924 #endif /* ZANGBAND */
\r
3925 Term_key_push(SPECIAL_KEY_QUIT);
\r
3933 case IDM_FILE_SCORE:
\r
3937 /* Build the filename */
\r
3938 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
\r
3940 /* Open the binary high score file, for reading */
\r
3941 highscore_fd = fd_open(buf, O_RDONLY);
\r
3943 /* Paranoia -- No score file */
\r
3944 if (highscore_fd < 0)
\r
3946 msg_print("Score file unavailable.");
\r
3953 /* Clear screen */
\r
3956 /* Display the scores */
\r
3957 display_scores_aux(0, MAX_HISCORES, -1, NULL);
\r
3959 /* Shut the high score file */
\r
3960 (void)fd_close(highscore_fd);
\r
3962 /* Forget the high score fd */
\r
3963 highscore_fd = -1;
\r
3968 /* Hack - Flush it */
\r
3976 case IDM_FILE_MOVIE:
\r
3980 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3982 else if (game_in_progress)
\r
3984 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
\r
3988 memset(&ofn, 0, sizeof(ofn));
\r
3989 ofn.lStructSize = sizeof(ofn);
\r
3990 ofn.hwndOwner = data[0].w;
\r
3991 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
\r
3992 ofn.nFilterIndex = 1;
\r
3993 ofn.lpstrFile = savefile;
\r
3994 ofn.nMaxFile = 1024;
\r
3995 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
\r
3996 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
3998 if (GetOpenFileName(&ofn))
\r
4000 /* Load 'savefile' */
\r
4001 prepare_browse_movie_aux(savefile);
\r
4011 case IDM_WINDOW_VIS_0:
\r
4013 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
\r
4017 /* Window visibility */
\r
4018 case IDM_WINDOW_VIS_1:
\r
4019 case IDM_WINDOW_VIS_2:
\r
4020 case IDM_WINDOW_VIS_3:
\r
4021 case IDM_WINDOW_VIS_4:
\r
4022 case IDM_WINDOW_VIS_5:
\r
4023 case IDM_WINDOW_VIS_6:
\r
4024 case IDM_WINDOW_VIS_7:
\r
4026 i = wCmd - IDM_WINDOW_VIS_0;
\r
4028 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4034 td->visible = TRUE;
\r
4035 ShowWindow(td->w, SW_SHOW);
\r
4036 term_data_redraw(td);
\r
4040 td->visible = FALSE;
\r
4041 td->posfix = FALSE;
\r
4042 ShowWindow(td->w, SW_HIDE);
\r
4048 /* Window fonts */
\r
4049 case IDM_WINDOW_FONT_0:
\r
4050 case IDM_WINDOW_FONT_1:
\r
4051 case IDM_WINDOW_FONT_2:
\r
4052 case IDM_WINDOW_FONT_3:
\r
4053 case IDM_WINDOW_FONT_4:
\r
4054 case IDM_WINDOW_FONT_5:
\r
4055 case IDM_WINDOW_FONT_6:
\r
4056 case IDM_WINDOW_FONT_7:
\r
4058 i = wCmd - IDM_WINDOW_FONT_0;
\r
4060 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4064 term_change_font(td);
\r
4069 /* Window Z Position */
\r
4070 case IDM_WINDOW_POS_1:
\r
4071 case IDM_WINDOW_POS_2:
\r
4072 case IDM_WINDOW_POS_3:
\r
4073 case IDM_WINDOW_POS_4:
\r
4074 case IDM_WINDOW_POS_5:
\r
4075 case IDM_WINDOW_POS_6:
\r
4076 case IDM_WINDOW_POS_7:
\r
4078 i = wCmd - IDM_WINDOW_POS_0;
\r
4080 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4084 if (!td->posfix && td->visible)
\r
4086 td->posfix = TRUE;
\r
4087 term_window_pos(td, HWND_TOPMOST);
\r
4091 td->posfix = FALSE;
\r
4092 term_window_pos(td, data[0].w);
\r
4098 /* Bizarre Display */
\r
4099 case IDM_WINDOW_BIZ_0:
\r
4100 case IDM_WINDOW_BIZ_1:
\r
4101 case IDM_WINDOW_BIZ_2:
\r
4102 case IDM_WINDOW_BIZ_3:
\r
4103 case IDM_WINDOW_BIZ_4:
\r
4104 case IDM_WINDOW_BIZ_5:
\r
4105 case IDM_WINDOW_BIZ_6:
\r
4106 case IDM_WINDOW_BIZ_7:
\r
4108 i = wCmd - IDM_WINDOW_BIZ_0;
\r
4110 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4114 td->bizarre = !td->bizarre;
\r
4118 term_window_resize(td);
\r
4123 /* Increase Tile Width */
\r
4124 case IDM_WINDOW_I_WID_0:
\r
4125 case IDM_WINDOW_I_WID_1:
\r
4126 case IDM_WINDOW_I_WID_2:
\r
4127 case IDM_WINDOW_I_WID_3:
\r
4128 case IDM_WINDOW_I_WID_4:
\r
4129 case IDM_WINDOW_I_WID_5:
\r
4130 case IDM_WINDOW_I_WID_6:
\r
4131 case IDM_WINDOW_I_WID_7:
\r
4133 i = wCmd - IDM_WINDOW_I_WID_0;
\r
4135 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4139 td->tile_wid += 1;
\r
4143 term_window_resize(td);
\r
4148 /* Decrease Tile Height */
\r
4149 case IDM_WINDOW_D_WID_0:
\r
4150 case IDM_WINDOW_D_WID_1:
\r
4151 case IDM_WINDOW_D_WID_2:
\r
4152 case IDM_WINDOW_D_WID_3:
\r
4153 case IDM_WINDOW_D_WID_4:
\r
4154 case IDM_WINDOW_D_WID_5:
\r
4155 case IDM_WINDOW_D_WID_6:
\r
4156 case IDM_WINDOW_D_WID_7:
\r
4158 i = wCmd - IDM_WINDOW_D_WID_0;
\r
4160 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4164 td->tile_wid -= 1;
\r
4168 term_window_resize(td);
\r
4173 /* Increase Tile Height */
\r
4174 case IDM_WINDOW_I_HGT_0:
\r
4175 case IDM_WINDOW_I_HGT_1:
\r
4176 case IDM_WINDOW_I_HGT_2:
\r
4177 case IDM_WINDOW_I_HGT_3:
\r
4178 case IDM_WINDOW_I_HGT_4:
\r
4179 case IDM_WINDOW_I_HGT_5:
\r
4180 case IDM_WINDOW_I_HGT_6:
\r
4181 case IDM_WINDOW_I_HGT_7:
\r
4183 i = wCmd - IDM_WINDOW_I_HGT_0;
\r
4185 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4189 td->tile_hgt += 1;
\r
4193 term_window_resize(td);
\r
4198 /* Decrease Tile Height */
\r
4199 case IDM_WINDOW_D_HGT_0:
\r
4200 case IDM_WINDOW_D_HGT_1:
\r
4201 case IDM_WINDOW_D_HGT_2:
\r
4202 case IDM_WINDOW_D_HGT_3:
\r
4203 case IDM_WINDOW_D_HGT_4:
\r
4204 case IDM_WINDOW_D_HGT_5:
\r
4205 case IDM_WINDOW_D_HGT_6:
\r
4206 case IDM_WINDOW_D_HGT_7:
\r
4208 i = wCmd - IDM_WINDOW_D_HGT_0;
\r
4210 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4214 td->tile_hgt -= 1;
\r
4218 term_window_resize(td);
\r
4223 case IDM_OPTIONS_NO_GRAPHICS:
\r
4228 plog("You may not do that right now.");
\r
4232 /* Toggle "arg_graphics" */
\r
4233 if (arg_graphics != GRAPHICS_NONE)
\r
4235 arg_graphics = GRAPHICS_NONE;
\r
4237 /* React to changes */
\r
4238 Term_xtra_win_react();
\r
4240 /* Hack -- Force redraw */
\r
4241 Term_key_push(KTRL('R'));
\r
4247 case IDM_OPTIONS_OLD_GRAPHICS:
\r
4252 plog("You may not do that right now.");
\r
4256 /* Toggle "arg_graphics" */
\r
4257 if (arg_graphics != GRAPHICS_ORIGINAL)
\r
4259 arg_graphics = GRAPHICS_ORIGINAL;
\r
4261 /* React to changes */
\r
4262 Term_xtra_win_react();
\r
4264 /* Hack -- Force redraw */
\r
4265 Term_key_push(KTRL('R'));
\r
4271 case IDM_OPTIONS_NEW_GRAPHICS:
\r
4276 plog("You may not do that right now.");
\r
4280 /* Toggle "arg_graphics" */
\r
4281 if (arg_graphics != GRAPHICS_ADAM_BOLT)
\r
4283 arg_graphics = GRAPHICS_ADAM_BOLT;
\r
4285 /* React to changes */
\r
4286 Term_xtra_win_react();
\r
4288 /* Hack -- Force redraw */
\r
4289 Term_key_push(KTRL('R'));
\r
4295 case IDM_OPTIONS_NEW2_GRAPHICS:
\r
4300 plog("You may not do that right now.");
\r
4304 /* Toggle "arg_graphics" */
\r
4305 if (arg_graphics != GRAPHICS_HENGBAND)
\r
4307 arg_graphics = GRAPHICS_HENGBAND;
\r
4309 /* React to changes */
\r
4310 Term_xtra_win_react();
\r
4312 /* Hack -- Force redraw */
\r
4313 Term_key_push(KTRL('R'));
\r
4319 case IDM_OPTIONS_BIGTILE:
\r
4326 plog("You may not do that right now.");
\r
4330 /* Toggle "arg_sound" */
\r
4331 arg_bigtile = !arg_bigtile;
\r
4334 Term_activate(&td->t);
\r
4336 /* Resize the term */
\r
4337 Term_resize(td->cols, td->rows);
\r
4339 /* Redraw later */
\r
4340 InvalidateRect(td->w, NULL, TRUE);
\r
4345 case IDM_OPTIONS_MUSIC:
\r
4350 plog("You may not do that right now.");
\r
4354 /* Toggle "arg_sound" */
\r
4355 arg_music = !arg_music;
\r
4357 /* React to changes */
\r
4358 Term_xtra_win_react();
\r
4360 /* Hack -- Force redraw */
\r
4361 Term_key_push(KTRL('R'));
\r
4366 case IDM_OPTIONS_SOUND:
\r
4371 plog("You may not do that right now.");
\r
4375 /* Toggle "arg_sound" */
\r
4376 arg_sound = !arg_sound;
\r
4378 /* React to changes */
\r
4379 Term_xtra_win_react();
\r
4381 /* Hack -- Force redraw */
\r
4382 Term_key_push(KTRL('R'));
\r
4388 case IDM_OPTIONS_BG:
\r
4393 plog("You may not do that right now.");
\r
4397 /* Toggle "use_bg" */
\r
4402 /* React to changes */
\r
4403 Term_xtra_win_react();
\r
4405 /* Hack -- Force redraw */
\r
4406 Term_key_push(KTRL('R'));
\r
4412 case IDM_OPTIONS_OPEN_BG:
\r
4417 plog("You may not do that right now.");
\r
4422 memset(&ofn, 0, sizeof(ofn));
\r
4423 ofn.lStructSize = sizeof(ofn);
\r
4424 ofn.hwndOwner = data[0].w;
\r
4425 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
\r
4426 ofn.nFilterIndex = 1;
\r
4427 ofn.lpstrFile = bg_bitmap_file;
\r
4428 ofn.nMaxFile = 1023;
\r
4429 ofn.lpstrInitialDir = NULL;
\r
4430 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
\r
4431 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
\r
4433 if (GetOpenFileName(&ofn))
\r
4435 /* Load 'savefile' */
\r
4440 /* React to changes */
\r
4441 Term_xtra_win_react();
\r
4443 /* Hack -- Force redraw */
\r
4444 Term_key_push(KTRL('R'));
\r
4449 case IDM_DUMP_SCREEN_HTML:
\r
4451 static char buf[1024] = "";
\r
4452 memset(&ofn, 0, sizeof(ofn));
\r
4453 ofn.lStructSize = sizeof(ofn);
\r
4454 ofn.hwndOwner = data[0].w;
\r
4455 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
\r
4456 ofn.nFilterIndex = 1;
\r
4457 ofn.lpstrFile = buf;
\r
4458 ofn.nMaxFile = 1023;
\r
4459 ofn.lpstrDefExt = "html";
\r
4460 ofn.lpstrInitialDir = NULL;
\r
4461 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
\r
4462 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
\r
4464 if (GetSaveFileName(&ofn))
\r
4466 do_cmd_save_screen_html_aux(buf, 0);
\r
4473 case IDM_OPTIONS_SAVER:
\r
4477 DestroyWindow(hwndSaver);
\r
4482 /* Create a screen scaver window */
\r
4483 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
\r
4484 "Angband Screensaver",
\r
4485 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
\r
4486 0, 0, GetSystemMetrics(SM_CXSCREEN),
\r
4487 GetSystemMetrics(SM_CYSCREEN),
\r
4488 NULL, NULL, hInstance, NULL);
\r
4492 /* Push the window to the bottom XXX XXX XXX */
\r
4493 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
4497 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
\r
4505 case IDM_OPTIONS_MAP:
\r
4511 case IDM_HELP_CONTENTS:
\r
4515 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
\r
4516 if (check_file(tmp))
\r
4518 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
\r
4523 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4524 plog("代わりにオンラインヘルプを使用してください。");
\r
4526 plog_fmt("Cannot find help file: %s", tmp);
\r
4527 plog("Use the online help files instead.");
\r
4532 #else /* HTML_HELP */
\r
4535 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
\r
4536 if (check_file(tmp))
\r
4538 sprintf(buf, "winhelp.exe %s", tmp);
\r
4539 WinExec(buf, SW_NORMAL);
\r
4544 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4545 plog("代わりにオンラインヘルプを使用してください。");
\r
4547 plog_fmt("Cannot find help file: %s", tmp);
\r
4548 plog("Use the online help files instead.");
\r
4553 #endif /* HTML_HELP */
\r
4559 static bool process_keydown(WPARAM wParam, LPARAM lParam)
\r
4566 /* Extract the modifiers */
\r
4567 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
\r
4568 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
\r
4569 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
\r
4571 Term_no_press = (ma) ? TRUE : FALSE;
\r
4573 /* Handle "special" keys */
\r
4574 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
\r
4576 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
\r
4577 bool numpad = FALSE;
\r
4579 /* Begin the macro trigger */
\r
4580 Term_keypress(31);
\r
4582 /* Send the modifiers */
\r
4583 if (mc) Term_keypress('C');
\r
4584 if (ms) Term_keypress('S');
\r
4585 if (ma) Term_keypress('A');
\r
4587 /* Extract "scan code" */
\r
4588 i = LOBYTE(HIWORD(lParam));
\r
4590 /* Introduce the scan code */
\r
4591 Term_keypress('x');
\r
4593 /* Extended key bit */
\r
4596 /* Numpad Enter and '/' are extended key */
\r
4598 Term_no_press = TRUE;
\r
4599 case VK_RETURN: /* Enter */
\r
4602 /* Other extended keys are on full keyboard */
\r
4616 case VK_SEPARATOR:
\r
4618 Term_no_press = TRUE;
\r
4622 case VK_PRIOR: /* Page Up */
\r
4623 case VK_NEXT: /* Page Down */
\r
4630 numpad = !ext_key;
\r
4633 /* Special modifiers for keypad keys */
\r
4634 if (numpad) Term_keypress('K');
\r
4636 /* Encode the hexidecimal scan code */
\r
4637 Term_keypress(hexsym[i/16]);
\r
4638 Term_keypress(hexsym[i%16]);
\r
4640 /* End the macro trigger */
\r
4641 Term_keypress(13);
\r
4651 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4652 WPARAM wParam, LPARAM lParam);
\r
4653 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4654 WPARAM wParam, LPARAM lParam)
\r
4655 #else /* __MWERKS__ */
\r
4656 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4657 WPARAM wParam, LPARAM lParam)
\r
4658 #endif /* __MWERKS__ */
\r
4664 MINMAXINFO FAR *lpmmi;
\r
4670 /* Acquire proper "term_data" info */
\r
4671 td = (term_data *)GetWindowLong(hWnd, 0);
\r
4673 /* Handle message */
\r
4679 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
4687 mop.dwCallback=(DWORD)hWnd;
\r
4692 case WM_GETMINMAXINFO:
\r
4694 MINMAXINFO FAR *lpmmi;
\r
4697 lpmmi = (MINMAXINFO FAR *)lParam;
\r
4699 /* this message was sent before WM_NCCREATE */
\r
4700 if (!td) return 1;
\r
4702 /* Minimum window size is 80x24 */
\r
4703 rc.left = rc.top = 0;
\r
4704 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
4705 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
4708 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
4710 /* Save minimum size */
\r
4711 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
4712 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
4719 BeginPaint(hWnd, &ps);
\r
4720 if (td) term_data_redraw(td);
\r
4721 EndPaint(hWnd, &ps);
\r
4722 ValidateRect(hWnd, NULL);
\r
4727 case MM_MCINOTIFY:
\r
4729 if(wParam == MCI_NOTIFY_SUCCESSFUL)
\r
4731 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
4732 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
4738 case WM_SYSKEYDOWN:
\r
4741 if (process_keydown(wParam, lParam))
\r
4748 if (Term_no_press) Term_no_press = FALSE;
\r
4749 else Term_keypress(wParam);
\r
4753 case WM_LBUTTONDOWN:
\r
4755 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4756 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4757 mouse_down = TRUE;
\r
4763 case WM_LBUTTONUP:
\r
4768 TERM_POSITION dx = abs(oldx - mousex) + 1;
\r
4769 TERM_POSITION dy = abs(oldy - mousey) + 1;
\r
4770 TERM_POSITION ox = (oldx > mousex) ? mousex : oldx;
\r
4771 TERM_POSITION oy = (oldy > mousey) ? mousey : oldy;
\r
4773 mouse_down = FALSE;
\r
4774 paint_rect = FALSE;
\r
4777 sz = (dx + 3) * dy;
\r
4779 sz = (dx + 2) * dy;
\r
4781 hGlobal = GlobalAlloc(GHND, sz + 1);
\r
4782 if (hGlobal == NULL) return 0;
\r
4783 lpStr = (LPSTR)GlobalLock(hGlobal);
\r
4785 for (i = 0; i < dy; i++)
\r
4789 char **scr = data[0].t.scr->c;
\r
4791 C_MAKE(s, (dx + 1), char);
\r
4792 strncpy(s, &scr[oy + i][ox], dx);
\r
4796 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
\r
4799 if (ox + dx < data[0].cols)
\r
4801 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
\r
4804 for (j = 0; j < dx; j++)
\r
4806 if (s[j] == 127) s[j] = '#';
\r
4810 for (j = 0; j < dx; j++)
\r
4812 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
\r
4822 GlobalUnlock(hGlobal);
\r
4823 if (OpenClipboard(hWnd) == 0)
\r
4825 GlobalFree(hGlobal);
\r
4829 SetClipboardData(CF_TEXT, hGlobal);
\r
4837 case WM_MOUSEMOVE:
\r
4842 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4843 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4848 dx = abs(oldx - mousex) + 1;
\r
4849 dy = abs(oldy - mousey) + 1;
\r
4850 ox = (oldx > mousex) ? mousex : oldx;
\r
4851 oy = (oldy > mousey) ? mousey : oldy;
\r
4852 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4856 paint_rect = TRUE;
\r
4859 dx = abs(cx - mousex) + 1;
\r
4860 dy = abs(cy - mousey) + 1;
\r
4861 ox = (cx > mousex) ? mousex : cx;
\r
4862 oy = (cy > mousey) ? mousey : cy;
\r
4863 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4879 if (game_in_progress && character_generated)
\r
4883 plog(_("今は終了できません。", "You may not do that right now."));
\r
4887 /* Hack -- Forget messages */
\r
4894 /* Save the game */
\r
4896 /* do_cmd_save_game(FALSE); */
\r
4897 #else /* ZANGBAND */
\r
4898 /* do_cmd_save_game(); */
\r
4899 #endif /* ZANGBAND */
\r
4900 Term_key_push(SPECIAL_KEY_QUIT);
\r
4907 case WM_QUERYENDSESSION:
\r
4909 if (game_in_progress && character_generated)
\r
4911 /* Hack -- Forget messages */
\r
4914 /* Mega-Hack -- Delay death */
\r
4915 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
\r
4916 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
\r
4918 /* Hardcode panic save */
\r
4919 p_ptr->panic_save = 1;
\r
4921 /* Forbid suspend */
\r
4922 signals_ignore_tstp();
\r
4924 /* Indicate panic save */
\r
4925 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
\r
4928 (void)save_player();
\r
4942 process_menus(LOWORD(wParam));
\r
4948 /* this message was sent before WM_NCCREATE */
\r
4949 if (!td) return 1;
\r
4951 /* it was sent from inside CreateWindowEx */
\r
4952 if (!td->w) return 1;
\r
4954 /* was sent from WM_SIZE */
\r
4955 if (td->size_hack) return 1;
\r
4959 case SIZE_MINIMIZED:
\r
4961 /* Hide sub-windows */
\r
4962 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4964 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
\r
4969 case SIZE_MAXIMIZED:
\r
4971 /* fall through XXX XXX XXX */
\r
4974 case SIZE_RESTORED:
\r
4976 TERM_POSITION cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
4977 TERM_POSITION rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
4980 if ((td->cols != cols) || (td->rows != rows))
\r
4982 /* Save the new size */
\r
4986 if (!IsZoomed(td->w) && !IsIconic(td->w))
\r
4988 normsize.x = td->cols;
\r
4989 normsize.y = td->rows;
\r
4993 Term_activate(&td->t);
\r
4995 /* Resize the term */
\r
4996 Term_resize(td->cols, td->rows);
\r
4998 /* Redraw later */
\r
4999 InvalidateRect(td->w, NULL, TRUE);
\r
5002 td->size_hack = TRUE;
\r
5004 /* Show sub-windows */
\r
5005 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5007 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
\r
5010 td->size_hack = FALSE;
\r
5018 case WM_PALETTECHANGED:
\r
5020 /* Ignore if palette change caused by itself */
\r
5021 if ((HWND)wParam == hWnd) return 0;
\r
5023 /* Fall through... */
\r
5026 case WM_QUERYNEWPALETTE:
\r
5028 if (!paletted) return 0;
\r
5030 hdc = GetDC(hWnd);
\r
5032 SelectPalette(hdc, hPal, FALSE);
\r
5034 i = RealizePalette(hdc);
\r
5036 /* if any palette entries changed, repaint the window. */
\r
5037 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5039 ReleaseDC(hWnd, hdc);
\r
5046 if (wParam && !HIWORD(lParam))
\r
5048 /* Do something to sub-windows */
\r
5049 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5051 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
\r
5054 /* Focus on main window */
\r
5063 case WM_ACTIVATEAPP:
\r
5065 if (IsIconic(td->w)) break;
\r
5067 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5069 if(data[i].visible)
\r
5071 if (wParam == TRUE)
\r
5073 ShowWindow(data[i].w, SW_SHOW);
\r
5077 ShowWindow(data[i].w, SW_HIDE);
\r
5084 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5089 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5090 WPARAM wParam, LPARAM lParam);
\r
5091 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5092 WPARAM wParam, LPARAM lParam)
\r
5093 #else /* __MWERKS__ */
\r
5094 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5095 WPARAM wParam, LPARAM lParam)
\r
5096 #endif /* __MWERKS__ */
\r
5100 MINMAXINFO FAR *lpmmi;
\r
5108 /* Acquire proper "term_data" info */
\r
5109 td = (term_data *)GetWindowLong(hWnd, 0);
\r
5111 /* Process message */
\r
5117 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
5127 case WM_GETMINMAXINFO:
\r
5129 MINMAXINFO FAR *lpmmi;
\r
5132 lpmmi = (MINMAXINFO FAR *)lParam;
\r
5134 /* this message was sent before WM_NCCREATE */
\r
5135 if (!td) return 1;
\r
5137 /* Minimum window size is 80x24 */
\r
5138 rc.left = rc.top = 0;
\r
5139 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
5140 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
5143 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
5145 /* Save minimum size */
\r
5146 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
5147 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
5154 TERM_POSITION cols;
\r
5155 TERM_POSITION rows;
\r
5157 /* this message was sent before WM_NCCREATE */
\r
5158 if (!td) return 1;
\r
5160 /* it was sent from inside CreateWindowEx */
\r
5161 if (!td->w) return 1;
\r
5163 /* was sent from inside WM_SIZE */
\r
5164 if (td->size_hack) return 1;
\r
5166 td->size_hack = TRUE;
\r
5168 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
5169 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
5172 if ((td->cols != cols) || (td->rows != rows))
\r
5174 /* Save old term */
\r
5175 term *old_term = Term;
\r
5177 /* Save the new size */
\r
5182 Term_activate(&td->t);
\r
5184 /* Resize the term */
\r
5185 Term_resize(td->cols, td->rows);
\r
5188 Term_activate(old_term);
\r
5190 /* Redraw later */
\r
5191 InvalidateRect(td->w, NULL, TRUE);
\r
5193 /* HACK - Redraw all windows */
\r
5194 p_ptr->window = 0xFFFFFFFF;
\r
5198 td->size_hack = FALSE;
\r
5205 BeginPaint(hWnd, &ps);
\r
5206 if (td) term_data_redraw(td);
\r
5207 EndPaint(hWnd, &ps);
\r
5211 case WM_SYSKEYDOWN:
\r
5214 if (process_keydown(wParam, lParam))
\r
5221 if (Term_no_press) Term_no_press = FALSE;
\r
5222 else Term_keypress(wParam);
\r
5226 case WM_PALETTECHANGED:
\r
5228 /* ignore if palette change caused by itself */
\r
5229 if ((HWND)wParam == hWnd) return FALSE;
\r
5230 /* otherwise, fall through!!! */
\r
5233 case WM_QUERYNEWPALETTE:
\r
5235 if (!paletted) return 0;
\r
5236 hdc = GetDC(hWnd);
\r
5237 SelectPalette(hdc, hPal, FALSE);
\r
5238 i = RealizePalette(hdc);
\r
5239 /* if any palette entries changed, repaint the window. */
\r
5240 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5241 ReleaseDC(hWnd, hdc);
\r
5245 case WM_NCLBUTTONDOWN:
\r
5249 if (wParam == HTCLOSE) wParam = HTSYSMENU;
\r
5250 #endif /* HTCLOSE */
\r
5252 if (wParam == HTSYSMENU)
\r
5256 td->visible = FALSE;
\r
5257 ShowWindow(td->w, SW_HIDE);
\r
5267 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5273 #define MOUSE_SENS 40
\r
5276 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5277 WPARAM wParam, LPARAM lParam);
\r
5278 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5279 WPARAM wParam, LPARAM lParam)
\r
5280 #else /* __MWERKS__ */
\r
5281 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5282 WPARAM wParam, LPARAM lParam)
\r
5283 #endif /* __MWERKS__ */
\r
5285 static int iMouse = 0;
\r
5286 static WORD xMouse = 0;
\r
5287 static WORD yMouse = 0;
\r
5301 case WM_SETCURSOR:
\r
5310 if (LOWORD(wParam) == WA_INACTIVE) break;
\r
5312 /* else fall through */
\r
5316 case WM_LBUTTONDOWN:
\r
5317 case WM_MBUTTONDOWN:
\r
5318 case WM_RBUTTONDOWN:
\r
5321 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5325 case WM_MOUSEMOVE:
\r
5329 dx = LOWORD(lParam) - xMouse;
\r
5330 dy = HIWORD(lParam) - yMouse;
\r
5332 if (dx < 0) dx = -dx;
\r
5333 if (dy < 0) dy = -dy;
\r
5335 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
\r
5337 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5341 /* Save last location */
\r
5343 xMouse = LOWORD(lParam);
\r
5344 yMouse = HIWORD(lParam);
\r
5351 DestroyWindow(hwndSaver);
\r
5358 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5361 #endif /* USE_SAVER */
\r
5367 /*** Temporary Hooks ***/
\r
5371 * Display warning message (see "z-util.c")
\r
5373 static void hack_plog(cptr str)
\r
5375 /* Give a warning */
\r
5379 MessageBox(NULL, str, "警告!",
\r
5380 MB_ICONEXCLAMATION | MB_OK);
\r
5382 MessageBox(NULL, str, "Warning",
\r
5383 MB_ICONEXCLAMATION | MB_OK);
\r
5391 * Display error message and quit (see "z-util.c")
\r
5393 static void hack_quit(cptr str)
\r
5395 /* Give a warning */
\r
5399 MessageBox(NULL, str, "エラー!",
\r
5400 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5402 MessageBox(NULL, str, "Error",
\r
5403 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5408 /* Unregister the classes */
\r
5409 UnregisterClass(AppName, hInstance);
\r
5411 /* Destroy the icon */
\r
5412 if (hIcon) DestroyIcon(hIcon);
\r
5420 /*** Various hooks ***/
\r
5424 * Display warning message (see "z-util.c")
\r
5426 static void hook_plog(cptr str)
\r
5432 MessageBox(data[0].w, str, "警告!",
\r
5433 MB_ICONEXCLAMATION | MB_OK);
\r
5435 MessageBox(data[0].w, str, "Warning",
\r
5436 MB_ICONEXCLAMATION | MB_OK);
\r
5444 * Display error message and quit (see "z-util.c")
\r
5446 static void hook_quit(cptr str)
\r
5451 /* Give a warning */
\r
5455 MessageBox(data[0].w, str, "エラー!",
\r
5456 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5458 MessageBox(data[0].w, str, "Error",
\r
5459 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5465 /* Save the preferences */
\r
5469 /*** Could use 'Term_nuke_win()' XXX XXX XXX */
\r
5471 /* Destroy all windows */
\r
5472 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
\r
5474 term_force_font(&data[i], NULL);
\r
5475 if (data[i].font_want) string_free(data[i].font_want);
\r
5476 if (data[i].w) DestroyWindow(data[i].w);
\r
5480 /* Free the bitmap stuff */
\r
5481 #ifdef USE_GRAPHICS
\r
5482 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
\r
5483 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
\r
5485 if (infMask.hPalette) DeleteObject(infMask.hPalette);
\r
5486 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
\r
5488 #endif /* USE_GRAPHICS */
\r
5490 /*** Free some other stuff ***/
\r
5492 DeleteObject(hbrYellow);
\r
5497 if (hPal) DeleteObject(hPal);
\r
5499 UnregisterClass(AppName, hInstance);
\r
5501 if (hIcon) DestroyIcon(hIcon);
\r
5508 /*** Initialize ***/
\r
5514 static void init_stuff(void)
\r
5521 /* Get program name with full path */
\r
5522 GetModuleFileName(hInstance, path, 512);
\r
5524 /* Save the "program name" XXX XXX XXX */
\r
5527 /* Get the name of the "*.ini" file */
\r
5528 strcpy(path + strlen(path) - 4, ".INI");
\r
5530 /* Save the the name of the ini-file */
\r
5531 ini_file = string_make(path);
\r
5533 /* Analyze the path */
\r
5536 /* Get the path */
\r
5537 for (; i > 0; i--)
\r
5539 if (path[i] == '\\')
\r
5546 /* Add "lib" to the path */
\r
5547 strcpy(path + i + 1, "lib\\");
\r
5549 /* Validate the path */
\r
5550 validate_dir(path, TRUE);
\r
5552 /* Init the file paths */
\r
5553 init_file_paths(path);
\r
5555 /* Hack -- Validate the paths */
\r
5556 validate_dir(ANGBAND_DIR_APEX, FALSE);
\r
5557 validate_dir(ANGBAND_DIR_BONE, FALSE);
\r
5559 /* Allow missing 'edit' directory */
\r
5560 if (!check_dir(ANGBAND_DIR_EDIT))
\r
5562 /* Must have 'data'! */
\r
5563 validate_dir(ANGBAND_DIR_DATA, TRUE);
\r
5567 /* Don't need 'data' */
\r
5568 validate_dir(ANGBAND_DIR_DATA, FALSE);
\r
5571 validate_dir(ANGBAND_DIR_FILE, TRUE);
\r
5572 validate_dir(ANGBAND_DIR_HELP, FALSE);
\r
5573 validate_dir(ANGBAND_DIR_INFO, FALSE);
\r
5574 validate_dir(ANGBAND_DIR_PREF, TRUE);
\r
5575 validate_dir(ANGBAND_DIR_SAVE, FALSE);
\r
5576 validate_dir(ANGBAND_DIR_USER, TRUE);
\r
5577 validate_dir(ANGBAND_DIR_XTRA, TRUE);
\r
5579 /* Build the filename */
\r
5580 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
\r
5582 /* Hack -- Validate the "news.txt" file */
\r
5583 validate_file(path);
\r
5586 #if 0 /* #ifndef JP */
\r
5587 /* Build the "font" path */
\r
5588 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
\r
5590 /* Allocate the path */
\r
5591 ANGBAND_DIR_XTRA_FONT = string_make(path);
\r
5593 /* Validate the "font" directory */
\r
5594 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
\r
5596 /* Build the filename */
\r
5597 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
5599 /* Hack -- Validate the basic font */
\r
5600 validate_file(path);
\r
5604 #ifdef USE_GRAPHICS
\r
5606 /* Build the "graf" path */
\r
5607 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
\r
5609 /* Allocate the path */
\r
5610 ANGBAND_DIR_XTRA_GRAF = string_make(path);
\r
5612 /* Validate the "graf" directory */
\r
5613 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
\r
5615 #endif /* USE_GRAPHICS */
\r
5620 /* Build the "sound" path */
\r
5621 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
\r
5623 /* Allocate the path */
\r
5624 ANGBAND_DIR_XTRA_SOUND = string_make(path);
\r
5626 /* Validate the "sound" directory */
\r
5627 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
\r
5629 #endif /* USE_SOUND */
\r
5633 /* Build the "music" path */
\r
5634 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
\r
5636 /* Allocate the path */
\r
5637 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
\r
5639 /* Validate the "music" directory */
\r
5640 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
\r
5642 #endif /* USE_MUSIC */
\r
5644 /* Build the "help" path */
\r
5645 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
\r
5647 /* Allocate the path */
\r
5648 ANGBAND_DIR_XTRA_HELP = string_make(path);
\r
5650 /* Validate the "help" directory */
\r
5651 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
\r
5654 static bool is_already_running(void)
\r
5656 bool result = FALSE;
\r
5659 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
\r
5660 if (GetLastError() == ERROR_ALREADY_EXISTS)
\r
5668 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
\r
5669 LPSTR lpCmdLine, int nCmdShow)
\r
5677 setlocale( LC_ALL, "ja_JP" );
\r
5682 /* Save globally */
\r
5683 hInstance = hInst;
\r
5686 /* Prevent multiple run */
\r
5687 if (is_already_running())
\r
5690 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
\r
5691 _("エラー!", "Error") ,
\r
5692 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5697 if (hPrevInst == NULL)
\r
5699 wc.style = CS_CLASSDC;
\r
5700 wc.lpfnWndProc = AngbandWndProc;
\r
5701 wc.cbClsExtra = 0;
\r
5702 wc.cbWndExtra = 4; /* one long pointer to term_data */
\r
5703 wc.hInstance = hInst;
\r
5704 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
\r
5705 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
\r
5706 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
\r
5707 wc.lpszMenuName = AppName;
\r
5708 wc.lpszClassName = AppName;
\r
5710 if (!RegisterClass(&wc)) exit(1);
\r
5712 wc.lpfnWndProc = AngbandListProc;
\r
5713 wc.lpszMenuName = NULL;
\r
5714 wc.lpszClassName = AngList;
\r
5716 if (!RegisterClass(&wc)) exit(2);
\r
5720 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
\r
5721 wc.lpfnWndProc = AngbandSaverProc;
\r
5722 wc.hCursor = NULL;
\r
5723 wc.lpszMenuName = NULL;
\r
5724 wc.lpszClassName = "WindowsScreenSaverClass";
\r
5726 if (!RegisterClass(&wc)) exit(3);
\r
5732 /* Temporary hooks */
\r
5733 plog_aux = hack_plog;
\r
5734 quit_aux = hack_quit;
\r
5735 core_aux = hack_quit;
\r
5737 /* Prepare the filepaths */
\r
5740 /* Initialize the keypress analyzer */
\r
5741 for (i = 0; special_key_list[i]; ++i)
\r
5743 special_key[special_key_list[i]] = TRUE;
\r
5745 /* Initialize the keypress analyzer */
\r
5746 for (i = 0; ignore_key_list[i]; ++i)
\r
5748 ignore_key[ignore_key_list[i]] = TRUE;
\r
5751 /* Determine if display is 16/256/true color */
\r
5752 hdc = GetDC(NULL);
\r
5753 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
\r
5754 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
\r
5755 ReleaseDC(NULL, hdc);
\r
5757 /* Initialize the colors */
\r
5758 for (i = 0; i < 256; i++)
\r
5762 /* Extract desired values */
\r
5763 rv = angband_color_table[i][1];
\r
5764 gv = angband_color_table[i][2];
\r
5765 bv = angband_color_table[i][3];
\r
5767 /* Extract the "complex" code */
\r
5768 win_clr[i] = PALETTERGB(rv, gv, bv);
\r
5770 /* Save the "simple" code */
\r
5771 angband_color_table[i][0] = win_pal[i];
\r
5774 /* Prepare the windows */
\r
5780 /* Activate hooks */
\r
5781 plog_aux = hook_plog;
\r
5782 quit_aux = hook_quit;
\r
5783 core_aux = hook_quit;
\r
5785 /* Set the system suffix */
\r
5786 ANGBAND_SYS = "win";
\r
5788 /* Set the keyboard suffix */
\r
5789 if (7 != GetKeyboardType(0))
\r
5790 ANGBAND_KEYBOARD = "0";
\r
5793 /* Japanese keyboard */
\r
5794 switch (GetKeyboardType(1))
\r
5796 case 0x0D01: case 0x0D02:
\r
5797 case 0x0D03: case 0x0D04:
\r
5798 case 0x0D05: case 0x0D06:
\r
5800 ANGBAND_KEYBOARD = "NEC98";
\r
5804 ANGBAND_KEYBOARD = "JAPAN";
\r
5808 /* Catch nasty signals */
\r
5812 Term_activate(term_screen);
\r
5815 /* We are now initialized */
\r
5816 initialized = TRUE;
\r
5818 if(lpCmdLine[0] == '-'){
\r
5819 switch(lpCmdLine[1])
\r
5824 if (!lpCmdLine[2]) break;
\r
5825 chuukei_server = TRUE;
\r
5826 if(connect_chuukei_server(&lpCmdLine[2])<0){
\r
5827 msg_print("connect fail");
\r
5830 msg_print("connect");
\r
5838 if (!lpCmdLine[2]) break;
\r
5839 chuukei_client = TRUE;
\r
5840 connect_chuukei_server(&lpCmdLine[2]);
\r
5848 if (!lpCmdLine[2]) break;
\r
5849 prepare_browse_movie(&lpCmdLine[2]);
\r
5859 /* Did the user double click on a save file? */
\r
5860 if(!chuukei_server) check_for_save_file(lpCmdLine);
\r
5862 /* Did the user double click on a save file? */
\r
5863 check_for_save_file(lpCmdLine);
\r
5866 /* Prompt the user */
\r
5867 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
\r
5871 /* Process messages forever */
\r
5872 while (GetMessage(&msg, NULL, 0, 0))
\r
5874 TranslateMessage(&msg);
\r
5875 DispatchMessage(&msg);
\r
5886 #endif /* WINDOWS */
\r