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
785 HDC wnddc, dcimage, dcbg;
\r
786 HBITMAP bmimage, bmimage_old, bmbg_old;
\r
791 wnddc = GetDC(hwnd);
\r
792 dcimage = CreateCompatibleDC(wnddc);
\r
793 dcbg = CreateCompatibleDC(wnddc);
\r
795 bmimage = LoadImage(NULL, "bg.bmp", LR_LOADFROMFILE, 0, 0, 0);
\r
796 if (!bmimage) quit("bg.bmpが読みこめない!");
\r
797 bmimage_old = SelectObject(dcimage, bmimage);
\r
799 CreateCompatibleBitmap();
\r
801 ReleaseDC(hwnd, wnddc);
\r
807 static void DrawBG(HDC hdc, RECT *r)
\r
812 int x = r->left, y = r->top;
\r
813 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
\r
815 if (!use_bg || !hBG)
\r
819 GetObject(hBG, sizeof(bm), &bm);
\r
820 swid = bm.bmWidth; shgt = bm.bmHeight;
\r
822 hdcSrc = CreateCompatibleDC(hdc);
\r
823 hOld = SelectObject(hdcSrc, hBG);
\r
827 cwid = MIN(swid - sx, r->right - nx);
\r
830 chgt = MIN(shgt - sy, r->bottom - ny);
\r
831 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
\r
833 } while (ny < r->bottom);
\r
836 } while (nx < r->right);
\r
838 SelectObject(hdcSrc, hOld);
\r
844 * Hack -- given a pathname, point at the filename
\r
846 static cptr extract_file_name(cptr s)
\r
850 /* Start at the end */
\r
851 p = s + strlen(s) - 1;
\r
853 /* Back up to divider */
\r
854 while ((p >= s) && (*p != ':') && (*p != '\\')) p--;
\r
856 /* Return file name */
\r
863 * Hack -- given a simple filename, extract the "font size" info
\r
865 * Return a pointer to a static buffer holding the capitalized base name.
\r
867 #if 0 /* #ifndef JP */
\r
868 static char *analyze_font(char *path, int *wp, int *hp)
\r
874 /* Start at the end */
\r
875 p = path + strlen(path) - 1;
\r
877 /* Back up to divider */
\r
878 while ((p >= path) && (*p != ':') && (*p != '\\')) --p;
\r
880 /* Advance to file name */
\r
884 for (s = p; *s; ++s)
\r
886 /* Capitalize (be paranoid) */
\r
887 if (islower(*s)) *s = toupper(*s);
\r
890 /* Find first 'X' */
\r
891 s = my_strchr(p, 'X');
\r
893 /* Extract font width */
\r
896 /* Extract height */
\r
897 hgt = s ? atoi(s+1) : 0;
\r
910 * Check for existance of a file
\r
912 static bool check_file(cptr s)
\r
922 unsigned int attrib;
\r
932 attrib = GetFileAttributes(path);
\r
934 /* Require valid filename */
\r
935 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
937 /* Prohibit directory */
\r
938 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return (FALSE);
\r
942 /* Examine and verify */
\r
943 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
945 /* Prohibit something */
\r
946 if (attrib & FA_LABEL) return (FALSE);
\r
948 /* Prohibit directory */
\r
949 if (attrib & FA_DIREC) return (FALSE);
\r
959 * Check for existance of a directory
\r
961 static bool check_dir(cptr s)
\r
973 unsigned int attrib;
\r
983 /* Remove trailing backslash */
\r
984 if (i && (path[i-1] == '\\')) path[--i] = '\0';
\r
989 attrib = GetFileAttributes(path);
\r
991 /* Require valid filename */
\r
992 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
994 /* Require directory */
\r
995 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE);
\r
999 /* Examine and verify */
\r
1000 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
1002 /* Prohibit something */
\r
1003 if (attrib & FA_LABEL) return (FALSE);
\r
1005 /* Require directory */
\r
1006 if (!(attrib & FA_DIREC)) return (FALSE);
\r
1008 #endif /* WIN32 */
\r
1018 static void validate_file(cptr s)
\r
1020 /* Verify or fail */
\r
1021 if (!check_file(s))
\r
1023 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
\r
1029 * Validate a directory
\r
1031 static void validate_dir(cptr s, bool vital)
\r
1033 /* Verify or fail */
\r
1034 if (!check_dir(s))
\r
1036 /* This directory contains needed data */
\r
1039 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
\r
1041 /* Attempt to create this directory */
\r
1042 else if (mkdir(s))
\r
1044 quit_fmt("Unable to create directory:\n%s", s);
\r
1051 * @brief (Windows版固有実装)Get the "size" for a window
\r
1053 static void term_getsize(term_data *td)
\r
1056 TERM_LEN wid, hgt;
\r
1059 if (td->cols < 1) td->cols = 1;
\r
1060 if (td->rows < 1) td->rows = 1;
\r
1062 /* Window sizes */
\r
1063 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
1064 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
\r
1066 /* Fake window size */
\r
1068 rc.right = rc.left + wid;
\r
1070 rc.bottom = rc.top + hgt;
\r
1072 /* rc.right += 1; */
\r
1073 /* rc.bottom += 1; */
\r
1076 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
1079 td->size_wid = rc.right - rc.left;
\r
1080 td->size_hgt = rc.bottom - rc.top;
\r
1082 /* See CreateWindowEx */
\r
1083 if (!td->w) return;
\r
1085 /* Extract actual location */
\r
1086 GetWindowRect(td->w, &rc);
\r
1088 /* Save the location */
\r
1089 td->pos_x = rc.left;
\r
1090 td->pos_y = rc.top;
\r
1095 * Write the "prefs" for a single term
\r
1097 static void save_prefs_aux(int i)
\r
1099 term_data *td = &data[i];
\r
1100 char sec_name[128];
\r
1104 WINDOWPLACEMENT lpwndpl;
\r
1107 if (!td->w) return;
\r
1109 /* Make section name */
\r
1110 sprintf(sec_name, "Term-%d", i);
\r
1115 strcpy(buf, td->visible ? "1" : "0");
\r
1116 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
\r
1121 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "MS ゴシック");
\r
1124 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
\r
1126 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
\r
1130 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
\r
1132 #if 1 /* #ifdef JP */
\r
1133 wsprintf(buf, "%d", td->lf.lfWidth);
\r
1134 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
\r
1135 wsprintf(buf, "%d", td->lf.lfHeight);
\r
1136 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
\r
1137 wsprintf(buf, "%d", td->lf.lfWeight);
\r
1138 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
\r
1141 strcpy(buf, td->bizarre ? "1" : "0");
\r
1142 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
\r
1144 /* Tile size (x) */
\r
1145 wsprintf(buf, "%d", td->tile_wid);
\r
1146 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
\r
1148 /* Tile size (y) */
\r
1149 wsprintf(buf, "%d", td->tile_hgt);
\r
1150 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
\r
1152 /* Get window placement and dimensions */
\r
1153 lpwndpl.length = sizeof(WINDOWPLACEMENT);
\r
1154 GetWindowPlacement(td->w, &lpwndpl);
\r
1156 /* Acquire position in *normal* mode (not minimized) */
\r
1157 rc = lpwndpl.rcNormalPosition;
\r
1159 /* Window size (x) */
\r
1160 if (i == 0) wsprintf(buf, "%d", normsize.x);
\r
1161 else wsprintf(buf, "%d", td->cols);
\r
1162 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
\r
1164 /* Window size (y) */
\r
1165 if (i == 0) wsprintf(buf, "%d", normsize.y);
\r
1166 else wsprintf(buf, "%d", td->rows);
\r
1167 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
\r
1169 /* Maxmized (only main window) */
\r
1172 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
\r
1173 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
\r
1176 /* Acquire position */
\r
1177 GetWindowRect(td->w, &rc);
\r
1179 /* Window position (x) */
\r
1180 wsprintf(buf, "%d", rc.left);
\r
1181 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
\r
1183 /* Window position (y) */
\r
1184 wsprintf(buf, "%d", rc.top);
\r
1185 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
\r
1187 /* Window Z position */
\r
1190 strcpy(buf, td->posfix ? "1" : "0");
\r
1191 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
\r
1197 * Write the "prefs"
\r
1198 * We assume that the windows have all been initialized
\r
1200 static void save_prefs(void)
\r
1206 /* Save the "arg_graphics" flag */
\r
1207 sprintf(buf, "%d", arg_graphics);
\r
1208 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
\r
1210 /* Save the "arg_bigtile" flag */
\r
1211 strcpy(buf, arg_bigtile ? "1" : "0");
\r
1212 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
\r
1214 /* Save the "arg_sound" flag */
\r
1215 strcpy(buf, arg_sound ? "1" : "0");
\r
1216 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
\r
1218 /* Save the "arg_sound" flag */
\r
1219 strcpy(buf, arg_music ? "1" : "0");
\r
1220 WritePrivateProfileString("Angband", "Music", buf, ini_file);
\r
1223 strcpy(buf, use_bg ? "1" : "0");
\r
1224 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
\r
1225 WritePrivateProfileString("Angband", "BackGroundBitmap",
\r
1226 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
\r
1228 /* Save window prefs */
\r
1229 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1231 save_prefs_aux(i);
\r
1237 * Load the "prefs" for a single term
\r
1239 static void load_prefs_aux(int i)
\r
1241 term_data *td = &data[i];
\r
1242 char sec_name[128];
\r
1245 int wid, hgt, posx, posy;
\r
1246 int dispx = GetSystemMetrics( SM_CXVIRTUALSCREEN);
\r
1247 int dispy = GetSystemMetrics( SM_CYVIRTUALSCREEN);
\r
1251 /* Make section name */
\r
1252 sprintf(sec_name, "Term-%d", i);
\r
1254 /* Make section name */
\r
1255 sprintf(sec_name, "Term-%d", i);
\r
1260 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
\r
1263 /* Desired font, with default */
\r
1265 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
\r
1268 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
\r
1270 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
\r
1276 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
\r
1278 /* Analyze font, save desired font name */
\r
1279 #if 1 /* #ifdef JP */
\r
1280 td->font_want = string_make(tmp);
\r
1281 hgt = 15; wid = 0;
\r
1282 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
\r
1283 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
\r
1284 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
\r
1286 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
\r
1291 #if 1 /* #ifdef JP */
\r
1292 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
\r
1293 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
\r
1295 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
\r
1296 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
\r
1301 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
\r
1302 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
\r
1303 normsize.x = td->cols; normsize.y = td->rows;
\r
1308 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
\r
1311 /* Window position */
\r
1312 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
\r
1313 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
\r
1314 td->pos_x = MIN(MAX(0, posx), dispx-128);
\r
1315 td->pos_y = MIN(MAX(0, posy), dispy-128);
\r
1317 /* Window Z position */
\r
1320 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
\r
1326 * Load the "prefs"
\r
1328 static void load_prefs(void)
\r
1332 /* Extract the "arg_graphics" flag */
\r
1333 arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
\r
1335 /* Extract the "arg_bigtile" flag */
\r
1336 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
\r
1337 use_bigtile = arg_bigtile;
\r
1339 /* Extract the "arg_sound" flag */
\r
1340 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
\r
1342 /* Extract the "arg_sound" flag */
\r
1343 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
\r
1346 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
\r
1347 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
\r
1349 /* Load window prefs */
\r
1350 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1352 load_prefs_aux(i);
\r
1356 #if defined(USE_SOUND) || defined(USE_MUSIC)
\r
1359 * - Taken from files.c.
\r
1361 * Extract "tokens" from a buffer
\r
1363 * This function uses "whitespace" as delimiters, and treats any amount of
\r
1364 * whitespace as a single delimiter. We will never return any empty tokens.
\r
1365 * When given an empty buffer, or a buffer containing only "whitespace", we
\r
1366 * will return no tokens. We will never extract more than "num" tokens.
\r
1368 * By running a token through the "text_to_ascii()" function, you can allow
\r
1369 * that token to include (encoded) whitespace, using "\s" to encode spaces.
\r
1371 * We save pointers to the tokens in "tokens", and return the number found.
\r
1373 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
\r
1383 /* Skip leading whitespace */
\r
1384 for ( ; *s && iswspace(*s); ++s) /* loop */;
\r
1389 /* Find next whitespace, if any */
\r
1390 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
\r
1392 /* Nuke and advance (if necessary) */
\r
1393 if (*t) *t++ = '\0';
\r
1395 /* Save the token */
\r
1406 #endif /* USE_SOUND || USE_MUSIC */
\r
1410 static void load_sound_prefs(void)
\r
1414 char ini_path[1024];
\r
1415 char wav_path[1024];
\r
1416 char *zz[SAMPLE_MAX];
\r
1418 /* Access the sound.cfg */
\r
1420 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
\r
1422 for (i = 0; i < SOUND_MAX; i++)
\r
1424 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
\r
1426 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
\r
1428 for (j = 0; j < num; j++)
\r
1430 /* Access the sound */
\r
1431 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
\r
1433 /* Save the sound filename, if it exists */
\r
1434 if (check_file(wav_path))
\r
1435 sound_file[i][j] = string_make(zz[j]);
\r
1440 #endif /* USE_SOUND */
\r
1444 static void load_music_prefs(void)
\r
1448 char ini_path[1024];
\r
1449 char wav_path[1024];
\r
1450 char *zz[SAMPLE_MAX];
\r
1453 /* Access the music.cfg */
\r
1455 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
\r
1457 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
\r
1459 for (i = 0; i < MUSIC_BASIC_MAX; i++)
\r
1461 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
\r
1463 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1465 for (j = 0; j < num; j++)
\r
1467 /* Access the sound */
\r
1468 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1470 /* Save the sound filename, if it exists */
\r
1471 if (check_file(wav_path))
\r
1472 music_file[i][j] = string_make(zz[j]);
\r
1476 for (i = 0; i < max_d_idx; i++)
\r
1478 sprintf(key, "dungeon%03d", i);
\r
1479 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
\r
1481 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1483 for (j = 0; j < num; j++)
\r
1485 /* Access the sound */
\r
1486 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1488 /* Save the sound filename, if it exists */
\r
1489 if (check_file(wav_path))
\r
1490 dungeon_music_file[i][j] = string_make(zz[j]);
\r
1494 for (i = 0; i < max_q_idx; i++)
\r
1496 sprintf(key, "quest%03d", i);
\r
1497 GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
\r
1499 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1501 for (j = 0; j < num; j++)
\r
1503 /* Access the sound */
\r
1504 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1506 /* Save the sound filename, if it exists */
\r
1507 if (check_file(wav_path))
\r
1508 quest_music_file[i][j] = string_make(zz[j]);
\r
1512 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
\r
1514 sprintf(key, "town%03d", i);
\r
1515 GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
\r
1517 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1519 for (j = 0; j < num; j++)
\r
1521 /* Access the sound */
\r
1522 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1524 /* Save the sound filename, if it exists */
\r
1525 if (check_file(wav_path))
\r
1526 town_music_file[i][j] = string_make(zz[j]);
\r
1533 #endif /* USE_MUSIC */
\r
1536 * Create the new global palette based on the bitmap palette
\r
1537 * (if any), and the standard 16 entry palette derived from
\r
1538 * "win_clr[]" which is used for the basic 16 Angband colors.
\r
1540 * This function is never called before all windows are ready.
\r
1542 * This function returns FALSE if the new palette could not be
\r
1543 * prepared, which should normally be a fatal error. XXX XXX
\r
1545 * Note that only some machines actually use a "palette".
\r
1547 static int new_palette(void)
\r
1555 LPLOGPALETTE pLogPal;
\r
1556 LPPALETTEENTRY lppe;
\r
1561 /* This makes no sense */
\r
1562 if (!paletted) return (TRUE);
\r
1570 #ifdef USE_GRAPHICS
\r
1572 /* Check the bitmap palette */
\r
1573 hBmPal = infGraph.hPalette;
\r
1575 /* Use the bitmap */
\r
1578 lppeSize = 256 * sizeof(PALETTEENTRY);
\r
1579 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
\r
1580 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
\r
1581 if ((nEntries == 0) || (nEntries > 220))
\r
1583 /* Warn the user */
\r
1584 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
\r
1587 rnfree(lppe, lppeSize);
\r
1594 #endif /* USE_GRAPHICS */
\r
1596 /* Size of palette */
\r
1597 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
\r
1599 /* Allocate palette */
\r
1600 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
\r
1603 pLogPal->palVersion = 0x300;
\r
1605 /* Make room for bitmap and normal data */
\r
1606 pLogPal->palNumEntries = nEntries + 16;
\r
1608 /* Save the bitmap data */
\r
1609 for (i = 0; i < nEntries; i++)
\r
1611 pLogPal->palPalEntry[i] = lppe[i];
\r
1614 /* Save the normal data */
\r
1615 for (i = 0; i < 16; i++)
\r
1619 /* Access the entry */
\r
1620 p = &(pLogPal->palPalEntry[i+nEntries]);
\r
1622 /* Save the colors */
\r
1623 p->peRed = GetRValue(win_clr[i]);
\r
1624 p->peGreen = GetGValue(win_clr[i]);
\r
1625 p->peBlue = GetBValue(win_clr[i]);
\r
1627 /* Save the flags */
\r
1628 p->peFlags = PC_NOCOLLAPSE;
\r
1631 /* Free something */
\r
1632 if (lppe) rnfree(lppe, lppeSize);
\r
1634 /* Create a new palette, or fail */
\r
1635 hNewPal = CreatePalette(pLogPal);
\r
1636 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
\r
1638 /* Free the palette */
\r
1639 rnfree(pLogPal, pLogPalSize);
\r
1644 /* Realize the palette */
\r
1645 hdc = GetDC(td->w);
\r
1646 SelectPalette(hdc, hNewPal, 0);
\r
1647 i = RealizePalette(hdc);
\r
1648 ReleaseDC(td->w, hdc);
\r
1649 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
\r
1653 for (i = 1; i < MAX_TERM_DATA; i++)
\r
1657 hdc = GetDC(td->w);
\r
1658 SelectPalette(hdc, hNewPal, 0);
\r
1659 ReleaseDC(td->w, hdc);
\r
1662 /* Delete old palette */
\r
1663 if (hPal) DeleteObject(hPal);
\r
1665 /* Save new palette */
\r
1673 #ifdef USE_GRAPHICS
\r
1675 * @brief グラフィクスを初期化する / Initialize graphics
\r
1678 * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
\r
1679 * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
\r
1682 static bool init_graphics(void)
\r
1684 /* Initialize once */
\r
1686 BYTE wid, hgt, twid, thgt, ox, oy;
\r
1689 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1697 name = "16X16.BMP";
\r
1699 ANGBAND_GRAF = "new";
\r
1701 else if (arg_graphics == GRAPHICS_HENGBAND)
\r
1710 name = "64X64.BMP";
\r
1719 name = "32X32.BMP";
\r
1721 ANGBAND_GRAF = "ne2";
\r
1732 ANGBAND_GRAF = "old";
\r
1735 /* Access the bitmap file */
\r
1736 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
\r
1738 /* Load the bitmap or quit */
\r
1739 if (!ReadDIB(data[0].w, buf, &infGraph))
\r
1741 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
\r
1745 /* Save the new sizes */
\r
1746 infGraph.CellWidth = wid;
\r
1747 infGraph.CellHeight = hgt;
\r
1748 infGraph.TileWidth = twid;
\r
1749 infGraph.TileHeight = thgt;
\r
1750 infGraph.OffsetX = ox;
\r
1751 infGraph.OffsetY = oy;
\r
1753 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1755 /* Access the mask file */
\r
1756 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
\r
1758 /* Load the bitmap or quit */
\r
1759 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1761 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1765 if (arg_graphics == GRAPHICS_HENGBAND)
\r
1767 /* Access the mask file */
\r
1768 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
\r
1770 /* Load the bitmap or quit */
\r
1771 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1773 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1778 /* Activate a palette */
\r
1779 if (!new_palette())
\r
1783 plog(_("パレットを実現できません!", "Cannot activate palette!"));
\r
1787 /* Graphics available */
\r
1788 current_graphics_mode = arg_graphics;
\r
1791 return (current_graphics_mode);
\r
1793 #endif /* USE_GRAPHICS */
\r
1798 * Initialize music
\r
1800 static bool init_music(void)
\r
1802 /* Initialize once */
\r
1803 if (!can_use_music)
\r
1805 /* Load the prefs */
\r
1806 load_music_prefs();
\r
1808 /* Sound available */
\r
1809 can_use_music = TRUE;
\r
1813 return (can_use_music);
\r
1817 * Hack -- Stop a music
\r
1819 static void stop_music(void)
\r
1821 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
1822 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
1825 #endif /* USE_MUSIC */
\r
1829 * Initialize sound
\r
1831 static bool init_sound(void)
\r
1833 /* Initialize once */
\r
1834 if (!can_use_sound)
\r
1836 /* Load the prefs */
\r
1837 load_sound_prefs();
\r
1839 /* Sound available */
\r
1840 can_use_sound = TRUE;
\r
1844 return (can_use_sound);
\r
1846 #endif /* USE_SOUND */
\r
1852 static void term_window_resize(term_data *td)
\r
1854 /* Require window */
\r
1855 if (!td->w) return;
\r
1857 /* Resize the window */
\r
1858 SetWindowPos(td->w, 0, 0, 0,
\r
1859 td->size_wid, td->size_hgt,
\r
1860 SWP_NOMOVE | SWP_NOZORDER);
\r
1862 /* Redraw later */
\r
1863 InvalidateRect(td->w, NULL, TRUE);
\r
1868 * Force the use of a new "font file" for a term_data
\r
1870 * This function may be called before the "window" is ready
\r
1872 * This function returns zero only if everything succeeds.
\r
1874 * Note that the "font name" must be capitalized!!!
\r
1876 static errr term_force_font(term_data *td, cptr path)
\r
1880 #if 0 /* #ifndef JP */
\r
1886 /* Forget the old font (if needed) */
\r
1887 if (td->font_id) DeleteObject(td->font_id);
\r
1889 #if 1 /* #ifdef JP */
\r
1893 /* Create the font (using the 'base' of the font file name!) */
\r
1894 td->font_id = CreateFontIndirect(&(td->lf));
\r
1895 wid = td->lf.lfWidth;
\r
1896 hgt = td->lf.lfHeight;
\r
1897 if (!td->font_id) return (1);
\r
1899 /* Forget old font */
\r
1900 if (td->font_file)
\r
1902 bool used = FALSE;
\r
1904 /* Scan windows */
\r
1905 for (i = 0; i < MAX_TERM_DATA; i++)
\r
1907 /* Don't check when closing the application */
\r
1910 /* Check "screen" */
\r
1911 if ((td != &data[i]) &&
\r
1912 (data[i].font_file) &&
\r
1913 (streq(data[i].font_file, td->font_file)))
\r
1919 /* Remove unused font resources */
\r
1920 if (!used) RemoveFontResource(td->font_file);
\r
1922 /* Free the old name */
\r
1923 string_free(td->font_file);
\r
1926 td->font_file = NULL;
\r
1929 /* No path given */
\r
1930 if (!path) return (1);
\r
1933 strcpy(buf, path);
\r
1935 /* Analyze font path */
\r
1936 base = analyze_font(buf, &wid, &hgt);
\r
1938 /* Verify suffix */
\r
1939 if (!suffix(base, ".FON")) return (1);
\r
1942 if (!check_file(buf)) return (1);
\r
1944 /* Load the new font */
\r
1945 if (!AddFontResource(buf)) return (1);
\r
1947 /* Save new font name */
\r
1948 td->font_file = string_make(base);
\r
1950 /* Remove the "suffix" */
\r
1951 base[strlen(base)-4] = '\0';
\r
1953 /* Create the font (using the 'base' of the font file name!) */
\r
1954 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
\r
1955 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
\r
1956 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
\r
1957 FIXED_PITCH | FF_DONTCARE, base);
\r
1960 /* Hack -- Unknown size */
\r
1967 /* all this trouble to get the cell size */
\r
1968 hdcDesktop = GetDC(HWND_DESKTOP);
\r
1969 hfOld = SelectObject(hdcDesktop, td->font_id);
\r
1970 GetTextMetrics(hdcDesktop, &tm);
\r
1971 SelectObject(hdcDesktop, hfOld);
\r
1972 ReleaseDC(HWND_DESKTOP, hdcDesktop);
\r
1974 /* Font size info */
\r
1975 wid = tm.tmAveCharWidth;
\r
1976 hgt = tm.tmHeight;
\r
1979 /* Save the size info */
\r
1980 td->font_wid = wid;
\r
1981 td->font_hgt = hgt;
\r
1990 * Allow the user to change the font for this window.
\r
1992 static void term_change_font(term_data *td)
\r
1994 #if 1 /* #ifdef JP */
\r
1997 memset(&cf, 0, sizeof(cf));
\r
1998 cf.lStructSize = sizeof(cf);
\r
1999 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
\r
2000 cf.lpLogFont = &(td->lf);
\r
2002 if (ChooseFont(&cf))
\r
2004 /* Force the font */
\r
2005 term_force_font(td, NULL);
\r
2007 /* Assume not bizarre */
\r
2008 td->bizarre = TRUE;
\r
2010 /* Reset the tile info */
\r
2011 td->tile_wid = td->font_wid;
\r
2012 td->tile_hgt = td->font_hgt;
\r
2014 /* Analyze the font */
\r
2017 /* Resize the window */
\r
2018 term_window_resize(td);
\r
2024 char tmp[1024] = "";
\r
2026 /* Extract a default if possible */
\r
2027 if (td->font_file) strcpy(tmp, td->font_file);
\r
2029 /* Ask for a choice */
\r
2030 memset(&ofn, 0, sizeof(ofn));
\r
2031 ofn.lStructSize = sizeof(ofn);
\r
2032 ofn.hwndOwner = data[0].w;
\r
2033 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
\r
2034 ofn.nFilterIndex = 1;
\r
2035 ofn.lpstrFile = tmp;
\r
2036 ofn.nMaxFile = 128;
\r
2037 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
\r
2038 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
2039 ofn.lpstrDefExt = "fon";
\r
2041 /* Force choice if legal */
\r
2042 if (GetOpenFileName(&ofn))
\r
2044 /* Force the font */
\r
2045 if (term_force_font(td, tmp))
\r
2047 /* Access the standard font file */
\r
2048 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
2050 /* Force the use of that font */
\r
2051 (void)term_force_font(td, tmp);
\r
2054 /* Assume not bizarre */
\r
2055 td->bizarre = FALSE;
\r
2057 /* Reset the tile info */
\r
2058 td->tile_wid = td->font_wid;
\r
2059 td->tile_hgt = td->font_hgt;
\r
2061 /* Analyze the font */
\r
2064 /* Resize the window */
\r
2065 term_window_resize(td);
\r
2072 * Allow the user to lock this window.
\r
2074 static void term_window_pos(term_data *td, HWND hWnd)
\r
2076 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
\r
2077 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
\r
2080 static void windows_map(void);
\r
2083 * Hack -- redraw a term_data
\r
2085 static void term_data_redraw(term_data *td)
\r
2087 if (td->map_active)
\r
2089 /* Redraw the map */
\r
2094 /* Activate the term */
\r
2095 Term_activate(&td->t);
\r
2097 /* Redraw the contents */
\r
2100 /* Restore the term */
\r
2101 Term_activate(term_screen);
\r
2106 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
\r
2110 HBRUSH myBrush, oldBrush;
\r
2112 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
\r
2113 int tx = td->size_ow1 + x * td->tile_wid;
\r
2114 int ty = td->size_oh1 + y * td->tile_hgt;
\r
2115 int tw = w * td->tile_wid - 1;
\r
2116 int th = h * td->tile_hgt - 1;
\r
2118 hdc = GetDC(hWnd);
\r
2119 myBrush = CreateSolidBrush(RGB(255, 255, 255));
\r
2120 oldBrush = SelectObject(hdc, myBrush);
\r
2121 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2123 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
\r
2125 SelectObject(hdc, oldBrush);
\r
2126 SelectObject(hdc, oldPen);
\r
2131 /*** Function hooks needed by "Term" ***/
\r
2137 * Initialize a new Term
\r
2139 static void Term_init_win(term *t)
\r
2146 * Nuke an old Term
\r
2148 static void Term_nuke_win(term *t)
\r
2157 * @brief //!< Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
\r
2159 static errr Term_user_win(int n)
\r
2170 * React to global changes
\r
2172 static errr Term_xtra_win_react(void)
\r
2176 /* Simple color */
\r
2179 /* Save the default colors */
\r
2180 for (i = 0; i < 256; i++)
\r
2182 /* Simply accept the desired colors */
\r
2183 win_pal[i] = angband_color_table[i][0];
\r
2187 /* Complex color */
\r
2194 bool change = FALSE;
\r
2196 /* Save the default colors */
\r
2197 for (i = 0; i < 256; i++)
\r
2199 /* Extract desired values */
\r
2200 rv = angband_color_table[i][1];
\r
2201 gv = angband_color_table[i][2];
\r
2202 bv = angband_color_table[i][3];
\r
2204 /* Extract a full color code */
\r
2205 code = PALETTERGB(rv, gv, bv);
\r
2207 /* Activate changes */
\r
2208 if (win_clr[i] != code)
\r
2210 /* Note the change */
\r
2213 /* Apply the desired color */
\r
2214 win_clr[i] = code;
\r
2218 /* Activate the palette if needed */
\r
2219 if (change) (void)new_palette();
\r
2225 /* Handle "arg_sound" */
\r
2226 if (use_sound != arg_sound)
\r
2228 /* Initialize (if needed) */
\r
2229 if (arg_sound && !init_sound())
\r
2232 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
\r
2234 /* Cannot enable */
\r
2235 arg_sound = FALSE;
\r
2238 /* Change setting */
\r
2239 use_sound = arg_sound;
\r
2246 /* Handle "arg_sound" */
\r
2247 if (use_music != arg_music)
\r
2249 /* Initialize (if needed) */
\r
2250 if (arg_music && !init_music())
\r
2253 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
\r
2254 /* Cannot enable */
\r
2255 arg_music = FALSE;
\r
2258 /* Change setting */
\r
2259 use_music = arg_music;
\r
2261 if(!arg_music) stop_music();
\r
2262 else select_floor_music();
\r
2269 #ifdef USE_GRAPHICS
\r
2271 /* Handle "arg_graphics" */
\r
2272 if (use_graphics != arg_graphics)
\r
2274 /* Initialize (if needed) */
\r
2275 if (arg_graphics && !init_graphics())
\r
2278 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
\r
2280 /* Cannot enable */
\r
2281 arg_graphics = GRAPHICS_NONE;
\r
2284 /* Change setting */
\r
2285 use_graphics = arg_graphics;
\r
2287 /* Reset visuals */
\r
2288 #ifdef ANGBAND_2_8_1
\r
2290 #else /* ANGBAND_2_8_1 */
\r
2291 reset_visuals(TRUE);
\r
2292 #endif /* ANGBAND_2_8_1 */
\r
2295 #endif /* USE_GRAPHICS */
\r
2298 /* Clean up windows */
\r
2299 for (i = 0; i < MAX_TERM_DATA; i++)
\r
2303 term_data *td = &data[i];
\r
2305 /* Update resized windows */
\r
2306 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
\r
2309 Term_activate(&td->t);
\r
2311 /* Hack -- Resize the term */
\r
2312 Term_resize(td->cols, td->rows);
\r
2314 /* Redraw the contents */
\r
2318 Term_activate(old);
\r
2329 * Process at least one event
\r
2331 static errr Term_xtra_win_event(int v)
\r
2335 /* Wait for an event */
\r
2339 if (GetMessage(&msg, NULL, 0, 0))
\r
2341 TranslateMessage(&msg);
\r
2342 DispatchMessage(&msg);
\r
2346 /* Check for an event */
\r
2350 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2352 TranslateMessage(&msg);
\r
2353 DispatchMessage(&msg);
\r
2363 * Process all pending events
\r
2365 static errr Term_xtra_win_flush(void)
\r
2369 /* Process all pending events */
\r
2370 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2372 TranslateMessage(&msg);
\r
2373 DispatchMessage(&msg);
\r
2382 * Hack -- clear the screen
\r
2384 * Make this more efficient
\r
2386 static errr Term_xtra_win_clear(void)
\r
2388 term_data *td = (term_data*)(Term->data);
\r
2393 /* Rectangle to erase */
\r
2394 rc.left = td->size_ow1;
\r
2395 rc.right = rc.left + td->cols * td->tile_wid;
\r
2396 rc.top = td->size_oh1;
\r
2397 rc.bottom = rc.top + td->rows * td->tile_hgt;
\r
2400 hdc = GetDC(td->w);
\r
2401 SetBkColor(hdc, RGB(0, 0, 0));
\r
2402 SelectObject(hdc, td->font_id);
\r
2403 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2408 rc.left = 0; rc.top = 0;
\r
2411 ReleaseDC(td->w, hdc);
\r
2419 * Hack -- make a noise
\r
2421 static errr Term_xtra_win_noise(void)
\r
2423 MessageBeep(MB_ICONASTERISK);
\r
2429 * Hack -- make a sound
\r
2431 static errr Term_xtra_win_sound(int v)
\r
2436 #endif /* USE_SOUND */
\r
2438 /* Sound disabled */
\r
2439 if (!use_sound) return (1);
\r
2441 /* Illegal sound */
\r
2442 if ((v < 0) || (v >= SOUND_MAX)) return (1);
\r
2446 /* Count the samples */
\r
2447 for (i = 0; i < SAMPLE_MAX; i++)
\r
2449 if (!sound_file[v][i])
\r
2454 if (i == 0) return (1);
\r
2456 /* Build the path */
\r
2457 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
\r
2461 /* Play the sound, catch errors */
\r
2462 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
\r
2466 /* Play the sound, catch errors */
\r
2467 return (sndPlaySound(buf, SND_ASYNC));
\r
2469 #endif /* WIN32 */
\r
2471 #else /* USE_SOUND */
\r
2475 #endif /* USE_SOUND */
\r
2479 * Hack -- play a music
\r
2481 static errr Term_xtra_win_music(int n, int v)
\r
2486 #endif /* USE_MUSIC */
\r
2488 /* Sound disabled */
\r
2490 if(!use_music) return (1);
\r
2492 /* Illegal sound */
\r
2493 if(n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return (1);
\r
2494 else if(v < 0 || v >= 1000) return(1); /*!< TODO */
\r
2500 case TERM_XTRA_MUSIC_BASIC:
\r
2501 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2503 case TERM_XTRA_MUSIC_DUNGEON:
\r
2504 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2506 case TERM_XTRA_MUSIC_QUEST:
\r
2507 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2509 case TERM_XTRA_MUSIC_TOWN:
\r
2510 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2517 //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2518 //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2524 case TERM_XTRA_MUSIC_BASIC:
\r
2525 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2527 case TERM_XTRA_MUSIC_DUNGEON:
\r
2528 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2530 case TERM_XTRA_MUSIC_QUEST:
\r
2531 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2533 case TERM_XTRA_MUSIC_TOWN:
\r
2534 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2541 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2542 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2548 case TERM_XTRA_MUSIC_BASIC:
\r
2549 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
\r
2551 case TERM_XTRA_MUSIC_DUNGEON:
\r
2552 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
\r
2554 case TERM_XTRA_MUSIC_QUEST:
\r
2555 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
\r
2557 case TERM_XTRA_MUSIC_TOWN:
\r
2558 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
\r
2562 if(current_music_type == n && current_music_id == v)
\r
2566 current_music_type = n;
\r
2567 current_music_id = v;
\r
2571 mop.lpstrDeviceType = mci_device_type;
\r
2572 mop.lpstrElementName = buf;
\r
2573 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2574 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2575 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
\r
2576 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
2577 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
2580 #endif /* WIN32 */
\r
2582 #else /* USE_MUSIC */
\r
2586 #endif /* USE_MUSIC */
\r
2592 * Delay for "x" milliseconds
\r
2594 static int Term_xtra_win_delay(int v)
\r
2608 t = GetTickCount() + v;
\r
2611 while (GetTickCount() < t)
\r
2613 /* Handle messages */
\r
2614 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2616 TranslateMessage(&msg);
\r
2617 DispatchMessage(&msg);
\r
2621 #endif /* WIN32 */
\r
2629 * Do a "special thing"
\r
2631 static errr Term_xtra_win(int n, int v)
\r
2633 /* Handle a subset of the legal requests */
\r
2636 /* Make a bell sound */
\r
2637 case TERM_XTRA_NOISE:
\r
2639 return (Term_xtra_win_noise());
\r
2642 /* Play a music */
\r
2643 case TERM_XTRA_MUSIC_BASIC:
\r
2644 case TERM_XTRA_MUSIC_DUNGEON:
\r
2645 case TERM_XTRA_MUSIC_QUEST:
\r
2646 case TERM_XTRA_MUSIC_TOWN:
\r
2648 return (Term_xtra_win_music(n, v));
\r
2651 /* Make a special sound */
\r
2652 case TERM_XTRA_SOUND:
\r
2654 return (Term_xtra_win_sound(v));
\r
2657 /* Process random events */
\r
2658 case TERM_XTRA_BORED:
\r
2660 return (Term_xtra_win_event(0));
\r
2663 /* Process an event */
\r
2664 case TERM_XTRA_EVENT:
\r
2666 return (Term_xtra_win_event(v));
\r
2669 /* Flush all events */
\r
2670 case TERM_XTRA_FLUSH:
\r
2672 return (Term_xtra_win_flush());
\r
2675 /* Clear the screen */
\r
2676 case TERM_XTRA_CLEAR:
\r
2678 return (Term_xtra_win_clear());
\r
2681 /* React to global changes */
\r
2682 case TERM_XTRA_REACT:
\r
2684 return (Term_xtra_win_react());
\r
2687 /* Delay for some milliseconds */
\r
2688 case TERM_XTRA_DELAY:
\r
2690 return (Term_xtra_win_delay(v));
\r
2700 * Low level graphics (Assumes valid input).
\r
2702 * Draw a "cursor" at (x,y), using a "yellow box".
\r
2704 static errr Term_curs_win(int x, int y)
\r
2706 term_data *td = (term_data*)(Term->data);
\r
2711 int tile_wid, tile_hgt;
\r
2713 if (td->map_active)
\r
2715 tile_wid = td->map_tile_wid;
\r
2716 tile_hgt = td->map_tile_hgt;
\r
2720 tile_wid = td->tile_wid;
\r
2721 tile_hgt = td->tile_hgt;
\r
2724 /* Frame the grid */
\r
2725 rc.left = x * tile_wid + td->size_ow1;
\r
2726 rc.right = rc.left + tile_wid;
\r
2727 rc.top = y * tile_hgt + td->size_oh1;
\r
2728 rc.bottom = rc.top + tile_hgt;
\r
2730 /* Cursor is done as a yellow "box" */
\r
2731 hdc = GetDC(td->w);
\r
2732 FrameRect(hdc, &rc, hbrYellow);
\r
2733 ReleaseDC(td->w, hdc);
\r
2741 * Low level graphics (Assumes valid input).
\r
2743 * Draw a "big cursor" at (x,y), using a "yellow box".
\r
2745 static errr Term_bigcurs_win(int x, int y)
\r
2747 term_data *td = (term_data*)(Term->data);
\r
2752 int tile_wid, tile_hgt;
\r
2754 if (td->map_active)
\r
2756 /* Normal cursor in map window */
\r
2757 Term_curs_win(x, y);
\r
2762 tile_wid = td->tile_wid;
\r
2763 tile_hgt = td->tile_hgt;
\r
2766 /* Frame the grid */
\r
2767 rc.left = x * tile_wid + td->size_ow1;
\r
2768 rc.right = rc.left + 2 * tile_wid;
\r
2769 rc.top = y * tile_hgt + td->size_oh1;
\r
2770 rc.bottom = rc.top + tile_hgt;
\r
2772 /* Cursor is done as a yellow "box" */
\r
2773 hdc = GetDC(td->w);
\r
2774 FrameRect(hdc, &rc, hbrYellow);
\r
2775 ReleaseDC(td->w, hdc);
\r
2783 * Low level graphics (Assumes valid input).
\r
2785 * Erase a "block" of "n" characters starting at (x,y).
\r
2787 static errr Term_wipe_win(int x, int y, int n)
\r
2789 term_data *td = (term_data*)(Term->data);
\r
2794 /* Rectangle to erase in client coords */
\r
2795 rc.left = x * td->tile_wid + td->size_ow1;
\r
2796 rc.right = rc.left + n * td->tile_wid;
\r
2797 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2798 rc.bottom = rc.top + td->tile_hgt;
\r
2800 hdc = GetDC(td->w);
\r
2801 SetBkColor(hdc, RGB(0, 0, 0));
\r
2802 SelectObject(hdc, td->font_id);
\r
2807 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2808 ReleaseDC(td->w, hdc);
\r
2816 * Low level graphics. Assumes valid input.
\r
2818 * Draw several ("n") chars, with an attr, at a given location.
\r
2820 * All "graphic" data is handled by "Term_pict_win()", below.
\r
2822 * One would think there is a more efficient method for telling a window
\r
2823 * what color it should be using to draw with, but perhaps simply changing
\r
2824 * it every time is not too inefficient.
\r
2826 static errr Term_text_win(int x, int y, int n, TERM_COLOR a, const char *s)
\r
2828 term_data *td = (term_data*)(Term->data);
\r
2832 #if 1 /* #ifdef JP */
\r
2833 static HBITMAP WALL;
\r
2834 static HBRUSH myBrush, oldBrush;
\r
2835 static HPEN oldPen;
\r
2836 static bool init_done = FALSE;
\r
2839 WALL = LoadBitmap(hInstance, AppName);
\r
2840 myBrush = CreatePatternBrush(WALL);
\r
2845 /* Total rectangle */
\r
2846 rc.left = x * td->tile_wid + td->size_ow1;
\r
2847 rc.right = rc.left + n * td->tile_wid;
\r
2848 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2849 rc.bottom = rc.top + td->tile_hgt;
\r
2852 hdc = GetDC(td->w);
\r
2854 /* Background color */
\r
2855 SetBkColor(hdc, RGB(0, 0, 0));
\r
2857 /* Foreground color */
\r
2860 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
\r
2862 else if (paletted)
\r
2864 SetTextColor(hdc, win_clr[a&0x0F]);
\r
2868 SetTextColor(hdc, win_clr[a]);
\r
2871 /* Use the font */
\r
2872 SelectObject(hdc, td->font_id);
\r
2875 if (use_bg) SetBkMode(hdc, TRANSPARENT);
\r
2877 /* Bizarre size */
\r
2878 if (td->bizarre ||
\r
2879 (td->tile_hgt != td->font_hgt) ||
\r
2880 (td->tile_wid != td->font_wid))
\r
2884 /* Erase complete rectangle */
\r
2885 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2888 if (use_bg) DrawBG(hdc, &rc);
\r
2890 /* New rectangle */
\r
2891 rc.left += ((td->tile_wid - td->font_wid) / 2);
\r
2892 rc.right = rc.left + td->font_wid;
\r
2893 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
\r
2894 rc.bottom = rc.top + td->font_hgt;
\r
2896 /* Dump each character */
\r
2897 for (i = 0; i < n; i++)
\r
2900 if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
\r
2902 rc.right += td->font_wid;
\r
2904 oldBrush = SelectObject(hdc, myBrush);
\r
2905 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2907 /* Dump the wall */
\r
2908 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2910 SelectObject(hdc, oldBrush);
\r
2911 SelectObject(hdc, oldPen);
\r
2912 rc.right -= td->font_wid;
\r
2916 rc.left += 2 * td->tile_wid;
\r
2917 rc.right += 2 * td->tile_wid;
\r
2919 else if ( iskanji(*(s+i)) ) /* 2バイト文字 */
\r
2921 rc.right += td->font_wid;
\r
2922 /* Dump the text */
\r
2923 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2925 rc.right -= td->font_wid;
\r
2929 rc.left += 2 * td->tile_wid;
\r
2930 rc.right += 2 * td->tile_wid;
\r
2931 } else if (*(s+i)==127){
\r
2932 oldBrush = SelectObject(hdc, myBrush);
\r
2933 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2935 /* Dump the wall */
\r
2936 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2938 SelectObject(hdc, oldBrush);
\r
2939 SelectObject(hdc, oldPen);
\r
2942 rc.left += td->tile_wid;
\r
2943 rc.right += td->tile_wid;
\r
2945 /* Dump the text */
\r
2946 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
\r
2949 rc.left += td->tile_wid;
\r
2950 rc.right += td->tile_wid;
\r
2955 oldBrush = SelectObject(hdc, myBrush);
\r
2956 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2958 /* Dump the wall */
\r
2959 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2961 SelectObject(hdc, oldBrush);
\r
2962 SelectObject(hdc, oldPen);
\r
2965 rc.left += td->tile_wid;
\r
2966 rc.right += td->tile_wid;
\r
2968 /* Dump the text */
\r
2969 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2973 rc.left += td->tile_wid;
\r
2974 rc.right += td->tile_wid;
\r
2977 /* Dump the text */
\r
2978 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
\r
2982 rc.left += td->tile_wid;
\r
2983 rc.right += td->tile_wid;
\r
2993 /* Dump the text */
\r
2994 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
\r
2999 ReleaseDC(td->w, hdc);
\r
3007 * Low level graphics. Assumes valid input.
\r
3009 * Draw an array of "special" attr/char pairs at the given location.
\r
3011 * We use the "Term_pict_win()" function for "graphic" data, which are
\r
3012 * encoded by setting the "high-bits" of both the "attr" and the "char"
\r
3013 * data. We use the "attr" to represent the "row" of the main bitmap,
\r
3014 * and the "char" to represent the "col" of the main bitmap. The use
\r
3015 * of this function is induced by the "higher_pict" flag.
\r
3017 * If "graphics" is not available, we simply "wipe" the given grids.
\r
3019 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
3021 term_data *td = (term_data*)(Term->data);
\r
3023 #ifdef USE_GRAPHICS
\r
3026 TERM_LEN x1, y1, w1, h1, tw1, th1;
\r
3027 TERM_LEN x2, y2, w2, h2, tw2 = 0;
\r
3030 HDC hdcMask = NULL;
\r
3034 HBITMAP hbmSrcOld;
\r
3037 if (!use_graphics)
\r
3039 /* Erase the grids */
\r
3040 return (Term_wipe_win(x, y, n));
\r
3043 /* Size of bitmap cell */
\r
3044 w1 = infGraph.CellWidth;
\r
3045 h1 = infGraph.CellHeight;
\r
3046 tw1 = infGraph.TileWidth;
\r
3047 th1 = infGraph.TileHeight;
\r
3049 /* Size of window cell */
\r
3050 if (td->map_active)
\r
3052 w2 = td->map_tile_wid;
\r
3053 h2 = td->map_tile_hgt;
\r
3057 w2 = td->tile_wid;
\r
3058 h2 = td->tile_hgt;
\r
3061 /* big tile mode */
\r
3062 if (use_bigtile) tw2 *= 2;
\r
3065 /* Location of window cell */
\r
3066 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
\r
3067 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
\r
3070 hdc = GetDC(td->w);
\r
3073 hdcSrc = CreateCompatibleDC(hdc);
\r
3074 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
\r
3076 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3078 hdcMask = CreateCompatibleDC(hdc);
\r
3079 SelectObject(hdcMask, infMask.hBitmap);
\r
3082 /* Draw attr/char pairs */
\r
3083 for (i = 0; i < n; i++, x2 += w2)
\r
3085 TERM_COLOR a = ap[i];
\r
3089 /* Extract picture */
\r
3090 int row = (a & 0x7F);
\r
3091 int col = (c & 0x7F);
\r
3093 /* Location of bitmap cell */
\r
3097 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3099 x3 = (tcp[i] & 0x7F) * w1;
\r
3100 y3 = (tap[i] & 0x7F) * h1;
\r
3101 tw2 = tw2 * w1 / tw1;
\r
3102 h2 = h2 * h1 / th1;
\r
3104 /* Perfect size */
\r
3105 if ((tw1 == tw2) && (th1 == h2))
\r
3107 /* Copy the terrain picture from the bitmap to the window */
\r
3108 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
\r
3110 /* Mask out the tile */
\r
3111 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
\r
3113 /* Draw the tile */
\r
3114 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
\r
3117 /* Need to stretch */
\r
3120 /* Set the correct mode for stretching the tiles */
\r
3121 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3123 /* Copy the terrain picture from the bitmap to the window */
\r
3124 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
\r
3126 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
\r
3128 /* Only draw if terrain and overlay are different */
\r
3129 if ((x1 != x3) || (y1 != y3))
\r
3131 /* Mask out the tile */
\r
3132 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
\r
3134 /* Draw the tile */
\r
3135 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
\r
3141 /* Perfect size */
\r
3142 if ((w1 == tw2) && (h1 == h2))
\r
3144 /* Copy the picture from the bitmap to the window */
\r
3145 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
\r
3148 /* Need to stretch */
\r
3151 /* Set the correct mode for stretching the tiles */
\r
3152 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3154 /* Copy the picture from the bitmap to the window */
\r
3155 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
\r
3161 SelectObject(hdcSrc, hbmSrcOld);
\r
3164 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3167 SelectObject(hdcMask, hbmSrcOld);
\r
3168 DeleteDC(hdcMask);
\r
3172 ReleaseDC(td->w, hdc);
\r
3174 #else /* USE_GRAPHICS */
\r
3176 /* Just erase this grid */
\r
3177 return (Term_wipe_win(x, y, n));
\r
3179 #endif /* USE_GRAPHICS */
\r
3186 static void windows_map(void)
\r
3188 term_data *td = &data[0];
\r
3191 TERM_LEN x, min_x, max_x;
\r
3192 TERM_LEN y, min_y, max_y;
\r
3197 /* Only in graphics mode */
\r
3198 if (!use_graphics) return;
\r
3200 /* Clear screen */
\r
3201 Term_xtra_win_clear();
\r
3203 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
\r
3204 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
\r
3205 td->map_active = TRUE;
\r
3214 /* Draw the map */
\r
3215 for (x = min_x; x < max_x; x++)
\r
3217 for (y = min_y; y < max_y; y++)
\r
3219 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
\r
3221 /* Ignore non-graphics */
\r
3222 if ((a & 0x80) && (c & 0x80))
\r
3224 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
\r
3229 /* Hilite the player */
\r
3230 Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
\r
3232 /* Wait for a keypress, flush key buffer */
\r
3233 Term_inkey(&c, TRUE, TRUE);
\r
3236 /* Switch off the map display */
\r
3237 td->map_active = FALSE;
\r
3239 /* Restore screen */
\r
3240 Term_xtra_win_clear();
\r
3245 /*** Other routines ***/
\r
3249 * Create and initialize a "term_data" given a title
\r
3251 static void term_data_link(term_data *td)
\r
3255 /* Initialize the term */
\r
3256 term_init(t, td->cols, td->rows, td->keys);
\r
3258 /* Use a "software" cursor */
\r
3259 t->soft_cursor = TRUE;
\r
3261 /* Use "Term_pict" for "graphic" data */
\r
3262 t->higher_pict = TRUE;
\r
3264 /* Erase with "white space" */
\r
3265 t->attr_blank = TERM_WHITE;
\r
3266 t->char_blank = ' ';
\r
3269 /* Prepare the init/nuke hooks */
\r
3270 t->init_hook = Term_init_win;
\r
3271 t->nuke_hook = Term_nuke_win;
\r
3274 /* Prepare the template hooks */
\r
3275 t->user_hook = Term_user_win;
\r
3276 t->xtra_hook = Term_xtra_win;
\r
3277 t->curs_hook = Term_curs_win;
\r
3278 t->bigcurs_hook = Term_bigcurs_win;
\r
3279 t->wipe_hook = Term_wipe_win;
\r
3280 t->text_hook = Term_text_win;
\r
3281 t->pict_hook = Term_pict_win;
\r
3283 /* Remember where we came from */
\r
3284 t->data = (vptr)(td);
\r
3289 * Create the windows
\r
3291 * First, instantiate the "default" values, then read the "ini_file"
\r
3292 * to over-ride selected values, then create the windows, and fonts.
\r
3294 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
\r
3295 * must make active to realize the palette.
\r
3297 static void init_windows(void)
\r
3303 #if 0 /* #ifndef JP */
\r
3309 WIPE(td, term_data);
\r
3313 td->s = angband_term_name[0];
\r
3319 td->visible = TRUE;
\r
3324 td->pos_x = 7 * 30;
\r
3325 td->pos_y = 7 * 20;
\r
3326 td->posfix = FALSE;
\r
3327 #if 1 /* #ifdef JP */
\r
3328 td->bizarre = TRUE;
\r
3331 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3334 WIPE(td, term_data);
\r
3335 td->s = angband_term_name[i];
\r
3339 td->visible = FALSE;
\r
3344 td->pos_x = (7 - i) * 30;
\r
3345 td->pos_y = (7 - i) * 20;
\r
3346 td->posfix = FALSE;
\r
3347 #if 1 /* #ifdef JP */
\r
3348 td->bizarre = TRUE;
\r
3357 /* Main window (need these before term_getsize gets called) */
\r
3359 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
\r
3360 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
\r
3362 td->dwExStyle = 0;
\r
3363 td->visible = TRUE;
\r
3365 /* Sub windows (need these before term_getsize gets called) */
\r
3366 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3369 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
\r
3370 td->dwExStyle = (WS_EX_TOOLWINDOW);
\r
3375 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3379 #if 1 /* #ifdef JP */
\r
3380 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
\r
3381 td->lf.lfCharSet = DEFAULT_CHARSET;
\r
3382 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
\r
3383 /* Activate the chosen font */
\r
3384 term_force_font(td, NULL);
\r
3385 if(!td->tile_wid) td->tile_wid = td->font_wid;
\r
3386 if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
\r
3388 /* Access the standard font file */
\r
3389 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
\r
3391 /* Activate the chosen font */
\r
3392 if (term_force_font(td, buf))
\r
3394 /* Access the standard font file */
\r
3395 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
3397 /* Force the use of that font */
\r
3398 (void)term_force_font(td, buf);
\r
3401 td->tile_hgt = 13;
\r
3403 /* Assume not bizarre */
\r
3404 td->bizarre = FALSE;
\r
3409 /* Analyze the font */
\r
3412 /* Resize the window */
\r
3413 term_window_resize(td);
\r
3417 /* Sub windows (reverse order) */
\r
3418 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
\r
3423 td->w = CreateWindowEx(td->dwExStyle, AngList,
\r
3424 td->s, td->dwStyle,
\r
3425 td->pos_x, td->pos_y,
\r
3426 td->size_wid, td->size_hgt,
\r
3427 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3429 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
\r
3433 td->size_hack = TRUE;
\r
3434 ShowWindow(td->w, SW_SHOW);
\r
3435 td->size_hack = FALSE;
\r
3438 term_data_link(td);
\r
3439 angband_term[i] = &td->t;
\r
3443 /* Activate the window */
\r
3444 SetActiveWindow(td->w);
\r
3447 if (data[i].posfix)
\r
3449 term_window_pos(&data[i], HWND_TOPMOST);
\r
3453 term_window_pos(&data[i], td->w);
\r
3463 td->w = CreateWindowEx(td->dwExStyle, AppName,
\r
3464 td->s, td->dwStyle,
\r
3465 td->pos_x, td->pos_y,
\r
3466 td->size_wid, td->size_hgt,
\r
3467 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3469 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
\r
3471 term_data_link(td);
\r
3472 angband_term[0] = &td->t;
\r
3473 normsize.x = td->cols;
\r
3474 normsize.y = td->rows;
\r
3476 /* Activate the main window */
\r
3477 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
\r
3478 else ShowWindow(td->w, SW_SHOW);
\r
3480 /* Bring main window back to top */
\r
3481 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
3485 (void)new_palette();
\r
3488 /* Create a "brush" for drawing the "cursor" */
\r
3489 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
\r
3492 /* Process pending messages */
\r
3493 (void)Term_xtra_win_flush();
\r
3499 * Prepare the menus
\r
3501 static void setup_menus(void)
\r
3505 HMENU hm = GetMenu(data[0].w);
\r
3508 /* Menu "File", Disable all */
\r
3509 EnableMenuItem(hm, IDM_FILE_NEW,
\r
3510 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3511 EnableMenuItem(hm, IDM_FILE_OPEN,
\r
3512 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3513 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3514 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3515 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3516 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3517 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3518 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3521 /* No character available */
\r
3522 if (!character_generated)
\r
3524 /* Menu "File", Item "New" */
\r
3525 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
\r
3527 /* Menu "File", Item "Open" */
\r
3528 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
\r
3531 /* A character available */
\r
3532 if (character_generated)
\r
3534 /* Menu "File", Item "Save" */
\r
3535 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3536 MF_BYCOMMAND | MF_ENABLED);
\r
3539 /* Menu "File", Item "Exit" */
\r
3540 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3541 MF_BYCOMMAND | MF_ENABLED);
\r
3543 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3544 MF_BYCOMMAND | MF_ENABLED);
\r
3547 /* Menu "Window::Visibility" */
\r
3548 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3550 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3551 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3553 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3554 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
\r
3556 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3557 MF_BYCOMMAND | MF_ENABLED);
\r
3560 /* Menu "Window::Font" */
\r
3561 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3563 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3564 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3566 if (data[i].visible)
\r
3568 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3569 MF_BYCOMMAND | MF_ENABLED);
\r
3573 /* Menu "Window::Window Position Fix" */
\r
3574 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3576 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3577 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3579 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3580 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
\r
3582 if (data[i].visible)
\r
3584 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3585 MF_BYCOMMAND | MF_ENABLED);
\r
3589 /* Menu "Window::Bizarre Display" */
\r
3590 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3592 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3593 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3595 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3596 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
\r
3598 if (data[i].visible)
\r
3600 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3601 MF_BYCOMMAND | MF_ENABLED);
\r
3606 /* Menu "Window::Increase Tile Width" */
\r
3607 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3609 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3610 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3612 if (data[i].visible)
\r
3614 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3615 MF_BYCOMMAND | MF_ENABLED);
\r
3620 /* Menu "Window::Decrease Tile Width" */
\r
3621 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3623 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3624 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3626 if (data[i].visible)
\r
3628 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3629 MF_BYCOMMAND | MF_ENABLED);
\r
3634 /* Menu "Window::Increase Tile Height" */
\r
3635 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3637 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3638 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3640 if (data[i].visible)
\r
3642 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3643 MF_BYCOMMAND | MF_ENABLED);
\r
3648 /* Menu "Window::Decrease Tile Height" */
\r
3649 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3651 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3652 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3654 if (data[i].visible)
\r
3656 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3657 MF_BYCOMMAND | MF_ENABLED);
\r
3662 /* Menu "Options", disable all */
\r
3663 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3664 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3665 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3666 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3667 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3668 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3669 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3670 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3671 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3672 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3674 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3675 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3678 /* Menu "Options", Item "Map" */
\r
3679 if (use_graphics != GRAPHICS_NONE)
\r
3680 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
\r
3682 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
\r
3683 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3685 /* Menu "Options", update all */
\r
3686 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3687 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
\r
3688 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3689 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
\r
3690 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3691 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
\r
3692 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
\r
3693 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
\r
3694 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3695 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
\r
3696 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
\r
3697 (arg_music ? MF_CHECKED : MF_UNCHECKED));
\r
3698 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3699 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
\r
3700 CheckMenuItem(hm, IDM_OPTIONS_BG,
\r
3701 (use_bg ? MF_CHECKED : MF_UNCHECKED));
\r
3703 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3704 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
\r
3707 #ifdef USE_GRAPHICS
\r
3708 /* Menu "Options", Item "Graphics" */
\r
3709 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
\r
3710 /* Menu "Options", Item "Graphics" */
\r
3711 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
\r
3712 /* Menu "Options", Item "Graphics" */
\r
3713 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
\r
3714 /* Menu "Options", Item "Graphics" */
\r
3715 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
\r
3716 #endif /* USE_GRAPHICS */
\r
3719 /* Menu "Options", Item "Sound" */
\r
3720 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
\r
3721 #endif /* USE_SOUND */
\r
3724 /* Menu "Options", Item "ScreenSaver" */
\r
3725 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3726 MF_BYCOMMAND | MF_ENABLED);
\r
3727 #endif /* USE_SAVER */
\r
3732 * Check for double clicked (or dragged) savefile
\r
3734 * Apparently, Windows copies the entire filename into the first
\r
3735 * piece of the "command line string". Perhaps we should extract
\r
3736 * the "basename" of that filename and append it to the "save" dir.
\r
3738 static void check_for_save_file(LPSTR cmd_line)
\r
3748 /* Extract filename */
\r
3749 strcat(savefile, s);
\r
3751 /* Validate the file */
\r
3752 validate_file(savefile);
\r
3754 /* Game in progress */
\r
3755 game_in_progress = TRUE;
\r
3763 * Process a menu command
\r
3765 static void process_menus(WORD wCmd)
\r
3777 case IDM_FILE_NEW:
\r
3781 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3783 else if (game_in_progress)
\r
3785 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
\r
3789 game_in_progress = TRUE;
\r
3798 case IDM_FILE_OPEN:
\r
3802 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3804 else if (game_in_progress)
\r
3806 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
\r
3810 memset(&ofn, 0, sizeof(ofn));
\r
3811 ofn.lStructSize = sizeof(ofn);
\r
3812 ofn.hwndOwner = data[0].w;
\r
3813 ofn.lpstrFilter = "Save Files (*.)\0*\0";
\r
3814 ofn.nFilterIndex = 1;
\r
3815 ofn.lpstrFile = savefile;
\r
3816 ofn.nMaxFile = 1024;
\r
3817 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
\r
3818 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
\r
3820 if (GetOpenFileName(&ofn))
\r
3822 /* Load 'savefile' */
\r
3823 validate_file(savefile);
\r
3824 game_in_progress = TRUE;
\r
3834 case IDM_FILE_SAVE:
\r
3836 if (game_in_progress && character_generated)
\r
3841 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
\r
3845 /* Hack -- Forget messages */
\r
3848 /* Save the game */
\r
3850 do_cmd_save_game(FALSE);
\r
3851 #else /* ZANGBAND */
\r
3852 do_cmd_save_game();
\r
3853 #endif /* ZANGBAND */
\r
3857 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
\r
3863 case IDM_FILE_EXIT:
\r
3865 if (game_in_progress && character_generated)
\r
3870 plog(_("今は終了できません。", "You may not do that right now."));
\r
3874 /* Hack -- Forget messages */
\r
3881 /* Save the game */
\r
3883 /* do_cmd_save_game(FALSE); */
\r
3884 #else /* ZANGBAND */
\r
3885 /* do_cmd_save_game(); */
\r
3886 #endif /* ZANGBAND */
\r
3887 Term_key_push(SPECIAL_KEY_QUIT);
\r
3895 case IDM_FILE_SCORE:
\r
3899 /* Build the filename */
\r
3900 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
\r
3902 /* Open the binary high score file, for reading */
\r
3903 highscore_fd = fd_open(buf, O_RDONLY);
\r
3905 /* Paranoia -- No score file */
\r
3906 if (highscore_fd < 0)
\r
3908 msg_print("Score file unavailable.");
\r
3915 /* Clear screen */
\r
3918 /* Display the scores */
\r
3919 display_scores_aux(0, MAX_HISCORES, -1, NULL);
\r
3921 /* Shut the high score file */
\r
3922 (void)fd_close(highscore_fd);
\r
3924 /* Forget the high score fd */
\r
3925 highscore_fd = -1;
\r
3930 /* Hack - Flush it */
\r
3938 case IDM_FILE_MOVIE:
\r
3942 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3944 else if (game_in_progress)
\r
3946 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
\r
3950 memset(&ofn, 0, sizeof(ofn));
\r
3951 ofn.lStructSize = sizeof(ofn);
\r
3952 ofn.hwndOwner = data[0].w;
\r
3953 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
\r
3954 ofn.nFilterIndex = 1;
\r
3955 ofn.lpstrFile = savefile;
\r
3956 ofn.nMaxFile = 1024;
\r
3957 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
\r
3958 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
3960 if (GetOpenFileName(&ofn))
\r
3962 /* Load 'savefile' */
\r
3963 prepare_browse_movie_aux(savefile);
\r
3973 case IDM_WINDOW_VIS_0:
\r
3975 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
\r
3979 /* Window visibility */
\r
3980 case IDM_WINDOW_VIS_1:
\r
3981 case IDM_WINDOW_VIS_2:
\r
3982 case IDM_WINDOW_VIS_3:
\r
3983 case IDM_WINDOW_VIS_4:
\r
3984 case IDM_WINDOW_VIS_5:
\r
3985 case IDM_WINDOW_VIS_6:
\r
3986 case IDM_WINDOW_VIS_7:
\r
3988 i = wCmd - IDM_WINDOW_VIS_0;
\r
3990 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
3996 td->visible = TRUE;
\r
3997 ShowWindow(td->w, SW_SHOW);
\r
3998 term_data_redraw(td);
\r
4002 td->visible = FALSE;
\r
4003 td->posfix = FALSE;
\r
4004 ShowWindow(td->w, SW_HIDE);
\r
4010 /* Window fonts */
\r
4011 case IDM_WINDOW_FONT_0:
\r
4012 case IDM_WINDOW_FONT_1:
\r
4013 case IDM_WINDOW_FONT_2:
\r
4014 case IDM_WINDOW_FONT_3:
\r
4015 case IDM_WINDOW_FONT_4:
\r
4016 case IDM_WINDOW_FONT_5:
\r
4017 case IDM_WINDOW_FONT_6:
\r
4018 case IDM_WINDOW_FONT_7:
\r
4020 i = wCmd - IDM_WINDOW_FONT_0;
\r
4022 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4026 term_change_font(td);
\r
4031 /* Window Z Position */
\r
4032 case IDM_WINDOW_POS_1:
\r
4033 case IDM_WINDOW_POS_2:
\r
4034 case IDM_WINDOW_POS_3:
\r
4035 case IDM_WINDOW_POS_4:
\r
4036 case IDM_WINDOW_POS_5:
\r
4037 case IDM_WINDOW_POS_6:
\r
4038 case IDM_WINDOW_POS_7:
\r
4040 i = wCmd - IDM_WINDOW_POS_0;
\r
4042 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4046 if (!td->posfix && td->visible)
\r
4048 td->posfix = TRUE;
\r
4049 term_window_pos(td, HWND_TOPMOST);
\r
4053 td->posfix = FALSE;
\r
4054 term_window_pos(td, data[0].w);
\r
4060 /* Bizarre Display */
\r
4061 case IDM_WINDOW_BIZ_0:
\r
4062 case IDM_WINDOW_BIZ_1:
\r
4063 case IDM_WINDOW_BIZ_2:
\r
4064 case IDM_WINDOW_BIZ_3:
\r
4065 case IDM_WINDOW_BIZ_4:
\r
4066 case IDM_WINDOW_BIZ_5:
\r
4067 case IDM_WINDOW_BIZ_6:
\r
4068 case IDM_WINDOW_BIZ_7:
\r
4070 i = wCmd - IDM_WINDOW_BIZ_0;
\r
4072 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4076 td->bizarre = !td->bizarre;
\r
4080 term_window_resize(td);
\r
4085 /* Increase Tile Width */
\r
4086 case IDM_WINDOW_I_WID_0:
\r
4087 case IDM_WINDOW_I_WID_1:
\r
4088 case IDM_WINDOW_I_WID_2:
\r
4089 case IDM_WINDOW_I_WID_3:
\r
4090 case IDM_WINDOW_I_WID_4:
\r
4091 case IDM_WINDOW_I_WID_5:
\r
4092 case IDM_WINDOW_I_WID_6:
\r
4093 case IDM_WINDOW_I_WID_7:
\r
4095 i = wCmd - IDM_WINDOW_I_WID_0;
\r
4097 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4101 td->tile_wid += 1;
\r
4105 term_window_resize(td);
\r
4110 /* Decrease Tile Height */
\r
4111 case IDM_WINDOW_D_WID_0:
\r
4112 case IDM_WINDOW_D_WID_1:
\r
4113 case IDM_WINDOW_D_WID_2:
\r
4114 case IDM_WINDOW_D_WID_3:
\r
4115 case IDM_WINDOW_D_WID_4:
\r
4116 case IDM_WINDOW_D_WID_5:
\r
4117 case IDM_WINDOW_D_WID_6:
\r
4118 case IDM_WINDOW_D_WID_7:
\r
4120 i = wCmd - IDM_WINDOW_D_WID_0;
\r
4122 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4126 td->tile_wid -= 1;
\r
4130 term_window_resize(td);
\r
4135 /* Increase Tile Height */
\r
4136 case IDM_WINDOW_I_HGT_0:
\r
4137 case IDM_WINDOW_I_HGT_1:
\r
4138 case IDM_WINDOW_I_HGT_2:
\r
4139 case IDM_WINDOW_I_HGT_3:
\r
4140 case IDM_WINDOW_I_HGT_4:
\r
4141 case IDM_WINDOW_I_HGT_5:
\r
4142 case IDM_WINDOW_I_HGT_6:
\r
4143 case IDM_WINDOW_I_HGT_7:
\r
4145 i = wCmd - IDM_WINDOW_I_HGT_0;
\r
4147 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4151 td->tile_hgt += 1;
\r
4155 term_window_resize(td);
\r
4160 /* Decrease Tile Height */
\r
4161 case IDM_WINDOW_D_HGT_0:
\r
4162 case IDM_WINDOW_D_HGT_1:
\r
4163 case IDM_WINDOW_D_HGT_2:
\r
4164 case IDM_WINDOW_D_HGT_3:
\r
4165 case IDM_WINDOW_D_HGT_4:
\r
4166 case IDM_WINDOW_D_HGT_5:
\r
4167 case IDM_WINDOW_D_HGT_6:
\r
4168 case IDM_WINDOW_D_HGT_7:
\r
4170 i = wCmd - IDM_WINDOW_D_HGT_0;
\r
4172 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4176 td->tile_hgt -= 1;
\r
4180 term_window_resize(td);
\r
4185 case IDM_OPTIONS_NO_GRAPHICS:
\r
4190 plog("You may not do that right now.");
\r
4194 /* Toggle "arg_graphics" */
\r
4195 if (arg_graphics != GRAPHICS_NONE)
\r
4197 arg_graphics = GRAPHICS_NONE;
\r
4199 /* React to changes */
\r
4200 Term_xtra_win_react();
\r
4202 /* Hack -- Force redraw */
\r
4203 Term_key_push(KTRL('R'));
\r
4209 case IDM_OPTIONS_OLD_GRAPHICS:
\r
4214 plog("You may not do that right now.");
\r
4218 /* Toggle "arg_graphics" */
\r
4219 if (arg_graphics != GRAPHICS_ORIGINAL)
\r
4221 arg_graphics = GRAPHICS_ORIGINAL;
\r
4223 /* React to changes */
\r
4224 Term_xtra_win_react();
\r
4226 /* Hack -- Force redraw */
\r
4227 Term_key_push(KTRL('R'));
\r
4233 case IDM_OPTIONS_NEW_GRAPHICS:
\r
4238 plog("You may not do that right now.");
\r
4242 /* Toggle "arg_graphics" */
\r
4243 if (arg_graphics != GRAPHICS_ADAM_BOLT)
\r
4245 arg_graphics = GRAPHICS_ADAM_BOLT;
\r
4247 /* React to changes */
\r
4248 Term_xtra_win_react();
\r
4250 /* Hack -- Force redraw */
\r
4251 Term_key_push(KTRL('R'));
\r
4257 case IDM_OPTIONS_NEW2_GRAPHICS:
\r
4262 plog("You may not do that right now.");
\r
4266 /* Toggle "arg_graphics" */
\r
4267 if (arg_graphics != GRAPHICS_HENGBAND)
\r
4269 arg_graphics = GRAPHICS_HENGBAND;
\r
4271 /* React to changes */
\r
4272 Term_xtra_win_react();
\r
4274 /* Hack -- Force redraw */
\r
4275 Term_key_push(KTRL('R'));
\r
4281 case IDM_OPTIONS_BIGTILE:
\r
4288 plog("You may not do that right now.");
\r
4292 /* Toggle "arg_sound" */
\r
4293 arg_bigtile = !arg_bigtile;
\r
4296 Term_activate(&td->t);
\r
4298 /* Resize the term */
\r
4299 Term_resize(td->cols, td->rows);
\r
4301 /* Redraw later */
\r
4302 InvalidateRect(td->w, NULL, TRUE);
\r
4307 case IDM_OPTIONS_MUSIC:
\r
4312 plog("You may not do that right now.");
\r
4316 /* Toggle "arg_sound" */
\r
4317 arg_music = !arg_music;
\r
4319 /* React to changes */
\r
4320 Term_xtra_win_react();
\r
4322 /* Hack -- Force redraw */
\r
4323 Term_key_push(KTRL('R'));
\r
4328 case IDM_OPTIONS_SOUND:
\r
4333 plog("You may not do that right now.");
\r
4337 /* Toggle "arg_sound" */
\r
4338 arg_sound = !arg_sound;
\r
4340 /* React to changes */
\r
4341 Term_xtra_win_react();
\r
4343 /* Hack -- Force redraw */
\r
4344 Term_key_push(KTRL('R'));
\r
4350 case IDM_OPTIONS_BG:
\r
4355 plog("You may not do that right now.");
\r
4359 /* Toggle "use_bg" */
\r
4364 /* React to changes */
\r
4365 Term_xtra_win_react();
\r
4367 /* Hack -- Force redraw */
\r
4368 Term_key_push(KTRL('R'));
\r
4374 case IDM_OPTIONS_OPEN_BG:
\r
4379 plog("You may not do that right now.");
\r
4384 memset(&ofn, 0, sizeof(ofn));
\r
4385 ofn.lStructSize = sizeof(ofn);
\r
4386 ofn.hwndOwner = data[0].w;
\r
4387 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
\r
4388 ofn.nFilterIndex = 1;
\r
4389 ofn.lpstrFile = bg_bitmap_file;
\r
4390 ofn.nMaxFile = 1023;
\r
4391 ofn.lpstrInitialDir = NULL;
\r
4392 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
\r
4393 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
\r
4395 if (GetOpenFileName(&ofn))
\r
4397 /* Load 'savefile' */
\r
4402 /* React to changes */
\r
4403 Term_xtra_win_react();
\r
4405 /* Hack -- Force redraw */
\r
4406 Term_key_push(KTRL('R'));
\r
4411 case IDM_DUMP_SCREEN_HTML:
\r
4413 static char buf[1024] = "";
\r
4414 memset(&ofn, 0, sizeof(ofn));
\r
4415 ofn.lStructSize = sizeof(ofn);
\r
4416 ofn.hwndOwner = data[0].w;
\r
4417 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
\r
4418 ofn.nFilterIndex = 1;
\r
4419 ofn.lpstrFile = buf;
\r
4420 ofn.nMaxFile = 1023;
\r
4421 ofn.lpstrDefExt = "html";
\r
4422 ofn.lpstrInitialDir = NULL;
\r
4423 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
\r
4424 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
\r
4426 if (GetSaveFileName(&ofn))
\r
4428 do_cmd_save_screen_html_aux(buf, 0);
\r
4435 case IDM_OPTIONS_SAVER:
\r
4439 DestroyWindow(hwndSaver);
\r
4444 /* Create a screen scaver window */
\r
4445 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
\r
4446 "Angband Screensaver",
\r
4447 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
\r
4448 0, 0, GetSystemMetrics(SM_CXSCREEN),
\r
4449 GetSystemMetrics(SM_CYSCREEN),
\r
4450 NULL, NULL, hInstance, NULL);
\r
4454 /* Push the window to the bottom */
\r
4455 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
4459 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
\r
4467 case IDM_OPTIONS_MAP:
\r
4473 case IDM_HELP_CONTENTS:
\r
4477 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
\r
4478 if (check_file(tmp))
\r
4480 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
\r
4484 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
\r
4485 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
\r
4488 #else /* HTML_HELP */
\r
4491 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
\r
4492 if (check_file(tmp))
\r
4494 sprintf(buf, "winhelp.exe %s", tmp);
\r
4495 WinExec(buf, SW_NORMAL);
\r
4499 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
\r
4500 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
\r
4504 #endif /* HTML_HELP */
\r
4510 static bool process_keydown(WPARAM wParam, LPARAM lParam)
\r
4517 /* Extract the modifiers */
\r
4518 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
\r
4519 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
\r
4520 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
\r
4522 Term_no_press = (ma) ? TRUE : FALSE;
\r
4524 /* Handle "special" keys */
\r
4525 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
\r
4527 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
\r
4528 bool numpad = FALSE;
\r
4530 /* Begin the macro trigger */
\r
4531 Term_keypress(31);
\r
4533 /* Send the modifiers */
\r
4534 if (mc) Term_keypress('C');
\r
4535 if (ms) Term_keypress('S');
\r
4536 if (ma) Term_keypress('A');
\r
4538 /* Extract "scan code" */
\r
4539 i = LOBYTE(HIWORD(lParam));
\r
4541 /* Introduce the scan code */
\r
4542 Term_keypress('x');
\r
4544 /* Extended key bit */
\r
4547 /* Numpad Enter and '/' are extended key */
\r
4549 Term_no_press = TRUE;
\r
4550 case VK_RETURN: /* Enter */
\r
4553 /* Other extended keys are on full keyboard */
\r
4567 case VK_SEPARATOR:
\r
4569 Term_no_press = TRUE;
\r
4573 case VK_PRIOR: /* Page Up */
\r
4574 case VK_NEXT: /* Page Down */
\r
4581 numpad = !ext_key;
\r
4584 /* Special modifiers for keypad keys */
\r
4585 if (numpad) Term_keypress('K');
\r
4587 /* Encode the hexidecimal scan code */
\r
4588 Term_keypress(hexsym[i/16]);
\r
4589 Term_keypress(hexsym[i%16]);
\r
4591 /* End the macro trigger */
\r
4592 Term_keypress(13);
\r
4602 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4603 WPARAM wParam, LPARAM lParam);
\r
4604 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4605 WPARAM wParam, LPARAM lParam)
\r
4606 #else /* __MWERKS__ */
\r
4607 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
4608 #endif /* __MWERKS__ */
\r
4614 MINMAXINFO FAR *lpmmi;
\r
4620 /* Acquire proper "term_data" info */
\r
4621 td = (term_data *)GetWindowLong(hWnd, 0);
\r
4623 /* Handle message */
\r
4628 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
4635 mop.dwCallback=(DWORD)hWnd;
\r
4640 case WM_GETMINMAXINFO:
\r
4642 MINMAXINFO FAR *lpmmi;
\r
4645 lpmmi = (MINMAXINFO FAR *)lParam;
\r
4647 /* this message was sent before WM_NCCREATE */
\r
4648 if (!td) return 1;
\r
4650 /* Minimum window size is 80x24 */
\r
4651 rc.left = rc.top = 0;
\r
4652 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
4653 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
4656 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
4658 /* Save minimum size */
\r
4659 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
4660 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
4667 BeginPaint(hWnd, &ps);
\r
4668 if (td) term_data_redraw(td);
\r
4669 EndPaint(hWnd, &ps);
\r
4670 ValidateRect(hWnd, NULL);
\r
4675 case MM_MCINOTIFY:
\r
4677 if(wParam == MCI_NOTIFY_SUCCESSFUL)
\r
4679 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
4680 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
4686 case WM_SYSKEYDOWN:
\r
4689 if (process_keydown(wParam, lParam))
\r
4696 if (Term_no_press) Term_no_press = FALSE;
\r
4697 else Term_keypress(wParam);
\r
4701 case WM_LBUTTONDOWN:
\r
4703 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4704 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4705 mouse_down = TRUE;
\r
4711 case WM_LBUTTONUP:
\r
4716 TERM_LEN dx = abs(oldx - mousex) + 1;
\r
4717 TERM_LEN dy = abs(oldy - mousey) + 1;
\r
4718 TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
\r
4719 TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
\r
4721 mouse_down = FALSE;
\r
4722 paint_rect = FALSE;
\r
4725 sz = (dx + 3) * dy;
\r
4727 sz = (dx + 2) * dy;
\r
4729 hGlobal = GlobalAlloc(GHND, sz + 1);
\r
4730 if (hGlobal == NULL) return 0;
\r
4731 lpStr = (LPSTR)GlobalLock(hGlobal);
\r
4733 for (i = 0; i < dy; i++)
\r
4737 char **scr = data[0].t.scr->c;
\r
4739 C_MAKE(s, (dx + 1), char);
\r
4740 strncpy(s, &scr[oy + i][ox], dx);
\r
4744 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
\r
4747 if (ox + dx < data[0].cols)
\r
4749 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
\r
4752 for (j = 0; j < dx; j++)
\r
4754 if (s[j] == 127) s[j] = '#';
\r
4758 for (j = 0; j < dx; j++)
\r
4760 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
\r
4770 GlobalUnlock(hGlobal);
\r
4771 if (OpenClipboard(hWnd) == 0)
\r
4773 GlobalFree(hGlobal);
\r
4777 SetClipboardData(CF_TEXT, hGlobal);
\r
4785 case WM_MOUSEMOVE:
\r
4790 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4791 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4796 dx = abs(oldx - mousex) + 1;
\r
4797 dy = abs(oldy - mousey) + 1;
\r
4798 ox = (oldx > mousex) ? mousex : oldx;
\r
4799 oy = (oldy > mousey) ? mousey : oldy;
\r
4800 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4804 paint_rect = TRUE;
\r
4807 dx = abs(cx - mousex) + 1;
\r
4808 dy = abs(cy - mousey) + 1;
\r
4809 ox = (cx > mousex) ? mousex : cx;
\r
4810 oy = (cy > mousey) ? mousey : cy;
\r
4811 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4827 if (game_in_progress && character_generated)
\r
4831 plog(_("今は終了できません。", "You may not do that right now."));
\r
4835 /* Hack -- Forget messages */
\r
4842 /* Save the game */
\r
4844 /* do_cmd_save_game(FALSE); */
\r
4845 #else /* ZANGBAND */
\r
4846 /* do_cmd_save_game(); */
\r
4847 #endif /* ZANGBAND */
\r
4848 Term_key_push(SPECIAL_KEY_QUIT);
\r
4855 case WM_QUERYENDSESSION:
\r
4857 if (game_in_progress && character_generated)
\r
4859 /* Hack -- Forget messages */
\r
4862 /* Mega-Hack -- Delay death */
\r
4863 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
\r
4864 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
\r
4866 /* Hardcode panic save */
\r
4867 p_ptr->panic_save = 1;
\r
4869 /* Forbid suspend */
\r
4870 signals_ignore_tstp();
\r
4872 /* Indicate panic save */
\r
4873 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
\r
4876 (void)save_player();
\r
4890 process_menus(LOWORD(wParam));
\r
4896 /* this message was sent before WM_NCCREATE */
\r
4897 if (!td) return 1;
\r
4899 /* it was sent from inside CreateWindowEx */
\r
4900 if (!td->w) return 1;
\r
4902 /* was sent from WM_SIZE */
\r
4903 if (td->size_hack) return 1;
\r
4907 case SIZE_MINIMIZED:
\r
4909 /* Hide sub-windows */
\r
4910 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4912 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
\r
4917 case SIZE_MAXIMIZED:
\r
4919 /* fall through */
\r
4922 case SIZE_RESTORED:
\r
4924 TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
4925 TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
4928 if ((td->cols != cols) || (td->rows != rows))
\r
4930 /* Save the new size */
\r
4934 if (!IsZoomed(td->w) && !IsIconic(td->w))
\r
4936 normsize.x = td->cols;
\r
4937 normsize.y = td->rows;
\r
4941 Term_activate(&td->t);
\r
4943 /* Resize the term */
\r
4944 Term_resize(td->cols, td->rows);
\r
4946 /* Redraw later */
\r
4947 InvalidateRect(td->w, NULL, TRUE);
\r
4950 td->size_hack = TRUE;
\r
4952 /* Show sub-windows */
\r
4953 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4955 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
\r
4958 td->size_hack = FALSE;
\r
4966 case WM_PALETTECHANGED:
\r
4968 /* Ignore if palette change caused by itself */
\r
4969 if ((HWND)wParam == hWnd) return 0;
\r
4971 /* Fall through... */
\r
4974 case WM_QUERYNEWPALETTE:
\r
4976 if (!paletted) return 0;
\r
4978 hdc = GetDC(hWnd);
\r
4980 SelectPalette(hdc, hPal, FALSE);
\r
4982 i = RealizePalette(hdc);
\r
4984 /* if any palette entries changed, repaint the window. */
\r
4985 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
4987 ReleaseDC(hWnd, hdc);
\r
4994 if (wParam && !HIWORD(lParam))
\r
4996 /* Do something to sub-windows */
\r
4997 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4999 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
\r
5002 /* Focus on main window */
\r
5011 case WM_ACTIVATEAPP:
\r
5013 if (IsIconic(td->w)) break;
\r
5015 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5017 if(data[i].visible)
\r
5019 if (wParam == TRUE)
\r
5021 ShowWindow(data[i].w, SW_SHOW);
\r
5025 ShowWindow(data[i].w, SW_HIDE);
\r
5032 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5037 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5038 WPARAM wParam, LPARAM lParam);
\r
5039 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5040 WPARAM wParam, LPARAM lParam)
\r
5041 #else /* __MWERKS__ */
\r
5042 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5043 WPARAM wParam, LPARAM lParam)
\r
5044 #endif /* __MWERKS__ */
\r
5048 MINMAXINFO FAR *lpmmi;
\r
5056 /* Acquire proper "term_data" info */
\r
5057 td = (term_data *)GetWindowLong(hWnd, 0);
\r
5059 /* Process message */
\r
5064 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
5073 case WM_GETMINMAXINFO:
\r
5075 MINMAXINFO FAR *lpmmi;
\r
5078 lpmmi = (MINMAXINFO FAR *)lParam;
\r
5080 /* this message was sent before WM_NCCREATE */
\r
5081 if (!td) return 1;
\r
5083 /* Minimum window size is 80x24 */
\r
5084 rc.left = rc.top = 0;
\r
5085 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
5086 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
5089 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
5091 /* Save minimum size */
\r
5092 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
5093 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
5103 /* this message was sent before WM_NCCREATE */
\r
5104 if (!td) return 1;
\r
5106 /* it was sent from inside CreateWindowEx */
\r
5107 if (!td->w) return 1;
\r
5109 /* was sent from inside WM_SIZE */
\r
5110 if (td->size_hack) return 1;
\r
5112 td->size_hack = TRUE;
\r
5114 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
5115 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
5118 if ((td->cols != cols) || (td->rows != rows))
\r
5120 /* Save old term */
\r
5121 term *old_term = Term;
\r
5123 /* Save the new size */
\r
5128 Term_activate(&td->t);
\r
5130 /* Resize the term */
\r
5131 Term_resize(td->cols, td->rows);
\r
5134 Term_activate(old_term);
\r
5136 /* Redraw later */
\r
5137 InvalidateRect(td->w, NULL, TRUE);
\r
5139 /* HACK - Redraw all windows */
\r
5140 p_ptr->window = 0xFFFFFFFF;
\r
5144 td->size_hack = FALSE;
\r
5151 BeginPaint(hWnd, &ps);
\r
5152 if (td) term_data_redraw(td);
\r
5153 EndPaint(hWnd, &ps);
\r
5157 case WM_SYSKEYDOWN:
\r
5160 if (process_keydown(wParam, lParam))
\r
5167 if (Term_no_press) Term_no_press = FALSE;
\r
5168 else Term_keypress(wParam);
\r
5172 case WM_PALETTECHANGED:
\r
5174 /* ignore if palette change caused by itself */
\r
5175 if ((HWND)wParam == hWnd) return FALSE;
\r
5176 /* otherwise, fall through!!! */
\r
5179 case WM_QUERYNEWPALETTE:
\r
5181 if (!paletted) return 0;
\r
5182 hdc = GetDC(hWnd);
\r
5183 SelectPalette(hdc, hPal, FALSE);
\r
5184 i = RealizePalette(hdc);
\r
5185 /* if any palette entries changed, repaint the window. */
\r
5186 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5187 ReleaseDC(hWnd, hdc);
\r
5191 case WM_NCLBUTTONDOWN:
\r
5195 if (wParam == HTCLOSE) wParam = HTSYSMENU;
\r
5196 #endif /* HTCLOSE */
\r
5198 if (wParam == HTSYSMENU)
\r
5202 td->visible = FALSE;
\r
5203 ShowWindow(td->w, SW_HIDE);
\r
5213 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5219 #define MOUSE_SENS 40
\r
5222 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5223 WPARAM wParam, LPARAM lParam);
\r
5224 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5225 WPARAM wParam, LPARAM lParam)
\r
5226 #else /* __MWERKS__ */
\r
5227 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5228 WPARAM wParam, LPARAM lParam)
\r
5229 #endif /* __MWERKS__ */
\r
5231 static int iMouse = 0;
\r
5232 static WORD xMouse = 0;
\r
5233 static WORD yMouse = 0;
\r
5246 case WM_SETCURSOR:
\r
5255 if (LOWORD(wParam) == WA_INACTIVE) break;
\r
5257 /* else fall through */
\r
5261 case WM_LBUTTONDOWN:
\r
5262 case WM_MBUTTONDOWN:
\r
5263 case WM_RBUTTONDOWN:
\r
5266 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5270 case WM_MOUSEMOVE:
\r
5274 dx = LOWORD(lParam) - xMouse;
\r
5275 dy = HIWORD(lParam) - yMouse;
\r
5277 if (dx < 0) dx = -dx;
\r
5278 if (dy < 0) dy = -dy;
\r
5280 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
\r
5282 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5286 /* Save last location */
\r
5288 xMouse = LOWORD(lParam);
\r
5289 yMouse = HIWORD(lParam);
\r
5296 DestroyWindow(hwndSaver);
\r
5302 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5305 #endif /* USE_SAVER */
\r
5311 /*** Temporary Hooks ***/
\r
5315 * Display warning message (see "z-util.c")
\r
5317 static void hack_plog(cptr str)
\r
5319 /* Give a warning */
\r
5323 MessageBox(NULL, str, "警告!",
\r
5324 MB_ICONEXCLAMATION | MB_OK);
\r
5326 MessageBox(NULL, str, "Warning",
\r
5327 MB_ICONEXCLAMATION | MB_OK);
\r
5335 * Display error message and quit (see "z-util.c")
\r
5337 static void hack_quit(cptr str)
\r
5339 /* Give a warning */
\r
5343 MessageBox(NULL, str, "エラー!",
\r
5344 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5346 MessageBox(NULL, str, "Error",
\r
5347 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5352 /* Unregister the classes */
\r
5353 UnregisterClass(AppName, hInstance);
\r
5355 /* Destroy the icon */
\r
5356 if (hIcon) DestroyIcon(hIcon);
\r
5364 /*** Various hooks ***/
\r
5368 * Display warning message (see "z-util.c")
\r
5370 static void hook_plog(cptr str)
\r
5376 MessageBox(data[0].w, str, "警告!",
\r
5377 MB_ICONEXCLAMATION | MB_OK);
\r
5379 MessageBox(data[0].w, str, "Warning",
\r
5380 MB_ICONEXCLAMATION | MB_OK);
\r
5388 * Display error message and quit (see "z-util.c")
\r
5390 static void hook_quit(cptr str)
\r
5395 /* Give a warning */
\r
5399 MessageBox(data[0].w, str, "エラー!",
\r
5400 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5402 MessageBox(data[0].w, str, "Error",
\r
5403 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5409 /* Save the preferences */
\r
5413 /*** Could use 'Term_nuke_win()' */
\r
5415 /* Destroy all windows */
\r
5416 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
\r
5418 term_force_font(&data[i], NULL);
\r
5419 if (data[i].font_want) string_free(data[i].font_want);
\r
5420 if (data[i].w) DestroyWindow(data[i].w);
\r
5424 /* Free the bitmap stuff */
\r
5425 #ifdef USE_GRAPHICS
\r
5426 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
\r
5427 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
\r
5429 if (infMask.hPalette) DeleteObject(infMask.hPalette);
\r
5430 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
\r
5432 #endif /* USE_GRAPHICS */
\r
5434 /*** Free some other stuff ***/
\r
5436 DeleteObject(hbrYellow);
\r
5441 if (hPal) DeleteObject(hPal);
\r
5443 UnregisterClass(AppName, hInstance);
\r
5445 if (hIcon) DestroyIcon(hIcon);
\r
5452 /*** Initialize ***/
\r
5458 static void init_stuff(void)
\r
5465 /* Get program name with full path */
\r
5466 GetModuleFileName(hInstance, path, 512);
\r
5468 /* Save the "program name" */
\r
5471 /* Get the name of the "*.ini" file */
\r
5472 strcpy(path + strlen(path) - 4, ".INI");
\r
5474 /* Save the the name of the ini-file */
\r
5475 ini_file = string_make(path);
\r
5477 /* Analyze the path */
\r
5480 /* Get the path */
\r
5481 for (; i > 0; i--)
\r
5483 if (path[i] == '\\')
\r
5490 /* Add "lib" to the path */
\r
5491 strcpy(path + i + 1, "lib\\");
\r
5493 /* Validate the path */
\r
5494 validate_dir(path, TRUE);
\r
5496 /* Init the file paths */
\r
5497 init_file_paths(path);
\r
5499 /* Hack -- Validate the paths */
\r
5500 validate_dir(ANGBAND_DIR_APEX, FALSE);
\r
5501 validate_dir(ANGBAND_DIR_BONE, FALSE);
\r
5503 /* Allow missing 'edit' directory */
\r
5504 if (!check_dir(ANGBAND_DIR_EDIT))
\r
5506 /* Must have 'data'! */
\r
5507 validate_dir(ANGBAND_DIR_DATA, TRUE);
\r
5511 /* Don't need 'data' */
\r
5512 validate_dir(ANGBAND_DIR_DATA, FALSE);
\r
5515 validate_dir(ANGBAND_DIR_FILE, TRUE);
\r
5516 validate_dir(ANGBAND_DIR_HELP, FALSE);
\r
5517 validate_dir(ANGBAND_DIR_INFO, FALSE);
\r
5518 validate_dir(ANGBAND_DIR_PREF, TRUE);
\r
5519 validate_dir(ANGBAND_DIR_SAVE, FALSE);
\r
5520 validate_dir(ANGBAND_DIR_USER, TRUE);
\r
5521 validate_dir(ANGBAND_DIR_XTRA, TRUE);
\r
5523 /* Build the filename */
\r
5524 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
\r
5526 /* Hack -- Validate the "news.txt" file */
\r
5527 validate_file(path);
\r
5530 #if 0 /* #ifndef JP */
\r
5531 /* Build the "font" path */
\r
5532 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
\r
5534 /* Allocate the path */
\r
5535 ANGBAND_DIR_XTRA_FONT = string_make(path);
\r
5537 /* Validate the "font" directory */
\r
5538 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
\r
5540 /* Build the filename */
\r
5541 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
5543 /* Hack -- Validate the basic font */
\r
5544 validate_file(path);
\r
5548 #ifdef USE_GRAPHICS
\r
5550 /* Build the "graf" path */
\r
5551 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
\r
5553 /* Allocate the path */
\r
5554 ANGBAND_DIR_XTRA_GRAF = string_make(path);
\r
5556 /* Validate the "graf" directory */
\r
5557 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
\r
5559 #endif /* USE_GRAPHICS */
\r
5564 /* Build the "sound" path */
\r
5565 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
\r
5567 /* Allocate the path */
\r
5568 ANGBAND_DIR_XTRA_SOUND = string_make(path);
\r
5570 /* Validate the "sound" directory */
\r
5571 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
\r
5573 #endif /* USE_SOUND */
\r
5577 /* Build the "music" path */
\r
5578 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
\r
5580 /* Allocate the path */
\r
5581 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
\r
5583 /* Validate the "music" directory */
\r
5584 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
\r
5586 #endif /* USE_MUSIC */
\r
5588 /* Build the "help" path */
\r
5589 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
\r
5591 /* Allocate the path */
\r
5592 ANGBAND_DIR_XTRA_HELP = string_make(path);
\r
5594 /* Validate the "help" directory */
\r
5595 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
\r
5599 * @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
\r
5601 static bool is_already_running(void)
\r
5603 bool result = FALSE;
\r
5606 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
\r
5607 if (GetLastError() == ERROR_ALREADY_EXISTS)
\r
5616 * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
\r
5618 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
\r
5619 LPSTR lpCmdLine, int nCmdShow)
\r
5627 setlocale( LC_ALL, "ja_JP" );
\r
5632 /* Save globally */
\r
5633 hInstance = hInst;
\r
5636 /* Prevent multiple run */
\r
5637 if (is_already_running())
\r
5640 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
\r
5641 _("エラー!", "Error") ,
\r
5642 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5647 if (hPrevInst == NULL)
\r
5649 wc.style = CS_CLASSDC;
\r
5650 wc.lpfnWndProc = AngbandWndProc;
\r
5651 wc.cbClsExtra = 0;
\r
5652 wc.cbWndExtra = 4; /* one long pointer to term_data */
\r
5653 wc.hInstance = hInst;
\r
5654 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
\r
5655 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
\r
5656 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
\r
5657 wc.lpszMenuName = AppName;
\r
5658 wc.lpszClassName = AppName;
\r
5660 if (!RegisterClass(&wc)) exit(1);
\r
5662 wc.lpfnWndProc = AngbandListProc;
\r
5663 wc.lpszMenuName = NULL;
\r
5664 wc.lpszClassName = AngList;
\r
5666 if (!RegisterClass(&wc)) exit(2);
\r
5670 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
\r
5671 wc.lpfnWndProc = AngbandSaverProc;
\r
5672 wc.hCursor = NULL;
\r
5673 wc.lpszMenuName = NULL;
\r
5674 wc.lpszClassName = "WindowsScreenSaverClass";
\r
5676 if (!RegisterClass(&wc)) exit(3);
\r
5682 /* Temporary hooks */
\r
5683 plog_aux = hack_plog;
\r
5684 quit_aux = hack_quit;
\r
5685 core_aux = hack_quit;
\r
5687 /* Prepare the filepaths */
\r
5690 /* Initialize the keypress analyzer */
\r
5691 for (i = 0; special_key_list[i]; ++i)
\r
5693 special_key[special_key_list[i]] = TRUE;
\r
5695 /* Initialize the keypress analyzer */
\r
5696 for (i = 0; ignore_key_list[i]; ++i)
\r
5698 ignore_key[ignore_key_list[i]] = TRUE;
\r
5701 /* Determine if display is 16/256/true color */
\r
5702 hdc = GetDC(NULL);
\r
5703 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
\r
5704 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
\r
5705 ReleaseDC(NULL, hdc);
\r
5707 /* Initialize the colors */
\r
5708 for (i = 0; i < 256; i++)
\r
5712 /* Extract desired values */
\r
5713 rv = angband_color_table[i][1];
\r
5714 gv = angband_color_table[i][2];
\r
5715 bv = angband_color_table[i][3];
\r
5717 /* Extract the "complex" code */
\r
5718 win_clr[i] = PALETTERGB(rv, gv, bv);
\r
5720 /* Save the "simple" code */
\r
5721 angband_color_table[i][0] = win_pal[i];
\r
5724 /* Prepare the windows */
\r
5730 /* Activate hooks */
\r
5731 plog_aux = hook_plog;
\r
5732 quit_aux = hook_quit;
\r
5733 core_aux = hook_quit;
\r
5735 /* Set the system suffix */
\r
5736 ANGBAND_SYS = "win";
\r
5738 /* Set the keyboard suffix */
\r
5739 if (7 != GetKeyboardType(0))
\r
5740 ANGBAND_KEYBOARD = "0";
\r
5743 /* Japanese keyboard */
\r
5744 switch (GetKeyboardType(1))
\r
5746 case 0x0D01: case 0x0D02:
\r
5747 case 0x0D03: case 0x0D04:
\r
5748 case 0x0D05: case 0x0D06:
\r
5750 ANGBAND_KEYBOARD = "NEC98";
\r
5754 ANGBAND_KEYBOARD = "JAPAN";
\r
5758 /* Catch nasty signals */
\r
5762 Term_activate(term_screen);
\r
5765 /* We are now initialized */
\r
5766 initialized = TRUE;
\r
5768 if(lpCmdLine[0] == '-'){
\r
5769 switch(lpCmdLine[1])
\r
5774 if (!lpCmdLine[2]) break;
\r
5775 chuukei_server = TRUE;
\r
5776 if(connect_chuukei_server(&lpCmdLine[2])<0){
\r
5777 msg_print("connect fail");
\r
5780 msg_print("connect");
\r
5788 if (!lpCmdLine[2]) break;
\r
5789 chuukei_client = TRUE;
\r
5790 connect_chuukei_server(&lpCmdLine[2]);
\r
5798 if (!lpCmdLine[2]) break;
\r
5799 prepare_browse_movie(&lpCmdLine[2]);
\r
5809 /* Did the user double click on a save file? */
\r
5810 if(!chuukei_server) check_for_save_file(lpCmdLine);
\r
5812 /* Did the user double click on a save file? */
\r
5813 check_for_save_file(lpCmdLine);
\r
5816 /* Prompt the user */
\r
5817 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
\r
5821 /* Process messages forever */
\r
5822 while (GetMessage(&msg, NULL, 0, 0))
\r
5824 TranslateMessage(&msg);
\r
5825 DispatchMessage(&msg);
\r
5836 #endif /* WINDOWS */
\r