3 * @brief Windows版固有実装(メインエントリポイント含む)
\r
5 * @author Hengband Team
\r
9 * Windows98かその前後の頃を起点としたAPI実装。
\r
11 * DirectXといった昨今描画に標準的となったライブラリも用いていない。
\r
12 * タイルの描画処理などについては、現在動作の詳細を検証中。
\r
16 * Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others
\r
18 * This software may be copied and distributed for educational, research,
\r
19 * and not for profit purposes provided that this copyright and statement
\r
20 * are included in all such copies.
\r
23 * This file helps Angband work with Windows computers.
\r
25 * To use this file, use an appropriate "Makefile" or "Project File",
\r
26 * make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and
\r
27 * make sure to obtain various extra files as described below.
\r
29 * The official compilation uses the CodeWarrior Pro compiler, which
\r
30 * includes a special project file and precompilable header file.
\r
34 * <del>See also "main-dos.c" and "main-ibm.c".</del>
\r
38 * The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
\r
39 * and/or color redefinitions.
\r
43 * The "lib/user/font-win.prf" contains attr/char mappings for use with the
\r
44 * normal "lib/xtra/font/*.fon" font files.
\r
48 * The "lib/user/graf-win.prf" contains attr/char mappings for use with the
\r
49 * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
\r
54 * Compiling this file, and using the resulting executable, requires
\r
55 * several extra files not distributed with the standard Angband code.
\r
56 * If "USE_GRAPHICS" is defined, then "readdib.h" and "readdib.c" must
\r
57 * be placed into "src/", and the "8X8.BMP" bitmap file must be placed
\r
58 * into "lib/xtra/graf". In any case, some "*.fon" files (including
\r
59 * "8X13.FON" if nothing else) must be placed into "lib/xtra/font/".
\r
60 * If "USE_SOUND" is defined, then some special library (for example,
\r
61 * "winmm.lib") may need to be linked in, and desired "*.WAV" sound
\r
62 * files must be placed into "lib/xtra/sound/". All of these extra
\r
63 * files can be found in the "ext-win" archive.
\r
67 * The "Term_xtra_win_clear()" function should probably do a low-level
\r
68 * clear of the current window, and redraw the borders and other things,
\r
69 * if only for efficiency. XXX XXX XXX
\r
73 * A simpler method is needed for selecting the "tile size" for windows.
\r
78 * The various "warning" messages assume the existance of the "screen.w"
\r
79 * window, I think, and only a few calls actually check for its existance,
\r
80 * this may be okay since "NULL" means "on top of all windows". (?) The
\r
81 * user must never be allowed to "hide" the main window, or the "menubar"
\r
82 * will disappear. XXX XXX XXX
\r
86 * Special "Windows Help Files" can be placed into "lib/xtra/help/" for
\r
87 * use with the "winhelp.exe" program. These files *may* be available
\r
88 * at the ftp site somewhere, but I have not seen them. XXX XXX XXX
\r
92 * Initial framework (and most code) by Ben Harrison (benh@phial.com).
\r
94 * Original code by Skirmantas Kligys (kligys@scf.usc.edu).
\r
96 * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
\r
97 * and Chris R. Martin (crm7479@tam2000.tamu.edu).
\r
101 #include "angband.h"
\r
104 #include <windows.h>
\r
105 #include <direct.h>
\r
106 #include <locale.h>
\r
107 #include "z-term.h"
\r
110 * Extract the "WIN32" flag from the compiler
\r
112 #if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__)
\r
120 * Hack -- allow use of "screen saver" mode
\r
126 * Menu constants -- see "ANGBAND.RC"
\r
129 #define IDM_FILE_NEW 100
\r
130 #define IDM_FILE_OPEN 101
\r
131 #define IDM_FILE_SAVE 110
\r
132 #define IDM_FILE_SCORE 120
\r
133 #define IDM_FILE_MOVIE 121
\r
134 #define IDM_FILE_EXIT 130
\r
136 #define IDM_WINDOW_VIS_0 200
\r
137 #define IDM_WINDOW_VIS_1 201
\r
138 #define IDM_WINDOW_VIS_2 202
\r
139 #define IDM_WINDOW_VIS_3 203
\r
140 #define IDM_WINDOW_VIS_4 204
\r
141 #define IDM_WINDOW_VIS_5 205
\r
142 #define IDM_WINDOW_VIS_6 206
\r
143 #define IDM_WINDOW_VIS_7 207
\r
145 #define IDM_WINDOW_FONT_0 210
\r
146 #define IDM_WINDOW_FONT_1 211
\r
147 #define IDM_WINDOW_FONT_2 212
\r
148 #define IDM_WINDOW_FONT_3 213
\r
149 #define IDM_WINDOW_FONT_4 214
\r
150 #define IDM_WINDOW_FONT_5 215
\r
151 #define IDM_WINDOW_FONT_6 216
\r
152 #define IDM_WINDOW_FONT_7 217
\r
154 #define IDM_WINDOW_POS_0 220
\r
155 #define IDM_WINDOW_POS_1 221
\r
156 #define IDM_WINDOW_POS_2 222
\r
157 #define IDM_WINDOW_POS_3 223
\r
158 #define IDM_WINDOW_POS_4 224
\r
159 #define IDM_WINDOW_POS_5 225
\r
160 #define IDM_WINDOW_POS_6 226
\r
161 #define IDM_WINDOW_POS_7 227
\r
163 #define IDM_WINDOW_BIZ_0 230
\r
164 #define IDM_WINDOW_BIZ_1 231
\r
165 #define IDM_WINDOW_BIZ_2 232
\r
166 #define IDM_WINDOW_BIZ_3 233
\r
167 #define IDM_WINDOW_BIZ_4 234
\r
168 #define IDM_WINDOW_BIZ_5 235
\r
169 #define IDM_WINDOW_BIZ_6 236
\r
170 #define IDM_WINDOW_BIZ_7 237
\r
172 #define IDM_WINDOW_I_WID_0 240
\r
173 #define IDM_WINDOW_I_WID_1 241
\r
174 #define IDM_WINDOW_I_WID_2 242
\r
175 #define IDM_WINDOW_I_WID_3 243
\r
176 #define IDM_WINDOW_I_WID_4 244
\r
177 #define IDM_WINDOW_I_WID_5 245
\r
178 #define IDM_WINDOW_I_WID_6 246
\r
179 #define IDM_WINDOW_I_WID_7 247
\r
181 #define IDM_WINDOW_D_WID_0 250
\r
182 #define IDM_WINDOW_D_WID_1 251
\r
183 #define IDM_WINDOW_D_WID_2 252
\r
184 #define IDM_WINDOW_D_WID_3 253
\r
185 #define IDM_WINDOW_D_WID_4 254
\r
186 #define IDM_WINDOW_D_WID_5 255
\r
187 #define IDM_WINDOW_D_WID_6 256
\r
188 #define IDM_WINDOW_D_WID_7 257
\r
190 #define IDM_WINDOW_I_HGT_0 260
\r
191 #define IDM_WINDOW_I_HGT_1 261
\r
192 #define IDM_WINDOW_I_HGT_2 262
\r
193 #define IDM_WINDOW_I_HGT_3 263
\r
194 #define IDM_WINDOW_I_HGT_4 264
\r
195 #define IDM_WINDOW_I_HGT_5 265
\r
196 #define IDM_WINDOW_I_HGT_6 266
\r
197 #define IDM_WINDOW_I_HGT_7 267
\r
199 #define IDM_WINDOW_D_HGT_0 270
\r
200 #define IDM_WINDOW_D_HGT_1 271
\r
201 #define IDM_WINDOW_D_HGT_2 272
\r
202 #define IDM_WINDOW_D_HGT_3 273
\r
203 #define IDM_WINDOW_D_HGT_4 274
\r
204 #define IDM_WINDOW_D_HGT_5 275
\r
205 #define IDM_WINDOW_D_HGT_6 276
\r
206 #define IDM_WINDOW_D_HGT_7 277
\r
208 #define IDM_OPTIONS_NO_GRAPHICS 400
\r
209 #define IDM_OPTIONS_OLD_GRAPHICS 401
\r
210 #define IDM_OPTIONS_NEW_GRAPHICS 402
\r
211 #define IDM_OPTIONS_NEW2_GRAPHICS 403
\r
212 #define IDM_OPTIONS_BIGTILE 409
\r
213 #define IDM_OPTIONS_SOUND 410
\r
214 #define IDM_OPTIONS_MUSIC 411
\r
215 #define IDM_OPTIONS_SAVER 420
\r
216 #define IDM_OPTIONS_MAP 430
\r
217 #define IDM_OPTIONS_BG 440
\r
218 #define IDM_OPTIONS_OPEN_BG 441
\r
220 #define IDM_DUMP_SCREEN_HTML 450
\r
222 #define IDM_HELP_CONTENTS 901
\r
227 * This may need to be removed for some compilers XXX XXX XXX
\r
234 * Exclude parts of WINDOWS.H that are not needed
\r
236 #define NOCOMM /* Comm driver APIs and definitions */
\r
237 #define NOLOGERROR /* LogError() and related definitions */
\r
238 #define NOPROFILER /* Profiler APIs */
\r
239 #define NOLFILEIO /* _l* file I/O routines */
\r
240 #define NOOPENFILE /* OpenFile and related definitions */
\r
241 #define NORESOURCE /* Resource management */
\r
242 #define NOATOM /* Atom management */
\r
243 #define NOLANGUAGE /* Character test routines */
\r
244 #define NOLSTRING /* lstr* string management routines */
\r
245 #define NODBCS /* Double-byte character set routines */
\r
246 #define NOKEYBOARDINFO /* Keyboard driver routines */
\r
247 #define NOCOLOR /* COLOR_* color values */
\r
248 #define NODRAWTEXT /* DrawText() and related definitions */
\r
249 #define NOSCALABLEFONT /* Truetype scalable font support */
\r
250 #define NOMETAFILE /* Metafile support */
\r
251 #define NOSYSTEMPARAMSINFO /* SystemParametersInfo() and SPI_* definitions */
\r
252 #define NODEFERWINDOWPOS /* DeferWindowPos and related definitions */
\r
253 #define NOKEYSTATES /* MK_* message key state flags */
\r
254 #define NOWH /* SetWindowsHook and related WH_* definitions */
\r
255 #define NOCLIPBOARD /* Clipboard APIs and definitions */
\r
256 #define NOICONS /* IDI_* icon IDs */
\r
257 #define NOMDI /* MDI support */
\r
258 #define NOHELP /* Help support */
\r
260 /* Not defined since it breaks Borland C++ 5.5 */
\r
261 /* #define NOCTLMGR */ /* Control management and controls */
\r
264 * Exclude parts of WINDOWS.H that are not needed (Win32)
\r
266 #define WIN32_LEAN_AND_MEAN
\r
267 #define NONLS /* All NLS defines and routines */
\r
268 #define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
\r
269 #define NOKANJI /* Kanji support stuff. */
\r
270 #define NOMCX /* Modem Configuration Extensions */
\r
273 * Include the "windows" support file
\r
275 #include <windows.h>
\r
278 * Exclude parts of MMSYSTEM.H that are not needed
\r
280 #define MMNODRV /* Installable driver support */
\r
281 #define MMNOWAVE /* Waveform support */
\r
282 #define MMNOMIDI /* MIDI support */
\r
283 #define MMNOAUX /* Auxiliary audio support */
\r
284 #define MMNOTIMER /* Timer support */
\r
285 #define MMNOJOY /* Joystick support */
\r
286 #define MMNOMCI /* MCI support */
\r
287 #define MMNOMMIO /* Multimedia file I/O support */
\r
288 #define MMNOMMSYSTEM /* General MMSYSTEM functions */
\r
291 * Include some more files. Note: the Cygnus Cygwin compiler
\r
292 * doesn't use mmsystem.h instead it includes the winmm library
\r
293 * which performs a similar function.
\r
295 #include <mmsystem.h>
\r
296 #include <commdlg.h>
\r
299 * HTML-Help requires htmlhelp.h and htmlhelp.lib from Microsoft's
\r
300 * HTML Workshop < http://msdn.microsoft.com/workshop/author/htmlhelp/ >.
\r
302 /* #define HTML_HELP */
\r
305 #include <htmlhelp.h>
\r
306 #endif /* HTML_HELP */
\r
309 * Include the support for loading bitmaps
\r
311 #ifdef USE_GRAPHICS
\r
312 # include "readdib.h"
\r
316 * Hack -- Fake declarations from "dos.h" XXX XXX XXX
\r
319 #define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
\r
321 #define FA_LABEL 0x08 /* Volume label */
\r
322 #define FA_DIREC 0x10 /* Directory */
\r
323 unsigned _cdecl _dos_getfileattr(const char *, unsigned *);
\r
327 * Silliness in WIN32 drawing routine
\r
330 # define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL)
\r
334 * Silliness for Windows 95
\r
336 #ifndef WS_EX_TOOLWINDOW
\r
337 # define WS_EX_TOOLWINDOW 0
\r
341 * Foreground color bits (hard-coded by DOS)
\r
343 #define VID_BLACK 0x00
\r
344 #define VID_BLUE 0x01
\r
345 #define VID_GREEN 0x02
\r
346 #define VID_CYAN 0x03
\r
347 #define VID_RED 0x04
\r
348 #define VID_MAGENTA 0x05
\r
349 #define VID_YELLOW 0x06
\r
350 #define VID_WHITE 0x07
\r
353 * Bright text (hard-coded by DOS)
\r
355 #define VID_BRIGHT 0x08
\r
358 * Background color bits (hard-coded by DOS)
\r
360 #define VUD_BLACK 0x00
\r
361 #define VUD_BLUE 0x10
\r
362 #define VUD_GREEN 0x20
\r
363 #define VUD_CYAN 0x30
\r
364 #define VUD_RED 0x40
\r
365 #define VUD_MAGENTA 0x50
\r
366 #define VUD_YELLOW 0x60
\r
367 #define VUD_WHITE 0x70
\r
370 * Blinking text (hard-coded by DOS)
\r
372 #define VUD_BRIGHT 0x80
\r
378 typedef struct _term_data term_data;
\r
381 * @struct _term_data
\r
382 * @brief ターム情報構造体 / Extra "term" data
\r
385 * pos_x / pos_y は各タームの左上点座標を指す。
\r
388 * tile_wid / tile_hgt は[ウィンドウ]メニューのタイルの幅/高さを~を
\r
389 * 1ドットずつ調整するステータスを指す。
\r
390 * また、フォントを変更すると都度自動調整される。
\r
393 * Note the use of "font_want" for the names of the font file requested by
\r
394 * the user, and the use of "font_file" for the currently active font file.
\r
396 * The "font_file" is uppercased, and takes the form "8X13.FON", while
\r
397 * "font_want" can be in almost any form as long as it could be construed
\r
398 * as attempting to represent the name of a font.
\r
414 TERM_POSITION rows; /* int -> uint */
\r
415 TERM_POSITION cols;
\r
417 uint pos_x; //!< タームの左上X座標
\r
418 uint pos_y; //!< タームの左上Y座標
\r
440 int font_wid; //!< フォント横幅
\r
441 int font_hgt; //!< フォント縦幅
\r
443 int tile_wid; //!< タイル横幅
\r
444 int tile_hgt; //!< タイル縦幅
\r
450 #if 1 /* #ifdef JP */
\r
465 * Maximum number of windows XXX XXX XXX
\r
467 #define MAX_TERM_DATA 8
\r
470 * An array of term_data's
\r
472 static term_data data[MAX_TERM_DATA];
\r
475 * Hack -- global "window creation" pointer
\r
477 static term_data *my_td;
\r
480 * Remember normal size of main window when maxmized
\r
485 * was main window maximized on previous playing
\r
487 bool win_maximized = FALSE;
\r
492 bool game_in_progress = FALSE;
\r
495 * note when "open"/"new" become valid
\r
497 bool initialized = FALSE;
\r
500 * screen paletted, i.e. 256 colors
\r
502 bool paletted = FALSE;
\r
505 * 16 colors screen, don't use RGB()
\r
507 bool colors16 = FALSE;
\r
510 * Saved instance handle
\r
512 static HINSTANCE hInstance;
\r
515 * Yellow brush for the cursor
\r
517 static HBRUSH hbrYellow;
\r
522 static HICON hIcon;
\r
527 static HPALETTE hPal;
\r
530 static HBITMAP hBG = NULL;
\r
531 static int use_bg = 0; //!< 背景使用フラグ、1なら私用。
\r
532 static char bg_bitmap_file[1024] = "bg.bmp"; //!< 現在の背景ビットマップファイル名。
\r
537 * The screen saver window
\r
539 static HWND hwndSaver;
\r
541 #endif /* USE_SAVER */
\r
544 #ifdef USE_GRAPHICS
\r
547 * 現在使用中のタイルID(0ならば未使用)
\r
548 * Flag set once "graphics" has been initialized
\r
550 static byte_hack current_graphics_mode = 0;
\r
553 * The global bitmap
\r
555 static DIBINIT infGraph;
\r
558 * The global bitmap mask
\r
560 static DIBINIT infMask;
\r
562 #endif /* USE_GRAPHICS */
\r
568 * Flag set once "sound" has been initialized
\r
570 static bool can_use_sound = FALSE;
\r
572 #define SAMPLE_MAX 8
\r
574 * An array of sound file names
\r
576 static cptr sound_file[SOUND_MAX][SAMPLE_MAX];
\r
578 #endif /* USE_SOUND */
\r
584 #define SAMPLE_MUSIC_MAX 16
\r
585 static cptr music_file[MUSIC_BASIC_MAX][SAMPLE_MUSIC_MAX];
\r
586 static cptr dungeon_music_file[1000][SAMPLE_MUSIC_MAX];
\r
587 static cptr town_music_file[1000][SAMPLE_MUSIC_MAX];
\r
588 static cptr quest_music_file[1000][SAMPLE_MUSIC_MAX];
\r
589 static bool can_use_music = FALSE;
\r
591 static MCI_OPEN_PARMS mop;
\r
592 static char mci_device_type[256];
\r
594 int current_music_type = 0;
\r
595 int current_music_id = 0;
\r
597 #endif /* USE_MUSIC */
\r
601 * Full path to ANGBAND.INI
\r
603 static cptr ini_file = NULL;
\r
606 * Name of application
\r
608 static cptr AppName = "ANGBAND";
\r
611 * Name of sub-window type
\r
613 static cptr AngList = "AngList";
\r
618 static cptr ANGBAND_DIR_XTRA_GRAF;
\r
619 static cptr ANGBAND_DIR_XTRA_SOUND;
\r
620 static cptr ANGBAND_DIR_XTRA_MUSIC;
\r
621 static cptr ANGBAND_DIR_XTRA_HELP;
\r
622 #if 0 /* #ifndef JP */
\r
623 static cptr ANGBAND_DIR_XTRA_FONT;
\r
626 static cptr ANGBAND_DIR_XTRA_MUSIC;
\r
631 * The "complex" color values
\r
633 static COLORREF win_clr[256];
\r
637 * Flag for macro trigger with dump ASCII
\r
639 static bool Term_no_press = FALSE;
\r
644 static bool mouse_down = FALSE;
\r
645 static bool paint_rect = FALSE;
\r
646 static TERM_POSITION mousex = 0, mousey = 0;
\r
647 static TERM_POSITION oldx, oldy;
\r
651 * The "simple" color values
\r
653 * See "main-ibm.c" for original table information
\r
655 * The entries below are taken from the "color bits" defined above.
\r
657 * Note that many of the choices below suck, but so do crappy monitors.
\r
659 static BYTE win_pal[256] =
\r
661 VID_BLACK, /* Dark */
\r
662 VID_WHITE, /* White */
\r
663 VID_CYAN, /* Slate XXX */
\r
664 VID_RED | VID_BRIGHT, /* Orange XXX */
\r
666 VID_GREEN, /* Green */
\r
667 VID_BLUE, /* Blue */
\r
668 VID_YELLOW, /* Umber XXX */
\r
669 VID_BLACK | VID_BRIGHT, /* Light Dark */
\r
670 VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
\r
671 VID_MAGENTA, /* Violet XXX */
\r
672 VID_YELLOW | VID_BRIGHT, /* Yellow */
\r
673 VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
\r
674 VID_GREEN | VID_BRIGHT, /* Light Green */
\r
675 VID_BLUE | VID_BRIGHT, /* Light Blue */
\r
676 VID_YELLOW /* Light Umber XXX */
\r
681 * Hack -- define which keys are "special"
\r
683 static bool special_key[256];
\r
684 static bool ignore_key[256];
\r
688 * Hack -- initialization list for "special_key"
\r
690 static byte special_key_list[] = {
\r
691 VK_CLEAR, VK_PAUSE, VK_CAPITAL,
\r
692 VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI,
\r
693 VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE,
\r
694 VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
\r
695 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN,
\r
696 VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT,
\r
697 VK_INSERT, VK_DELETE, VK_HELP, VK_APPS,
\r
698 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
\r
699 VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
\r
700 VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD,
\r
701 VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE,
\r
702 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
\r
703 VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
\r
704 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
\r
705 VK_F19,VK_F20, VK_F21, VK_F22, VK_F23, VK_F24,
\r
706 VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL,
\r
707 VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM,
\r
709 0 /* End of List */
\r
712 static byte ignore_key_list[] = {
\r
713 VK_ESCAPE, VK_TAB, VK_SPACE,
\r
714 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
\r
715 VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN,
\r
716 VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL,
\r
717 VK_LMENU, VK_RMENU,
\r
718 0 /* End of List */
\r
722 * Hack -- initialization list for "special_key"
\r
724 * We ignore the modifier keys (shift, control, alt, num lock, scroll lock),
\r
725 * and the normal keys (escape, tab, return, letters, numbers, etc), but we
\r
726 * catch the keypad keys (with and without numlock set, including keypad 5),
\r
727 * the function keys (including the "menu" key which maps to F10), and the
\r
728 * "pause" key (between scroll lock and numlock). We also catch a few odd
\r
729 * keys which I do not recognize, but which are listed among keys which we
\r
730 * do catch, so they should be harmless to catch.
\r
732 static byte special_key_list[] =
\r
734 VK_CLEAR, /* 0x0C (KP<5>) */
\r
736 VK_PAUSE, /* 0x13 (pause) */
\r
738 VK_PRIOR, /* 0x21 (KP<9>) */
\r
739 VK_NEXT, /* 0x22 (KP<3>) */
\r
740 VK_END, /* 0x23 (KP<1>) */
\r
741 VK_HOME, /* 0x24 (KP<7>) */
\r
742 VK_LEFT, /* 0x25 (KP<4>) */
\r
743 VK_UP, /* 0x26 (KP<8>) */
\r
744 VK_RIGHT, /* 0x27 (KP<6>) */
\r
745 VK_DOWN, /* 0x28 (KP<2>) */
\r
746 VK_SELECT, /* 0x29 (?????) */
\r
747 VK_PRINT, /* 0x2A (?????) */
\r
748 VK_EXECUTE, /* 0x2B (?????) */
\r
749 VK_SNAPSHOT, /* 0x2C (?????) */
\r
750 VK_INSERT, /* 0x2D (KP<0>) */
\r
751 VK_DELETE, /* 0x2E (KP<.>) */
\r
752 VK_HELP, /* 0x2F (?????) */
\r
754 VK_NUMPAD0, /* 0x60 (KP<0>) */
\r
755 VK_NUMPAD1, /* 0x61 (KP<1>) */
\r
756 VK_NUMPAD2, /* 0x62 (KP<2>) */
\r
757 VK_NUMPAD3, /* 0x63 (KP<3>) */
\r
758 VK_NUMPAD4, /* 0x64 (KP<4>) */
\r
759 VK_NUMPAD5, /* 0x65 (KP<5>) */
\r
760 VK_NUMPAD6, /* 0x66 (KP<6>) */
\r
761 VK_NUMPAD7, /* 0x67 (KP<7>) */
\r
762 VK_NUMPAD8, /* 0x68 (KP<8>) */
\r
763 VK_NUMPAD9, /* 0x69 (KP<9>) */
\r
764 VK_MULTIPLY, /* 0x6A (KP<*>) */
\r
765 VK_ADD, /* 0x6B (KP<+>) */
\r
766 VK_SEPARATOR, /* 0x6C (?????) */
\r
767 VK_SUBTRACT, /* 0x6D (KP<->) */
\r
768 VK_DECIMAL, /* 0x6E (KP<.>) */
\r
769 VK_DIVIDE, /* 0x6F (KP</>) */
\r
800 /* Function prototype */
\r
802 static bool is_already_running(void);
\r
806 static void delete_bg(void)
\r
815 static int init_bg(void)
\r
817 char * bmfile = bg_bitmap_file;
\r
820 if (use_bg == 0) return 0;
\r
822 hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
\r
824 plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
\r
829 HDC wnddc, dcimage, dcbg;
\r
830 HBITMAP bmimage, bmimage_old, bmbg_old;
\r
835 wnddc = GetDC(hwnd);
\r
836 dcimage = CreateCompatibleDC(wnddc);
\r
837 dcbg = CreateCompatibleDC(wnddc);
\r
839 bmimage = LoadImage(NULL, "bg.bmp", LR_LOADFROMFILE, 0, 0, 0);
\r
840 if (!bmimage) quit("bg.bmpが読みこめない!");
\r
841 bmimage_old = SelectObject(dcimage, bmimage);
\r
843 CreateCompatibleBitmap();
\r
845 ReleaseDC(hwnd, wnddc);
\r
851 static void DrawBG(HDC hdc, RECT *r)
\r
856 int x = r->left, y = r->top;
\r
857 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
\r
859 if (!use_bg || !hBG)
\r
863 GetObject(hBG, sizeof(bm), &bm);
\r
864 swid = bm.bmWidth; shgt = bm.bmHeight;
\r
866 hdcSrc = CreateCompatibleDC(hdc);
\r
867 hOld = SelectObject(hdcSrc, hBG);
\r
871 cwid = MIN(swid - sx, r->right - nx);
\r
874 chgt = MIN(shgt - sy, r->bottom - ny);
\r
875 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
\r
877 } while (ny < r->bottom);
\r
880 } while (nx < r->right);
\r
882 SelectObject(hdcSrc, hOld);
\r
888 * Hack -- given a pathname, point at the filename
\r
890 static cptr extract_file_name(cptr s)
\r
894 /* Start at the end */
\r
895 p = s + strlen(s) - 1;
\r
897 /* Back up to divider */
\r
898 while ((p >= s) && (*p != ':') && (*p != '\\')) p--;
\r
900 /* Return file name */
\r
907 * Hack -- given a simple filename, extract the "font size" info
\r
909 * Return a pointer to a static buffer holding the capitalized base name.
\r
911 #if 0 /* #ifndef JP */
\r
912 static char *analyze_font(char *path, int *wp, int *hp)
\r
918 /* Start at the end */
\r
919 p = path + strlen(path) - 1;
\r
921 /* Back up to divider */
\r
922 while ((p >= path) && (*p != ':') && (*p != '\\')) --p;
\r
924 /* Advance to file name */
\r
928 for (s = p; *s; ++s)
\r
930 /* Capitalize (be paranoid) */
\r
931 if (islower(*s)) *s = toupper(*s);
\r
934 /* Find first 'X' */
\r
935 s = my_strchr(p, 'X');
\r
937 /* Extract font width */
\r
940 /* Extract height */
\r
941 hgt = s ? atoi(s+1) : 0;
\r
954 * Check for existance of a file
\r
956 static bool check_file(cptr s)
\r
966 unsigned int attrib;
\r
976 attrib = GetFileAttributes(path);
\r
978 /* Require valid filename */
\r
979 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
981 /* Prohibit directory */
\r
982 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return (FALSE);
\r
986 /* Examine and verify */
\r
987 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
989 /* Prohibit something */
\r
990 if (attrib & FA_LABEL) return (FALSE);
\r
992 /* Prohibit directory */
\r
993 if (attrib & FA_DIREC) return (FALSE);
\r
1003 * Check for existance of a directory
\r
1005 static bool check_dir(cptr s)
\r
1017 unsigned int attrib;
\r
1019 #endif /* WIN32 */
\r
1024 /* Check length */
\r
1027 /* Remove trailing backslash */
\r
1028 if (i && (path[i-1] == '\\')) path[--i] = '\0';
\r
1033 attrib = GetFileAttributes(path);
\r
1035 /* Require valid filename */
\r
1036 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
1038 /* Require directory */
\r
1039 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE);
\r
1043 /* Examine and verify */
\r
1044 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
1046 /* Prohibit something */
\r
1047 if (attrib & FA_LABEL) return (FALSE);
\r
1049 /* Require directory */
\r
1050 if (!(attrib & FA_DIREC)) return (FALSE);
\r
1052 #endif /* WIN32 */
\r
1062 static void validate_file(cptr s)
\r
1064 /* Verify or fail */
\r
1065 if (!check_file(s))
\r
1067 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
\r
1073 * Validate a directory
\r
1075 static void validate_dir(cptr s, bool vital)
\r
1077 /* Verify or fail */
\r
1078 if (!check_dir(s))
\r
1080 /* This directory contains needed data */
\r
1083 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
\r
1085 /* Attempt to create this directory */
\r
1086 else if (mkdir(s))
\r
1088 quit_fmt("Unable to create directory:\n%s", s);
\r
1095 * Get the "size" for a window
\r
1097 static void term_getsize(term_data *td)
\r
1104 if (td->cols < 1) td->cols = 1;
\r
1105 if (td->rows < 1) td->rows = 1;
\r
1107 /* Window sizes */
\r
1108 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
1109 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
\r
1111 /* Fake window size */
\r
1113 rc.right = rc.left + wid;
\r
1115 rc.bottom = rc.top + hgt;
\r
1118 /* rc.right += 1; */
\r
1119 /* rc.bottom += 1; */
\r
1122 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
1125 td->size_wid = rc.right - rc.left;
\r
1126 td->size_hgt = rc.bottom - rc.top;
\r
1128 /* See CreateWindowEx */
\r
1129 if (!td->w) return;
\r
1131 /* Extract actual location */
\r
1132 GetWindowRect(td->w, &rc);
\r
1134 /* Save the location */
\r
1135 td->pos_x = rc.left;
\r
1136 td->pos_y = rc.top;
\r
1141 * Write the "prefs" for a single term
\r
1143 static void save_prefs_aux(int i)
\r
1145 term_data *td = &data[i];
\r
1146 char sec_name[128];
\r
1150 WINDOWPLACEMENT lpwndpl;
\r
1153 if (!td->w) return;
\r
1155 /* Make section name */
\r
1156 sprintf(sec_name, "Term-%d", i);
\r
1161 strcpy(buf, td->visible ? "1" : "0");
\r
1162 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
\r
1167 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "MS ゴシック");
\r
1170 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
\r
1172 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
\r
1176 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
\r
1178 #if 1 /* #ifdef JP */
\r
1179 wsprintf(buf, "%d", td->lf.lfWidth);
\r
1180 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
\r
1181 wsprintf(buf, "%d", td->lf.lfHeight);
\r
1182 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
\r
1183 wsprintf(buf, "%d", td->lf.lfWeight);
\r
1184 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
\r
1187 strcpy(buf, td->bizarre ? "1" : "0");
\r
1188 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
\r
1190 /* Tile size (x) */
\r
1191 wsprintf(buf, "%d", td->tile_wid);
\r
1192 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
\r
1194 /* Tile size (y) */
\r
1195 wsprintf(buf, "%d", td->tile_hgt);
\r
1196 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
\r
1198 /* Get window placement and dimensions */
\r
1199 lpwndpl.length = sizeof(WINDOWPLACEMENT);
\r
1200 GetWindowPlacement(td->w, &lpwndpl);
\r
1202 /* Acquire position in *normal* mode (not minimized) */
\r
1203 rc = lpwndpl.rcNormalPosition;
\r
1205 /* Window size (x) */
\r
1206 if (i == 0) wsprintf(buf, "%d", normsize.x);
\r
1207 else wsprintf(buf, "%d", td->cols);
\r
1208 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
\r
1210 /* Window size (y) */
\r
1211 if (i == 0) wsprintf(buf, "%d", normsize.y);
\r
1212 else wsprintf(buf, "%d", td->rows);
\r
1213 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
\r
1215 /* Maxmized (only main window) */
\r
1218 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
\r
1219 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
\r
1222 /* Acquire position */
\r
1223 GetWindowRect(td->w, &rc);
\r
1225 /* Window position (x) */
\r
1226 wsprintf(buf, "%d", rc.left);
\r
1227 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
\r
1229 /* Window position (y) */
\r
1230 wsprintf(buf, "%d", rc.top);
\r
1231 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
\r
1233 /* Window Z position */
\r
1236 strcpy(buf, td->posfix ? "1" : "0");
\r
1237 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
\r
1243 * Write the "prefs"
\r
1245 * We assume that the windows have all been initialized
\r
1247 static void save_prefs(void)
\r
1253 /* Save the "arg_graphics" flag */
\r
1254 sprintf(buf, "%d", arg_graphics);
\r
1255 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
\r
1257 /* Save the "arg_bigtile" flag */
\r
1258 strcpy(buf, arg_bigtile ? "1" : "0");
\r
1259 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
\r
1261 /* Save the "arg_sound" flag */
\r
1262 strcpy(buf, arg_sound ? "1" : "0");
\r
1263 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
\r
1265 /* Save the "arg_sound" flag */
\r
1266 strcpy(buf, arg_music ? "1" : "0");
\r
1267 WritePrivateProfileString("Angband", "Music", buf, ini_file);
\r
1270 strcpy(buf, use_bg ? "1" : "0");
\r
1271 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
\r
1272 WritePrivateProfileString("Angband", "BackGroundBitmap",
\r
1273 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
\r
1275 /* Save window prefs */
\r
1276 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1278 save_prefs_aux(i);
\r
1284 * Load the "prefs" for a single term
\r
1286 static void load_prefs_aux(int i)
\r
1288 term_data *td = &data[i];
\r
1289 char sec_name[128];
\r
1292 int wid, hgt, posx, posy;
\r
1293 int dispx = GetSystemMetrics( SM_CXVIRTUALSCREEN);
\r
1294 int dispy = GetSystemMetrics( SM_CYVIRTUALSCREEN);
\r
1298 /* Make section name */
\r
1299 sprintf(sec_name, "Term-%d", i);
\r
1301 /* Make section name */
\r
1302 sprintf(sec_name, "Term-%d", i);
\r
1307 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
\r
1310 /* Desired font, with default */
\r
1312 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
\r
1315 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
\r
1317 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
\r
1323 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
\r
1325 /* Analyze font, save desired font name */
\r
1326 #if 1 /* #ifdef JP */
\r
1327 td->font_want = string_make(tmp);
\r
1328 hgt = 15; wid = 0;
\r
1329 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
\r
1330 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
\r
1331 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
\r
1333 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
\r
1338 #if 1 /* #ifdef JP */
\r
1339 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
\r
1340 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
\r
1342 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
\r
1343 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
\r
1348 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
\r
1349 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
\r
1350 normsize.x = td->cols; normsize.y = td->rows;
\r
1355 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
\r
1358 /* Window position */
\r
1359 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
\r
1360 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
\r
1361 td->pos_x = MIN(MAX(0, posx), dispx-128);
\r
1362 td->pos_y = MIN(MAX(0, posy), dispy-128);
\r
1364 /* Window Z position */
\r
1367 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
\r
1373 * Load the "prefs"
\r
1375 static void load_prefs(void)
\r
1379 /* Extract the "arg_graphics" flag */
\r
1380 arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
\r
1382 /* Extract the "arg_bigtile" flag */
\r
1383 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
\r
1384 use_bigtile = arg_bigtile;
\r
1386 /* Extract the "arg_sound" flag */
\r
1387 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
\r
1389 /* Extract the "arg_sound" flag */
\r
1390 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
\r
1393 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
\r
1394 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
\r
1396 /* Load window prefs */
\r
1397 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1399 load_prefs_aux(i);
\r
1403 #if defined(USE_SOUND) || defined(USE_MUSIC)
\r
1406 * XXX XXX XXX - Taken from files.c.
\r
1408 * Extract "tokens" from a buffer
\r
1410 * This function uses "whitespace" as delimiters, and treats any amount of
\r
1411 * whitespace as a single delimiter. We will never return any empty tokens.
\r
1412 * When given an empty buffer, or a buffer containing only "whitespace", we
\r
1413 * will return no tokens. We will never extract more than "num" tokens.
\r
1415 * By running a token through the "text_to_ascii()" function, you can allow
\r
1416 * that token to include (encoded) whitespace, using "\s" to encode spaces.
\r
1418 * We save pointers to the tokens in "tokens", and return the number found.
\r
1420 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
\r
1430 /* Skip leading whitespace */
\r
1431 for ( ; *s && iswspace(*s); ++s) /* loop */;
\r
1436 /* Find next whitespace, if any */
\r
1437 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
\r
1439 /* Nuke and advance (if necessary) */
\r
1440 if (*t) *t++ = '\0';
\r
1442 /* Save the token */
\r
1453 #endif /* USE_SOUND || USE_MUSIC */
\r
1457 static void load_sound_prefs(void)
\r
1461 char ini_path[1024];
\r
1462 char wav_path[1024];
\r
1463 char *zz[SAMPLE_MAX];
\r
1465 /* Access the sound.cfg */
\r
1467 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
\r
1469 for (i = 0; i < SOUND_MAX; i++)
\r
1471 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
\r
1473 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
\r
1475 for (j = 0; j < num; j++)
\r
1477 /* Access the sound */
\r
1478 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
\r
1480 /* Save the sound filename, if it exists */
\r
1481 if (check_file(wav_path))
\r
1482 sound_file[i][j] = string_make(zz[j]);
\r
1487 #endif /* USE_SOUND */
\r
1491 static void load_music_prefs(void)
\r
1495 char ini_path[1024];
\r
1496 char wav_path[1024];
\r
1497 char *zz[SAMPLE_MAX];
\r
1500 /* Access the music.cfg */
\r
1502 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
\r
1504 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
\r
1506 for (i = 0; i < MUSIC_BASIC_MAX; i++)
\r
1508 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
\r
1510 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1512 for (j = 0; j < num; j++)
\r
1514 /* Access the sound */
\r
1515 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1517 /* Save the sound filename, if it exists */
\r
1518 if (check_file(wav_path))
\r
1519 music_file[i][j] = string_make(zz[j]);
\r
1523 for (i = 0; i < max_d_idx; i++)
\r
1525 sprintf(key, "dungeon%03d", i);
\r
1526 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
\r
1528 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1530 for (j = 0; j < num; j++)
\r
1532 /* Access the sound */
\r
1533 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1535 /* Save the sound filename, if it exists */
\r
1536 if (check_file(wav_path))
\r
1537 dungeon_music_file[i][j] = string_make(zz[j]);
\r
1541 for (i = 0; i < max_q_idx; i++)
\r
1543 sprintf(key, "quest%03d", i);
\r
1544 GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
\r
1546 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1548 for (j = 0; j < num; j++)
\r
1550 /* Access the sound */
\r
1551 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1553 /* Save the sound filename, if it exists */
\r
1554 if (check_file(wav_path))
\r
1555 quest_music_file[i][j] = string_make(zz[j]);
\r
1559 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
\r
1561 sprintf(key, "town%03d", i);
\r
1562 GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
\r
1564 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1566 for (j = 0; j < num; j++)
\r
1568 /* Access the sound */
\r
1569 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1571 /* Save the sound filename, if it exists */
\r
1572 if (check_file(wav_path))
\r
1573 town_music_file[i][j] = string_make(zz[j]);
\r
1580 #endif /* USE_MUSIC */
\r
1583 * Create the new global palette based on the bitmap palette
\r
1584 * (if any), and the standard 16 entry palette derived from
\r
1585 * "win_clr[]" which is used for the basic 16 Angband colors.
\r
1587 * This function is never called before all windows are ready.
\r
1589 * This function returns FALSE if the new palette could not be
\r
1590 * prepared, which should normally be a fatal error. XXX XXX
\r
1592 * Note that only some machines actually use a "palette".
\r
1594 static int new_palette(void)
\r
1602 LPLOGPALETTE pLogPal;
\r
1603 LPPALETTEENTRY lppe;
\r
1608 /* This makes no sense */
\r
1609 if (!paletted) return (TRUE);
\r
1617 #ifdef USE_GRAPHICS
\r
1619 /* Check the bitmap palette */
\r
1620 hBmPal = infGraph.hPalette;
\r
1622 /* Use the bitmap */
\r
1625 lppeSize = 256 * sizeof(PALETTEENTRY);
\r
1626 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
\r
1627 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
\r
1628 if ((nEntries == 0) || (nEntries > 220))
\r
1630 /* Warn the user */
\r
1631 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
\r
1634 rnfree(lppe, lppeSize);
\r
1641 #endif /* USE_GRAPHICS */
\r
1643 /* Size of palette */
\r
1644 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
\r
1646 /* Allocate palette */
\r
1647 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
\r
1650 pLogPal->palVersion = 0x300;
\r
1652 /* Make room for bitmap and normal data */
\r
1653 pLogPal->palNumEntries = nEntries + 16;
\r
1655 /* Save the bitmap data */
\r
1656 for (i = 0; i < nEntries; i++)
\r
1658 pLogPal->palPalEntry[i] = lppe[i];
\r
1661 /* Save the normal data */
\r
1662 for (i = 0; i < 16; i++)
\r
1666 /* Access the entry */
\r
1667 p = &(pLogPal->palPalEntry[i+nEntries]);
\r
1669 /* Save the colors */
\r
1670 p->peRed = GetRValue(win_clr[i]);
\r
1671 p->peGreen = GetGValue(win_clr[i]);
\r
1672 p->peBlue = GetBValue(win_clr[i]);
\r
1674 /* Save the flags */
\r
1675 p->peFlags = PC_NOCOLLAPSE;
\r
1678 /* Free something */
\r
1679 if (lppe) rnfree(lppe, lppeSize);
\r
1681 /* Create a new palette, or fail */
\r
1682 hNewPal = CreatePalette(pLogPal);
\r
1683 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
\r
1685 /* Free the palette */
\r
1686 rnfree(pLogPal, pLogPalSize);
\r
1691 /* Realize the palette */
\r
1692 hdc = GetDC(td->w);
\r
1693 SelectPalette(hdc, hNewPal, 0);
\r
1694 i = RealizePalette(hdc);
\r
1695 ReleaseDC(td->w, hdc);
\r
1696 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
\r
1700 for (i = 1; i < MAX_TERM_DATA; i++)
\r
1704 hdc = GetDC(td->w);
\r
1705 SelectPalette(hdc, hNewPal, 0);
\r
1706 ReleaseDC(td->w, hdc);
\r
1709 /* Delete old palette */
\r
1710 if (hPal) DeleteObject(hPal);
\r
1712 /* Save new palette */
\r
1720 #ifdef USE_GRAPHICS
\r
1722 * @brief グラフィクスを初期化する / Initialize graphics
\r
1725 * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
\r
1726 * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
\r
1729 static bool init_graphics(void)
\r
1731 /* Initialize once */
\r
1733 BYTE wid, hgt, twid, thgt, ox, oy;
\r
1736 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1744 name = "16X16.BMP";
\r
1746 ANGBAND_GRAF = "new";
\r
1748 else if (arg_graphics == GRAPHICS_HENGBAND)
\r
1757 name = "64X64.BMP";
\r
1766 name = "32X32.BMP";
\r
1768 ANGBAND_GRAF = "ne2";
\r
1779 ANGBAND_GRAF = "old";
\r
1782 /* Access the bitmap file */
\r
1783 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
\r
1785 /* Load the bitmap or quit */
\r
1786 if (!ReadDIB(data[0].w, buf, &infGraph))
\r
1788 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
\r
1792 /* Save the new sizes */
\r
1793 infGraph.CellWidth = wid;
\r
1794 infGraph.CellHeight = hgt;
\r
1795 infGraph.TileWidth = twid;
\r
1796 infGraph.TileHeight = thgt;
\r
1797 infGraph.OffsetX = ox;
\r
1798 infGraph.OffsetY = oy;
\r
1800 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1802 /* Access the mask file */
\r
1803 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
\r
1805 /* Load the bitmap or quit */
\r
1806 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1808 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1812 if (arg_graphics == GRAPHICS_HENGBAND)
\r
1814 /* Access the mask file */
\r
1815 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
\r
1817 /* Load the bitmap or quit */
\r
1818 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1820 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1825 /* Activate a palette */
\r
1826 if (!new_palette())
\r
1828 /* Free bitmap XXX XXX XXX */
\r
1831 plog(_("パレットを実現できません!", "Cannot activate palette!"));
\r
1835 /* Graphics available */
\r
1836 current_graphics_mode = arg_graphics;
\r
1839 return (current_graphics_mode);
\r
1841 #endif /* USE_GRAPHICS */
\r
1846 * Initialize music
\r
1848 static bool init_music(void)
\r
1850 /* Initialize once */
\r
1851 if (!can_use_music)
\r
1853 /* Load the prefs */
\r
1854 load_music_prefs();
\r
1856 /* Sound available */
\r
1857 can_use_music = TRUE;
\r
1861 return (can_use_music);
\r
1865 * Hack -- Stop a music
\r
1867 static void stop_music(void)
\r
1869 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
1870 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
1873 #endif /* USE_MUSIC */
\r
1877 * Initialize sound
\r
1879 static bool init_sound(void)
\r
1881 /* Initialize once */
\r
1882 if (!can_use_sound)
\r
1884 /* Load the prefs */
\r
1885 load_sound_prefs();
\r
1887 /* Sound available */
\r
1888 can_use_sound = TRUE;
\r
1892 return (can_use_sound);
\r
1894 #endif /* USE_SOUND */
\r
1900 static void term_window_resize(term_data *td)
\r
1902 /* Require window */
\r
1903 if (!td->w) return;
\r
1905 /* Resize the window */
\r
1906 SetWindowPos(td->w, 0, 0, 0,
\r
1907 td->size_wid, td->size_hgt,
\r
1908 SWP_NOMOVE | SWP_NOZORDER);
\r
1910 /* Redraw later */
\r
1911 InvalidateRect(td->w, NULL, TRUE);
\r
1916 * Force the use of a new "font file" for a term_data
\r
1918 * This function may be called before the "window" is ready
\r
1920 * This function returns zero only if everything succeeds.
\r
1922 * Note that the "font name" must be capitalized!!!
\r
1924 static errr term_force_font(term_data *td, cptr path)
\r
1928 #if 0 /* #ifndef JP */
\r
1934 /* Forget the old font (if needed) */
\r
1935 if (td->font_id) DeleteObject(td->font_id);
\r
1937 #if 1 /* #ifdef JP */
\r
1941 /* Create the font (using the 'base' of the font file name!) */
\r
1942 td->font_id = CreateFontIndirect(&(td->lf));
\r
1943 wid = td->lf.lfWidth;
\r
1944 hgt = td->lf.lfHeight;
\r
1945 if (!td->font_id) return (1);
\r
1947 /* Forget old font */
\r
1948 if (td->font_file)
\r
1950 bool used = FALSE;
\r
1952 /* Scan windows */
\r
1953 for (i = 0; i < MAX_TERM_DATA; i++)
\r
1955 /* Don't check when closing the application */
\r
1958 /* Check "screen" */
\r
1959 if ((td != &data[i]) &&
\r
1960 (data[i].font_file) &&
\r
1961 (streq(data[i].font_file, td->font_file)))
\r
1967 /* Remove unused font resources */
\r
1968 if (!used) RemoveFontResource(td->font_file);
\r
1970 /* Free the old name */
\r
1971 string_free(td->font_file);
\r
1974 td->font_file = NULL;
\r
1977 /* No path given */
\r
1978 if (!path) return (1);
\r
1981 strcpy(buf, path);
\r
1983 /* Analyze font path */
\r
1984 base = analyze_font(buf, &wid, &hgt);
\r
1986 /* Verify suffix */
\r
1987 if (!suffix(base, ".FON")) return (1);
\r
1990 if (!check_file(buf)) return (1);
\r
1992 /* Load the new font */
\r
1993 if (!AddFontResource(buf)) return (1);
\r
1995 /* Save new font name */
\r
1996 td->font_file = string_make(base);
\r
1998 /* Remove the "suffix" */
\r
1999 base[strlen(base)-4] = '\0';
\r
2001 /* Create the font (using the 'base' of the font file name!) */
\r
2002 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
\r
2003 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
\r
2004 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
\r
2005 FIXED_PITCH | FF_DONTCARE, base);
\r
2008 /* Hack -- Unknown size */
\r
2015 /* all this trouble to get the cell size */
\r
2016 hdcDesktop = GetDC(HWND_DESKTOP);
\r
2017 hfOld = SelectObject(hdcDesktop, td->font_id);
\r
2018 GetTextMetrics(hdcDesktop, &tm);
\r
2019 SelectObject(hdcDesktop, hfOld);
\r
2020 ReleaseDC(HWND_DESKTOP, hdcDesktop);
\r
2022 /* Font size info */
\r
2023 wid = tm.tmAveCharWidth;
\r
2024 hgt = tm.tmHeight;
\r
2027 /* Save the size info */
\r
2028 td->font_wid = wid;
\r
2029 td->font_hgt = hgt;
\r
2038 * Allow the user to change the font for this window.
\r
2040 static void term_change_font(term_data *td)
\r
2042 #if 1 /* #ifdef JP */
\r
2045 memset(&cf, 0, sizeof(cf));
\r
2046 cf.lStructSize = sizeof(cf);
\r
2047 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
\r
2048 cf.lpLogFont = &(td->lf);
\r
2050 if (ChooseFont(&cf))
\r
2052 /* Force the font */
\r
2053 term_force_font(td, NULL);
\r
2055 /* Assume not bizarre */
\r
2056 td->bizarre = TRUE;
\r
2058 /* Reset the tile info */
\r
2059 td->tile_wid = td->font_wid;
\r
2060 td->tile_hgt = td->font_hgt;
\r
2062 /* Analyze the font */
\r
2065 /* Resize the window */
\r
2066 term_window_resize(td);
\r
2072 char tmp[1024] = "";
\r
2074 /* Extract a default if possible */
\r
2075 if (td->font_file) strcpy(tmp, td->font_file);
\r
2077 /* Ask for a choice */
\r
2078 memset(&ofn, 0, sizeof(ofn));
\r
2079 ofn.lStructSize = sizeof(ofn);
\r
2080 ofn.hwndOwner = data[0].w;
\r
2081 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
\r
2082 ofn.nFilterIndex = 1;
\r
2083 ofn.lpstrFile = tmp;
\r
2084 ofn.nMaxFile = 128;
\r
2085 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
\r
2086 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
2087 ofn.lpstrDefExt = "fon";
\r
2089 /* Force choice if legal */
\r
2090 if (GetOpenFileName(&ofn))
\r
2092 /* Force the font */
\r
2093 if (term_force_font(td, tmp))
\r
2095 /* Access the standard font file */
\r
2096 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
2098 /* Force the use of that font */
\r
2099 (void)term_force_font(td, tmp);
\r
2102 /* Assume not bizarre */
\r
2103 td->bizarre = FALSE;
\r
2105 /* Reset the tile info */
\r
2106 td->tile_wid = td->font_wid;
\r
2107 td->tile_hgt = td->font_hgt;
\r
2109 /* Analyze the font */
\r
2112 /* Resize the window */
\r
2113 term_window_resize(td);
\r
2120 * Allow the user to lock this window.
\r
2122 static void term_window_pos(term_data *td, HWND hWnd)
\r
2124 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
\r
2125 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
\r
2128 static void windows_map(void);
\r
2131 * Hack -- redraw a term_data
\r
2133 static void term_data_redraw(term_data *td)
\r
2135 if (td->map_active)
\r
2137 /* Redraw the map */
\r
2142 /* Activate the term */
\r
2143 Term_activate(&td->t);
\r
2145 /* Redraw the contents */
\r
2148 /* Restore the term */
\r
2149 Term_activate(term_screen);
\r
2154 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
\r
2158 HBRUSH myBrush, oldBrush;
\r
2160 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
\r
2161 int tx = td->size_ow1 + x * td->tile_wid;
\r
2162 int ty = td->size_oh1 + y * td->tile_hgt;
\r
2163 int tw = w * td->tile_wid - 1;
\r
2164 int th = h * td->tile_hgt - 1;
\r
2166 hdc = GetDC(hWnd);
\r
2167 myBrush = CreateSolidBrush(RGB(255, 255, 255));
\r
2168 oldBrush = SelectObject(hdc, myBrush);
\r
2169 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2171 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
\r
2173 SelectObject(hdc, oldBrush);
\r
2174 SelectObject(hdc, oldPen);
\r
2179 /*** Function hooks needed by "Term" ***/
\r
2185 * Initialize a new Term
\r
2187 static void Term_init_win(term *t)
\r
2194 * Nuke an old Term
\r
2196 static void Term_nuke_win(term *t)
\r
2205 * Interact with the User
\r
2207 static errr Term_user_win(int n)
\r
2218 * React to global changes
\r
2220 static errr Term_xtra_win_react(void)
\r
2225 /* Simple color */
\r
2228 /* Save the default colors */
\r
2229 for (i = 0; i < 256; i++)
\r
2231 /* Simply accept the desired colors */
\r
2232 win_pal[i] = angband_color_table[i][0];
\r
2236 /* Complex color */
\r
2243 bool change = FALSE;
\r
2245 /* Save the default colors */
\r
2246 for (i = 0; i < 256; i++)
\r
2248 /* Extract desired values */
\r
2249 rv = angband_color_table[i][1];
\r
2250 gv = angband_color_table[i][2];
\r
2251 bv = angband_color_table[i][3];
\r
2253 /* Extract a full color code */
\r
2254 code = PALETTERGB(rv, gv, bv);
\r
2256 /* Activate changes */
\r
2257 if (win_clr[i] != code)
\r
2259 /* Note the change */
\r
2262 /* Apply the desired color */
\r
2263 win_clr[i] = code;
\r
2267 /* Activate the palette if needed */
\r
2268 if (change) (void)new_palette();
\r
2274 /* Handle "arg_sound" */
\r
2275 if (use_sound != arg_sound)
\r
2277 /* Initialize (if needed) */
\r
2278 if (arg_sound && !init_sound())
\r
2281 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
\r
2283 /* Cannot enable */
\r
2284 arg_sound = FALSE;
\r
2287 /* Change setting */
\r
2288 use_sound = arg_sound;
\r
2295 /* Handle "arg_sound" */
\r
2296 if (use_music != arg_music)
\r
2298 /* Initialize (if needed) */
\r
2299 if (arg_music && !init_music())
\r
2302 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
\r
2303 /* Cannot enable */
\r
2304 arg_music = FALSE;
\r
2307 /* Change setting */
\r
2308 use_music = arg_music;
\r
2310 if(!arg_music) stop_music();
\r
2311 else select_floor_music();
\r
2318 #ifdef USE_GRAPHICS
\r
2320 /* Handle "arg_graphics" */
\r
2321 if (use_graphics != arg_graphics)
\r
2323 /* Initialize (if needed) */
\r
2324 if (arg_graphics && !init_graphics())
\r
2327 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
\r
2329 /* Cannot enable */
\r
2330 arg_graphics = GRAPHICS_NONE;
\r
2333 /* Change setting */
\r
2334 use_graphics = arg_graphics;
\r
2336 /* Reset visuals */
\r
2337 #ifdef ANGBAND_2_8_1
\r
2339 #else /* ANGBAND_2_8_1 */
\r
2340 reset_visuals(TRUE);
\r
2341 #endif /* ANGBAND_2_8_1 */
\r
2344 #endif /* USE_GRAPHICS */
\r
2347 /* Clean up windows */
\r
2348 for (i = 0; i < MAX_TERM_DATA; i++)
\r
2352 term_data *td = &data[i];
\r
2354 /* Update resized windows */
\r
2355 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
\r
2358 Term_activate(&td->t);
\r
2360 /* Hack -- Resize the term */
\r
2361 Term_resize(td->cols, td->rows);
\r
2363 /* Redraw the contents */
\r
2367 Term_activate(old);
\r
2378 * Process at least one event
\r
2380 static errr Term_xtra_win_event(int v)
\r
2384 /* Wait for an event */
\r
2388 if (GetMessage(&msg, NULL, 0, 0))
\r
2390 TranslateMessage(&msg);
\r
2391 DispatchMessage(&msg);
\r
2395 /* Check for an event */
\r
2399 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2401 TranslateMessage(&msg);
\r
2402 DispatchMessage(&msg);
\r
2412 * Process all pending events
\r
2414 static errr Term_xtra_win_flush(void)
\r
2418 /* Process all pending events */
\r
2419 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2421 TranslateMessage(&msg);
\r
2422 DispatchMessage(&msg);
\r
2431 * Hack -- clear the screen
\r
2433 * Make this more efficient XXX XXX XXX
\r
2435 static errr Term_xtra_win_clear(void)
\r
2437 term_data *td = (term_data*)(Term->data);
\r
2442 /* Rectangle to erase */
\r
2443 rc.left = td->size_ow1;
\r
2444 rc.right = rc.left + td->cols * td->tile_wid;
\r
2445 rc.top = td->size_oh1;
\r
2446 rc.bottom = rc.top + td->rows * td->tile_hgt;
\r
2449 hdc = GetDC(td->w);
\r
2450 SetBkColor(hdc, RGB(0, 0, 0));
\r
2451 SelectObject(hdc, td->font_id);
\r
2452 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2457 rc.left = 0; rc.top = 0;
\r
2460 ReleaseDC(td->w, hdc);
\r
2468 * Hack -- make a noise
\r
2470 static errr Term_xtra_win_noise(void)
\r
2472 MessageBeep(MB_ICONASTERISK);
\r
2478 * Hack -- make a sound
\r
2480 static errr Term_xtra_win_sound(int v)
\r
2485 #endif /* USE_SOUND */
\r
2487 /* Sound disabled */
\r
2488 if (!use_sound) return (1);
\r
2490 /* Illegal sound */
\r
2491 if ((v < 0) || (v >= SOUND_MAX)) return (1);
\r
2495 /* Count the samples */
\r
2496 for (i = 0; i < SAMPLE_MAX; i++)
\r
2498 if (!sound_file[v][i])
\r
2503 if (i == 0) return (1);
\r
2505 /* Build the path */
\r
2506 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
\r
2510 /* Play the sound, catch errors */
\r
2511 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
\r
2515 /* Play the sound, catch errors */
\r
2516 return (sndPlaySound(buf, SND_ASYNC));
\r
2518 #endif /* WIN32 */
\r
2520 #else /* USE_SOUND */
\r
2525 #endif /* USE_SOUND */
\r
2529 * Hack -- play a music
\r
2531 static errr Term_xtra_win_music(int n, int v)
\r
2536 #endif /* USE_MUSIC */
\r
2538 /* Sound disabled */
\r
2540 if(!use_music) return (1);
\r
2542 /* Illegal sound */
\r
2543 if(n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return (1);
\r
2544 else if(v < 0 || v >= 1000) return(1); /*!< TODO */
\r
2550 case TERM_XTRA_MUSIC_BASIC:
\r
2551 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2553 case TERM_XTRA_MUSIC_DUNGEON:
\r
2554 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2556 case TERM_XTRA_MUSIC_QUEST:
\r
2557 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2559 case TERM_XTRA_MUSIC_TOWN:
\r
2560 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2567 //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2568 //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2574 case TERM_XTRA_MUSIC_BASIC:
\r
2575 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2577 case TERM_XTRA_MUSIC_DUNGEON:
\r
2578 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2580 case TERM_XTRA_MUSIC_QUEST:
\r
2581 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2583 case TERM_XTRA_MUSIC_TOWN:
\r
2584 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2591 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2592 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2598 case TERM_XTRA_MUSIC_BASIC:
\r
2599 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
\r
2601 case TERM_XTRA_MUSIC_DUNGEON:
\r
2602 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
\r
2604 case TERM_XTRA_MUSIC_QUEST:
\r
2605 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
\r
2607 case TERM_XTRA_MUSIC_TOWN:
\r
2608 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
\r
2612 if(current_music_type == n && current_music_id == v)
\r
2616 current_music_type = n;
\r
2617 current_music_id = v;
\r
2621 mop.lpstrDeviceType = mci_device_type;
\r
2622 mop.lpstrElementName = buf;
\r
2623 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2624 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2625 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
\r
2626 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
2627 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
2630 #endif /* WIN32 */
\r
2632 #else /* USE_MUSIC */
\r
2636 #endif /* USE_MUSIC */
\r
2642 * Delay for "x" milliseconds
\r
2644 static int Term_xtra_win_delay(int v)
\r
2658 t = GetTickCount() + v;
\r
2661 while (GetTickCount() < t)
\r
2663 /* Handle messages */
\r
2664 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2666 TranslateMessage(&msg);
\r
2667 DispatchMessage(&msg);
\r
2671 #endif /* WIN32 */
\r
2679 * Do a "special thing"
\r
2681 static errr Term_xtra_win(int n, int v)
\r
2683 /* Handle a subset of the legal requests */
\r
2686 /* Make a bell sound */
\r
2687 case TERM_XTRA_NOISE:
\r
2689 return (Term_xtra_win_noise());
\r
2692 /* Play a music */
\r
2693 case TERM_XTRA_MUSIC_BASIC:
\r
2694 case TERM_XTRA_MUSIC_DUNGEON:
\r
2695 case TERM_XTRA_MUSIC_QUEST:
\r
2696 case TERM_XTRA_MUSIC_TOWN:
\r
2698 return (Term_xtra_win_music(n, v));
\r
2701 /* Make a special sound */
\r
2702 case TERM_XTRA_SOUND:
\r
2704 return (Term_xtra_win_sound(v));
\r
2707 /* Process random events */
\r
2708 case TERM_XTRA_BORED:
\r
2710 return (Term_xtra_win_event(0));
\r
2713 /* Process an event */
\r
2714 case TERM_XTRA_EVENT:
\r
2716 return (Term_xtra_win_event(v));
\r
2719 /* Flush all events */
\r
2720 case TERM_XTRA_FLUSH:
\r
2722 return (Term_xtra_win_flush());
\r
2725 /* Clear the screen */
\r
2726 case TERM_XTRA_CLEAR:
\r
2728 return (Term_xtra_win_clear());
\r
2731 /* React to global changes */
\r
2732 case TERM_XTRA_REACT:
\r
2734 return (Term_xtra_win_react());
\r
2737 /* Delay for some milliseconds */
\r
2738 case TERM_XTRA_DELAY:
\r
2740 return (Term_xtra_win_delay(v));
\r
2751 * Low level graphics (Assumes valid input).
\r
2753 * Draw a "cursor" at (x,y), using a "yellow box".
\r
2755 static errr Term_curs_win(int x, int y)
\r
2757 term_data *td = (term_data*)(Term->data);
\r
2762 int tile_wid, tile_hgt;
\r
2764 if (td->map_active)
\r
2766 tile_wid = td->map_tile_wid;
\r
2767 tile_hgt = td->map_tile_hgt;
\r
2771 tile_wid = td->tile_wid;
\r
2772 tile_hgt = td->tile_hgt;
\r
2775 /* Frame the grid */
\r
2776 rc.left = x * tile_wid + td->size_ow1;
\r
2777 rc.right = rc.left + tile_wid;
\r
2778 rc.top = y * tile_hgt + td->size_oh1;
\r
2779 rc.bottom = rc.top + tile_hgt;
\r
2781 /* Cursor is done as a yellow "box" */
\r
2782 hdc = GetDC(td->w);
\r
2783 FrameRect(hdc, &rc, hbrYellow);
\r
2784 ReleaseDC(td->w, hdc);
\r
2792 * Low level graphics (Assumes valid input).
\r
2794 * Draw a "big cursor" at (x,y), using a "yellow box".
\r
2796 static errr Term_bigcurs_win(int x, int y)
\r
2798 term_data *td = (term_data*)(Term->data);
\r
2803 int tile_wid, tile_hgt;
\r
2805 if (td->map_active)
\r
2807 /* Normal cursor in map window */
\r
2808 Term_curs_win(x, y);
\r
2813 tile_wid = td->tile_wid;
\r
2814 tile_hgt = td->tile_hgt;
\r
2817 /* Frame the grid */
\r
2818 rc.left = x * tile_wid + td->size_ow1;
\r
2819 rc.right = rc.left + 2 * tile_wid;
\r
2820 rc.top = y * tile_hgt + td->size_oh1;
\r
2821 rc.bottom = rc.top + tile_hgt;
\r
2823 /* Cursor is done as a yellow "box" */
\r
2824 hdc = GetDC(td->w);
\r
2825 FrameRect(hdc, &rc, hbrYellow);
\r
2826 ReleaseDC(td->w, hdc);
\r
2834 * Low level graphics (Assumes valid input).
\r
2836 * Erase a "block" of "n" characters starting at (x,y).
\r
2838 static errr Term_wipe_win(int x, int y, int n)
\r
2840 term_data *td = (term_data*)(Term->data);
\r
2845 /* Rectangle to erase in client coords */
\r
2846 rc.left = x * td->tile_wid + td->size_ow1;
\r
2847 rc.right = rc.left + n * td->tile_wid;
\r
2848 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2849 rc.bottom = rc.top + td->tile_hgt;
\r
2851 hdc = GetDC(td->w);
\r
2852 SetBkColor(hdc, RGB(0, 0, 0));
\r
2853 SelectObject(hdc, td->font_id);
\r
2858 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2859 ReleaseDC(td->w, hdc);
\r
2867 * Low level graphics. Assumes valid input.
\r
2869 * Draw several ("n") chars, with an attr, at a given location.
\r
2871 * All "graphic" data is handled by "Term_pict_win()", below.
\r
2873 * One would think there is a more efficient method for telling a window
\r
2874 * what color it should be using to draw with, but perhaps simply changing
\r
2875 * it every time is not too inefficient. XXX XXX XXX
\r
2877 static errr Term_text_win(int x, int y, int n, byte a, const char *s)
\r
2879 term_data *td = (term_data*)(Term->data);
\r
2883 #if 1 /* #ifdef JP */
\r
2884 static HBITMAP WALL;
\r
2885 static HBRUSH myBrush, oldBrush;
\r
2886 static HPEN oldPen;
\r
2887 static bool init_done = FALSE;
\r
2890 WALL = LoadBitmap(hInstance, AppName);
\r
2891 myBrush = CreatePatternBrush(WALL);
\r
2896 /* Total rectangle */
\r
2897 rc.left = x * td->tile_wid + td->size_ow1;
\r
2898 rc.right = rc.left + n * td->tile_wid;
\r
2899 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2900 rc.bottom = rc.top + td->tile_hgt;
\r
2903 hdc = GetDC(td->w);
\r
2905 /* Background color */
\r
2906 SetBkColor(hdc, RGB(0, 0, 0));
\r
2908 /* Foreground color */
\r
2911 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
\r
2913 else if (paletted)
\r
2915 SetTextColor(hdc, win_clr[a&0x0F]);
\r
2919 SetTextColor(hdc, win_clr[a]);
\r
2922 /* Use the font */
\r
2923 SelectObject(hdc, td->font_id);
\r
2926 if (use_bg) SetBkMode(hdc, TRANSPARENT);
\r
2928 /* Bizarre size */
\r
2929 if (td->bizarre ||
\r
2930 (td->tile_hgt != td->font_hgt) ||
\r
2931 (td->tile_wid != td->font_wid))
\r
2935 /* Erase complete rectangle */
\r
2936 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2939 if (use_bg) DrawBG(hdc, &rc);
\r
2941 /* New rectangle */
\r
2942 rc.left += ((td->tile_wid - td->font_wid) / 2);
\r
2943 rc.right = rc.left + td->font_wid;
\r
2944 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
\r
2945 rc.bottom = rc.top + td->font_hgt;
\r
2947 /* Dump each character */
\r
2948 for (i = 0; i < n; i++)
\r
2951 if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
\r
2953 rc.right += td->font_wid;
\r
2955 oldBrush = SelectObject(hdc, myBrush);
\r
2956 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2958 /* Dump the wall */
\r
2959 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2961 SelectObject(hdc, oldBrush);
\r
2962 SelectObject(hdc, oldPen);
\r
2963 rc.right -= td->font_wid;
\r
2967 rc.left += 2 * td->tile_wid;
\r
2968 rc.right += 2 * td->tile_wid;
\r
2970 else if ( iskanji(*(s+i)) ) /* 2バイト文字 */
\r
2972 rc.right += td->font_wid;
\r
2973 /* Dump the text */
\r
2974 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2976 rc.right -= td->font_wid;
\r
2980 rc.left += 2 * td->tile_wid;
\r
2981 rc.right += 2 * td->tile_wid;
\r
2982 } else if (*(s+i)==127){
\r
2983 oldBrush = SelectObject(hdc, myBrush);
\r
2984 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2986 /* Dump the wall */
\r
2987 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2989 SelectObject(hdc, oldBrush);
\r
2990 SelectObject(hdc, oldPen);
\r
2993 rc.left += td->tile_wid;
\r
2994 rc.right += td->tile_wid;
\r
2996 /* Dump the text */
\r
2997 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
\r
3000 rc.left += td->tile_wid;
\r
3001 rc.right += td->tile_wid;
\r
3006 oldBrush = SelectObject(hdc, myBrush);
\r
3007 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
3009 /* Dump the wall */
\r
3010 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
3012 SelectObject(hdc, oldBrush);
\r
3013 SelectObject(hdc, oldPen);
\r
3016 rc.left += td->tile_wid;
\r
3017 rc.right += td->tile_wid;
\r
3019 /* Dump the text */
\r
3020 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
3024 rc.left += td->tile_wid;
\r
3025 rc.right += td->tile_wid;
\r
3028 /* Dump the text */
\r
3029 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
\r
3033 rc.left += td->tile_wid;
\r
3034 rc.right += td->tile_wid;
\r
3044 /* Dump the text */
\r
3045 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
\r
3050 ReleaseDC(td->w, hdc);
\r
3058 * Low level graphics. Assumes valid input.
\r
3060 * Draw an array of "special" attr/char pairs at the given location.
\r
3062 * We use the "Term_pict_win()" function for "graphic" data, which are
\r
3063 * encoded by setting the "high-bits" of both the "attr" and the "char"
\r
3064 * data. We use the "attr" to represent the "row" of the main bitmap,
\r
3065 * and the "char" to represent the "col" of the main bitmap. The use
\r
3066 * of this function is induced by the "higher_pict" flag.
\r
3068 * If "graphics" is not available, we simply "wipe" the given grids.
\r
3070 static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
\r
3072 term_data *td = (term_data*)(Term->data);
\r
3074 #ifdef USE_GRAPHICS
\r
3077 int x1, y1, w1, h1, tw1, th1;
\r
3078 int x2, y2, w2, h2, tw2 = 0;
\r
3081 HDC hdcMask = NULL;
\r
3085 HBITMAP hbmSrcOld;
\r
3088 if (!use_graphics)
\r
3090 /* Erase the grids */
\r
3091 return (Term_wipe_win(x, y, n));
\r
3094 /* Size of bitmap cell */
\r
3095 w1 = infGraph.CellWidth;
\r
3096 h1 = infGraph.CellHeight;
\r
3097 tw1 = infGraph.TileWidth;
\r
3098 th1 = infGraph.TileHeight;
\r
3100 /* Size of window cell */
\r
3101 if (td->map_active)
\r
3103 w2 = td->map_tile_wid;
\r
3104 h2 = td->map_tile_hgt;
\r
3108 w2 = td->tile_wid;
\r
3109 h2 = td->tile_hgt;
\r
3112 /* big tile mode */
\r
3113 if (use_bigtile) tw2 *= 2;
\r
3116 /* Location of window cell */
\r
3117 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
\r
3118 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
\r
3121 hdc = GetDC(td->w);
\r
3124 hdcSrc = CreateCompatibleDC(hdc);
\r
3125 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
\r
3127 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3129 hdcMask = CreateCompatibleDC(hdc);
\r
3130 SelectObject(hdcMask, infMask.hBitmap);
\r
3133 /* Draw attr/char pairs */
\r
3134 for (i = 0; i < n; i++, x2 += w2)
\r
3140 /* Extract picture */
\r
3141 int row = (a & 0x7F);
\r
3142 int col = (c & 0x7F);
\r
3144 /* Location of bitmap cell */
\r
3148 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3150 x3 = (tcp[i] & 0x7F) * w1;
\r
3151 y3 = (tap[i] & 0x7F) * h1;
\r
3152 tw2 = tw2 * w1 / tw1;
\r
3153 h2 = h2 * h1 / th1;
\r
3155 /* Perfect size */
\r
3156 if ((tw1 == tw2) && (th1 == h2))
\r
3158 /* Copy the terrain picture from the bitmap to the window */
\r
3159 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
\r
3161 /* Mask out the tile */
\r
3162 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
\r
3164 /* Draw the tile */
\r
3165 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
\r
3168 /* Need to stretch */
\r
3171 /* Set the correct mode for stretching the tiles */
\r
3172 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3174 /* Copy the terrain picture from the bitmap to the window */
\r
3175 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
\r
3177 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
\r
3179 /* Only draw if terrain and overlay are different */
\r
3180 if ((x1 != x3) || (y1 != y3))
\r
3182 /* Mask out the tile */
\r
3183 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
\r
3185 /* Draw the tile */
\r
3186 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
\r
3192 /* Perfect size */
\r
3193 if ((w1 == tw2) && (h1 == h2))
\r
3195 /* Copy the picture from the bitmap to the window */
\r
3196 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
\r
3199 /* Need to stretch */
\r
3202 /* Set the correct mode for stretching the tiles */
\r
3203 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3205 /* Copy the picture from the bitmap to the window */
\r
3206 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
\r
3212 SelectObject(hdcSrc, hbmSrcOld);
\r
3215 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3218 SelectObject(hdcMask, hbmSrcOld);
\r
3219 DeleteDC(hdcMask);
\r
3223 ReleaseDC(td->w, hdc);
\r
3225 #else /* USE_GRAPHICS */
\r
3227 /* Just erase this grid */
\r
3228 return (Term_wipe_win(x, y, n));
\r
3230 #endif /* USE_GRAPHICS */
\r
3237 static void windows_map(void)
\r
3239 term_data *td = &data[0];
\r
3242 int x, min_x, max_x;
\r
3243 int y, min_y, max_y;
\r
3248 /* Only in graphics mode */
\r
3249 if (!use_graphics) return;
\r
3251 /* Clear screen */
\r
3252 Term_xtra_win_clear();
\r
3254 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
\r
3255 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
\r
3256 td->map_active = TRUE;
\r
3265 /* Draw the map */
\r
3266 for (x = min_x; x < max_x; x++)
\r
3268 for (y = min_y; y < max_y; y++)
\r
3270 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
\r
3272 /* Ignore non-graphics */
\r
3273 if ((a & 0x80) && (c & 0x80))
\r
3275 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
\r
3280 /* Hilite the player */
\r
3281 Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
\r
3283 /* Wait for a keypress, flush key buffer */
\r
3284 Term_inkey(&c, TRUE, TRUE);
\r
3287 /* Switch off the map display */
\r
3288 td->map_active = FALSE;
\r
3290 /* Restore screen */
\r
3291 Term_xtra_win_clear();
\r
3296 /*** Other routines ***/
\r
3300 * Create and initialize a "term_data" given a title
\r
3302 static void term_data_link(term_data *td)
\r
3306 /* Initialize the term */
\r
3307 term_init(t, td->cols, td->rows, td->keys);
\r
3309 /* Use a "software" cursor */
\r
3310 t->soft_cursor = TRUE;
\r
3312 /* Use "Term_pict" for "graphic" data */
\r
3313 t->higher_pict = TRUE;
\r
3315 /* Erase with "white space" */
\r
3316 t->attr_blank = TERM_WHITE;
\r
3317 t->char_blank = ' ';
\r
3320 /* Prepare the init/nuke hooks */
\r
3321 t->init_hook = Term_init_win;
\r
3322 t->nuke_hook = Term_nuke_win;
\r
3325 /* Prepare the template hooks */
\r
3326 t->user_hook = Term_user_win;
\r
3327 t->xtra_hook = Term_xtra_win;
\r
3328 t->curs_hook = Term_curs_win;
\r
3329 t->bigcurs_hook = Term_bigcurs_win;
\r
3330 t->wipe_hook = Term_wipe_win;
\r
3331 t->text_hook = Term_text_win;
\r
3332 t->pict_hook = Term_pict_win;
\r
3334 /* Remember where we came from */
\r
3335 t->data = (vptr)(td);
\r
3340 * Create the windows
\r
3342 * First, instantiate the "default" values, then read the "ini_file"
\r
3343 * to over-ride selected values, then create the windows, and fonts.
\r
3345 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
\r
3346 * must make active to realize the palette. XXX XXX XXX
\r
3348 static void init_windows(void)
\r
3354 #if 0 /* #ifndef JP */
\r
3360 WIPE(td, term_data);
\r
3364 td->s = angband_term_name[0];
\r
3370 td->visible = TRUE;
\r
3375 td->pos_x = 7 * 30;
\r
3376 td->pos_y = 7 * 20;
\r
3377 td->posfix = FALSE;
\r
3378 #if 1 /* #ifdef JP */
\r
3379 td->bizarre = TRUE;
\r
3382 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3385 WIPE(td, term_data);
\r
3386 td->s = angband_term_name[i];
\r
3390 td->visible = FALSE;
\r
3395 td->pos_x = (7 - i) * 30;
\r
3396 td->pos_y = (7 - i) * 20;
\r
3397 td->posfix = FALSE;
\r
3398 #if 1 /* #ifdef JP */
\r
3399 td->bizarre = TRUE;
\r
3408 /* Main window (need these before term_getsize gets called) */
\r
3410 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
\r
3411 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
\r
3413 td->dwExStyle = 0;
\r
3414 td->visible = TRUE;
\r
3416 /* Sub windows (need these before term_getsize gets called) */
\r
3417 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3420 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
\r
3421 td->dwExStyle = (WS_EX_TOOLWINDOW);
\r
3426 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3430 #if 1 /* #ifdef JP */
\r
3431 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
\r
3432 td->lf.lfCharSet = DEFAULT_CHARSET;
\r
3433 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
\r
3434 /* Activate the chosen font */
\r
3435 term_force_font(td, NULL);
\r
3436 if(!td->tile_wid) td->tile_wid = td->font_wid;
\r
3437 if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
\r
3439 /* Access the standard font file */
\r
3440 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
\r
3442 /* Activate the chosen font */
\r
3443 if (term_force_font(td, buf))
\r
3445 /* Access the standard font file */
\r
3446 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
3448 /* Force the use of that font */
\r
3449 (void)term_force_font(td, buf);
\r
3453 td->tile_hgt = 13;
\r
3455 /* Assume not bizarre */
\r
3456 td->bizarre = FALSE;
\r
3461 /* Analyze the font */
\r
3464 /* Resize the window */
\r
3465 term_window_resize(td);
\r
3469 /* Sub windows (reverse order) */
\r
3470 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
\r
3475 td->w = CreateWindowEx(td->dwExStyle, AngList,
\r
3476 td->s, td->dwStyle,
\r
3477 td->pos_x, td->pos_y,
\r
3478 td->size_wid, td->size_hgt,
\r
3479 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3481 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
\r
3485 td->size_hack = TRUE;
\r
3486 ShowWindow(td->w, SW_SHOW);
\r
3487 td->size_hack = FALSE;
\r
3490 term_data_link(td);
\r
3491 angband_term[i] = &td->t;
\r
3495 /* Activate the window */
\r
3496 SetActiveWindow(td->w);
\r
3499 if (data[i].posfix)
\r
3501 term_window_pos(&data[i], HWND_TOPMOST);
\r
3505 term_window_pos(&data[i], td->w);
\r
3515 td->w = CreateWindowEx(td->dwExStyle, AppName,
\r
3516 td->s, td->dwStyle,
\r
3517 td->pos_x, td->pos_y,
\r
3518 td->size_wid, td->size_hgt,
\r
3519 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3521 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
\r
3523 term_data_link(td);
\r
3524 angband_term[0] = &td->t;
\r
3525 normsize.x = td->cols;
\r
3526 normsize.y = td->rows;
\r
3528 /* Activate the main window */
\r
3529 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
\r
3530 else ShowWindow(td->w, SW_SHOW);
\r
3532 /* Bring main window back to top */
\r
3533 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
3536 /* New palette XXX XXX XXX */
\r
3537 (void)new_palette();
\r
3540 /* Create a "brush" for drawing the "cursor" */
\r
3541 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
\r
3544 /* Process pending messages */
\r
3545 (void)Term_xtra_win_flush();
\r
3551 * Prepare the menus
\r
3553 static void setup_menus(void)
\r
3557 HMENU hm = GetMenu(data[0].w);
\r
3560 /* Menu "File", Disable all */
\r
3561 EnableMenuItem(hm, IDM_FILE_NEW,
\r
3562 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3563 EnableMenuItem(hm, IDM_FILE_OPEN,
\r
3564 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3565 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3566 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3567 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3568 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3569 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3570 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3573 /* No character available */
\r
3574 if (!character_generated)
\r
3576 /* Menu "File", Item "New" */
\r
3577 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
\r
3579 /* Menu "File", Item "Open" */
\r
3580 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
\r
3583 /* A character available */
\r
3584 if (character_generated)
\r
3586 /* Menu "File", Item "Save" */
\r
3587 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3588 MF_BYCOMMAND | MF_ENABLED);
\r
3591 /* Menu "File", Item "Exit" */
\r
3592 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3593 MF_BYCOMMAND | MF_ENABLED);
\r
3595 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3596 MF_BYCOMMAND | MF_ENABLED);
\r
3599 /* Menu "Window::Visibility" */
\r
3600 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3602 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3603 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3605 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3606 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
\r
3608 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3609 MF_BYCOMMAND | MF_ENABLED);
\r
3612 /* Menu "Window::Font" */
\r
3613 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3615 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3616 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3618 if (data[i].visible)
\r
3620 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3621 MF_BYCOMMAND | MF_ENABLED);
\r
3625 /* Menu "Window::Window Position Fix" */
\r
3626 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3628 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3629 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3631 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3632 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
\r
3634 if (data[i].visible)
\r
3636 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3637 MF_BYCOMMAND | MF_ENABLED);
\r
3641 /* Menu "Window::Bizarre Display" */
\r
3642 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3644 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3645 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3647 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3648 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
\r
3650 if (data[i].visible)
\r
3652 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3653 MF_BYCOMMAND | MF_ENABLED);
\r
3658 /* Menu "Window::Increase Tile Width" */
\r
3659 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3661 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3662 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3664 if (data[i].visible)
\r
3666 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3667 MF_BYCOMMAND | MF_ENABLED);
\r
3672 /* Menu "Window::Decrease Tile Width" */
\r
3673 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3675 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3676 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3678 if (data[i].visible)
\r
3680 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3681 MF_BYCOMMAND | MF_ENABLED);
\r
3686 /* Menu "Window::Increase Tile Height" */
\r
3687 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3689 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3690 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3692 if (data[i].visible)
\r
3694 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3695 MF_BYCOMMAND | MF_ENABLED);
\r
3700 /* Menu "Window::Decrease Tile Height" */
\r
3701 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3703 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3704 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3706 if (data[i].visible)
\r
3708 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3709 MF_BYCOMMAND | MF_ENABLED);
\r
3714 /* Menu "Options", disable all */
\r
3715 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3716 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3717 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3718 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3719 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3720 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3721 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3722 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3723 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3724 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3726 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3727 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3730 /* Menu "Options", Item "Map" */
\r
3731 if (use_graphics != GRAPHICS_NONE)
\r
3732 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
\r
3734 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
\r
3735 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3737 /* Menu "Options", update all */
\r
3738 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3739 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
\r
3740 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3741 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
\r
3742 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3743 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
\r
3744 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
\r
3745 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
\r
3746 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3747 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
\r
3748 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
\r
3749 (arg_music ? MF_CHECKED : MF_UNCHECKED));
\r
3750 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3751 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
\r
3752 CheckMenuItem(hm, IDM_OPTIONS_BG,
\r
3753 (use_bg ? MF_CHECKED : MF_UNCHECKED));
\r
3755 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3756 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
\r
3759 #ifdef USE_GRAPHICS
\r
3760 /* Menu "Options", Item "Graphics" */
\r
3761 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
\r
3762 /* Menu "Options", Item "Graphics" */
\r
3763 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
\r
3764 /* Menu "Options", Item "Graphics" */
\r
3765 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
\r
3766 /* Menu "Options", Item "Graphics" */
\r
3767 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
\r
3768 #endif /* USE_GRAPHICS */
\r
3771 /* Menu "Options", Item "Sound" */
\r
3772 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
\r
3773 #endif /* USE_SOUND */
\r
3776 /* Menu "Options", Item "ScreenSaver" */
\r
3777 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3778 MF_BYCOMMAND | MF_ENABLED);
\r
3779 #endif /* USE_SAVER */
\r
3784 * Check for double clicked (or dragged) savefile
\r
3786 * Apparently, Windows copies the entire filename into the first
\r
3787 * piece of the "command line string". Perhaps we should extract
\r
3788 * the "basename" of that filename and append it to the "save" dir.
\r
3790 static void check_for_save_file(LPSTR cmd_line)
\r
3800 /* Extract filename */
\r
3801 strcat(savefile, s);
\r
3803 /* Validate the file */
\r
3804 validate_file(savefile);
\r
3806 /* Game in progress */
\r
3807 game_in_progress = TRUE;
\r
3815 * Process a menu command
\r
3817 static void process_menus(WORD wCmd)
\r
3829 case IDM_FILE_NEW:
\r
3833 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3835 else if (game_in_progress)
\r
3837 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
\r
3841 game_in_progress = TRUE;
\r
3850 case IDM_FILE_OPEN:
\r
3854 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3856 else if (game_in_progress)
\r
3858 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
\r
3862 memset(&ofn, 0, sizeof(ofn));
\r
3863 ofn.lStructSize = sizeof(ofn);
\r
3864 ofn.hwndOwner = data[0].w;
\r
3865 ofn.lpstrFilter = "Save Files (*.)\0*\0";
\r
3866 ofn.nFilterIndex = 1;
\r
3867 ofn.lpstrFile = savefile;
\r
3868 ofn.nMaxFile = 1024;
\r
3869 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
\r
3870 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
\r
3872 if (GetOpenFileName(&ofn))
\r
3874 /* Load 'savefile' */
\r
3875 validate_file(savefile);
\r
3876 game_in_progress = TRUE;
\r
3886 case IDM_FILE_SAVE:
\r
3888 if (game_in_progress && character_generated)
\r
3893 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
\r
3897 /* Hack -- Forget messages */
\r
3900 /* Save the game */
\r
3902 do_cmd_save_game(FALSE);
\r
3903 #else /* ZANGBAND */
\r
3904 do_cmd_save_game();
\r
3905 #endif /* ZANGBAND */
\r
3909 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
\r
3915 case IDM_FILE_EXIT:
\r
3917 if (game_in_progress && character_generated)
\r
3922 plog(_("今は終了できません。", "You may not do that right now."));
\r
3926 /* Hack -- Forget messages */
\r
3933 /* Save the game */
\r
3935 /* do_cmd_save_game(FALSE); */
\r
3936 #else /* ZANGBAND */
\r
3937 /* do_cmd_save_game(); */
\r
3938 #endif /* ZANGBAND */
\r
3939 Term_key_push(SPECIAL_KEY_QUIT);
\r
3947 case IDM_FILE_SCORE:
\r
3951 /* Build the filename */
\r
3952 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
\r
3954 /* Open the binary high score file, for reading */
\r
3955 highscore_fd = fd_open(buf, O_RDONLY);
\r
3957 /* Paranoia -- No score file */
\r
3958 if (highscore_fd < 0)
\r
3960 msg_print("Score file unavailable.");
\r
3967 /* Clear screen */
\r
3970 /* Display the scores */
\r
3971 display_scores_aux(0, MAX_HISCORES, -1, NULL);
\r
3973 /* Shut the high score file */
\r
3974 (void)fd_close(highscore_fd);
\r
3976 /* Forget the high score fd */
\r
3977 highscore_fd = -1;
\r
3982 /* Hack - Flush it */
\r
3990 case IDM_FILE_MOVIE:
\r
3994 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3996 else if (game_in_progress)
\r
3998 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
\r
4002 memset(&ofn, 0, sizeof(ofn));
\r
4003 ofn.lStructSize = sizeof(ofn);
\r
4004 ofn.hwndOwner = data[0].w;
\r
4005 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
\r
4006 ofn.nFilterIndex = 1;
\r
4007 ofn.lpstrFile = savefile;
\r
4008 ofn.nMaxFile = 1024;
\r
4009 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
\r
4010 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
4012 if (GetOpenFileName(&ofn))
\r
4014 /* Load 'savefile' */
\r
4015 prepare_browse_movie_aux(savefile);
\r
4025 case IDM_WINDOW_VIS_0:
\r
4027 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
\r
4031 /* Window visibility */
\r
4032 case IDM_WINDOW_VIS_1:
\r
4033 case IDM_WINDOW_VIS_2:
\r
4034 case IDM_WINDOW_VIS_3:
\r
4035 case IDM_WINDOW_VIS_4:
\r
4036 case IDM_WINDOW_VIS_5:
\r
4037 case IDM_WINDOW_VIS_6:
\r
4038 case IDM_WINDOW_VIS_7:
\r
4040 i = wCmd - IDM_WINDOW_VIS_0;
\r
4042 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4048 td->visible = TRUE;
\r
4049 ShowWindow(td->w, SW_SHOW);
\r
4050 term_data_redraw(td);
\r
4054 td->visible = FALSE;
\r
4055 td->posfix = FALSE;
\r
4056 ShowWindow(td->w, SW_HIDE);
\r
4062 /* Window fonts */
\r
4063 case IDM_WINDOW_FONT_0:
\r
4064 case IDM_WINDOW_FONT_1:
\r
4065 case IDM_WINDOW_FONT_2:
\r
4066 case IDM_WINDOW_FONT_3:
\r
4067 case IDM_WINDOW_FONT_4:
\r
4068 case IDM_WINDOW_FONT_5:
\r
4069 case IDM_WINDOW_FONT_6:
\r
4070 case IDM_WINDOW_FONT_7:
\r
4072 i = wCmd - IDM_WINDOW_FONT_0;
\r
4074 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4078 term_change_font(td);
\r
4083 /* Window Z Position */
\r
4084 case IDM_WINDOW_POS_1:
\r
4085 case IDM_WINDOW_POS_2:
\r
4086 case IDM_WINDOW_POS_3:
\r
4087 case IDM_WINDOW_POS_4:
\r
4088 case IDM_WINDOW_POS_5:
\r
4089 case IDM_WINDOW_POS_6:
\r
4090 case IDM_WINDOW_POS_7:
\r
4092 i = wCmd - IDM_WINDOW_POS_0;
\r
4094 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4098 if (!td->posfix && td->visible)
\r
4100 td->posfix = TRUE;
\r
4101 term_window_pos(td, HWND_TOPMOST);
\r
4105 td->posfix = FALSE;
\r
4106 term_window_pos(td, data[0].w);
\r
4112 /* Bizarre Display */
\r
4113 case IDM_WINDOW_BIZ_0:
\r
4114 case IDM_WINDOW_BIZ_1:
\r
4115 case IDM_WINDOW_BIZ_2:
\r
4116 case IDM_WINDOW_BIZ_3:
\r
4117 case IDM_WINDOW_BIZ_4:
\r
4118 case IDM_WINDOW_BIZ_5:
\r
4119 case IDM_WINDOW_BIZ_6:
\r
4120 case IDM_WINDOW_BIZ_7:
\r
4122 i = wCmd - IDM_WINDOW_BIZ_0;
\r
4124 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4128 td->bizarre = !td->bizarre;
\r
4132 term_window_resize(td);
\r
4137 /* Increase Tile Width */
\r
4138 case IDM_WINDOW_I_WID_0:
\r
4139 case IDM_WINDOW_I_WID_1:
\r
4140 case IDM_WINDOW_I_WID_2:
\r
4141 case IDM_WINDOW_I_WID_3:
\r
4142 case IDM_WINDOW_I_WID_4:
\r
4143 case IDM_WINDOW_I_WID_5:
\r
4144 case IDM_WINDOW_I_WID_6:
\r
4145 case IDM_WINDOW_I_WID_7:
\r
4147 i = wCmd - IDM_WINDOW_I_WID_0;
\r
4149 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4153 td->tile_wid += 1;
\r
4157 term_window_resize(td);
\r
4162 /* Decrease Tile Height */
\r
4163 case IDM_WINDOW_D_WID_0:
\r
4164 case IDM_WINDOW_D_WID_1:
\r
4165 case IDM_WINDOW_D_WID_2:
\r
4166 case IDM_WINDOW_D_WID_3:
\r
4167 case IDM_WINDOW_D_WID_4:
\r
4168 case IDM_WINDOW_D_WID_5:
\r
4169 case IDM_WINDOW_D_WID_6:
\r
4170 case IDM_WINDOW_D_WID_7:
\r
4172 i = wCmd - IDM_WINDOW_D_WID_0;
\r
4174 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4178 td->tile_wid -= 1;
\r
4182 term_window_resize(td);
\r
4187 /* Increase Tile Height */
\r
4188 case IDM_WINDOW_I_HGT_0:
\r
4189 case IDM_WINDOW_I_HGT_1:
\r
4190 case IDM_WINDOW_I_HGT_2:
\r
4191 case IDM_WINDOW_I_HGT_3:
\r
4192 case IDM_WINDOW_I_HGT_4:
\r
4193 case IDM_WINDOW_I_HGT_5:
\r
4194 case IDM_WINDOW_I_HGT_6:
\r
4195 case IDM_WINDOW_I_HGT_7:
\r
4197 i = wCmd - IDM_WINDOW_I_HGT_0;
\r
4199 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4203 td->tile_hgt += 1;
\r
4207 term_window_resize(td);
\r
4212 /* Decrease Tile Height */
\r
4213 case IDM_WINDOW_D_HGT_0:
\r
4214 case IDM_WINDOW_D_HGT_1:
\r
4215 case IDM_WINDOW_D_HGT_2:
\r
4216 case IDM_WINDOW_D_HGT_3:
\r
4217 case IDM_WINDOW_D_HGT_4:
\r
4218 case IDM_WINDOW_D_HGT_5:
\r
4219 case IDM_WINDOW_D_HGT_6:
\r
4220 case IDM_WINDOW_D_HGT_7:
\r
4222 i = wCmd - IDM_WINDOW_D_HGT_0;
\r
4224 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4228 td->tile_hgt -= 1;
\r
4232 term_window_resize(td);
\r
4237 case IDM_OPTIONS_NO_GRAPHICS:
\r
4242 plog("You may not do that right now.");
\r
4246 /* Toggle "arg_graphics" */
\r
4247 if (arg_graphics != GRAPHICS_NONE)
\r
4249 arg_graphics = GRAPHICS_NONE;
\r
4251 /* React to changes */
\r
4252 Term_xtra_win_react();
\r
4254 /* Hack -- Force redraw */
\r
4255 Term_key_push(KTRL('R'));
\r
4261 case IDM_OPTIONS_OLD_GRAPHICS:
\r
4266 plog("You may not do that right now.");
\r
4270 /* Toggle "arg_graphics" */
\r
4271 if (arg_graphics != GRAPHICS_ORIGINAL)
\r
4273 arg_graphics = GRAPHICS_ORIGINAL;
\r
4275 /* React to changes */
\r
4276 Term_xtra_win_react();
\r
4278 /* Hack -- Force redraw */
\r
4279 Term_key_push(KTRL('R'));
\r
4285 case IDM_OPTIONS_NEW_GRAPHICS:
\r
4290 plog("You may not do that right now.");
\r
4294 /* Toggle "arg_graphics" */
\r
4295 if (arg_graphics != GRAPHICS_ADAM_BOLT)
\r
4297 arg_graphics = GRAPHICS_ADAM_BOLT;
\r
4299 /* React to changes */
\r
4300 Term_xtra_win_react();
\r
4302 /* Hack -- Force redraw */
\r
4303 Term_key_push(KTRL('R'));
\r
4309 case IDM_OPTIONS_NEW2_GRAPHICS:
\r
4314 plog("You may not do that right now.");
\r
4318 /* Toggle "arg_graphics" */
\r
4319 if (arg_graphics != GRAPHICS_HENGBAND)
\r
4321 arg_graphics = GRAPHICS_HENGBAND;
\r
4323 /* React to changes */
\r
4324 Term_xtra_win_react();
\r
4326 /* Hack -- Force redraw */
\r
4327 Term_key_push(KTRL('R'));
\r
4333 case IDM_OPTIONS_BIGTILE:
\r
4340 plog("You may not do that right now.");
\r
4344 /* Toggle "arg_sound" */
\r
4345 arg_bigtile = !arg_bigtile;
\r
4348 Term_activate(&td->t);
\r
4350 /* Resize the term */
\r
4351 Term_resize(td->cols, td->rows);
\r
4353 /* Redraw later */
\r
4354 InvalidateRect(td->w, NULL, TRUE);
\r
4359 case IDM_OPTIONS_MUSIC:
\r
4364 plog("You may not do that right now.");
\r
4368 /* Toggle "arg_sound" */
\r
4369 arg_music = !arg_music;
\r
4371 /* React to changes */
\r
4372 Term_xtra_win_react();
\r
4374 /* Hack -- Force redraw */
\r
4375 Term_key_push(KTRL('R'));
\r
4380 case IDM_OPTIONS_SOUND:
\r
4385 plog("You may not do that right now.");
\r
4389 /* Toggle "arg_sound" */
\r
4390 arg_sound = !arg_sound;
\r
4392 /* React to changes */
\r
4393 Term_xtra_win_react();
\r
4395 /* Hack -- Force redraw */
\r
4396 Term_key_push(KTRL('R'));
\r
4402 case IDM_OPTIONS_BG:
\r
4407 plog("You may not do that right now.");
\r
4411 /* Toggle "use_bg" */
\r
4416 /* React to changes */
\r
4417 Term_xtra_win_react();
\r
4419 /* Hack -- Force redraw */
\r
4420 Term_key_push(KTRL('R'));
\r
4426 case IDM_OPTIONS_OPEN_BG:
\r
4431 plog("You may not do that right now.");
\r
4436 memset(&ofn, 0, sizeof(ofn));
\r
4437 ofn.lStructSize = sizeof(ofn);
\r
4438 ofn.hwndOwner = data[0].w;
\r
4439 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
\r
4440 ofn.nFilterIndex = 1;
\r
4441 ofn.lpstrFile = bg_bitmap_file;
\r
4442 ofn.nMaxFile = 1023;
\r
4443 ofn.lpstrInitialDir = NULL;
\r
4444 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
\r
4445 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
\r
4447 if (GetOpenFileName(&ofn))
\r
4449 /* Load 'savefile' */
\r
4454 /* React to changes */
\r
4455 Term_xtra_win_react();
\r
4457 /* Hack -- Force redraw */
\r
4458 Term_key_push(KTRL('R'));
\r
4463 case IDM_DUMP_SCREEN_HTML:
\r
4465 static char buf[1024] = "";
\r
4466 memset(&ofn, 0, sizeof(ofn));
\r
4467 ofn.lStructSize = sizeof(ofn);
\r
4468 ofn.hwndOwner = data[0].w;
\r
4469 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
\r
4470 ofn.nFilterIndex = 1;
\r
4471 ofn.lpstrFile = buf;
\r
4472 ofn.nMaxFile = 1023;
\r
4473 ofn.lpstrDefExt = "html";
\r
4474 ofn.lpstrInitialDir = NULL;
\r
4475 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
\r
4476 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
\r
4478 if (GetSaveFileName(&ofn))
\r
4480 do_cmd_save_screen_html_aux(buf, 0);
\r
4487 case IDM_OPTIONS_SAVER:
\r
4491 DestroyWindow(hwndSaver);
\r
4496 /* Create a screen scaver window */
\r
4497 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
\r
4498 "Angband Screensaver",
\r
4499 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
\r
4500 0, 0, GetSystemMetrics(SM_CXSCREEN),
\r
4501 GetSystemMetrics(SM_CYSCREEN),
\r
4502 NULL, NULL, hInstance, NULL);
\r
4506 /* Push the window to the bottom XXX XXX XXX */
\r
4507 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
4511 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
\r
4519 case IDM_OPTIONS_MAP:
\r
4525 case IDM_HELP_CONTENTS:
\r
4529 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
\r
4530 if (check_file(tmp))
\r
4532 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
\r
4537 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4538 plog("代わりにオンラインヘルプを使用してください。");
\r
4540 plog_fmt("Cannot find help file: %s", tmp);
\r
4541 plog("Use the online help files instead.");
\r
4546 #else /* HTML_HELP */
\r
4549 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
\r
4550 if (check_file(tmp))
\r
4552 sprintf(buf, "winhelp.exe %s", tmp);
\r
4553 WinExec(buf, SW_NORMAL);
\r
4558 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4559 plog("代わりにオンラインヘルプを使用してください。");
\r
4561 plog_fmt("Cannot find help file: %s", tmp);
\r
4562 plog("Use the online help files instead.");
\r
4567 #endif /* HTML_HELP */
\r
4573 static bool process_keydown(WPARAM wParam, LPARAM lParam)
\r
4580 /* Extract the modifiers */
\r
4581 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
\r
4582 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
\r
4583 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
\r
4585 Term_no_press = (ma) ? TRUE : FALSE;
\r
4587 /* Handle "special" keys */
\r
4588 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
\r
4590 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
\r
4591 bool numpad = FALSE;
\r
4593 /* Begin the macro trigger */
\r
4594 Term_keypress(31);
\r
4596 /* Send the modifiers */
\r
4597 if (mc) Term_keypress('C');
\r
4598 if (ms) Term_keypress('S');
\r
4599 if (ma) Term_keypress('A');
\r
4601 /* Extract "scan code" */
\r
4602 i = LOBYTE(HIWORD(lParam));
\r
4604 /* Introduce the scan code */
\r
4605 Term_keypress('x');
\r
4607 /* Extended key bit */
\r
4610 /* Numpad Enter and '/' are extended key */
\r
4612 Term_no_press = TRUE;
\r
4613 case VK_RETURN: /* Enter */
\r
4616 /* Other extended keys are on full keyboard */
\r
4630 case VK_SEPARATOR:
\r
4632 Term_no_press = TRUE;
\r
4636 case VK_PRIOR: /* Page Up */
\r
4637 case VK_NEXT: /* Page Down */
\r
4644 numpad = !ext_key;
\r
4647 /* Special modifiers for keypad keys */
\r
4648 if (numpad) Term_keypress('K');
\r
4650 /* Encode the hexidecimal scan code */
\r
4651 Term_keypress(hexsym[i/16]);
\r
4652 Term_keypress(hexsym[i%16]);
\r
4654 /* End the macro trigger */
\r
4655 Term_keypress(13);
\r
4665 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4666 WPARAM wParam, LPARAM lParam);
\r
4667 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4668 WPARAM wParam, LPARAM lParam)
\r
4669 #else /* __MWERKS__ */
\r
4670 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4671 WPARAM wParam, LPARAM lParam)
\r
4672 #endif /* __MWERKS__ */
\r
4678 MINMAXINFO FAR *lpmmi;
\r
4684 /* Acquire proper "term_data" info */
\r
4685 td = (term_data *)GetWindowLong(hWnd, 0);
\r
4687 /* Handle message */
\r
4693 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
4701 mop.dwCallback=(DWORD)hWnd;
\r
4706 case WM_GETMINMAXINFO:
\r
4708 MINMAXINFO FAR *lpmmi;
\r
4711 lpmmi = (MINMAXINFO FAR *)lParam;
\r
4713 /* this message was sent before WM_NCCREATE */
\r
4714 if (!td) return 1;
\r
4716 /* Minimum window size is 80x24 */
\r
4717 rc.left = rc.top = 0;
\r
4718 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
4719 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
4722 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
4724 /* Save minimum size */
\r
4725 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
4726 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
4733 BeginPaint(hWnd, &ps);
\r
4734 if (td) term_data_redraw(td);
\r
4735 EndPaint(hWnd, &ps);
\r
4736 ValidateRect(hWnd, NULL);
\r
4741 case MM_MCINOTIFY:
\r
4743 if(wParam == MCI_NOTIFY_SUCCESSFUL)
\r
4745 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
4746 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
4752 case WM_SYSKEYDOWN:
\r
4755 if (process_keydown(wParam, lParam))
\r
4762 if (Term_no_press) Term_no_press = FALSE;
\r
4763 else Term_keypress(wParam);
\r
4767 case WM_LBUTTONDOWN:
\r
4769 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4770 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4771 mouse_down = TRUE;
\r
4777 case WM_LBUTTONUP:
\r
4782 TERM_POSITION dx = abs(oldx - mousex) + 1;
\r
4783 TERM_POSITION dy = abs(oldy - mousey) + 1;
\r
4784 TERM_POSITION ox = (oldx > mousex) ? mousex : oldx;
\r
4785 TERM_POSITION oy = (oldy > mousey) ? mousey : oldy;
\r
4787 mouse_down = FALSE;
\r
4788 paint_rect = FALSE;
\r
4791 sz = (dx + 3) * dy;
\r
4793 sz = (dx + 2) * dy;
\r
4795 hGlobal = GlobalAlloc(GHND, sz + 1);
\r
4796 if (hGlobal == NULL) return 0;
\r
4797 lpStr = (LPSTR)GlobalLock(hGlobal);
\r
4799 for (i = 0; i < dy; i++)
\r
4803 char **scr = data[0].t.scr->c;
\r
4805 C_MAKE(s, (dx + 1), char);
\r
4806 strncpy(s, &scr[oy + i][ox], dx);
\r
4810 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
\r
4813 if (ox + dx < data[0].cols)
\r
4815 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
\r
4818 for (j = 0; j < dx; j++)
\r
4820 if (s[j] == 127) s[j] = '#';
\r
4824 for (j = 0; j < dx; j++)
\r
4826 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
\r
4836 GlobalUnlock(hGlobal);
\r
4837 if (OpenClipboard(hWnd) == 0)
\r
4839 GlobalFree(hGlobal);
\r
4843 SetClipboardData(CF_TEXT, hGlobal);
\r
4851 case WM_MOUSEMOVE:
\r
4856 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4857 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4862 dx = abs(oldx - mousex) + 1;
\r
4863 dy = abs(oldy - mousey) + 1;
\r
4864 ox = (oldx > mousex) ? mousex : oldx;
\r
4865 oy = (oldy > mousey) ? mousey : oldy;
\r
4866 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4870 paint_rect = TRUE;
\r
4873 dx = abs(cx - mousex) + 1;
\r
4874 dy = abs(cy - mousey) + 1;
\r
4875 ox = (cx > mousex) ? mousex : cx;
\r
4876 oy = (cy > mousey) ? mousey : cy;
\r
4877 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4893 if (game_in_progress && character_generated)
\r
4897 plog(_("今は終了できません。", "You may not do that right now."));
\r
4901 /* Hack -- Forget messages */
\r
4908 /* Save the game */
\r
4910 /* do_cmd_save_game(FALSE); */
\r
4911 #else /* ZANGBAND */
\r
4912 /* do_cmd_save_game(); */
\r
4913 #endif /* ZANGBAND */
\r
4914 Term_key_push(SPECIAL_KEY_QUIT);
\r
4921 case WM_QUERYENDSESSION:
\r
4923 if (game_in_progress && character_generated)
\r
4925 /* Hack -- Forget messages */
\r
4928 /* Mega-Hack -- Delay death */
\r
4929 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
\r
4930 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
\r
4932 /* Hardcode panic save */
\r
4933 p_ptr->panic_save = 1;
\r
4935 /* Forbid suspend */
\r
4936 signals_ignore_tstp();
\r
4938 /* Indicate panic save */
\r
4939 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
\r
4942 (void)save_player();
\r
4956 process_menus(LOWORD(wParam));
\r
4962 /* this message was sent before WM_NCCREATE */
\r
4963 if (!td) return 1;
\r
4965 /* it was sent from inside CreateWindowEx */
\r
4966 if (!td->w) return 1;
\r
4968 /* was sent from WM_SIZE */
\r
4969 if (td->size_hack) return 1;
\r
4973 case SIZE_MINIMIZED:
\r
4975 /* Hide sub-windows */
\r
4976 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4978 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
\r
4983 case SIZE_MAXIMIZED:
\r
4985 /* fall through XXX XXX XXX */
\r
4988 case SIZE_RESTORED:
\r
4990 TERM_POSITION cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
4991 TERM_POSITION rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
4994 if ((td->cols != cols) || (td->rows != rows))
\r
4996 /* Save the new size */
\r
5000 if (!IsZoomed(td->w) && !IsIconic(td->w))
\r
5002 normsize.x = td->cols;
\r
5003 normsize.y = td->rows;
\r
5007 Term_activate(&td->t);
\r
5009 /* Resize the term */
\r
5010 Term_resize(td->cols, td->rows);
\r
5012 /* Redraw later */
\r
5013 InvalidateRect(td->w, NULL, TRUE);
\r
5016 td->size_hack = TRUE;
\r
5018 /* Show sub-windows */
\r
5019 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5021 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
\r
5024 td->size_hack = FALSE;
\r
5032 case WM_PALETTECHANGED:
\r
5034 /* Ignore if palette change caused by itself */
\r
5035 if ((HWND)wParam == hWnd) return 0;
\r
5037 /* Fall through... */
\r
5040 case WM_QUERYNEWPALETTE:
\r
5042 if (!paletted) return 0;
\r
5044 hdc = GetDC(hWnd);
\r
5046 SelectPalette(hdc, hPal, FALSE);
\r
5048 i = RealizePalette(hdc);
\r
5050 /* if any palette entries changed, repaint the window. */
\r
5051 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5053 ReleaseDC(hWnd, hdc);
\r
5060 if (wParam && !HIWORD(lParam))
\r
5062 /* Do something to sub-windows */
\r
5063 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5065 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
\r
5068 /* Focus on main window */
\r
5077 case WM_ACTIVATEAPP:
\r
5079 if (IsIconic(td->w)) break;
\r
5081 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5083 if(data[i].visible)
\r
5085 if (wParam == TRUE)
\r
5087 ShowWindow(data[i].w, SW_SHOW);
\r
5091 ShowWindow(data[i].w, SW_HIDE);
\r
5098 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5103 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5104 WPARAM wParam, LPARAM lParam);
\r
5105 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5106 WPARAM wParam, LPARAM lParam)
\r
5107 #else /* __MWERKS__ */
\r
5108 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5109 WPARAM wParam, LPARAM lParam)
\r
5110 #endif /* __MWERKS__ */
\r
5114 MINMAXINFO FAR *lpmmi;
\r
5122 /* Acquire proper "term_data" info */
\r
5123 td = (term_data *)GetWindowLong(hWnd, 0);
\r
5125 /* Process message */
\r
5131 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
5141 case WM_GETMINMAXINFO:
\r
5143 MINMAXINFO FAR *lpmmi;
\r
5146 lpmmi = (MINMAXINFO FAR *)lParam;
\r
5148 /* this message was sent before WM_NCCREATE */
\r
5149 if (!td) return 1;
\r
5151 /* Minimum window size is 80x24 */
\r
5152 rc.left = rc.top = 0;
\r
5153 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
5154 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
5157 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
5159 /* Save minimum size */
\r
5160 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
5161 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
5168 TERM_POSITION cols;
\r
5169 TERM_POSITION rows;
\r
5171 /* this message was sent before WM_NCCREATE */
\r
5172 if (!td) return 1;
\r
5174 /* it was sent from inside CreateWindowEx */
\r
5175 if (!td->w) return 1;
\r
5177 /* was sent from inside WM_SIZE */
\r
5178 if (td->size_hack) return 1;
\r
5180 td->size_hack = TRUE;
\r
5182 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
5183 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
5186 if ((td->cols != cols) || (td->rows != rows))
\r
5188 /* Save old term */
\r
5189 term *old_term = Term;
\r
5191 /* Save the new size */
\r
5196 Term_activate(&td->t);
\r
5198 /* Resize the term */
\r
5199 Term_resize(td->cols, td->rows);
\r
5202 Term_activate(old_term);
\r
5204 /* Redraw later */
\r
5205 InvalidateRect(td->w, NULL, TRUE);
\r
5207 /* HACK - Redraw all windows */
\r
5208 p_ptr->window = 0xFFFFFFFF;
\r
5212 td->size_hack = FALSE;
\r
5219 BeginPaint(hWnd, &ps);
\r
5220 if (td) term_data_redraw(td);
\r
5221 EndPaint(hWnd, &ps);
\r
5225 case WM_SYSKEYDOWN:
\r
5228 if (process_keydown(wParam, lParam))
\r
5235 if (Term_no_press) Term_no_press = FALSE;
\r
5236 else Term_keypress(wParam);
\r
5240 case WM_PALETTECHANGED:
\r
5242 /* ignore if palette change caused by itself */
\r
5243 if ((HWND)wParam == hWnd) return FALSE;
\r
5244 /* otherwise, fall through!!! */
\r
5247 case WM_QUERYNEWPALETTE:
\r
5249 if (!paletted) return 0;
\r
5250 hdc = GetDC(hWnd);
\r
5251 SelectPalette(hdc, hPal, FALSE);
\r
5252 i = RealizePalette(hdc);
\r
5253 /* if any palette entries changed, repaint the window. */
\r
5254 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5255 ReleaseDC(hWnd, hdc);
\r
5259 case WM_NCLBUTTONDOWN:
\r
5263 if (wParam == HTCLOSE) wParam = HTSYSMENU;
\r
5264 #endif /* HTCLOSE */
\r
5266 if (wParam == HTSYSMENU)
\r
5270 td->visible = FALSE;
\r
5271 ShowWindow(td->w, SW_HIDE);
\r
5281 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5287 #define MOUSE_SENS 40
\r
5290 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5291 WPARAM wParam, LPARAM lParam);
\r
5292 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5293 WPARAM wParam, LPARAM lParam)
\r
5294 #else /* __MWERKS__ */
\r
5295 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5296 WPARAM wParam, LPARAM lParam)
\r
5297 #endif /* __MWERKS__ */
\r
5299 static int iMouse = 0;
\r
5300 static WORD xMouse = 0;
\r
5301 static WORD yMouse = 0;
\r
5315 case WM_SETCURSOR:
\r
5324 if (LOWORD(wParam) == WA_INACTIVE) break;
\r
5326 /* else fall through */
\r
5330 case WM_LBUTTONDOWN:
\r
5331 case WM_MBUTTONDOWN:
\r
5332 case WM_RBUTTONDOWN:
\r
5335 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5339 case WM_MOUSEMOVE:
\r
5343 dx = LOWORD(lParam) - xMouse;
\r
5344 dy = HIWORD(lParam) - yMouse;
\r
5346 if (dx < 0) dx = -dx;
\r
5347 if (dy < 0) dy = -dy;
\r
5349 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
\r
5351 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5355 /* Save last location */
\r
5357 xMouse = LOWORD(lParam);
\r
5358 yMouse = HIWORD(lParam);
\r
5365 DestroyWindow(hwndSaver);
\r
5372 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5375 #endif /* USE_SAVER */
\r
5381 /*** Temporary Hooks ***/
\r
5385 * Display warning message (see "z-util.c")
\r
5387 static void hack_plog(cptr str)
\r
5389 /* Give a warning */
\r
5393 MessageBox(NULL, str, "警告!",
\r
5394 MB_ICONEXCLAMATION | MB_OK);
\r
5396 MessageBox(NULL, str, "Warning",
\r
5397 MB_ICONEXCLAMATION | MB_OK);
\r
5405 * Display error message and quit (see "z-util.c")
\r
5407 static void hack_quit(cptr str)
\r
5409 /* Give a warning */
\r
5413 MessageBox(NULL, str, "エラー!",
\r
5414 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5416 MessageBox(NULL, str, "Error",
\r
5417 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5422 /* Unregister the classes */
\r
5423 UnregisterClass(AppName, hInstance);
\r
5425 /* Destroy the icon */
\r
5426 if (hIcon) DestroyIcon(hIcon);
\r
5434 /*** Various hooks ***/
\r
5438 * Display warning message (see "z-util.c")
\r
5440 static void hook_plog(cptr str)
\r
5446 MessageBox(data[0].w, str, "警告!",
\r
5447 MB_ICONEXCLAMATION | MB_OK);
\r
5449 MessageBox(data[0].w, str, "Warning",
\r
5450 MB_ICONEXCLAMATION | MB_OK);
\r
5458 * Display error message and quit (see "z-util.c")
\r
5460 static void hook_quit(cptr str)
\r
5465 /* Give a warning */
\r
5469 MessageBox(data[0].w, str, "エラー!",
\r
5470 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5472 MessageBox(data[0].w, str, "Error",
\r
5473 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5479 /* Save the preferences */
\r
5483 /*** Could use 'Term_nuke_win()' XXX XXX XXX */
\r
5485 /* Destroy all windows */
\r
5486 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
\r
5488 term_force_font(&data[i], NULL);
\r
5489 if (data[i].font_want) string_free(data[i].font_want);
\r
5490 if (data[i].w) DestroyWindow(data[i].w);
\r
5494 /* Free the bitmap stuff */
\r
5495 #ifdef USE_GRAPHICS
\r
5496 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
\r
5497 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
\r
5499 if (infMask.hPalette) DeleteObject(infMask.hPalette);
\r
5500 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
\r
5502 #endif /* USE_GRAPHICS */
\r
5504 /*** Free some other stuff ***/
\r
5506 DeleteObject(hbrYellow);
\r
5511 if (hPal) DeleteObject(hPal);
\r
5513 UnregisterClass(AppName, hInstance);
\r
5515 if (hIcon) DestroyIcon(hIcon);
\r
5522 /*** Initialize ***/
\r
5528 static void init_stuff(void)
\r
5535 /* Get program name with full path */
\r
5536 GetModuleFileName(hInstance, path, 512);
\r
5538 /* Save the "program name" XXX XXX XXX */
\r
5541 /* Get the name of the "*.ini" file */
\r
5542 strcpy(path + strlen(path) - 4, ".INI");
\r
5544 /* Save the the name of the ini-file */
\r
5545 ini_file = string_make(path);
\r
5547 /* Analyze the path */
\r
5550 /* Get the path */
\r
5551 for (; i > 0; i--)
\r
5553 if (path[i] == '\\')
\r
5560 /* Add "lib" to the path */
\r
5561 strcpy(path + i + 1, "lib\\");
\r
5563 /* Validate the path */
\r
5564 validate_dir(path, TRUE);
\r
5566 /* Init the file paths */
\r
5567 init_file_paths(path);
\r
5569 /* Hack -- Validate the paths */
\r
5570 validate_dir(ANGBAND_DIR_APEX, FALSE);
\r
5571 validate_dir(ANGBAND_DIR_BONE, FALSE);
\r
5573 /* Allow missing 'edit' directory */
\r
5574 if (!check_dir(ANGBAND_DIR_EDIT))
\r
5576 /* Must have 'data'! */
\r
5577 validate_dir(ANGBAND_DIR_DATA, TRUE);
\r
5581 /* Don't need 'data' */
\r
5582 validate_dir(ANGBAND_DIR_DATA, FALSE);
\r
5585 validate_dir(ANGBAND_DIR_FILE, TRUE);
\r
5586 validate_dir(ANGBAND_DIR_HELP, FALSE);
\r
5587 validate_dir(ANGBAND_DIR_INFO, FALSE);
\r
5588 validate_dir(ANGBAND_DIR_PREF, TRUE);
\r
5589 validate_dir(ANGBAND_DIR_SAVE, FALSE);
\r
5590 validate_dir(ANGBAND_DIR_USER, TRUE);
\r
5591 validate_dir(ANGBAND_DIR_XTRA, TRUE);
\r
5593 /* Build the filename */
\r
5594 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
\r
5596 /* Hack -- Validate the "news.txt" file */
\r
5597 validate_file(path);
\r
5600 #if 0 /* #ifndef JP */
\r
5601 /* Build the "font" path */
\r
5602 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
\r
5604 /* Allocate the path */
\r
5605 ANGBAND_DIR_XTRA_FONT = string_make(path);
\r
5607 /* Validate the "font" directory */
\r
5608 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
\r
5610 /* Build the filename */
\r
5611 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
5613 /* Hack -- Validate the basic font */
\r
5614 validate_file(path);
\r
5618 #ifdef USE_GRAPHICS
\r
5620 /* Build the "graf" path */
\r
5621 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
\r
5623 /* Allocate the path */
\r
5624 ANGBAND_DIR_XTRA_GRAF = string_make(path);
\r
5626 /* Validate the "graf" directory */
\r
5627 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
\r
5629 #endif /* USE_GRAPHICS */
\r
5634 /* Build the "sound" path */
\r
5635 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
\r
5637 /* Allocate the path */
\r
5638 ANGBAND_DIR_XTRA_SOUND = string_make(path);
\r
5640 /* Validate the "sound" directory */
\r
5641 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
\r
5643 #endif /* USE_SOUND */
\r
5647 /* Build the "music" path */
\r
5648 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
\r
5650 /* Allocate the path */
\r
5651 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
\r
5653 /* Validate the "music" directory */
\r
5654 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
\r
5656 #endif /* USE_MUSIC */
\r
5658 /* Build the "help" path */
\r
5659 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
\r
5661 /* Allocate the path */
\r
5662 ANGBAND_DIR_XTRA_HELP = string_make(path);
\r
5664 /* Validate the "help" directory */
\r
5665 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
\r
5668 static bool is_already_running(void)
\r
5670 bool result = FALSE;
\r
5673 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
\r
5674 if (GetLastError() == ERROR_ALREADY_EXISTS)
\r
5682 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
\r
5683 LPSTR lpCmdLine, int nCmdShow)
\r
5691 setlocale( LC_ALL, "ja_JP" );
\r
5696 /* Save globally */
\r
5697 hInstance = hInst;
\r
5700 /* Prevent multiple run */
\r
5701 if (is_already_running())
\r
5704 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
\r
5705 _("エラー!", "Error") ,
\r
5706 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5711 if (hPrevInst == NULL)
\r
5713 wc.style = CS_CLASSDC;
\r
5714 wc.lpfnWndProc = AngbandWndProc;
\r
5715 wc.cbClsExtra = 0;
\r
5716 wc.cbWndExtra = 4; /* one long pointer to term_data */
\r
5717 wc.hInstance = hInst;
\r
5718 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
\r
5719 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
\r
5720 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
\r
5721 wc.lpszMenuName = AppName;
\r
5722 wc.lpszClassName = AppName;
\r
5724 if (!RegisterClass(&wc)) exit(1);
\r
5726 wc.lpfnWndProc = AngbandListProc;
\r
5727 wc.lpszMenuName = NULL;
\r
5728 wc.lpszClassName = AngList;
\r
5730 if (!RegisterClass(&wc)) exit(2);
\r
5734 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
\r
5735 wc.lpfnWndProc = AngbandSaverProc;
\r
5736 wc.hCursor = NULL;
\r
5737 wc.lpszMenuName = NULL;
\r
5738 wc.lpszClassName = "WindowsScreenSaverClass";
\r
5740 if (!RegisterClass(&wc)) exit(3);
\r
5746 /* Temporary hooks */
\r
5747 plog_aux = hack_plog;
\r
5748 quit_aux = hack_quit;
\r
5749 core_aux = hack_quit;
\r
5751 /* Prepare the filepaths */
\r
5754 /* Initialize the keypress analyzer */
\r
5755 for (i = 0; special_key_list[i]; ++i)
\r
5757 special_key[special_key_list[i]] = TRUE;
\r
5759 /* Initialize the keypress analyzer */
\r
5760 for (i = 0; ignore_key_list[i]; ++i)
\r
5762 ignore_key[ignore_key_list[i]] = TRUE;
\r
5765 /* Determine if display is 16/256/true color */
\r
5766 hdc = GetDC(NULL);
\r
5767 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
\r
5768 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
\r
5769 ReleaseDC(NULL, hdc);
\r
5771 /* Initialize the colors */
\r
5772 for (i = 0; i < 256; i++)
\r
5776 /* Extract desired values */
\r
5777 rv = angband_color_table[i][1];
\r
5778 gv = angband_color_table[i][2];
\r
5779 bv = angband_color_table[i][3];
\r
5781 /* Extract the "complex" code */
\r
5782 win_clr[i] = PALETTERGB(rv, gv, bv);
\r
5784 /* Save the "simple" code */
\r
5785 angband_color_table[i][0] = win_pal[i];
\r
5788 /* Prepare the windows */
\r
5794 /* Activate hooks */
\r
5795 plog_aux = hook_plog;
\r
5796 quit_aux = hook_quit;
\r
5797 core_aux = hook_quit;
\r
5799 /* Set the system suffix */
\r
5800 ANGBAND_SYS = "win";
\r
5802 /* Set the keyboard suffix */
\r
5803 if (7 != GetKeyboardType(0))
\r
5804 ANGBAND_KEYBOARD = "0";
\r
5807 /* Japanese keyboard */
\r
5808 switch (GetKeyboardType(1))
\r
5810 case 0x0D01: case 0x0D02:
\r
5811 case 0x0D03: case 0x0D04:
\r
5812 case 0x0D05: case 0x0D06:
\r
5814 ANGBAND_KEYBOARD = "NEC98";
\r
5818 ANGBAND_KEYBOARD = "JAPAN";
\r
5822 /* Catch nasty signals */
\r
5826 Term_activate(term_screen);
\r
5829 /* We are now initialized */
\r
5830 initialized = TRUE;
\r
5832 if(lpCmdLine[0] == '-'){
\r
5833 switch(lpCmdLine[1])
\r
5838 if (!lpCmdLine[2]) break;
\r
5839 chuukei_server = TRUE;
\r
5840 if(connect_chuukei_server(&lpCmdLine[2])<0){
\r
5841 msg_print("connect fail");
\r
5844 msg_print("connect");
\r
5852 if (!lpCmdLine[2]) break;
\r
5853 chuukei_client = TRUE;
\r
5854 connect_chuukei_server(&lpCmdLine[2]);
\r
5862 if (!lpCmdLine[2]) break;
\r
5863 prepare_browse_movie(&lpCmdLine[2]);
\r
5873 /* Did the user double click on a save file? */
\r
5874 if(!chuukei_server) check_for_save_file(lpCmdLine);
\r
5876 /* Did the user double click on a save file? */
\r
5877 check_for_save_file(lpCmdLine);
\r
5880 /* Prompt the user */
\r
5881 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
\r
5885 /* Process messages forever */
\r
5886 while (GetMessage(&msg, NULL, 0, 0))
\r
5888 TranslateMessage(&msg);
\r
5889 DispatchMessage(&msg);
\r
5900 #endif /* WINDOWS */
\r