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
225 * Exclude parts of WINDOWS.H that are not needed
\r
227 #define NOCOMM /* Comm driver APIs and definitions */
\r
228 #define NOLOGERROR /* LogError() and related definitions */
\r
229 #define NOPROFILER /* Profiler APIs */
\r
230 #define NOLFILEIO /* _l* file I/O routines */
\r
231 #define NOOPENFILE /* OpenFile and related definitions */
\r
232 #define NORESOURCE /* Resource management */
\r
233 #define NOATOM /* Atom management */
\r
234 #define NOLANGUAGE /* Character test routines */
\r
235 #define NOLSTRING /* lstr* string management routines */
\r
236 #define NODBCS /* Double-byte character set routines */
\r
237 #define NOKEYBOARDINFO /* Keyboard driver routines */
\r
238 #define NOCOLOR /* COLOR_* color values */
\r
239 #define NODRAWTEXT /* DrawText() and related definitions */
\r
240 #define NOSCALABLEFONT /* Truetype scalable font support */
\r
241 #define NOMETAFILE /* Metafile support */
\r
242 #define NOSYSTEMPARAMSINFO /* SystemParametersInfo() and SPI_* definitions */
\r
243 #define NODEFERWINDOWPOS /* DeferWindowPos and related definitions */
\r
244 #define NOKEYSTATES /* MK_* message key state flags */
\r
245 #define NOWH /* SetWindowsHook and related WH_* definitions */
\r
246 #define NOCLIPBOARD /* Clipboard APIs and definitions */
\r
247 #define NOICONS /* IDI_* icon IDs */
\r
248 #define NOMDI /* MDI support */
\r
249 #define NOHELP /* Help support */
\r
251 /* Not defined since it breaks Borland C++ 5.5 */
\r
252 /* #define NOCTLMGR */ /* Control management and controls */
\r
255 * Exclude parts of WINDOWS.H that are not needed (Win32)
\r
257 #define WIN32_LEAN_AND_MEAN
\r
258 #define NONLS /* All NLS defines and routines */
\r
259 #define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
\r
260 #define NOKANJI /* Kanji support stuff. */
\r
261 #define NOMCX /* Modem Configuration Extensions */
\r
264 * Include the "windows" support file
\r
266 #include <windows.h>
\r
269 * Exclude parts of MMSYSTEM.H that are not needed
\r
271 #define MMNODRV /* Installable driver support */
\r
272 #define MMNOWAVE /* Waveform support */
\r
273 #define MMNOMIDI /* MIDI support */
\r
274 #define MMNOAUX /* Auxiliary audio support */
\r
275 #define MMNOTIMER /* Timer support */
\r
276 #define MMNOJOY /* Joystick support */
\r
277 #define MMNOMCI /* MCI support */
\r
278 #define MMNOMMIO /* Multimedia file I/O support */
\r
279 #define MMNOMMSYSTEM /* General MMSYSTEM functions */
\r
282 * Include some more files. Note: the Cygnus Cygwin compiler
\r
283 * doesn't use mmsystem.h instead it includes the winmm library
\r
284 * which performs a similar function.
\r
286 #include <mmsystem.h>
\r
287 #include <commdlg.h>
\r
290 * HTML-Help requires htmlhelp.h and htmlhelp.lib from Microsoft's
\r
291 * HTML Workshop < http://msdn.microsoft.com/workshop/author/htmlhelp/ >.
\r
293 /* #define HTML_HELP */
\r
296 #include <htmlhelp.h>
\r
297 #endif /* HTML_HELP */
\r
300 * Include the support for loading bitmaps
\r
302 #ifdef USE_GRAPHICS
\r
303 # include "readdib.h"
\r
307 * Hack -- Fake declarations from "dos.h" XXX XXX XXX
\r
310 #define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
\r
312 #define FA_LABEL 0x08 /* Volume label */
\r
313 #define FA_DIREC 0x10 /* Directory */
\r
314 unsigned _cdecl _dos_getfileattr(const char *, unsigned *);
\r
318 * Silliness in WIN32 drawing routine
\r
321 # define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL)
\r
325 * Silliness for Windows 95
\r
327 #ifndef WS_EX_TOOLWINDOW
\r
328 # define WS_EX_TOOLWINDOW 0
\r
332 * Foreground color bits (hard-coded by DOS)
\r
334 #define VID_BLACK 0x00
\r
335 #define VID_BLUE 0x01
\r
336 #define VID_GREEN 0x02
\r
337 #define VID_CYAN 0x03
\r
338 #define VID_RED 0x04
\r
339 #define VID_MAGENTA 0x05
\r
340 #define VID_YELLOW 0x06
\r
341 #define VID_WHITE 0x07
\r
344 * Bright text (hard-coded by DOS)
\r
346 #define VID_BRIGHT 0x08
\r
349 * Background color bits (hard-coded by DOS)
\r
351 #define VUD_BLACK 0x00
\r
352 #define VUD_BLUE 0x10
\r
353 #define VUD_GREEN 0x20
\r
354 #define VUD_CYAN 0x30
\r
355 #define VUD_RED 0x40
\r
356 #define VUD_MAGENTA 0x50
\r
357 #define VUD_YELLOW 0x60
\r
358 #define VUD_WHITE 0x70
\r
361 * Blinking text (hard-coded by DOS)
\r
363 #define VUD_BRIGHT 0x80
\r
369 typedef struct _term_data term_data;
\r
372 * @struct _term_data
\r
373 * @brief ターム情報構造体 / Extra "term" data
\r
376 * pos_x / pos_y は各タームの左上点座標を指す。
\r
379 * tile_wid / tile_hgt は[ウィンドウ]メニューのタイルの幅/高さを~を
\r
380 * 1ドットずつ調整するステータスを指す。
\r
381 * また、フォントを変更すると都度自動調整される。
\r
384 * Note the use of "font_want" for the names of the font file requested by
\r
385 * the user, and the use of "font_file" for the currently active font file.
\r
387 * The "font_file" is uppercased, and takes the form "8X13.FON", while
\r
388 * "font_want" can be in almost any form as long as it could be construed
\r
389 * as attempting to represent the name of a font.
\r
401 TERM_LEN rows; /* int -> uint */
\r
404 uint pos_x; //!< タームの左上X座標
\r
405 uint pos_y; //!< タームの左上Y座標
\r
420 int font_wid; //!< フォント横幅
\r
421 int font_hgt; //!< フォント縦幅
\r
422 int tile_wid; //!< タイル横幅
\r
423 int tile_hgt; //!< タイル縦幅
\r
429 #if 1 /* #ifdef JP */
\r
437 #define MAX_TERM_DATA 8 //!< Maximum number of windows XXX XXX XXX
\r
439 static term_data data[MAX_TERM_DATA]; //!< An array of term_data's
\r
440 static term_data *my_td; //!< Hack -- global "window creation" pointer
\r
441 POINT normsize; //!< Remember normal size of main window when maxmized
\r
444 * was main window maximized on previous playing
\r
446 bool win_maximized = FALSE;
\r
451 bool game_in_progress = FALSE;
\r
454 * note when "open"/"new" become valid
\r
456 bool initialized = FALSE;
\r
459 * screen paletted, i.e. 256 colors
\r
461 bool paletted = FALSE;
\r
464 * 16 colors screen, don't use RGB()
\r
466 bool colors16 = FALSE;
\r
469 * Saved instance handle
\r
471 static HINSTANCE hInstance;
\r
474 * Yellow brush for the cursor
\r
476 static HBRUSH hbrYellow;
\r
481 static HICON hIcon;
\r
486 static HPALETTE hPal;
\r
489 static HBITMAP hBG = NULL;
\r
490 static int use_bg = 0; //!< 背景使用フラグ、1なら私用。
\r
491 static char bg_bitmap_file[1024] = "bg.bmp"; //!< 現在の背景ビットマップファイル名。
\r
496 * The screen saver window
\r
498 static HWND hwndSaver;
\r
500 #endif /* USE_SAVER */
\r
503 #ifdef USE_GRAPHICS
\r
506 * 現在使用中のタイルID(0ならば未使用)
\r
507 * Flag set once "graphics" has been initialized
\r
509 static byte_hack current_graphics_mode = 0;
\r
512 * The global bitmap
\r
514 static DIBINIT infGraph;
\r
517 * The global bitmap mask
\r
519 static DIBINIT infMask;
\r
521 #endif /* USE_GRAPHICS */
\r
527 * Flag set once "sound" has been initialized
\r
529 static bool can_use_sound = FALSE;
\r
531 #define SAMPLE_MAX 8
\r
533 * An array of sound file names
\r
535 static cptr sound_file[SOUND_MAX][SAMPLE_MAX];
\r
537 #endif /* USE_SOUND */
\r
543 #define SAMPLE_MUSIC_MAX 16
\r
544 static cptr music_file[MUSIC_BASIC_MAX][SAMPLE_MUSIC_MAX];
\r
545 static cptr dungeon_music_file[1000][SAMPLE_MUSIC_MAX];
\r
546 static cptr town_music_file[1000][SAMPLE_MUSIC_MAX];
\r
547 static cptr quest_music_file[1000][SAMPLE_MUSIC_MAX];
\r
548 static bool can_use_music = FALSE;
\r
550 static MCI_OPEN_PARMS mop;
\r
551 static char mci_device_type[256];
\r
553 int current_music_type = 0;
\r
554 int current_music_id = 0;
\r
556 #endif /* USE_MUSIC */
\r
560 * Full path to ANGBAND.INI
\r
562 static cptr ini_file = NULL;
\r
565 * Name of application
\r
567 static cptr AppName = "ANGBAND";
\r
570 * Name of sub-window type
\r
572 static cptr AngList = "AngList";
\r
577 static cptr ANGBAND_DIR_XTRA_GRAF;
\r
578 static cptr ANGBAND_DIR_XTRA_SOUND;
\r
579 static cptr ANGBAND_DIR_XTRA_MUSIC;
\r
580 static cptr ANGBAND_DIR_XTRA_HELP;
\r
581 #if 0 /* #ifndef JP */
\r
582 static cptr ANGBAND_DIR_XTRA_FONT;
\r
585 static cptr ANGBAND_DIR_XTRA_MUSIC;
\r
590 * The "complex" color values
\r
592 static COLORREF win_clr[256];
\r
596 * Flag for macro trigger with dump ASCII
\r
598 static bool Term_no_press = FALSE;
\r
603 static bool mouse_down = FALSE;
\r
604 static bool paint_rect = FALSE;
\r
605 static TERM_LEN mousex = 0, mousey = 0;
\r
606 static TERM_LEN oldx, oldy;
\r
610 * @brief The "simple" color values
\r
612 * See "main-ibm.c" for original table information
\r
613 * The entries below are taken from the "color bits" defined above.
\r
614 * Note that many of the choices below suck, but so do crappy monitors.
\r
616 static BYTE win_pal[256] =
\r
618 VID_BLACK, /* Dark */
\r
619 VID_WHITE, /* White */
\r
620 VID_CYAN, /* Slate XXX */
\r
621 VID_RED | VID_BRIGHT, /* Orange XXX */
\r
623 VID_GREEN, /* Green */
\r
624 VID_BLUE, /* Blue */
\r
625 VID_YELLOW, /* Umber XXX */
\r
626 VID_BLACK | VID_BRIGHT, /* Light Dark */
\r
627 VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
\r
628 VID_MAGENTA, /* Violet XXX */
\r
629 VID_YELLOW | VID_BRIGHT, /* Yellow */
\r
630 VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
\r
631 VID_GREEN | VID_BRIGHT, /* Light Green */
\r
632 VID_BLUE | VID_BRIGHT, /* Light Blue */
\r
633 VID_YELLOW /* Light Umber XXX */
\r
638 * Hack -- define which keys are "special"
\r
640 static bool special_key[256];
\r
641 static bool ignore_key[256];
\r
645 * Hack -- initialization list for "special_key"
\r
647 static byte special_key_list[] = {
\r
648 VK_CLEAR, VK_PAUSE, VK_CAPITAL,
\r
649 VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI,
\r
650 VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE,
\r
651 VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
\r
652 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN,
\r
653 VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT,
\r
654 VK_INSERT, VK_DELETE, VK_HELP, VK_APPS,
\r
655 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
\r
656 VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
\r
657 VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD,
\r
658 VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE,
\r
659 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
\r
660 VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
\r
661 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
\r
662 VK_F19,VK_F20, VK_F21, VK_F22, VK_F23, VK_F24,
\r
663 VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL,
\r
664 VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM,
\r
666 0 /* End of List */
\r
669 static byte ignore_key_list[] = {
\r
670 VK_ESCAPE, VK_TAB, VK_SPACE,
\r
671 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
\r
672 VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN,
\r
673 VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL,
\r
674 VK_LMENU, VK_RMENU,
\r
675 0 /* End of List */
\r
679 * Hack -- initialization list for "special_key"
\r
681 * We ignore the modifier keys (shift, control, alt, num lock, scroll lock),
\r
682 * and the normal keys (escape, tab, return, letters, numbers, etc), but we
\r
683 * catch the keypad keys (with and without numlock set, including keypad 5),
\r
684 * the function keys (including the "menu" key which maps to F10), and the
\r
685 * "pause" key (between scroll lock and numlock). We also catch a few odd
\r
686 * keys which I do not recognize, but which are listed among keys which we
\r
687 * do catch, so they should be harmless to catch.
\r
689 static byte special_key_list[] =
\r
691 VK_CLEAR, /* 0x0C (KP<5>) */
\r
693 VK_PAUSE, /* 0x13 (pause) */
\r
695 VK_PRIOR, /* 0x21 (KP<9>) */
\r
696 VK_NEXT, /* 0x22 (KP<3>) */
\r
697 VK_END, /* 0x23 (KP<1>) */
\r
698 VK_HOME, /* 0x24 (KP<7>) */
\r
699 VK_LEFT, /* 0x25 (KP<4>) */
\r
700 VK_UP, /* 0x26 (KP<8>) */
\r
701 VK_RIGHT, /* 0x27 (KP<6>) */
\r
702 VK_DOWN, /* 0x28 (KP<2>) */
\r
703 VK_SELECT, /* 0x29 (?????) */
\r
704 VK_PRINT, /* 0x2A (?????) */
\r
705 VK_EXECUTE, /* 0x2B (?????) */
\r
706 VK_SNAPSHOT, /* 0x2C (?????) */
\r
707 VK_INSERT, /* 0x2D (KP<0>) */
\r
708 VK_DELETE, /* 0x2E (KP<.>) */
\r
709 VK_HELP, /* 0x2F (?????) */
\r
711 VK_NUMPAD0, /* 0x60 (KP<0>) */
\r
712 VK_NUMPAD1, /* 0x61 (KP<1>) */
\r
713 VK_NUMPAD2, /* 0x62 (KP<2>) */
\r
714 VK_NUMPAD3, /* 0x63 (KP<3>) */
\r
715 VK_NUMPAD4, /* 0x64 (KP<4>) */
\r
716 VK_NUMPAD5, /* 0x65 (KP<5>) */
\r
717 VK_NUMPAD6, /* 0x66 (KP<6>) */
\r
718 VK_NUMPAD7, /* 0x67 (KP<7>) */
\r
719 VK_NUMPAD8, /* 0x68 (KP<8>) */
\r
720 VK_NUMPAD9, /* 0x69 (KP<9>) */
\r
721 VK_MULTIPLY, /* 0x6A (KP<*>) */
\r
722 VK_ADD, /* 0x6B (KP<+>) */
\r
723 VK_SEPARATOR, /* 0x6C (?????) */
\r
724 VK_SUBTRACT, /* 0x6D (KP<->) */
\r
725 VK_DECIMAL, /* 0x6E (KP<.>) */
\r
726 VK_DIVIDE, /* 0x6F (KP</>) */
\r
757 /* Function prototype */
\r
759 static bool is_already_running(void);
\r
763 static void delete_bg(void)
\r
772 static int init_bg(void)
\r
774 char * bmfile = bg_bitmap_file;
\r
777 if (use_bg == 0) return 0;
\r
779 hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
\r
781 plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
\r
786 HDC wnddc, dcimage, dcbg;
\r
787 HBITMAP bmimage, bmimage_old, bmbg_old;
\r
792 wnddc = GetDC(hwnd);
\r
793 dcimage = CreateCompatibleDC(wnddc);
\r
794 dcbg = CreateCompatibleDC(wnddc);
\r
796 bmimage = LoadImage(NULL, "bg.bmp", LR_LOADFROMFILE, 0, 0, 0);
\r
797 if (!bmimage) quit("bg.bmpが読みこめない!");
\r
798 bmimage_old = SelectObject(dcimage, bmimage);
\r
800 CreateCompatibleBitmap();
\r
802 ReleaseDC(hwnd, wnddc);
\r
808 static void DrawBG(HDC hdc, RECT *r)
\r
813 int x = r->left, y = r->top;
\r
814 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
\r
816 if (!use_bg || !hBG)
\r
820 GetObject(hBG, sizeof(bm), &bm);
\r
821 swid = bm.bmWidth; shgt = bm.bmHeight;
\r
823 hdcSrc = CreateCompatibleDC(hdc);
\r
824 hOld = SelectObject(hdcSrc, hBG);
\r
828 cwid = MIN(swid - sx, r->right - nx);
\r
831 chgt = MIN(shgt - sy, r->bottom - ny);
\r
832 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
\r
834 } while (ny < r->bottom);
\r
837 } while (nx < r->right);
\r
839 SelectObject(hdcSrc, hOld);
\r
845 * Hack -- given a pathname, point at the filename
\r
847 static cptr extract_file_name(cptr s)
\r
851 /* Start at the end */
\r
852 p = s + strlen(s) - 1;
\r
854 /* Back up to divider */
\r
855 while ((p >= s) && (*p != ':') && (*p != '\\')) p--;
\r
857 /* Return file name */
\r
864 * Hack -- given a simple filename, extract the "font size" info
\r
866 * Return a pointer to a static buffer holding the capitalized base name.
\r
868 #if 0 /* #ifndef JP */
\r
869 static char *analyze_font(char *path, int *wp, int *hp)
\r
875 /* Start at the end */
\r
876 p = path + strlen(path) - 1;
\r
878 /* Back up to divider */
\r
879 while ((p >= path) && (*p != ':') && (*p != '\\')) --p;
\r
881 /* Advance to file name */
\r
885 for (s = p; *s; ++s)
\r
887 /* Capitalize (be paranoid) */
\r
888 if (islower(*s)) *s = toupper(*s);
\r
891 /* Find first 'X' */
\r
892 s = my_strchr(p, 'X');
\r
894 /* Extract font width */
\r
897 /* Extract height */
\r
898 hgt = s ? atoi(s+1) : 0;
\r
911 * Check for existance of a file
\r
913 static bool check_file(cptr s)
\r
923 unsigned int attrib;
\r
933 attrib = GetFileAttributes(path);
\r
935 /* Require valid filename */
\r
936 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
938 /* Prohibit directory */
\r
939 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return (FALSE);
\r
943 /* Examine and verify */
\r
944 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
946 /* Prohibit something */
\r
947 if (attrib & FA_LABEL) return (FALSE);
\r
949 /* Prohibit directory */
\r
950 if (attrib & FA_DIREC) return (FALSE);
\r
960 * Check for existance of a directory
\r
962 static bool check_dir(cptr s)
\r
974 unsigned int attrib;
\r
984 /* Remove trailing backslash */
\r
985 if (i && (path[i-1] == '\\')) path[--i] = '\0';
\r
990 attrib = GetFileAttributes(path);
\r
992 /* Require valid filename */
\r
993 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
995 /* Require directory */
\r
996 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE);
\r
1000 /* Examine and verify */
\r
1001 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
1003 /* Prohibit something */
\r
1004 if (attrib & FA_LABEL) return (FALSE);
\r
1006 /* Require directory */
\r
1007 if (!(attrib & FA_DIREC)) return (FALSE);
\r
1009 #endif /* WIN32 */
\r
1019 static void validate_file(cptr s)
\r
1021 /* Verify or fail */
\r
1022 if (!check_file(s))
\r
1024 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
\r
1030 * Validate a directory
\r
1032 static void validate_dir(cptr s, bool vital)
\r
1034 /* Verify or fail */
\r
1035 if (!check_dir(s))
\r
1037 /* This directory contains needed data */
\r
1040 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
\r
1042 /* Attempt to create this directory */
\r
1043 else if (mkdir(s))
\r
1045 quit_fmt("Unable to create directory:\n%s", s);
\r
1052 * @brief (Windows版固有実装)Get the "size" for a window
\r
1054 static void term_getsize(term_data *td)
\r
1057 TERM_LEN wid, hgt;
\r
1060 if (td->cols < 1) td->cols = 1;
\r
1061 if (td->rows < 1) td->rows = 1;
\r
1063 /* Window sizes */
\r
1064 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
1065 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
\r
1067 /* Fake window size */
\r
1069 rc.right = rc.left + wid;
\r
1071 rc.bottom = rc.top + hgt;
\r
1073 /* rc.right += 1; */
\r
1074 /* rc.bottom += 1; */
\r
1077 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
1080 td->size_wid = rc.right - rc.left;
\r
1081 td->size_hgt = rc.bottom - rc.top;
\r
1083 /* See CreateWindowEx */
\r
1084 if (!td->w) return;
\r
1086 /* Extract actual location */
\r
1087 GetWindowRect(td->w, &rc);
\r
1089 /* Save the location */
\r
1090 td->pos_x = rc.left;
\r
1091 td->pos_y = rc.top;
\r
1096 * Write the "prefs" for a single term
\r
1098 static void save_prefs_aux(int i)
\r
1100 term_data *td = &data[i];
\r
1101 char sec_name[128];
\r
1105 WINDOWPLACEMENT lpwndpl;
\r
1108 if (!td->w) return;
\r
1110 /* Make section name */
\r
1111 sprintf(sec_name, "Term-%d", i);
\r
1116 strcpy(buf, td->visible ? "1" : "0");
\r
1117 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
\r
1122 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "MS ゴシック");
\r
1125 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
\r
1127 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
\r
1131 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
\r
1133 #if 1 /* #ifdef JP */
\r
1134 wsprintf(buf, "%d", td->lf.lfWidth);
\r
1135 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
\r
1136 wsprintf(buf, "%d", td->lf.lfHeight);
\r
1137 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
\r
1138 wsprintf(buf, "%d", td->lf.lfWeight);
\r
1139 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
\r
1142 strcpy(buf, td->bizarre ? "1" : "0");
\r
1143 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
\r
1145 /* Tile size (x) */
\r
1146 wsprintf(buf, "%d", td->tile_wid);
\r
1147 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
\r
1149 /* Tile size (y) */
\r
1150 wsprintf(buf, "%d", td->tile_hgt);
\r
1151 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
\r
1153 /* Get window placement and dimensions */
\r
1154 lpwndpl.length = sizeof(WINDOWPLACEMENT);
\r
1155 GetWindowPlacement(td->w, &lpwndpl);
\r
1157 /* Acquire position in *normal* mode (not minimized) */
\r
1158 rc = lpwndpl.rcNormalPosition;
\r
1160 /* Window size (x) */
\r
1161 if (i == 0) wsprintf(buf, "%d", normsize.x);
\r
1162 else wsprintf(buf, "%d", td->cols);
\r
1163 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
\r
1165 /* Window size (y) */
\r
1166 if (i == 0) wsprintf(buf, "%d", normsize.y);
\r
1167 else wsprintf(buf, "%d", td->rows);
\r
1168 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
\r
1170 /* Maxmized (only main window) */
\r
1173 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
\r
1174 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
\r
1177 /* Acquire position */
\r
1178 GetWindowRect(td->w, &rc);
\r
1180 /* Window position (x) */
\r
1181 wsprintf(buf, "%d", rc.left);
\r
1182 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
\r
1184 /* Window position (y) */
\r
1185 wsprintf(buf, "%d", rc.top);
\r
1186 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
\r
1188 /* Window Z position */
\r
1191 strcpy(buf, td->posfix ? "1" : "0");
\r
1192 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
\r
1198 * Write the "prefs"
\r
1199 * We assume that the windows have all been initialized
\r
1201 static void save_prefs(void)
\r
1207 /* Save the "arg_graphics" flag */
\r
1208 sprintf(buf, "%d", arg_graphics);
\r
1209 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
\r
1211 /* Save the "arg_bigtile" flag */
\r
1212 strcpy(buf, arg_bigtile ? "1" : "0");
\r
1213 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
\r
1215 /* Save the "arg_sound" flag */
\r
1216 strcpy(buf, arg_sound ? "1" : "0");
\r
1217 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
\r
1219 /* Save the "arg_sound" flag */
\r
1220 strcpy(buf, arg_music ? "1" : "0");
\r
1221 WritePrivateProfileString("Angband", "Music", buf, ini_file);
\r
1224 strcpy(buf, use_bg ? "1" : "0");
\r
1225 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
\r
1226 WritePrivateProfileString("Angband", "BackGroundBitmap",
\r
1227 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
\r
1229 /* Save window prefs */
\r
1230 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1232 save_prefs_aux(i);
\r
1238 * Load the "prefs" for a single term
\r
1240 static void load_prefs_aux(int i)
\r
1242 term_data *td = &data[i];
\r
1243 char sec_name[128];
\r
1246 int wid, hgt, posx, posy;
\r
1247 int dispx = GetSystemMetrics( SM_CXVIRTUALSCREEN);
\r
1248 int dispy = GetSystemMetrics( SM_CYVIRTUALSCREEN);
\r
1252 /* Make section name */
\r
1253 sprintf(sec_name, "Term-%d", i);
\r
1255 /* Make section name */
\r
1256 sprintf(sec_name, "Term-%d", i);
\r
1261 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
\r
1264 /* Desired font, with default */
\r
1266 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
\r
1269 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
\r
1271 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
\r
1277 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
\r
1279 /* Analyze font, save desired font name */
\r
1280 #if 1 /* #ifdef JP */
\r
1281 td->font_want = string_make(tmp);
\r
1282 hgt = 15; wid = 0;
\r
1283 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
\r
1284 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
\r
1285 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
\r
1287 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
\r
1292 #if 1 /* #ifdef JP */
\r
1293 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
\r
1294 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
\r
1296 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
\r
1297 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
\r
1302 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
\r
1303 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
\r
1304 normsize.x = td->cols; normsize.y = td->rows;
\r
1309 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
\r
1312 /* Window position */
\r
1313 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
\r
1314 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
\r
1315 td->pos_x = MIN(MAX(0, posx), dispx-128);
\r
1316 td->pos_y = MIN(MAX(0, posy), dispy-128);
\r
1318 /* Window Z position */
\r
1321 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
\r
1327 * Load the "prefs"
\r
1329 static void load_prefs(void)
\r
1333 /* Extract the "arg_graphics" flag */
\r
1334 arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
\r
1336 /* Extract the "arg_bigtile" flag */
\r
1337 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
\r
1338 use_bigtile = arg_bigtile;
\r
1340 /* Extract the "arg_sound" flag */
\r
1341 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
\r
1343 /* Extract the "arg_sound" flag */
\r
1344 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
\r
1347 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
\r
1348 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
\r
1350 /* Load window prefs */
\r
1351 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1353 load_prefs_aux(i);
\r
1357 #if defined(USE_SOUND) || defined(USE_MUSIC)
\r
1360 * XXX XXX XXX - Taken from files.c.
\r
1362 * Extract "tokens" from a buffer
\r
1364 * This function uses "whitespace" as delimiters, and treats any amount of
\r
1365 * whitespace as a single delimiter. We will never return any empty tokens.
\r
1366 * When given an empty buffer, or a buffer containing only "whitespace", we
\r
1367 * will return no tokens. We will never extract more than "num" tokens.
\r
1369 * By running a token through the "text_to_ascii()" function, you can allow
\r
1370 * that token to include (encoded) whitespace, using "\s" to encode spaces.
\r
1372 * We save pointers to the tokens in "tokens", and return the number found.
\r
1374 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
\r
1384 /* Skip leading whitespace */
\r
1385 for ( ; *s && iswspace(*s); ++s) /* loop */;
\r
1390 /* Find next whitespace, if any */
\r
1391 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
\r
1393 /* Nuke and advance (if necessary) */
\r
1394 if (*t) *t++ = '\0';
\r
1396 /* Save the token */
\r
1407 #endif /* USE_SOUND || USE_MUSIC */
\r
1411 static void load_sound_prefs(void)
\r
1415 char ini_path[1024];
\r
1416 char wav_path[1024];
\r
1417 char *zz[SAMPLE_MAX];
\r
1419 /* Access the sound.cfg */
\r
1421 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
\r
1423 for (i = 0; i < SOUND_MAX; i++)
\r
1425 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
\r
1427 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
\r
1429 for (j = 0; j < num; j++)
\r
1431 /* Access the sound */
\r
1432 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
\r
1434 /* Save the sound filename, if it exists */
\r
1435 if (check_file(wav_path))
\r
1436 sound_file[i][j] = string_make(zz[j]);
\r
1441 #endif /* USE_SOUND */
\r
1445 static void load_music_prefs(void)
\r
1449 char ini_path[1024];
\r
1450 char wav_path[1024];
\r
1451 char *zz[SAMPLE_MAX];
\r
1454 /* Access the music.cfg */
\r
1456 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
\r
1458 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
\r
1460 for (i = 0; i < MUSIC_BASIC_MAX; i++)
\r
1462 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
\r
1464 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1466 for (j = 0; j < num; j++)
\r
1468 /* Access the sound */
\r
1469 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1471 /* Save the sound filename, if it exists */
\r
1472 if (check_file(wav_path))
\r
1473 music_file[i][j] = string_make(zz[j]);
\r
1477 for (i = 0; i < max_d_idx; i++)
\r
1479 sprintf(key, "dungeon%03d", i);
\r
1480 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
\r
1482 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1484 for (j = 0; j < num; j++)
\r
1486 /* Access the sound */
\r
1487 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1489 /* Save the sound filename, if it exists */
\r
1490 if (check_file(wav_path))
\r
1491 dungeon_music_file[i][j] = string_make(zz[j]);
\r
1495 for (i = 0; i < max_q_idx; i++)
\r
1497 sprintf(key, "quest%03d", i);
\r
1498 GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
\r
1500 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1502 for (j = 0; j < num; j++)
\r
1504 /* Access the sound */
\r
1505 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1507 /* Save the sound filename, if it exists */
\r
1508 if (check_file(wav_path))
\r
1509 quest_music_file[i][j] = string_make(zz[j]);
\r
1513 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
\r
1515 sprintf(key, "town%03d", i);
\r
1516 GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
\r
1518 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1520 for (j = 0; j < num; j++)
\r
1522 /* Access the sound */
\r
1523 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1525 /* Save the sound filename, if it exists */
\r
1526 if (check_file(wav_path))
\r
1527 town_music_file[i][j] = string_make(zz[j]);
\r
1534 #endif /* USE_MUSIC */
\r
1537 * Create the new global palette based on the bitmap palette
\r
1538 * (if any), and the standard 16 entry palette derived from
\r
1539 * "win_clr[]" which is used for the basic 16 Angband colors.
\r
1541 * This function is never called before all windows are ready.
\r
1543 * This function returns FALSE if the new palette could not be
\r
1544 * prepared, which should normally be a fatal error. XXX XXX
\r
1546 * Note that only some machines actually use a "palette".
\r
1548 static int new_palette(void)
\r
1556 LPLOGPALETTE pLogPal;
\r
1557 LPPALETTEENTRY lppe;
\r
1562 /* This makes no sense */
\r
1563 if (!paletted) return (TRUE);
\r
1571 #ifdef USE_GRAPHICS
\r
1573 /* Check the bitmap palette */
\r
1574 hBmPal = infGraph.hPalette;
\r
1576 /* Use the bitmap */
\r
1579 lppeSize = 256 * sizeof(PALETTEENTRY);
\r
1580 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
\r
1581 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
\r
1582 if ((nEntries == 0) || (nEntries > 220))
\r
1584 /* Warn the user */
\r
1585 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
\r
1588 rnfree(lppe, lppeSize);
\r
1595 #endif /* USE_GRAPHICS */
\r
1597 /* Size of palette */
\r
1598 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
\r
1600 /* Allocate palette */
\r
1601 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
\r
1604 pLogPal->palVersion = 0x300;
\r
1606 /* Make room for bitmap and normal data */
\r
1607 pLogPal->palNumEntries = nEntries + 16;
\r
1609 /* Save the bitmap data */
\r
1610 for (i = 0; i < nEntries; i++)
\r
1612 pLogPal->palPalEntry[i] = lppe[i];
\r
1615 /* Save the normal data */
\r
1616 for (i = 0; i < 16; i++)
\r
1620 /* Access the entry */
\r
1621 p = &(pLogPal->palPalEntry[i+nEntries]);
\r
1623 /* Save the colors */
\r
1624 p->peRed = GetRValue(win_clr[i]);
\r
1625 p->peGreen = GetGValue(win_clr[i]);
\r
1626 p->peBlue = GetBValue(win_clr[i]);
\r
1628 /* Save the flags */
\r
1629 p->peFlags = PC_NOCOLLAPSE;
\r
1632 /* Free something */
\r
1633 if (lppe) rnfree(lppe, lppeSize);
\r
1635 /* Create a new palette, or fail */
\r
1636 hNewPal = CreatePalette(pLogPal);
\r
1637 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
\r
1639 /* Free the palette */
\r
1640 rnfree(pLogPal, pLogPalSize);
\r
1645 /* Realize the palette */
\r
1646 hdc = GetDC(td->w);
\r
1647 SelectPalette(hdc, hNewPal, 0);
\r
1648 i = RealizePalette(hdc);
\r
1649 ReleaseDC(td->w, hdc);
\r
1650 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
\r
1654 for (i = 1; i < MAX_TERM_DATA; i++)
\r
1658 hdc = GetDC(td->w);
\r
1659 SelectPalette(hdc, hNewPal, 0);
\r
1660 ReleaseDC(td->w, hdc);
\r
1663 /* Delete old palette */
\r
1664 if (hPal) DeleteObject(hPal);
\r
1666 /* Save new palette */
\r
1674 #ifdef USE_GRAPHICS
\r
1676 * @brief グラフィクスを初期化する / Initialize graphics
\r
1679 * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
\r
1680 * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
\r
1683 static bool init_graphics(void)
\r
1685 /* Initialize once */
\r
1687 BYTE wid, hgt, twid, thgt, ox, oy;
\r
1690 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1698 name = "16X16.BMP";
\r
1700 ANGBAND_GRAF = "new";
\r
1702 else if (arg_graphics == GRAPHICS_HENGBAND)
\r
1711 name = "64X64.BMP";
\r
1720 name = "32X32.BMP";
\r
1722 ANGBAND_GRAF = "ne2";
\r
1733 ANGBAND_GRAF = "old";
\r
1736 /* Access the bitmap file */
\r
1737 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
\r
1739 /* Load the bitmap or quit */
\r
1740 if (!ReadDIB(data[0].w, buf, &infGraph))
\r
1742 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
\r
1746 /* Save the new sizes */
\r
1747 infGraph.CellWidth = wid;
\r
1748 infGraph.CellHeight = hgt;
\r
1749 infGraph.TileWidth = twid;
\r
1750 infGraph.TileHeight = thgt;
\r
1751 infGraph.OffsetX = ox;
\r
1752 infGraph.OffsetY = oy;
\r
1754 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1756 /* Access the mask file */
\r
1757 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
\r
1759 /* Load the bitmap or quit */
\r
1760 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1762 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1766 if (arg_graphics == GRAPHICS_HENGBAND)
\r
1768 /* Access the mask file */
\r
1769 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
\r
1771 /* Load the bitmap or quit */
\r
1772 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1774 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1779 /* Activate a palette */
\r
1780 if (!new_palette())
\r
1782 /* Free bitmap XXX XXX XXX */
\r
1785 plog(_("パレットを実現できません!", "Cannot activate palette!"));
\r
1789 /* Graphics available */
\r
1790 current_graphics_mode = arg_graphics;
\r
1793 return (current_graphics_mode);
\r
1795 #endif /* USE_GRAPHICS */
\r
1800 * Initialize music
\r
1802 static bool init_music(void)
\r
1804 /* Initialize once */
\r
1805 if (!can_use_music)
\r
1807 /* Load the prefs */
\r
1808 load_music_prefs();
\r
1810 /* Sound available */
\r
1811 can_use_music = TRUE;
\r
1815 return (can_use_music);
\r
1819 * Hack -- Stop a music
\r
1821 static void stop_music(void)
\r
1823 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
1824 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
1827 #endif /* USE_MUSIC */
\r
1831 * Initialize sound
\r
1833 static bool init_sound(void)
\r
1835 /* Initialize once */
\r
1836 if (!can_use_sound)
\r
1838 /* Load the prefs */
\r
1839 load_sound_prefs();
\r
1841 /* Sound available */
\r
1842 can_use_sound = TRUE;
\r
1846 return (can_use_sound);
\r
1848 #endif /* USE_SOUND */
\r
1854 static void term_window_resize(term_data *td)
\r
1856 /* Require window */
\r
1857 if (!td->w) return;
\r
1859 /* Resize the window */
\r
1860 SetWindowPos(td->w, 0, 0, 0,
\r
1861 td->size_wid, td->size_hgt,
\r
1862 SWP_NOMOVE | SWP_NOZORDER);
\r
1864 /* Redraw later */
\r
1865 InvalidateRect(td->w, NULL, TRUE);
\r
1870 * Force the use of a new "font file" for a term_data
\r
1872 * This function may be called before the "window" is ready
\r
1874 * This function returns zero only if everything succeeds.
\r
1876 * Note that the "font name" must be capitalized!!!
\r
1878 static errr term_force_font(term_data *td, cptr path)
\r
1882 #if 0 /* #ifndef JP */
\r
1888 /* Forget the old font (if needed) */
\r
1889 if (td->font_id) DeleteObject(td->font_id);
\r
1891 #if 1 /* #ifdef JP */
\r
1895 /* Create the font (using the 'base' of the font file name!) */
\r
1896 td->font_id = CreateFontIndirect(&(td->lf));
\r
1897 wid = td->lf.lfWidth;
\r
1898 hgt = td->lf.lfHeight;
\r
1899 if (!td->font_id) return (1);
\r
1901 /* Forget old font */
\r
1902 if (td->font_file)
\r
1904 bool used = FALSE;
\r
1906 /* Scan windows */
\r
1907 for (i = 0; i < MAX_TERM_DATA; i++)
\r
1909 /* Don't check when closing the application */
\r
1912 /* Check "screen" */
\r
1913 if ((td != &data[i]) &&
\r
1914 (data[i].font_file) &&
\r
1915 (streq(data[i].font_file, td->font_file)))
\r
1921 /* Remove unused font resources */
\r
1922 if (!used) RemoveFontResource(td->font_file);
\r
1924 /* Free the old name */
\r
1925 string_free(td->font_file);
\r
1928 td->font_file = NULL;
\r
1931 /* No path given */
\r
1932 if (!path) return (1);
\r
1935 strcpy(buf, path);
\r
1937 /* Analyze font path */
\r
1938 base = analyze_font(buf, &wid, &hgt);
\r
1940 /* Verify suffix */
\r
1941 if (!suffix(base, ".FON")) return (1);
\r
1944 if (!check_file(buf)) return (1);
\r
1946 /* Load the new font */
\r
1947 if (!AddFontResource(buf)) return (1);
\r
1949 /* Save new font name */
\r
1950 td->font_file = string_make(base);
\r
1952 /* Remove the "suffix" */
\r
1953 base[strlen(base)-4] = '\0';
\r
1955 /* Create the font (using the 'base' of the font file name!) */
\r
1956 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
\r
1957 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
\r
1958 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
\r
1959 FIXED_PITCH | FF_DONTCARE, base);
\r
1962 /* Hack -- Unknown size */
\r
1969 /* all this trouble to get the cell size */
\r
1970 hdcDesktop = GetDC(HWND_DESKTOP);
\r
1971 hfOld = SelectObject(hdcDesktop, td->font_id);
\r
1972 GetTextMetrics(hdcDesktop, &tm);
\r
1973 SelectObject(hdcDesktop, hfOld);
\r
1974 ReleaseDC(HWND_DESKTOP, hdcDesktop);
\r
1976 /* Font size info */
\r
1977 wid = tm.tmAveCharWidth;
\r
1978 hgt = tm.tmHeight;
\r
1981 /* Save the size info */
\r
1982 td->font_wid = wid;
\r
1983 td->font_hgt = hgt;
\r
1992 * Allow the user to change the font for this window.
\r
1994 static void term_change_font(term_data *td)
\r
1996 #if 1 /* #ifdef JP */
\r
1999 memset(&cf, 0, sizeof(cf));
\r
2000 cf.lStructSize = sizeof(cf);
\r
2001 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
\r
2002 cf.lpLogFont = &(td->lf);
\r
2004 if (ChooseFont(&cf))
\r
2006 /* Force the font */
\r
2007 term_force_font(td, NULL);
\r
2009 /* Assume not bizarre */
\r
2010 td->bizarre = TRUE;
\r
2012 /* Reset the tile info */
\r
2013 td->tile_wid = td->font_wid;
\r
2014 td->tile_hgt = td->font_hgt;
\r
2016 /* Analyze the font */
\r
2019 /* Resize the window */
\r
2020 term_window_resize(td);
\r
2026 char tmp[1024] = "";
\r
2028 /* Extract a default if possible */
\r
2029 if (td->font_file) strcpy(tmp, td->font_file);
\r
2031 /* Ask for a choice */
\r
2032 memset(&ofn, 0, sizeof(ofn));
\r
2033 ofn.lStructSize = sizeof(ofn);
\r
2034 ofn.hwndOwner = data[0].w;
\r
2035 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
\r
2036 ofn.nFilterIndex = 1;
\r
2037 ofn.lpstrFile = tmp;
\r
2038 ofn.nMaxFile = 128;
\r
2039 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
\r
2040 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
2041 ofn.lpstrDefExt = "fon";
\r
2043 /* Force choice if legal */
\r
2044 if (GetOpenFileName(&ofn))
\r
2046 /* Force the font */
\r
2047 if (term_force_font(td, tmp))
\r
2049 /* Access the standard font file */
\r
2050 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
2052 /* Force the use of that font */
\r
2053 (void)term_force_font(td, tmp);
\r
2056 /* Assume not bizarre */
\r
2057 td->bizarre = FALSE;
\r
2059 /* Reset the tile info */
\r
2060 td->tile_wid = td->font_wid;
\r
2061 td->tile_hgt = td->font_hgt;
\r
2063 /* Analyze the font */
\r
2066 /* Resize the window */
\r
2067 term_window_resize(td);
\r
2074 * Allow the user to lock this window.
\r
2076 static void term_window_pos(term_data *td, HWND hWnd)
\r
2078 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
\r
2079 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
\r
2082 static void windows_map(void);
\r
2085 * Hack -- redraw a term_data
\r
2087 static void term_data_redraw(term_data *td)
\r
2089 if (td->map_active)
\r
2091 /* Redraw the map */
\r
2096 /* Activate the term */
\r
2097 Term_activate(&td->t);
\r
2099 /* Redraw the contents */
\r
2102 /* Restore the term */
\r
2103 Term_activate(term_screen);
\r
2108 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
\r
2112 HBRUSH myBrush, oldBrush;
\r
2114 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
\r
2115 int tx = td->size_ow1 + x * td->tile_wid;
\r
2116 int ty = td->size_oh1 + y * td->tile_hgt;
\r
2117 int tw = w * td->tile_wid - 1;
\r
2118 int th = h * td->tile_hgt - 1;
\r
2120 hdc = GetDC(hWnd);
\r
2121 myBrush = CreateSolidBrush(RGB(255, 255, 255));
\r
2122 oldBrush = SelectObject(hdc, myBrush);
\r
2123 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2125 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
\r
2127 SelectObject(hdc, oldBrush);
\r
2128 SelectObject(hdc, oldPen);
\r
2133 /*** Function hooks needed by "Term" ***/
\r
2139 * Initialize a new Term
\r
2141 static void Term_init_win(term *t)
\r
2148 * Nuke an old Term
\r
2150 static void Term_nuke_win(term *t)
\r
2159 * @brief //!< Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
\r
2161 static errr Term_user_win(int n)
\r
2172 * React to global changes
\r
2174 static errr Term_xtra_win_react(void)
\r
2178 /* Simple color */
\r
2181 /* Save the default colors */
\r
2182 for (i = 0; i < 256; i++)
\r
2184 /* Simply accept the desired colors */
\r
2185 win_pal[i] = angband_color_table[i][0];
\r
2189 /* Complex color */
\r
2196 bool change = FALSE;
\r
2198 /* Save the default colors */
\r
2199 for (i = 0; i < 256; i++)
\r
2201 /* Extract desired values */
\r
2202 rv = angband_color_table[i][1];
\r
2203 gv = angband_color_table[i][2];
\r
2204 bv = angband_color_table[i][3];
\r
2206 /* Extract a full color code */
\r
2207 code = PALETTERGB(rv, gv, bv);
\r
2209 /* Activate changes */
\r
2210 if (win_clr[i] != code)
\r
2212 /* Note the change */
\r
2215 /* Apply the desired color */
\r
2216 win_clr[i] = code;
\r
2220 /* Activate the palette if needed */
\r
2221 if (change) (void)new_palette();
\r
2227 /* Handle "arg_sound" */
\r
2228 if (use_sound != arg_sound)
\r
2230 /* Initialize (if needed) */
\r
2231 if (arg_sound && !init_sound())
\r
2234 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
\r
2236 /* Cannot enable */
\r
2237 arg_sound = FALSE;
\r
2240 /* Change setting */
\r
2241 use_sound = arg_sound;
\r
2248 /* Handle "arg_sound" */
\r
2249 if (use_music != arg_music)
\r
2251 /* Initialize (if needed) */
\r
2252 if (arg_music && !init_music())
\r
2255 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
\r
2256 /* Cannot enable */
\r
2257 arg_music = FALSE;
\r
2260 /* Change setting */
\r
2261 use_music = arg_music;
\r
2263 if(!arg_music) stop_music();
\r
2264 else select_floor_music();
\r
2271 #ifdef USE_GRAPHICS
\r
2273 /* Handle "arg_graphics" */
\r
2274 if (use_graphics != arg_graphics)
\r
2276 /* Initialize (if needed) */
\r
2277 if (arg_graphics && !init_graphics())
\r
2280 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
\r
2282 /* Cannot enable */
\r
2283 arg_graphics = GRAPHICS_NONE;
\r
2286 /* Change setting */
\r
2287 use_graphics = arg_graphics;
\r
2289 /* Reset visuals */
\r
2290 #ifdef ANGBAND_2_8_1
\r
2292 #else /* ANGBAND_2_8_1 */
\r
2293 reset_visuals(TRUE);
\r
2294 #endif /* ANGBAND_2_8_1 */
\r
2297 #endif /* USE_GRAPHICS */
\r
2300 /* Clean up windows */
\r
2301 for (i = 0; i < MAX_TERM_DATA; i++)
\r
2305 term_data *td = &data[i];
\r
2307 /* Update resized windows */
\r
2308 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
\r
2311 Term_activate(&td->t);
\r
2313 /* Hack -- Resize the term */
\r
2314 Term_resize(td->cols, td->rows);
\r
2316 /* Redraw the contents */
\r
2320 Term_activate(old);
\r
2331 * Process at least one event
\r
2333 static errr Term_xtra_win_event(int v)
\r
2337 /* Wait for an event */
\r
2341 if (GetMessage(&msg, NULL, 0, 0))
\r
2343 TranslateMessage(&msg);
\r
2344 DispatchMessage(&msg);
\r
2348 /* Check for an event */
\r
2352 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2354 TranslateMessage(&msg);
\r
2355 DispatchMessage(&msg);
\r
2365 * Process all pending events
\r
2367 static errr Term_xtra_win_flush(void)
\r
2371 /* Process all pending events */
\r
2372 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2374 TranslateMessage(&msg);
\r
2375 DispatchMessage(&msg);
\r
2384 * Hack -- clear the screen
\r
2386 * Make this more efficient XXX XXX XXX
\r
2388 static errr Term_xtra_win_clear(void)
\r
2390 term_data *td = (term_data*)(Term->data);
\r
2395 /* Rectangle to erase */
\r
2396 rc.left = td->size_ow1;
\r
2397 rc.right = rc.left + td->cols * td->tile_wid;
\r
2398 rc.top = td->size_oh1;
\r
2399 rc.bottom = rc.top + td->rows * td->tile_hgt;
\r
2402 hdc = GetDC(td->w);
\r
2403 SetBkColor(hdc, RGB(0, 0, 0));
\r
2404 SelectObject(hdc, td->font_id);
\r
2405 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2410 rc.left = 0; rc.top = 0;
\r
2413 ReleaseDC(td->w, hdc);
\r
2421 * Hack -- make a noise
\r
2423 static errr Term_xtra_win_noise(void)
\r
2425 MessageBeep(MB_ICONASTERISK);
\r
2431 * Hack -- make a sound
\r
2433 static errr Term_xtra_win_sound(int v)
\r
2438 #endif /* USE_SOUND */
\r
2440 /* Sound disabled */
\r
2441 if (!use_sound) return (1);
\r
2443 /* Illegal sound */
\r
2444 if ((v < 0) || (v >= SOUND_MAX)) return (1);
\r
2448 /* Count the samples */
\r
2449 for (i = 0; i < SAMPLE_MAX; i++)
\r
2451 if (!sound_file[v][i])
\r
2456 if (i == 0) return (1);
\r
2458 /* Build the path */
\r
2459 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
\r
2463 /* Play the sound, catch errors */
\r
2464 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
\r
2468 /* Play the sound, catch errors */
\r
2469 return (sndPlaySound(buf, SND_ASYNC));
\r
2471 #endif /* WIN32 */
\r
2473 #else /* USE_SOUND */
\r
2478 #endif /* USE_SOUND */
\r
2482 * Hack -- play a music
\r
2484 static errr Term_xtra_win_music(int n, int v)
\r
2489 #endif /* USE_MUSIC */
\r
2491 /* Sound disabled */
\r
2493 if(!use_music) return (1);
\r
2495 /* Illegal sound */
\r
2496 if(n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return (1);
\r
2497 else if(v < 0 || v >= 1000) return(1); /*!< TODO */
\r
2503 case TERM_XTRA_MUSIC_BASIC:
\r
2504 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2506 case TERM_XTRA_MUSIC_DUNGEON:
\r
2507 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2509 case TERM_XTRA_MUSIC_QUEST:
\r
2510 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2512 case TERM_XTRA_MUSIC_TOWN:
\r
2513 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2520 //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2521 //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2527 case TERM_XTRA_MUSIC_BASIC:
\r
2528 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2530 case TERM_XTRA_MUSIC_DUNGEON:
\r
2531 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2533 case TERM_XTRA_MUSIC_QUEST:
\r
2534 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2536 case TERM_XTRA_MUSIC_TOWN:
\r
2537 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2544 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2545 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2551 case TERM_XTRA_MUSIC_BASIC:
\r
2552 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
\r
2554 case TERM_XTRA_MUSIC_DUNGEON:
\r
2555 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
\r
2557 case TERM_XTRA_MUSIC_QUEST:
\r
2558 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
\r
2560 case TERM_XTRA_MUSIC_TOWN:
\r
2561 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
\r
2565 if(current_music_type == n && current_music_id == v)
\r
2569 current_music_type = n;
\r
2570 current_music_id = v;
\r
2574 mop.lpstrDeviceType = mci_device_type;
\r
2575 mop.lpstrElementName = buf;
\r
2576 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2577 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2578 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
\r
2579 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
2580 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
2583 #endif /* WIN32 */
\r
2585 #else /* USE_MUSIC */
\r
2589 #endif /* USE_MUSIC */
\r
2595 * Delay for "x" milliseconds
\r
2597 static int Term_xtra_win_delay(int v)
\r
2611 t = GetTickCount() + v;
\r
2614 while (GetTickCount() < t)
\r
2616 /* Handle messages */
\r
2617 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2619 TranslateMessage(&msg);
\r
2620 DispatchMessage(&msg);
\r
2624 #endif /* WIN32 */
\r
2632 * Do a "special thing"
\r
2634 static errr Term_xtra_win(int n, int v)
\r
2636 /* Handle a subset of the legal requests */
\r
2639 /* Make a bell sound */
\r
2640 case TERM_XTRA_NOISE:
\r
2642 return (Term_xtra_win_noise());
\r
2645 /* Play a music */
\r
2646 case TERM_XTRA_MUSIC_BASIC:
\r
2647 case TERM_XTRA_MUSIC_DUNGEON:
\r
2648 case TERM_XTRA_MUSIC_QUEST:
\r
2649 case TERM_XTRA_MUSIC_TOWN:
\r
2651 return (Term_xtra_win_music(n, v));
\r
2654 /* Make a special sound */
\r
2655 case TERM_XTRA_SOUND:
\r
2657 return (Term_xtra_win_sound(v));
\r
2660 /* Process random events */
\r
2661 case TERM_XTRA_BORED:
\r
2663 return (Term_xtra_win_event(0));
\r
2666 /* Process an event */
\r
2667 case TERM_XTRA_EVENT:
\r
2669 return (Term_xtra_win_event(v));
\r
2672 /* Flush all events */
\r
2673 case TERM_XTRA_FLUSH:
\r
2675 return (Term_xtra_win_flush());
\r
2678 /* Clear the screen */
\r
2679 case TERM_XTRA_CLEAR:
\r
2681 return (Term_xtra_win_clear());
\r
2684 /* React to global changes */
\r
2685 case TERM_XTRA_REACT:
\r
2687 return (Term_xtra_win_react());
\r
2690 /* Delay for some milliseconds */
\r
2691 case TERM_XTRA_DELAY:
\r
2693 return (Term_xtra_win_delay(v));
\r
2704 * Low level graphics (Assumes valid input).
\r
2706 * Draw a "cursor" at (x,y), using a "yellow box".
\r
2708 static errr Term_curs_win(int x, int y)
\r
2710 term_data *td = (term_data*)(Term->data);
\r
2715 int tile_wid, tile_hgt;
\r
2717 if (td->map_active)
\r
2719 tile_wid = td->map_tile_wid;
\r
2720 tile_hgt = td->map_tile_hgt;
\r
2724 tile_wid = td->tile_wid;
\r
2725 tile_hgt = td->tile_hgt;
\r
2728 /* Frame the grid */
\r
2729 rc.left = x * tile_wid + td->size_ow1;
\r
2730 rc.right = rc.left + tile_wid;
\r
2731 rc.top = y * tile_hgt + td->size_oh1;
\r
2732 rc.bottom = rc.top + tile_hgt;
\r
2734 /* Cursor is done as a yellow "box" */
\r
2735 hdc = GetDC(td->w);
\r
2736 FrameRect(hdc, &rc, hbrYellow);
\r
2737 ReleaseDC(td->w, hdc);
\r
2745 * Low level graphics (Assumes valid input).
\r
2747 * Draw a "big cursor" at (x,y), using a "yellow box".
\r
2749 static errr Term_bigcurs_win(int x, int y)
\r
2751 term_data *td = (term_data*)(Term->data);
\r
2756 int tile_wid, tile_hgt;
\r
2758 if (td->map_active)
\r
2760 /* Normal cursor in map window */
\r
2761 Term_curs_win(x, y);
\r
2766 tile_wid = td->tile_wid;
\r
2767 tile_hgt = td->tile_hgt;
\r
2770 /* Frame the grid */
\r
2771 rc.left = x * tile_wid + td->size_ow1;
\r
2772 rc.right = rc.left + 2 * tile_wid;
\r
2773 rc.top = y * tile_hgt + td->size_oh1;
\r
2774 rc.bottom = rc.top + tile_hgt;
\r
2776 /* Cursor is done as a yellow "box" */
\r
2777 hdc = GetDC(td->w);
\r
2778 FrameRect(hdc, &rc, hbrYellow);
\r
2779 ReleaseDC(td->w, hdc);
\r
2787 * Low level graphics (Assumes valid input).
\r
2789 * Erase a "block" of "n" characters starting at (x,y).
\r
2791 static errr Term_wipe_win(int x, int y, int n)
\r
2793 term_data *td = (term_data*)(Term->data);
\r
2798 /* Rectangle to erase in client coords */
\r
2799 rc.left = x * td->tile_wid + td->size_ow1;
\r
2800 rc.right = rc.left + n * td->tile_wid;
\r
2801 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2802 rc.bottom = rc.top + td->tile_hgt;
\r
2804 hdc = GetDC(td->w);
\r
2805 SetBkColor(hdc, RGB(0, 0, 0));
\r
2806 SelectObject(hdc, td->font_id);
\r
2811 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2812 ReleaseDC(td->w, hdc);
\r
2820 * Low level graphics. Assumes valid input.
\r
2822 * Draw several ("n") chars, with an attr, at a given location.
\r
2824 * All "graphic" data is handled by "Term_pict_win()", below.
\r
2826 * One would think there is a more efficient method for telling a window
\r
2827 * what color it should be using to draw with, but perhaps simply changing
\r
2828 * it every time is not too inefficient. XXX XXX XXX
\r
2830 static errr Term_text_win(int x, int y, int n, TERM_COLOR a, const char *s)
\r
2832 term_data *td = (term_data*)(Term->data);
\r
2836 #if 1 /* #ifdef JP */
\r
2837 static HBITMAP WALL;
\r
2838 static HBRUSH myBrush, oldBrush;
\r
2839 static HPEN oldPen;
\r
2840 static bool init_done = FALSE;
\r
2843 WALL = LoadBitmap(hInstance, AppName);
\r
2844 myBrush = CreatePatternBrush(WALL);
\r
2849 /* Total rectangle */
\r
2850 rc.left = x * td->tile_wid + td->size_ow1;
\r
2851 rc.right = rc.left + n * td->tile_wid;
\r
2852 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2853 rc.bottom = rc.top + td->tile_hgt;
\r
2856 hdc = GetDC(td->w);
\r
2858 /* Background color */
\r
2859 SetBkColor(hdc, RGB(0, 0, 0));
\r
2861 /* Foreground color */
\r
2864 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
\r
2866 else if (paletted)
\r
2868 SetTextColor(hdc, win_clr[a&0x0F]);
\r
2872 SetTextColor(hdc, win_clr[a]);
\r
2875 /* Use the font */
\r
2876 SelectObject(hdc, td->font_id);
\r
2879 if (use_bg) SetBkMode(hdc, TRANSPARENT);
\r
2881 /* Bizarre size */
\r
2882 if (td->bizarre ||
\r
2883 (td->tile_hgt != td->font_hgt) ||
\r
2884 (td->tile_wid != td->font_wid))
\r
2888 /* Erase complete rectangle */
\r
2889 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2892 if (use_bg) DrawBG(hdc, &rc);
\r
2894 /* New rectangle */
\r
2895 rc.left += ((td->tile_wid - td->font_wid) / 2);
\r
2896 rc.right = rc.left + td->font_wid;
\r
2897 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
\r
2898 rc.bottom = rc.top + td->font_hgt;
\r
2900 /* Dump each character */
\r
2901 for (i = 0; i < n; i++)
\r
2904 if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
\r
2906 rc.right += td->font_wid;
\r
2908 oldBrush = SelectObject(hdc, myBrush);
\r
2909 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2911 /* Dump the wall */
\r
2912 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2914 SelectObject(hdc, oldBrush);
\r
2915 SelectObject(hdc, oldPen);
\r
2916 rc.right -= td->font_wid;
\r
2920 rc.left += 2 * td->tile_wid;
\r
2921 rc.right += 2 * td->tile_wid;
\r
2923 else if ( iskanji(*(s+i)) ) /* 2バイト文字 */
\r
2925 rc.right += td->font_wid;
\r
2926 /* Dump the text */
\r
2927 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2929 rc.right -= td->font_wid;
\r
2933 rc.left += 2 * td->tile_wid;
\r
2934 rc.right += 2 * td->tile_wid;
\r
2935 } else if (*(s+i)==127){
\r
2936 oldBrush = SelectObject(hdc, myBrush);
\r
2937 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2939 /* Dump the wall */
\r
2940 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2942 SelectObject(hdc, oldBrush);
\r
2943 SelectObject(hdc, oldPen);
\r
2946 rc.left += td->tile_wid;
\r
2947 rc.right += td->tile_wid;
\r
2949 /* Dump the text */
\r
2950 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
\r
2953 rc.left += td->tile_wid;
\r
2954 rc.right += td->tile_wid;
\r
2959 oldBrush = SelectObject(hdc, myBrush);
\r
2960 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2962 /* Dump the wall */
\r
2963 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2965 SelectObject(hdc, oldBrush);
\r
2966 SelectObject(hdc, oldPen);
\r
2969 rc.left += td->tile_wid;
\r
2970 rc.right += td->tile_wid;
\r
2972 /* Dump the text */
\r
2973 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2977 rc.left += td->tile_wid;
\r
2978 rc.right += td->tile_wid;
\r
2981 /* Dump the text */
\r
2982 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
\r
2986 rc.left += td->tile_wid;
\r
2987 rc.right += td->tile_wid;
\r
2997 /* Dump the text */
\r
2998 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
\r
3003 ReleaseDC(td->w, hdc);
\r
3011 * Low level graphics. Assumes valid input.
\r
3013 * Draw an array of "special" attr/char pairs at the given location.
\r
3015 * We use the "Term_pict_win()" function for "graphic" data, which are
\r
3016 * encoded by setting the "high-bits" of both the "attr" and the "char"
\r
3017 * data. We use the "attr" to represent the "row" of the main bitmap,
\r
3018 * and the "char" to represent the "col" of the main bitmap. The use
\r
3019 * of this function is induced by the "higher_pict" flag.
\r
3021 * If "graphics" is not available, we simply "wipe" the given grids.
\r
3023 static errr Term_pict_win(TERM_LEN x, TERM_LEN y, int n, const TERM_COLOR *ap, const char *cp, const TERM_COLOR *tap, const char *tcp)
\r
3025 term_data *td = (term_data*)(Term->data);
\r
3027 #ifdef USE_GRAPHICS
\r
3030 TERM_LEN x1, y1, w1, h1, tw1, th1;
\r
3031 TERM_LEN x2, y2, w2, h2, tw2 = 0;
\r
3034 HDC hdcMask = NULL;
\r
3038 HBITMAP hbmSrcOld;
\r
3041 if (!use_graphics)
\r
3043 /* Erase the grids */
\r
3044 return (Term_wipe_win(x, y, n));
\r
3047 /* Size of bitmap cell */
\r
3048 w1 = infGraph.CellWidth;
\r
3049 h1 = infGraph.CellHeight;
\r
3050 tw1 = infGraph.TileWidth;
\r
3051 th1 = infGraph.TileHeight;
\r
3053 /* Size of window cell */
\r
3054 if (td->map_active)
\r
3056 w2 = td->map_tile_wid;
\r
3057 h2 = td->map_tile_hgt;
\r
3061 w2 = td->tile_wid;
\r
3062 h2 = td->tile_hgt;
\r
3065 /* big tile mode */
\r
3066 if (use_bigtile) tw2 *= 2;
\r
3069 /* Location of window cell */
\r
3070 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
\r
3071 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
\r
3074 hdc = GetDC(td->w);
\r
3077 hdcSrc = CreateCompatibleDC(hdc);
\r
3078 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
\r
3080 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3082 hdcMask = CreateCompatibleDC(hdc);
\r
3083 SelectObject(hdcMask, infMask.hBitmap);
\r
3086 /* Draw attr/char pairs */
\r
3087 for (i = 0; i < n; i++, x2 += w2)
\r
3089 TERM_COLOR a = ap[i];
\r
3093 /* Extract picture */
\r
3094 int row = (a & 0x7F);
\r
3095 int col = (c & 0x7F);
\r
3097 /* Location of bitmap cell */
\r
3101 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3103 x3 = (tcp[i] & 0x7F) * w1;
\r
3104 y3 = (tap[i] & 0x7F) * h1;
\r
3105 tw2 = tw2 * w1 / tw1;
\r
3106 h2 = h2 * h1 / th1;
\r
3108 /* Perfect size */
\r
3109 if ((tw1 == tw2) && (th1 == h2))
\r
3111 /* Copy the terrain picture from the bitmap to the window */
\r
3112 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
\r
3114 /* Mask out the tile */
\r
3115 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
\r
3117 /* Draw the tile */
\r
3118 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
\r
3121 /* Need to stretch */
\r
3124 /* Set the correct mode for stretching the tiles */
\r
3125 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3127 /* Copy the terrain picture from the bitmap to the window */
\r
3128 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
\r
3130 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
\r
3132 /* Only draw if terrain and overlay are different */
\r
3133 if ((x1 != x3) || (y1 != y3))
\r
3135 /* Mask out the tile */
\r
3136 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
\r
3138 /* Draw the tile */
\r
3139 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
\r
3145 /* Perfect size */
\r
3146 if ((w1 == tw2) && (h1 == h2))
\r
3148 /* Copy the picture from the bitmap to the window */
\r
3149 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
\r
3152 /* Need to stretch */
\r
3155 /* Set the correct mode for stretching the tiles */
\r
3156 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3158 /* Copy the picture from the bitmap to the window */
\r
3159 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
\r
3165 SelectObject(hdcSrc, hbmSrcOld);
\r
3168 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3171 SelectObject(hdcMask, hbmSrcOld);
\r
3172 DeleteDC(hdcMask);
\r
3176 ReleaseDC(td->w, hdc);
\r
3178 #else /* USE_GRAPHICS */
\r
3180 /* Just erase this grid */
\r
3181 return (Term_wipe_win(x, y, n));
\r
3183 #endif /* USE_GRAPHICS */
\r
3190 static void windows_map(void)
\r
3192 term_data *td = &data[0];
\r
3195 TERM_LEN x, min_x, max_x;
\r
3196 TERM_LEN y, min_y, max_y;
\r
3201 /* Only in graphics mode */
\r
3202 if (!use_graphics) return;
\r
3204 /* Clear screen */
\r
3205 Term_xtra_win_clear();
\r
3207 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
\r
3208 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
\r
3209 td->map_active = TRUE;
\r
3218 /* Draw the map */
\r
3219 for (x = min_x; x < max_x; x++)
\r
3221 for (y = min_y; y < max_y; y++)
\r
3223 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
\r
3225 /* Ignore non-graphics */
\r
3226 if ((a & 0x80) && (c & 0x80))
\r
3228 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
\r
3233 /* Hilite the player */
\r
3234 Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
\r
3236 /* Wait for a keypress, flush key buffer */
\r
3237 Term_inkey(&c, TRUE, TRUE);
\r
3240 /* Switch off the map display */
\r
3241 td->map_active = FALSE;
\r
3243 /* Restore screen */
\r
3244 Term_xtra_win_clear();
\r
3249 /*** Other routines ***/
\r
3253 * Create and initialize a "term_data" given a title
\r
3255 static void term_data_link(term_data *td)
\r
3259 /* Initialize the term */
\r
3260 term_init(t, td->cols, td->rows, td->keys);
\r
3262 /* Use a "software" cursor */
\r
3263 t->soft_cursor = TRUE;
\r
3265 /* Use "Term_pict" for "graphic" data */
\r
3266 t->higher_pict = TRUE;
\r
3268 /* Erase with "white space" */
\r
3269 t->attr_blank = TERM_WHITE;
\r
3270 t->char_blank = ' ';
\r
3273 /* Prepare the init/nuke hooks */
\r
3274 t->init_hook = Term_init_win;
\r
3275 t->nuke_hook = Term_nuke_win;
\r
3278 /* Prepare the template hooks */
\r
3279 t->user_hook = Term_user_win;
\r
3280 t->xtra_hook = Term_xtra_win;
\r
3281 t->curs_hook = Term_curs_win;
\r
3282 t->bigcurs_hook = Term_bigcurs_win;
\r
3283 t->wipe_hook = Term_wipe_win;
\r
3284 t->text_hook = Term_text_win;
\r
3285 t->pict_hook = Term_pict_win;
\r
3287 /* Remember where we came from */
\r
3288 t->data = (vptr)(td);
\r
3293 * Create the windows
\r
3295 * First, instantiate the "default" values, then read the "ini_file"
\r
3296 * to over-ride selected values, then create the windows, and fonts.
\r
3298 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
\r
3299 * must make active to realize the palette. XXX XXX XXX
\r
3301 static void init_windows(void)
\r
3307 #if 0 /* #ifndef JP */
\r
3313 WIPE(td, term_data);
\r
3317 td->s = angband_term_name[0];
\r
3323 td->visible = TRUE;
\r
3328 td->pos_x = 7 * 30;
\r
3329 td->pos_y = 7 * 20;
\r
3330 td->posfix = FALSE;
\r
3331 #if 1 /* #ifdef JP */
\r
3332 td->bizarre = TRUE;
\r
3335 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3338 WIPE(td, term_data);
\r
3339 td->s = angband_term_name[i];
\r
3343 td->visible = FALSE;
\r
3348 td->pos_x = (7 - i) * 30;
\r
3349 td->pos_y = (7 - i) * 20;
\r
3350 td->posfix = FALSE;
\r
3351 #if 1 /* #ifdef JP */
\r
3352 td->bizarre = TRUE;
\r
3361 /* Main window (need these before term_getsize gets called) */
\r
3363 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
\r
3364 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
\r
3366 td->dwExStyle = 0;
\r
3367 td->visible = TRUE;
\r
3369 /* Sub windows (need these before term_getsize gets called) */
\r
3370 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3373 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
\r
3374 td->dwExStyle = (WS_EX_TOOLWINDOW);
\r
3379 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3383 #if 1 /* #ifdef JP */
\r
3384 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
\r
3385 td->lf.lfCharSet = DEFAULT_CHARSET;
\r
3386 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
\r
3387 /* Activate the chosen font */
\r
3388 term_force_font(td, NULL);
\r
3389 if(!td->tile_wid) td->tile_wid = td->font_wid;
\r
3390 if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
\r
3392 /* Access the standard font file */
\r
3393 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
\r
3395 /* Activate the chosen font */
\r
3396 if (term_force_font(td, buf))
\r
3398 /* Access the standard font file */
\r
3399 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
3401 /* Force the use of that font */
\r
3402 (void)term_force_font(td, buf);
\r
3406 td->tile_hgt = 13;
\r
3408 /* Assume not bizarre */
\r
3409 td->bizarre = FALSE;
\r
3414 /* Analyze the font */
\r
3417 /* Resize the window */
\r
3418 term_window_resize(td);
\r
3422 /* Sub windows (reverse order) */
\r
3423 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
\r
3428 td->w = CreateWindowEx(td->dwExStyle, AngList,
\r
3429 td->s, td->dwStyle,
\r
3430 td->pos_x, td->pos_y,
\r
3431 td->size_wid, td->size_hgt,
\r
3432 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3434 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
\r
3438 td->size_hack = TRUE;
\r
3439 ShowWindow(td->w, SW_SHOW);
\r
3440 td->size_hack = FALSE;
\r
3443 term_data_link(td);
\r
3444 angband_term[i] = &td->t;
\r
3448 /* Activate the window */
\r
3449 SetActiveWindow(td->w);
\r
3452 if (data[i].posfix)
\r
3454 term_window_pos(&data[i], HWND_TOPMOST);
\r
3458 term_window_pos(&data[i], td->w);
\r
3468 td->w = CreateWindowEx(td->dwExStyle, AppName,
\r
3469 td->s, td->dwStyle,
\r
3470 td->pos_x, td->pos_y,
\r
3471 td->size_wid, td->size_hgt,
\r
3472 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3474 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
\r
3476 term_data_link(td);
\r
3477 angband_term[0] = &td->t;
\r
3478 normsize.x = td->cols;
\r
3479 normsize.y = td->rows;
\r
3481 /* Activate the main window */
\r
3482 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
\r
3483 else ShowWindow(td->w, SW_SHOW);
\r
3485 /* Bring main window back to top */
\r
3486 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
3489 /* New palette XXX XXX XXX */
\r
3490 (void)new_palette();
\r
3493 /* Create a "brush" for drawing the "cursor" */
\r
3494 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
\r
3497 /* Process pending messages */
\r
3498 (void)Term_xtra_win_flush();
\r
3504 * Prepare the menus
\r
3506 static void setup_menus(void)
\r
3510 HMENU hm = GetMenu(data[0].w);
\r
3513 /* Menu "File", Disable all */
\r
3514 EnableMenuItem(hm, IDM_FILE_NEW,
\r
3515 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3516 EnableMenuItem(hm, IDM_FILE_OPEN,
\r
3517 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3518 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3519 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3520 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3521 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3522 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3523 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3526 /* No character available */
\r
3527 if (!character_generated)
\r
3529 /* Menu "File", Item "New" */
\r
3530 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
\r
3532 /* Menu "File", Item "Open" */
\r
3533 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
\r
3536 /* A character available */
\r
3537 if (character_generated)
\r
3539 /* Menu "File", Item "Save" */
\r
3540 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3541 MF_BYCOMMAND | MF_ENABLED);
\r
3544 /* Menu "File", Item "Exit" */
\r
3545 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3546 MF_BYCOMMAND | MF_ENABLED);
\r
3548 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3549 MF_BYCOMMAND | MF_ENABLED);
\r
3552 /* Menu "Window::Visibility" */
\r
3553 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3555 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3556 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3558 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3559 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
\r
3561 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3562 MF_BYCOMMAND | MF_ENABLED);
\r
3565 /* Menu "Window::Font" */
\r
3566 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3568 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3569 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3571 if (data[i].visible)
\r
3573 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3574 MF_BYCOMMAND | MF_ENABLED);
\r
3578 /* Menu "Window::Window Position Fix" */
\r
3579 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3581 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3582 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3584 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3585 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
\r
3587 if (data[i].visible)
\r
3589 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3590 MF_BYCOMMAND | MF_ENABLED);
\r
3594 /* Menu "Window::Bizarre Display" */
\r
3595 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3597 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3598 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3600 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3601 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
\r
3603 if (data[i].visible)
\r
3605 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3606 MF_BYCOMMAND | MF_ENABLED);
\r
3611 /* Menu "Window::Increase Tile Width" */
\r
3612 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3614 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3615 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3617 if (data[i].visible)
\r
3619 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3620 MF_BYCOMMAND | MF_ENABLED);
\r
3625 /* Menu "Window::Decrease Tile Width" */
\r
3626 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3628 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3629 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3631 if (data[i].visible)
\r
3633 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3634 MF_BYCOMMAND | MF_ENABLED);
\r
3639 /* Menu "Window::Increase Tile Height" */
\r
3640 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3642 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3643 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3645 if (data[i].visible)
\r
3647 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3648 MF_BYCOMMAND | MF_ENABLED);
\r
3653 /* Menu "Window::Decrease Tile Height" */
\r
3654 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3656 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3657 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3659 if (data[i].visible)
\r
3661 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3662 MF_BYCOMMAND | MF_ENABLED);
\r
3667 /* Menu "Options", disable all */
\r
3668 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3669 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3670 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3671 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3672 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3673 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3674 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3675 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3676 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3677 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3679 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3680 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3683 /* Menu "Options", Item "Map" */
\r
3684 if (use_graphics != GRAPHICS_NONE)
\r
3685 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
\r
3687 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
\r
3688 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3690 /* Menu "Options", update all */
\r
3691 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3692 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
\r
3693 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3694 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
\r
3695 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3696 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
\r
3697 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
\r
3698 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
\r
3699 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3700 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
\r
3701 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
\r
3702 (arg_music ? MF_CHECKED : MF_UNCHECKED));
\r
3703 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3704 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
\r
3705 CheckMenuItem(hm, IDM_OPTIONS_BG,
\r
3706 (use_bg ? MF_CHECKED : MF_UNCHECKED));
\r
3708 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3709 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
\r
3712 #ifdef USE_GRAPHICS
\r
3713 /* Menu "Options", Item "Graphics" */
\r
3714 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
\r
3715 /* Menu "Options", Item "Graphics" */
\r
3716 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
\r
3717 /* Menu "Options", Item "Graphics" */
\r
3718 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
\r
3719 /* Menu "Options", Item "Graphics" */
\r
3720 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
\r
3721 #endif /* USE_GRAPHICS */
\r
3724 /* Menu "Options", Item "Sound" */
\r
3725 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
\r
3726 #endif /* USE_SOUND */
\r
3729 /* Menu "Options", Item "ScreenSaver" */
\r
3730 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3731 MF_BYCOMMAND | MF_ENABLED);
\r
3732 #endif /* USE_SAVER */
\r
3737 * Check for double clicked (or dragged) savefile
\r
3739 * Apparently, Windows copies the entire filename into the first
\r
3740 * piece of the "command line string". Perhaps we should extract
\r
3741 * the "basename" of that filename and append it to the "save" dir.
\r
3743 static void check_for_save_file(LPSTR cmd_line)
\r
3753 /* Extract filename */
\r
3754 strcat(savefile, s);
\r
3756 /* Validate the file */
\r
3757 validate_file(savefile);
\r
3759 /* Game in progress */
\r
3760 game_in_progress = TRUE;
\r
3768 * Process a menu command
\r
3770 static void process_menus(WORD wCmd)
\r
3782 case IDM_FILE_NEW:
\r
3786 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3788 else if (game_in_progress)
\r
3790 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
\r
3794 game_in_progress = TRUE;
\r
3803 case IDM_FILE_OPEN:
\r
3807 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3809 else if (game_in_progress)
\r
3811 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
\r
3815 memset(&ofn, 0, sizeof(ofn));
\r
3816 ofn.lStructSize = sizeof(ofn);
\r
3817 ofn.hwndOwner = data[0].w;
\r
3818 ofn.lpstrFilter = "Save Files (*.)\0*\0";
\r
3819 ofn.nFilterIndex = 1;
\r
3820 ofn.lpstrFile = savefile;
\r
3821 ofn.nMaxFile = 1024;
\r
3822 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
\r
3823 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
\r
3825 if (GetOpenFileName(&ofn))
\r
3827 /* Load 'savefile' */
\r
3828 validate_file(savefile);
\r
3829 game_in_progress = TRUE;
\r
3839 case IDM_FILE_SAVE:
\r
3841 if (game_in_progress && character_generated)
\r
3846 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
\r
3850 /* Hack -- Forget messages */
\r
3853 /* Save the game */
\r
3855 do_cmd_save_game(FALSE);
\r
3856 #else /* ZANGBAND */
\r
3857 do_cmd_save_game();
\r
3858 #endif /* ZANGBAND */
\r
3862 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
\r
3868 case IDM_FILE_EXIT:
\r
3870 if (game_in_progress && character_generated)
\r
3875 plog(_("今は終了できません。", "You may not do that right now."));
\r
3879 /* Hack -- Forget messages */
\r
3886 /* Save the game */
\r
3888 /* do_cmd_save_game(FALSE); */
\r
3889 #else /* ZANGBAND */
\r
3890 /* do_cmd_save_game(); */
\r
3891 #endif /* ZANGBAND */
\r
3892 Term_key_push(SPECIAL_KEY_QUIT);
\r
3900 case IDM_FILE_SCORE:
\r
3904 /* Build the filename */
\r
3905 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
\r
3907 /* Open the binary high score file, for reading */
\r
3908 highscore_fd = fd_open(buf, O_RDONLY);
\r
3910 /* Paranoia -- No score file */
\r
3911 if (highscore_fd < 0)
\r
3913 msg_print("Score file unavailable.");
\r
3920 /* Clear screen */
\r
3923 /* Display the scores */
\r
3924 display_scores_aux(0, MAX_HISCORES, -1, NULL);
\r
3926 /* Shut the high score file */
\r
3927 (void)fd_close(highscore_fd);
\r
3929 /* Forget the high score fd */
\r
3930 highscore_fd = -1;
\r
3935 /* Hack - Flush it */
\r
3943 case IDM_FILE_MOVIE:
\r
3947 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3949 else if (game_in_progress)
\r
3951 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
\r
3955 memset(&ofn, 0, sizeof(ofn));
\r
3956 ofn.lStructSize = sizeof(ofn);
\r
3957 ofn.hwndOwner = data[0].w;
\r
3958 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
\r
3959 ofn.nFilterIndex = 1;
\r
3960 ofn.lpstrFile = savefile;
\r
3961 ofn.nMaxFile = 1024;
\r
3962 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
\r
3963 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
3965 if (GetOpenFileName(&ofn))
\r
3967 /* Load 'savefile' */
\r
3968 prepare_browse_movie_aux(savefile);
\r
3978 case IDM_WINDOW_VIS_0:
\r
3980 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
\r
3984 /* Window visibility */
\r
3985 case IDM_WINDOW_VIS_1:
\r
3986 case IDM_WINDOW_VIS_2:
\r
3987 case IDM_WINDOW_VIS_3:
\r
3988 case IDM_WINDOW_VIS_4:
\r
3989 case IDM_WINDOW_VIS_5:
\r
3990 case IDM_WINDOW_VIS_6:
\r
3991 case IDM_WINDOW_VIS_7:
\r
3993 i = wCmd - IDM_WINDOW_VIS_0;
\r
3995 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4001 td->visible = TRUE;
\r
4002 ShowWindow(td->w, SW_SHOW);
\r
4003 term_data_redraw(td);
\r
4007 td->visible = FALSE;
\r
4008 td->posfix = FALSE;
\r
4009 ShowWindow(td->w, SW_HIDE);
\r
4015 /* Window fonts */
\r
4016 case IDM_WINDOW_FONT_0:
\r
4017 case IDM_WINDOW_FONT_1:
\r
4018 case IDM_WINDOW_FONT_2:
\r
4019 case IDM_WINDOW_FONT_3:
\r
4020 case IDM_WINDOW_FONT_4:
\r
4021 case IDM_WINDOW_FONT_5:
\r
4022 case IDM_WINDOW_FONT_6:
\r
4023 case IDM_WINDOW_FONT_7:
\r
4025 i = wCmd - IDM_WINDOW_FONT_0;
\r
4027 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4031 term_change_font(td);
\r
4036 /* Window Z Position */
\r
4037 case IDM_WINDOW_POS_1:
\r
4038 case IDM_WINDOW_POS_2:
\r
4039 case IDM_WINDOW_POS_3:
\r
4040 case IDM_WINDOW_POS_4:
\r
4041 case IDM_WINDOW_POS_5:
\r
4042 case IDM_WINDOW_POS_6:
\r
4043 case IDM_WINDOW_POS_7:
\r
4045 i = wCmd - IDM_WINDOW_POS_0;
\r
4047 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4051 if (!td->posfix && td->visible)
\r
4053 td->posfix = TRUE;
\r
4054 term_window_pos(td, HWND_TOPMOST);
\r
4058 td->posfix = FALSE;
\r
4059 term_window_pos(td, data[0].w);
\r
4065 /* Bizarre Display */
\r
4066 case IDM_WINDOW_BIZ_0:
\r
4067 case IDM_WINDOW_BIZ_1:
\r
4068 case IDM_WINDOW_BIZ_2:
\r
4069 case IDM_WINDOW_BIZ_3:
\r
4070 case IDM_WINDOW_BIZ_4:
\r
4071 case IDM_WINDOW_BIZ_5:
\r
4072 case IDM_WINDOW_BIZ_6:
\r
4073 case IDM_WINDOW_BIZ_7:
\r
4075 i = wCmd - IDM_WINDOW_BIZ_0;
\r
4077 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4081 td->bizarre = !td->bizarre;
\r
4085 term_window_resize(td);
\r
4090 /* Increase Tile Width */
\r
4091 case IDM_WINDOW_I_WID_0:
\r
4092 case IDM_WINDOW_I_WID_1:
\r
4093 case IDM_WINDOW_I_WID_2:
\r
4094 case IDM_WINDOW_I_WID_3:
\r
4095 case IDM_WINDOW_I_WID_4:
\r
4096 case IDM_WINDOW_I_WID_5:
\r
4097 case IDM_WINDOW_I_WID_6:
\r
4098 case IDM_WINDOW_I_WID_7:
\r
4100 i = wCmd - IDM_WINDOW_I_WID_0;
\r
4102 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4106 td->tile_wid += 1;
\r
4110 term_window_resize(td);
\r
4115 /* Decrease Tile Height */
\r
4116 case IDM_WINDOW_D_WID_0:
\r
4117 case IDM_WINDOW_D_WID_1:
\r
4118 case IDM_WINDOW_D_WID_2:
\r
4119 case IDM_WINDOW_D_WID_3:
\r
4120 case IDM_WINDOW_D_WID_4:
\r
4121 case IDM_WINDOW_D_WID_5:
\r
4122 case IDM_WINDOW_D_WID_6:
\r
4123 case IDM_WINDOW_D_WID_7:
\r
4125 i = wCmd - IDM_WINDOW_D_WID_0;
\r
4127 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4131 td->tile_wid -= 1;
\r
4135 term_window_resize(td);
\r
4140 /* Increase Tile Height */
\r
4141 case IDM_WINDOW_I_HGT_0:
\r
4142 case IDM_WINDOW_I_HGT_1:
\r
4143 case IDM_WINDOW_I_HGT_2:
\r
4144 case IDM_WINDOW_I_HGT_3:
\r
4145 case IDM_WINDOW_I_HGT_4:
\r
4146 case IDM_WINDOW_I_HGT_5:
\r
4147 case IDM_WINDOW_I_HGT_6:
\r
4148 case IDM_WINDOW_I_HGT_7:
\r
4150 i = wCmd - IDM_WINDOW_I_HGT_0;
\r
4152 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4156 td->tile_hgt += 1;
\r
4160 term_window_resize(td);
\r
4165 /* Decrease Tile Height */
\r
4166 case IDM_WINDOW_D_HGT_0:
\r
4167 case IDM_WINDOW_D_HGT_1:
\r
4168 case IDM_WINDOW_D_HGT_2:
\r
4169 case IDM_WINDOW_D_HGT_3:
\r
4170 case IDM_WINDOW_D_HGT_4:
\r
4171 case IDM_WINDOW_D_HGT_5:
\r
4172 case IDM_WINDOW_D_HGT_6:
\r
4173 case IDM_WINDOW_D_HGT_7:
\r
4175 i = wCmd - IDM_WINDOW_D_HGT_0;
\r
4177 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4181 td->tile_hgt -= 1;
\r
4185 term_window_resize(td);
\r
4190 case IDM_OPTIONS_NO_GRAPHICS:
\r
4195 plog("You may not do that right now.");
\r
4199 /* Toggle "arg_graphics" */
\r
4200 if (arg_graphics != GRAPHICS_NONE)
\r
4202 arg_graphics = GRAPHICS_NONE;
\r
4204 /* React to changes */
\r
4205 Term_xtra_win_react();
\r
4207 /* Hack -- Force redraw */
\r
4208 Term_key_push(KTRL('R'));
\r
4214 case IDM_OPTIONS_OLD_GRAPHICS:
\r
4219 plog("You may not do that right now.");
\r
4223 /* Toggle "arg_graphics" */
\r
4224 if (arg_graphics != GRAPHICS_ORIGINAL)
\r
4226 arg_graphics = GRAPHICS_ORIGINAL;
\r
4228 /* React to changes */
\r
4229 Term_xtra_win_react();
\r
4231 /* Hack -- Force redraw */
\r
4232 Term_key_push(KTRL('R'));
\r
4238 case IDM_OPTIONS_NEW_GRAPHICS:
\r
4243 plog("You may not do that right now.");
\r
4247 /* Toggle "arg_graphics" */
\r
4248 if (arg_graphics != GRAPHICS_ADAM_BOLT)
\r
4250 arg_graphics = GRAPHICS_ADAM_BOLT;
\r
4252 /* React to changes */
\r
4253 Term_xtra_win_react();
\r
4255 /* Hack -- Force redraw */
\r
4256 Term_key_push(KTRL('R'));
\r
4262 case IDM_OPTIONS_NEW2_GRAPHICS:
\r
4267 plog("You may not do that right now.");
\r
4271 /* Toggle "arg_graphics" */
\r
4272 if (arg_graphics != GRAPHICS_HENGBAND)
\r
4274 arg_graphics = GRAPHICS_HENGBAND;
\r
4276 /* React to changes */
\r
4277 Term_xtra_win_react();
\r
4279 /* Hack -- Force redraw */
\r
4280 Term_key_push(KTRL('R'));
\r
4286 case IDM_OPTIONS_BIGTILE:
\r
4293 plog("You may not do that right now.");
\r
4297 /* Toggle "arg_sound" */
\r
4298 arg_bigtile = !arg_bigtile;
\r
4301 Term_activate(&td->t);
\r
4303 /* Resize the term */
\r
4304 Term_resize(td->cols, td->rows);
\r
4306 /* Redraw later */
\r
4307 InvalidateRect(td->w, NULL, TRUE);
\r
4312 case IDM_OPTIONS_MUSIC:
\r
4317 plog("You may not do that right now.");
\r
4321 /* Toggle "arg_sound" */
\r
4322 arg_music = !arg_music;
\r
4324 /* React to changes */
\r
4325 Term_xtra_win_react();
\r
4327 /* Hack -- Force redraw */
\r
4328 Term_key_push(KTRL('R'));
\r
4333 case IDM_OPTIONS_SOUND:
\r
4338 plog("You may not do that right now.");
\r
4342 /* Toggle "arg_sound" */
\r
4343 arg_sound = !arg_sound;
\r
4345 /* React to changes */
\r
4346 Term_xtra_win_react();
\r
4348 /* Hack -- Force redraw */
\r
4349 Term_key_push(KTRL('R'));
\r
4355 case IDM_OPTIONS_BG:
\r
4360 plog("You may not do that right now.");
\r
4364 /* Toggle "use_bg" */
\r
4369 /* React to changes */
\r
4370 Term_xtra_win_react();
\r
4372 /* Hack -- Force redraw */
\r
4373 Term_key_push(KTRL('R'));
\r
4379 case IDM_OPTIONS_OPEN_BG:
\r
4384 plog("You may not do that right now.");
\r
4389 memset(&ofn, 0, sizeof(ofn));
\r
4390 ofn.lStructSize = sizeof(ofn);
\r
4391 ofn.hwndOwner = data[0].w;
\r
4392 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
\r
4393 ofn.nFilterIndex = 1;
\r
4394 ofn.lpstrFile = bg_bitmap_file;
\r
4395 ofn.nMaxFile = 1023;
\r
4396 ofn.lpstrInitialDir = NULL;
\r
4397 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
\r
4398 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
\r
4400 if (GetOpenFileName(&ofn))
\r
4402 /* Load 'savefile' */
\r
4407 /* React to changes */
\r
4408 Term_xtra_win_react();
\r
4410 /* Hack -- Force redraw */
\r
4411 Term_key_push(KTRL('R'));
\r
4416 case IDM_DUMP_SCREEN_HTML:
\r
4418 static char buf[1024] = "";
\r
4419 memset(&ofn, 0, sizeof(ofn));
\r
4420 ofn.lStructSize = sizeof(ofn);
\r
4421 ofn.hwndOwner = data[0].w;
\r
4422 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
\r
4423 ofn.nFilterIndex = 1;
\r
4424 ofn.lpstrFile = buf;
\r
4425 ofn.nMaxFile = 1023;
\r
4426 ofn.lpstrDefExt = "html";
\r
4427 ofn.lpstrInitialDir = NULL;
\r
4428 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
\r
4429 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
\r
4431 if (GetSaveFileName(&ofn))
\r
4433 do_cmd_save_screen_html_aux(buf, 0);
\r
4440 case IDM_OPTIONS_SAVER:
\r
4444 DestroyWindow(hwndSaver);
\r
4449 /* Create a screen scaver window */
\r
4450 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
\r
4451 "Angband Screensaver",
\r
4452 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
\r
4453 0, 0, GetSystemMetrics(SM_CXSCREEN),
\r
4454 GetSystemMetrics(SM_CYSCREEN),
\r
4455 NULL, NULL, hInstance, NULL);
\r
4459 /* Push the window to the bottom XXX XXX XXX */
\r
4460 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
4464 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
\r
4472 case IDM_OPTIONS_MAP:
\r
4478 case IDM_HELP_CONTENTS:
\r
4482 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
\r
4483 if (check_file(tmp))
\r
4485 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
\r
4490 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4491 plog("代わりにオンラインヘルプを使用してください。");
\r
4493 plog_fmt("Cannot find help file: %s", tmp);
\r
4494 plog("Use the online help files instead.");
\r
4499 #else /* HTML_HELP */
\r
4502 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
\r
4503 if (check_file(tmp))
\r
4505 sprintf(buf, "winhelp.exe %s", tmp);
\r
4506 WinExec(buf, SW_NORMAL);
\r
4511 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4512 plog("代わりにオンラインヘルプを使用してください。");
\r
4514 plog_fmt("Cannot find help file: %s", tmp);
\r
4515 plog("Use the online help files instead.");
\r
4520 #endif /* HTML_HELP */
\r
4526 static bool process_keydown(WPARAM wParam, LPARAM lParam)
\r
4533 /* Extract the modifiers */
\r
4534 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
\r
4535 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
\r
4536 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
\r
4538 Term_no_press = (ma) ? TRUE : FALSE;
\r
4540 /* Handle "special" keys */
\r
4541 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
\r
4543 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
\r
4544 bool numpad = FALSE;
\r
4546 /* Begin the macro trigger */
\r
4547 Term_keypress(31);
\r
4549 /* Send the modifiers */
\r
4550 if (mc) Term_keypress('C');
\r
4551 if (ms) Term_keypress('S');
\r
4552 if (ma) Term_keypress('A');
\r
4554 /* Extract "scan code" */
\r
4555 i = LOBYTE(HIWORD(lParam));
\r
4557 /* Introduce the scan code */
\r
4558 Term_keypress('x');
\r
4560 /* Extended key bit */
\r
4563 /* Numpad Enter and '/' are extended key */
\r
4565 Term_no_press = TRUE;
\r
4566 case VK_RETURN: /* Enter */
\r
4569 /* Other extended keys are on full keyboard */
\r
4583 case VK_SEPARATOR:
\r
4585 Term_no_press = TRUE;
\r
4589 case VK_PRIOR: /* Page Up */
\r
4590 case VK_NEXT: /* Page Down */
\r
4597 numpad = !ext_key;
\r
4600 /* Special modifiers for keypad keys */
\r
4601 if (numpad) Term_keypress('K');
\r
4603 /* Encode the hexidecimal scan code */
\r
4604 Term_keypress(hexsym[i/16]);
\r
4605 Term_keypress(hexsym[i%16]);
\r
4607 /* End the macro trigger */
\r
4608 Term_keypress(13);
\r
4618 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4619 WPARAM wParam, LPARAM lParam);
\r
4620 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4621 WPARAM wParam, LPARAM lParam)
\r
4622 #else /* __MWERKS__ */
\r
4623 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4624 WPARAM wParam, LPARAM lParam)
\r
4625 #endif /* __MWERKS__ */
\r
4631 MINMAXINFO FAR *lpmmi;
\r
4637 /* Acquire proper "term_data" info */
\r
4638 td = (term_data *)GetWindowLong(hWnd, 0);
\r
4640 /* Handle message */
\r
4645 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
4652 mop.dwCallback=(DWORD)hWnd;
\r
4657 case WM_GETMINMAXINFO:
\r
4659 MINMAXINFO FAR *lpmmi;
\r
4662 lpmmi = (MINMAXINFO FAR *)lParam;
\r
4664 /* this message was sent before WM_NCCREATE */
\r
4665 if (!td) return 1;
\r
4667 /* Minimum window size is 80x24 */
\r
4668 rc.left = rc.top = 0;
\r
4669 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
4670 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
4673 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
4675 /* Save minimum size */
\r
4676 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
4677 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
4684 BeginPaint(hWnd, &ps);
\r
4685 if (td) term_data_redraw(td);
\r
4686 EndPaint(hWnd, &ps);
\r
4687 ValidateRect(hWnd, NULL);
\r
4692 case MM_MCINOTIFY:
\r
4694 if(wParam == MCI_NOTIFY_SUCCESSFUL)
\r
4696 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
4697 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
4703 case WM_SYSKEYDOWN:
\r
4706 if (process_keydown(wParam, lParam))
\r
4713 if (Term_no_press) Term_no_press = FALSE;
\r
4714 else Term_keypress(wParam);
\r
4718 case WM_LBUTTONDOWN:
\r
4720 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4721 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4722 mouse_down = TRUE;
\r
4728 case WM_LBUTTONUP:
\r
4733 TERM_LEN dx = abs(oldx - mousex) + 1;
\r
4734 TERM_LEN dy = abs(oldy - mousey) + 1;
\r
4735 TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
\r
4736 TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
\r
4738 mouse_down = FALSE;
\r
4739 paint_rect = FALSE;
\r
4742 sz = (dx + 3) * dy;
\r
4744 sz = (dx + 2) * dy;
\r
4746 hGlobal = GlobalAlloc(GHND, sz + 1);
\r
4747 if (hGlobal == NULL) return 0;
\r
4748 lpStr = (LPSTR)GlobalLock(hGlobal);
\r
4750 for (i = 0; i < dy; i++)
\r
4754 char **scr = data[0].t.scr->c;
\r
4756 C_MAKE(s, (dx + 1), char);
\r
4757 strncpy(s, &scr[oy + i][ox], dx);
\r
4761 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
\r
4764 if (ox + dx < data[0].cols)
\r
4766 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
\r
4769 for (j = 0; j < dx; j++)
\r
4771 if (s[j] == 127) s[j] = '#';
\r
4775 for (j = 0; j < dx; j++)
\r
4777 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
\r
4787 GlobalUnlock(hGlobal);
\r
4788 if (OpenClipboard(hWnd) == 0)
\r
4790 GlobalFree(hGlobal);
\r
4794 SetClipboardData(CF_TEXT, hGlobal);
\r
4802 case WM_MOUSEMOVE:
\r
4807 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4808 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4813 dx = abs(oldx - mousex) + 1;
\r
4814 dy = abs(oldy - mousey) + 1;
\r
4815 ox = (oldx > mousex) ? mousex : oldx;
\r
4816 oy = (oldy > mousey) ? mousey : oldy;
\r
4817 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4821 paint_rect = TRUE;
\r
4824 dx = abs(cx - mousex) + 1;
\r
4825 dy = abs(cy - mousey) + 1;
\r
4826 ox = (cx > mousex) ? mousex : cx;
\r
4827 oy = (cy > mousey) ? mousey : cy;
\r
4828 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4844 if (game_in_progress && character_generated)
\r
4848 plog(_("今は終了できません。", "You may not do that right now."));
\r
4852 /* Hack -- Forget messages */
\r
4859 /* Save the game */
\r
4861 /* do_cmd_save_game(FALSE); */
\r
4862 #else /* ZANGBAND */
\r
4863 /* do_cmd_save_game(); */
\r
4864 #endif /* ZANGBAND */
\r
4865 Term_key_push(SPECIAL_KEY_QUIT);
\r
4872 case WM_QUERYENDSESSION:
\r
4874 if (game_in_progress && character_generated)
\r
4876 /* Hack -- Forget messages */
\r
4879 /* Mega-Hack -- Delay death */
\r
4880 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
\r
4881 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
\r
4883 /* Hardcode panic save */
\r
4884 p_ptr->panic_save = 1;
\r
4886 /* Forbid suspend */
\r
4887 signals_ignore_tstp();
\r
4889 /* Indicate panic save */
\r
4890 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
\r
4893 (void)save_player();
\r
4907 process_menus(LOWORD(wParam));
\r
4913 /* this message was sent before WM_NCCREATE */
\r
4914 if (!td) return 1;
\r
4916 /* it was sent from inside CreateWindowEx */
\r
4917 if (!td->w) return 1;
\r
4919 /* was sent from WM_SIZE */
\r
4920 if (td->size_hack) return 1;
\r
4924 case SIZE_MINIMIZED:
\r
4926 /* Hide sub-windows */
\r
4927 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4929 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
\r
4934 case SIZE_MAXIMIZED:
\r
4936 /* fall through XXX XXX XXX */
\r
4939 case SIZE_RESTORED:
\r
4941 TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
4942 TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
4945 if ((td->cols != cols) || (td->rows != rows))
\r
4947 /* Save the new size */
\r
4951 if (!IsZoomed(td->w) && !IsIconic(td->w))
\r
4953 normsize.x = td->cols;
\r
4954 normsize.y = td->rows;
\r
4958 Term_activate(&td->t);
\r
4960 /* Resize the term */
\r
4961 Term_resize(td->cols, td->rows);
\r
4963 /* Redraw later */
\r
4964 InvalidateRect(td->w, NULL, TRUE);
\r
4967 td->size_hack = TRUE;
\r
4969 /* Show sub-windows */
\r
4970 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4972 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
\r
4975 td->size_hack = FALSE;
\r
4983 case WM_PALETTECHANGED:
\r
4985 /* Ignore if palette change caused by itself */
\r
4986 if ((HWND)wParam == hWnd) return 0;
\r
4988 /* Fall through... */
\r
4991 case WM_QUERYNEWPALETTE:
\r
4993 if (!paletted) return 0;
\r
4995 hdc = GetDC(hWnd);
\r
4997 SelectPalette(hdc, hPal, FALSE);
\r
4999 i = RealizePalette(hdc);
\r
5001 /* if any palette entries changed, repaint the window. */
\r
5002 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5004 ReleaseDC(hWnd, hdc);
\r
5011 if (wParam && !HIWORD(lParam))
\r
5013 /* Do something to sub-windows */
\r
5014 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5016 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
\r
5019 /* Focus on main window */
\r
5028 case WM_ACTIVATEAPP:
\r
5030 if (IsIconic(td->w)) break;
\r
5032 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5034 if(data[i].visible)
\r
5036 if (wParam == TRUE)
\r
5038 ShowWindow(data[i].w, SW_SHOW);
\r
5042 ShowWindow(data[i].w, SW_HIDE);
\r
5049 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5054 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5055 WPARAM wParam, LPARAM lParam);
\r
5056 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5057 WPARAM wParam, LPARAM lParam)
\r
5058 #else /* __MWERKS__ */
\r
5059 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5060 WPARAM wParam, LPARAM lParam)
\r
5061 #endif /* __MWERKS__ */
\r
5065 MINMAXINFO FAR *lpmmi;
\r
5073 /* Acquire proper "term_data" info */
\r
5074 td = (term_data *)GetWindowLong(hWnd, 0);
\r
5076 /* Process message */
\r
5081 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
5090 case WM_GETMINMAXINFO:
\r
5092 MINMAXINFO FAR *lpmmi;
\r
5095 lpmmi = (MINMAXINFO FAR *)lParam;
\r
5097 /* this message was sent before WM_NCCREATE */
\r
5098 if (!td) return 1;
\r
5100 /* Minimum window size is 80x24 */
\r
5101 rc.left = rc.top = 0;
\r
5102 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
5103 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
5106 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
5108 /* Save minimum size */
\r
5109 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
5110 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
5120 /* this message was sent before WM_NCCREATE */
\r
5121 if (!td) return 1;
\r
5123 /* it was sent from inside CreateWindowEx */
\r
5124 if (!td->w) return 1;
\r
5126 /* was sent from inside WM_SIZE */
\r
5127 if (td->size_hack) return 1;
\r
5129 td->size_hack = TRUE;
\r
5131 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
5132 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
5135 if ((td->cols != cols) || (td->rows != rows))
\r
5137 /* Save old term */
\r
5138 term *old_term = Term;
\r
5140 /* Save the new size */
\r
5145 Term_activate(&td->t);
\r
5147 /* Resize the term */
\r
5148 Term_resize(td->cols, td->rows);
\r
5151 Term_activate(old_term);
\r
5153 /* Redraw later */
\r
5154 InvalidateRect(td->w, NULL, TRUE);
\r
5156 /* HACK - Redraw all windows */
\r
5157 p_ptr->window = 0xFFFFFFFF;
\r
5161 td->size_hack = FALSE;
\r
5168 BeginPaint(hWnd, &ps);
\r
5169 if (td) term_data_redraw(td);
\r
5170 EndPaint(hWnd, &ps);
\r
5174 case WM_SYSKEYDOWN:
\r
5177 if (process_keydown(wParam, lParam))
\r
5184 if (Term_no_press) Term_no_press = FALSE;
\r
5185 else Term_keypress(wParam);
\r
5189 case WM_PALETTECHANGED:
\r
5191 /* ignore if palette change caused by itself */
\r
5192 if ((HWND)wParam == hWnd) return FALSE;
\r
5193 /* otherwise, fall through!!! */
\r
5196 case WM_QUERYNEWPALETTE:
\r
5198 if (!paletted) return 0;
\r
5199 hdc = GetDC(hWnd);
\r
5200 SelectPalette(hdc, hPal, FALSE);
\r
5201 i = RealizePalette(hdc);
\r
5202 /* if any palette entries changed, repaint the window. */
\r
5203 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5204 ReleaseDC(hWnd, hdc);
\r
5208 case WM_NCLBUTTONDOWN:
\r
5212 if (wParam == HTCLOSE) wParam = HTSYSMENU;
\r
5213 #endif /* HTCLOSE */
\r
5215 if (wParam == HTSYSMENU)
\r
5219 td->visible = FALSE;
\r
5220 ShowWindow(td->w, SW_HIDE);
\r
5230 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5236 #define MOUSE_SENS 40
\r
5239 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5240 WPARAM wParam, LPARAM lParam);
\r
5241 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5242 WPARAM wParam, LPARAM lParam)
\r
5243 #else /* __MWERKS__ */
\r
5244 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5245 WPARAM wParam, LPARAM lParam)
\r
5246 #endif /* __MWERKS__ */
\r
5248 static int iMouse = 0;
\r
5249 static WORD xMouse = 0;
\r
5250 static WORD yMouse = 0;
\r
5263 case WM_SETCURSOR:
\r
5272 if (LOWORD(wParam) == WA_INACTIVE) break;
\r
5274 /* else fall through */
\r
5278 case WM_LBUTTONDOWN:
\r
5279 case WM_MBUTTONDOWN:
\r
5280 case WM_RBUTTONDOWN:
\r
5283 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5287 case WM_MOUSEMOVE:
\r
5291 dx = LOWORD(lParam) - xMouse;
\r
5292 dy = HIWORD(lParam) - yMouse;
\r
5294 if (dx < 0) dx = -dx;
\r
5295 if (dy < 0) dy = -dy;
\r
5297 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
\r
5299 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5303 /* Save last location */
\r
5305 xMouse = LOWORD(lParam);
\r
5306 yMouse = HIWORD(lParam);
\r
5313 DestroyWindow(hwndSaver);
\r
5320 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5323 #endif /* USE_SAVER */
\r
5329 /*** Temporary Hooks ***/
\r
5333 * Display warning message (see "z-util.c")
\r
5335 static void hack_plog(cptr str)
\r
5337 /* Give a warning */
\r
5341 MessageBox(NULL, str, "警告!",
\r
5342 MB_ICONEXCLAMATION | MB_OK);
\r
5344 MessageBox(NULL, str, "Warning",
\r
5345 MB_ICONEXCLAMATION | MB_OK);
\r
5353 * Display error message and quit (see "z-util.c")
\r
5355 static void hack_quit(cptr str)
\r
5357 /* Give a warning */
\r
5361 MessageBox(NULL, str, "エラー!",
\r
5362 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5364 MessageBox(NULL, str, "Error",
\r
5365 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5370 /* Unregister the classes */
\r
5371 UnregisterClass(AppName, hInstance);
\r
5373 /* Destroy the icon */
\r
5374 if (hIcon) DestroyIcon(hIcon);
\r
5382 /*** Various hooks ***/
\r
5386 * Display warning message (see "z-util.c")
\r
5388 static void hook_plog(cptr str)
\r
5394 MessageBox(data[0].w, str, "警告!",
\r
5395 MB_ICONEXCLAMATION | MB_OK);
\r
5397 MessageBox(data[0].w, str, "Warning",
\r
5398 MB_ICONEXCLAMATION | MB_OK);
\r
5406 * Display error message and quit (see "z-util.c")
\r
5408 static void hook_quit(cptr str)
\r
5413 /* Give a warning */
\r
5417 MessageBox(data[0].w, str, "エラー!",
\r
5418 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5420 MessageBox(data[0].w, str, "Error",
\r
5421 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5427 /* Save the preferences */
\r
5431 /*** Could use 'Term_nuke_win()' XXX XXX XXX */
\r
5433 /* Destroy all windows */
\r
5434 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
\r
5436 term_force_font(&data[i], NULL);
\r
5437 if (data[i].font_want) string_free(data[i].font_want);
\r
5438 if (data[i].w) DestroyWindow(data[i].w);
\r
5442 /* Free the bitmap stuff */
\r
5443 #ifdef USE_GRAPHICS
\r
5444 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
\r
5445 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
\r
5447 if (infMask.hPalette) DeleteObject(infMask.hPalette);
\r
5448 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
\r
5450 #endif /* USE_GRAPHICS */
\r
5452 /*** Free some other stuff ***/
\r
5454 DeleteObject(hbrYellow);
\r
5459 if (hPal) DeleteObject(hPal);
\r
5461 UnregisterClass(AppName, hInstance);
\r
5463 if (hIcon) DestroyIcon(hIcon);
\r
5470 /*** Initialize ***/
\r
5476 static void init_stuff(void)
\r
5483 /* Get program name with full path */
\r
5484 GetModuleFileName(hInstance, path, 512);
\r
5486 /* Save the "program name" XXX XXX XXX */
\r
5489 /* Get the name of the "*.ini" file */
\r
5490 strcpy(path + strlen(path) - 4, ".INI");
\r
5492 /* Save the the name of the ini-file */
\r
5493 ini_file = string_make(path);
\r
5495 /* Analyze the path */
\r
5498 /* Get the path */
\r
5499 for (; i > 0; i--)
\r
5501 if (path[i] == '\\')
\r
5508 /* Add "lib" to the path */
\r
5509 strcpy(path + i + 1, "lib\\");
\r
5511 /* Validate the path */
\r
5512 validate_dir(path, TRUE);
\r
5514 /* Init the file paths */
\r
5515 init_file_paths(path);
\r
5517 /* Hack -- Validate the paths */
\r
5518 validate_dir(ANGBAND_DIR_APEX, FALSE);
\r
5519 validate_dir(ANGBAND_DIR_BONE, FALSE);
\r
5521 /* Allow missing 'edit' directory */
\r
5522 if (!check_dir(ANGBAND_DIR_EDIT))
\r
5524 /* Must have 'data'! */
\r
5525 validate_dir(ANGBAND_DIR_DATA, TRUE);
\r
5529 /* Don't need 'data' */
\r
5530 validate_dir(ANGBAND_DIR_DATA, FALSE);
\r
5533 validate_dir(ANGBAND_DIR_FILE, TRUE);
\r
5534 validate_dir(ANGBAND_DIR_HELP, FALSE);
\r
5535 validate_dir(ANGBAND_DIR_INFO, FALSE);
\r
5536 validate_dir(ANGBAND_DIR_PREF, TRUE);
\r
5537 validate_dir(ANGBAND_DIR_SAVE, FALSE);
\r
5538 validate_dir(ANGBAND_DIR_USER, TRUE);
\r
5539 validate_dir(ANGBAND_DIR_XTRA, TRUE);
\r
5541 /* Build the filename */
\r
5542 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
\r
5544 /* Hack -- Validate the "news.txt" file */
\r
5545 validate_file(path);
\r
5548 #if 0 /* #ifndef JP */
\r
5549 /* Build the "font" path */
\r
5550 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
\r
5552 /* Allocate the path */
\r
5553 ANGBAND_DIR_XTRA_FONT = string_make(path);
\r
5555 /* Validate the "font" directory */
\r
5556 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
\r
5558 /* Build the filename */
\r
5559 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
5561 /* Hack -- Validate the basic font */
\r
5562 validate_file(path);
\r
5566 #ifdef USE_GRAPHICS
\r
5568 /* Build the "graf" path */
\r
5569 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
\r
5571 /* Allocate the path */
\r
5572 ANGBAND_DIR_XTRA_GRAF = string_make(path);
\r
5574 /* Validate the "graf" directory */
\r
5575 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
\r
5577 #endif /* USE_GRAPHICS */
\r
5582 /* Build the "sound" path */
\r
5583 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
\r
5585 /* Allocate the path */
\r
5586 ANGBAND_DIR_XTRA_SOUND = string_make(path);
\r
5588 /* Validate the "sound" directory */
\r
5589 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
\r
5591 #endif /* USE_SOUND */
\r
5595 /* Build the "music" path */
\r
5596 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
\r
5598 /* Allocate the path */
\r
5599 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
\r
5601 /* Validate the "music" directory */
\r
5602 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
\r
5604 #endif /* USE_MUSIC */
\r
5606 /* Build the "help" path */
\r
5607 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
\r
5609 /* Allocate the path */
\r
5610 ANGBAND_DIR_XTRA_HELP = string_make(path);
\r
5612 /* Validate the "help" directory */
\r
5613 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
\r
5617 * @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
\r
5619 static bool is_already_running(void)
\r
5621 bool result = FALSE;
\r
5624 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
\r
5625 if (GetLastError() == ERROR_ALREADY_EXISTS)
\r
5634 * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
\r
5636 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
\r
5637 LPSTR lpCmdLine, int nCmdShow)
\r
5645 setlocale( LC_ALL, "ja_JP" );
\r
5650 /* Save globally */
\r
5651 hInstance = hInst;
\r
5654 /* Prevent multiple run */
\r
5655 if (is_already_running())
\r
5658 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
\r
5659 _("エラー!", "Error") ,
\r
5660 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5665 if (hPrevInst == NULL)
\r
5667 wc.style = CS_CLASSDC;
\r
5668 wc.lpfnWndProc = AngbandWndProc;
\r
5669 wc.cbClsExtra = 0;
\r
5670 wc.cbWndExtra = 4; /* one long pointer to term_data */
\r
5671 wc.hInstance = hInst;
\r
5672 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
\r
5673 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
\r
5674 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
\r
5675 wc.lpszMenuName = AppName;
\r
5676 wc.lpszClassName = AppName;
\r
5678 if (!RegisterClass(&wc)) exit(1);
\r
5680 wc.lpfnWndProc = AngbandListProc;
\r
5681 wc.lpszMenuName = NULL;
\r
5682 wc.lpszClassName = AngList;
\r
5684 if (!RegisterClass(&wc)) exit(2);
\r
5688 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
\r
5689 wc.lpfnWndProc = AngbandSaverProc;
\r
5690 wc.hCursor = NULL;
\r
5691 wc.lpszMenuName = NULL;
\r
5692 wc.lpszClassName = "WindowsScreenSaverClass";
\r
5694 if (!RegisterClass(&wc)) exit(3);
\r
5700 /* Temporary hooks */
\r
5701 plog_aux = hack_plog;
\r
5702 quit_aux = hack_quit;
\r
5703 core_aux = hack_quit;
\r
5705 /* Prepare the filepaths */
\r
5708 /* Initialize the keypress analyzer */
\r
5709 for (i = 0; special_key_list[i]; ++i)
\r
5711 special_key[special_key_list[i]] = TRUE;
\r
5713 /* Initialize the keypress analyzer */
\r
5714 for (i = 0; ignore_key_list[i]; ++i)
\r
5716 ignore_key[ignore_key_list[i]] = TRUE;
\r
5719 /* Determine if display is 16/256/true color */
\r
5720 hdc = GetDC(NULL);
\r
5721 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
\r
5722 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
\r
5723 ReleaseDC(NULL, hdc);
\r
5725 /* Initialize the colors */
\r
5726 for (i = 0; i < 256; i++)
\r
5730 /* Extract desired values */
\r
5731 rv = angband_color_table[i][1];
\r
5732 gv = angband_color_table[i][2];
\r
5733 bv = angband_color_table[i][3];
\r
5735 /* Extract the "complex" code */
\r
5736 win_clr[i] = PALETTERGB(rv, gv, bv);
\r
5738 /* Save the "simple" code */
\r
5739 angband_color_table[i][0] = win_pal[i];
\r
5742 /* Prepare the windows */
\r
5748 /* Activate hooks */
\r
5749 plog_aux = hook_plog;
\r
5750 quit_aux = hook_quit;
\r
5751 core_aux = hook_quit;
\r
5753 /* Set the system suffix */
\r
5754 ANGBAND_SYS = "win";
\r
5756 /* Set the keyboard suffix */
\r
5757 if (7 != GetKeyboardType(0))
\r
5758 ANGBAND_KEYBOARD = "0";
\r
5761 /* Japanese keyboard */
\r
5762 switch (GetKeyboardType(1))
\r
5764 case 0x0D01: case 0x0D02:
\r
5765 case 0x0D03: case 0x0D04:
\r
5766 case 0x0D05: case 0x0D06:
\r
5768 ANGBAND_KEYBOARD = "NEC98";
\r
5772 ANGBAND_KEYBOARD = "JAPAN";
\r
5776 /* Catch nasty signals */
\r
5780 Term_activate(term_screen);
\r
5783 /* We are now initialized */
\r
5784 initialized = TRUE;
\r
5786 if(lpCmdLine[0] == '-'){
\r
5787 switch(lpCmdLine[1])
\r
5792 if (!lpCmdLine[2]) break;
\r
5793 chuukei_server = TRUE;
\r
5794 if(connect_chuukei_server(&lpCmdLine[2])<0){
\r
5795 msg_print("connect fail");
\r
5798 msg_print("connect");
\r
5806 if (!lpCmdLine[2]) break;
\r
5807 chuukei_client = TRUE;
\r
5808 connect_chuukei_server(&lpCmdLine[2]);
\r
5816 if (!lpCmdLine[2]) break;
\r
5817 prepare_browse_movie(&lpCmdLine[2]);
\r
5827 /* Did the user double click on a save file? */
\r
5828 if(!chuukei_server) check_for_save_file(lpCmdLine);
\r
5830 /* Did the user double click on a save file? */
\r
5831 check_for_save_file(lpCmdLine);
\r
5834 /* Prompt the user */
\r
5835 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
\r
5839 /* Process messages forever */
\r
5840 while (GetMessage(&msg, NULL, 0, 0))
\r
5842 TranslateMessage(&msg);
\r
5843 DispatchMessage(&msg);
\r
5854 #endif /* WINDOWS */
\r