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.
\r
73 * A simpler method is needed for selecting the "tile size" for windows.
\r
77 * The various "warning" messages assume the existance of the "screen.w"
\r
78 * window, I think, and only a few calls actually check for its existance,
\r
79 * this may be okay since "NULL" means "on top of all windows". (?) The
\r
80 * user must never be allowed to "hide" the main window, or the "menubar"
\r
85 * Special "Windows Help Files" can be placed into "lib/xtra/help/" for
\r
86 * use with the "winhelp.exe" program. These files *may* be available
\r
87 * at the ftp site somewhere, but I have not seen them.
\r
91 * Initial framework (and most code) by Ben Harrison (benh@phial.com).
\r
93 * Original code by Skirmantas Kligys (kligys@scf.usc.edu).
\r
95 * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
\r
96 * and Chris R. Martin (crm7479@tam2000.tamu.edu).
\r
100 #include "angband.h"
\r
103 #include <windows.h>
\r
104 #include <direct.h>
\r
105 #include <locale.h>
\r
106 #include "z-term.h"
\r
109 * Extract the "WIN32" flag from the compiler
\r
111 #if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__)
\r
119 * Hack -- allow use of "screen saver" mode
\r
125 * Menu constants -- see "ANGBAND.RC"
\r
128 #define IDM_FILE_NEW 100
\r
129 #define IDM_FILE_OPEN 101
\r
130 #define IDM_FILE_SAVE 110
\r
131 #define IDM_FILE_SCORE 120
\r
132 #define IDM_FILE_MOVIE 121
\r
133 #define IDM_FILE_EXIT 130
\r
135 #define IDM_WINDOW_VIS_0 200
\r
136 #define IDM_WINDOW_VIS_1 201
\r
137 #define IDM_WINDOW_VIS_2 202
\r
138 #define IDM_WINDOW_VIS_3 203
\r
139 #define IDM_WINDOW_VIS_4 204
\r
140 #define IDM_WINDOW_VIS_5 205
\r
141 #define IDM_WINDOW_VIS_6 206
\r
142 #define IDM_WINDOW_VIS_7 207
\r
144 #define IDM_WINDOW_FONT_0 210
\r
145 #define IDM_WINDOW_FONT_1 211
\r
146 #define IDM_WINDOW_FONT_2 212
\r
147 #define IDM_WINDOW_FONT_3 213
\r
148 #define IDM_WINDOW_FONT_4 214
\r
149 #define IDM_WINDOW_FONT_5 215
\r
150 #define IDM_WINDOW_FONT_6 216
\r
151 #define IDM_WINDOW_FONT_7 217
\r
153 #define IDM_WINDOW_POS_0 220
\r
154 #define IDM_WINDOW_POS_1 221
\r
155 #define IDM_WINDOW_POS_2 222
\r
156 #define IDM_WINDOW_POS_3 223
\r
157 #define IDM_WINDOW_POS_4 224
\r
158 #define IDM_WINDOW_POS_5 225
\r
159 #define IDM_WINDOW_POS_6 226
\r
160 #define IDM_WINDOW_POS_7 227
\r
162 #define IDM_WINDOW_BIZ_0 230
\r
163 #define IDM_WINDOW_BIZ_1 231
\r
164 #define IDM_WINDOW_BIZ_2 232
\r
165 #define IDM_WINDOW_BIZ_3 233
\r
166 #define IDM_WINDOW_BIZ_4 234
\r
167 #define IDM_WINDOW_BIZ_5 235
\r
168 #define IDM_WINDOW_BIZ_6 236
\r
169 #define IDM_WINDOW_BIZ_7 237
\r
171 #define IDM_WINDOW_I_WID_0 240
\r
172 #define IDM_WINDOW_I_WID_1 241
\r
173 #define IDM_WINDOW_I_WID_2 242
\r
174 #define IDM_WINDOW_I_WID_3 243
\r
175 #define IDM_WINDOW_I_WID_4 244
\r
176 #define IDM_WINDOW_I_WID_5 245
\r
177 #define IDM_WINDOW_I_WID_6 246
\r
178 #define IDM_WINDOW_I_WID_7 247
\r
180 #define IDM_WINDOW_D_WID_0 250
\r
181 #define IDM_WINDOW_D_WID_1 251
\r
182 #define IDM_WINDOW_D_WID_2 252
\r
183 #define IDM_WINDOW_D_WID_3 253
\r
184 #define IDM_WINDOW_D_WID_4 254
\r
185 #define IDM_WINDOW_D_WID_5 255
\r
186 #define IDM_WINDOW_D_WID_6 256
\r
187 #define IDM_WINDOW_D_WID_7 257
\r
189 #define IDM_WINDOW_I_HGT_0 260
\r
190 #define IDM_WINDOW_I_HGT_1 261
\r
191 #define IDM_WINDOW_I_HGT_2 262
\r
192 #define IDM_WINDOW_I_HGT_3 263
\r
193 #define IDM_WINDOW_I_HGT_4 264
\r
194 #define IDM_WINDOW_I_HGT_5 265
\r
195 #define IDM_WINDOW_I_HGT_6 266
\r
196 #define IDM_WINDOW_I_HGT_7 267
\r
198 #define IDM_WINDOW_D_HGT_0 270
\r
199 #define IDM_WINDOW_D_HGT_1 271
\r
200 #define IDM_WINDOW_D_HGT_2 272
\r
201 #define IDM_WINDOW_D_HGT_3 273
\r
202 #define IDM_WINDOW_D_HGT_4 274
\r
203 #define IDM_WINDOW_D_HGT_5 275
\r
204 #define IDM_WINDOW_D_HGT_6 276
\r
205 #define IDM_WINDOW_D_HGT_7 277
\r
207 #define IDM_OPTIONS_NO_GRAPHICS 400
\r
208 #define IDM_OPTIONS_OLD_GRAPHICS 401
\r
209 #define IDM_OPTIONS_NEW_GRAPHICS 402
\r
210 #define IDM_OPTIONS_NEW2_GRAPHICS 403
\r
211 #define IDM_OPTIONS_BIGTILE 409
\r
212 #define IDM_OPTIONS_SOUND 410
\r
213 #define IDM_OPTIONS_MUSIC 411
\r
214 #define IDM_OPTIONS_SAVER 420
\r
215 #define IDM_OPTIONS_MAP 430
\r
216 #define IDM_OPTIONS_BG 440
\r
217 #define IDM_OPTIONS_OPEN_BG 441
\r
219 #define IDM_DUMP_SCREEN_HTML 450
\r
221 #define IDM_HELP_CONTENTS 901
\r
224 * Exclude parts of WINDOWS.H that are not needed
\r
226 #define NOCOMM /* Comm driver APIs and definitions */
\r
227 #define NOLOGERROR /* LogError() and related definitions */
\r
228 #define NOPROFILER /* Profiler APIs */
\r
229 #define NOLFILEIO /* _l* file I/O routines */
\r
230 #define NOOPENFILE /* OpenFile and related definitions */
\r
231 #define NORESOURCE /* Resource management */
\r
232 #define NOATOM /* Atom management */
\r
233 #define NOLANGUAGE /* Character test routines */
\r
234 #define NOLSTRING /* lstr* string management routines */
\r
235 #define NODBCS /* Double-byte character set routines */
\r
236 #define NOKEYBOARDINFO /* Keyboard driver routines */
\r
237 #define NOCOLOR /* COLOR_* color values */
\r
238 #define NODRAWTEXT /* DrawText() and related definitions */
\r
239 #define NOSCALABLEFONT /* Truetype scalable font support */
\r
240 #define NOMETAFILE /* Metafile support */
\r
241 #define NOSYSTEMPARAMSINFO /* SystemParametersInfo() and SPI_* definitions */
\r
242 #define NODEFERWINDOWPOS /* DeferWindowPos and related definitions */
\r
243 #define NOKEYSTATES /* MK_* message key state flags */
\r
244 #define NOWH /* SetWindowsHook and related WH_* definitions */
\r
245 #define NOCLIPBOARD /* Clipboard APIs and definitions */
\r
246 #define NOICONS /* IDI_* icon IDs */
\r
247 #define NOMDI /* MDI support */
\r
248 #define NOHELP /* Help support */
\r
250 /* Not defined since it breaks Borland C++ 5.5 */
\r
251 /* #define NOCTLMGR */ /* Control management and controls */
\r
254 * Exclude parts of WINDOWS.H that are not needed (Win32)
\r
256 #define WIN32_LEAN_AND_MEAN
\r
257 #define NONLS /* All NLS defines and routines */
\r
258 #define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
\r
259 #define NOKANJI /* Kanji support stuff. */
\r
260 #define NOMCX /* Modem Configuration Extensions */
\r
263 * Include the "windows" support file
\r
265 #include <windows.h>
\r
268 * Exclude parts of MMSYSTEM.H that are not needed
\r
270 #define MMNODRV /* Installable driver support */
\r
271 #define MMNOWAVE /* Waveform support */
\r
272 #define MMNOMIDI /* MIDI support */
\r
273 #define MMNOAUX /* Auxiliary audio support */
\r
274 #define MMNOTIMER /* Timer support */
\r
275 #define MMNOJOY /* Joystick support */
\r
276 #define MMNOMCI /* MCI support */
\r
277 #define MMNOMMIO /* Multimedia file I/O support */
\r
278 #define MMNOMMSYSTEM /* General MMSYSTEM functions */
\r
281 * Include some more files. Note: the Cygnus Cygwin compiler
\r
282 * doesn't use mmsystem.h instead it includes the winmm library
\r
283 * which performs a similar function.
\r
285 #include <mmsystem.h>
\r
286 #include <commdlg.h>
\r
289 * HTML-Help requires htmlhelp.h and htmlhelp.lib from Microsoft's
\r
290 * HTML Workshop < http://msdn.microsoft.com/workshop/author/htmlhelp/ >.
\r
292 /* #define HTML_HELP */
\r
295 #include <htmlhelp.h>
\r
296 #endif /* HTML_HELP */
\r
299 * Include the support for loading bitmaps
\r
301 #ifdef USE_GRAPHICS
\r
302 # include "readdib.h"
\r
306 * Hack -- Fake declarations from "dos.h"
\r
309 #define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
\r
311 #define FA_LABEL 0x08 /* Volume label */
\r
312 #define FA_DIREC 0x10 /* Directory */
\r
313 unsigned _cdecl _dos_getfileattr(concptr , unsigned *);
\r
317 * Silliness in WIN32 drawing routine
\r
320 # define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL)
\r
324 * Silliness for Windows 95
\r
326 #ifndef WS_EX_TOOLWINDOW
\r
327 # define WS_EX_TOOLWINDOW 0
\r
331 * Foreground color bits (hard-coded by DOS)
\r
333 #define VID_BLACK 0x00
\r
334 #define VID_BLUE 0x01
\r
335 #define VID_GREEN 0x02
\r
336 #define VID_CYAN 0x03
\r
337 #define VID_RED 0x04
\r
338 #define VID_MAGENTA 0x05
\r
339 #define VID_YELLOW 0x06
\r
340 #define VID_WHITE 0x07
\r
343 * Bright text (hard-coded by DOS)
\r
345 #define VID_BRIGHT 0x08
\r
348 * Background color bits (hard-coded by DOS)
\r
350 #define VUD_BLACK 0x00
\r
351 #define VUD_BLUE 0x10
\r
352 #define VUD_GREEN 0x20
\r
353 #define VUD_CYAN 0x30
\r
354 #define VUD_RED 0x40
\r
355 #define VUD_MAGENTA 0x50
\r
356 #define VUD_YELLOW 0x60
\r
357 #define VUD_WHITE 0x70
\r
360 * Blinking text (hard-coded by DOS)
\r
362 #define VUD_BRIGHT 0x80
\r
368 typedef struct _term_data term_data;
\r
371 * @struct _term_data
\r
372 * @brief ターム情報構造体 / Extra "term" data
\r
375 * pos_x / pos_y は各タームの左上点座標を指す。
\r
378 * tile_wid / tile_hgt は[ウィンドウ]メニューのタイルの幅/高さを~を
\r
379 * 1ドットずつ調整するステータスを指す。
\r
380 * また、フォントを変更すると都度自動調整される。
\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
400 TERM_LEN rows; /* int -> uint */
\r
403 uint pos_x; //!< タームの左上X座標
\r
404 uint pos_y; //!< タームの左上Y座標
\r
419 int font_wid; //!< フォント横幅
\r
420 int font_hgt; //!< フォント縦幅
\r
421 int tile_wid; //!< タイル横幅
\r
422 int tile_hgt; //!< タイル縦幅
\r
428 #if 1 /* #ifdef JP */
\r
436 #define MAX_TERM_DATA 8 //!< Maximum number of windows
\r
438 static term_data data[MAX_TERM_DATA]; //!< An array of term_data's
\r
439 static term_data *my_td; //!< Hack -- global "window creation" pointer
\r
440 POINT normsize; //!< Remember normal size of main window when maxmized
\r
443 * was main window maximized on previous playing
\r
445 bool win_maximized = FALSE;
\r
450 bool game_in_progress = FALSE;
\r
453 * note when "open"/"new" become valid
\r
455 bool initialized = FALSE;
\r
458 * screen paletted, i.e. 256 colors
\r
460 bool paletted = FALSE;
\r
463 * 16 colors screen, don't use RGB()
\r
465 bool colors16 = FALSE;
\r
468 * Saved instance handle
\r
470 static HINSTANCE hInstance;
\r
473 * Yellow brush for the cursor
\r
475 static HBRUSH hbrYellow;
\r
480 static HICON hIcon;
\r
485 static HPALETTE hPal;
\r
488 static HBITMAP hBG = NULL;
\r
489 static int use_bg = 0; //!< 背景使用フラグ、1なら私用。
\r
490 static char bg_bitmap_file[1024] = "bg.bmp"; //!< 現在の背景ビットマップファイル名。
\r
495 * The screen saver window
\r
497 static HWND hwndSaver;
\r
499 #endif /* USE_SAVER */
\r
502 #ifdef USE_GRAPHICS
\r
505 * 現在使用中のタイルID(0ならば未使用)
\r
506 * Flag set once "graphics" has been initialized
\r
508 static byte_hack current_graphics_mode = 0;
\r
511 * The global bitmap
\r
513 static DIBINIT infGraph;
\r
516 * The global bitmap mask
\r
518 static DIBINIT infMask;
\r
520 #endif /* USE_GRAPHICS */
\r
526 * Flag set once "sound" has been initialized
\r
528 static bool can_use_sound = FALSE;
\r
530 #define SAMPLE_MAX 8
\r
532 * An array of sound file names
\r
534 static concptr sound_file[SOUND_MAX][SAMPLE_MAX];
\r
536 #endif /* USE_SOUND */
\r
542 #define SAMPLE_MUSIC_MAX 16
\r
543 static concptr music_file[MUSIC_BASIC_MAX][SAMPLE_MUSIC_MAX];
\r
544 static concptr dungeon_music_file[1000][SAMPLE_MUSIC_MAX];
\r
545 static concptr town_music_file[1000][SAMPLE_MUSIC_MAX];
\r
546 static concptr quest_music_file[1000][SAMPLE_MUSIC_MAX];
\r
547 static bool can_use_music = FALSE;
\r
549 static MCI_OPEN_PARMS mop;
\r
550 static char mci_device_type[256];
\r
552 int current_music_type = 0;
\r
553 int current_music_id = 0;
\r
555 #endif /* USE_MUSIC */
\r
559 * Full path to ANGBAND.INI
\r
561 static concptr ini_file = NULL;
\r
564 * Name of application
\r
566 static concptr AppName = "ANGBAND";
\r
569 * Name of sub-window type
\r
571 static concptr AngList = "AngList";
\r
576 static concptr ANGBAND_DIR_XTRA_GRAF;
\r
577 static concptr ANGBAND_DIR_XTRA_SOUND;
\r
578 static concptr ANGBAND_DIR_XTRA_MUSIC;
\r
579 static concptr ANGBAND_DIR_XTRA_HELP;
\r
580 #if 0 /* #ifndef JP */
\r
581 static concptr ANGBAND_DIR_XTRA_FONT;
\r
584 static concptr ANGBAND_DIR_XTRA_MUSIC;
\r
589 * The "complex" color values
\r
591 static COLORREF win_clr[256];
\r
595 * Flag for macro trigger with dump ASCII
\r
597 static bool Term_no_press = FALSE;
\r
602 static bool mouse_down = FALSE;
\r
603 static bool paint_rect = FALSE;
\r
604 static TERM_LEN mousex = 0, mousey = 0;
\r
605 static TERM_LEN oldx, oldy;
\r
609 * @brief The "simple" color values
\r
611 * See "main-ibm.c" for original table information
\r
612 * The entries below are taken from the "color bits" defined above.
\r
613 * Note that many of the choices below suck, but so do crappy monitors.
\r
615 static BYTE win_pal[256] =
\r
617 VID_BLACK, /* Dark */
\r
618 VID_WHITE, /* White */
\r
619 VID_CYAN, /* Slate XXX */
\r
620 VID_RED | VID_BRIGHT, /* Orange XXX */
\r
622 VID_GREEN, /* Green */
\r
623 VID_BLUE, /* Blue */
\r
624 VID_YELLOW, /* Umber XXX */
\r
625 VID_BLACK | VID_BRIGHT, /* Light Dark */
\r
626 VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
\r
627 VID_MAGENTA, /* Violet XXX */
\r
628 VID_YELLOW | VID_BRIGHT, /* Yellow */
\r
629 VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
\r
630 VID_GREEN | VID_BRIGHT, /* Light Green */
\r
631 VID_BLUE | VID_BRIGHT, /* Light Blue */
\r
632 VID_YELLOW /* Light Umber XXX */
\r
637 * Hack -- define which keys are "special"
\r
639 static bool special_key[256];
\r
640 static bool ignore_key[256];
\r
644 * Hack -- initialization list for "special_key"
\r
646 static byte special_key_list[] = {
\r
647 VK_CLEAR, VK_PAUSE, VK_CAPITAL,
\r
648 VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI,
\r
649 VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE,
\r
650 VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
\r
651 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN,
\r
652 VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT,
\r
653 VK_INSERT, VK_DELETE, VK_HELP, VK_APPS,
\r
654 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
\r
655 VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
\r
656 VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD,
\r
657 VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE,
\r
658 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
\r
659 VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
\r
660 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
\r
661 VK_F19,VK_F20, VK_F21, VK_F22, VK_F23, VK_F24,
\r
662 VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL,
\r
663 VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM,
\r
665 0 /* End of List */
\r
668 static byte ignore_key_list[] = {
\r
669 VK_ESCAPE, VK_TAB, VK_SPACE,
\r
670 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
\r
671 VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN,
\r
672 VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL,
\r
673 VK_LMENU, VK_RMENU,
\r
674 0 /* End of List */
\r
678 * Hack -- initialization list for "special_key"
\r
680 * We ignore the modifier keys (shift, control, alt, num lock, scroll lock),
\r
681 * and the normal keys (escape, tab, return, letters, numbers, etc), but we
\r
682 * catch the keypad keys (with and without numlock set, including keypad 5),
\r
683 * the function keys (including the "menu" key which maps to F10), and the
\r
684 * "pause" key (between scroll lock and numlock). We also catch a few odd
\r
685 * keys which I do not recognize, but which are listed among keys which we
\r
686 * do catch, so they should be harmless to catch.
\r
688 static byte special_key_list[] =
\r
690 VK_CLEAR, /* 0x0C (KP<5>) */
\r
692 VK_PAUSE, /* 0x13 (pause) */
\r
694 VK_PRIOR, /* 0x21 (KP<9>) */
\r
695 VK_NEXT, /* 0x22 (KP<3>) */
\r
696 VK_END, /* 0x23 (KP<1>) */
\r
697 VK_HOME, /* 0x24 (KP<7>) */
\r
698 VK_LEFT, /* 0x25 (KP<4>) */
\r
699 VK_UP, /* 0x26 (KP<8>) */
\r
700 VK_RIGHT, /* 0x27 (KP<6>) */
\r
701 VK_DOWN, /* 0x28 (KP<2>) */
\r
702 VK_SELECT, /* 0x29 (?????) */
\r
703 VK_PRINT, /* 0x2A (?????) */
\r
704 VK_EXECUTE, /* 0x2B (?????) */
\r
705 VK_SNAPSHOT, /* 0x2C (?????) */
\r
706 VK_INSERT, /* 0x2D (KP<0>) */
\r
707 VK_DELETE, /* 0x2E (KP<.>) */
\r
708 VK_HELP, /* 0x2F (?????) */
\r
710 VK_NUMPAD0, /* 0x60 (KP<0>) */
\r
711 VK_NUMPAD1, /* 0x61 (KP<1>) */
\r
712 VK_NUMPAD2, /* 0x62 (KP<2>) */
\r
713 VK_NUMPAD3, /* 0x63 (KP<3>) */
\r
714 VK_NUMPAD4, /* 0x64 (KP<4>) */
\r
715 VK_NUMPAD5, /* 0x65 (KP<5>) */
\r
716 VK_NUMPAD6, /* 0x66 (KP<6>) */
\r
717 VK_NUMPAD7, /* 0x67 (KP<7>) */
\r
718 VK_NUMPAD8, /* 0x68 (KP<8>) */
\r
719 VK_NUMPAD9, /* 0x69 (KP<9>) */
\r
720 VK_MULTIPLY, /* 0x6A (KP<*>) */
\r
721 VK_ADD, /* 0x6B (KP<+>) */
\r
722 VK_SEPARATOR, /* 0x6C (?????) */
\r
723 VK_SUBTRACT, /* 0x6D (KP<->) */
\r
724 VK_DECIMAL, /* 0x6E (KP<.>) */
\r
725 VK_DIVIDE, /* 0x6F (KP</>) */
\r
756 /* Function prototype */
\r
758 static bool is_already_running(void);
\r
762 static void delete_bg(void)
\r
771 static int init_bg(void)
\r
773 char * bmfile = bg_bitmap_file;
\r
776 if (use_bg == 0) return 0;
\r
778 hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
\r
780 plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
\r
788 static void DrawBG(HDC hdc, RECT *r)
\r
793 int x = r->left, y = r->top;
\r
794 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
\r
796 if (!use_bg || !hBG)
\r
800 GetObject(hBG, sizeof(bm), &bm);
\r
801 swid = bm.bmWidth; shgt = bm.bmHeight;
\r
803 hdcSrc = CreateCompatibleDC(hdc);
\r
804 hOld = SelectObject(hdcSrc, hBG);
\r
808 cwid = MIN(swid - sx, r->right - nx);
\r
811 chgt = MIN(shgt - sy, r->bottom - ny);
\r
812 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
\r
814 } while (ny < r->bottom);
\r
817 } while (nx < r->right);
\r
819 SelectObject(hdcSrc, hOld);
\r
825 * Hack -- given a pathname, point at the filename
\r
827 static concptr extract_file_name(concptr s)
\r
831 /* Start at the end */
\r
832 p = s + strlen(s) - 1;
\r
834 /* Back up to divider */
\r
835 while ((p >= s) && (*p != ':') && (*p != '\\')) p--;
\r
837 /* Return file name */
\r
844 * Hack -- given a simple filename, extract the "font size" info
\r
846 * Return a pointer to a static buffer holding the capitalized base name.
\r
848 #if 0 /* #ifndef JP */
\r
849 static char *analyze_font(char *path, int *wp, int *hp)
\r
855 /* Start at the end */
\r
856 p = path + strlen(path) - 1;
\r
858 /* Back up to divider */
\r
859 while ((p >= path) && (*p != ':') && (*p != '\\')) --p;
\r
861 /* Advance to file name */
\r
865 for (s = p; *s; ++s)
\r
867 /* Capitalize (be paranoid) */
\r
868 if (islower(*s)) *s = toupper(*s);
\r
871 /* Find first 'X' */
\r
872 s = my_strchr(p, 'X');
\r
874 /* Extract font width */
\r
877 /* Extract height */
\r
878 hgt = s ? atoi(s+1) : 0;
\r
889 * Check for existance of a file
\r
891 static bool check_file(concptr s)
\r
901 unsigned int attrib;
\r
911 attrib = GetFileAttributes(path);
\r
913 /* Require valid filename */
\r
914 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
916 /* Prohibit directory */
\r
917 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return (FALSE);
\r
921 /* Examine and verify */
\r
922 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
924 /* Prohibit something */
\r
925 if (attrib & FA_LABEL) return (FALSE);
\r
927 /* Prohibit directory */
\r
928 if (attrib & FA_DIREC) return (FALSE);
\r
938 * Check for existance of a directory
\r
940 static bool check_dir(concptr s)
\r
952 unsigned int attrib;
\r
962 /* Remove trailing backslash */
\r
963 if (i && (path[i-1] == '\\')) path[--i] = '\0';
\r
968 attrib = GetFileAttributes(path);
\r
970 /* Require valid filename */
\r
971 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
973 /* Require directory */
\r
974 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE);
\r
978 /* Examine and verify */
\r
979 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
981 /* Prohibit something */
\r
982 if (attrib & FA_LABEL) return (FALSE);
\r
984 /* Require directory */
\r
985 if (!(attrib & FA_DIREC)) return (FALSE);
\r
997 static void validate_file(concptr s)
\r
999 /* Verify or fail */
\r
1000 if (!check_file(s))
\r
1002 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
\r
1008 * Validate a directory
\r
1010 static void validate_dir(concptr s, bool vital)
\r
1012 /* Verify or fail */
\r
1013 if (!check_dir(s))
\r
1015 /* This directory contains needed data */
\r
1018 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
\r
1020 /* Attempt to create this directory */
\r
1021 else if (mkdir(s))
\r
1023 quit_fmt("Unable to create directory:\n%s", s);
\r
1030 * @brief (Windows版固有実装)Get the "size" for a window
\r
1032 static void term_getsize(term_data *td)
\r
1035 TERM_LEN wid, hgt;
\r
1038 if (td->cols < 1) td->cols = 1;
\r
1039 if (td->rows < 1) td->rows = 1;
\r
1041 /* Window sizes */
\r
1042 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
1043 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
\r
1045 /* Fake window size */
\r
1047 rc.right = rc.left + wid;
\r
1049 rc.bottom = rc.top + hgt;
\r
1051 /* rc.right += 1; */
\r
1052 /* rc.bottom += 1; */
\r
1055 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
1058 td->size_wid = rc.right - rc.left;
\r
1059 td->size_hgt = rc.bottom - rc.top;
\r
1061 /* See CreateWindowEx */
\r
1062 if (!td->w) return;
\r
1064 /* Extract actual location */
\r
1065 GetWindowRect(td->w, &rc);
\r
1067 /* Save the location */
\r
1068 td->pos_x = rc.left;
\r
1069 td->pos_y = rc.top;
\r
1074 * Write the "prefs" for a single term
\r
1076 static void save_prefs_aux(int i)
\r
1078 term_data *td = &data[i];
\r
1079 GAME_TEXT sec_name[128];
\r
1083 WINDOWPLACEMENT lpwndpl;
\r
1086 if (!td->w) return;
\r
1088 /* Make section name */
\r
1089 sprintf(sec_name, "Term-%d", i);
\r
1094 strcpy(buf, td->visible ? "1" : "0");
\r
1095 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
\r
1100 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "MS ゴシック");
\r
1103 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
\r
1105 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
\r
1109 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
\r
1111 #if 1 /* #ifdef JP */
\r
1112 wsprintf(buf, "%d", td->lf.lfWidth);
\r
1113 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
\r
1114 wsprintf(buf, "%d", td->lf.lfHeight);
\r
1115 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
\r
1116 wsprintf(buf, "%d", td->lf.lfWeight);
\r
1117 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
\r
1120 strcpy(buf, td->bizarre ? "1" : "0");
\r
1121 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
\r
1123 /* Tile size (x) */
\r
1124 wsprintf(buf, "%d", td->tile_wid);
\r
1125 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
\r
1127 /* Tile size (y) */
\r
1128 wsprintf(buf, "%d", td->tile_hgt);
\r
1129 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
\r
1131 /* Get window placement and dimensions */
\r
1132 lpwndpl.length = sizeof(WINDOWPLACEMENT);
\r
1133 GetWindowPlacement(td->w, &lpwndpl);
\r
1135 /* Acquire position in *normal* mode (not minimized) */
\r
1136 rc = lpwndpl.rcNormalPosition;
\r
1138 /* Window size (x) */
\r
1139 if (i == 0) wsprintf(buf, "%d", normsize.x);
\r
1140 else wsprintf(buf, "%d", td->cols);
\r
1141 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
\r
1143 /* Window size (y) */
\r
1144 if (i == 0) wsprintf(buf, "%d", normsize.y);
\r
1145 else wsprintf(buf, "%d", td->rows);
\r
1146 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
\r
1148 /* Maxmized (only main window) */
\r
1151 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
\r
1152 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
\r
1155 /* Acquire position */
\r
1156 GetWindowRect(td->w, &rc);
\r
1158 /* Window position (x) */
\r
1159 wsprintf(buf, "%d", rc.left);
\r
1160 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
\r
1162 /* Window position (y) */
\r
1163 wsprintf(buf, "%d", rc.top);
\r
1164 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
\r
1166 /* Window Z position */
\r
1169 strcpy(buf, td->posfix ? "1" : "0");
\r
1170 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
\r
1176 * Write the "prefs"
\r
1177 * We assume that the windows have all been initialized
\r
1179 static void save_prefs(void)
\r
1185 /* Save the "arg_graphics" flag */
\r
1186 sprintf(buf, "%d", arg_graphics);
\r
1187 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
\r
1189 /* Save the "arg_bigtile" flag */
\r
1190 strcpy(buf, arg_bigtile ? "1" : "0");
\r
1191 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
\r
1193 /* Save the "arg_sound" flag */
\r
1194 strcpy(buf, arg_sound ? "1" : "0");
\r
1195 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
\r
1197 /* Save the "arg_sound" flag */
\r
1198 strcpy(buf, arg_music ? "1" : "0");
\r
1199 WritePrivateProfileString("Angband", "Music", buf, ini_file);
\r
1202 strcpy(buf, use_bg ? "1" : "0");
\r
1203 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
\r
1204 WritePrivateProfileString("Angband", "BackGroundBitmap",
\r
1205 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
\r
1207 /* Save window prefs */
\r
1208 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1210 save_prefs_aux(i);
\r
1216 * Load the "prefs" for a single term
\r
1218 static void load_prefs_aux(int i)
\r
1220 term_data *td = &data[i];
\r
1221 GAME_TEXT sec_name[128];
\r
1224 int wid, hgt, posx, posy;
\r
1225 int dispx = GetSystemMetrics( SM_CXVIRTUALSCREEN);
\r
1226 int dispy = GetSystemMetrics( SM_CYVIRTUALSCREEN);
\r
1230 /* Make section name */
\r
1231 sprintf(sec_name, "Term-%d", i);
\r
1233 /* Make section name */
\r
1234 sprintf(sec_name, "Term-%d", i);
\r
1239 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
\r
1242 /* Desired font, with default */
\r
1244 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
\r
1247 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
\r
1249 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
\r
1255 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
\r
1257 /* Analyze font, save desired font name */
\r
1258 #if 1 /* #ifdef JP */
\r
1259 td->font_want = string_make(tmp);
\r
1260 hgt = 15; wid = 0;
\r
1261 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
\r
1262 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
\r
1263 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
\r
1265 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
\r
1270 #if 1 /* #ifdef JP */
\r
1271 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
\r
1272 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
\r
1274 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
\r
1275 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
\r
1280 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
\r
1281 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
\r
1282 normsize.x = td->cols; normsize.y = td->rows;
\r
1287 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
\r
1290 /* Window position */
\r
1291 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
\r
1292 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
\r
1293 td->pos_x = MIN(MAX(0, posx), dispx-128);
\r
1294 td->pos_y = MIN(MAX(0, posy), dispy-128);
\r
1296 /* Window Z position */
\r
1299 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
\r
1305 * Load the "prefs"
\r
1307 static void load_prefs(void)
\r
1311 /* Extract the "arg_graphics" flag */
\r
1312 arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
\r
1314 /* Extract the "arg_bigtile" flag */
\r
1315 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
\r
1316 use_bigtile = arg_bigtile;
\r
1318 /* Extract the "arg_sound" flag */
\r
1319 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
\r
1321 /* Extract the "arg_sound" flag */
\r
1322 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
\r
1325 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
\r
1326 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
\r
1328 /* Load window prefs */
\r
1329 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1331 load_prefs_aux(i);
\r
1335 #if defined(USE_SOUND) || defined(USE_MUSIC)
\r
1338 * - Taken from files.c.
\r
1340 * Extract "tokens" from a buffer
\r
1342 * This function uses "whitespace" as delimiters, and treats any amount of
\r
1343 * whitespace as a single delimiter. We will never return any empty tokens.
\r
1344 * When given an empty buffer, or a buffer containing only "whitespace", we
\r
1345 * will return no tokens. We will never extract more than "num" tokens.
\r
1347 * By running a token through the "text_to_ascii()" function, you can allow
\r
1348 * that token to include (encoded) whitespace, using "\s" to encode spaces.
\r
1350 * We save pointers to the tokens in "tokens", and return the number found.
\r
1352 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
\r
1362 /* Skip leading whitespace */
\r
1363 for ( ; *s && iswspace(*s); ++s) /* loop */;
\r
1368 /* Find next whitespace, if any */
\r
1369 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
\r
1371 /* Nuke and advance (if necessary) */
\r
1372 if (*t) *t++ = '\0';
\r
1374 /* Save the token */
\r
1385 #endif /* USE_SOUND || USE_MUSIC */
\r
1389 static void load_sound_prefs(void)
\r
1393 char ini_path[1024];
\r
1394 char wav_path[1024];
\r
1395 char *zz[SAMPLE_MAX];
\r
1397 /* Access the sound.cfg */
\r
1399 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
\r
1401 for (i = 0; i < SOUND_MAX; i++)
\r
1403 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
\r
1405 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
\r
1407 for (j = 0; j < num; j++)
\r
1409 /* Access the sound */
\r
1410 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
\r
1412 /* Save the sound filename, if it exists */
\r
1413 if (check_file(wav_path))
\r
1414 sound_file[i][j] = string_make(zz[j]);
\r
1419 #endif /* USE_SOUND */
\r
1423 static void load_music_prefs(void)
\r
1427 char ini_path[1024];
\r
1428 char wav_path[1024];
\r
1429 char *zz[SAMPLE_MAX];
\r
1432 /* Access the music.cfg */
\r
1434 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
\r
1436 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
\r
1438 for (i = 0; i < MUSIC_BASIC_MAX; i++)
\r
1440 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
\r
1442 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1444 for (j = 0; j < num; j++)
\r
1446 /* Access the sound */
\r
1447 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1449 /* Save the sound filename, if it exists */
\r
1450 if (check_file(wav_path))
\r
1451 music_file[i][j] = string_make(zz[j]);
\r
1455 for (i = 0; i < max_d_idx; i++)
\r
1457 sprintf(key, "dungeon%03d", i);
\r
1458 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
\r
1460 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1462 for (j = 0; j < num; j++)
\r
1464 /* Access the sound */
\r
1465 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1467 /* Save the sound filename, if it exists */
\r
1468 if (check_file(wav_path))
\r
1469 dungeon_music_file[i][j] = string_make(zz[j]);
\r
1473 for (i = 0; i < max_q_idx; i++)
\r
1475 sprintf(key, "quest%03d", i);
\r
1476 GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
\r
1478 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1480 for (j = 0; j < num; j++)
\r
1482 /* Access the sound */
\r
1483 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1485 /* Save the sound filename, if it exists */
\r
1486 if (check_file(wav_path))
\r
1487 quest_music_file[i][j] = string_make(zz[j]);
\r
1491 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
\r
1493 sprintf(key, "town%03d", i);
\r
1494 GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
\r
1496 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1498 for (j = 0; j < num; j++)
\r
1500 /* Access the sound */
\r
1501 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1503 /* Save the sound filename, if it exists */
\r
1504 if (check_file(wav_path))
\r
1505 town_music_file[i][j] = string_make(zz[j]);
\r
1512 #endif /* USE_MUSIC */
\r
1515 * Create the new global palette based on the bitmap palette
\r
1516 * (if any), and the standard 16 entry palette derived from
\r
1517 * "win_clr[]" which is used for the basic 16 Angband colors.
\r
1519 * This function is never called before all windows are ready.
\r
1521 * This function returns FALSE if the new palette could not be
\r
1522 * prepared, which should normally be a fatal error. XXX XXX
\r
1524 * Note that only some machines actually use a "palette".
\r
1526 static int new_palette(void)
\r
1534 LPLOGPALETTE pLogPal;
\r
1535 LPPALETTEENTRY lppe;
\r
1540 /* This makes no sense */
\r
1541 if (!paletted) return (TRUE);
\r
1549 #ifdef USE_GRAPHICS
\r
1551 /* Check the bitmap palette */
\r
1552 hBmPal = infGraph.hPalette;
\r
1554 /* Use the bitmap */
\r
1557 lppeSize = 256 * sizeof(PALETTEENTRY);
\r
1558 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
\r
1559 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
\r
1560 if ((nEntries == 0) || (nEntries > 220))
\r
1562 /* Warn the user */
\r
1563 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
\r
1566 rnfree(lppe, lppeSize);
\r
1573 #endif /* USE_GRAPHICS */
\r
1575 /* Size of palette */
\r
1576 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
\r
1578 /* Allocate palette */
\r
1579 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
\r
1582 pLogPal->palVersion = 0x300;
\r
1584 /* Make room for bitmap and normal data */
\r
1585 pLogPal->palNumEntries = nEntries + 16;
\r
1587 /* Save the bitmap data */
\r
1588 for (i = 0; i < nEntries; i++)
\r
1590 pLogPal->palPalEntry[i] = lppe[i];
\r
1593 /* Save the normal data */
\r
1594 for (i = 0; i < 16; i++)
\r
1598 /* Access the entry */
\r
1599 p = &(pLogPal->palPalEntry[i+nEntries]);
\r
1601 /* Save the colors */
\r
1602 p->peRed = GetRValue(win_clr[i]);
\r
1603 p->peGreen = GetGValue(win_clr[i]);
\r
1604 p->peBlue = GetBValue(win_clr[i]);
\r
1606 /* Save the flags */
\r
1607 p->peFlags = PC_NOCOLLAPSE;
\r
1610 /* Free something */
\r
1611 if (lppe) rnfree(lppe, lppeSize);
\r
1613 /* Create a new palette, or fail */
\r
1614 hNewPal = CreatePalette(pLogPal);
\r
1615 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
\r
1617 /* Free the palette */
\r
1618 rnfree(pLogPal, pLogPalSize);
\r
1623 /* Realize the palette */
\r
1624 hdc = GetDC(td->w);
\r
1625 SelectPalette(hdc, hNewPal, 0);
\r
1626 i = RealizePalette(hdc);
\r
1627 ReleaseDC(td->w, hdc);
\r
1628 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
\r
1632 for (i = 1; i < MAX_TERM_DATA; i++)
\r
1636 hdc = GetDC(td->w);
\r
1637 SelectPalette(hdc, hNewPal, 0);
\r
1638 ReleaseDC(td->w, hdc);
\r
1641 /* Delete old palette */
\r
1642 if (hPal) DeleteObject(hPal);
\r
1644 /* Save new palette */
\r
1652 #ifdef USE_GRAPHICS
\r
1654 * @brief グラフィクスを初期化する / Initialize graphics
\r
1657 * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
\r
1658 * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
\r
1661 static bool init_graphics(void)
\r
1663 /* Initialize once */
\r
1665 BYTE wid, hgt, twid, thgt, ox, oy;
\r
1668 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1676 name = "16X16.BMP";
\r
1678 ANGBAND_GRAF = "new";
\r
1680 else if (arg_graphics == GRAPHICS_HENGBAND)
\r
1689 name = "64X64.BMP";
\r
1698 name = "32X32.BMP";
\r
1700 ANGBAND_GRAF = "ne2";
\r
1711 ANGBAND_GRAF = "old";
\r
1714 /* Access the bitmap file */
\r
1715 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
\r
1717 /* Load the bitmap or quit */
\r
1718 if (!ReadDIB(data[0].w, buf, &infGraph))
\r
1720 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
\r
1724 /* Save the new sizes */
\r
1725 infGraph.CellWidth = wid;
\r
1726 infGraph.CellHeight = hgt;
\r
1727 infGraph.TileWidth = twid;
\r
1728 infGraph.TileHeight = thgt;
\r
1729 infGraph.OffsetX = ox;
\r
1730 infGraph.OffsetY = oy;
\r
1732 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1734 /* Access the mask file */
\r
1735 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
\r
1737 /* Load the bitmap or quit */
\r
1738 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1740 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1744 if (arg_graphics == GRAPHICS_HENGBAND)
\r
1746 /* Access the mask file */
\r
1747 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
\r
1749 /* Load the bitmap or quit */
\r
1750 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1752 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1757 /* Activate a palette */
\r
1758 if (!new_palette())
\r
1762 plog(_("パレットを実現できません!", "Cannot activate palette!"));
\r
1766 /* Graphics available */
\r
1767 current_graphics_mode = arg_graphics;
\r
1768 return (current_graphics_mode);
\r
1770 #endif /* USE_GRAPHICS */
\r
1775 * Initialize music
\r
1777 static bool init_music(void)
\r
1779 /* Initialize once */
\r
1780 if (!can_use_music)
\r
1782 /* Load the prefs */
\r
1783 load_music_prefs();
\r
1785 /* Sound available */
\r
1786 can_use_music = TRUE;
\r
1788 return (can_use_music);
\r
1792 * Hack -- Stop a music
\r
1794 static void stop_music(void)
\r
1796 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
1797 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
1800 #endif /* USE_MUSIC */
\r
1804 * Initialize sound
\r
1806 static bool init_sound(void)
\r
1808 /* Initialize once */
\r
1809 if (!can_use_sound)
\r
1811 /* Load the prefs */
\r
1812 load_sound_prefs();
\r
1814 /* Sound available */
\r
1815 can_use_sound = TRUE;
\r
1817 return (can_use_sound);
\r
1819 #endif /* USE_SOUND */
\r
1825 static void term_window_resize(term_data *td)
\r
1827 /* Require window */
\r
1828 if (!td->w) return;
\r
1830 /* Resize the window */
\r
1831 SetWindowPos(td->w, 0, 0, 0,
\r
1832 td->size_wid, td->size_hgt,
\r
1833 SWP_NOMOVE | SWP_NOZORDER);
\r
1835 /* Redraw later */
\r
1836 InvalidateRect(td->w, NULL, TRUE);
\r
1841 * Force the use of a new "font file" for a term_data
\r
1843 * This function may be called before the "window" is ready
\r
1845 * This function returns zero only if everything succeeds.
\r
1847 * Note that the "font name" must be capitalized!!!
\r
1849 static errr term_force_font(term_data *td, concptr path)
\r
1853 #if 0 /* #ifndef JP */
\r
1859 /* Forget the old font (if needed) */
\r
1860 if (td->font_id) DeleteObject(td->font_id);
\r
1862 #if 1 /* #ifdef JP */
\r
1866 /* Create the font (using the 'base' of the font file name!) */
\r
1867 td->font_id = CreateFontIndirect(&(td->lf));
\r
1868 wid = td->lf.lfWidth;
\r
1869 hgt = td->lf.lfHeight;
\r
1870 if (!td->font_id) return (1);
\r
1872 /* Forget old font */
\r
1873 if (td->font_file)
\r
1875 bool used = FALSE;
\r
1877 /* Scan windows */
\r
1878 for (i = 0; i < MAX_TERM_DATA; i++)
\r
1880 /* Don't check when closing the application */
\r
1883 /* Check "screen" */
\r
1884 if ((td != &data[i]) &&
\r
1885 (data[i].font_file) &&
\r
1886 (streq(data[i].font_file, td->font_file)))
\r
1892 /* Remove unused font resources */
\r
1893 if (!used) RemoveFontResource(td->font_file);
\r
1895 /* Free the old name */
\r
1896 string_free(td->font_file);
\r
1899 td->font_file = NULL;
\r
1902 /* No path given */
\r
1903 if (!path) return (1);
\r
1906 strcpy(buf, path);
\r
1908 /* Analyze font path */
\r
1909 base = analyze_font(buf, &wid, &hgt);
\r
1911 /* Verify suffix */
\r
1912 if (!suffix(base, ".FON")) return (1);
\r
1915 if (!check_file(buf)) return (1);
\r
1917 /* Load the new font */
\r
1918 if (!AddFontResource(buf)) return (1);
\r
1920 /* Save new font name */
\r
1921 td->font_file = string_make(base);
\r
1923 /* Remove the "suffix" */
\r
1924 base[strlen(base)-4] = '\0';
\r
1926 /* Create the font (using the 'base' of the font file name!) */
\r
1927 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
\r
1928 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
\r
1929 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
\r
1930 FIXED_PITCH | FF_DONTCARE, base);
\r
1933 /* Hack -- Unknown size */
\r
1940 /* all this trouble to get the cell size */
\r
1941 hdcDesktop = GetDC(HWND_DESKTOP);
\r
1942 hfOld = SelectObject(hdcDesktop, td->font_id);
\r
1943 GetTextMetrics(hdcDesktop, &tm);
\r
1944 SelectObject(hdcDesktop, hfOld);
\r
1945 ReleaseDC(HWND_DESKTOP, hdcDesktop);
\r
1947 /* Font size info */
\r
1948 wid = tm.tmAveCharWidth;
\r
1949 hgt = tm.tmHeight;
\r
1952 /* Save the size info */
\r
1953 td->font_wid = wid;
\r
1954 td->font_hgt = hgt;
\r
1963 * Allow the user to change the font for this window.
\r
1965 static void term_change_font(term_data *td)
\r
1967 #if 1 /* #ifdef JP */
\r
1970 memset(&cf, 0, sizeof(cf));
\r
1971 cf.lStructSize = sizeof(cf);
\r
1972 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
\r
1973 cf.lpLogFont = &(td->lf);
\r
1975 if (ChooseFont(&cf))
\r
1977 /* Force the font */
\r
1978 term_force_font(td, NULL);
\r
1980 /* Assume not bizarre */
\r
1981 td->bizarre = TRUE;
\r
1983 /* Reset the tile info */
\r
1984 td->tile_wid = td->font_wid;
\r
1985 td->tile_hgt = td->font_hgt;
\r
1987 /* Analyze the font */
\r
1990 /* Resize the window */
\r
1991 term_window_resize(td);
\r
1997 char tmp[1024] = "";
\r
1999 /* Extract a default if possible */
\r
2000 if (td->font_file) strcpy(tmp, td->font_file);
\r
2002 /* Ask for a choice */
\r
2003 memset(&ofn, 0, sizeof(ofn));
\r
2004 ofn.lStructSize = sizeof(ofn);
\r
2005 ofn.hwndOwner = data[0].w;
\r
2006 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
\r
2007 ofn.nFilterIndex = 1;
\r
2008 ofn.lpstrFile = tmp;
\r
2009 ofn.nMaxFile = 128;
\r
2010 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
\r
2011 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
2012 ofn.lpstrDefExt = "fon";
\r
2014 /* Force choice if legal */
\r
2015 if (GetOpenFileName(&ofn))
\r
2017 /* Force the font */
\r
2018 if (term_force_font(td, tmp))
\r
2020 /* Access the standard font file */
\r
2021 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
2023 /* Force the use of that font */
\r
2024 (void)term_force_font(td, tmp);
\r
2027 /* Assume not bizarre */
\r
2028 td->bizarre = FALSE;
\r
2030 /* Reset the tile info */
\r
2031 td->tile_wid = td->font_wid;
\r
2032 td->tile_hgt = td->font_hgt;
\r
2034 /* Analyze the font */
\r
2037 /* Resize the window */
\r
2038 term_window_resize(td);
\r
2045 * Allow the user to lock this window.
\r
2047 static void term_window_pos(term_data *td, HWND hWnd)
\r
2049 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
\r
2050 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
\r
2053 static void windows_map(void);
\r
2056 * Hack -- redraw a term_data
\r
2058 static void term_data_redraw(term_data *td)
\r
2060 if (td->map_active)
\r
2062 /* Redraw the map */
\r
2067 /* Activate the term */
\r
2068 Term_activate(&td->t);
\r
2070 /* Redraw the contents */
\r
2073 /* Restore the term */
\r
2074 Term_activate(term_screen);
\r
2079 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
\r
2083 HBRUSH myBrush, oldBrush;
\r
2085 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
\r
2086 int tx = td->size_ow1 + x * td->tile_wid;
\r
2087 int ty = td->size_oh1 + y * td->tile_hgt;
\r
2088 int tw = w * td->tile_wid - 1;
\r
2089 int th = h * td->tile_hgt - 1;
\r
2091 hdc = GetDC(hWnd);
\r
2092 myBrush = CreateSolidBrush(RGB(255, 255, 255));
\r
2093 oldBrush = SelectObject(hdc, myBrush);
\r
2094 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2096 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
\r
2098 SelectObject(hdc, oldBrush);
\r
2099 SelectObject(hdc, oldPen);
\r
2104 /*** Function hooks needed by "Term" ***/
\r
2110 * Initialize a new Term
\r
2112 static void Term_init_win(term *t)
\r
2119 * Nuke an old Term
\r
2121 static void Term_nuke_win(term *t)
\r
2130 * @brief //!< Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
\r
2132 static errr Term_user_win(int n)
\r
2143 * React to global changes
\r
2145 static errr Term_xtra_win_react(void)
\r
2149 /* Simple color */
\r
2152 /* Save the default colors */
\r
2153 for (i = 0; i < 256; i++)
\r
2155 /* Simply accept the desired colors */
\r
2156 win_pal[i] = angband_color_table[i][0];
\r
2160 /* Complex color */
\r
2167 bool change = FALSE;
\r
2169 /* Save the default colors */
\r
2170 for (i = 0; i < 256; i++)
\r
2172 /* Extract desired values */
\r
2173 rv = angband_color_table[i][1];
\r
2174 gv = angband_color_table[i][2];
\r
2175 bv = angband_color_table[i][3];
\r
2177 /* Extract a full color code */
\r
2178 code = PALETTERGB(rv, gv, bv);
\r
2180 /* Activate changes */
\r
2181 if (win_clr[i] != code)
\r
2183 /* Note the change */
\r
2186 /* Apply the desired color */
\r
2187 win_clr[i] = code;
\r
2191 /* Activate the palette if needed */
\r
2192 if (change) (void)new_palette();
\r
2198 /* Handle "arg_sound" */
\r
2199 if (use_sound != arg_sound)
\r
2201 /* Initialize (if needed) */
\r
2202 if (arg_sound && !init_sound())
\r
2205 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
\r
2207 /* Cannot enable */
\r
2208 arg_sound = FALSE;
\r
2211 /* Change setting */
\r
2212 use_sound = arg_sound;
\r
2219 /* Handle "arg_sound" */
\r
2220 if (use_music != arg_music)
\r
2222 /* Initialize (if needed) */
\r
2223 if (arg_music && !init_music())
\r
2226 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
\r
2227 /* Cannot enable */
\r
2228 arg_music = FALSE;
\r
2231 /* Change setting */
\r
2232 use_music = arg_music;
\r
2234 if(!arg_music) stop_music();
\r
2235 else select_floor_music();
\r
2242 #ifdef USE_GRAPHICS
\r
2244 /* Handle "arg_graphics" */
\r
2245 if (use_graphics != arg_graphics)
\r
2247 /* Initialize (if needed) */
\r
2248 if (arg_graphics && !init_graphics())
\r
2251 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
\r
2253 /* Cannot enable */
\r
2254 arg_graphics = GRAPHICS_NONE;
\r
2257 /* Change setting */
\r
2258 use_graphics = arg_graphics;
\r
2260 /* Reset visuals */
\r
2261 #ifdef ANGBAND_2_8_1
\r
2263 #else /* ANGBAND_2_8_1 */
\r
2264 reset_visuals(TRUE);
\r
2265 #endif /* ANGBAND_2_8_1 */
\r
2268 #endif /* USE_GRAPHICS */
\r
2271 /* Clean up windows */
\r
2272 for (i = 0; i < MAX_TERM_DATA; i++)
\r
2276 term_data *td = &data[i];
\r
2278 /* Update resized windows */
\r
2279 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
\r
2282 Term_activate(&td->t);
\r
2284 /* Hack -- Resize the term */
\r
2285 Term_resize(td->cols, td->rows);
\r
2287 /* Redraw the contents */
\r
2289 Term_activate(old);
\r
2300 * Process at least one event
\r
2302 static errr Term_xtra_win_event(int v)
\r
2306 /* Wait for an event */
\r
2310 if (GetMessage(&msg, NULL, 0, 0))
\r
2312 TranslateMessage(&msg);
\r
2313 DispatchMessage(&msg);
\r
2317 /* Check for an event */
\r
2321 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2323 TranslateMessage(&msg);
\r
2324 DispatchMessage(&msg);
\r
2334 * Process all pending events
\r
2336 static errr Term_xtra_win_flush(void)
\r
2340 /* Process all pending events */
\r
2341 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2343 TranslateMessage(&msg);
\r
2344 DispatchMessage(&msg);
\r
2353 * Hack -- clear the screen
\r
2355 * Make this more efficient
\r
2357 static errr Term_xtra_win_clear(void)
\r
2359 term_data *td = (term_data*)(Term->data);
\r
2364 /* Rectangle to erase */
\r
2365 rc.left = td->size_ow1;
\r
2366 rc.right = rc.left + td->cols * td->tile_wid;
\r
2367 rc.top = td->size_oh1;
\r
2368 rc.bottom = rc.top + td->rows * td->tile_hgt;
\r
2371 hdc = GetDC(td->w);
\r
2372 SetBkColor(hdc, RGB(0, 0, 0));
\r
2373 SelectObject(hdc, td->font_id);
\r
2374 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2379 rc.left = 0; rc.top = 0;
\r
2382 ReleaseDC(td->w, hdc);
\r
2390 * Hack -- make a noise
\r
2392 static errr Term_xtra_win_noise(void)
\r
2394 MessageBeep(MB_ICONASTERISK);
\r
2400 * Hack -- make a sound
\r
2402 static errr Term_xtra_win_sound(int v)
\r
2407 #endif /* USE_SOUND */
\r
2409 /* Sound disabled */
\r
2410 if (!use_sound) return (1);
\r
2412 /* Illegal sound */
\r
2413 if ((v < 0) || (v >= SOUND_MAX)) return (1);
\r
2417 /* Count the samples */
\r
2418 for (i = 0; i < SAMPLE_MAX; i++)
\r
2420 if (!sound_file[v][i])
\r
2425 if (i == 0) return (1);
\r
2427 /* Build the path */
\r
2428 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
\r
2432 /* Play the sound, catch errors */
\r
2433 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
\r
2437 /* Play the sound, catch errors */
\r
2438 return (sndPlaySound(buf, SND_ASYNC));
\r
2440 #endif /* WIN32 */
\r
2442 #else /* USE_SOUND */
\r
2446 #endif /* USE_SOUND */
\r
2450 * Hack -- play a music
\r
2452 static errr Term_xtra_win_music(int n, int v)
\r
2457 #endif /* USE_MUSIC */
\r
2459 /* Sound disabled */
\r
2461 if(!use_music) return (1);
\r
2463 /* Illegal sound */
\r
2464 if(n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return (1);
\r
2465 else if(v < 0 || v >= 1000) return(1); /*!< TODO */
\r
2471 case TERM_XTRA_MUSIC_BASIC:
\r
2472 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2474 case TERM_XTRA_MUSIC_DUNGEON:
\r
2475 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2477 case TERM_XTRA_MUSIC_QUEST:
\r
2478 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2480 case TERM_XTRA_MUSIC_TOWN:
\r
2481 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2488 //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2489 //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2495 case TERM_XTRA_MUSIC_BASIC:
\r
2496 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2498 case TERM_XTRA_MUSIC_DUNGEON:
\r
2499 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2501 case TERM_XTRA_MUSIC_QUEST:
\r
2502 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2504 case TERM_XTRA_MUSIC_TOWN:
\r
2505 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2512 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2513 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2519 case TERM_XTRA_MUSIC_BASIC:
\r
2520 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
\r
2522 case TERM_XTRA_MUSIC_DUNGEON:
\r
2523 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
\r
2525 case TERM_XTRA_MUSIC_QUEST:
\r
2526 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
\r
2528 case TERM_XTRA_MUSIC_TOWN:
\r
2529 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
\r
2533 if(current_music_type == n && current_music_id == v)
\r
2537 current_music_type = n;
\r
2538 current_music_id = v;
\r
2542 mop.lpstrDeviceType = mci_device_type;
\r
2543 mop.lpstrElementName = buf;
\r
2544 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2545 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2546 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
\r
2547 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
2548 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
2551 #endif /* WIN32 */
\r
2553 #else /* USE_MUSIC */
\r
2557 #endif /* USE_MUSIC */
\r
2563 * Delay for "x" milliseconds
\r
2565 static int Term_xtra_win_delay(int v)
\r
2579 t = GetTickCount() + v;
\r
2582 while (GetTickCount() < t)
\r
2584 /* Handle messages */
\r
2585 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2587 TranslateMessage(&msg);
\r
2588 DispatchMessage(&msg);
\r
2592 #endif /* WIN32 */
\r
2600 * Do a "special thing"
\r
2602 static errr Term_xtra_win(int n, int v)
\r
2604 /* Handle a subset of the legal requests */
\r
2607 /* Make a bell sound */
\r
2608 case TERM_XTRA_NOISE:
\r
2610 return (Term_xtra_win_noise());
\r
2613 /* Play a music */
\r
2614 case TERM_XTRA_MUSIC_BASIC:
\r
2615 case TERM_XTRA_MUSIC_DUNGEON:
\r
2616 case TERM_XTRA_MUSIC_QUEST:
\r
2617 case TERM_XTRA_MUSIC_TOWN:
\r
2619 return (Term_xtra_win_music(n, v));
\r
2622 /* Make a special sound */
\r
2623 case TERM_XTRA_SOUND:
\r
2625 return (Term_xtra_win_sound(v));
\r
2628 /* Process random events */
\r
2629 case TERM_XTRA_BORED:
\r
2631 return (Term_xtra_win_event(0));
\r
2634 /* Process an event */
\r
2635 case TERM_XTRA_EVENT:
\r
2637 return (Term_xtra_win_event(v));
\r
2640 /* Flush all events */
\r
2641 case TERM_XTRA_FLUSH:
\r
2643 return (Term_xtra_win_flush());
\r
2646 /* Clear the screen */
\r
2647 case TERM_XTRA_CLEAR:
\r
2649 return (Term_xtra_win_clear());
\r
2652 /* React to global changes */
\r
2653 case TERM_XTRA_REACT:
\r
2655 return (Term_xtra_win_react());
\r
2658 /* Delay for some milliseconds */
\r
2659 case TERM_XTRA_DELAY:
\r
2661 return (Term_xtra_win_delay(v));
\r
2671 * Low level graphics (Assumes valid input).
\r
2673 * Draw a "cursor" at (x,y), using a "yellow box".
\r
2675 static errr Term_curs_win(int x, int y)
\r
2677 term_data *td = (term_data*)(Term->data);
\r
2682 int tile_wid, tile_hgt;
\r
2684 if (td->map_active)
\r
2686 tile_wid = td->map_tile_wid;
\r
2687 tile_hgt = td->map_tile_hgt;
\r
2691 tile_wid = td->tile_wid;
\r
2692 tile_hgt = td->tile_hgt;
\r
2695 /* Frame the grid */
\r
2696 rc.left = x * tile_wid + td->size_ow1;
\r
2697 rc.right = rc.left + tile_wid;
\r
2698 rc.top = y * tile_hgt + td->size_oh1;
\r
2699 rc.bottom = rc.top + tile_hgt;
\r
2701 /* Cursor is done as a yellow "box" */
\r
2702 hdc = GetDC(td->w);
\r
2703 FrameRect(hdc, &rc, hbrYellow);
\r
2704 ReleaseDC(td->w, hdc);
\r
2712 * Low level graphics (Assumes valid input).
\r
2714 * Draw a "big cursor" at (x,y), using a "yellow box".
\r
2716 static errr Term_bigcurs_win(int x, int y)
\r
2718 term_data *td = (term_data*)(Term->data);
\r
2723 int tile_wid, tile_hgt;
\r
2725 if (td->map_active)
\r
2727 /* Normal cursor in map window */
\r
2728 Term_curs_win(x, y);
\r
2733 tile_wid = td->tile_wid;
\r
2734 tile_hgt = td->tile_hgt;
\r
2737 /* Frame the grid */
\r
2738 rc.left = x * tile_wid + td->size_ow1;
\r
2739 rc.right = rc.left + 2 * tile_wid;
\r
2740 rc.top = y * tile_hgt + td->size_oh1;
\r
2741 rc.bottom = rc.top + tile_hgt;
\r
2743 /* Cursor is done as a yellow "box" */
\r
2744 hdc = GetDC(td->w);
\r
2745 FrameRect(hdc, &rc, hbrYellow);
\r
2746 ReleaseDC(td->w, hdc);
\r
2754 * Low level graphics (Assumes valid input).
\r
2756 * Erase a "block" of "n" characters starting at (x,y).
\r
2758 static errr Term_wipe_win(int x, int y, int n)
\r
2760 term_data *td = (term_data*)(Term->data);
\r
2765 /* Rectangle to erase in client coords */
\r
2766 rc.left = x * td->tile_wid + td->size_ow1;
\r
2767 rc.right = rc.left + n * td->tile_wid;
\r
2768 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2769 rc.bottom = rc.top + td->tile_hgt;
\r
2771 hdc = GetDC(td->w);
\r
2772 SetBkColor(hdc, RGB(0, 0, 0));
\r
2773 SelectObject(hdc, td->font_id);
\r
2778 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2779 ReleaseDC(td->w, hdc);
\r
2787 * Low level graphics. Assumes valid input.
\r
2789 * Draw several ("n") chars, with an attr, at a given location.
\r
2791 * All "graphic" data is handled by "Term_pict_win()", below.
\r
2793 * One would think there is a more efficient method for telling a window
\r
2794 * what color it should be using to draw with, but perhaps simply changing
\r
2795 * it every time is not too inefficient.
\r
2797 static errr Term_text_win(int x, int y, int n, TERM_COLOR a, concptr s)
\r
2799 term_data *td = (term_data*)(Term->data);
\r
2803 #if 1 /* #ifdef JP */
\r
2804 static HBITMAP WALL;
\r
2805 static HBRUSH myBrush, oldBrush;
\r
2806 static HPEN oldPen;
\r
2807 static bool init_done = FALSE;
\r
2810 WALL = LoadBitmap(hInstance, AppName);
\r
2811 myBrush = CreatePatternBrush(WALL);
\r
2816 /* Total rectangle */
\r
2817 rc.left = x * td->tile_wid + td->size_ow1;
\r
2818 rc.right = rc.left + n * td->tile_wid;
\r
2819 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2820 rc.bottom = rc.top + td->tile_hgt;
\r
2823 hdc = GetDC(td->w);
\r
2825 /* Background color */
\r
2826 SetBkColor(hdc, RGB(0, 0, 0));
\r
2828 /* Foreground color */
\r
2831 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
\r
2833 else if (paletted)
\r
2835 SetTextColor(hdc, win_clr[a&0x0F]);
\r
2839 SetTextColor(hdc, win_clr[a]);
\r
2842 /* Use the font */
\r
2843 SelectObject(hdc, td->font_id);
\r
2846 if (use_bg) SetBkMode(hdc, TRANSPARENT);
\r
2848 /* Bizarre size */
\r
2849 if (td->bizarre ||
\r
2850 (td->tile_hgt != td->font_hgt) ||
\r
2851 (td->tile_wid != td->font_wid))
\r
2855 /* Erase complete rectangle */
\r
2856 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2859 if (use_bg) DrawBG(hdc, &rc);
\r
2861 /* New rectangle */
\r
2862 rc.left += ((td->tile_wid - td->font_wid) / 2);
\r
2863 rc.right = rc.left + td->font_wid;
\r
2864 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
\r
2865 rc.bottom = rc.top + td->font_hgt;
\r
2867 /* Dump each character */
\r
2868 for (i = 0; i < n; i++)
\r
2871 if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
\r
2873 rc.right += td->font_wid;
\r
2875 oldBrush = SelectObject(hdc, myBrush);
\r
2876 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2878 /* Dump the wall */
\r
2879 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2881 SelectObject(hdc, oldBrush);
\r
2882 SelectObject(hdc, oldPen);
\r
2883 rc.right -= td->font_wid;
\r
2887 rc.left += 2 * td->tile_wid;
\r
2888 rc.right += 2 * td->tile_wid;
\r
2890 else if ( iskanji(*(s+i)) ) /* 2バイト文字 */
\r
2892 rc.right += td->font_wid;
\r
2893 /* Dump the text */
\r
2894 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2896 rc.right -= td->font_wid;
\r
2900 rc.left += 2 * td->tile_wid;
\r
2901 rc.right += 2 * td->tile_wid;
\r
2902 } else if (*(s+i)==127){
\r
2903 oldBrush = SelectObject(hdc, myBrush);
\r
2904 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2906 /* Dump the wall */
\r
2907 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2909 SelectObject(hdc, oldBrush);
\r
2910 SelectObject(hdc, oldPen);
\r
2913 rc.left += td->tile_wid;
\r
2914 rc.right += td->tile_wid;
\r
2916 /* Dump the text */
\r
2917 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
\r
2920 rc.left += td->tile_wid;
\r
2921 rc.right += td->tile_wid;
\r
2926 oldBrush = SelectObject(hdc, myBrush);
\r
2927 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2929 /* Dump the wall */
\r
2930 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2932 SelectObject(hdc, oldBrush);
\r
2933 SelectObject(hdc, oldPen);
\r
2936 rc.left += td->tile_wid;
\r
2937 rc.right += td->tile_wid;
\r
2939 /* Dump the text */
\r
2940 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2944 rc.left += td->tile_wid;
\r
2945 rc.right += td->tile_wid;
\r
2948 /* Dump the text */
\r
2949 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
\r
2953 rc.left += td->tile_wid;
\r
2954 rc.right += td->tile_wid;
\r
2964 /* Dump the text */
\r
2965 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
\r
2970 ReleaseDC(td->w, hdc);
\r
2978 * Low level graphics. Assumes valid input.
\r
2980 * Draw an array of "special" attr/char pairs at the given location.
\r
2982 * We use the "Term_pict_win()" function for "graphic" data, which are
\r
2983 * encoded by setting the "high-bits" of both the "attr" and the "char"
\r
2984 * data. We use the "attr" to represent the "row" of the main bitmap,
\r
2985 * and the "char" to represent the "col" of the main bitmap. The use
\r
2986 * of this function is induced by the "higher_pict" flag.
\r
2988 * If "graphics" is not available, we simply "wipe" the given grids.
\r
2990 static errr Term_pict_win(TERM_LEN x, TERM_LEN y, int n, const TERM_COLOR *ap, concptr cp, const TERM_COLOR *tap, concptr tcp)
\r
2992 term_data *td = (term_data*)(Term->data);
\r
2994 #ifdef USE_GRAPHICS
\r
2997 TERM_LEN x1, y1, w1, h1, tw1, th1;
\r
2998 TERM_LEN x2, y2, w2, h2, tw2 = 0;
\r
3001 HDC hdcMask = NULL;
\r
3005 HBITMAP hbmSrcOld;
\r
3008 if (!use_graphics)
\r
3010 /* Erase the grids */
\r
3011 return (Term_wipe_win(x, y, n));
\r
3014 /* Size of bitmap cell */
\r
3015 w1 = infGraph.CellWidth;
\r
3016 h1 = infGraph.CellHeight;
\r
3017 tw1 = infGraph.TileWidth;
\r
3018 th1 = infGraph.TileHeight;
\r
3020 /* Size of window cell */
\r
3021 if (td->map_active)
\r
3023 w2 = td->map_tile_wid;
\r
3024 h2 = td->map_tile_hgt;
\r
3028 w2 = td->tile_wid;
\r
3029 h2 = td->tile_hgt;
\r
3032 /* big tile mode */
\r
3033 if (use_bigtile) tw2 *= 2;
\r
3036 /* Location of window cell */
\r
3037 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
\r
3038 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
\r
3041 hdc = GetDC(td->w);
\r
3044 hdcSrc = CreateCompatibleDC(hdc);
\r
3045 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
\r
3047 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3049 hdcMask = CreateCompatibleDC(hdc);
\r
3050 SelectObject(hdcMask, infMask.hBitmap);
\r
3053 /* Draw attr/char pairs */
\r
3054 for (i = 0; i < n; i++, x2 += w2)
\r
3056 TERM_COLOR a = ap[i];
\r
3060 /* Extract picture */
\r
3061 int row = (a & 0x7F);
\r
3062 int col = (c & 0x7F);
\r
3064 /* Location of bitmap cell */
\r
3068 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3070 x3 = (tcp[i] & 0x7F) * w1;
\r
3071 y3 = (tap[i] & 0x7F) * h1;
\r
3072 tw2 = tw2 * w1 / tw1;
\r
3073 h2 = h2 * h1 / th1;
\r
3075 /* Perfect size */
\r
3076 if ((tw1 == tw2) && (th1 == h2))
\r
3078 /* Copy the terrain picture from the bitmap to the window */
\r
3079 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
\r
3081 /* Mask out the tile */
\r
3082 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
\r
3084 /* Draw the tile */
\r
3085 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
\r
3088 /* Need to stretch */
\r
3091 /* Set the correct mode for stretching the tiles */
\r
3092 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3094 /* Copy the terrain picture from the bitmap to the window */
\r
3095 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
\r
3097 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
\r
3099 /* Only draw if terrain and overlay are different */
\r
3100 if ((x1 != x3) || (y1 != y3))
\r
3102 /* Mask out the tile */
\r
3103 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
\r
3105 /* Draw the tile */
\r
3106 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
\r
3112 /* Perfect size */
\r
3113 if ((w1 == tw2) && (h1 == h2))
\r
3115 /* Copy the picture from the bitmap to the window */
\r
3116 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
\r
3119 /* Need to stretch */
\r
3122 /* Set the correct mode for stretching the tiles */
\r
3123 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3125 /* Copy the picture from the bitmap to the window */
\r
3126 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
\r
3132 SelectObject(hdcSrc, hbmSrcOld);
\r
3135 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3138 SelectObject(hdcMask, hbmSrcOld);
\r
3139 DeleteDC(hdcMask);
\r
3143 ReleaseDC(td->w, hdc);
\r
3145 #else /* USE_GRAPHICS */
\r
3147 /* Just erase this grid */
\r
3148 return (Term_wipe_win(x, y, n));
\r
3150 #endif /* USE_GRAPHICS */
\r
3157 static void windows_map(void)
\r
3159 term_data *td = &data[0];
\r
3162 TERM_LEN x, min_x, max_x;
\r
3163 TERM_LEN y, min_y, max_y;
\r
3168 /* Only in graphics mode */
\r
3169 if (!use_graphics) return;
\r
3170 Term_xtra_win_clear();
\r
3172 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
\r
3173 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
\r
3174 td->map_active = TRUE;
\r
3183 /* Draw the map */
\r
3184 for (x = min_x; x < max_x; x++)
\r
3186 for (y = min_y; y < max_y; y++)
\r
3188 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
\r
3190 /* Ignore non-graphics */
\r
3191 if ((a & 0x80) && (c & 0x80))
\r
3193 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
\r
3198 /* Hilite the player */
\r
3199 Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
\r
3201 /* Wait for a keypress, flush key buffer */
\r
3202 Term_inkey(&c, TRUE, TRUE);
\r
3205 /* Switch off the map display */
\r
3206 td->map_active = FALSE;
\r
3208 /* Restore screen */
\r
3209 Term_xtra_win_clear();
\r
3214 /*** Other routines ***/
\r
3218 * Create and initialize a "term_data" given a title
\r
3220 static void term_data_link(term_data *td)
\r
3224 /* Initialize the term */
\r
3225 term_init(t, td->cols, td->rows, td->keys);
\r
3227 /* Use a "software" cursor */
\r
3228 t->soft_cursor = TRUE;
\r
3230 /* Use "Term_pict" for "graphic" data */
\r
3231 t->higher_pict = TRUE;
\r
3233 /* Erase with "white space" */
\r
3234 t->attr_blank = TERM_WHITE;
\r
3235 t->char_blank = ' ';
\r
3238 /* Prepare the init/nuke hooks */
\r
3239 t->init_hook = Term_init_win;
\r
3240 t->nuke_hook = Term_nuke_win;
\r
3243 /* Prepare the template hooks */
\r
3244 t->user_hook = Term_user_win;
\r
3245 t->xtra_hook = Term_xtra_win;
\r
3246 t->curs_hook = Term_curs_win;
\r
3247 t->bigcurs_hook = Term_bigcurs_win;
\r
3248 t->wipe_hook = Term_wipe_win;
\r
3249 t->text_hook = Term_text_win;
\r
3250 t->pict_hook = Term_pict_win;
\r
3252 /* Remember where we came from */
\r
3253 t->data = (vptr)(td);
\r
3258 * Create the windows
\r
3260 * First, instantiate the "default" values, then read the "ini_file"
\r
3261 * to over-ride selected values, then create the windows, and fonts.
\r
3263 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
\r
3264 * must make active to realize the palette.
\r
3266 static void init_windows(void)
\r
3272 #if 0 /* #ifndef JP */
\r
3278 WIPE(td, term_data);
\r
3282 td->s = angband_term_name[0];
\r
3288 td->visible = TRUE;
\r
3293 td->pos_x = 7 * 30;
\r
3294 td->pos_y = 7 * 20;
\r
3295 td->posfix = FALSE;
\r
3296 #if 1 /* #ifdef JP */
\r
3297 td->bizarre = TRUE;
\r
3300 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3303 WIPE(td, term_data);
\r
3304 td->s = angband_term_name[i];
\r
3308 td->visible = FALSE;
\r
3313 td->pos_x = (7 - i) * 30;
\r
3314 td->pos_y = (7 - i) * 20;
\r
3315 td->posfix = FALSE;
\r
3316 #if 1 /* #ifdef JP */
\r
3317 td->bizarre = TRUE;
\r
3326 /* Main window (need these before term_getsize gets called) */
\r
3328 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
\r
3329 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
\r
3331 td->dwExStyle = 0;
\r
3332 td->visible = TRUE;
\r
3334 /* Sub windows (need these before term_getsize gets called) */
\r
3335 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3338 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
\r
3339 td->dwExStyle = (WS_EX_TOOLWINDOW);
\r
3344 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3348 #if 1 /* #ifdef JP */
\r
3349 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
\r
3350 td->lf.lfCharSet = DEFAULT_CHARSET;
\r
3351 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
\r
3352 /* Activate the chosen font */
\r
3353 term_force_font(td, NULL);
\r
3354 if(!td->tile_wid) td->tile_wid = td->font_wid;
\r
3355 if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
\r
3357 /* Access the standard font file */
\r
3358 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
\r
3360 /* Activate the chosen font */
\r
3361 if (term_force_font(td, buf))
\r
3363 /* Access the standard font file */
\r
3364 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
3366 /* Force the use of that font */
\r
3367 (void)term_force_font(td, buf);
\r
3370 td->tile_hgt = 13;
\r
3372 /* Assume not bizarre */
\r
3373 td->bizarre = FALSE;
\r
3378 /* Analyze the font */
\r
3381 /* Resize the window */
\r
3382 term_window_resize(td);
\r
3386 /* Sub windows (reverse order) */
\r
3387 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
\r
3392 td->w = CreateWindowEx(td->dwExStyle, AngList,
\r
3393 td->s, td->dwStyle,
\r
3394 td->pos_x, td->pos_y,
\r
3395 td->size_wid, td->size_hgt,
\r
3396 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3398 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
\r
3402 td->size_hack = TRUE;
\r
3403 ShowWindow(td->w, SW_SHOW);
\r
3404 td->size_hack = FALSE;
\r
3407 term_data_link(td);
\r
3408 angband_term[i] = &td->t;
\r
3412 /* Activate the window */
\r
3413 SetActiveWindow(td->w);
\r
3416 if (data[i].posfix)
\r
3418 term_window_pos(&data[i], HWND_TOPMOST);
\r
3422 term_window_pos(&data[i], td->w);
\r
3432 td->w = CreateWindowEx(td->dwExStyle, AppName,
\r
3433 td->s, td->dwStyle,
\r
3434 td->pos_x, td->pos_y,
\r
3435 td->size_wid, td->size_hgt,
\r
3436 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3438 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
\r
3440 term_data_link(td);
\r
3441 angband_term[0] = &td->t;
\r
3442 normsize.x = td->cols;
\r
3443 normsize.y = td->rows;
\r
3445 /* Activate the main window */
\r
3446 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
\r
3447 else ShowWindow(td->w, SW_SHOW);
\r
3449 /* Bring main window back to top */
\r
3450 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
3454 (void)new_palette();
\r
3457 /* Create a "brush" for drawing the "cursor" */
\r
3458 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
\r
3461 /* Process pending messages */
\r
3462 (void)Term_xtra_win_flush();
\r
3468 * Prepare the menus
\r
3470 static void setup_menus(void)
\r
3474 HMENU hm = GetMenu(data[0].w);
\r
3477 /* Menu "File", Disable all */
\r
3478 EnableMenuItem(hm, IDM_FILE_NEW,
\r
3479 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3480 EnableMenuItem(hm, IDM_FILE_OPEN,
\r
3481 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3482 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3483 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3484 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3485 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3486 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3487 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3490 /* No character available */
\r
3491 if (!character_generated)
\r
3493 /* Menu "File", Item "New" */
\r
3494 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
\r
3496 /* Menu "File", Item "Open" */
\r
3497 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
\r
3500 /* A character available */
\r
3501 if (character_generated)
\r
3503 /* Menu "File", Item "Save" */
\r
3504 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3505 MF_BYCOMMAND | MF_ENABLED);
\r
3508 /* Menu "File", Item "Exit" */
\r
3509 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3510 MF_BYCOMMAND | MF_ENABLED);
\r
3512 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3513 MF_BYCOMMAND | MF_ENABLED);
\r
3516 /* Menu "Window::Visibility" */
\r
3517 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3519 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3520 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3522 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3523 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
\r
3525 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3526 MF_BYCOMMAND | MF_ENABLED);
\r
3529 /* Menu "Window::Font" */
\r
3530 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3532 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3533 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3535 if (data[i].visible)
\r
3537 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3538 MF_BYCOMMAND | MF_ENABLED);
\r
3542 /* Menu "Window::Window Position Fix" */
\r
3543 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3545 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3546 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3548 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3549 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
\r
3551 if (data[i].visible)
\r
3553 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3554 MF_BYCOMMAND | MF_ENABLED);
\r
3558 /* Menu "Window::Bizarre Display" */
\r
3559 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3561 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3562 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3564 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3565 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
\r
3567 if (data[i].visible)
\r
3569 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3570 MF_BYCOMMAND | MF_ENABLED);
\r
3575 /* Menu "Window::Increase Tile Width" */
\r
3576 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3578 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3579 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3581 if (data[i].visible)
\r
3583 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3584 MF_BYCOMMAND | MF_ENABLED);
\r
3589 /* Menu "Window::Decrease Tile Width" */
\r
3590 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3592 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3593 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3595 if (data[i].visible)
\r
3597 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3598 MF_BYCOMMAND | MF_ENABLED);
\r
3603 /* Menu "Window::Increase Tile Height" */
\r
3604 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3606 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3607 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3609 if (data[i].visible)
\r
3611 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3612 MF_BYCOMMAND | MF_ENABLED);
\r
3617 /* Menu "Window::Decrease Tile Height" */
\r
3618 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3620 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3621 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3623 if (data[i].visible)
\r
3625 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3626 MF_BYCOMMAND | MF_ENABLED);
\r
3631 /* Menu "Options", disable all */
\r
3632 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3633 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3634 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3635 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3636 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3637 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3638 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3639 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3640 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3641 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3643 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3644 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3647 /* Menu "Options", Item "Map" */
\r
3648 if (use_graphics != GRAPHICS_NONE)
\r
3649 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
\r
3651 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
\r
3652 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3654 /* Menu "Options", update all */
\r
3655 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3656 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
\r
3657 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3658 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
\r
3659 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3660 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
\r
3661 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
\r
3662 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
\r
3663 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3664 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
\r
3665 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
\r
3666 (arg_music ? MF_CHECKED : MF_UNCHECKED));
\r
3667 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3668 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
\r
3669 CheckMenuItem(hm, IDM_OPTIONS_BG,
\r
3670 (use_bg ? MF_CHECKED : MF_UNCHECKED));
\r
3672 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3673 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
\r
3676 #ifdef USE_GRAPHICS
\r
3677 /* Menu "Options", Item "Graphics" */
\r
3678 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
\r
3679 /* Menu "Options", Item "Graphics" */
\r
3680 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
\r
3681 /* Menu "Options", Item "Graphics" */
\r
3682 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
\r
3683 /* Menu "Options", Item "Graphics" */
\r
3684 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
\r
3685 #endif /* USE_GRAPHICS */
\r
3688 /* Menu "Options", Item "Sound" */
\r
3689 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
\r
3690 #endif /* USE_SOUND */
\r
3693 /* Menu "Options", Item "ScreenSaver" */
\r
3694 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3695 MF_BYCOMMAND | MF_ENABLED);
\r
3696 #endif /* USE_SAVER */
\r
3701 * Check for double clicked (or dragged) savefile
\r
3703 * Apparently, Windows copies the entire filename into the first
\r
3704 * piece of the "command line string". Perhaps we should extract
\r
3705 * the "basename" of that filename and append it to the "save" dir.
\r
3707 static void check_for_save_file(LPSTR cmd_line)
\r
3717 /* Extract filename */
\r
3718 strcat(savefile, s);
\r
3720 /* Validate the file */
\r
3721 validate_file(savefile);
\r
3723 /* Game in progress */
\r
3724 game_in_progress = TRUE;
\r
3732 * Process a menu command
\r
3734 static void process_menus(WORD wCmd)
\r
3746 case IDM_FILE_NEW:
\r
3750 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3752 else if (game_in_progress)
\r
3754 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
\r
3758 game_in_progress = TRUE;
\r
3767 case IDM_FILE_OPEN:
\r
3771 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3773 else if (game_in_progress)
\r
3775 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
\r
3779 memset(&ofn, 0, sizeof(ofn));
\r
3780 ofn.lStructSize = sizeof(ofn);
\r
3781 ofn.hwndOwner = data[0].w;
\r
3782 ofn.lpstrFilter = "Save Files (*.)\0*\0";
\r
3783 ofn.nFilterIndex = 1;
\r
3784 ofn.lpstrFile = savefile;
\r
3785 ofn.nMaxFile = 1024;
\r
3786 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
\r
3787 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
\r
3789 if (GetOpenFileName(&ofn))
\r
3791 /* Load 'savefile' */
\r
3792 validate_file(savefile);
\r
3793 game_in_progress = TRUE;
\r
3803 case IDM_FILE_SAVE:
\r
3805 if (game_in_progress && character_generated)
\r
3810 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
\r
3814 /* Hack -- Forget messages */
\r
3817 /* Save the game */
\r
3819 do_cmd_save_game(FALSE);
\r
3820 #else /* ZANGBAND */
\r
3821 do_cmd_save_game();
\r
3822 #endif /* ZANGBAND */
\r
3826 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
\r
3832 case IDM_FILE_EXIT:
\r
3834 if (game_in_progress && character_generated)
\r
3839 plog(_("今は終了できません。", "You may not do that right now."));
\r
3843 /* Hack -- Forget messages */
\r
3850 /* Save the game */
\r
3852 /* do_cmd_save_game(FALSE); */
\r
3853 #else /* ZANGBAND */
\r
3854 /* do_cmd_save_game(); */
\r
3855 #endif /* ZANGBAND */
\r
3856 Term_key_push(SPECIAL_KEY_QUIT);
\r
3864 case IDM_FILE_SCORE:
\r
3868 /* Build the filename */
\r
3869 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
\r
3871 /* Open the binary high score file, for reading */
\r
3872 highscore_fd = fd_open(buf, O_RDONLY);
\r
3874 /* Paranoia -- No score file */
\r
3875 if (highscore_fd < 0)
\r
3877 msg_print("Score file unavailable.");
\r
3884 /* Display the scores */
\r
3885 display_scores_aux(0, MAX_HISCORES, -1, NULL);
\r
3887 /* Shut the high score file */
\r
3888 (void)fd_close(highscore_fd);
\r
3890 /* Forget the high score fd */
\r
3891 highscore_fd = -1;
\r
3894 /* Hack - Flush it */
\r
3902 case IDM_FILE_MOVIE:
\r
3906 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3908 else if (game_in_progress)
\r
3910 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
\r
3914 memset(&ofn, 0, sizeof(ofn));
\r
3915 ofn.lStructSize = sizeof(ofn);
\r
3916 ofn.hwndOwner = data[0].w;
\r
3917 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
\r
3918 ofn.nFilterIndex = 1;
\r
3919 ofn.lpstrFile = savefile;
\r
3920 ofn.nMaxFile = 1024;
\r
3921 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
\r
3922 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
3924 if (GetOpenFileName(&ofn))
\r
3926 /* Load 'savefile' */
\r
3927 prepare_browse_movie_aux(savefile);
\r
3937 case IDM_WINDOW_VIS_0:
\r
3939 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
\r
3943 /* Window visibility */
\r
3944 case IDM_WINDOW_VIS_1:
\r
3945 case IDM_WINDOW_VIS_2:
\r
3946 case IDM_WINDOW_VIS_3:
\r
3947 case IDM_WINDOW_VIS_4:
\r
3948 case IDM_WINDOW_VIS_5:
\r
3949 case IDM_WINDOW_VIS_6:
\r
3950 case IDM_WINDOW_VIS_7:
\r
3952 i = wCmd - IDM_WINDOW_VIS_0;
\r
3954 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
3960 td->visible = TRUE;
\r
3961 ShowWindow(td->w, SW_SHOW);
\r
3962 term_data_redraw(td);
\r
3966 td->visible = FALSE;
\r
3967 td->posfix = FALSE;
\r
3968 ShowWindow(td->w, SW_HIDE);
\r
3974 /* Window fonts */
\r
3975 case IDM_WINDOW_FONT_0:
\r
3976 case IDM_WINDOW_FONT_1:
\r
3977 case IDM_WINDOW_FONT_2:
\r
3978 case IDM_WINDOW_FONT_3:
\r
3979 case IDM_WINDOW_FONT_4:
\r
3980 case IDM_WINDOW_FONT_5:
\r
3981 case IDM_WINDOW_FONT_6:
\r
3982 case IDM_WINDOW_FONT_7:
\r
3984 i = wCmd - IDM_WINDOW_FONT_0;
\r
3986 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
3990 term_change_font(td);
\r
3995 /* Window Z Position */
\r
3996 case IDM_WINDOW_POS_1:
\r
3997 case IDM_WINDOW_POS_2:
\r
3998 case IDM_WINDOW_POS_3:
\r
3999 case IDM_WINDOW_POS_4:
\r
4000 case IDM_WINDOW_POS_5:
\r
4001 case IDM_WINDOW_POS_6:
\r
4002 case IDM_WINDOW_POS_7:
\r
4004 i = wCmd - IDM_WINDOW_POS_0;
\r
4006 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4010 if (!td->posfix && td->visible)
\r
4012 td->posfix = TRUE;
\r
4013 term_window_pos(td, HWND_TOPMOST);
\r
4017 td->posfix = FALSE;
\r
4018 term_window_pos(td, data[0].w);
\r
4024 /* Bizarre Display */
\r
4025 case IDM_WINDOW_BIZ_0:
\r
4026 case IDM_WINDOW_BIZ_1:
\r
4027 case IDM_WINDOW_BIZ_2:
\r
4028 case IDM_WINDOW_BIZ_3:
\r
4029 case IDM_WINDOW_BIZ_4:
\r
4030 case IDM_WINDOW_BIZ_5:
\r
4031 case IDM_WINDOW_BIZ_6:
\r
4032 case IDM_WINDOW_BIZ_7:
\r
4034 i = wCmd - IDM_WINDOW_BIZ_0;
\r
4036 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4040 td->bizarre = !td->bizarre;
\r
4044 term_window_resize(td);
\r
4049 /* Increase Tile Width */
\r
4050 case IDM_WINDOW_I_WID_0:
\r
4051 case IDM_WINDOW_I_WID_1:
\r
4052 case IDM_WINDOW_I_WID_2:
\r
4053 case IDM_WINDOW_I_WID_3:
\r
4054 case IDM_WINDOW_I_WID_4:
\r
4055 case IDM_WINDOW_I_WID_5:
\r
4056 case IDM_WINDOW_I_WID_6:
\r
4057 case IDM_WINDOW_I_WID_7:
\r
4059 i = wCmd - IDM_WINDOW_I_WID_0;
\r
4061 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4065 td->tile_wid += 1;
\r
4069 term_window_resize(td);
\r
4074 /* Decrease Tile Height */
\r
4075 case IDM_WINDOW_D_WID_0:
\r
4076 case IDM_WINDOW_D_WID_1:
\r
4077 case IDM_WINDOW_D_WID_2:
\r
4078 case IDM_WINDOW_D_WID_3:
\r
4079 case IDM_WINDOW_D_WID_4:
\r
4080 case IDM_WINDOW_D_WID_5:
\r
4081 case IDM_WINDOW_D_WID_6:
\r
4082 case IDM_WINDOW_D_WID_7:
\r
4084 i = wCmd - IDM_WINDOW_D_WID_0;
\r
4086 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4090 td->tile_wid -= 1;
\r
4094 term_window_resize(td);
\r
4099 /* Increase Tile Height */
\r
4100 case IDM_WINDOW_I_HGT_0:
\r
4101 case IDM_WINDOW_I_HGT_1:
\r
4102 case IDM_WINDOW_I_HGT_2:
\r
4103 case IDM_WINDOW_I_HGT_3:
\r
4104 case IDM_WINDOW_I_HGT_4:
\r
4105 case IDM_WINDOW_I_HGT_5:
\r
4106 case IDM_WINDOW_I_HGT_6:
\r
4107 case IDM_WINDOW_I_HGT_7:
\r
4109 i = wCmd - IDM_WINDOW_I_HGT_0;
\r
4111 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4115 td->tile_hgt += 1;
\r
4119 term_window_resize(td);
\r
4124 /* Decrease Tile Height */
\r
4125 case IDM_WINDOW_D_HGT_0:
\r
4126 case IDM_WINDOW_D_HGT_1:
\r
4127 case IDM_WINDOW_D_HGT_2:
\r
4128 case IDM_WINDOW_D_HGT_3:
\r
4129 case IDM_WINDOW_D_HGT_4:
\r
4130 case IDM_WINDOW_D_HGT_5:
\r
4131 case IDM_WINDOW_D_HGT_6:
\r
4132 case IDM_WINDOW_D_HGT_7:
\r
4134 i = wCmd - IDM_WINDOW_D_HGT_0;
\r
4136 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4140 td->tile_hgt -= 1;
\r
4144 term_window_resize(td);
\r
4149 case IDM_OPTIONS_NO_GRAPHICS:
\r
4154 plog("You may not do that right now.");
\r
4158 /* Toggle "arg_graphics" */
\r
4159 if (arg_graphics != GRAPHICS_NONE)
\r
4161 arg_graphics = GRAPHICS_NONE;
\r
4163 /* React to changes */
\r
4164 Term_xtra_win_react();
\r
4166 /* Hack -- Force redraw */
\r
4167 Term_key_push(KTRL('R'));
\r
4173 case IDM_OPTIONS_OLD_GRAPHICS:
\r
4178 plog("You may not do that right now.");
\r
4182 /* Toggle "arg_graphics" */
\r
4183 if (arg_graphics != GRAPHICS_ORIGINAL)
\r
4185 arg_graphics = GRAPHICS_ORIGINAL;
\r
4187 /* React to changes */
\r
4188 Term_xtra_win_react();
\r
4190 /* Hack -- Force redraw */
\r
4191 Term_key_push(KTRL('R'));
\r
4197 case IDM_OPTIONS_NEW_GRAPHICS:
\r
4202 plog("You may not do that right now.");
\r
4206 /* Toggle "arg_graphics" */
\r
4207 if (arg_graphics != GRAPHICS_ADAM_BOLT)
\r
4209 arg_graphics = GRAPHICS_ADAM_BOLT;
\r
4211 /* React to changes */
\r
4212 Term_xtra_win_react();
\r
4214 /* Hack -- Force redraw */
\r
4215 Term_key_push(KTRL('R'));
\r
4221 case IDM_OPTIONS_NEW2_GRAPHICS:
\r
4226 plog("You may not do that right now.");
\r
4230 /* Toggle "arg_graphics" */
\r
4231 if (arg_graphics != GRAPHICS_HENGBAND)
\r
4233 arg_graphics = GRAPHICS_HENGBAND;
\r
4235 /* React to changes */
\r
4236 Term_xtra_win_react();
\r
4238 /* Hack -- Force redraw */
\r
4239 Term_key_push(KTRL('R'));
\r
4245 case IDM_OPTIONS_BIGTILE:
\r
4252 plog("You may not do that right now.");
\r
4256 /* Toggle "arg_sound" */
\r
4257 arg_bigtile = !arg_bigtile;
\r
4260 Term_activate(&td->t);
\r
4262 /* Resize the term */
\r
4263 Term_resize(td->cols, td->rows);
\r
4265 /* Redraw later */
\r
4266 InvalidateRect(td->w, NULL, TRUE);
\r
4271 case IDM_OPTIONS_MUSIC:
\r
4276 plog("You may not do that right now.");
\r
4280 /* Toggle "arg_sound" */
\r
4281 arg_music = !arg_music;
\r
4283 /* React to changes */
\r
4284 Term_xtra_win_react();
\r
4286 /* Hack -- Force redraw */
\r
4287 Term_key_push(KTRL('R'));
\r
4292 case IDM_OPTIONS_SOUND:
\r
4297 plog("You may not do that right now.");
\r
4301 /* Toggle "arg_sound" */
\r
4302 arg_sound = !arg_sound;
\r
4304 /* React to changes */
\r
4305 Term_xtra_win_react();
\r
4307 /* Hack -- Force redraw */
\r
4308 Term_key_push(KTRL('R'));
\r
4314 case IDM_OPTIONS_BG:
\r
4319 plog("You may not do that right now.");
\r
4323 /* Toggle "use_bg" */
\r
4328 /* React to changes */
\r
4329 Term_xtra_win_react();
\r
4331 /* Hack -- Force redraw */
\r
4332 Term_key_push(KTRL('R'));
\r
4338 case IDM_OPTIONS_OPEN_BG:
\r
4343 plog("You may not do that right now.");
\r
4348 memset(&ofn, 0, sizeof(ofn));
\r
4349 ofn.lStructSize = sizeof(ofn);
\r
4350 ofn.hwndOwner = data[0].w;
\r
4351 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
\r
4352 ofn.nFilterIndex = 1;
\r
4353 ofn.lpstrFile = bg_bitmap_file;
\r
4354 ofn.nMaxFile = 1023;
\r
4355 ofn.lpstrInitialDir = NULL;
\r
4356 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
\r
4357 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
\r
4359 if (GetOpenFileName(&ofn))
\r
4361 /* Load 'savefile' */
\r
4366 /* React to changes */
\r
4367 Term_xtra_win_react();
\r
4369 /* Hack -- Force redraw */
\r
4370 Term_key_push(KTRL('R'));
\r
4375 case IDM_DUMP_SCREEN_HTML:
\r
4377 static char buf[1024] = "";
\r
4378 memset(&ofn, 0, sizeof(ofn));
\r
4379 ofn.lStructSize = sizeof(ofn);
\r
4380 ofn.hwndOwner = data[0].w;
\r
4381 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
\r
4382 ofn.nFilterIndex = 1;
\r
4383 ofn.lpstrFile = buf;
\r
4384 ofn.nMaxFile = 1023;
\r
4385 ofn.lpstrDefExt = "html";
\r
4386 ofn.lpstrInitialDir = NULL;
\r
4387 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
\r
4388 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
\r
4390 if (GetSaveFileName(&ofn))
\r
4392 do_cmd_save_screen_html_aux(buf, 0);
\r
4399 case IDM_OPTIONS_SAVER:
\r
4403 DestroyWindow(hwndSaver);
\r
4408 /* Create a screen scaver window */
\r
4409 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
\r
4410 "Angband Screensaver",
\r
4411 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
\r
4412 0, 0, GetSystemMetrics(SM_CXSCREEN),
\r
4413 GetSystemMetrics(SM_CYSCREEN),
\r
4414 NULL, NULL, hInstance, NULL);
\r
4418 /* Push the window to the bottom */
\r
4419 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
4423 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
\r
4431 case IDM_OPTIONS_MAP:
\r
4437 case IDM_HELP_CONTENTS:
\r
4441 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
\r
4442 if (check_file(tmp))
\r
4444 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
\r
4448 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
\r
4449 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
\r
4452 #else /* HTML_HELP */
\r
4455 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
\r
4456 if (check_file(tmp))
\r
4458 sprintf(buf, "winhelp.exe %s", tmp);
\r
4459 WinExec(buf, SW_NORMAL);
\r
4463 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
\r
4464 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
\r
4468 #endif /* HTML_HELP */
\r
4474 static bool process_keydown(WPARAM wParam, LPARAM lParam)
\r
4481 /* Extract the modifiers */
\r
4482 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
\r
4483 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
\r
4484 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
\r
4486 Term_no_press = (ma) ? TRUE : FALSE;
\r
4488 /* Handle "special" keys */
\r
4489 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
\r
4491 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
\r
4492 bool numpad = FALSE;
\r
4494 /* Begin the macro trigger */
\r
4495 Term_keypress(31);
\r
4497 /* Send the modifiers */
\r
4498 if (mc) Term_keypress('C');
\r
4499 if (ms) Term_keypress('S');
\r
4500 if (ma) Term_keypress('A');
\r
4502 /* Extract "scan code" */
\r
4503 i = LOBYTE(HIWORD(lParam));
\r
4505 /* Introduce the scan code */
\r
4506 Term_keypress('x');
\r
4508 /* Extended key bit */
\r
4511 /* Numpad Enter and '/' are extended key */
\r
4513 Term_no_press = TRUE;
\r
4514 case VK_RETURN: /* Enter */
\r
4517 /* Other extended keys are on full keyboard */
\r
4531 case VK_SEPARATOR:
\r
4533 Term_no_press = TRUE;
\r
4537 case VK_PRIOR: /* Page Up */
\r
4538 case VK_NEXT: /* Page Down */
\r
4545 numpad = !ext_key;
\r
4548 /* Special modifiers for keypad keys */
\r
4549 if (numpad) Term_keypress('K');
\r
4551 /* Encode the hexidecimal scan code */
\r
4552 Term_keypress(hexsym[i/16]);
\r
4553 Term_keypress(hexsym[i%16]);
\r
4555 /* End the macro trigger */
\r
4556 Term_keypress(13);
\r
4566 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4567 WPARAM wParam, LPARAM lParam);
\r
4568 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4569 WPARAM wParam, LPARAM lParam)
\r
4570 #else /* __MWERKS__ */
\r
4571 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
4572 #endif /* __MWERKS__ */
\r
4578 MINMAXINFO FAR *lpmmi;
\r
4584 /* Acquire proper "term_data" info */
\r
4585 td = (term_data *)GetWindowLong(hWnd, 0);
\r
4587 /* Handle message */
\r
4592 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
4599 mop.dwCallback=(DWORD)hWnd;
\r
4604 case WM_GETMINMAXINFO:
\r
4606 MINMAXINFO FAR *lpmmi;
\r
4609 lpmmi = (MINMAXINFO FAR *)lParam;
\r
4611 /* this message was sent before WM_NCCREATE */
\r
4612 if (!td) return 1;
\r
4614 /* Minimum window size is 80x24 */
\r
4615 rc.left = rc.top = 0;
\r
4616 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
4617 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
4620 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
4622 /* Save minimum size */
\r
4623 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
4624 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
4631 BeginPaint(hWnd, &ps);
\r
4632 if (td) term_data_redraw(td);
\r
4633 EndPaint(hWnd, &ps);
\r
4634 ValidateRect(hWnd, NULL);
\r
4639 case MM_MCINOTIFY:
\r
4641 if(wParam == MCI_NOTIFY_SUCCESSFUL)
\r
4643 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
4644 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
4650 case WM_SYSKEYDOWN:
\r
4653 if (process_keydown(wParam, lParam))
\r
4660 if (Term_no_press) Term_no_press = FALSE;
\r
4661 else Term_keypress(wParam);
\r
4665 case WM_LBUTTONDOWN:
\r
4667 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4668 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4669 mouse_down = TRUE;
\r
4675 case WM_LBUTTONUP:
\r
4680 TERM_LEN dx = abs(oldx - mousex) + 1;
\r
4681 TERM_LEN dy = abs(oldy - mousey) + 1;
\r
4682 TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
\r
4683 TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
\r
4685 mouse_down = FALSE;
\r
4686 paint_rect = FALSE;
\r
4689 sz = (dx + 3) * dy;
\r
4691 sz = (dx + 2) * dy;
\r
4693 hGlobal = GlobalAlloc(GHND, sz + 1);
\r
4694 if (hGlobal == NULL) return 0;
\r
4695 lpStr = (LPSTR)GlobalLock(hGlobal);
\r
4697 for (i = 0; i < dy; i++)
\r
4701 char **scr = data[0].t.scr->c;
\r
4703 C_MAKE(s, (dx + 1), char);
\r
4704 strncpy(s, &scr[oy + i][ox], dx);
\r
4708 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
\r
4711 if (ox + dx < data[0].cols)
\r
4713 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
\r
4716 for (j = 0; j < dx; j++)
\r
4718 if (s[j] == 127) s[j] = '#';
\r
4722 for (j = 0; j < dx; j++)
\r
4724 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
\r
4734 GlobalUnlock(hGlobal);
\r
4735 if (OpenClipboard(hWnd) == 0)
\r
4737 GlobalFree(hGlobal);
\r
4741 SetClipboardData(CF_TEXT, hGlobal);
\r
4749 case WM_MOUSEMOVE:
\r
4754 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4755 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4760 dx = abs(oldx - mousex) + 1;
\r
4761 dy = abs(oldy - mousey) + 1;
\r
4762 ox = (oldx > mousex) ? mousex : oldx;
\r
4763 oy = (oldy > mousey) ? mousey : oldy;
\r
4764 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4768 paint_rect = TRUE;
\r
4771 dx = abs(cx - mousex) + 1;
\r
4772 dy = abs(cy - mousey) + 1;
\r
4773 ox = (cx > mousex) ? mousex : cx;
\r
4774 oy = (cy > mousey) ? mousey : cy;
\r
4775 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4791 if (game_in_progress && character_generated)
\r
4795 plog(_("今は終了できません。", "You may not do that right now."));
\r
4799 /* Hack -- Forget messages */
\r
4806 /* Save the game */
\r
4808 /* do_cmd_save_game(FALSE); */
\r
4809 #else /* ZANGBAND */
\r
4810 /* do_cmd_save_game(); */
\r
4811 #endif /* ZANGBAND */
\r
4812 Term_key_push(SPECIAL_KEY_QUIT);
\r
4819 case WM_QUERYENDSESSION:
\r
4821 if (game_in_progress && character_generated)
\r
4823 /* Hack -- Forget messages */
\r
4826 /* Mega-Hack -- Delay death */
\r
4827 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
\r
4828 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
\r
4830 /* Hardcode panic save */
\r
4831 p_ptr->panic_save = 1;
\r
4833 /* Forbid suspend */
\r
4834 signals_ignore_tstp();
\r
4836 /* Indicate panic save */
\r
4837 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
\r
4840 (void)save_player();
\r
4854 process_menus(LOWORD(wParam));
\r
4860 /* this message was sent before WM_NCCREATE */
\r
4861 if (!td) return 1;
\r
4863 /* it was sent from inside CreateWindowEx */
\r
4864 if (!td->w) return 1;
\r
4866 /* was sent from WM_SIZE */
\r
4867 if (td->size_hack) return 1;
\r
4871 case SIZE_MINIMIZED:
\r
4873 /* Hide sub-windows */
\r
4874 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4876 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
\r
4881 case SIZE_MAXIMIZED:
\r
4883 /* fall through */
\r
4886 case SIZE_RESTORED:
\r
4888 TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
4889 TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
4892 if ((td->cols != cols) || (td->rows != rows))
\r
4894 /* Save the new size */
\r
4898 if (!IsZoomed(td->w) && !IsIconic(td->w))
\r
4900 normsize.x = td->cols;
\r
4901 normsize.y = td->rows;
\r
4905 Term_activate(&td->t);
\r
4907 /* Resize the term */
\r
4908 Term_resize(td->cols, td->rows);
\r
4910 /* Redraw later */
\r
4911 InvalidateRect(td->w, NULL, TRUE);
\r
4914 td->size_hack = TRUE;
\r
4916 /* Show sub-windows */
\r
4917 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4919 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
\r
4922 td->size_hack = FALSE;
\r
4930 case WM_PALETTECHANGED:
\r
4932 /* Ignore if palette change caused by itself */
\r
4933 if ((HWND)wParam == hWnd) return 0;
\r
4935 /* Fall through... */
\r
4938 case WM_QUERYNEWPALETTE:
\r
4940 if (!paletted) return 0;
\r
4942 hdc = GetDC(hWnd);
\r
4944 SelectPalette(hdc, hPal, FALSE);
\r
4946 i = RealizePalette(hdc);
\r
4948 /* if any palette entries changed, repaint the window. */
\r
4949 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
4951 ReleaseDC(hWnd, hdc);
\r
4958 if (wParam && !HIWORD(lParam))
\r
4960 /* Do something to sub-windows */
\r
4961 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4963 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
\r
4966 /* Focus on main window */
\r
4975 case WM_ACTIVATEAPP:
\r
4977 if (IsIconic(td->w)) break;
\r
4979 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4981 if(data[i].visible)
\r
4983 if (wParam == TRUE)
\r
4985 ShowWindow(data[i].w, SW_SHOW);
\r
4989 ShowWindow(data[i].w, SW_HIDE);
\r
4996 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5001 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5002 WPARAM wParam, LPARAM lParam);
\r
5003 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5004 WPARAM wParam, LPARAM lParam)
\r
5005 #else /* __MWERKS__ */
\r
5006 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5007 WPARAM wParam, LPARAM lParam)
\r
5008 #endif /* __MWERKS__ */
\r
5012 MINMAXINFO FAR *lpmmi;
\r
5020 /* Acquire proper "term_data" info */
\r
5021 td = (term_data *)GetWindowLong(hWnd, 0);
\r
5023 /* Process message */
\r
5028 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
5037 case WM_GETMINMAXINFO:
\r
5039 MINMAXINFO FAR *lpmmi;
\r
5042 lpmmi = (MINMAXINFO FAR *)lParam;
\r
5044 /* this message was sent before WM_NCCREATE */
\r
5045 if (!td) return 1;
\r
5047 /* Minimum window size is 80x24 */
\r
5048 rc.left = rc.top = 0;
\r
5049 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
5050 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
5053 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
5055 /* Save minimum size */
\r
5056 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
5057 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
5067 /* this message was sent before WM_NCCREATE */
\r
5068 if (!td) return 1;
\r
5070 /* it was sent from inside CreateWindowEx */
\r
5071 if (!td->w) return 1;
\r
5073 /* was sent from inside WM_SIZE */
\r
5074 if (td->size_hack) return 1;
\r
5076 td->size_hack = TRUE;
\r
5078 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
5079 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
5082 if ((td->cols != cols) || (td->rows != rows))
\r
5084 /* Save old term */
\r
5085 term *old_term = Term;
\r
5087 /* Save the new size */
\r
5092 Term_activate(&td->t);
\r
5094 /* Resize the term */
\r
5095 Term_resize(td->cols, td->rows);
\r
5098 Term_activate(old_term);
\r
5100 /* Redraw later */
\r
5101 InvalidateRect(td->w, NULL, TRUE);
\r
5103 /* HACK - Redraw all windows */
\r
5104 p_ptr->window = 0xFFFFFFFF;
\r
5108 td->size_hack = FALSE;
\r
5115 BeginPaint(hWnd, &ps);
\r
5116 if (td) term_data_redraw(td);
\r
5117 EndPaint(hWnd, &ps);
\r
5121 case WM_SYSKEYDOWN:
\r
5124 if (process_keydown(wParam, lParam))
\r
5131 if (Term_no_press) Term_no_press = FALSE;
\r
5132 else Term_keypress(wParam);
\r
5136 case WM_PALETTECHANGED:
\r
5138 /* ignore if palette change caused by itself */
\r
5139 if ((HWND)wParam == hWnd) return FALSE;
\r
5140 /* otherwise, fall through!!! */
\r
5143 case WM_QUERYNEWPALETTE:
\r
5145 if (!paletted) return 0;
\r
5146 hdc = GetDC(hWnd);
\r
5147 SelectPalette(hdc, hPal, FALSE);
\r
5148 i = RealizePalette(hdc);
\r
5149 /* if any palette entries changed, repaint the window. */
\r
5150 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5151 ReleaseDC(hWnd, hdc);
\r
5155 case WM_NCLBUTTONDOWN:
\r
5159 if (wParam == HTCLOSE) wParam = HTSYSMENU;
\r
5160 #endif /* HTCLOSE */
\r
5162 if (wParam == HTSYSMENU)
\r
5166 td->visible = FALSE;
\r
5167 ShowWindow(td->w, SW_HIDE);
\r
5177 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5183 #define MOUSE_SENS 40
\r
5186 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5187 WPARAM wParam, LPARAM lParam);
\r
5188 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5189 WPARAM wParam, LPARAM lParam)
\r
5190 #else /* __MWERKS__ */
\r
5191 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5192 WPARAM wParam, LPARAM lParam)
\r
5193 #endif /* __MWERKS__ */
\r
5195 static int iMouse = 0;
\r
5196 static WORD xMouse = 0;
\r
5197 static WORD yMouse = 0;
\r
5210 case WM_SETCURSOR:
\r
5219 if (LOWORD(wParam) == WA_INACTIVE) break;
\r
5221 /* else fall through */
\r
5225 case WM_LBUTTONDOWN:
\r
5226 case WM_MBUTTONDOWN:
\r
5227 case WM_RBUTTONDOWN:
\r
5230 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5234 case WM_MOUSEMOVE:
\r
5238 dx = LOWORD(lParam) - xMouse;
\r
5239 dy = HIWORD(lParam) - yMouse;
\r
5241 if (dx < 0) dx = -dx;
\r
5242 if (dy < 0) dy = -dy;
\r
5244 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
\r
5246 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5250 /* Save last location */
\r
5252 xMouse = LOWORD(lParam);
\r
5253 yMouse = HIWORD(lParam);
\r
5260 DestroyWindow(hwndSaver);
\r
5266 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5269 #endif /* USE_SAVER */
\r
5275 /*** Temporary Hooks ***/
\r
5279 * Display warning message (see "z-util.c")
\r
5281 static void hack_plog(concptr str)
\r
5283 /* Give a warning */
\r
5287 MessageBox(NULL, str, "警告!",
\r
5288 MB_ICONEXCLAMATION | MB_OK);
\r
5290 MessageBox(NULL, str, "Warning",
\r
5291 MB_ICONEXCLAMATION | MB_OK);
\r
5299 * Display error message and quit (see "z-util.c")
\r
5301 static void hack_quit(concptr str)
\r
5303 /* Give a warning */
\r
5307 MessageBox(NULL, str, "エラー!",
\r
5308 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5310 MessageBox(NULL, str, "Error",
\r
5311 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5316 /* Unregister the classes */
\r
5317 UnregisterClass(AppName, hInstance);
\r
5319 /* Destroy the icon */
\r
5320 if (hIcon) DestroyIcon(hIcon);
\r
5328 /*** Various hooks ***/
\r
5332 * Display warning message (see "z-util.c")
\r
5334 static void hook_plog(concptr str)
\r
5340 MessageBox(data[0].w, str, "警告!",
\r
5341 MB_ICONEXCLAMATION | MB_OK);
\r
5343 MessageBox(data[0].w, str, "Warning",
\r
5344 MB_ICONEXCLAMATION | MB_OK);
\r
5352 * Display error message and quit (see "z-util.c")
\r
5354 static void hook_quit(concptr str)
\r
5359 /* Give a warning */
\r
5363 MessageBox(data[0].w, str, "エラー!",
\r
5364 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5366 MessageBox(data[0].w, str, "Error",
\r
5367 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5373 /* Save the preferences */
\r
5377 /*** Could use 'Term_nuke_win()' */
\r
5379 /* Destroy all windows */
\r
5380 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
\r
5382 term_force_font(&data[i], NULL);
\r
5383 if (data[i].font_want) string_free(data[i].font_want);
\r
5384 if (data[i].w) DestroyWindow(data[i].w);
\r
5388 /* Free the bitmap stuff */
\r
5389 #ifdef USE_GRAPHICS
\r
5390 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
\r
5391 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
\r
5393 if (infMask.hPalette) DeleteObject(infMask.hPalette);
\r
5394 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
\r
5396 #endif /* USE_GRAPHICS */
\r
5398 /*** Free some other stuff ***/
\r
5400 DeleteObject(hbrYellow);
\r
5405 if (hPal) DeleteObject(hPal);
\r
5407 UnregisterClass(AppName, hInstance);
\r
5409 if (hIcon) DestroyIcon(hIcon);
\r
5416 /*** Initialize ***/
\r
5422 static void init_stuff(void)
\r
5429 /* Get program name with full path */
\r
5430 GetModuleFileName(hInstance, path, 512);
\r
5432 /* Save the "program name" */
\r
5435 /* Get the name of the "*.ini" file */
\r
5436 strcpy(path + strlen(path) - 4, ".INI");
\r
5438 /* Save the the name of the ini-file */
\r
5439 ini_file = string_make(path);
\r
5441 /* Analyze the path */
\r
5444 /* Get the path */
\r
5445 for (; i > 0; i--)
\r
5447 if (path[i] == '\\')
\r
5454 /* Add "lib" to the path */
\r
5455 strcpy(path + i + 1, "lib\\");
\r
5457 /* Validate the path */
\r
5458 validate_dir(path, TRUE);
\r
5460 /* Init the file paths */
\r
5461 init_file_paths(path);
\r
5463 /* Hack -- Validate the paths */
\r
5464 validate_dir(ANGBAND_DIR_APEX, FALSE);
\r
5465 validate_dir(ANGBAND_DIR_BONE, FALSE);
\r
5467 /* Allow missing 'edit' directory */
\r
5468 if (!check_dir(ANGBAND_DIR_EDIT))
\r
5470 /* Must have 'data'! */
\r
5471 validate_dir(ANGBAND_DIR_DATA, TRUE);
\r
5475 /* Don't need 'data' */
\r
5476 validate_dir(ANGBAND_DIR_DATA, FALSE);
\r
5479 validate_dir(ANGBAND_DIR_FILE, TRUE);
\r
5480 validate_dir(ANGBAND_DIR_HELP, FALSE);
\r
5481 validate_dir(ANGBAND_DIR_INFO, FALSE);
\r
5482 validate_dir(ANGBAND_DIR_PREF, TRUE);
\r
5483 validate_dir(ANGBAND_DIR_SAVE, FALSE);
\r
5484 validate_dir(ANGBAND_DIR_USER, TRUE);
\r
5485 validate_dir(ANGBAND_DIR_XTRA, TRUE);
\r
5487 /* Build the filename */
\r
5488 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
\r
5490 /* Hack -- Validate the "news.txt" file */
\r
5491 validate_file(path);
\r
5494 #if 0 /* #ifndef JP */
\r
5495 /* Build the "font" path */
\r
5496 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
\r
5498 /* Allocate the path */
\r
5499 ANGBAND_DIR_XTRA_FONT = string_make(path);
\r
5501 /* Validate the "font" directory */
\r
5502 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
\r
5504 /* Build the filename */
\r
5505 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
5507 /* Hack -- Validate the basic font */
\r
5508 validate_file(path);
\r
5512 #ifdef USE_GRAPHICS
\r
5514 /* Build the "graf" path */
\r
5515 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
\r
5517 /* Allocate the path */
\r
5518 ANGBAND_DIR_XTRA_GRAF = string_make(path);
\r
5520 /* Validate the "graf" directory */
\r
5521 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
\r
5523 #endif /* USE_GRAPHICS */
\r
5528 /* Build the "sound" path */
\r
5529 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
\r
5531 /* Allocate the path */
\r
5532 ANGBAND_DIR_XTRA_SOUND = string_make(path);
\r
5534 /* Validate the "sound" directory */
\r
5535 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
\r
5537 #endif /* USE_SOUND */
\r
5541 /* Build the "music" path */
\r
5542 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
\r
5544 /* Allocate the path */
\r
5545 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
\r
5547 /* Validate the "music" directory */
\r
5548 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
\r
5550 #endif /* USE_MUSIC */
\r
5552 /* Build the "help" path */
\r
5553 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
\r
5555 /* Allocate the path */
\r
5556 ANGBAND_DIR_XTRA_HELP = string_make(path);
\r
5558 /* Validate the "help" directory */
\r
5559 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
\r
5563 * @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
\r
5565 static bool is_already_running(void)
\r
5567 bool result = FALSE;
\r
5570 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
\r
5571 if (GetLastError() == ERROR_ALREADY_EXISTS)
\r
5580 * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
\r
5582 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
\r
5583 LPSTR lpCmdLine, int nCmdShow)
\r
5591 setlocale(LC_ALL, "ja_JP.utf8");
\r
5596 /* Save globally */
\r
5597 hInstance = hInst;
\r
5600 /* Prevent multiple run */
\r
5601 if (is_already_running())
\r
5604 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
\r
5605 _("エラー!", "Error") ,
\r
5606 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5610 if (hPrevInst == NULL)
\r
5612 wc.style = CS_CLASSDC;
\r
5613 wc.lpfnWndProc = AngbandWndProc;
\r
5614 wc.cbClsExtra = 0;
\r
5615 wc.cbWndExtra = 4; /* one long pointer to term_data */
\r
5616 wc.hInstance = hInst;
\r
5617 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
\r
5618 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
\r
5619 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
\r
5620 wc.lpszMenuName = AppName;
\r
5621 wc.lpszClassName = AppName;
\r
5623 if (!RegisterClass(&wc)) exit(1);
\r
5625 wc.lpfnWndProc = AngbandListProc;
\r
5626 wc.lpszMenuName = NULL;
\r
5627 wc.lpszClassName = AngList;
\r
5629 if (!RegisterClass(&wc)) exit(2);
\r
5633 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
\r
5634 wc.lpfnWndProc = AngbandSaverProc;
\r
5635 wc.hCursor = NULL;
\r
5636 wc.lpszMenuName = NULL;
\r
5637 wc.lpszClassName = "WindowsScreenSaverClass";
\r
5639 if (!RegisterClass(&wc)) exit(3);
\r
5645 /* Temporary hooks */
\r
5646 plog_aux = hack_plog;
\r
5647 quit_aux = hack_quit;
\r
5648 core_aux = hack_quit;
\r
5650 /* Prepare the filepaths */
\r
5653 /* Initialize the keypress analyzer */
\r
5654 for (i = 0; special_key_list[i]; ++i)
\r
5656 special_key[special_key_list[i]] = TRUE;
\r
5658 /* Initialize the keypress analyzer */
\r
5659 for (i = 0; ignore_key_list[i]; ++i)
\r
5661 ignore_key[ignore_key_list[i]] = TRUE;
\r
5664 /* Determine if display is 16/256/true color */
\r
5665 hdc = GetDC(NULL);
\r
5666 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
\r
5667 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
\r
5668 ReleaseDC(NULL, hdc);
\r
5670 /* Initialize the colors */
\r
5671 for (i = 0; i < 256; i++)
\r
5675 /* Extract desired values */
\r
5676 rv = angband_color_table[i][1];
\r
5677 gv = angband_color_table[i][2];
\r
5678 bv = angband_color_table[i][3];
\r
5680 /* Extract the "complex" code */
\r
5681 win_clr[i] = PALETTERGB(rv, gv, bv);
\r
5683 /* Save the "simple" code */
\r
5684 angband_color_table[i][0] = win_pal[i];
\r
5687 /* Prepare the windows */
\r
5693 /* Activate hooks */
\r
5694 plog_aux = hook_plog;
\r
5695 quit_aux = hook_quit;
\r
5696 core_aux = hook_quit;
\r
5698 /* Set the system suffix */
\r
5699 ANGBAND_SYS = "win";
\r
5701 /* Set the keyboard suffix */
\r
5702 if (7 != GetKeyboardType(0))
\r
5703 ANGBAND_KEYBOARD = "0";
\r
5706 /* Japanese keyboard */
\r
5707 switch (GetKeyboardType(1))
\r
5709 case 0x0D01: case 0x0D02:
\r
5710 case 0x0D03: case 0x0D04:
\r
5711 case 0x0D05: case 0x0D06:
\r
5713 ANGBAND_KEYBOARD = "NEC98";
\r
5717 ANGBAND_KEYBOARD = "JAPAN";
\r
5721 /* Catch nasty signals */
\r
5724 Term_activate(term_screen);
\r
5727 /* We are now initialized */
\r
5728 initialized = TRUE;
\r
5730 if(lpCmdLine[0] == '-'){
\r
5731 switch(lpCmdLine[1])
\r
5736 if (!lpCmdLine[2]) break;
\r
5737 chuukei_server = TRUE;
\r
5738 if(connect_chuukei_server(&lpCmdLine[2])<0){
\r
5739 msg_print("connect fail");
\r
5742 msg_print("connect");
\r
5750 if (!lpCmdLine[2]) break;
\r
5751 chuukei_client = TRUE;
\r
5752 connect_chuukei_server(&lpCmdLine[2]);
\r
5760 if (!lpCmdLine[2]) break;
\r
5761 prepare_browse_movie(&lpCmdLine[2]);
\r
5771 /* Did the user double click on a save file? */
\r
5772 if(!chuukei_server) check_for_save_file(lpCmdLine);
\r
5774 /* Did the user double click on a save file? */
\r
5775 check_for_save_file(lpCmdLine);
\r
5778 /* Prompt the user */
\r
5779 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
\r
5783 /* Process messages forever */
\r
5784 while (GetMessage(&msg, NULL, 0, 0))
\r
5786 TranslateMessage(&msg);
\r
5787 DispatchMessage(&msg);
\r
5798 #endif /* WINDOWS */
\r