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
908 * Check for existance of a file
\r
910 static bool check_file(cptr s)
\r
920 unsigned int attrib;
\r
930 attrib = GetFileAttributes(path);
\r
932 /* Require valid filename */
\r
933 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
935 /* Prohibit directory */
\r
936 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return (FALSE);
\r
940 /* Examine and verify */
\r
941 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
943 /* Prohibit something */
\r
944 if (attrib & FA_LABEL) return (FALSE);
\r
946 /* Prohibit directory */
\r
947 if (attrib & FA_DIREC) return (FALSE);
\r
957 * Check for existance of a directory
\r
959 static bool check_dir(cptr s)
\r
971 unsigned int attrib;
\r
981 /* Remove trailing backslash */
\r
982 if (i && (path[i-1] == '\\')) path[--i] = '\0';
\r
987 attrib = GetFileAttributes(path);
\r
989 /* Require valid filename */
\r
990 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
992 /* Require directory */
\r
993 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE);
\r
997 /* Examine and verify */
\r
998 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
1000 /* Prohibit something */
\r
1001 if (attrib & FA_LABEL) return (FALSE);
\r
1003 /* Require directory */
\r
1004 if (!(attrib & FA_DIREC)) return (FALSE);
\r
1006 #endif /* WIN32 */
\r
1016 static void validate_file(cptr s)
\r
1018 /* Verify or fail */
\r
1019 if (!check_file(s))
\r
1021 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
\r
1027 * Validate a directory
\r
1029 static void validate_dir(cptr s, bool vital)
\r
1031 /* Verify or fail */
\r
1032 if (!check_dir(s))
\r
1034 /* This directory contains needed data */
\r
1037 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
\r
1039 /* Attempt to create this directory */
\r
1040 else if (mkdir(s))
\r
1042 quit_fmt("Unable to create directory:\n%s", s);
\r
1049 * @brief (Windows版固有実装)Get the "size" for a window
\r
1051 static void term_getsize(term_data *td)
\r
1054 TERM_LEN wid, hgt;
\r
1057 if (td->cols < 1) td->cols = 1;
\r
1058 if (td->rows < 1) td->rows = 1;
\r
1060 /* Window sizes */
\r
1061 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
1062 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
\r
1064 /* Fake window size */
\r
1066 rc.right = rc.left + wid;
\r
1068 rc.bottom = rc.top + hgt;
\r
1070 /* rc.right += 1; */
\r
1071 /* rc.bottom += 1; */
\r
1074 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
1077 td->size_wid = rc.right - rc.left;
\r
1078 td->size_hgt = rc.bottom - rc.top;
\r
1080 /* See CreateWindowEx */
\r
1081 if (!td->w) return;
\r
1083 /* Extract actual location */
\r
1084 GetWindowRect(td->w, &rc);
\r
1086 /* Save the location */
\r
1087 td->pos_x = rc.left;
\r
1088 td->pos_y = rc.top;
\r
1093 * Write the "prefs" for a single term
\r
1095 static void save_prefs_aux(int i)
\r
1097 term_data *td = &data[i];
\r
1098 char sec_name[128];
\r
1102 WINDOWPLACEMENT lpwndpl;
\r
1105 if (!td->w) return;
\r
1107 /* Make section name */
\r
1108 sprintf(sec_name, "Term-%d", i);
\r
1113 strcpy(buf, td->visible ? "1" : "0");
\r
1114 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
\r
1119 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "MS ゴシック");
\r
1122 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
\r
1124 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
\r
1128 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
\r
1130 #if 1 /* #ifdef JP */
\r
1131 wsprintf(buf, "%d", td->lf.lfWidth);
\r
1132 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
\r
1133 wsprintf(buf, "%d", td->lf.lfHeight);
\r
1134 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
\r
1135 wsprintf(buf, "%d", td->lf.lfWeight);
\r
1136 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
\r
1139 strcpy(buf, td->bizarre ? "1" : "0");
\r
1140 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
\r
1142 /* Tile size (x) */
\r
1143 wsprintf(buf, "%d", td->tile_wid);
\r
1144 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
\r
1146 /* Tile size (y) */
\r
1147 wsprintf(buf, "%d", td->tile_hgt);
\r
1148 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
\r
1150 /* Get window placement and dimensions */
\r
1151 lpwndpl.length = sizeof(WINDOWPLACEMENT);
\r
1152 GetWindowPlacement(td->w, &lpwndpl);
\r
1154 /* Acquire position in *normal* mode (not minimized) */
\r
1155 rc = lpwndpl.rcNormalPosition;
\r
1157 /* Window size (x) */
\r
1158 if (i == 0) wsprintf(buf, "%d", normsize.x);
\r
1159 else wsprintf(buf, "%d", td->cols);
\r
1160 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
\r
1162 /* Window size (y) */
\r
1163 if (i == 0) wsprintf(buf, "%d", normsize.y);
\r
1164 else wsprintf(buf, "%d", td->rows);
\r
1165 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
\r
1167 /* Maxmized (only main window) */
\r
1170 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
\r
1171 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
\r
1174 /* Acquire position */
\r
1175 GetWindowRect(td->w, &rc);
\r
1177 /* Window position (x) */
\r
1178 wsprintf(buf, "%d", rc.left);
\r
1179 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
\r
1181 /* Window position (y) */
\r
1182 wsprintf(buf, "%d", rc.top);
\r
1183 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
\r
1185 /* Window Z position */
\r
1188 strcpy(buf, td->posfix ? "1" : "0");
\r
1189 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
\r
1195 * Write the "prefs"
\r
1196 * We assume that the windows have all been initialized
\r
1198 static void save_prefs(void)
\r
1204 /* Save the "arg_graphics" flag */
\r
1205 sprintf(buf, "%d", arg_graphics);
\r
1206 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
\r
1208 /* Save the "arg_bigtile" flag */
\r
1209 strcpy(buf, arg_bigtile ? "1" : "0");
\r
1210 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
\r
1212 /* Save the "arg_sound" flag */
\r
1213 strcpy(buf, arg_sound ? "1" : "0");
\r
1214 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
\r
1216 /* Save the "arg_sound" flag */
\r
1217 strcpy(buf, arg_music ? "1" : "0");
\r
1218 WritePrivateProfileString("Angband", "Music", buf, ini_file);
\r
1221 strcpy(buf, use_bg ? "1" : "0");
\r
1222 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
\r
1223 WritePrivateProfileString("Angband", "BackGroundBitmap",
\r
1224 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
\r
1226 /* Save window prefs */
\r
1227 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1229 save_prefs_aux(i);
\r
1235 * Load the "prefs" for a single term
\r
1237 static void load_prefs_aux(int i)
\r
1239 term_data *td = &data[i];
\r
1240 char sec_name[128];
\r
1243 int wid, hgt, posx, posy;
\r
1244 int dispx = GetSystemMetrics( SM_CXVIRTUALSCREEN);
\r
1245 int dispy = GetSystemMetrics( SM_CYVIRTUALSCREEN);
\r
1249 /* Make section name */
\r
1250 sprintf(sec_name, "Term-%d", i);
\r
1252 /* Make section name */
\r
1253 sprintf(sec_name, "Term-%d", i);
\r
1258 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
\r
1261 /* Desired font, with default */
\r
1263 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
\r
1266 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
\r
1268 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
\r
1274 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
\r
1276 /* Analyze font, save desired font name */
\r
1277 #if 1 /* #ifdef JP */
\r
1278 td->font_want = string_make(tmp);
\r
1279 hgt = 15; wid = 0;
\r
1280 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
\r
1281 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
\r
1282 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
\r
1284 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
\r
1289 #if 1 /* #ifdef JP */
\r
1290 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
\r
1291 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
\r
1293 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
\r
1294 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
\r
1299 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
\r
1300 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
\r
1301 normsize.x = td->cols; normsize.y = td->rows;
\r
1306 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
\r
1309 /* Window position */
\r
1310 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
\r
1311 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
\r
1312 td->pos_x = MIN(MAX(0, posx), dispx-128);
\r
1313 td->pos_y = MIN(MAX(0, posy), dispy-128);
\r
1315 /* Window Z position */
\r
1318 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
\r
1324 * Load the "prefs"
\r
1326 static void load_prefs(void)
\r
1330 /* Extract the "arg_graphics" flag */
\r
1331 arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
\r
1333 /* Extract the "arg_bigtile" flag */
\r
1334 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
\r
1335 use_bigtile = arg_bigtile;
\r
1337 /* Extract the "arg_sound" flag */
\r
1338 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
\r
1340 /* Extract the "arg_sound" flag */
\r
1341 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
\r
1344 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
\r
1345 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
\r
1347 /* Load window prefs */
\r
1348 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1350 load_prefs_aux(i);
\r
1354 #if defined(USE_SOUND) || defined(USE_MUSIC)
\r
1357 * - Taken from files.c.
\r
1359 * Extract "tokens" from a buffer
\r
1361 * This function uses "whitespace" as delimiters, and treats any amount of
\r
1362 * whitespace as a single delimiter. We will never return any empty tokens.
\r
1363 * When given an empty buffer, or a buffer containing only "whitespace", we
\r
1364 * will return no tokens. We will never extract more than "num" tokens.
\r
1366 * By running a token through the "text_to_ascii()" function, you can allow
\r
1367 * that token to include (encoded) whitespace, using "\s" to encode spaces.
\r
1369 * We save pointers to the tokens in "tokens", and return the number found.
\r
1371 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
\r
1381 /* Skip leading whitespace */
\r
1382 for ( ; *s && iswspace(*s); ++s) /* loop */;
\r
1387 /* Find next whitespace, if any */
\r
1388 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
\r
1390 /* Nuke and advance (if necessary) */
\r
1391 if (*t) *t++ = '\0';
\r
1393 /* Save the token */
\r
1404 #endif /* USE_SOUND || USE_MUSIC */
\r
1408 static void load_sound_prefs(void)
\r
1412 char ini_path[1024];
\r
1413 char wav_path[1024];
\r
1414 char *zz[SAMPLE_MAX];
\r
1416 /* Access the sound.cfg */
\r
1418 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
\r
1420 for (i = 0; i < SOUND_MAX; i++)
\r
1422 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
\r
1424 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
\r
1426 for (j = 0; j < num; j++)
\r
1428 /* Access the sound */
\r
1429 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
\r
1431 /* Save the sound filename, if it exists */
\r
1432 if (check_file(wav_path))
\r
1433 sound_file[i][j] = string_make(zz[j]);
\r
1438 #endif /* USE_SOUND */
\r
1442 static void load_music_prefs(void)
\r
1446 char ini_path[1024];
\r
1447 char wav_path[1024];
\r
1448 char *zz[SAMPLE_MAX];
\r
1451 /* Access the music.cfg */
\r
1453 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
\r
1455 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
\r
1457 for (i = 0; i < MUSIC_BASIC_MAX; i++)
\r
1459 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
\r
1461 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1463 for (j = 0; j < num; j++)
\r
1465 /* Access the sound */
\r
1466 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1468 /* Save the sound filename, if it exists */
\r
1469 if (check_file(wav_path))
\r
1470 music_file[i][j] = string_make(zz[j]);
\r
1474 for (i = 0; i < max_d_idx; i++)
\r
1476 sprintf(key, "dungeon%03d", i);
\r
1477 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
\r
1479 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1481 for (j = 0; j < num; j++)
\r
1483 /* Access the sound */
\r
1484 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1486 /* Save the sound filename, if it exists */
\r
1487 if (check_file(wav_path))
\r
1488 dungeon_music_file[i][j] = string_make(zz[j]);
\r
1492 for (i = 0; i < max_q_idx; i++)
\r
1494 sprintf(key, "quest%03d", i);
\r
1495 GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
\r
1497 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1499 for (j = 0; j < num; j++)
\r
1501 /* Access the sound */
\r
1502 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1504 /* Save the sound filename, if it exists */
\r
1505 if (check_file(wav_path))
\r
1506 quest_music_file[i][j] = string_make(zz[j]);
\r
1510 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
\r
1512 sprintf(key, "town%03d", i);
\r
1513 GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
\r
1515 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1517 for (j = 0; j < num; j++)
\r
1519 /* Access the sound */
\r
1520 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1522 /* Save the sound filename, if it exists */
\r
1523 if (check_file(wav_path))
\r
1524 town_music_file[i][j] = string_make(zz[j]);
\r
1531 #endif /* USE_MUSIC */
\r
1534 * Create the new global palette based on the bitmap palette
\r
1535 * (if any), and the standard 16 entry palette derived from
\r
1536 * "win_clr[]" which is used for the basic 16 Angband colors.
\r
1538 * This function is never called before all windows are ready.
\r
1540 * This function returns FALSE if the new palette could not be
\r
1541 * prepared, which should normally be a fatal error. XXX XXX
\r
1543 * Note that only some machines actually use a "palette".
\r
1545 static int new_palette(void)
\r
1553 LPLOGPALETTE pLogPal;
\r
1554 LPPALETTEENTRY lppe;
\r
1559 /* This makes no sense */
\r
1560 if (!paletted) return (TRUE);
\r
1568 #ifdef USE_GRAPHICS
\r
1570 /* Check the bitmap palette */
\r
1571 hBmPal = infGraph.hPalette;
\r
1573 /* Use the bitmap */
\r
1576 lppeSize = 256 * sizeof(PALETTEENTRY);
\r
1577 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
\r
1578 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
\r
1579 if ((nEntries == 0) || (nEntries > 220))
\r
1581 /* Warn the user */
\r
1582 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
\r
1585 rnfree(lppe, lppeSize);
\r
1592 #endif /* USE_GRAPHICS */
\r
1594 /* Size of palette */
\r
1595 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
\r
1597 /* Allocate palette */
\r
1598 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
\r
1601 pLogPal->palVersion = 0x300;
\r
1603 /* Make room for bitmap and normal data */
\r
1604 pLogPal->palNumEntries = nEntries + 16;
\r
1606 /* Save the bitmap data */
\r
1607 for (i = 0; i < nEntries; i++)
\r
1609 pLogPal->palPalEntry[i] = lppe[i];
\r
1612 /* Save the normal data */
\r
1613 for (i = 0; i < 16; i++)
\r
1617 /* Access the entry */
\r
1618 p = &(pLogPal->palPalEntry[i+nEntries]);
\r
1620 /* Save the colors */
\r
1621 p->peRed = GetRValue(win_clr[i]);
\r
1622 p->peGreen = GetGValue(win_clr[i]);
\r
1623 p->peBlue = GetBValue(win_clr[i]);
\r
1625 /* Save the flags */
\r
1626 p->peFlags = PC_NOCOLLAPSE;
\r
1629 /* Free something */
\r
1630 if (lppe) rnfree(lppe, lppeSize);
\r
1632 /* Create a new palette, or fail */
\r
1633 hNewPal = CreatePalette(pLogPal);
\r
1634 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
\r
1636 /* Free the palette */
\r
1637 rnfree(pLogPal, pLogPalSize);
\r
1642 /* Realize the palette */
\r
1643 hdc = GetDC(td->w);
\r
1644 SelectPalette(hdc, hNewPal, 0);
\r
1645 i = RealizePalette(hdc);
\r
1646 ReleaseDC(td->w, hdc);
\r
1647 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
\r
1651 for (i = 1; i < MAX_TERM_DATA; i++)
\r
1655 hdc = GetDC(td->w);
\r
1656 SelectPalette(hdc, hNewPal, 0);
\r
1657 ReleaseDC(td->w, hdc);
\r
1660 /* Delete old palette */
\r
1661 if (hPal) DeleteObject(hPal);
\r
1663 /* Save new palette */
\r
1671 #ifdef USE_GRAPHICS
\r
1673 * @brief グラフィクスを初期化する / Initialize graphics
\r
1676 * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
\r
1677 * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
\r
1680 static bool init_graphics(void)
\r
1682 /* Initialize once */
\r
1684 BYTE wid, hgt, twid, thgt, ox, oy;
\r
1687 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1695 name = "16X16.BMP";
\r
1697 ANGBAND_GRAF = "new";
\r
1699 else if (arg_graphics == GRAPHICS_HENGBAND)
\r
1708 name = "64X64.BMP";
\r
1717 name = "32X32.BMP";
\r
1719 ANGBAND_GRAF = "ne2";
\r
1730 ANGBAND_GRAF = "old";
\r
1733 /* Access the bitmap file */
\r
1734 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
\r
1736 /* Load the bitmap or quit */
\r
1737 if (!ReadDIB(data[0].w, buf, &infGraph))
\r
1739 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
\r
1743 /* Save the new sizes */
\r
1744 infGraph.CellWidth = wid;
\r
1745 infGraph.CellHeight = hgt;
\r
1746 infGraph.TileWidth = twid;
\r
1747 infGraph.TileHeight = thgt;
\r
1748 infGraph.OffsetX = ox;
\r
1749 infGraph.OffsetY = oy;
\r
1751 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1753 /* Access the mask file */
\r
1754 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
\r
1756 /* Load the bitmap or quit */
\r
1757 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1759 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1763 if (arg_graphics == GRAPHICS_HENGBAND)
\r
1765 /* Access the mask file */
\r
1766 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
\r
1768 /* Load the bitmap or quit */
\r
1769 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1771 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1776 /* Activate a palette */
\r
1777 if (!new_palette())
\r
1781 plog(_("パレットを実現できません!", "Cannot activate palette!"));
\r
1785 /* Graphics available */
\r
1786 current_graphics_mode = arg_graphics;
\r
1787 return (current_graphics_mode);
\r
1789 #endif /* USE_GRAPHICS */
\r
1794 * Initialize music
\r
1796 static bool init_music(void)
\r
1798 /* Initialize once */
\r
1799 if (!can_use_music)
\r
1801 /* Load the prefs */
\r
1802 load_music_prefs();
\r
1804 /* Sound available */
\r
1805 can_use_music = TRUE;
\r
1807 return (can_use_music);
\r
1811 * Hack -- Stop a music
\r
1813 static void stop_music(void)
\r
1815 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
1816 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
1819 #endif /* USE_MUSIC */
\r
1823 * Initialize sound
\r
1825 static bool init_sound(void)
\r
1827 /* Initialize once */
\r
1828 if (!can_use_sound)
\r
1830 /* Load the prefs */
\r
1831 load_sound_prefs();
\r
1833 /* Sound available */
\r
1834 can_use_sound = TRUE;
\r
1836 return (can_use_sound);
\r
1838 #endif /* USE_SOUND */
\r
1844 static void term_window_resize(term_data *td)
\r
1846 /* Require window */
\r
1847 if (!td->w) return;
\r
1849 /* Resize the window */
\r
1850 SetWindowPos(td->w, 0, 0, 0,
\r
1851 td->size_wid, td->size_hgt,
\r
1852 SWP_NOMOVE | SWP_NOZORDER);
\r
1854 /* Redraw later */
\r
1855 InvalidateRect(td->w, NULL, TRUE);
\r
1860 * Force the use of a new "font file" for a term_data
\r
1862 * This function may be called before the "window" is ready
\r
1864 * This function returns zero only if everything succeeds.
\r
1866 * Note that the "font name" must be capitalized!!!
\r
1868 static errr term_force_font(term_data *td, cptr path)
\r
1872 #if 0 /* #ifndef JP */
\r
1878 /* Forget the old font (if needed) */
\r
1879 if (td->font_id) DeleteObject(td->font_id);
\r
1881 #if 1 /* #ifdef JP */
\r
1885 /* Create the font (using the 'base' of the font file name!) */
\r
1886 td->font_id = CreateFontIndirect(&(td->lf));
\r
1887 wid = td->lf.lfWidth;
\r
1888 hgt = td->lf.lfHeight;
\r
1889 if (!td->font_id) return (1);
\r
1891 /* Forget old font */
\r
1892 if (td->font_file)
\r
1894 bool used = FALSE;
\r
1896 /* Scan windows */
\r
1897 for (i = 0; i < MAX_TERM_DATA; i++)
\r
1899 /* Don't check when closing the application */
\r
1902 /* Check "screen" */
\r
1903 if ((td != &data[i]) &&
\r
1904 (data[i].font_file) &&
\r
1905 (streq(data[i].font_file, td->font_file)))
\r
1911 /* Remove unused font resources */
\r
1912 if (!used) RemoveFontResource(td->font_file);
\r
1914 /* Free the old name */
\r
1915 string_free(td->font_file);
\r
1918 td->font_file = NULL;
\r
1921 /* No path given */
\r
1922 if (!path) return (1);
\r
1925 strcpy(buf, path);
\r
1927 /* Analyze font path */
\r
1928 base = analyze_font(buf, &wid, &hgt);
\r
1930 /* Verify suffix */
\r
1931 if (!suffix(base, ".FON")) return (1);
\r
1934 if (!check_file(buf)) return (1);
\r
1936 /* Load the new font */
\r
1937 if (!AddFontResource(buf)) return (1);
\r
1939 /* Save new font name */
\r
1940 td->font_file = string_make(base);
\r
1942 /* Remove the "suffix" */
\r
1943 base[strlen(base)-4] = '\0';
\r
1945 /* Create the font (using the 'base' of the font file name!) */
\r
1946 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
\r
1947 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
\r
1948 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
\r
1949 FIXED_PITCH | FF_DONTCARE, base);
\r
1952 /* Hack -- Unknown size */
\r
1959 /* all this trouble to get the cell size */
\r
1960 hdcDesktop = GetDC(HWND_DESKTOP);
\r
1961 hfOld = SelectObject(hdcDesktop, td->font_id);
\r
1962 GetTextMetrics(hdcDesktop, &tm);
\r
1963 SelectObject(hdcDesktop, hfOld);
\r
1964 ReleaseDC(HWND_DESKTOP, hdcDesktop);
\r
1966 /* Font size info */
\r
1967 wid = tm.tmAveCharWidth;
\r
1968 hgt = tm.tmHeight;
\r
1971 /* Save the size info */
\r
1972 td->font_wid = wid;
\r
1973 td->font_hgt = hgt;
\r
1982 * Allow the user to change the font for this window.
\r
1984 static void term_change_font(term_data *td)
\r
1986 #if 1 /* #ifdef JP */
\r
1989 memset(&cf, 0, sizeof(cf));
\r
1990 cf.lStructSize = sizeof(cf);
\r
1991 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
\r
1992 cf.lpLogFont = &(td->lf);
\r
1994 if (ChooseFont(&cf))
\r
1996 /* Force the font */
\r
1997 term_force_font(td, NULL);
\r
1999 /* Assume not bizarre */
\r
2000 td->bizarre = TRUE;
\r
2002 /* Reset the tile info */
\r
2003 td->tile_wid = td->font_wid;
\r
2004 td->tile_hgt = td->font_hgt;
\r
2006 /* Analyze the font */
\r
2009 /* Resize the window */
\r
2010 term_window_resize(td);
\r
2016 char tmp[1024] = "";
\r
2018 /* Extract a default if possible */
\r
2019 if (td->font_file) strcpy(tmp, td->font_file);
\r
2021 /* Ask for a choice */
\r
2022 memset(&ofn, 0, sizeof(ofn));
\r
2023 ofn.lStructSize = sizeof(ofn);
\r
2024 ofn.hwndOwner = data[0].w;
\r
2025 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
\r
2026 ofn.nFilterIndex = 1;
\r
2027 ofn.lpstrFile = tmp;
\r
2028 ofn.nMaxFile = 128;
\r
2029 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
\r
2030 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
2031 ofn.lpstrDefExt = "fon";
\r
2033 /* Force choice if legal */
\r
2034 if (GetOpenFileName(&ofn))
\r
2036 /* Force the font */
\r
2037 if (term_force_font(td, tmp))
\r
2039 /* Access the standard font file */
\r
2040 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
2042 /* Force the use of that font */
\r
2043 (void)term_force_font(td, tmp);
\r
2046 /* Assume not bizarre */
\r
2047 td->bizarre = FALSE;
\r
2049 /* Reset the tile info */
\r
2050 td->tile_wid = td->font_wid;
\r
2051 td->tile_hgt = td->font_hgt;
\r
2053 /* Analyze the font */
\r
2056 /* Resize the window */
\r
2057 term_window_resize(td);
\r
2064 * Allow the user to lock this window.
\r
2066 static void term_window_pos(term_data *td, HWND hWnd)
\r
2068 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
\r
2069 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
\r
2072 static void windows_map(void);
\r
2075 * Hack -- redraw a term_data
\r
2077 static void term_data_redraw(term_data *td)
\r
2079 if (td->map_active)
\r
2081 /* Redraw the map */
\r
2086 /* Activate the term */
\r
2087 Term_activate(&td->t);
\r
2089 /* Redraw the contents */
\r
2092 /* Restore the term */
\r
2093 Term_activate(term_screen);
\r
2098 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
\r
2102 HBRUSH myBrush, oldBrush;
\r
2104 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
\r
2105 int tx = td->size_ow1 + x * td->tile_wid;
\r
2106 int ty = td->size_oh1 + y * td->tile_hgt;
\r
2107 int tw = w * td->tile_wid - 1;
\r
2108 int th = h * td->tile_hgt - 1;
\r
2110 hdc = GetDC(hWnd);
\r
2111 myBrush = CreateSolidBrush(RGB(255, 255, 255));
\r
2112 oldBrush = SelectObject(hdc, myBrush);
\r
2113 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2115 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
\r
2117 SelectObject(hdc, oldBrush);
\r
2118 SelectObject(hdc, oldPen);
\r
2123 /*** Function hooks needed by "Term" ***/
\r
2129 * Initialize a new Term
\r
2131 static void Term_init_win(term *t)
\r
2138 * Nuke an old Term
\r
2140 static void Term_nuke_win(term *t)
\r
2149 * @brief //!< Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
\r
2151 static errr Term_user_win(int n)
\r
2162 * React to global changes
\r
2164 static errr Term_xtra_win_react(void)
\r
2168 /* Simple color */
\r
2171 /* Save the default colors */
\r
2172 for (i = 0; i < 256; i++)
\r
2174 /* Simply accept the desired colors */
\r
2175 win_pal[i] = angband_color_table[i][0];
\r
2179 /* Complex color */
\r
2186 bool change = FALSE;
\r
2188 /* Save the default colors */
\r
2189 for (i = 0; i < 256; i++)
\r
2191 /* Extract desired values */
\r
2192 rv = angband_color_table[i][1];
\r
2193 gv = angband_color_table[i][2];
\r
2194 bv = angband_color_table[i][3];
\r
2196 /* Extract a full color code */
\r
2197 code = PALETTERGB(rv, gv, bv);
\r
2199 /* Activate changes */
\r
2200 if (win_clr[i] != code)
\r
2202 /* Note the change */
\r
2205 /* Apply the desired color */
\r
2206 win_clr[i] = code;
\r
2210 /* Activate the palette if needed */
\r
2211 if (change) (void)new_palette();
\r
2217 /* Handle "arg_sound" */
\r
2218 if (use_sound != arg_sound)
\r
2220 /* Initialize (if needed) */
\r
2221 if (arg_sound && !init_sound())
\r
2224 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
\r
2226 /* Cannot enable */
\r
2227 arg_sound = FALSE;
\r
2230 /* Change setting */
\r
2231 use_sound = arg_sound;
\r
2238 /* Handle "arg_sound" */
\r
2239 if (use_music != arg_music)
\r
2241 /* Initialize (if needed) */
\r
2242 if (arg_music && !init_music())
\r
2245 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
\r
2246 /* Cannot enable */
\r
2247 arg_music = FALSE;
\r
2250 /* Change setting */
\r
2251 use_music = arg_music;
\r
2253 if(!arg_music) stop_music();
\r
2254 else select_floor_music();
\r
2261 #ifdef USE_GRAPHICS
\r
2263 /* Handle "arg_graphics" */
\r
2264 if (use_graphics != arg_graphics)
\r
2266 /* Initialize (if needed) */
\r
2267 if (arg_graphics && !init_graphics())
\r
2270 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
\r
2272 /* Cannot enable */
\r
2273 arg_graphics = GRAPHICS_NONE;
\r
2276 /* Change setting */
\r
2277 use_graphics = arg_graphics;
\r
2279 /* Reset visuals */
\r
2280 #ifdef ANGBAND_2_8_1
\r
2282 #else /* ANGBAND_2_8_1 */
\r
2283 reset_visuals(TRUE);
\r
2284 #endif /* ANGBAND_2_8_1 */
\r
2287 #endif /* USE_GRAPHICS */
\r
2290 /* Clean up windows */
\r
2291 for (i = 0; i < MAX_TERM_DATA; i++)
\r
2295 term_data *td = &data[i];
\r
2297 /* Update resized windows */
\r
2298 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
\r
2301 Term_activate(&td->t);
\r
2303 /* Hack -- Resize the term */
\r
2304 Term_resize(td->cols, td->rows);
\r
2306 /* Redraw the contents */
\r
2310 Term_activate(old);
\r
2321 * Process at least one event
\r
2323 static errr Term_xtra_win_event(int v)
\r
2327 /* Wait for an event */
\r
2331 if (GetMessage(&msg, NULL, 0, 0))
\r
2333 TranslateMessage(&msg);
\r
2334 DispatchMessage(&msg);
\r
2338 /* Check for an event */
\r
2342 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2344 TranslateMessage(&msg);
\r
2345 DispatchMessage(&msg);
\r
2355 * Process all pending events
\r
2357 static errr Term_xtra_win_flush(void)
\r
2361 /* Process all pending events */
\r
2362 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2364 TranslateMessage(&msg);
\r
2365 DispatchMessage(&msg);
\r
2374 * Hack -- clear the screen
\r
2376 * Make this more efficient
\r
2378 static errr Term_xtra_win_clear(void)
\r
2380 term_data *td = (term_data*)(Term->data);
\r
2385 /* Rectangle to erase */
\r
2386 rc.left = td->size_ow1;
\r
2387 rc.right = rc.left + td->cols * td->tile_wid;
\r
2388 rc.top = td->size_oh1;
\r
2389 rc.bottom = rc.top + td->rows * td->tile_hgt;
\r
2392 hdc = GetDC(td->w);
\r
2393 SetBkColor(hdc, RGB(0, 0, 0));
\r
2394 SelectObject(hdc, td->font_id);
\r
2395 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2400 rc.left = 0; rc.top = 0;
\r
2403 ReleaseDC(td->w, hdc);
\r
2411 * Hack -- make a noise
\r
2413 static errr Term_xtra_win_noise(void)
\r
2415 MessageBeep(MB_ICONASTERISK);
\r
2421 * Hack -- make a sound
\r
2423 static errr Term_xtra_win_sound(int v)
\r
2428 #endif /* USE_SOUND */
\r
2430 /* Sound disabled */
\r
2431 if (!use_sound) return (1);
\r
2433 /* Illegal sound */
\r
2434 if ((v < 0) || (v >= SOUND_MAX)) return (1);
\r
2438 /* Count the samples */
\r
2439 for (i = 0; i < SAMPLE_MAX; i++)
\r
2441 if (!sound_file[v][i])
\r
2446 if (i == 0) return (1);
\r
2448 /* Build the path */
\r
2449 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
\r
2453 /* Play the sound, catch errors */
\r
2454 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
\r
2458 /* Play the sound, catch errors */
\r
2459 return (sndPlaySound(buf, SND_ASYNC));
\r
2461 #endif /* WIN32 */
\r
2463 #else /* USE_SOUND */
\r
2467 #endif /* USE_SOUND */
\r
2471 * Hack -- play a music
\r
2473 static errr Term_xtra_win_music(int n, int v)
\r
2478 #endif /* USE_MUSIC */
\r
2480 /* Sound disabled */
\r
2482 if(!use_music) return (1);
\r
2484 /* Illegal sound */
\r
2485 if(n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return (1);
\r
2486 else if(v < 0 || v >= 1000) return(1); /*!< TODO */
\r
2492 case TERM_XTRA_MUSIC_BASIC:
\r
2493 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2495 case TERM_XTRA_MUSIC_DUNGEON:
\r
2496 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2498 case TERM_XTRA_MUSIC_QUEST:
\r
2499 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2501 case TERM_XTRA_MUSIC_TOWN:
\r
2502 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2509 //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2510 //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2516 case TERM_XTRA_MUSIC_BASIC:
\r
2517 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2519 case TERM_XTRA_MUSIC_DUNGEON:
\r
2520 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2522 case TERM_XTRA_MUSIC_QUEST:
\r
2523 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2525 case TERM_XTRA_MUSIC_TOWN:
\r
2526 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2533 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2534 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2540 case TERM_XTRA_MUSIC_BASIC:
\r
2541 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
\r
2543 case TERM_XTRA_MUSIC_DUNGEON:
\r
2544 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
\r
2546 case TERM_XTRA_MUSIC_QUEST:
\r
2547 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
\r
2549 case TERM_XTRA_MUSIC_TOWN:
\r
2550 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
\r
2554 if(current_music_type == n && current_music_id == v)
\r
2558 current_music_type = n;
\r
2559 current_music_id = v;
\r
2563 mop.lpstrDeviceType = mci_device_type;
\r
2564 mop.lpstrElementName = buf;
\r
2565 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2566 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2567 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
\r
2568 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
2569 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
2572 #endif /* WIN32 */
\r
2574 #else /* USE_MUSIC */
\r
2578 #endif /* USE_MUSIC */
\r
2584 * Delay for "x" milliseconds
\r
2586 static int Term_xtra_win_delay(int v)
\r
2600 t = GetTickCount() + v;
\r
2603 while (GetTickCount() < t)
\r
2605 /* Handle messages */
\r
2606 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2608 TranslateMessage(&msg);
\r
2609 DispatchMessage(&msg);
\r
2613 #endif /* WIN32 */
\r
2621 * Do a "special thing"
\r
2623 static errr Term_xtra_win(int n, int v)
\r
2625 /* Handle a subset of the legal requests */
\r
2628 /* Make a bell sound */
\r
2629 case TERM_XTRA_NOISE:
\r
2631 return (Term_xtra_win_noise());
\r
2634 /* Play a music */
\r
2635 case TERM_XTRA_MUSIC_BASIC:
\r
2636 case TERM_XTRA_MUSIC_DUNGEON:
\r
2637 case TERM_XTRA_MUSIC_QUEST:
\r
2638 case TERM_XTRA_MUSIC_TOWN:
\r
2640 return (Term_xtra_win_music(n, v));
\r
2643 /* Make a special sound */
\r
2644 case TERM_XTRA_SOUND:
\r
2646 return (Term_xtra_win_sound(v));
\r
2649 /* Process random events */
\r
2650 case TERM_XTRA_BORED:
\r
2652 return (Term_xtra_win_event(0));
\r
2655 /* Process an event */
\r
2656 case TERM_XTRA_EVENT:
\r
2658 return (Term_xtra_win_event(v));
\r
2661 /* Flush all events */
\r
2662 case TERM_XTRA_FLUSH:
\r
2664 return (Term_xtra_win_flush());
\r
2667 /* Clear the screen */
\r
2668 case TERM_XTRA_CLEAR:
\r
2670 return (Term_xtra_win_clear());
\r
2673 /* React to global changes */
\r
2674 case TERM_XTRA_REACT:
\r
2676 return (Term_xtra_win_react());
\r
2679 /* Delay for some milliseconds */
\r
2680 case TERM_XTRA_DELAY:
\r
2682 return (Term_xtra_win_delay(v));
\r
2692 * Low level graphics (Assumes valid input).
\r
2694 * Draw a "cursor" at (x,y), using a "yellow box".
\r
2696 static errr Term_curs_win(int x, int y)
\r
2698 term_data *td = (term_data*)(Term->data);
\r
2703 int tile_wid, tile_hgt;
\r
2705 if (td->map_active)
\r
2707 tile_wid = td->map_tile_wid;
\r
2708 tile_hgt = td->map_tile_hgt;
\r
2712 tile_wid = td->tile_wid;
\r
2713 tile_hgt = td->tile_hgt;
\r
2716 /* Frame the grid */
\r
2717 rc.left = x * tile_wid + td->size_ow1;
\r
2718 rc.right = rc.left + tile_wid;
\r
2719 rc.top = y * tile_hgt + td->size_oh1;
\r
2720 rc.bottom = rc.top + tile_hgt;
\r
2722 /* Cursor is done as a yellow "box" */
\r
2723 hdc = GetDC(td->w);
\r
2724 FrameRect(hdc, &rc, hbrYellow);
\r
2725 ReleaseDC(td->w, hdc);
\r
2733 * Low level graphics (Assumes valid input).
\r
2735 * Draw a "big cursor" at (x,y), using a "yellow box".
\r
2737 static errr Term_bigcurs_win(int x, int y)
\r
2739 term_data *td = (term_data*)(Term->data);
\r
2744 int tile_wid, tile_hgt;
\r
2746 if (td->map_active)
\r
2748 /* Normal cursor in map window */
\r
2749 Term_curs_win(x, y);
\r
2754 tile_wid = td->tile_wid;
\r
2755 tile_hgt = td->tile_hgt;
\r
2758 /* Frame the grid */
\r
2759 rc.left = x * tile_wid + td->size_ow1;
\r
2760 rc.right = rc.left + 2 * tile_wid;
\r
2761 rc.top = y * tile_hgt + td->size_oh1;
\r
2762 rc.bottom = rc.top + tile_hgt;
\r
2764 /* Cursor is done as a yellow "box" */
\r
2765 hdc = GetDC(td->w);
\r
2766 FrameRect(hdc, &rc, hbrYellow);
\r
2767 ReleaseDC(td->w, hdc);
\r
2775 * Low level graphics (Assumes valid input).
\r
2777 * Erase a "block" of "n" characters starting at (x,y).
\r
2779 static errr Term_wipe_win(int x, int y, int n)
\r
2781 term_data *td = (term_data*)(Term->data);
\r
2786 /* Rectangle to erase in client coords */
\r
2787 rc.left = x * td->tile_wid + td->size_ow1;
\r
2788 rc.right = rc.left + n * td->tile_wid;
\r
2789 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2790 rc.bottom = rc.top + td->tile_hgt;
\r
2792 hdc = GetDC(td->w);
\r
2793 SetBkColor(hdc, RGB(0, 0, 0));
\r
2794 SelectObject(hdc, td->font_id);
\r
2799 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2800 ReleaseDC(td->w, hdc);
\r
2808 * Low level graphics. Assumes valid input.
\r
2810 * Draw several ("n") chars, with an attr, at a given location.
\r
2812 * All "graphic" data is handled by "Term_pict_win()", below.
\r
2814 * One would think there is a more efficient method for telling a window
\r
2815 * what color it should be using to draw with, but perhaps simply changing
\r
2816 * it every time is not too inefficient.
\r
2818 static errr Term_text_win(int x, int y, int n, TERM_COLOR a, const char *s)
\r
2820 term_data *td = (term_data*)(Term->data);
\r
2824 #if 1 /* #ifdef JP */
\r
2825 static HBITMAP WALL;
\r
2826 static HBRUSH myBrush, oldBrush;
\r
2827 static HPEN oldPen;
\r
2828 static bool init_done = FALSE;
\r
2831 WALL = LoadBitmap(hInstance, AppName);
\r
2832 myBrush = CreatePatternBrush(WALL);
\r
2837 /* Total rectangle */
\r
2838 rc.left = x * td->tile_wid + td->size_ow1;
\r
2839 rc.right = rc.left + n * td->tile_wid;
\r
2840 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2841 rc.bottom = rc.top + td->tile_hgt;
\r
2844 hdc = GetDC(td->w);
\r
2846 /* Background color */
\r
2847 SetBkColor(hdc, RGB(0, 0, 0));
\r
2849 /* Foreground color */
\r
2852 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
\r
2854 else if (paletted)
\r
2856 SetTextColor(hdc, win_clr[a&0x0F]);
\r
2860 SetTextColor(hdc, win_clr[a]);
\r
2863 /* Use the font */
\r
2864 SelectObject(hdc, td->font_id);
\r
2867 if (use_bg) SetBkMode(hdc, TRANSPARENT);
\r
2869 /* Bizarre size */
\r
2870 if (td->bizarre ||
\r
2871 (td->tile_hgt != td->font_hgt) ||
\r
2872 (td->tile_wid != td->font_wid))
\r
2876 /* Erase complete rectangle */
\r
2877 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2880 if (use_bg) DrawBG(hdc, &rc);
\r
2882 /* New rectangle */
\r
2883 rc.left += ((td->tile_wid - td->font_wid) / 2);
\r
2884 rc.right = rc.left + td->font_wid;
\r
2885 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
\r
2886 rc.bottom = rc.top + td->font_hgt;
\r
2888 /* Dump each character */
\r
2889 for (i = 0; i < n; i++)
\r
2892 if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
\r
2894 rc.right += td->font_wid;
\r
2896 oldBrush = SelectObject(hdc, myBrush);
\r
2897 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2899 /* Dump the wall */
\r
2900 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2902 SelectObject(hdc, oldBrush);
\r
2903 SelectObject(hdc, oldPen);
\r
2904 rc.right -= td->font_wid;
\r
2908 rc.left += 2 * td->tile_wid;
\r
2909 rc.right += 2 * td->tile_wid;
\r
2911 else if ( iskanji(*(s+i)) ) /* 2バイト文字 */
\r
2913 rc.right += td->font_wid;
\r
2914 /* Dump the text */
\r
2915 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2917 rc.right -= td->font_wid;
\r
2921 rc.left += 2 * td->tile_wid;
\r
2922 rc.right += 2 * td->tile_wid;
\r
2923 } else if (*(s+i)==127){
\r
2924 oldBrush = SelectObject(hdc, myBrush);
\r
2925 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2927 /* Dump the wall */
\r
2928 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2930 SelectObject(hdc, oldBrush);
\r
2931 SelectObject(hdc, oldPen);
\r
2934 rc.left += td->tile_wid;
\r
2935 rc.right += td->tile_wid;
\r
2937 /* Dump the text */
\r
2938 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
\r
2941 rc.left += td->tile_wid;
\r
2942 rc.right += td->tile_wid;
\r
2947 oldBrush = SelectObject(hdc, myBrush);
\r
2948 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2950 /* Dump the wall */
\r
2951 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2953 SelectObject(hdc, oldBrush);
\r
2954 SelectObject(hdc, oldPen);
\r
2957 rc.left += td->tile_wid;
\r
2958 rc.right += td->tile_wid;
\r
2960 /* Dump the text */
\r
2961 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2965 rc.left += td->tile_wid;
\r
2966 rc.right += td->tile_wid;
\r
2969 /* Dump the text */
\r
2970 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
\r
2974 rc.left += td->tile_wid;
\r
2975 rc.right += td->tile_wid;
\r
2985 /* Dump the text */
\r
2986 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
\r
2991 ReleaseDC(td->w, hdc);
\r
2999 * Low level graphics. Assumes valid input.
\r
3001 * Draw an array of "special" attr/char pairs at the given location.
\r
3003 * We use the "Term_pict_win()" function for "graphic" data, which are
\r
3004 * encoded by setting the "high-bits" of both the "attr" and the "char"
\r
3005 * data. We use the "attr" to represent the "row" of the main bitmap,
\r
3006 * and the "char" to represent the "col" of the main bitmap. The use
\r
3007 * of this function is induced by the "higher_pict" flag.
\r
3009 * If "graphics" is not available, we simply "wipe" the given grids.
\r
3011 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
3013 term_data *td = (term_data*)(Term->data);
\r
3015 #ifdef USE_GRAPHICS
\r
3018 TERM_LEN x1, y1, w1, h1, tw1, th1;
\r
3019 TERM_LEN x2, y2, w2, h2, tw2 = 0;
\r
3022 HDC hdcMask = NULL;
\r
3026 HBITMAP hbmSrcOld;
\r
3029 if (!use_graphics)
\r
3031 /* Erase the grids */
\r
3032 return (Term_wipe_win(x, y, n));
\r
3035 /* Size of bitmap cell */
\r
3036 w1 = infGraph.CellWidth;
\r
3037 h1 = infGraph.CellHeight;
\r
3038 tw1 = infGraph.TileWidth;
\r
3039 th1 = infGraph.TileHeight;
\r
3041 /* Size of window cell */
\r
3042 if (td->map_active)
\r
3044 w2 = td->map_tile_wid;
\r
3045 h2 = td->map_tile_hgt;
\r
3049 w2 = td->tile_wid;
\r
3050 h2 = td->tile_hgt;
\r
3053 /* big tile mode */
\r
3054 if (use_bigtile) tw2 *= 2;
\r
3057 /* Location of window cell */
\r
3058 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
\r
3059 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
\r
3062 hdc = GetDC(td->w);
\r
3065 hdcSrc = CreateCompatibleDC(hdc);
\r
3066 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
\r
3068 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3070 hdcMask = CreateCompatibleDC(hdc);
\r
3071 SelectObject(hdcMask, infMask.hBitmap);
\r
3074 /* Draw attr/char pairs */
\r
3075 for (i = 0; i < n; i++, x2 += w2)
\r
3077 TERM_COLOR a = ap[i];
\r
3081 /* Extract picture */
\r
3082 int row = (a & 0x7F);
\r
3083 int col = (c & 0x7F);
\r
3085 /* Location of bitmap cell */
\r
3089 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3091 x3 = (tcp[i] & 0x7F) * w1;
\r
3092 y3 = (tap[i] & 0x7F) * h1;
\r
3093 tw2 = tw2 * w1 / tw1;
\r
3094 h2 = h2 * h1 / th1;
\r
3096 /* Perfect size */
\r
3097 if ((tw1 == tw2) && (th1 == h2))
\r
3099 /* Copy the terrain picture from the bitmap to the window */
\r
3100 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
\r
3102 /* Mask out the tile */
\r
3103 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
\r
3105 /* Draw the tile */
\r
3106 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
\r
3109 /* Need to stretch */
\r
3112 /* Set the correct mode for stretching the tiles */
\r
3113 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3115 /* Copy the terrain picture from the bitmap to the window */
\r
3116 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
\r
3118 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
\r
3120 /* Only draw if terrain and overlay are different */
\r
3121 if ((x1 != x3) || (y1 != y3))
\r
3123 /* Mask out the tile */
\r
3124 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
\r
3126 /* Draw the tile */
\r
3127 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
\r
3133 /* Perfect size */
\r
3134 if ((w1 == tw2) && (h1 == h2))
\r
3136 /* Copy the picture from the bitmap to the window */
\r
3137 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
\r
3140 /* Need to stretch */
\r
3143 /* Set the correct mode for stretching the tiles */
\r
3144 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3146 /* Copy the picture from the bitmap to the window */
\r
3147 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
\r
3153 SelectObject(hdcSrc, hbmSrcOld);
\r
3156 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3159 SelectObject(hdcMask, hbmSrcOld);
\r
3160 DeleteDC(hdcMask);
\r
3164 ReleaseDC(td->w, hdc);
\r
3166 #else /* USE_GRAPHICS */
\r
3168 /* Just erase this grid */
\r
3169 return (Term_wipe_win(x, y, n));
\r
3171 #endif /* USE_GRAPHICS */
\r
3178 static void windows_map(void)
\r
3180 term_data *td = &data[0];
\r
3183 TERM_LEN x, min_x, max_x;
\r
3184 TERM_LEN y, min_y, max_y;
\r
3189 /* Only in graphics mode */
\r
3190 if (!use_graphics) return;
\r
3192 /* Clear screen */
\r
3193 Term_xtra_win_clear();
\r
3195 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
\r
3196 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
\r
3197 td->map_active = TRUE;
\r
3206 /* Draw the map */
\r
3207 for (x = min_x; x < max_x; x++)
\r
3209 for (y = min_y; y < max_y; y++)
\r
3211 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
\r
3213 /* Ignore non-graphics */
\r
3214 if ((a & 0x80) && (c & 0x80))
\r
3216 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
\r
3221 /* Hilite the player */
\r
3222 Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
\r
3224 /* Wait for a keypress, flush key buffer */
\r
3225 Term_inkey(&c, TRUE, TRUE);
\r
3228 /* Switch off the map display */
\r
3229 td->map_active = FALSE;
\r
3231 /* Restore screen */
\r
3232 Term_xtra_win_clear();
\r
3237 /*** Other routines ***/
\r
3241 * Create and initialize a "term_data" given a title
\r
3243 static void term_data_link(term_data *td)
\r
3247 /* Initialize the term */
\r
3248 term_init(t, td->cols, td->rows, td->keys);
\r
3250 /* Use a "software" cursor */
\r
3251 t->soft_cursor = TRUE;
\r
3253 /* Use "Term_pict" for "graphic" data */
\r
3254 t->higher_pict = TRUE;
\r
3256 /* Erase with "white space" */
\r
3257 t->attr_blank = TERM_WHITE;
\r
3258 t->char_blank = ' ';
\r
3261 /* Prepare the init/nuke hooks */
\r
3262 t->init_hook = Term_init_win;
\r
3263 t->nuke_hook = Term_nuke_win;
\r
3266 /* Prepare the template hooks */
\r
3267 t->user_hook = Term_user_win;
\r
3268 t->xtra_hook = Term_xtra_win;
\r
3269 t->curs_hook = Term_curs_win;
\r
3270 t->bigcurs_hook = Term_bigcurs_win;
\r
3271 t->wipe_hook = Term_wipe_win;
\r
3272 t->text_hook = Term_text_win;
\r
3273 t->pict_hook = Term_pict_win;
\r
3275 /* Remember where we came from */
\r
3276 t->data = (vptr)(td);
\r
3281 * Create the windows
\r
3283 * First, instantiate the "default" values, then read the "ini_file"
\r
3284 * to over-ride selected values, then create the windows, and fonts.
\r
3286 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
\r
3287 * must make active to realize the palette.
\r
3289 static void init_windows(void)
\r
3295 #if 0 /* #ifndef JP */
\r
3301 WIPE(td, term_data);
\r
3305 td->s = angband_term_name[0];
\r
3311 td->visible = TRUE;
\r
3316 td->pos_x = 7 * 30;
\r
3317 td->pos_y = 7 * 20;
\r
3318 td->posfix = FALSE;
\r
3319 #if 1 /* #ifdef JP */
\r
3320 td->bizarre = TRUE;
\r
3323 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3326 WIPE(td, term_data);
\r
3327 td->s = angband_term_name[i];
\r
3331 td->visible = FALSE;
\r
3336 td->pos_x = (7 - i) * 30;
\r
3337 td->pos_y = (7 - i) * 20;
\r
3338 td->posfix = FALSE;
\r
3339 #if 1 /* #ifdef JP */
\r
3340 td->bizarre = TRUE;
\r
3349 /* Main window (need these before term_getsize gets called) */
\r
3351 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
\r
3352 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
\r
3354 td->dwExStyle = 0;
\r
3355 td->visible = TRUE;
\r
3357 /* Sub windows (need these before term_getsize gets called) */
\r
3358 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3361 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
\r
3362 td->dwExStyle = (WS_EX_TOOLWINDOW);
\r
3367 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3371 #if 1 /* #ifdef JP */
\r
3372 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
\r
3373 td->lf.lfCharSet = DEFAULT_CHARSET;
\r
3374 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
\r
3375 /* Activate the chosen font */
\r
3376 term_force_font(td, NULL);
\r
3377 if(!td->tile_wid) td->tile_wid = td->font_wid;
\r
3378 if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
\r
3380 /* Access the standard font file */
\r
3381 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
\r
3383 /* Activate the chosen font */
\r
3384 if (term_force_font(td, buf))
\r
3386 /* Access the standard font file */
\r
3387 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
3389 /* Force the use of that font */
\r
3390 (void)term_force_font(td, buf);
\r
3393 td->tile_hgt = 13;
\r
3395 /* Assume not bizarre */
\r
3396 td->bizarre = FALSE;
\r
3401 /* Analyze the font */
\r
3404 /* Resize the window */
\r
3405 term_window_resize(td);
\r
3409 /* Sub windows (reverse order) */
\r
3410 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
\r
3415 td->w = CreateWindowEx(td->dwExStyle, AngList,
\r
3416 td->s, td->dwStyle,
\r
3417 td->pos_x, td->pos_y,
\r
3418 td->size_wid, td->size_hgt,
\r
3419 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3421 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
\r
3425 td->size_hack = TRUE;
\r
3426 ShowWindow(td->w, SW_SHOW);
\r
3427 td->size_hack = FALSE;
\r
3430 term_data_link(td);
\r
3431 angband_term[i] = &td->t;
\r
3435 /* Activate the window */
\r
3436 SetActiveWindow(td->w);
\r
3439 if (data[i].posfix)
\r
3441 term_window_pos(&data[i], HWND_TOPMOST);
\r
3445 term_window_pos(&data[i], td->w);
\r
3455 td->w = CreateWindowEx(td->dwExStyle, AppName,
\r
3456 td->s, td->dwStyle,
\r
3457 td->pos_x, td->pos_y,
\r
3458 td->size_wid, td->size_hgt,
\r
3459 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3461 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
\r
3463 term_data_link(td);
\r
3464 angband_term[0] = &td->t;
\r
3465 normsize.x = td->cols;
\r
3466 normsize.y = td->rows;
\r
3468 /* Activate the main window */
\r
3469 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
\r
3470 else ShowWindow(td->w, SW_SHOW);
\r
3472 /* Bring main window back to top */
\r
3473 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
3477 (void)new_palette();
\r
3480 /* Create a "brush" for drawing the "cursor" */
\r
3481 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
\r
3484 /* Process pending messages */
\r
3485 (void)Term_xtra_win_flush();
\r
3491 * Prepare the menus
\r
3493 static void setup_menus(void)
\r
3497 HMENU hm = GetMenu(data[0].w);
\r
3500 /* Menu "File", Disable all */
\r
3501 EnableMenuItem(hm, IDM_FILE_NEW,
\r
3502 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3503 EnableMenuItem(hm, IDM_FILE_OPEN,
\r
3504 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3505 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3506 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3507 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3508 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3509 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3510 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3513 /* No character available */
\r
3514 if (!character_generated)
\r
3516 /* Menu "File", Item "New" */
\r
3517 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
\r
3519 /* Menu "File", Item "Open" */
\r
3520 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
\r
3523 /* A character available */
\r
3524 if (character_generated)
\r
3526 /* Menu "File", Item "Save" */
\r
3527 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3528 MF_BYCOMMAND | MF_ENABLED);
\r
3531 /* Menu "File", Item "Exit" */
\r
3532 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3533 MF_BYCOMMAND | MF_ENABLED);
\r
3535 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3536 MF_BYCOMMAND | MF_ENABLED);
\r
3539 /* Menu "Window::Visibility" */
\r
3540 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3542 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3543 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3545 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3546 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
\r
3548 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3549 MF_BYCOMMAND | MF_ENABLED);
\r
3552 /* Menu "Window::Font" */
\r
3553 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3555 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3556 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3558 if (data[i].visible)
\r
3560 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3561 MF_BYCOMMAND | MF_ENABLED);
\r
3565 /* Menu "Window::Window Position Fix" */
\r
3566 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3568 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3569 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3571 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3572 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
\r
3574 if (data[i].visible)
\r
3576 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3577 MF_BYCOMMAND | MF_ENABLED);
\r
3581 /* Menu "Window::Bizarre Display" */
\r
3582 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3584 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3585 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3587 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3588 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
\r
3590 if (data[i].visible)
\r
3592 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3593 MF_BYCOMMAND | MF_ENABLED);
\r
3598 /* Menu "Window::Increase Tile Width" */
\r
3599 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3601 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3602 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3604 if (data[i].visible)
\r
3606 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3607 MF_BYCOMMAND | MF_ENABLED);
\r
3612 /* Menu "Window::Decrease Tile Width" */
\r
3613 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3615 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3616 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3618 if (data[i].visible)
\r
3620 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3621 MF_BYCOMMAND | MF_ENABLED);
\r
3626 /* Menu "Window::Increase Tile Height" */
\r
3627 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3629 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3630 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3632 if (data[i].visible)
\r
3634 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3635 MF_BYCOMMAND | MF_ENABLED);
\r
3640 /* Menu "Window::Decrease Tile Height" */
\r
3641 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3643 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3644 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3646 if (data[i].visible)
\r
3648 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3649 MF_BYCOMMAND | MF_ENABLED);
\r
3654 /* Menu "Options", disable all */
\r
3655 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3656 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3657 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3658 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3659 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3660 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3661 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3662 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3663 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3664 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3666 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3667 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3670 /* Menu "Options", Item "Map" */
\r
3671 if (use_graphics != GRAPHICS_NONE)
\r
3672 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
\r
3674 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
\r
3675 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3677 /* Menu "Options", update all */
\r
3678 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3679 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
\r
3680 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3681 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
\r
3682 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3683 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
\r
3684 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
\r
3685 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
\r
3686 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3687 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
\r
3688 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
\r
3689 (arg_music ? MF_CHECKED : MF_UNCHECKED));
\r
3690 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3691 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
\r
3692 CheckMenuItem(hm, IDM_OPTIONS_BG,
\r
3693 (use_bg ? MF_CHECKED : MF_UNCHECKED));
\r
3695 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3696 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
\r
3699 #ifdef USE_GRAPHICS
\r
3700 /* Menu "Options", Item "Graphics" */
\r
3701 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
\r
3702 /* Menu "Options", Item "Graphics" */
\r
3703 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
\r
3704 /* Menu "Options", Item "Graphics" */
\r
3705 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
\r
3706 /* Menu "Options", Item "Graphics" */
\r
3707 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
\r
3708 #endif /* USE_GRAPHICS */
\r
3711 /* Menu "Options", Item "Sound" */
\r
3712 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
\r
3713 #endif /* USE_SOUND */
\r
3716 /* Menu "Options", Item "ScreenSaver" */
\r
3717 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3718 MF_BYCOMMAND | MF_ENABLED);
\r
3719 #endif /* USE_SAVER */
\r
3724 * Check for double clicked (or dragged) savefile
\r
3726 * Apparently, Windows copies the entire filename into the first
\r
3727 * piece of the "command line string". Perhaps we should extract
\r
3728 * the "basename" of that filename and append it to the "save" dir.
\r
3730 static void check_for_save_file(LPSTR cmd_line)
\r
3740 /* Extract filename */
\r
3741 strcat(savefile, s);
\r
3743 /* Validate the file */
\r
3744 validate_file(savefile);
\r
3746 /* Game in progress */
\r
3747 game_in_progress = TRUE;
\r
3755 * Process a menu command
\r
3757 static void process_menus(WORD wCmd)
\r
3769 case IDM_FILE_NEW:
\r
3773 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3775 else if (game_in_progress)
\r
3777 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
\r
3781 game_in_progress = TRUE;
\r
3790 case IDM_FILE_OPEN:
\r
3794 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3796 else if (game_in_progress)
\r
3798 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
\r
3802 memset(&ofn, 0, sizeof(ofn));
\r
3803 ofn.lStructSize = sizeof(ofn);
\r
3804 ofn.hwndOwner = data[0].w;
\r
3805 ofn.lpstrFilter = "Save Files (*.)\0*\0";
\r
3806 ofn.nFilterIndex = 1;
\r
3807 ofn.lpstrFile = savefile;
\r
3808 ofn.nMaxFile = 1024;
\r
3809 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
\r
3810 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
\r
3812 if (GetOpenFileName(&ofn))
\r
3814 /* Load 'savefile' */
\r
3815 validate_file(savefile);
\r
3816 game_in_progress = TRUE;
\r
3826 case IDM_FILE_SAVE:
\r
3828 if (game_in_progress && character_generated)
\r
3833 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
\r
3837 /* Hack -- Forget messages */
\r
3840 /* Save the game */
\r
3842 do_cmd_save_game(FALSE);
\r
3843 #else /* ZANGBAND */
\r
3844 do_cmd_save_game();
\r
3845 #endif /* ZANGBAND */
\r
3849 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
\r
3855 case IDM_FILE_EXIT:
\r
3857 if (game_in_progress && character_generated)
\r
3862 plog(_("今は終了できません。", "You may not do that right now."));
\r
3866 /* Hack -- Forget messages */
\r
3873 /* Save the game */
\r
3875 /* do_cmd_save_game(FALSE); */
\r
3876 #else /* ZANGBAND */
\r
3877 /* do_cmd_save_game(); */
\r
3878 #endif /* ZANGBAND */
\r
3879 Term_key_push(SPECIAL_KEY_QUIT);
\r
3887 case IDM_FILE_SCORE:
\r
3891 /* Build the filename */
\r
3892 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
\r
3894 /* Open the binary high score file, for reading */
\r
3895 highscore_fd = fd_open(buf, O_RDONLY);
\r
3897 /* Paranoia -- No score file */
\r
3898 if (highscore_fd < 0)
\r
3900 msg_print("Score file unavailable.");
\r
3907 /* Clear screen */
\r
3910 /* Display the scores */
\r
3911 display_scores_aux(0, MAX_HISCORES, -1, NULL);
\r
3913 /* Shut the high score file */
\r
3914 (void)fd_close(highscore_fd);
\r
3916 /* Forget the high score fd */
\r
3917 highscore_fd = -1;
\r
3922 /* Hack - Flush it */
\r
3930 case IDM_FILE_MOVIE:
\r
3934 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3936 else if (game_in_progress)
\r
3938 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
\r
3942 memset(&ofn, 0, sizeof(ofn));
\r
3943 ofn.lStructSize = sizeof(ofn);
\r
3944 ofn.hwndOwner = data[0].w;
\r
3945 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
\r
3946 ofn.nFilterIndex = 1;
\r
3947 ofn.lpstrFile = savefile;
\r
3948 ofn.nMaxFile = 1024;
\r
3949 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
\r
3950 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
3952 if (GetOpenFileName(&ofn))
\r
3954 /* Load 'savefile' */
\r
3955 prepare_browse_movie_aux(savefile);
\r
3965 case IDM_WINDOW_VIS_0:
\r
3967 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
\r
3971 /* Window visibility */
\r
3972 case IDM_WINDOW_VIS_1:
\r
3973 case IDM_WINDOW_VIS_2:
\r
3974 case IDM_WINDOW_VIS_3:
\r
3975 case IDM_WINDOW_VIS_4:
\r
3976 case IDM_WINDOW_VIS_5:
\r
3977 case IDM_WINDOW_VIS_6:
\r
3978 case IDM_WINDOW_VIS_7:
\r
3980 i = wCmd - IDM_WINDOW_VIS_0;
\r
3982 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
3988 td->visible = TRUE;
\r
3989 ShowWindow(td->w, SW_SHOW);
\r
3990 term_data_redraw(td);
\r
3994 td->visible = FALSE;
\r
3995 td->posfix = FALSE;
\r
3996 ShowWindow(td->w, SW_HIDE);
\r
4002 /* Window fonts */
\r
4003 case IDM_WINDOW_FONT_0:
\r
4004 case IDM_WINDOW_FONT_1:
\r
4005 case IDM_WINDOW_FONT_2:
\r
4006 case IDM_WINDOW_FONT_3:
\r
4007 case IDM_WINDOW_FONT_4:
\r
4008 case IDM_WINDOW_FONT_5:
\r
4009 case IDM_WINDOW_FONT_6:
\r
4010 case IDM_WINDOW_FONT_7:
\r
4012 i = wCmd - IDM_WINDOW_FONT_0;
\r
4014 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4018 term_change_font(td);
\r
4023 /* Window Z Position */
\r
4024 case IDM_WINDOW_POS_1:
\r
4025 case IDM_WINDOW_POS_2:
\r
4026 case IDM_WINDOW_POS_3:
\r
4027 case IDM_WINDOW_POS_4:
\r
4028 case IDM_WINDOW_POS_5:
\r
4029 case IDM_WINDOW_POS_6:
\r
4030 case IDM_WINDOW_POS_7:
\r
4032 i = wCmd - IDM_WINDOW_POS_0;
\r
4034 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4038 if (!td->posfix && td->visible)
\r
4040 td->posfix = TRUE;
\r
4041 term_window_pos(td, HWND_TOPMOST);
\r
4045 td->posfix = FALSE;
\r
4046 term_window_pos(td, data[0].w);
\r
4052 /* Bizarre Display */
\r
4053 case IDM_WINDOW_BIZ_0:
\r
4054 case IDM_WINDOW_BIZ_1:
\r
4055 case IDM_WINDOW_BIZ_2:
\r
4056 case IDM_WINDOW_BIZ_3:
\r
4057 case IDM_WINDOW_BIZ_4:
\r
4058 case IDM_WINDOW_BIZ_5:
\r
4059 case IDM_WINDOW_BIZ_6:
\r
4060 case IDM_WINDOW_BIZ_7:
\r
4062 i = wCmd - IDM_WINDOW_BIZ_0;
\r
4064 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4068 td->bizarre = !td->bizarre;
\r
4072 term_window_resize(td);
\r
4077 /* Increase Tile Width */
\r
4078 case IDM_WINDOW_I_WID_0:
\r
4079 case IDM_WINDOW_I_WID_1:
\r
4080 case IDM_WINDOW_I_WID_2:
\r
4081 case IDM_WINDOW_I_WID_3:
\r
4082 case IDM_WINDOW_I_WID_4:
\r
4083 case IDM_WINDOW_I_WID_5:
\r
4084 case IDM_WINDOW_I_WID_6:
\r
4085 case IDM_WINDOW_I_WID_7:
\r
4087 i = wCmd - IDM_WINDOW_I_WID_0;
\r
4089 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4093 td->tile_wid += 1;
\r
4097 term_window_resize(td);
\r
4102 /* Decrease Tile Height */
\r
4103 case IDM_WINDOW_D_WID_0:
\r
4104 case IDM_WINDOW_D_WID_1:
\r
4105 case IDM_WINDOW_D_WID_2:
\r
4106 case IDM_WINDOW_D_WID_3:
\r
4107 case IDM_WINDOW_D_WID_4:
\r
4108 case IDM_WINDOW_D_WID_5:
\r
4109 case IDM_WINDOW_D_WID_6:
\r
4110 case IDM_WINDOW_D_WID_7:
\r
4112 i = wCmd - IDM_WINDOW_D_WID_0;
\r
4114 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4118 td->tile_wid -= 1;
\r
4122 term_window_resize(td);
\r
4127 /* Increase Tile Height */
\r
4128 case IDM_WINDOW_I_HGT_0:
\r
4129 case IDM_WINDOW_I_HGT_1:
\r
4130 case IDM_WINDOW_I_HGT_2:
\r
4131 case IDM_WINDOW_I_HGT_3:
\r
4132 case IDM_WINDOW_I_HGT_4:
\r
4133 case IDM_WINDOW_I_HGT_5:
\r
4134 case IDM_WINDOW_I_HGT_6:
\r
4135 case IDM_WINDOW_I_HGT_7:
\r
4137 i = wCmd - IDM_WINDOW_I_HGT_0;
\r
4139 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4143 td->tile_hgt += 1;
\r
4147 term_window_resize(td);
\r
4152 /* Decrease Tile Height */
\r
4153 case IDM_WINDOW_D_HGT_0:
\r
4154 case IDM_WINDOW_D_HGT_1:
\r
4155 case IDM_WINDOW_D_HGT_2:
\r
4156 case IDM_WINDOW_D_HGT_3:
\r
4157 case IDM_WINDOW_D_HGT_4:
\r
4158 case IDM_WINDOW_D_HGT_5:
\r
4159 case IDM_WINDOW_D_HGT_6:
\r
4160 case IDM_WINDOW_D_HGT_7:
\r
4162 i = wCmd - IDM_WINDOW_D_HGT_0;
\r
4164 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4168 td->tile_hgt -= 1;
\r
4172 term_window_resize(td);
\r
4177 case IDM_OPTIONS_NO_GRAPHICS:
\r
4182 plog("You may not do that right now.");
\r
4186 /* Toggle "arg_graphics" */
\r
4187 if (arg_graphics != GRAPHICS_NONE)
\r
4189 arg_graphics = GRAPHICS_NONE;
\r
4191 /* React to changes */
\r
4192 Term_xtra_win_react();
\r
4194 /* Hack -- Force redraw */
\r
4195 Term_key_push(KTRL('R'));
\r
4201 case IDM_OPTIONS_OLD_GRAPHICS:
\r
4206 plog("You may not do that right now.");
\r
4210 /* Toggle "arg_graphics" */
\r
4211 if (arg_graphics != GRAPHICS_ORIGINAL)
\r
4213 arg_graphics = GRAPHICS_ORIGINAL;
\r
4215 /* React to changes */
\r
4216 Term_xtra_win_react();
\r
4218 /* Hack -- Force redraw */
\r
4219 Term_key_push(KTRL('R'));
\r
4225 case IDM_OPTIONS_NEW_GRAPHICS:
\r
4230 plog("You may not do that right now.");
\r
4234 /* Toggle "arg_graphics" */
\r
4235 if (arg_graphics != GRAPHICS_ADAM_BOLT)
\r
4237 arg_graphics = GRAPHICS_ADAM_BOLT;
\r
4239 /* React to changes */
\r
4240 Term_xtra_win_react();
\r
4242 /* Hack -- Force redraw */
\r
4243 Term_key_push(KTRL('R'));
\r
4249 case IDM_OPTIONS_NEW2_GRAPHICS:
\r
4254 plog("You may not do that right now.");
\r
4258 /* Toggle "arg_graphics" */
\r
4259 if (arg_graphics != GRAPHICS_HENGBAND)
\r
4261 arg_graphics = GRAPHICS_HENGBAND;
\r
4263 /* React to changes */
\r
4264 Term_xtra_win_react();
\r
4266 /* Hack -- Force redraw */
\r
4267 Term_key_push(KTRL('R'));
\r
4273 case IDM_OPTIONS_BIGTILE:
\r
4280 plog("You may not do that right now.");
\r
4284 /* Toggle "arg_sound" */
\r
4285 arg_bigtile = !arg_bigtile;
\r
4288 Term_activate(&td->t);
\r
4290 /* Resize the term */
\r
4291 Term_resize(td->cols, td->rows);
\r
4293 /* Redraw later */
\r
4294 InvalidateRect(td->w, NULL, TRUE);
\r
4299 case IDM_OPTIONS_MUSIC:
\r
4304 plog("You may not do that right now.");
\r
4308 /* Toggle "arg_sound" */
\r
4309 arg_music = !arg_music;
\r
4311 /* React to changes */
\r
4312 Term_xtra_win_react();
\r
4314 /* Hack -- Force redraw */
\r
4315 Term_key_push(KTRL('R'));
\r
4320 case IDM_OPTIONS_SOUND:
\r
4325 plog("You may not do that right now.");
\r
4329 /* Toggle "arg_sound" */
\r
4330 arg_sound = !arg_sound;
\r
4332 /* React to changes */
\r
4333 Term_xtra_win_react();
\r
4335 /* Hack -- Force redraw */
\r
4336 Term_key_push(KTRL('R'));
\r
4342 case IDM_OPTIONS_BG:
\r
4347 plog("You may not do that right now.");
\r
4351 /* Toggle "use_bg" */
\r
4356 /* React to changes */
\r
4357 Term_xtra_win_react();
\r
4359 /* Hack -- Force redraw */
\r
4360 Term_key_push(KTRL('R'));
\r
4366 case IDM_OPTIONS_OPEN_BG:
\r
4371 plog("You may not do that right now.");
\r
4376 memset(&ofn, 0, sizeof(ofn));
\r
4377 ofn.lStructSize = sizeof(ofn);
\r
4378 ofn.hwndOwner = data[0].w;
\r
4379 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
\r
4380 ofn.nFilterIndex = 1;
\r
4381 ofn.lpstrFile = bg_bitmap_file;
\r
4382 ofn.nMaxFile = 1023;
\r
4383 ofn.lpstrInitialDir = NULL;
\r
4384 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
\r
4385 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
\r
4387 if (GetOpenFileName(&ofn))
\r
4389 /* Load 'savefile' */
\r
4394 /* React to changes */
\r
4395 Term_xtra_win_react();
\r
4397 /* Hack -- Force redraw */
\r
4398 Term_key_push(KTRL('R'));
\r
4403 case IDM_DUMP_SCREEN_HTML:
\r
4405 static char buf[1024] = "";
\r
4406 memset(&ofn, 0, sizeof(ofn));
\r
4407 ofn.lStructSize = sizeof(ofn);
\r
4408 ofn.hwndOwner = data[0].w;
\r
4409 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
\r
4410 ofn.nFilterIndex = 1;
\r
4411 ofn.lpstrFile = buf;
\r
4412 ofn.nMaxFile = 1023;
\r
4413 ofn.lpstrDefExt = "html";
\r
4414 ofn.lpstrInitialDir = NULL;
\r
4415 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
\r
4416 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
\r
4418 if (GetSaveFileName(&ofn))
\r
4420 do_cmd_save_screen_html_aux(buf, 0);
\r
4427 case IDM_OPTIONS_SAVER:
\r
4431 DestroyWindow(hwndSaver);
\r
4436 /* Create a screen scaver window */
\r
4437 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
\r
4438 "Angband Screensaver",
\r
4439 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
\r
4440 0, 0, GetSystemMetrics(SM_CXSCREEN),
\r
4441 GetSystemMetrics(SM_CYSCREEN),
\r
4442 NULL, NULL, hInstance, NULL);
\r
4446 /* Push the window to the bottom */
\r
4447 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
4451 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
\r
4459 case IDM_OPTIONS_MAP:
\r
4465 case IDM_HELP_CONTENTS:
\r
4469 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
\r
4470 if (check_file(tmp))
\r
4472 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
\r
4476 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
\r
4477 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
\r
4480 #else /* HTML_HELP */
\r
4483 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
\r
4484 if (check_file(tmp))
\r
4486 sprintf(buf, "winhelp.exe %s", tmp);
\r
4487 WinExec(buf, SW_NORMAL);
\r
4491 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
\r
4492 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
\r
4496 #endif /* HTML_HELP */
\r
4502 static bool process_keydown(WPARAM wParam, LPARAM lParam)
\r
4509 /* Extract the modifiers */
\r
4510 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
\r
4511 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
\r
4512 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
\r
4514 Term_no_press = (ma) ? TRUE : FALSE;
\r
4516 /* Handle "special" keys */
\r
4517 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
\r
4519 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
\r
4520 bool numpad = FALSE;
\r
4522 /* Begin the macro trigger */
\r
4523 Term_keypress(31);
\r
4525 /* Send the modifiers */
\r
4526 if (mc) Term_keypress('C');
\r
4527 if (ms) Term_keypress('S');
\r
4528 if (ma) Term_keypress('A');
\r
4530 /* Extract "scan code" */
\r
4531 i = LOBYTE(HIWORD(lParam));
\r
4533 /* Introduce the scan code */
\r
4534 Term_keypress('x');
\r
4536 /* Extended key bit */
\r
4539 /* Numpad Enter and '/' are extended key */
\r
4541 Term_no_press = TRUE;
\r
4542 case VK_RETURN: /* Enter */
\r
4545 /* Other extended keys are on full keyboard */
\r
4559 case VK_SEPARATOR:
\r
4561 Term_no_press = TRUE;
\r
4565 case VK_PRIOR: /* Page Up */
\r
4566 case VK_NEXT: /* Page Down */
\r
4573 numpad = !ext_key;
\r
4576 /* Special modifiers for keypad keys */
\r
4577 if (numpad) Term_keypress('K');
\r
4579 /* Encode the hexidecimal scan code */
\r
4580 Term_keypress(hexsym[i/16]);
\r
4581 Term_keypress(hexsym[i%16]);
\r
4583 /* End the macro trigger */
\r
4584 Term_keypress(13);
\r
4594 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4595 WPARAM wParam, LPARAM lParam);
\r
4596 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4597 WPARAM wParam, LPARAM lParam)
\r
4598 #else /* __MWERKS__ */
\r
4599 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
4600 #endif /* __MWERKS__ */
\r
4606 MINMAXINFO FAR *lpmmi;
\r
4612 /* Acquire proper "term_data" info */
\r
4613 td = (term_data *)GetWindowLong(hWnd, 0);
\r
4615 /* Handle message */
\r
4620 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
4627 mop.dwCallback=(DWORD)hWnd;
\r
4632 case WM_GETMINMAXINFO:
\r
4634 MINMAXINFO FAR *lpmmi;
\r
4637 lpmmi = (MINMAXINFO FAR *)lParam;
\r
4639 /* this message was sent before WM_NCCREATE */
\r
4640 if (!td) return 1;
\r
4642 /* Minimum window size is 80x24 */
\r
4643 rc.left = rc.top = 0;
\r
4644 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
4645 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
4648 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
4650 /* Save minimum size */
\r
4651 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
4652 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
4659 BeginPaint(hWnd, &ps);
\r
4660 if (td) term_data_redraw(td);
\r
4661 EndPaint(hWnd, &ps);
\r
4662 ValidateRect(hWnd, NULL);
\r
4667 case MM_MCINOTIFY:
\r
4669 if(wParam == MCI_NOTIFY_SUCCESSFUL)
\r
4671 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
4672 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
4678 case WM_SYSKEYDOWN:
\r
4681 if (process_keydown(wParam, lParam))
\r
4688 if (Term_no_press) Term_no_press = FALSE;
\r
4689 else Term_keypress(wParam);
\r
4693 case WM_LBUTTONDOWN:
\r
4695 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4696 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4697 mouse_down = TRUE;
\r
4703 case WM_LBUTTONUP:
\r
4708 TERM_LEN dx = abs(oldx - mousex) + 1;
\r
4709 TERM_LEN dy = abs(oldy - mousey) + 1;
\r
4710 TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
\r
4711 TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
\r
4713 mouse_down = FALSE;
\r
4714 paint_rect = FALSE;
\r
4717 sz = (dx + 3) * dy;
\r
4719 sz = (dx + 2) * dy;
\r
4721 hGlobal = GlobalAlloc(GHND, sz + 1);
\r
4722 if (hGlobal == NULL) return 0;
\r
4723 lpStr = (LPSTR)GlobalLock(hGlobal);
\r
4725 for (i = 0; i < dy; i++)
\r
4729 char **scr = data[0].t.scr->c;
\r
4731 C_MAKE(s, (dx + 1), char);
\r
4732 strncpy(s, &scr[oy + i][ox], dx);
\r
4736 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
\r
4739 if (ox + dx < data[0].cols)
\r
4741 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
\r
4744 for (j = 0; j < dx; j++)
\r
4746 if (s[j] == 127) s[j] = '#';
\r
4750 for (j = 0; j < dx; j++)
\r
4752 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
\r
4762 GlobalUnlock(hGlobal);
\r
4763 if (OpenClipboard(hWnd) == 0)
\r
4765 GlobalFree(hGlobal);
\r
4769 SetClipboardData(CF_TEXT, hGlobal);
\r
4777 case WM_MOUSEMOVE:
\r
4782 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4783 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4788 dx = abs(oldx - mousex) + 1;
\r
4789 dy = abs(oldy - mousey) + 1;
\r
4790 ox = (oldx > mousex) ? mousex : oldx;
\r
4791 oy = (oldy > mousey) ? mousey : oldy;
\r
4792 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4796 paint_rect = TRUE;
\r
4799 dx = abs(cx - mousex) + 1;
\r
4800 dy = abs(cy - mousey) + 1;
\r
4801 ox = (cx > mousex) ? mousex : cx;
\r
4802 oy = (cy > mousey) ? mousey : cy;
\r
4803 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4819 if (game_in_progress && character_generated)
\r
4823 plog(_("今は終了できません。", "You may not do that right now."));
\r
4827 /* Hack -- Forget messages */
\r
4834 /* Save the game */
\r
4836 /* do_cmd_save_game(FALSE); */
\r
4837 #else /* ZANGBAND */
\r
4838 /* do_cmd_save_game(); */
\r
4839 #endif /* ZANGBAND */
\r
4840 Term_key_push(SPECIAL_KEY_QUIT);
\r
4847 case WM_QUERYENDSESSION:
\r
4849 if (game_in_progress && character_generated)
\r
4851 /* Hack -- Forget messages */
\r
4854 /* Mega-Hack -- Delay death */
\r
4855 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
\r
4856 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
\r
4858 /* Hardcode panic save */
\r
4859 p_ptr->panic_save = 1;
\r
4861 /* Forbid suspend */
\r
4862 signals_ignore_tstp();
\r
4864 /* Indicate panic save */
\r
4865 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
\r
4868 (void)save_player();
\r
4882 process_menus(LOWORD(wParam));
\r
4888 /* this message was sent before WM_NCCREATE */
\r
4889 if (!td) return 1;
\r
4891 /* it was sent from inside CreateWindowEx */
\r
4892 if (!td->w) return 1;
\r
4894 /* was sent from WM_SIZE */
\r
4895 if (td->size_hack) return 1;
\r
4899 case SIZE_MINIMIZED:
\r
4901 /* Hide sub-windows */
\r
4902 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4904 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
\r
4909 case SIZE_MAXIMIZED:
\r
4911 /* fall through */
\r
4914 case SIZE_RESTORED:
\r
4916 TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
4917 TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
4920 if ((td->cols != cols) || (td->rows != rows))
\r
4922 /* Save the new size */
\r
4926 if (!IsZoomed(td->w) && !IsIconic(td->w))
\r
4928 normsize.x = td->cols;
\r
4929 normsize.y = td->rows;
\r
4933 Term_activate(&td->t);
\r
4935 /* Resize the term */
\r
4936 Term_resize(td->cols, td->rows);
\r
4938 /* Redraw later */
\r
4939 InvalidateRect(td->w, NULL, TRUE);
\r
4942 td->size_hack = TRUE;
\r
4944 /* Show sub-windows */
\r
4945 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4947 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
\r
4950 td->size_hack = FALSE;
\r
4958 case WM_PALETTECHANGED:
\r
4960 /* Ignore if palette change caused by itself */
\r
4961 if ((HWND)wParam == hWnd) return 0;
\r
4963 /* Fall through... */
\r
4966 case WM_QUERYNEWPALETTE:
\r
4968 if (!paletted) return 0;
\r
4970 hdc = GetDC(hWnd);
\r
4972 SelectPalette(hdc, hPal, FALSE);
\r
4974 i = RealizePalette(hdc);
\r
4976 /* if any palette entries changed, repaint the window. */
\r
4977 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
4979 ReleaseDC(hWnd, hdc);
\r
4986 if (wParam && !HIWORD(lParam))
\r
4988 /* Do something to sub-windows */
\r
4989 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4991 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
\r
4994 /* Focus on main window */
\r
5003 case WM_ACTIVATEAPP:
\r
5005 if (IsIconic(td->w)) break;
\r
5007 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5009 if(data[i].visible)
\r
5011 if (wParam == TRUE)
\r
5013 ShowWindow(data[i].w, SW_SHOW);
\r
5017 ShowWindow(data[i].w, SW_HIDE);
\r
5024 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5029 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5030 WPARAM wParam, LPARAM lParam);
\r
5031 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5032 WPARAM wParam, LPARAM lParam)
\r
5033 #else /* __MWERKS__ */
\r
5034 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5035 WPARAM wParam, LPARAM lParam)
\r
5036 #endif /* __MWERKS__ */
\r
5040 MINMAXINFO FAR *lpmmi;
\r
5048 /* Acquire proper "term_data" info */
\r
5049 td = (term_data *)GetWindowLong(hWnd, 0);
\r
5051 /* Process message */
\r
5056 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
5065 case WM_GETMINMAXINFO:
\r
5067 MINMAXINFO FAR *lpmmi;
\r
5070 lpmmi = (MINMAXINFO FAR *)lParam;
\r
5072 /* this message was sent before WM_NCCREATE */
\r
5073 if (!td) return 1;
\r
5075 /* Minimum window size is 80x24 */
\r
5076 rc.left = rc.top = 0;
\r
5077 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
5078 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
5081 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
5083 /* Save minimum size */
\r
5084 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
5085 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
5095 /* this message was sent before WM_NCCREATE */
\r
5096 if (!td) return 1;
\r
5098 /* it was sent from inside CreateWindowEx */
\r
5099 if (!td->w) return 1;
\r
5101 /* was sent from inside WM_SIZE */
\r
5102 if (td->size_hack) return 1;
\r
5104 td->size_hack = TRUE;
\r
5106 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
5107 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
5110 if ((td->cols != cols) || (td->rows != rows))
\r
5112 /* Save old term */
\r
5113 term *old_term = Term;
\r
5115 /* Save the new size */
\r
5120 Term_activate(&td->t);
\r
5122 /* Resize the term */
\r
5123 Term_resize(td->cols, td->rows);
\r
5126 Term_activate(old_term);
\r
5128 /* Redraw later */
\r
5129 InvalidateRect(td->w, NULL, TRUE);
\r
5131 /* HACK - Redraw all windows */
\r
5132 p_ptr->window = 0xFFFFFFFF;
\r
5136 td->size_hack = FALSE;
\r
5143 BeginPaint(hWnd, &ps);
\r
5144 if (td) term_data_redraw(td);
\r
5145 EndPaint(hWnd, &ps);
\r
5149 case WM_SYSKEYDOWN:
\r
5152 if (process_keydown(wParam, lParam))
\r
5159 if (Term_no_press) Term_no_press = FALSE;
\r
5160 else Term_keypress(wParam);
\r
5164 case WM_PALETTECHANGED:
\r
5166 /* ignore if palette change caused by itself */
\r
5167 if ((HWND)wParam == hWnd) return FALSE;
\r
5168 /* otherwise, fall through!!! */
\r
5171 case WM_QUERYNEWPALETTE:
\r
5173 if (!paletted) return 0;
\r
5174 hdc = GetDC(hWnd);
\r
5175 SelectPalette(hdc, hPal, FALSE);
\r
5176 i = RealizePalette(hdc);
\r
5177 /* if any palette entries changed, repaint the window. */
\r
5178 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5179 ReleaseDC(hWnd, hdc);
\r
5183 case WM_NCLBUTTONDOWN:
\r
5187 if (wParam == HTCLOSE) wParam = HTSYSMENU;
\r
5188 #endif /* HTCLOSE */
\r
5190 if (wParam == HTSYSMENU)
\r
5194 td->visible = FALSE;
\r
5195 ShowWindow(td->w, SW_HIDE);
\r
5205 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5211 #define MOUSE_SENS 40
\r
5214 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5215 WPARAM wParam, LPARAM lParam);
\r
5216 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5217 WPARAM wParam, LPARAM lParam)
\r
5218 #else /* __MWERKS__ */
\r
5219 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5220 WPARAM wParam, LPARAM lParam)
\r
5221 #endif /* __MWERKS__ */
\r
5223 static int iMouse = 0;
\r
5224 static WORD xMouse = 0;
\r
5225 static WORD yMouse = 0;
\r
5238 case WM_SETCURSOR:
\r
5247 if (LOWORD(wParam) == WA_INACTIVE) break;
\r
5249 /* else fall through */
\r
5253 case WM_LBUTTONDOWN:
\r
5254 case WM_MBUTTONDOWN:
\r
5255 case WM_RBUTTONDOWN:
\r
5258 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5262 case WM_MOUSEMOVE:
\r
5266 dx = LOWORD(lParam) - xMouse;
\r
5267 dy = HIWORD(lParam) - yMouse;
\r
5269 if (dx < 0) dx = -dx;
\r
5270 if (dy < 0) dy = -dy;
\r
5272 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
\r
5274 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5278 /* Save last location */
\r
5280 xMouse = LOWORD(lParam);
\r
5281 yMouse = HIWORD(lParam);
\r
5288 DestroyWindow(hwndSaver);
\r
5294 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5297 #endif /* USE_SAVER */
\r
5303 /*** Temporary Hooks ***/
\r
5307 * Display warning message (see "z-util.c")
\r
5309 static void hack_plog(cptr str)
\r
5311 /* Give a warning */
\r
5315 MessageBox(NULL, str, "警告!",
\r
5316 MB_ICONEXCLAMATION | MB_OK);
\r
5318 MessageBox(NULL, str, "Warning",
\r
5319 MB_ICONEXCLAMATION | MB_OK);
\r
5327 * Display error message and quit (see "z-util.c")
\r
5329 static void hack_quit(cptr str)
\r
5331 /* Give a warning */
\r
5335 MessageBox(NULL, str, "エラー!",
\r
5336 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5338 MessageBox(NULL, str, "Error",
\r
5339 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5344 /* Unregister the classes */
\r
5345 UnregisterClass(AppName, hInstance);
\r
5347 /* Destroy the icon */
\r
5348 if (hIcon) DestroyIcon(hIcon);
\r
5356 /*** Various hooks ***/
\r
5360 * Display warning message (see "z-util.c")
\r
5362 static void hook_plog(cptr str)
\r
5368 MessageBox(data[0].w, str, "警告!",
\r
5369 MB_ICONEXCLAMATION | MB_OK);
\r
5371 MessageBox(data[0].w, str, "Warning",
\r
5372 MB_ICONEXCLAMATION | MB_OK);
\r
5380 * Display error message and quit (see "z-util.c")
\r
5382 static void hook_quit(cptr str)
\r
5387 /* Give a warning */
\r
5391 MessageBox(data[0].w, str, "エラー!",
\r
5392 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5394 MessageBox(data[0].w, str, "Error",
\r
5395 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5401 /* Save the preferences */
\r
5405 /*** Could use 'Term_nuke_win()' */
\r
5407 /* Destroy all windows */
\r
5408 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
\r
5410 term_force_font(&data[i], NULL);
\r
5411 if (data[i].font_want) string_free(data[i].font_want);
\r
5412 if (data[i].w) DestroyWindow(data[i].w);
\r
5416 /* Free the bitmap stuff */
\r
5417 #ifdef USE_GRAPHICS
\r
5418 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
\r
5419 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
\r
5421 if (infMask.hPalette) DeleteObject(infMask.hPalette);
\r
5422 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
\r
5424 #endif /* USE_GRAPHICS */
\r
5426 /*** Free some other stuff ***/
\r
5428 DeleteObject(hbrYellow);
\r
5433 if (hPal) DeleteObject(hPal);
\r
5435 UnregisterClass(AppName, hInstance);
\r
5437 if (hIcon) DestroyIcon(hIcon);
\r
5444 /*** Initialize ***/
\r
5450 static void init_stuff(void)
\r
5457 /* Get program name with full path */
\r
5458 GetModuleFileName(hInstance, path, 512);
\r
5460 /* Save the "program name" */
\r
5463 /* Get the name of the "*.ini" file */
\r
5464 strcpy(path + strlen(path) - 4, ".INI");
\r
5466 /* Save the the name of the ini-file */
\r
5467 ini_file = string_make(path);
\r
5469 /* Analyze the path */
\r
5472 /* Get the path */
\r
5473 for (; i > 0; i--)
\r
5475 if (path[i] == '\\')
\r
5482 /* Add "lib" to the path */
\r
5483 strcpy(path + i + 1, "lib\\");
\r
5485 /* Validate the path */
\r
5486 validate_dir(path, TRUE);
\r
5488 /* Init the file paths */
\r
5489 init_file_paths(path);
\r
5491 /* Hack -- Validate the paths */
\r
5492 validate_dir(ANGBAND_DIR_APEX, FALSE);
\r
5493 validate_dir(ANGBAND_DIR_BONE, FALSE);
\r
5495 /* Allow missing 'edit' directory */
\r
5496 if (!check_dir(ANGBAND_DIR_EDIT))
\r
5498 /* Must have 'data'! */
\r
5499 validate_dir(ANGBAND_DIR_DATA, TRUE);
\r
5503 /* Don't need 'data' */
\r
5504 validate_dir(ANGBAND_DIR_DATA, FALSE);
\r
5507 validate_dir(ANGBAND_DIR_FILE, TRUE);
\r
5508 validate_dir(ANGBAND_DIR_HELP, FALSE);
\r
5509 validate_dir(ANGBAND_DIR_INFO, FALSE);
\r
5510 validate_dir(ANGBAND_DIR_PREF, TRUE);
\r
5511 validate_dir(ANGBAND_DIR_SAVE, FALSE);
\r
5512 validate_dir(ANGBAND_DIR_USER, TRUE);
\r
5513 validate_dir(ANGBAND_DIR_XTRA, TRUE);
\r
5515 /* Build the filename */
\r
5516 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
\r
5518 /* Hack -- Validate the "news.txt" file */
\r
5519 validate_file(path);
\r
5522 #if 0 /* #ifndef JP */
\r
5523 /* Build the "font" path */
\r
5524 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
\r
5526 /* Allocate the path */
\r
5527 ANGBAND_DIR_XTRA_FONT = string_make(path);
\r
5529 /* Validate the "font" directory */
\r
5530 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
\r
5532 /* Build the filename */
\r
5533 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
5535 /* Hack -- Validate the basic font */
\r
5536 validate_file(path);
\r
5540 #ifdef USE_GRAPHICS
\r
5542 /* Build the "graf" path */
\r
5543 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
\r
5545 /* Allocate the path */
\r
5546 ANGBAND_DIR_XTRA_GRAF = string_make(path);
\r
5548 /* Validate the "graf" directory */
\r
5549 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
\r
5551 #endif /* USE_GRAPHICS */
\r
5556 /* Build the "sound" path */
\r
5557 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
\r
5559 /* Allocate the path */
\r
5560 ANGBAND_DIR_XTRA_SOUND = string_make(path);
\r
5562 /* Validate the "sound" directory */
\r
5563 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
\r
5565 #endif /* USE_SOUND */
\r
5569 /* Build the "music" path */
\r
5570 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
\r
5572 /* Allocate the path */
\r
5573 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
\r
5575 /* Validate the "music" directory */
\r
5576 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
\r
5578 #endif /* USE_MUSIC */
\r
5580 /* Build the "help" path */
\r
5581 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
\r
5583 /* Allocate the path */
\r
5584 ANGBAND_DIR_XTRA_HELP = string_make(path);
\r
5586 /* Validate the "help" directory */
\r
5587 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
\r
5591 * @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
\r
5593 static bool is_already_running(void)
\r
5595 bool result = FALSE;
\r
5598 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
\r
5599 if (GetLastError() == ERROR_ALREADY_EXISTS)
\r
5608 * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
\r
5610 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
\r
5611 LPSTR lpCmdLine, int nCmdShow)
\r
5619 setlocale( LC_ALL, "ja_JP" );
\r
5624 /* Save globally */
\r
5625 hInstance = hInst;
\r
5628 /* Prevent multiple run */
\r
5629 if (is_already_running())
\r
5632 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
\r
5633 _("エラー!", "Error") ,
\r
5634 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5638 if (hPrevInst == NULL)
\r
5640 wc.style = CS_CLASSDC;
\r
5641 wc.lpfnWndProc = AngbandWndProc;
\r
5642 wc.cbClsExtra = 0;
\r
5643 wc.cbWndExtra = 4; /* one long pointer to term_data */
\r
5644 wc.hInstance = hInst;
\r
5645 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
\r
5646 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
\r
5647 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
\r
5648 wc.lpszMenuName = AppName;
\r
5649 wc.lpszClassName = AppName;
\r
5651 if (!RegisterClass(&wc)) exit(1);
\r
5653 wc.lpfnWndProc = AngbandListProc;
\r
5654 wc.lpszMenuName = NULL;
\r
5655 wc.lpszClassName = AngList;
\r
5657 if (!RegisterClass(&wc)) exit(2);
\r
5661 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
\r
5662 wc.lpfnWndProc = AngbandSaverProc;
\r
5663 wc.hCursor = NULL;
\r
5664 wc.lpszMenuName = NULL;
\r
5665 wc.lpszClassName = "WindowsScreenSaverClass";
\r
5667 if (!RegisterClass(&wc)) exit(3);
\r
5673 /* Temporary hooks */
\r
5674 plog_aux = hack_plog;
\r
5675 quit_aux = hack_quit;
\r
5676 core_aux = hack_quit;
\r
5678 /* Prepare the filepaths */
\r
5681 /* Initialize the keypress analyzer */
\r
5682 for (i = 0; special_key_list[i]; ++i)
\r
5684 special_key[special_key_list[i]] = TRUE;
\r
5686 /* Initialize the keypress analyzer */
\r
5687 for (i = 0; ignore_key_list[i]; ++i)
\r
5689 ignore_key[ignore_key_list[i]] = TRUE;
\r
5692 /* Determine if display is 16/256/true color */
\r
5693 hdc = GetDC(NULL);
\r
5694 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
\r
5695 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
\r
5696 ReleaseDC(NULL, hdc);
\r
5698 /* Initialize the colors */
\r
5699 for (i = 0; i < 256; i++)
\r
5703 /* Extract desired values */
\r
5704 rv = angband_color_table[i][1];
\r
5705 gv = angband_color_table[i][2];
\r
5706 bv = angband_color_table[i][3];
\r
5708 /* Extract the "complex" code */
\r
5709 win_clr[i] = PALETTERGB(rv, gv, bv);
\r
5711 /* Save the "simple" code */
\r
5712 angband_color_table[i][0] = win_pal[i];
\r
5715 /* Prepare the windows */
\r
5721 /* Activate hooks */
\r
5722 plog_aux = hook_plog;
\r
5723 quit_aux = hook_quit;
\r
5724 core_aux = hook_quit;
\r
5726 /* Set the system suffix */
\r
5727 ANGBAND_SYS = "win";
\r
5729 /* Set the keyboard suffix */
\r
5730 if (7 != GetKeyboardType(0))
\r
5731 ANGBAND_KEYBOARD = "0";
\r
5734 /* Japanese keyboard */
\r
5735 switch (GetKeyboardType(1))
\r
5737 case 0x0D01: case 0x0D02:
\r
5738 case 0x0D03: case 0x0D04:
\r
5739 case 0x0D05: case 0x0D06:
\r
5741 ANGBAND_KEYBOARD = "NEC98";
\r
5745 ANGBAND_KEYBOARD = "JAPAN";
\r
5749 /* Catch nasty signals */
\r
5752 Term_activate(term_screen);
\r
5755 /* We are now initialized */
\r
5756 initialized = TRUE;
\r
5758 if(lpCmdLine[0] == '-'){
\r
5759 switch(lpCmdLine[1])
\r
5764 if (!lpCmdLine[2]) break;
\r
5765 chuukei_server = TRUE;
\r
5766 if(connect_chuukei_server(&lpCmdLine[2])<0){
\r
5767 msg_print("connect fail");
\r
5770 msg_print("connect");
\r
5778 if (!lpCmdLine[2]) break;
\r
5779 chuukei_client = TRUE;
\r
5780 connect_chuukei_server(&lpCmdLine[2]);
\r
5788 if (!lpCmdLine[2]) break;
\r
5789 prepare_browse_movie(&lpCmdLine[2]);
\r
5799 /* Did the user double click on a save file? */
\r
5800 if(!chuukei_server) check_for_save_file(lpCmdLine);
\r
5802 /* Did the user double click on a save file? */
\r
5803 check_for_save_file(lpCmdLine);
\r
5806 /* Prompt the user */
\r
5807 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
\r
5811 /* Process messages forever */
\r
5812 while (GetMessage(&msg, NULL, 0, 0))
\r
5814 TranslateMessage(&msg);
\r
5815 DispatchMessage(&msg);
\r
5826 #endif /* WINDOWS */
\r