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(const char *, 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 cptr sound_file[SOUND_MAX][SAMPLE_MAX];
\r
536 #endif /* USE_SOUND */
\r
542 #define SAMPLE_MUSIC_MAX 16
\r
543 static cptr music_file[MUSIC_BASIC_MAX][SAMPLE_MUSIC_MAX];
\r
544 static cptr dungeon_music_file[1000][SAMPLE_MUSIC_MAX];
\r
545 static cptr town_music_file[1000][SAMPLE_MUSIC_MAX];
\r
546 static cptr 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 cptr ini_file = NULL;
\r
564 * Name of application
\r
566 static cptr AppName = "ANGBAND";
\r
569 * Name of sub-window type
\r
571 static cptr AngList = "AngList";
\r
576 static cptr ANGBAND_DIR_XTRA_GRAF;
\r
577 static cptr ANGBAND_DIR_XTRA_SOUND;
\r
578 static cptr ANGBAND_DIR_XTRA_MUSIC;
\r
579 static cptr ANGBAND_DIR_XTRA_HELP;
\r
580 #if 0 /* #ifndef JP */
\r
581 static cptr ANGBAND_DIR_XTRA_FONT;
\r
584 static cptr 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 cptr extract_file_name(cptr 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(cptr 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(cptr 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(cptr 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(cptr 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 char 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 char 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, cptr 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
2291 Term_activate(old);
\r
2302 * Process at least one event
\r
2304 static errr Term_xtra_win_event(int v)
\r
2308 /* Wait for an event */
\r
2312 if (GetMessage(&msg, NULL, 0, 0))
\r
2314 TranslateMessage(&msg);
\r
2315 DispatchMessage(&msg);
\r
2319 /* Check for an event */
\r
2323 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2325 TranslateMessage(&msg);
\r
2326 DispatchMessage(&msg);
\r
2336 * Process all pending events
\r
2338 static errr Term_xtra_win_flush(void)
\r
2342 /* Process all pending events */
\r
2343 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2345 TranslateMessage(&msg);
\r
2346 DispatchMessage(&msg);
\r
2355 * Hack -- clear the screen
\r
2357 * Make this more efficient
\r
2359 static errr Term_xtra_win_clear(void)
\r
2361 term_data *td = (term_data*)(Term->data);
\r
2366 /* Rectangle to erase */
\r
2367 rc.left = td->size_ow1;
\r
2368 rc.right = rc.left + td->cols * td->tile_wid;
\r
2369 rc.top = td->size_oh1;
\r
2370 rc.bottom = rc.top + td->rows * td->tile_hgt;
\r
2373 hdc = GetDC(td->w);
\r
2374 SetBkColor(hdc, RGB(0, 0, 0));
\r
2375 SelectObject(hdc, td->font_id);
\r
2376 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2381 rc.left = 0; rc.top = 0;
\r
2384 ReleaseDC(td->w, hdc);
\r
2392 * Hack -- make a noise
\r
2394 static errr Term_xtra_win_noise(void)
\r
2396 MessageBeep(MB_ICONASTERISK);
\r
2402 * Hack -- make a sound
\r
2404 static errr Term_xtra_win_sound(int v)
\r
2409 #endif /* USE_SOUND */
\r
2411 /* Sound disabled */
\r
2412 if (!use_sound) return (1);
\r
2414 /* Illegal sound */
\r
2415 if ((v < 0) || (v >= SOUND_MAX)) return (1);
\r
2419 /* Count the samples */
\r
2420 for (i = 0; i < SAMPLE_MAX; i++)
\r
2422 if (!sound_file[v][i])
\r
2427 if (i == 0) return (1);
\r
2429 /* Build the path */
\r
2430 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
\r
2434 /* Play the sound, catch errors */
\r
2435 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
\r
2439 /* Play the sound, catch errors */
\r
2440 return (sndPlaySound(buf, SND_ASYNC));
\r
2442 #endif /* WIN32 */
\r
2444 #else /* USE_SOUND */
\r
2448 #endif /* USE_SOUND */
\r
2452 * Hack -- play a music
\r
2454 static errr Term_xtra_win_music(int n, int v)
\r
2459 #endif /* USE_MUSIC */
\r
2461 /* Sound disabled */
\r
2463 if(!use_music) return (1);
\r
2465 /* Illegal sound */
\r
2466 if(n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return (1);
\r
2467 else if(v < 0 || v >= 1000) return(1); /*!< TODO */
\r
2473 case TERM_XTRA_MUSIC_BASIC:
\r
2474 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2476 case TERM_XTRA_MUSIC_DUNGEON:
\r
2477 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2479 case TERM_XTRA_MUSIC_QUEST:
\r
2480 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2482 case TERM_XTRA_MUSIC_TOWN:
\r
2483 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2490 //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2491 //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2497 case TERM_XTRA_MUSIC_BASIC:
\r
2498 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2500 case TERM_XTRA_MUSIC_DUNGEON:
\r
2501 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2503 case TERM_XTRA_MUSIC_QUEST:
\r
2504 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2506 case TERM_XTRA_MUSIC_TOWN:
\r
2507 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2514 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2515 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2521 case TERM_XTRA_MUSIC_BASIC:
\r
2522 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
\r
2524 case TERM_XTRA_MUSIC_DUNGEON:
\r
2525 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
\r
2527 case TERM_XTRA_MUSIC_QUEST:
\r
2528 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
\r
2530 case TERM_XTRA_MUSIC_TOWN:
\r
2531 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
\r
2535 if(current_music_type == n && current_music_id == v)
\r
2539 current_music_type = n;
\r
2540 current_music_id = v;
\r
2544 mop.lpstrDeviceType = mci_device_type;
\r
2545 mop.lpstrElementName = buf;
\r
2546 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2547 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2548 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
\r
2549 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
2550 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
2553 #endif /* WIN32 */
\r
2555 #else /* USE_MUSIC */
\r
2559 #endif /* USE_MUSIC */
\r
2565 * Delay for "x" milliseconds
\r
2567 static int Term_xtra_win_delay(int v)
\r
2581 t = GetTickCount() + v;
\r
2584 while (GetTickCount() < t)
\r
2586 /* Handle messages */
\r
2587 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2589 TranslateMessage(&msg);
\r
2590 DispatchMessage(&msg);
\r
2594 #endif /* WIN32 */
\r
2602 * Do a "special thing"
\r
2604 static errr Term_xtra_win(int n, int v)
\r
2606 /* Handle a subset of the legal requests */
\r
2609 /* Make a bell sound */
\r
2610 case TERM_XTRA_NOISE:
\r
2612 return (Term_xtra_win_noise());
\r
2615 /* Play a music */
\r
2616 case TERM_XTRA_MUSIC_BASIC:
\r
2617 case TERM_XTRA_MUSIC_DUNGEON:
\r
2618 case TERM_XTRA_MUSIC_QUEST:
\r
2619 case TERM_XTRA_MUSIC_TOWN:
\r
2621 return (Term_xtra_win_music(n, v));
\r
2624 /* Make a special sound */
\r
2625 case TERM_XTRA_SOUND:
\r
2627 return (Term_xtra_win_sound(v));
\r
2630 /* Process random events */
\r
2631 case TERM_XTRA_BORED:
\r
2633 return (Term_xtra_win_event(0));
\r
2636 /* Process an event */
\r
2637 case TERM_XTRA_EVENT:
\r
2639 return (Term_xtra_win_event(v));
\r
2642 /* Flush all events */
\r
2643 case TERM_XTRA_FLUSH:
\r
2645 return (Term_xtra_win_flush());
\r
2648 /* Clear the screen */
\r
2649 case TERM_XTRA_CLEAR:
\r
2651 return (Term_xtra_win_clear());
\r
2654 /* React to global changes */
\r
2655 case TERM_XTRA_REACT:
\r
2657 return (Term_xtra_win_react());
\r
2660 /* Delay for some milliseconds */
\r
2661 case TERM_XTRA_DELAY:
\r
2663 return (Term_xtra_win_delay(v));
\r
2673 * Low level graphics (Assumes valid input).
\r
2675 * Draw a "cursor" at (x,y), using a "yellow box".
\r
2677 static errr Term_curs_win(int x, int y)
\r
2679 term_data *td = (term_data*)(Term->data);
\r
2684 int tile_wid, tile_hgt;
\r
2686 if (td->map_active)
\r
2688 tile_wid = td->map_tile_wid;
\r
2689 tile_hgt = td->map_tile_hgt;
\r
2693 tile_wid = td->tile_wid;
\r
2694 tile_hgt = td->tile_hgt;
\r
2697 /* Frame the grid */
\r
2698 rc.left = x * tile_wid + td->size_ow1;
\r
2699 rc.right = rc.left + tile_wid;
\r
2700 rc.top = y * tile_hgt + td->size_oh1;
\r
2701 rc.bottom = rc.top + tile_hgt;
\r
2703 /* Cursor is done as a yellow "box" */
\r
2704 hdc = GetDC(td->w);
\r
2705 FrameRect(hdc, &rc, hbrYellow);
\r
2706 ReleaseDC(td->w, hdc);
\r
2714 * Low level graphics (Assumes valid input).
\r
2716 * Draw a "big cursor" at (x,y), using a "yellow box".
\r
2718 static errr Term_bigcurs_win(int x, int y)
\r
2720 term_data *td = (term_data*)(Term->data);
\r
2725 int tile_wid, tile_hgt;
\r
2727 if (td->map_active)
\r
2729 /* Normal cursor in map window */
\r
2730 Term_curs_win(x, y);
\r
2735 tile_wid = td->tile_wid;
\r
2736 tile_hgt = td->tile_hgt;
\r
2739 /* Frame the grid */
\r
2740 rc.left = x * tile_wid + td->size_ow1;
\r
2741 rc.right = rc.left + 2 * tile_wid;
\r
2742 rc.top = y * tile_hgt + td->size_oh1;
\r
2743 rc.bottom = rc.top + tile_hgt;
\r
2745 /* Cursor is done as a yellow "box" */
\r
2746 hdc = GetDC(td->w);
\r
2747 FrameRect(hdc, &rc, hbrYellow);
\r
2748 ReleaseDC(td->w, hdc);
\r
2756 * Low level graphics (Assumes valid input).
\r
2758 * Erase a "block" of "n" characters starting at (x,y).
\r
2760 static errr Term_wipe_win(int x, int y, int n)
\r
2762 term_data *td = (term_data*)(Term->data);
\r
2767 /* Rectangle to erase in client coords */
\r
2768 rc.left = x * td->tile_wid + td->size_ow1;
\r
2769 rc.right = rc.left + n * td->tile_wid;
\r
2770 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2771 rc.bottom = rc.top + td->tile_hgt;
\r
2773 hdc = GetDC(td->w);
\r
2774 SetBkColor(hdc, RGB(0, 0, 0));
\r
2775 SelectObject(hdc, td->font_id);
\r
2780 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2781 ReleaseDC(td->w, hdc);
\r
2789 * Low level graphics. Assumes valid input.
\r
2791 * Draw several ("n") chars, with an attr, at a given location.
\r
2793 * All "graphic" data is handled by "Term_pict_win()", below.
\r
2795 * One would think there is a more efficient method for telling a window
\r
2796 * what color it should be using to draw with, but perhaps simply changing
\r
2797 * it every time is not too inefficient.
\r
2799 static errr Term_text_win(int x, int y, int n, TERM_COLOR a, const char *s)
\r
2801 term_data *td = (term_data*)(Term->data);
\r
2805 #if 1 /* #ifdef JP */
\r
2806 static HBITMAP WALL;
\r
2807 static HBRUSH myBrush, oldBrush;
\r
2808 static HPEN oldPen;
\r
2809 static bool init_done = FALSE;
\r
2812 WALL = LoadBitmap(hInstance, AppName);
\r
2813 myBrush = CreatePatternBrush(WALL);
\r
2818 /* Total rectangle */
\r
2819 rc.left = x * td->tile_wid + td->size_ow1;
\r
2820 rc.right = rc.left + n * td->tile_wid;
\r
2821 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2822 rc.bottom = rc.top + td->tile_hgt;
\r
2825 hdc = GetDC(td->w);
\r
2827 /* Background color */
\r
2828 SetBkColor(hdc, RGB(0, 0, 0));
\r
2830 /* Foreground color */
\r
2833 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
\r
2835 else if (paletted)
\r
2837 SetTextColor(hdc, win_clr[a&0x0F]);
\r
2841 SetTextColor(hdc, win_clr[a]);
\r
2844 /* Use the font */
\r
2845 SelectObject(hdc, td->font_id);
\r
2848 if (use_bg) SetBkMode(hdc, TRANSPARENT);
\r
2850 /* Bizarre size */
\r
2851 if (td->bizarre ||
\r
2852 (td->tile_hgt != td->font_hgt) ||
\r
2853 (td->tile_wid != td->font_wid))
\r
2857 /* Erase complete rectangle */
\r
2858 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2861 if (use_bg) DrawBG(hdc, &rc);
\r
2863 /* New rectangle */
\r
2864 rc.left += ((td->tile_wid - td->font_wid) / 2);
\r
2865 rc.right = rc.left + td->font_wid;
\r
2866 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
\r
2867 rc.bottom = rc.top + td->font_hgt;
\r
2869 /* Dump each character */
\r
2870 for (i = 0; i < n; i++)
\r
2873 if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
\r
2875 rc.right += td->font_wid;
\r
2877 oldBrush = SelectObject(hdc, myBrush);
\r
2878 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2880 /* Dump the wall */
\r
2881 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2883 SelectObject(hdc, oldBrush);
\r
2884 SelectObject(hdc, oldPen);
\r
2885 rc.right -= td->font_wid;
\r
2889 rc.left += 2 * td->tile_wid;
\r
2890 rc.right += 2 * td->tile_wid;
\r
2892 else if ( iskanji(*(s+i)) ) /* 2バイト文字 */
\r
2894 rc.right += td->font_wid;
\r
2895 /* Dump the text */
\r
2896 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2898 rc.right -= td->font_wid;
\r
2902 rc.left += 2 * td->tile_wid;
\r
2903 rc.right += 2 * td->tile_wid;
\r
2904 } else if (*(s+i)==127){
\r
2905 oldBrush = SelectObject(hdc, myBrush);
\r
2906 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2908 /* Dump the wall */
\r
2909 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2911 SelectObject(hdc, oldBrush);
\r
2912 SelectObject(hdc, oldPen);
\r
2915 rc.left += td->tile_wid;
\r
2916 rc.right += td->tile_wid;
\r
2918 /* Dump the text */
\r
2919 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
\r
2922 rc.left += td->tile_wid;
\r
2923 rc.right += td->tile_wid;
\r
2928 oldBrush = SelectObject(hdc, myBrush);
\r
2929 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2931 /* Dump the wall */
\r
2932 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2934 SelectObject(hdc, oldBrush);
\r
2935 SelectObject(hdc, oldPen);
\r
2938 rc.left += td->tile_wid;
\r
2939 rc.right += td->tile_wid;
\r
2941 /* Dump the text */
\r
2942 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2946 rc.left += td->tile_wid;
\r
2947 rc.right += td->tile_wid;
\r
2950 /* Dump the text */
\r
2951 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
\r
2955 rc.left += td->tile_wid;
\r
2956 rc.right += td->tile_wid;
\r
2966 /* Dump the text */
\r
2967 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
\r
2972 ReleaseDC(td->w, hdc);
\r
2980 * Low level graphics. Assumes valid input.
\r
2982 * Draw an array of "special" attr/char pairs at the given location.
\r
2984 * We use the "Term_pict_win()" function for "graphic" data, which are
\r
2985 * encoded by setting the "high-bits" of both the "attr" and the "char"
\r
2986 * data. We use the "attr" to represent the "row" of the main bitmap,
\r
2987 * and the "char" to represent the "col" of the main bitmap. The use
\r
2988 * of this function is induced by the "higher_pict" flag.
\r
2990 * If "graphics" is not available, we simply "wipe" the given grids.
\r
2992 static errr Term_pict_win(TERM_LEN x, TERM_LEN y, int n, const TERM_COLOR *ap, const char *cp, const TERM_COLOR *tap, const char *tcp)
\r
2994 term_data *td = (term_data*)(Term->data);
\r
2996 #ifdef USE_GRAPHICS
\r
2999 TERM_LEN x1, y1, w1, h1, tw1, th1;
\r
3000 TERM_LEN x2, y2, w2, h2, tw2 = 0;
\r
3003 HDC hdcMask = NULL;
\r
3007 HBITMAP hbmSrcOld;
\r
3010 if (!use_graphics)
\r
3012 /* Erase the grids */
\r
3013 return (Term_wipe_win(x, y, n));
\r
3016 /* Size of bitmap cell */
\r
3017 w1 = infGraph.CellWidth;
\r
3018 h1 = infGraph.CellHeight;
\r
3019 tw1 = infGraph.TileWidth;
\r
3020 th1 = infGraph.TileHeight;
\r
3022 /* Size of window cell */
\r
3023 if (td->map_active)
\r
3025 w2 = td->map_tile_wid;
\r
3026 h2 = td->map_tile_hgt;
\r
3030 w2 = td->tile_wid;
\r
3031 h2 = td->tile_hgt;
\r
3034 /* big tile mode */
\r
3035 if (use_bigtile) tw2 *= 2;
\r
3038 /* Location of window cell */
\r
3039 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
\r
3040 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
\r
3043 hdc = GetDC(td->w);
\r
3046 hdcSrc = CreateCompatibleDC(hdc);
\r
3047 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
\r
3049 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3051 hdcMask = CreateCompatibleDC(hdc);
\r
3052 SelectObject(hdcMask, infMask.hBitmap);
\r
3055 /* Draw attr/char pairs */
\r
3056 for (i = 0; i < n; i++, x2 += w2)
\r
3058 TERM_COLOR a = ap[i];
\r
3062 /* Extract picture */
\r
3063 int row = (a & 0x7F);
\r
3064 int col = (c & 0x7F);
\r
3066 /* Location of bitmap cell */
\r
3070 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3072 x3 = (tcp[i] & 0x7F) * w1;
\r
3073 y3 = (tap[i] & 0x7F) * h1;
\r
3074 tw2 = tw2 * w1 / tw1;
\r
3075 h2 = h2 * h1 / th1;
\r
3077 /* Perfect size */
\r
3078 if ((tw1 == tw2) && (th1 == h2))
\r
3080 /* Copy the terrain picture from the bitmap to the window */
\r
3081 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
\r
3083 /* Mask out the tile */
\r
3084 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
\r
3086 /* Draw the tile */
\r
3087 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
\r
3090 /* Need to stretch */
\r
3093 /* Set the correct mode for stretching the tiles */
\r
3094 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3096 /* Copy the terrain picture from the bitmap to the window */
\r
3097 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
\r
3099 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
\r
3101 /* Only draw if terrain and overlay are different */
\r
3102 if ((x1 != x3) || (y1 != y3))
\r
3104 /* Mask out the tile */
\r
3105 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
\r
3107 /* Draw the tile */
\r
3108 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
\r
3114 /* Perfect size */
\r
3115 if ((w1 == tw2) && (h1 == h2))
\r
3117 /* Copy the picture from the bitmap to the window */
\r
3118 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
\r
3121 /* Need to stretch */
\r
3124 /* Set the correct mode for stretching the tiles */
\r
3125 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3127 /* Copy the picture from the bitmap to the window */
\r
3128 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
\r
3134 SelectObject(hdcSrc, hbmSrcOld);
\r
3137 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3140 SelectObject(hdcMask, hbmSrcOld);
\r
3141 DeleteDC(hdcMask);
\r
3145 ReleaseDC(td->w, hdc);
\r
3147 #else /* USE_GRAPHICS */
\r
3149 /* Just erase this grid */
\r
3150 return (Term_wipe_win(x, y, n));
\r
3152 #endif /* USE_GRAPHICS */
\r
3159 static void windows_map(void)
\r
3161 term_data *td = &data[0];
\r
3164 TERM_LEN x, min_x, max_x;
\r
3165 TERM_LEN y, min_y, max_y;
\r
3170 /* Only in graphics mode */
\r
3171 if (!use_graphics) return;
\r
3173 /* Clear screen */
\r
3174 Term_xtra_win_clear();
\r
3176 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
\r
3177 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
\r
3178 td->map_active = TRUE;
\r
3187 /* Draw the map */
\r
3188 for (x = min_x; x < max_x; x++)
\r
3190 for (y = min_y; y < max_y; y++)
\r
3192 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
\r
3194 /* Ignore non-graphics */
\r
3195 if ((a & 0x80) && (c & 0x80))
\r
3197 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
\r
3202 /* Hilite the player */
\r
3203 Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
\r
3205 /* Wait for a keypress, flush key buffer */
\r
3206 Term_inkey(&c, TRUE, TRUE);
\r
3209 /* Switch off the map display */
\r
3210 td->map_active = FALSE;
\r
3212 /* Restore screen */
\r
3213 Term_xtra_win_clear();
\r
3218 /*** Other routines ***/
\r
3222 * Create and initialize a "term_data" given a title
\r
3224 static void term_data_link(term_data *td)
\r
3228 /* Initialize the term */
\r
3229 term_init(t, td->cols, td->rows, td->keys);
\r
3231 /* Use a "software" cursor */
\r
3232 t->soft_cursor = TRUE;
\r
3234 /* Use "Term_pict" for "graphic" data */
\r
3235 t->higher_pict = TRUE;
\r
3237 /* Erase with "white space" */
\r
3238 t->attr_blank = TERM_WHITE;
\r
3239 t->char_blank = ' ';
\r
3242 /* Prepare the init/nuke hooks */
\r
3243 t->init_hook = Term_init_win;
\r
3244 t->nuke_hook = Term_nuke_win;
\r
3247 /* Prepare the template hooks */
\r
3248 t->user_hook = Term_user_win;
\r
3249 t->xtra_hook = Term_xtra_win;
\r
3250 t->curs_hook = Term_curs_win;
\r
3251 t->bigcurs_hook = Term_bigcurs_win;
\r
3252 t->wipe_hook = Term_wipe_win;
\r
3253 t->text_hook = Term_text_win;
\r
3254 t->pict_hook = Term_pict_win;
\r
3256 /* Remember where we came from */
\r
3257 t->data = (vptr)(td);
\r
3262 * Create the windows
\r
3264 * First, instantiate the "default" values, then read the "ini_file"
\r
3265 * to over-ride selected values, then create the windows, and fonts.
\r
3267 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
\r
3268 * must make active to realize the palette.
\r
3270 static void init_windows(void)
\r
3276 #if 0 /* #ifndef JP */
\r
3282 WIPE(td, term_data);
\r
3286 td->s = angband_term_name[0];
\r
3292 td->visible = TRUE;
\r
3297 td->pos_x = 7 * 30;
\r
3298 td->pos_y = 7 * 20;
\r
3299 td->posfix = FALSE;
\r
3300 #if 1 /* #ifdef JP */
\r
3301 td->bizarre = TRUE;
\r
3304 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3307 WIPE(td, term_data);
\r
3308 td->s = angband_term_name[i];
\r
3312 td->visible = FALSE;
\r
3317 td->pos_x = (7 - i) * 30;
\r
3318 td->pos_y = (7 - i) * 20;
\r
3319 td->posfix = FALSE;
\r
3320 #if 1 /* #ifdef JP */
\r
3321 td->bizarre = TRUE;
\r
3330 /* Main window (need these before term_getsize gets called) */
\r
3332 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
\r
3333 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
\r
3335 td->dwExStyle = 0;
\r
3336 td->visible = TRUE;
\r
3338 /* Sub windows (need these before term_getsize gets called) */
\r
3339 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3342 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
\r
3343 td->dwExStyle = (WS_EX_TOOLWINDOW);
\r
3348 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3352 #if 1 /* #ifdef JP */
\r
3353 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
\r
3354 td->lf.lfCharSet = DEFAULT_CHARSET;
\r
3355 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
\r
3356 /* Activate the chosen font */
\r
3357 term_force_font(td, NULL);
\r
3358 if(!td->tile_wid) td->tile_wid = td->font_wid;
\r
3359 if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
\r
3361 /* Access the standard font file */
\r
3362 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
\r
3364 /* Activate the chosen font */
\r
3365 if (term_force_font(td, buf))
\r
3367 /* Access the standard font file */
\r
3368 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
3370 /* Force the use of that font */
\r
3371 (void)term_force_font(td, buf);
\r
3374 td->tile_hgt = 13;
\r
3376 /* Assume not bizarre */
\r
3377 td->bizarre = FALSE;
\r
3382 /* Analyze the font */
\r
3385 /* Resize the window */
\r
3386 term_window_resize(td);
\r
3390 /* Sub windows (reverse order) */
\r
3391 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
\r
3396 td->w = CreateWindowEx(td->dwExStyle, AngList,
\r
3397 td->s, td->dwStyle,
\r
3398 td->pos_x, td->pos_y,
\r
3399 td->size_wid, td->size_hgt,
\r
3400 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3402 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
\r
3406 td->size_hack = TRUE;
\r
3407 ShowWindow(td->w, SW_SHOW);
\r
3408 td->size_hack = FALSE;
\r
3411 term_data_link(td);
\r
3412 angband_term[i] = &td->t;
\r
3416 /* Activate the window */
\r
3417 SetActiveWindow(td->w);
\r
3420 if (data[i].posfix)
\r
3422 term_window_pos(&data[i], HWND_TOPMOST);
\r
3426 term_window_pos(&data[i], td->w);
\r
3436 td->w = CreateWindowEx(td->dwExStyle, AppName,
\r
3437 td->s, td->dwStyle,
\r
3438 td->pos_x, td->pos_y,
\r
3439 td->size_wid, td->size_hgt,
\r
3440 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3442 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
\r
3444 term_data_link(td);
\r
3445 angband_term[0] = &td->t;
\r
3446 normsize.x = td->cols;
\r
3447 normsize.y = td->rows;
\r
3449 /* Activate the main window */
\r
3450 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
\r
3451 else ShowWindow(td->w, SW_SHOW);
\r
3453 /* Bring main window back to top */
\r
3454 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
3458 (void)new_palette();
\r
3461 /* Create a "brush" for drawing the "cursor" */
\r
3462 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
\r
3465 /* Process pending messages */
\r
3466 (void)Term_xtra_win_flush();
\r
3472 * Prepare the menus
\r
3474 static void setup_menus(void)
\r
3478 HMENU hm = GetMenu(data[0].w);
\r
3481 /* Menu "File", Disable all */
\r
3482 EnableMenuItem(hm, IDM_FILE_NEW,
\r
3483 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3484 EnableMenuItem(hm, IDM_FILE_OPEN,
\r
3485 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3486 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3487 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3488 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3489 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3490 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3491 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3494 /* No character available */
\r
3495 if (!character_generated)
\r
3497 /* Menu "File", Item "New" */
\r
3498 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
\r
3500 /* Menu "File", Item "Open" */
\r
3501 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
\r
3504 /* A character available */
\r
3505 if (character_generated)
\r
3507 /* Menu "File", Item "Save" */
\r
3508 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3509 MF_BYCOMMAND | MF_ENABLED);
\r
3512 /* Menu "File", Item "Exit" */
\r
3513 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3514 MF_BYCOMMAND | MF_ENABLED);
\r
3516 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3517 MF_BYCOMMAND | MF_ENABLED);
\r
3520 /* Menu "Window::Visibility" */
\r
3521 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3523 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3524 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3526 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3527 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
\r
3529 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3530 MF_BYCOMMAND | MF_ENABLED);
\r
3533 /* Menu "Window::Font" */
\r
3534 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3536 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3537 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3539 if (data[i].visible)
\r
3541 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3542 MF_BYCOMMAND | MF_ENABLED);
\r
3546 /* Menu "Window::Window Position Fix" */
\r
3547 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3549 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3550 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3552 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3553 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
\r
3555 if (data[i].visible)
\r
3557 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3558 MF_BYCOMMAND | MF_ENABLED);
\r
3562 /* Menu "Window::Bizarre Display" */
\r
3563 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3565 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3566 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3568 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3569 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
\r
3571 if (data[i].visible)
\r
3573 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3574 MF_BYCOMMAND | MF_ENABLED);
\r
3579 /* Menu "Window::Increase Tile Width" */
\r
3580 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3582 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3583 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3585 if (data[i].visible)
\r
3587 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3588 MF_BYCOMMAND | MF_ENABLED);
\r
3593 /* Menu "Window::Decrease Tile Width" */
\r
3594 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3596 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3597 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3599 if (data[i].visible)
\r
3601 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3602 MF_BYCOMMAND | MF_ENABLED);
\r
3607 /* Menu "Window::Increase Tile Height" */
\r
3608 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3610 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3611 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3613 if (data[i].visible)
\r
3615 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3616 MF_BYCOMMAND | MF_ENABLED);
\r
3621 /* Menu "Window::Decrease Tile Height" */
\r
3622 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3624 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3625 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3627 if (data[i].visible)
\r
3629 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3630 MF_BYCOMMAND | MF_ENABLED);
\r
3635 /* Menu "Options", disable all */
\r
3636 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3637 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3638 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3639 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3640 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3641 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3642 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3643 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3644 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3645 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3647 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3648 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3651 /* Menu "Options", Item "Map" */
\r
3652 if (use_graphics != GRAPHICS_NONE)
\r
3653 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
\r
3655 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
\r
3656 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3658 /* Menu "Options", update all */
\r
3659 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3660 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
\r
3661 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3662 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
\r
3663 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3664 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
\r
3665 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
\r
3666 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
\r
3667 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3668 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
\r
3669 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
\r
3670 (arg_music ? MF_CHECKED : MF_UNCHECKED));
\r
3671 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3672 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
\r
3673 CheckMenuItem(hm, IDM_OPTIONS_BG,
\r
3674 (use_bg ? MF_CHECKED : MF_UNCHECKED));
\r
3676 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3677 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
\r
3680 #ifdef USE_GRAPHICS
\r
3681 /* Menu "Options", Item "Graphics" */
\r
3682 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
\r
3683 /* Menu "Options", Item "Graphics" */
\r
3684 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
\r
3685 /* Menu "Options", Item "Graphics" */
\r
3686 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
\r
3687 /* Menu "Options", Item "Graphics" */
\r
3688 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
\r
3689 #endif /* USE_GRAPHICS */
\r
3692 /* Menu "Options", Item "Sound" */
\r
3693 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
\r
3694 #endif /* USE_SOUND */
\r
3697 /* Menu "Options", Item "ScreenSaver" */
\r
3698 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3699 MF_BYCOMMAND | MF_ENABLED);
\r
3700 #endif /* USE_SAVER */
\r
3705 * Check for double clicked (or dragged) savefile
\r
3707 * Apparently, Windows copies the entire filename into the first
\r
3708 * piece of the "command line string". Perhaps we should extract
\r
3709 * the "basename" of that filename and append it to the "save" dir.
\r
3711 static void check_for_save_file(LPSTR cmd_line)
\r
3721 /* Extract filename */
\r
3722 strcat(savefile, s);
\r
3724 /* Validate the file */
\r
3725 validate_file(savefile);
\r
3727 /* Game in progress */
\r
3728 game_in_progress = TRUE;
\r
3736 * Process a menu command
\r
3738 static void process_menus(WORD wCmd)
\r
3750 case IDM_FILE_NEW:
\r
3754 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3756 else if (game_in_progress)
\r
3758 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
\r
3762 game_in_progress = TRUE;
\r
3771 case IDM_FILE_OPEN:
\r
3775 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3777 else if (game_in_progress)
\r
3779 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
\r
3783 memset(&ofn, 0, sizeof(ofn));
\r
3784 ofn.lStructSize = sizeof(ofn);
\r
3785 ofn.hwndOwner = data[0].w;
\r
3786 ofn.lpstrFilter = "Save Files (*.)\0*\0";
\r
3787 ofn.nFilterIndex = 1;
\r
3788 ofn.lpstrFile = savefile;
\r
3789 ofn.nMaxFile = 1024;
\r
3790 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
\r
3791 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
\r
3793 if (GetOpenFileName(&ofn))
\r
3795 /* Load 'savefile' */
\r
3796 validate_file(savefile);
\r
3797 game_in_progress = TRUE;
\r
3807 case IDM_FILE_SAVE:
\r
3809 if (game_in_progress && character_generated)
\r
3814 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
\r
3818 /* Hack -- Forget messages */
\r
3821 /* Save the game */
\r
3823 do_cmd_save_game(FALSE);
\r
3824 #else /* ZANGBAND */
\r
3825 do_cmd_save_game();
\r
3826 #endif /* ZANGBAND */
\r
3830 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
\r
3836 case IDM_FILE_EXIT:
\r
3838 if (game_in_progress && character_generated)
\r
3843 plog(_("今は終了できません。", "You may not do that right now."));
\r
3847 /* Hack -- Forget messages */
\r
3854 /* Save the game */
\r
3856 /* do_cmd_save_game(FALSE); */
\r
3857 #else /* ZANGBAND */
\r
3858 /* do_cmd_save_game(); */
\r
3859 #endif /* ZANGBAND */
\r
3860 Term_key_push(SPECIAL_KEY_QUIT);
\r
3868 case IDM_FILE_SCORE:
\r
3872 /* Build the filename */
\r
3873 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
\r
3875 /* Open the binary high score file, for reading */
\r
3876 highscore_fd = fd_open(buf, O_RDONLY);
\r
3878 /* Paranoia -- No score file */
\r
3879 if (highscore_fd < 0)
\r
3881 msg_print("Score file unavailable.");
\r
3887 /* Clear screen */
\r
3890 /* Display the scores */
\r
3891 display_scores_aux(0, MAX_HISCORES, -1, NULL);
\r
3893 /* Shut the high score file */
\r
3894 (void)fd_close(highscore_fd);
\r
3896 /* Forget the high score fd */
\r
3897 highscore_fd = -1;
\r
3900 /* Hack - Flush it */
\r
3908 case IDM_FILE_MOVIE:
\r
3912 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3914 else if (game_in_progress)
\r
3916 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
\r
3920 memset(&ofn, 0, sizeof(ofn));
\r
3921 ofn.lStructSize = sizeof(ofn);
\r
3922 ofn.hwndOwner = data[0].w;
\r
3923 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
\r
3924 ofn.nFilterIndex = 1;
\r
3925 ofn.lpstrFile = savefile;
\r
3926 ofn.nMaxFile = 1024;
\r
3927 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
\r
3928 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
3930 if (GetOpenFileName(&ofn))
\r
3932 /* Load 'savefile' */
\r
3933 prepare_browse_movie_aux(savefile);
\r
3943 case IDM_WINDOW_VIS_0:
\r
3945 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
\r
3949 /* Window visibility */
\r
3950 case IDM_WINDOW_VIS_1:
\r
3951 case IDM_WINDOW_VIS_2:
\r
3952 case IDM_WINDOW_VIS_3:
\r
3953 case IDM_WINDOW_VIS_4:
\r
3954 case IDM_WINDOW_VIS_5:
\r
3955 case IDM_WINDOW_VIS_6:
\r
3956 case IDM_WINDOW_VIS_7:
\r
3958 i = wCmd - IDM_WINDOW_VIS_0;
\r
3960 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
3966 td->visible = TRUE;
\r
3967 ShowWindow(td->w, SW_SHOW);
\r
3968 term_data_redraw(td);
\r
3972 td->visible = FALSE;
\r
3973 td->posfix = FALSE;
\r
3974 ShowWindow(td->w, SW_HIDE);
\r
3980 /* Window fonts */
\r
3981 case IDM_WINDOW_FONT_0:
\r
3982 case IDM_WINDOW_FONT_1:
\r
3983 case IDM_WINDOW_FONT_2:
\r
3984 case IDM_WINDOW_FONT_3:
\r
3985 case IDM_WINDOW_FONT_4:
\r
3986 case IDM_WINDOW_FONT_5:
\r
3987 case IDM_WINDOW_FONT_6:
\r
3988 case IDM_WINDOW_FONT_7:
\r
3990 i = wCmd - IDM_WINDOW_FONT_0;
\r
3992 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
3996 term_change_font(td);
\r
4001 /* Window Z Position */
\r
4002 case IDM_WINDOW_POS_1:
\r
4003 case IDM_WINDOW_POS_2:
\r
4004 case IDM_WINDOW_POS_3:
\r
4005 case IDM_WINDOW_POS_4:
\r
4006 case IDM_WINDOW_POS_5:
\r
4007 case IDM_WINDOW_POS_6:
\r
4008 case IDM_WINDOW_POS_7:
\r
4010 i = wCmd - IDM_WINDOW_POS_0;
\r
4012 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4016 if (!td->posfix && td->visible)
\r
4018 td->posfix = TRUE;
\r
4019 term_window_pos(td, HWND_TOPMOST);
\r
4023 td->posfix = FALSE;
\r
4024 term_window_pos(td, data[0].w);
\r
4030 /* Bizarre Display */
\r
4031 case IDM_WINDOW_BIZ_0:
\r
4032 case IDM_WINDOW_BIZ_1:
\r
4033 case IDM_WINDOW_BIZ_2:
\r
4034 case IDM_WINDOW_BIZ_3:
\r
4035 case IDM_WINDOW_BIZ_4:
\r
4036 case IDM_WINDOW_BIZ_5:
\r
4037 case IDM_WINDOW_BIZ_6:
\r
4038 case IDM_WINDOW_BIZ_7:
\r
4040 i = wCmd - IDM_WINDOW_BIZ_0;
\r
4042 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4046 td->bizarre = !td->bizarre;
\r
4050 term_window_resize(td);
\r
4055 /* Increase Tile Width */
\r
4056 case IDM_WINDOW_I_WID_0:
\r
4057 case IDM_WINDOW_I_WID_1:
\r
4058 case IDM_WINDOW_I_WID_2:
\r
4059 case IDM_WINDOW_I_WID_3:
\r
4060 case IDM_WINDOW_I_WID_4:
\r
4061 case IDM_WINDOW_I_WID_5:
\r
4062 case IDM_WINDOW_I_WID_6:
\r
4063 case IDM_WINDOW_I_WID_7:
\r
4065 i = wCmd - IDM_WINDOW_I_WID_0;
\r
4067 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4071 td->tile_wid += 1;
\r
4075 term_window_resize(td);
\r
4080 /* Decrease Tile Height */
\r
4081 case IDM_WINDOW_D_WID_0:
\r
4082 case IDM_WINDOW_D_WID_1:
\r
4083 case IDM_WINDOW_D_WID_2:
\r
4084 case IDM_WINDOW_D_WID_3:
\r
4085 case IDM_WINDOW_D_WID_4:
\r
4086 case IDM_WINDOW_D_WID_5:
\r
4087 case IDM_WINDOW_D_WID_6:
\r
4088 case IDM_WINDOW_D_WID_7:
\r
4090 i = wCmd - IDM_WINDOW_D_WID_0;
\r
4092 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4096 td->tile_wid -= 1;
\r
4100 term_window_resize(td);
\r
4105 /* Increase Tile Height */
\r
4106 case IDM_WINDOW_I_HGT_0:
\r
4107 case IDM_WINDOW_I_HGT_1:
\r
4108 case IDM_WINDOW_I_HGT_2:
\r
4109 case IDM_WINDOW_I_HGT_3:
\r
4110 case IDM_WINDOW_I_HGT_4:
\r
4111 case IDM_WINDOW_I_HGT_5:
\r
4112 case IDM_WINDOW_I_HGT_6:
\r
4113 case IDM_WINDOW_I_HGT_7:
\r
4115 i = wCmd - IDM_WINDOW_I_HGT_0;
\r
4117 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4121 td->tile_hgt += 1;
\r
4125 term_window_resize(td);
\r
4130 /* Decrease Tile Height */
\r
4131 case IDM_WINDOW_D_HGT_0:
\r
4132 case IDM_WINDOW_D_HGT_1:
\r
4133 case IDM_WINDOW_D_HGT_2:
\r
4134 case IDM_WINDOW_D_HGT_3:
\r
4135 case IDM_WINDOW_D_HGT_4:
\r
4136 case IDM_WINDOW_D_HGT_5:
\r
4137 case IDM_WINDOW_D_HGT_6:
\r
4138 case IDM_WINDOW_D_HGT_7:
\r
4140 i = wCmd - IDM_WINDOW_D_HGT_0;
\r
4142 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4146 td->tile_hgt -= 1;
\r
4150 term_window_resize(td);
\r
4155 case IDM_OPTIONS_NO_GRAPHICS:
\r
4160 plog("You may not do that right now.");
\r
4164 /* Toggle "arg_graphics" */
\r
4165 if (arg_graphics != GRAPHICS_NONE)
\r
4167 arg_graphics = GRAPHICS_NONE;
\r
4169 /* React to changes */
\r
4170 Term_xtra_win_react();
\r
4172 /* Hack -- Force redraw */
\r
4173 Term_key_push(KTRL('R'));
\r
4179 case IDM_OPTIONS_OLD_GRAPHICS:
\r
4184 plog("You may not do that right now.");
\r
4188 /* Toggle "arg_graphics" */
\r
4189 if (arg_graphics != GRAPHICS_ORIGINAL)
\r
4191 arg_graphics = GRAPHICS_ORIGINAL;
\r
4193 /* React to changes */
\r
4194 Term_xtra_win_react();
\r
4196 /* Hack -- Force redraw */
\r
4197 Term_key_push(KTRL('R'));
\r
4203 case IDM_OPTIONS_NEW_GRAPHICS:
\r
4208 plog("You may not do that right now.");
\r
4212 /* Toggle "arg_graphics" */
\r
4213 if (arg_graphics != GRAPHICS_ADAM_BOLT)
\r
4215 arg_graphics = GRAPHICS_ADAM_BOLT;
\r
4217 /* React to changes */
\r
4218 Term_xtra_win_react();
\r
4220 /* Hack -- Force redraw */
\r
4221 Term_key_push(KTRL('R'));
\r
4227 case IDM_OPTIONS_NEW2_GRAPHICS:
\r
4232 plog("You may not do that right now.");
\r
4236 /* Toggle "arg_graphics" */
\r
4237 if (arg_graphics != GRAPHICS_HENGBAND)
\r
4239 arg_graphics = GRAPHICS_HENGBAND;
\r
4241 /* React to changes */
\r
4242 Term_xtra_win_react();
\r
4244 /* Hack -- Force redraw */
\r
4245 Term_key_push(KTRL('R'));
\r
4251 case IDM_OPTIONS_BIGTILE:
\r
4258 plog("You may not do that right now.");
\r
4262 /* Toggle "arg_sound" */
\r
4263 arg_bigtile = !arg_bigtile;
\r
4266 Term_activate(&td->t);
\r
4268 /* Resize the term */
\r
4269 Term_resize(td->cols, td->rows);
\r
4271 /* Redraw later */
\r
4272 InvalidateRect(td->w, NULL, TRUE);
\r
4277 case IDM_OPTIONS_MUSIC:
\r
4282 plog("You may not do that right now.");
\r
4286 /* Toggle "arg_sound" */
\r
4287 arg_music = !arg_music;
\r
4289 /* React to changes */
\r
4290 Term_xtra_win_react();
\r
4292 /* Hack -- Force redraw */
\r
4293 Term_key_push(KTRL('R'));
\r
4298 case IDM_OPTIONS_SOUND:
\r
4303 plog("You may not do that right now.");
\r
4307 /* Toggle "arg_sound" */
\r
4308 arg_sound = !arg_sound;
\r
4310 /* React to changes */
\r
4311 Term_xtra_win_react();
\r
4313 /* Hack -- Force redraw */
\r
4314 Term_key_push(KTRL('R'));
\r
4320 case IDM_OPTIONS_BG:
\r
4325 plog("You may not do that right now.");
\r
4329 /* Toggle "use_bg" */
\r
4334 /* React to changes */
\r
4335 Term_xtra_win_react();
\r
4337 /* Hack -- Force redraw */
\r
4338 Term_key_push(KTRL('R'));
\r
4344 case IDM_OPTIONS_OPEN_BG:
\r
4349 plog("You may not do that right now.");
\r
4354 memset(&ofn, 0, sizeof(ofn));
\r
4355 ofn.lStructSize = sizeof(ofn);
\r
4356 ofn.hwndOwner = data[0].w;
\r
4357 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
\r
4358 ofn.nFilterIndex = 1;
\r
4359 ofn.lpstrFile = bg_bitmap_file;
\r
4360 ofn.nMaxFile = 1023;
\r
4361 ofn.lpstrInitialDir = NULL;
\r
4362 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
\r
4363 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
\r
4365 if (GetOpenFileName(&ofn))
\r
4367 /* Load 'savefile' */
\r
4372 /* React to changes */
\r
4373 Term_xtra_win_react();
\r
4375 /* Hack -- Force redraw */
\r
4376 Term_key_push(KTRL('R'));
\r
4381 case IDM_DUMP_SCREEN_HTML:
\r
4383 static char buf[1024] = "";
\r
4384 memset(&ofn, 0, sizeof(ofn));
\r
4385 ofn.lStructSize = sizeof(ofn);
\r
4386 ofn.hwndOwner = data[0].w;
\r
4387 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
\r
4388 ofn.nFilterIndex = 1;
\r
4389 ofn.lpstrFile = buf;
\r
4390 ofn.nMaxFile = 1023;
\r
4391 ofn.lpstrDefExt = "html";
\r
4392 ofn.lpstrInitialDir = NULL;
\r
4393 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
\r
4394 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
\r
4396 if (GetSaveFileName(&ofn))
\r
4398 do_cmd_save_screen_html_aux(buf, 0);
\r
4405 case IDM_OPTIONS_SAVER:
\r
4409 DestroyWindow(hwndSaver);
\r
4414 /* Create a screen scaver window */
\r
4415 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
\r
4416 "Angband Screensaver",
\r
4417 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
\r
4418 0, 0, GetSystemMetrics(SM_CXSCREEN),
\r
4419 GetSystemMetrics(SM_CYSCREEN),
\r
4420 NULL, NULL, hInstance, NULL);
\r
4424 /* Push the window to the bottom */
\r
4425 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
4429 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
\r
4437 case IDM_OPTIONS_MAP:
\r
4443 case IDM_HELP_CONTENTS:
\r
4447 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
\r
4448 if (check_file(tmp))
\r
4450 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
\r
4454 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
\r
4455 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
\r
4458 #else /* HTML_HELP */
\r
4461 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
\r
4462 if (check_file(tmp))
\r
4464 sprintf(buf, "winhelp.exe %s", tmp);
\r
4465 WinExec(buf, SW_NORMAL);
\r
4469 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
\r
4470 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
\r
4474 #endif /* HTML_HELP */
\r
4480 static bool process_keydown(WPARAM wParam, LPARAM lParam)
\r
4487 /* Extract the modifiers */
\r
4488 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
\r
4489 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
\r
4490 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
\r
4492 Term_no_press = (ma) ? TRUE : FALSE;
\r
4494 /* Handle "special" keys */
\r
4495 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
\r
4497 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
\r
4498 bool numpad = FALSE;
\r
4500 /* Begin the macro trigger */
\r
4501 Term_keypress(31);
\r
4503 /* Send the modifiers */
\r
4504 if (mc) Term_keypress('C');
\r
4505 if (ms) Term_keypress('S');
\r
4506 if (ma) Term_keypress('A');
\r
4508 /* Extract "scan code" */
\r
4509 i = LOBYTE(HIWORD(lParam));
\r
4511 /* Introduce the scan code */
\r
4512 Term_keypress('x');
\r
4514 /* Extended key bit */
\r
4517 /* Numpad Enter and '/' are extended key */
\r
4519 Term_no_press = TRUE;
\r
4520 case VK_RETURN: /* Enter */
\r
4523 /* Other extended keys are on full keyboard */
\r
4537 case VK_SEPARATOR:
\r
4539 Term_no_press = TRUE;
\r
4543 case VK_PRIOR: /* Page Up */
\r
4544 case VK_NEXT: /* Page Down */
\r
4551 numpad = !ext_key;
\r
4554 /* Special modifiers for keypad keys */
\r
4555 if (numpad) Term_keypress('K');
\r
4557 /* Encode the hexidecimal scan code */
\r
4558 Term_keypress(hexsym[i/16]);
\r
4559 Term_keypress(hexsym[i%16]);
\r
4561 /* End the macro trigger */
\r
4562 Term_keypress(13);
\r
4572 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4573 WPARAM wParam, LPARAM lParam);
\r
4574 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4575 WPARAM wParam, LPARAM lParam)
\r
4576 #else /* __MWERKS__ */
\r
4577 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
4578 #endif /* __MWERKS__ */
\r
4584 MINMAXINFO FAR *lpmmi;
\r
4590 /* Acquire proper "term_data" info */
\r
4591 td = (term_data *)GetWindowLong(hWnd, 0);
\r
4593 /* Handle message */
\r
4598 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
4605 mop.dwCallback=(DWORD)hWnd;
\r
4610 case WM_GETMINMAXINFO:
\r
4612 MINMAXINFO FAR *lpmmi;
\r
4615 lpmmi = (MINMAXINFO FAR *)lParam;
\r
4617 /* this message was sent before WM_NCCREATE */
\r
4618 if (!td) return 1;
\r
4620 /* Minimum window size is 80x24 */
\r
4621 rc.left = rc.top = 0;
\r
4622 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
4623 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
4626 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
4628 /* Save minimum size */
\r
4629 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
4630 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
4637 BeginPaint(hWnd, &ps);
\r
4638 if (td) term_data_redraw(td);
\r
4639 EndPaint(hWnd, &ps);
\r
4640 ValidateRect(hWnd, NULL);
\r
4645 case MM_MCINOTIFY:
\r
4647 if(wParam == MCI_NOTIFY_SUCCESSFUL)
\r
4649 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
4650 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
4656 case WM_SYSKEYDOWN:
\r
4659 if (process_keydown(wParam, lParam))
\r
4666 if (Term_no_press) Term_no_press = FALSE;
\r
4667 else Term_keypress(wParam);
\r
4671 case WM_LBUTTONDOWN:
\r
4673 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4674 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4675 mouse_down = TRUE;
\r
4681 case WM_LBUTTONUP:
\r
4686 TERM_LEN dx = abs(oldx - mousex) + 1;
\r
4687 TERM_LEN dy = abs(oldy - mousey) + 1;
\r
4688 TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
\r
4689 TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
\r
4691 mouse_down = FALSE;
\r
4692 paint_rect = FALSE;
\r
4695 sz = (dx + 3) * dy;
\r
4697 sz = (dx + 2) * dy;
\r
4699 hGlobal = GlobalAlloc(GHND, sz + 1);
\r
4700 if (hGlobal == NULL) return 0;
\r
4701 lpStr = (LPSTR)GlobalLock(hGlobal);
\r
4703 for (i = 0; i < dy; i++)
\r
4707 char **scr = data[0].t.scr->c;
\r
4709 C_MAKE(s, (dx + 1), char);
\r
4710 strncpy(s, &scr[oy + i][ox], dx);
\r
4714 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
\r
4717 if (ox + dx < data[0].cols)
\r
4719 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
\r
4722 for (j = 0; j < dx; j++)
\r
4724 if (s[j] == 127) s[j] = '#';
\r
4728 for (j = 0; j < dx; j++)
\r
4730 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
\r
4740 GlobalUnlock(hGlobal);
\r
4741 if (OpenClipboard(hWnd) == 0)
\r
4743 GlobalFree(hGlobal);
\r
4747 SetClipboardData(CF_TEXT, hGlobal);
\r
4755 case WM_MOUSEMOVE:
\r
4760 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4761 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4766 dx = abs(oldx - mousex) + 1;
\r
4767 dy = abs(oldy - mousey) + 1;
\r
4768 ox = (oldx > mousex) ? mousex : oldx;
\r
4769 oy = (oldy > mousey) ? mousey : oldy;
\r
4770 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4774 paint_rect = TRUE;
\r
4777 dx = abs(cx - mousex) + 1;
\r
4778 dy = abs(cy - mousey) + 1;
\r
4779 ox = (cx > mousex) ? mousex : cx;
\r
4780 oy = (cy > mousey) ? mousey : cy;
\r
4781 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4797 if (game_in_progress && character_generated)
\r
4801 plog(_("今は終了できません。", "You may not do that right now."));
\r
4805 /* Hack -- Forget messages */
\r
4812 /* Save the game */
\r
4814 /* do_cmd_save_game(FALSE); */
\r
4815 #else /* ZANGBAND */
\r
4816 /* do_cmd_save_game(); */
\r
4817 #endif /* ZANGBAND */
\r
4818 Term_key_push(SPECIAL_KEY_QUIT);
\r
4825 case WM_QUERYENDSESSION:
\r
4827 if (game_in_progress && character_generated)
\r
4829 /* Hack -- Forget messages */
\r
4832 /* Mega-Hack -- Delay death */
\r
4833 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
\r
4834 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
\r
4836 /* Hardcode panic save */
\r
4837 p_ptr->panic_save = 1;
\r
4839 /* Forbid suspend */
\r
4840 signals_ignore_tstp();
\r
4842 /* Indicate panic save */
\r
4843 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
\r
4846 (void)save_player();
\r
4860 process_menus(LOWORD(wParam));
\r
4866 /* this message was sent before WM_NCCREATE */
\r
4867 if (!td) return 1;
\r
4869 /* it was sent from inside CreateWindowEx */
\r
4870 if (!td->w) return 1;
\r
4872 /* was sent from WM_SIZE */
\r
4873 if (td->size_hack) return 1;
\r
4877 case SIZE_MINIMIZED:
\r
4879 /* Hide sub-windows */
\r
4880 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4882 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
\r
4887 case SIZE_MAXIMIZED:
\r
4889 /* fall through */
\r
4892 case SIZE_RESTORED:
\r
4894 TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
4895 TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
4898 if ((td->cols != cols) || (td->rows != rows))
\r
4900 /* Save the new size */
\r
4904 if (!IsZoomed(td->w) && !IsIconic(td->w))
\r
4906 normsize.x = td->cols;
\r
4907 normsize.y = td->rows;
\r
4911 Term_activate(&td->t);
\r
4913 /* Resize the term */
\r
4914 Term_resize(td->cols, td->rows);
\r
4916 /* Redraw later */
\r
4917 InvalidateRect(td->w, NULL, TRUE);
\r
4920 td->size_hack = TRUE;
\r
4922 /* Show sub-windows */
\r
4923 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4925 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
\r
4928 td->size_hack = FALSE;
\r
4936 case WM_PALETTECHANGED:
\r
4938 /* Ignore if palette change caused by itself */
\r
4939 if ((HWND)wParam == hWnd) return 0;
\r
4941 /* Fall through... */
\r
4944 case WM_QUERYNEWPALETTE:
\r
4946 if (!paletted) return 0;
\r
4948 hdc = GetDC(hWnd);
\r
4950 SelectPalette(hdc, hPal, FALSE);
\r
4952 i = RealizePalette(hdc);
\r
4954 /* if any palette entries changed, repaint the window. */
\r
4955 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
4957 ReleaseDC(hWnd, hdc);
\r
4964 if (wParam && !HIWORD(lParam))
\r
4966 /* Do something to sub-windows */
\r
4967 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4969 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
\r
4972 /* Focus on main window */
\r
4981 case WM_ACTIVATEAPP:
\r
4983 if (IsIconic(td->w)) break;
\r
4985 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4987 if(data[i].visible)
\r
4989 if (wParam == TRUE)
\r
4991 ShowWindow(data[i].w, SW_SHOW);
\r
4995 ShowWindow(data[i].w, SW_HIDE);
\r
5002 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5007 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5008 WPARAM wParam, LPARAM lParam);
\r
5009 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5010 WPARAM wParam, LPARAM lParam)
\r
5011 #else /* __MWERKS__ */
\r
5012 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5013 WPARAM wParam, LPARAM lParam)
\r
5014 #endif /* __MWERKS__ */
\r
5018 MINMAXINFO FAR *lpmmi;
\r
5026 /* Acquire proper "term_data" info */
\r
5027 td = (term_data *)GetWindowLong(hWnd, 0);
\r
5029 /* Process message */
\r
5034 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
5043 case WM_GETMINMAXINFO:
\r
5045 MINMAXINFO FAR *lpmmi;
\r
5048 lpmmi = (MINMAXINFO FAR *)lParam;
\r
5050 /* this message was sent before WM_NCCREATE */
\r
5051 if (!td) return 1;
\r
5053 /* Minimum window size is 80x24 */
\r
5054 rc.left = rc.top = 0;
\r
5055 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
5056 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
5059 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
5061 /* Save minimum size */
\r
5062 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
5063 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
5073 /* this message was sent before WM_NCCREATE */
\r
5074 if (!td) return 1;
\r
5076 /* it was sent from inside CreateWindowEx */
\r
5077 if (!td->w) return 1;
\r
5079 /* was sent from inside WM_SIZE */
\r
5080 if (td->size_hack) return 1;
\r
5082 td->size_hack = TRUE;
\r
5084 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
5085 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
5088 if ((td->cols != cols) || (td->rows != rows))
\r
5090 /* Save old term */
\r
5091 term *old_term = Term;
\r
5093 /* Save the new size */
\r
5098 Term_activate(&td->t);
\r
5100 /* Resize the term */
\r
5101 Term_resize(td->cols, td->rows);
\r
5104 Term_activate(old_term);
\r
5106 /* Redraw later */
\r
5107 InvalidateRect(td->w, NULL, TRUE);
\r
5109 /* HACK - Redraw all windows */
\r
5110 p_ptr->window = 0xFFFFFFFF;
\r
5114 td->size_hack = FALSE;
\r
5121 BeginPaint(hWnd, &ps);
\r
5122 if (td) term_data_redraw(td);
\r
5123 EndPaint(hWnd, &ps);
\r
5127 case WM_SYSKEYDOWN:
\r
5130 if (process_keydown(wParam, lParam))
\r
5137 if (Term_no_press) Term_no_press = FALSE;
\r
5138 else Term_keypress(wParam);
\r
5142 case WM_PALETTECHANGED:
\r
5144 /* ignore if palette change caused by itself */
\r
5145 if ((HWND)wParam == hWnd) return FALSE;
\r
5146 /* otherwise, fall through!!! */
\r
5149 case WM_QUERYNEWPALETTE:
\r
5151 if (!paletted) return 0;
\r
5152 hdc = GetDC(hWnd);
\r
5153 SelectPalette(hdc, hPal, FALSE);
\r
5154 i = RealizePalette(hdc);
\r
5155 /* if any palette entries changed, repaint the window. */
\r
5156 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5157 ReleaseDC(hWnd, hdc);
\r
5161 case WM_NCLBUTTONDOWN:
\r
5165 if (wParam == HTCLOSE) wParam = HTSYSMENU;
\r
5166 #endif /* HTCLOSE */
\r
5168 if (wParam == HTSYSMENU)
\r
5172 td->visible = FALSE;
\r
5173 ShowWindow(td->w, SW_HIDE);
\r
5183 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5189 #define MOUSE_SENS 40
\r
5192 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5193 WPARAM wParam, LPARAM lParam);
\r
5194 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5195 WPARAM wParam, LPARAM lParam)
\r
5196 #else /* __MWERKS__ */
\r
5197 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5198 WPARAM wParam, LPARAM lParam)
\r
5199 #endif /* __MWERKS__ */
\r
5201 static int iMouse = 0;
\r
5202 static WORD xMouse = 0;
\r
5203 static WORD yMouse = 0;
\r
5216 case WM_SETCURSOR:
\r
5225 if (LOWORD(wParam) == WA_INACTIVE) break;
\r
5227 /* else fall through */
\r
5231 case WM_LBUTTONDOWN:
\r
5232 case WM_MBUTTONDOWN:
\r
5233 case WM_RBUTTONDOWN:
\r
5236 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5240 case WM_MOUSEMOVE:
\r
5244 dx = LOWORD(lParam) - xMouse;
\r
5245 dy = HIWORD(lParam) - yMouse;
\r
5247 if (dx < 0) dx = -dx;
\r
5248 if (dy < 0) dy = -dy;
\r
5250 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
\r
5252 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5256 /* Save last location */
\r
5258 xMouse = LOWORD(lParam);
\r
5259 yMouse = HIWORD(lParam);
\r
5266 DestroyWindow(hwndSaver);
\r
5272 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5275 #endif /* USE_SAVER */
\r
5281 /*** Temporary Hooks ***/
\r
5285 * Display warning message (see "z-util.c")
\r
5287 static void hack_plog(cptr str)
\r
5289 /* Give a warning */
\r
5293 MessageBox(NULL, str, "警告!",
\r
5294 MB_ICONEXCLAMATION | MB_OK);
\r
5296 MessageBox(NULL, str, "Warning",
\r
5297 MB_ICONEXCLAMATION | MB_OK);
\r
5305 * Display error message and quit (see "z-util.c")
\r
5307 static void hack_quit(cptr str)
\r
5309 /* Give a warning */
\r
5313 MessageBox(NULL, str, "エラー!",
\r
5314 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5316 MessageBox(NULL, str, "Error",
\r
5317 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5322 /* Unregister the classes */
\r
5323 UnregisterClass(AppName, hInstance);
\r
5325 /* Destroy the icon */
\r
5326 if (hIcon) DestroyIcon(hIcon);
\r
5334 /*** Various hooks ***/
\r
5338 * Display warning message (see "z-util.c")
\r
5340 static void hook_plog(cptr str)
\r
5346 MessageBox(data[0].w, str, "警告!",
\r
5347 MB_ICONEXCLAMATION | MB_OK);
\r
5349 MessageBox(data[0].w, str, "Warning",
\r
5350 MB_ICONEXCLAMATION | MB_OK);
\r
5358 * Display error message and quit (see "z-util.c")
\r
5360 static void hook_quit(cptr str)
\r
5365 /* Give a warning */
\r
5369 MessageBox(data[0].w, str, "エラー!",
\r
5370 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5372 MessageBox(data[0].w, str, "Error",
\r
5373 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5379 /* Save the preferences */
\r
5383 /*** Could use 'Term_nuke_win()' */
\r
5385 /* Destroy all windows */
\r
5386 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
\r
5388 term_force_font(&data[i], NULL);
\r
5389 if (data[i].font_want) string_free(data[i].font_want);
\r
5390 if (data[i].w) DestroyWindow(data[i].w);
\r
5394 /* Free the bitmap stuff */
\r
5395 #ifdef USE_GRAPHICS
\r
5396 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
\r
5397 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
\r
5399 if (infMask.hPalette) DeleteObject(infMask.hPalette);
\r
5400 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
\r
5402 #endif /* USE_GRAPHICS */
\r
5404 /*** Free some other stuff ***/
\r
5406 DeleteObject(hbrYellow);
\r
5411 if (hPal) DeleteObject(hPal);
\r
5413 UnregisterClass(AppName, hInstance);
\r
5415 if (hIcon) DestroyIcon(hIcon);
\r
5422 /*** Initialize ***/
\r
5428 static void init_stuff(void)
\r
5435 /* Get program name with full path */
\r
5436 GetModuleFileName(hInstance, path, 512);
\r
5438 /* Save the "program name" */
\r
5441 /* Get the name of the "*.ini" file */
\r
5442 strcpy(path + strlen(path) - 4, ".INI");
\r
5444 /* Save the the name of the ini-file */
\r
5445 ini_file = string_make(path);
\r
5447 /* Analyze the path */
\r
5450 /* Get the path */
\r
5451 for (; i > 0; i--)
\r
5453 if (path[i] == '\\')
\r
5460 /* Add "lib" to the path */
\r
5461 strcpy(path + i + 1, "lib\\");
\r
5463 /* Validate the path */
\r
5464 validate_dir(path, TRUE);
\r
5466 /* Init the file paths */
\r
5467 init_file_paths(path);
\r
5469 /* Hack -- Validate the paths */
\r
5470 validate_dir(ANGBAND_DIR_APEX, FALSE);
\r
5471 validate_dir(ANGBAND_DIR_BONE, FALSE);
\r
5473 /* Allow missing 'edit' directory */
\r
5474 if (!check_dir(ANGBAND_DIR_EDIT))
\r
5476 /* Must have 'data'! */
\r
5477 validate_dir(ANGBAND_DIR_DATA, TRUE);
\r
5481 /* Don't need 'data' */
\r
5482 validate_dir(ANGBAND_DIR_DATA, FALSE);
\r
5485 validate_dir(ANGBAND_DIR_FILE, TRUE);
\r
5486 validate_dir(ANGBAND_DIR_HELP, FALSE);
\r
5487 validate_dir(ANGBAND_DIR_INFO, FALSE);
\r
5488 validate_dir(ANGBAND_DIR_PREF, TRUE);
\r
5489 validate_dir(ANGBAND_DIR_SAVE, FALSE);
\r
5490 validate_dir(ANGBAND_DIR_USER, TRUE);
\r
5491 validate_dir(ANGBAND_DIR_XTRA, TRUE);
\r
5493 /* Build the filename */
\r
5494 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
\r
5496 /* Hack -- Validate the "news.txt" file */
\r
5497 validate_file(path);
\r
5500 #if 0 /* #ifndef JP */
\r
5501 /* Build the "font" path */
\r
5502 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
\r
5504 /* Allocate the path */
\r
5505 ANGBAND_DIR_XTRA_FONT = string_make(path);
\r
5507 /* Validate the "font" directory */
\r
5508 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
\r
5510 /* Build the filename */
\r
5511 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
5513 /* Hack -- Validate the basic font */
\r
5514 validate_file(path);
\r
5518 #ifdef USE_GRAPHICS
\r
5520 /* Build the "graf" path */
\r
5521 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
\r
5523 /* Allocate the path */
\r
5524 ANGBAND_DIR_XTRA_GRAF = string_make(path);
\r
5526 /* Validate the "graf" directory */
\r
5527 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
\r
5529 #endif /* USE_GRAPHICS */
\r
5534 /* Build the "sound" path */
\r
5535 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
\r
5537 /* Allocate the path */
\r
5538 ANGBAND_DIR_XTRA_SOUND = string_make(path);
\r
5540 /* Validate the "sound" directory */
\r
5541 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
\r
5543 #endif /* USE_SOUND */
\r
5547 /* Build the "music" path */
\r
5548 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
\r
5550 /* Allocate the path */
\r
5551 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
\r
5553 /* Validate the "music" directory */
\r
5554 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
\r
5556 #endif /* USE_MUSIC */
\r
5558 /* Build the "help" path */
\r
5559 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
\r
5561 /* Allocate the path */
\r
5562 ANGBAND_DIR_XTRA_HELP = string_make(path);
\r
5564 /* Validate the "help" directory */
\r
5565 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
\r
5569 * @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
\r
5571 static bool is_already_running(void)
\r
5573 bool result = FALSE;
\r
5576 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
\r
5577 if (GetLastError() == ERROR_ALREADY_EXISTS)
\r
5586 * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
\r
5588 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
\r
5589 LPSTR lpCmdLine, int nCmdShow)
\r
5597 setlocale(LC_ALL, "ja_JP.utf8");
\r
5602 /* Save globally */
\r
5603 hInstance = hInst;
\r
5606 /* Prevent multiple run */
\r
5607 if (is_already_running())
\r
5610 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
\r
5611 _("エラー!", "Error") ,
\r
5612 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5616 if (hPrevInst == NULL)
\r
5618 wc.style = CS_CLASSDC;
\r
5619 wc.lpfnWndProc = AngbandWndProc;
\r
5620 wc.cbClsExtra = 0;
\r
5621 wc.cbWndExtra = 4; /* one long pointer to term_data */
\r
5622 wc.hInstance = hInst;
\r
5623 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
\r
5624 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
\r
5625 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
\r
5626 wc.lpszMenuName = AppName;
\r
5627 wc.lpszClassName = AppName;
\r
5629 if (!RegisterClass(&wc)) exit(1);
\r
5631 wc.lpfnWndProc = AngbandListProc;
\r
5632 wc.lpszMenuName = NULL;
\r
5633 wc.lpszClassName = AngList;
\r
5635 if (!RegisterClass(&wc)) exit(2);
\r
5639 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
\r
5640 wc.lpfnWndProc = AngbandSaverProc;
\r
5641 wc.hCursor = NULL;
\r
5642 wc.lpszMenuName = NULL;
\r
5643 wc.lpszClassName = "WindowsScreenSaverClass";
\r
5645 if (!RegisterClass(&wc)) exit(3);
\r
5651 /* Temporary hooks */
\r
5652 plog_aux = hack_plog;
\r
5653 quit_aux = hack_quit;
\r
5654 core_aux = hack_quit;
\r
5656 /* Prepare the filepaths */
\r
5659 /* Initialize the keypress analyzer */
\r
5660 for (i = 0; special_key_list[i]; ++i)
\r
5662 special_key[special_key_list[i]] = TRUE;
\r
5664 /* Initialize the keypress analyzer */
\r
5665 for (i = 0; ignore_key_list[i]; ++i)
\r
5667 ignore_key[ignore_key_list[i]] = TRUE;
\r
5670 /* Determine if display is 16/256/true color */
\r
5671 hdc = GetDC(NULL);
\r
5672 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
\r
5673 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
\r
5674 ReleaseDC(NULL, hdc);
\r
5676 /* Initialize the colors */
\r
5677 for (i = 0; i < 256; i++)
\r
5681 /* Extract desired values */
\r
5682 rv = angband_color_table[i][1];
\r
5683 gv = angband_color_table[i][2];
\r
5684 bv = angband_color_table[i][3];
\r
5686 /* Extract the "complex" code */
\r
5687 win_clr[i] = PALETTERGB(rv, gv, bv);
\r
5689 /* Save the "simple" code */
\r
5690 angband_color_table[i][0] = win_pal[i];
\r
5693 /* Prepare the windows */
\r
5699 /* Activate hooks */
\r
5700 plog_aux = hook_plog;
\r
5701 quit_aux = hook_quit;
\r
5702 core_aux = hook_quit;
\r
5704 /* Set the system suffix */
\r
5705 ANGBAND_SYS = "win";
\r
5707 /* Set the keyboard suffix */
\r
5708 if (7 != GetKeyboardType(0))
\r
5709 ANGBAND_KEYBOARD = "0";
\r
5712 /* Japanese keyboard */
\r
5713 switch (GetKeyboardType(1))
\r
5715 case 0x0D01: case 0x0D02:
\r
5716 case 0x0D03: case 0x0D04:
\r
5717 case 0x0D05: case 0x0D06:
\r
5719 ANGBAND_KEYBOARD = "NEC98";
\r
5723 ANGBAND_KEYBOARD = "JAPAN";
\r
5727 /* Catch nasty signals */
\r
5730 Term_activate(term_screen);
\r
5733 /* We are now initialized */
\r
5734 initialized = TRUE;
\r
5736 if(lpCmdLine[0] == '-'){
\r
5737 switch(lpCmdLine[1])
\r
5742 if (!lpCmdLine[2]) break;
\r
5743 chuukei_server = TRUE;
\r
5744 if(connect_chuukei_server(&lpCmdLine[2])<0){
\r
5745 msg_print("connect fail");
\r
5748 msg_print("connect");
\r
5756 if (!lpCmdLine[2]) break;
\r
5757 chuukei_client = TRUE;
\r
5758 connect_chuukei_server(&lpCmdLine[2]);
\r
5766 if (!lpCmdLine[2]) break;
\r
5767 prepare_browse_movie(&lpCmdLine[2]);
\r
5777 /* Did the user double click on a save file? */
\r
5778 if(!chuukei_server) check_for_save_file(lpCmdLine);
\r
5780 /* Did the user double click on a save file? */
\r
5781 check_for_save_file(lpCmdLine);
\r
5784 /* Prompt the user */
\r
5785 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
\r
5789 /* Process messages forever */
\r
5790 while (GetMessage(&msg, NULL, 0, 0))
\r
5792 TranslateMessage(&msg);
\r
5793 DispatchMessage(&msg);
\r
5804 #endif /* WINDOWS */
\r