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
1074 /* rc.right += 1; */
\r
1075 /* rc.bottom += 1; */
\r
1078 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
1081 td->size_wid = rc.right - rc.left;
\r
1082 td->size_hgt = rc.bottom - rc.top;
\r
1084 /* See CreateWindowEx */
\r
1085 if (!td->w) return;
\r
1087 /* Extract actual location */
\r
1088 GetWindowRect(td->w, &rc);
\r
1090 /* Save the location */
\r
1091 td->pos_x = rc.left;
\r
1092 td->pos_y = rc.top;
\r
1097 * Write the "prefs" for a single term
\r
1099 static void save_prefs_aux(int i)
\r
1101 term_data *td = &data[i];
\r
1102 char sec_name[128];
\r
1106 WINDOWPLACEMENT lpwndpl;
\r
1109 if (!td->w) return;
\r
1111 /* Make section name */
\r
1112 sprintf(sec_name, "Term-%d", i);
\r
1117 strcpy(buf, td->visible ? "1" : "0");
\r
1118 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
\r
1123 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "MS ゴシック");
\r
1126 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
\r
1128 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
\r
1132 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
\r
1134 #if 1 /* #ifdef JP */
\r
1135 wsprintf(buf, "%d", td->lf.lfWidth);
\r
1136 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
\r
1137 wsprintf(buf, "%d", td->lf.lfHeight);
\r
1138 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
\r
1139 wsprintf(buf, "%d", td->lf.lfWeight);
\r
1140 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
\r
1143 strcpy(buf, td->bizarre ? "1" : "0");
\r
1144 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
\r
1146 /* Tile size (x) */
\r
1147 wsprintf(buf, "%d", td->tile_wid);
\r
1148 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
\r
1150 /* Tile size (y) */
\r
1151 wsprintf(buf, "%d", td->tile_hgt);
\r
1152 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
\r
1154 /* Get window placement and dimensions */
\r
1155 lpwndpl.length = sizeof(WINDOWPLACEMENT);
\r
1156 GetWindowPlacement(td->w, &lpwndpl);
\r
1158 /* Acquire position in *normal* mode (not minimized) */
\r
1159 rc = lpwndpl.rcNormalPosition;
\r
1161 /* Window size (x) */
\r
1162 if (i == 0) wsprintf(buf, "%d", normsize.x);
\r
1163 else wsprintf(buf, "%d", td->cols);
\r
1164 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
\r
1166 /* Window size (y) */
\r
1167 if (i == 0) wsprintf(buf, "%d", normsize.y);
\r
1168 else wsprintf(buf, "%d", td->rows);
\r
1169 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
\r
1171 /* Maxmized (only main window) */
\r
1174 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
\r
1175 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
\r
1178 /* Acquire position */
\r
1179 GetWindowRect(td->w, &rc);
\r
1181 /* Window position (x) */
\r
1182 wsprintf(buf, "%d", rc.left);
\r
1183 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
\r
1185 /* Window position (y) */
\r
1186 wsprintf(buf, "%d", rc.top);
\r
1187 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
\r
1189 /* Window Z position */
\r
1192 strcpy(buf, td->posfix ? "1" : "0");
\r
1193 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
\r
1199 * Write the "prefs"
\r
1200 * We assume that the windows have all been initialized
\r
1202 static void save_prefs(void)
\r
1208 /* Save the "arg_graphics" flag */
\r
1209 sprintf(buf, "%d", arg_graphics);
\r
1210 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
\r
1212 /* Save the "arg_bigtile" flag */
\r
1213 strcpy(buf, arg_bigtile ? "1" : "0");
\r
1214 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
\r
1216 /* Save the "arg_sound" flag */
\r
1217 strcpy(buf, arg_sound ? "1" : "0");
\r
1218 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
\r
1220 /* Save the "arg_sound" flag */
\r
1221 strcpy(buf, arg_music ? "1" : "0");
\r
1222 WritePrivateProfileString("Angband", "Music", buf, ini_file);
\r
1225 strcpy(buf, use_bg ? "1" : "0");
\r
1226 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
\r
1227 WritePrivateProfileString("Angband", "BackGroundBitmap",
\r
1228 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
\r
1230 /* Save window prefs */
\r
1231 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1233 save_prefs_aux(i);
\r
1239 * Load the "prefs" for a single term
\r
1241 static void load_prefs_aux(int i)
\r
1243 term_data *td = &data[i];
\r
1244 char sec_name[128];
\r
1247 int wid, hgt, posx, posy;
\r
1248 int dispx = GetSystemMetrics( SM_CXVIRTUALSCREEN);
\r
1249 int dispy = GetSystemMetrics( SM_CYVIRTUALSCREEN);
\r
1253 /* Make section name */
\r
1254 sprintf(sec_name, "Term-%d", i);
\r
1256 /* Make section name */
\r
1257 sprintf(sec_name, "Term-%d", i);
\r
1262 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
\r
1265 /* Desired font, with default */
\r
1267 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
\r
1270 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
\r
1272 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
\r
1278 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
\r
1280 /* Analyze font, save desired font name */
\r
1281 #if 1 /* #ifdef JP */
\r
1282 td->font_want = string_make(tmp);
\r
1283 hgt = 15; wid = 0;
\r
1284 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
\r
1285 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
\r
1286 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
\r
1288 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
\r
1293 #if 1 /* #ifdef JP */
\r
1294 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
\r
1295 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
\r
1297 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
\r
1298 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
\r
1303 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
\r
1304 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
\r
1305 normsize.x = td->cols; normsize.y = td->rows;
\r
1310 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
\r
1313 /* Window position */
\r
1314 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
\r
1315 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
\r
1316 td->pos_x = MIN(MAX(0, posx), dispx-128);
\r
1317 td->pos_y = MIN(MAX(0, posy), dispy-128);
\r
1319 /* Window Z position */
\r
1322 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
\r
1328 * Load the "prefs"
\r
1330 static void load_prefs(void)
\r
1334 /* Extract the "arg_graphics" flag */
\r
1335 arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
\r
1337 /* Extract the "arg_bigtile" flag */
\r
1338 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
\r
1339 use_bigtile = arg_bigtile;
\r
1341 /* Extract the "arg_sound" flag */
\r
1342 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
\r
1344 /* Extract the "arg_sound" flag */
\r
1345 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
\r
1348 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
\r
1349 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
\r
1351 /* Load window prefs */
\r
1352 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1354 load_prefs_aux(i);
\r
1358 #if defined(USE_SOUND) || defined(USE_MUSIC)
\r
1361 * XXX XXX XXX - Taken from files.c.
\r
1363 * Extract "tokens" from a buffer
\r
1365 * This function uses "whitespace" as delimiters, and treats any amount of
\r
1366 * whitespace as a single delimiter. We will never return any empty tokens.
\r
1367 * When given an empty buffer, or a buffer containing only "whitespace", we
\r
1368 * will return no tokens. We will never extract more than "num" tokens.
\r
1370 * By running a token through the "text_to_ascii()" function, you can allow
\r
1371 * that token to include (encoded) whitespace, using "\s" to encode spaces.
\r
1373 * We save pointers to the tokens in "tokens", and return the number found.
\r
1375 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
\r
1385 /* Skip leading whitespace */
\r
1386 for ( ; *s && iswspace(*s); ++s) /* loop */;
\r
1391 /* Find next whitespace, if any */
\r
1392 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
\r
1394 /* Nuke and advance (if necessary) */
\r
1395 if (*t) *t++ = '\0';
\r
1397 /* Save the token */
\r
1408 #endif /* USE_SOUND || USE_MUSIC */
\r
1412 static void load_sound_prefs(void)
\r
1416 char ini_path[1024];
\r
1417 char wav_path[1024];
\r
1418 char *zz[SAMPLE_MAX];
\r
1420 /* Access the sound.cfg */
\r
1422 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
\r
1424 for (i = 0; i < SOUND_MAX; i++)
\r
1426 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
\r
1428 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
\r
1430 for (j = 0; j < num; j++)
\r
1432 /* Access the sound */
\r
1433 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
\r
1435 /* Save the sound filename, if it exists */
\r
1436 if (check_file(wav_path))
\r
1437 sound_file[i][j] = string_make(zz[j]);
\r
1442 #endif /* USE_SOUND */
\r
1446 static void load_music_prefs(void)
\r
1450 char ini_path[1024];
\r
1451 char wav_path[1024];
\r
1452 char *zz[SAMPLE_MAX];
\r
1455 /* Access the music.cfg */
\r
1457 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
\r
1459 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
\r
1461 for (i = 0; i < MUSIC_BASIC_MAX; i++)
\r
1463 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
\r
1465 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1467 for (j = 0; j < num; j++)
\r
1469 /* Access the sound */
\r
1470 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1472 /* Save the sound filename, if it exists */
\r
1473 if (check_file(wav_path))
\r
1474 music_file[i][j] = string_make(zz[j]);
\r
1478 for (i = 0; i < max_d_idx; i++)
\r
1480 sprintf(key, "dungeon%03d", i);
\r
1481 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
\r
1483 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1485 for (j = 0; j < num; j++)
\r
1487 /* Access the sound */
\r
1488 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1490 /* Save the sound filename, if it exists */
\r
1491 if (check_file(wav_path))
\r
1492 dungeon_music_file[i][j] = string_make(zz[j]);
\r
1496 for (i = 0; i < max_q_idx; i++)
\r
1498 sprintf(key, "quest%03d", i);
\r
1499 GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
\r
1501 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1503 for (j = 0; j < num; j++)
\r
1505 /* Access the sound */
\r
1506 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1508 /* Save the sound filename, if it exists */
\r
1509 if (check_file(wav_path))
\r
1510 quest_music_file[i][j] = string_make(zz[j]);
\r
1514 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
\r
1516 sprintf(key, "town%03d", i);
\r
1517 GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
\r
1519 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1521 for (j = 0; j < num; j++)
\r
1523 /* Access the sound */
\r
1524 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1526 /* Save the sound filename, if it exists */
\r
1527 if (check_file(wav_path))
\r
1528 town_music_file[i][j] = string_make(zz[j]);
\r
1535 #endif /* USE_MUSIC */
\r
1538 * Create the new global palette based on the bitmap palette
\r
1539 * (if any), and the standard 16 entry palette derived from
\r
1540 * "win_clr[]" which is used for the basic 16 Angband colors.
\r
1542 * This function is never called before all windows are ready.
\r
1544 * This function returns FALSE if the new palette could not be
\r
1545 * prepared, which should normally be a fatal error. XXX XXX
\r
1547 * Note that only some machines actually use a "palette".
\r
1549 static int new_palette(void)
\r
1557 LPLOGPALETTE pLogPal;
\r
1558 LPPALETTEENTRY lppe;
\r
1563 /* This makes no sense */
\r
1564 if (!paletted) return (TRUE);
\r
1572 #ifdef USE_GRAPHICS
\r
1574 /* Check the bitmap palette */
\r
1575 hBmPal = infGraph.hPalette;
\r
1577 /* Use the bitmap */
\r
1580 lppeSize = 256 * sizeof(PALETTEENTRY);
\r
1581 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
\r
1582 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
\r
1583 if ((nEntries == 0) || (nEntries > 220))
\r
1585 /* Warn the user */
\r
1586 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
\r
1589 rnfree(lppe, lppeSize);
\r
1596 #endif /* USE_GRAPHICS */
\r
1598 /* Size of palette */
\r
1599 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
\r
1601 /* Allocate palette */
\r
1602 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
\r
1605 pLogPal->palVersion = 0x300;
\r
1607 /* Make room for bitmap and normal data */
\r
1608 pLogPal->palNumEntries = nEntries + 16;
\r
1610 /* Save the bitmap data */
\r
1611 for (i = 0; i < nEntries; i++)
\r
1613 pLogPal->palPalEntry[i] = lppe[i];
\r
1616 /* Save the normal data */
\r
1617 for (i = 0; i < 16; i++)
\r
1621 /* Access the entry */
\r
1622 p = &(pLogPal->palPalEntry[i+nEntries]);
\r
1624 /* Save the colors */
\r
1625 p->peRed = GetRValue(win_clr[i]);
\r
1626 p->peGreen = GetGValue(win_clr[i]);
\r
1627 p->peBlue = GetBValue(win_clr[i]);
\r
1629 /* Save the flags */
\r
1630 p->peFlags = PC_NOCOLLAPSE;
\r
1633 /* Free something */
\r
1634 if (lppe) rnfree(lppe, lppeSize);
\r
1636 /* Create a new palette, or fail */
\r
1637 hNewPal = CreatePalette(pLogPal);
\r
1638 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
\r
1640 /* Free the palette */
\r
1641 rnfree(pLogPal, pLogPalSize);
\r
1646 /* Realize the palette */
\r
1647 hdc = GetDC(td->w);
\r
1648 SelectPalette(hdc, hNewPal, 0);
\r
1649 i = RealizePalette(hdc);
\r
1650 ReleaseDC(td->w, hdc);
\r
1651 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
\r
1655 for (i = 1; i < MAX_TERM_DATA; i++)
\r
1659 hdc = GetDC(td->w);
\r
1660 SelectPalette(hdc, hNewPal, 0);
\r
1661 ReleaseDC(td->w, hdc);
\r
1664 /* Delete old palette */
\r
1665 if (hPal) DeleteObject(hPal);
\r
1667 /* Save new palette */
\r
1675 #ifdef USE_GRAPHICS
\r
1677 * @brief グラフィクスを初期化する / Initialize graphics
\r
1680 * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
\r
1681 * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
\r
1684 static bool init_graphics(void)
\r
1686 /* Initialize once */
\r
1688 BYTE wid, hgt, twid, thgt, ox, oy;
\r
1691 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1699 name = "16X16.BMP";
\r
1701 ANGBAND_GRAF = "new";
\r
1703 else if (arg_graphics == GRAPHICS_HENGBAND)
\r
1712 name = "64X64.BMP";
\r
1721 name = "32X32.BMP";
\r
1723 ANGBAND_GRAF = "ne2";
\r
1734 ANGBAND_GRAF = "old";
\r
1737 /* Access the bitmap file */
\r
1738 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
\r
1740 /* Load the bitmap or quit */
\r
1741 if (!ReadDIB(data[0].w, buf, &infGraph))
\r
1743 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
\r
1747 /* Save the new sizes */
\r
1748 infGraph.CellWidth = wid;
\r
1749 infGraph.CellHeight = hgt;
\r
1750 infGraph.TileWidth = twid;
\r
1751 infGraph.TileHeight = thgt;
\r
1752 infGraph.OffsetX = ox;
\r
1753 infGraph.OffsetY = oy;
\r
1755 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1757 /* Access the mask file */
\r
1758 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
\r
1760 /* Load the bitmap or quit */
\r
1761 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1763 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1767 if (arg_graphics == GRAPHICS_HENGBAND)
\r
1769 /* Access the mask file */
\r
1770 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
\r
1772 /* Load the bitmap or quit */
\r
1773 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1775 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1780 /* Activate a palette */
\r
1781 if (!new_palette())
\r
1783 /* Free bitmap XXX XXX XXX */
\r
1786 plog(_("パレットを実現できません!", "Cannot activate palette!"));
\r
1790 /* Graphics available */
\r
1791 current_graphics_mode = arg_graphics;
\r
1794 return (current_graphics_mode);
\r
1796 #endif /* USE_GRAPHICS */
\r
1801 * Initialize music
\r
1803 static bool init_music(void)
\r
1805 /* Initialize once */
\r
1806 if (!can_use_music)
\r
1808 /* Load the prefs */
\r
1809 load_music_prefs();
\r
1811 /* Sound available */
\r
1812 can_use_music = TRUE;
\r
1816 return (can_use_music);
\r
1820 * Hack -- Stop a music
\r
1822 static void stop_music(void)
\r
1824 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
1825 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
1828 #endif /* USE_MUSIC */
\r
1832 * Initialize sound
\r
1834 static bool init_sound(void)
\r
1836 /* Initialize once */
\r
1837 if (!can_use_sound)
\r
1839 /* Load the prefs */
\r
1840 load_sound_prefs();
\r
1842 /* Sound available */
\r
1843 can_use_sound = TRUE;
\r
1847 return (can_use_sound);
\r
1849 #endif /* USE_SOUND */
\r
1855 static void term_window_resize(term_data *td)
\r
1857 /* Require window */
\r
1858 if (!td->w) return;
\r
1860 /* Resize the window */
\r
1861 SetWindowPos(td->w, 0, 0, 0,
\r
1862 td->size_wid, td->size_hgt,
\r
1863 SWP_NOMOVE | SWP_NOZORDER);
\r
1865 /* Redraw later */
\r
1866 InvalidateRect(td->w, NULL, TRUE);
\r
1871 * Force the use of a new "font file" for a term_data
\r
1873 * This function may be called before the "window" is ready
\r
1875 * This function returns zero only if everything succeeds.
\r
1877 * Note that the "font name" must be capitalized!!!
\r
1879 static errr term_force_font(term_data *td, cptr path)
\r
1883 #if 0 /* #ifndef JP */
\r
1889 /* Forget the old font (if needed) */
\r
1890 if (td->font_id) DeleteObject(td->font_id);
\r
1892 #if 1 /* #ifdef JP */
\r
1896 /* Create the font (using the 'base' of the font file name!) */
\r
1897 td->font_id = CreateFontIndirect(&(td->lf));
\r
1898 wid = td->lf.lfWidth;
\r
1899 hgt = td->lf.lfHeight;
\r
1900 if (!td->font_id) return (1);
\r
1902 /* Forget old font */
\r
1903 if (td->font_file)
\r
1905 bool used = FALSE;
\r
1907 /* Scan windows */
\r
1908 for (i = 0; i < MAX_TERM_DATA; i++)
\r
1910 /* Don't check when closing the application */
\r
1913 /* Check "screen" */
\r
1914 if ((td != &data[i]) &&
\r
1915 (data[i].font_file) &&
\r
1916 (streq(data[i].font_file, td->font_file)))
\r
1922 /* Remove unused font resources */
\r
1923 if (!used) RemoveFontResource(td->font_file);
\r
1925 /* Free the old name */
\r
1926 string_free(td->font_file);
\r
1929 td->font_file = NULL;
\r
1932 /* No path given */
\r
1933 if (!path) return (1);
\r
1936 strcpy(buf, path);
\r
1938 /* Analyze font path */
\r
1939 base = analyze_font(buf, &wid, &hgt);
\r
1941 /* Verify suffix */
\r
1942 if (!suffix(base, ".FON")) return (1);
\r
1945 if (!check_file(buf)) return (1);
\r
1947 /* Load the new font */
\r
1948 if (!AddFontResource(buf)) return (1);
\r
1950 /* Save new font name */
\r
1951 td->font_file = string_make(base);
\r
1953 /* Remove the "suffix" */
\r
1954 base[strlen(base)-4] = '\0';
\r
1956 /* Create the font (using the 'base' of the font file name!) */
\r
1957 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
\r
1958 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
\r
1959 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
\r
1960 FIXED_PITCH | FF_DONTCARE, base);
\r
1963 /* Hack -- Unknown size */
\r
1970 /* all this trouble to get the cell size */
\r
1971 hdcDesktop = GetDC(HWND_DESKTOP);
\r
1972 hfOld = SelectObject(hdcDesktop, td->font_id);
\r
1973 GetTextMetrics(hdcDesktop, &tm);
\r
1974 SelectObject(hdcDesktop, hfOld);
\r
1975 ReleaseDC(HWND_DESKTOP, hdcDesktop);
\r
1977 /* Font size info */
\r
1978 wid = tm.tmAveCharWidth;
\r
1979 hgt = tm.tmHeight;
\r
1982 /* Save the size info */
\r
1983 td->font_wid = wid;
\r
1984 td->font_hgt = hgt;
\r
1993 * Allow the user to change the font for this window.
\r
1995 static void term_change_font(term_data *td)
\r
1997 #if 1 /* #ifdef JP */
\r
2000 memset(&cf, 0, sizeof(cf));
\r
2001 cf.lStructSize = sizeof(cf);
\r
2002 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
\r
2003 cf.lpLogFont = &(td->lf);
\r
2005 if (ChooseFont(&cf))
\r
2007 /* Force the font */
\r
2008 term_force_font(td, NULL);
\r
2010 /* Assume not bizarre */
\r
2011 td->bizarre = TRUE;
\r
2013 /* Reset the tile info */
\r
2014 td->tile_wid = td->font_wid;
\r
2015 td->tile_hgt = td->font_hgt;
\r
2017 /* Analyze the font */
\r
2020 /* Resize the window */
\r
2021 term_window_resize(td);
\r
2027 char tmp[1024] = "";
\r
2029 /* Extract a default if possible */
\r
2030 if (td->font_file) strcpy(tmp, td->font_file);
\r
2032 /* Ask for a choice */
\r
2033 memset(&ofn, 0, sizeof(ofn));
\r
2034 ofn.lStructSize = sizeof(ofn);
\r
2035 ofn.hwndOwner = data[0].w;
\r
2036 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
\r
2037 ofn.nFilterIndex = 1;
\r
2038 ofn.lpstrFile = tmp;
\r
2039 ofn.nMaxFile = 128;
\r
2040 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
\r
2041 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
2042 ofn.lpstrDefExt = "fon";
\r
2044 /* Force choice if legal */
\r
2045 if (GetOpenFileName(&ofn))
\r
2047 /* Force the font */
\r
2048 if (term_force_font(td, tmp))
\r
2050 /* Access the standard font file */
\r
2051 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
2053 /* Force the use of that font */
\r
2054 (void)term_force_font(td, tmp);
\r
2057 /* Assume not bizarre */
\r
2058 td->bizarre = FALSE;
\r
2060 /* Reset the tile info */
\r
2061 td->tile_wid = td->font_wid;
\r
2062 td->tile_hgt = td->font_hgt;
\r
2064 /* Analyze the font */
\r
2067 /* Resize the window */
\r
2068 term_window_resize(td);
\r
2075 * Allow the user to lock this window.
\r
2077 static void term_window_pos(term_data *td, HWND hWnd)
\r
2079 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
\r
2080 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
\r
2083 static void windows_map(void);
\r
2086 * Hack -- redraw a term_data
\r
2088 static void term_data_redraw(term_data *td)
\r
2090 if (td->map_active)
\r
2092 /* Redraw the map */
\r
2097 /* Activate the term */
\r
2098 Term_activate(&td->t);
\r
2100 /* Redraw the contents */
\r
2103 /* Restore the term */
\r
2104 Term_activate(term_screen);
\r
2109 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
\r
2113 HBRUSH myBrush, oldBrush;
\r
2115 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
\r
2116 int tx = td->size_ow1 + x * td->tile_wid;
\r
2117 int ty = td->size_oh1 + y * td->tile_hgt;
\r
2118 int tw = w * td->tile_wid - 1;
\r
2119 int th = h * td->tile_hgt - 1;
\r
2121 hdc = GetDC(hWnd);
\r
2122 myBrush = CreateSolidBrush(RGB(255, 255, 255));
\r
2123 oldBrush = SelectObject(hdc, myBrush);
\r
2124 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2126 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
\r
2128 SelectObject(hdc, oldBrush);
\r
2129 SelectObject(hdc, oldPen);
\r
2134 /*** Function hooks needed by "Term" ***/
\r
2140 * Initialize a new Term
\r
2142 static void Term_init_win(term *t)
\r
2149 * Nuke an old Term
\r
2151 static void Term_nuke_win(term *t)
\r
2160 * @brief //!< Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
\r
2162 static errr Term_user_win(int n)
\r
2173 * React to global changes
\r
2175 static errr Term_xtra_win_react(void)
\r
2179 /* Simple color */
\r
2182 /* Save the default colors */
\r
2183 for (i = 0; i < 256; i++)
\r
2185 /* Simply accept the desired colors */
\r
2186 win_pal[i] = angband_color_table[i][0];
\r
2190 /* Complex color */
\r
2197 bool change = FALSE;
\r
2199 /* Save the default colors */
\r
2200 for (i = 0; i < 256; i++)
\r
2202 /* Extract desired values */
\r
2203 rv = angband_color_table[i][1];
\r
2204 gv = angband_color_table[i][2];
\r
2205 bv = angband_color_table[i][3];
\r
2207 /* Extract a full color code */
\r
2208 code = PALETTERGB(rv, gv, bv);
\r
2210 /* Activate changes */
\r
2211 if (win_clr[i] != code)
\r
2213 /* Note the change */
\r
2216 /* Apply the desired color */
\r
2217 win_clr[i] = code;
\r
2221 /* Activate the palette if needed */
\r
2222 if (change) (void)new_palette();
\r
2228 /* Handle "arg_sound" */
\r
2229 if (use_sound != arg_sound)
\r
2231 /* Initialize (if needed) */
\r
2232 if (arg_sound && !init_sound())
\r
2235 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
\r
2237 /* Cannot enable */
\r
2238 arg_sound = FALSE;
\r
2241 /* Change setting */
\r
2242 use_sound = arg_sound;
\r
2249 /* Handle "arg_sound" */
\r
2250 if (use_music != arg_music)
\r
2252 /* Initialize (if needed) */
\r
2253 if (arg_music && !init_music())
\r
2256 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
\r
2257 /* Cannot enable */
\r
2258 arg_music = FALSE;
\r
2261 /* Change setting */
\r
2262 use_music = arg_music;
\r
2264 if(!arg_music) stop_music();
\r
2265 else select_floor_music();
\r
2272 #ifdef USE_GRAPHICS
\r
2274 /* Handle "arg_graphics" */
\r
2275 if (use_graphics != arg_graphics)
\r
2277 /* Initialize (if needed) */
\r
2278 if (arg_graphics && !init_graphics())
\r
2281 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
\r
2283 /* Cannot enable */
\r
2284 arg_graphics = GRAPHICS_NONE;
\r
2287 /* Change setting */
\r
2288 use_graphics = arg_graphics;
\r
2290 /* Reset visuals */
\r
2291 #ifdef ANGBAND_2_8_1
\r
2293 #else /* ANGBAND_2_8_1 */
\r
2294 reset_visuals(TRUE);
\r
2295 #endif /* ANGBAND_2_8_1 */
\r
2298 #endif /* USE_GRAPHICS */
\r
2301 /* Clean up windows */
\r
2302 for (i = 0; i < MAX_TERM_DATA; i++)
\r
2306 term_data *td = &data[i];
\r
2308 /* Update resized windows */
\r
2309 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
\r
2312 Term_activate(&td->t);
\r
2314 /* Hack -- Resize the term */
\r
2315 Term_resize(td->cols, td->rows);
\r
2317 /* Redraw the contents */
\r
2321 Term_activate(old);
\r
2332 * Process at least one event
\r
2334 static errr Term_xtra_win_event(int v)
\r
2338 /* Wait for an event */
\r
2342 if (GetMessage(&msg, NULL, 0, 0))
\r
2344 TranslateMessage(&msg);
\r
2345 DispatchMessage(&msg);
\r
2349 /* Check for an event */
\r
2353 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2355 TranslateMessage(&msg);
\r
2356 DispatchMessage(&msg);
\r
2366 * Process all pending events
\r
2368 static errr Term_xtra_win_flush(void)
\r
2372 /* Process all pending events */
\r
2373 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2375 TranslateMessage(&msg);
\r
2376 DispatchMessage(&msg);
\r
2385 * Hack -- clear the screen
\r
2387 * Make this more efficient XXX XXX XXX
\r
2389 static errr Term_xtra_win_clear(void)
\r
2391 term_data *td = (term_data*)(Term->data);
\r
2396 /* Rectangle to erase */
\r
2397 rc.left = td->size_ow1;
\r
2398 rc.right = rc.left + td->cols * td->tile_wid;
\r
2399 rc.top = td->size_oh1;
\r
2400 rc.bottom = rc.top + td->rows * td->tile_hgt;
\r
2403 hdc = GetDC(td->w);
\r
2404 SetBkColor(hdc, RGB(0, 0, 0));
\r
2405 SelectObject(hdc, td->font_id);
\r
2406 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2411 rc.left = 0; rc.top = 0;
\r
2414 ReleaseDC(td->w, hdc);
\r
2422 * Hack -- make a noise
\r
2424 static errr Term_xtra_win_noise(void)
\r
2426 MessageBeep(MB_ICONASTERISK);
\r
2432 * Hack -- make a sound
\r
2434 static errr Term_xtra_win_sound(int v)
\r
2439 #endif /* USE_SOUND */
\r
2441 /* Sound disabled */
\r
2442 if (!use_sound) return (1);
\r
2444 /* Illegal sound */
\r
2445 if ((v < 0) || (v >= SOUND_MAX)) return (1);
\r
2449 /* Count the samples */
\r
2450 for (i = 0; i < SAMPLE_MAX; i++)
\r
2452 if (!sound_file[v][i])
\r
2457 if (i == 0) return (1);
\r
2459 /* Build the path */
\r
2460 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
\r
2464 /* Play the sound, catch errors */
\r
2465 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
\r
2469 /* Play the sound, catch errors */
\r
2470 return (sndPlaySound(buf, SND_ASYNC));
\r
2472 #endif /* WIN32 */
\r
2474 #else /* USE_SOUND */
\r
2479 #endif /* USE_SOUND */
\r
2483 * Hack -- play a music
\r
2485 static errr Term_xtra_win_music(int n, int v)
\r
2490 #endif /* USE_MUSIC */
\r
2492 /* Sound disabled */
\r
2494 if(!use_music) return (1);
\r
2496 /* Illegal sound */
\r
2497 if(n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return (1);
\r
2498 else if(v < 0 || v >= 1000) return(1); /*!< TODO */
\r
2504 case TERM_XTRA_MUSIC_BASIC:
\r
2505 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2507 case TERM_XTRA_MUSIC_DUNGEON:
\r
2508 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2510 case TERM_XTRA_MUSIC_QUEST:
\r
2511 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2513 case TERM_XTRA_MUSIC_TOWN:
\r
2514 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2521 //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2522 //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2528 case TERM_XTRA_MUSIC_BASIC:
\r
2529 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2531 case TERM_XTRA_MUSIC_DUNGEON:
\r
2532 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2534 case TERM_XTRA_MUSIC_QUEST:
\r
2535 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2537 case TERM_XTRA_MUSIC_TOWN:
\r
2538 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2545 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2546 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2552 case TERM_XTRA_MUSIC_BASIC:
\r
2553 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
\r
2555 case TERM_XTRA_MUSIC_DUNGEON:
\r
2556 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
\r
2558 case TERM_XTRA_MUSIC_QUEST:
\r
2559 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
\r
2561 case TERM_XTRA_MUSIC_TOWN:
\r
2562 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
\r
2566 if(current_music_type == n && current_music_id == v)
\r
2570 current_music_type = n;
\r
2571 current_music_id = v;
\r
2575 mop.lpstrDeviceType = mci_device_type;
\r
2576 mop.lpstrElementName = buf;
\r
2577 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2578 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2579 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
\r
2580 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
2581 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
2584 #endif /* WIN32 */
\r
2586 #else /* USE_MUSIC */
\r
2590 #endif /* USE_MUSIC */
\r
2596 * Delay for "x" milliseconds
\r
2598 static int Term_xtra_win_delay(int v)
\r
2612 t = GetTickCount() + v;
\r
2615 while (GetTickCount() < t)
\r
2617 /* Handle messages */
\r
2618 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2620 TranslateMessage(&msg);
\r
2621 DispatchMessage(&msg);
\r
2625 #endif /* WIN32 */
\r
2633 * Do a "special thing"
\r
2635 static errr Term_xtra_win(int n, int v)
\r
2637 /* Handle a subset of the legal requests */
\r
2640 /* Make a bell sound */
\r
2641 case TERM_XTRA_NOISE:
\r
2643 return (Term_xtra_win_noise());
\r
2646 /* Play a music */
\r
2647 case TERM_XTRA_MUSIC_BASIC:
\r
2648 case TERM_XTRA_MUSIC_DUNGEON:
\r
2649 case TERM_XTRA_MUSIC_QUEST:
\r
2650 case TERM_XTRA_MUSIC_TOWN:
\r
2652 return (Term_xtra_win_music(n, v));
\r
2655 /* Make a special sound */
\r
2656 case TERM_XTRA_SOUND:
\r
2658 return (Term_xtra_win_sound(v));
\r
2661 /* Process random events */
\r
2662 case TERM_XTRA_BORED:
\r
2664 return (Term_xtra_win_event(0));
\r
2667 /* Process an event */
\r
2668 case TERM_XTRA_EVENT:
\r
2670 return (Term_xtra_win_event(v));
\r
2673 /* Flush all events */
\r
2674 case TERM_XTRA_FLUSH:
\r
2676 return (Term_xtra_win_flush());
\r
2679 /* Clear the screen */
\r
2680 case TERM_XTRA_CLEAR:
\r
2682 return (Term_xtra_win_clear());
\r
2685 /* React to global changes */
\r
2686 case TERM_XTRA_REACT:
\r
2688 return (Term_xtra_win_react());
\r
2691 /* Delay for some milliseconds */
\r
2692 case TERM_XTRA_DELAY:
\r
2694 return (Term_xtra_win_delay(v));
\r
2705 * Low level graphics (Assumes valid input).
\r
2707 * Draw a "cursor" at (x,y), using a "yellow box".
\r
2709 static errr Term_curs_win(int x, int y)
\r
2711 term_data *td = (term_data*)(Term->data);
\r
2716 int tile_wid, tile_hgt;
\r
2718 if (td->map_active)
\r
2720 tile_wid = td->map_tile_wid;
\r
2721 tile_hgt = td->map_tile_hgt;
\r
2725 tile_wid = td->tile_wid;
\r
2726 tile_hgt = td->tile_hgt;
\r
2729 /* Frame the grid */
\r
2730 rc.left = x * tile_wid + td->size_ow1;
\r
2731 rc.right = rc.left + tile_wid;
\r
2732 rc.top = y * tile_hgt + td->size_oh1;
\r
2733 rc.bottom = rc.top + tile_hgt;
\r
2735 /* Cursor is done as a yellow "box" */
\r
2736 hdc = GetDC(td->w);
\r
2737 FrameRect(hdc, &rc, hbrYellow);
\r
2738 ReleaseDC(td->w, hdc);
\r
2746 * Low level graphics (Assumes valid input).
\r
2748 * Draw a "big cursor" at (x,y), using a "yellow box".
\r
2750 static errr Term_bigcurs_win(int x, int y)
\r
2752 term_data *td = (term_data*)(Term->data);
\r
2757 int tile_wid, tile_hgt;
\r
2759 if (td->map_active)
\r
2761 /* Normal cursor in map window */
\r
2762 Term_curs_win(x, y);
\r
2767 tile_wid = td->tile_wid;
\r
2768 tile_hgt = td->tile_hgt;
\r
2771 /* Frame the grid */
\r
2772 rc.left = x * tile_wid + td->size_ow1;
\r
2773 rc.right = rc.left + 2 * tile_wid;
\r
2774 rc.top = y * tile_hgt + td->size_oh1;
\r
2775 rc.bottom = rc.top + tile_hgt;
\r
2777 /* Cursor is done as a yellow "box" */
\r
2778 hdc = GetDC(td->w);
\r
2779 FrameRect(hdc, &rc, hbrYellow);
\r
2780 ReleaseDC(td->w, hdc);
\r
2788 * Low level graphics (Assumes valid input).
\r
2790 * Erase a "block" of "n" characters starting at (x,y).
\r
2792 static errr Term_wipe_win(int x, int y, int n)
\r
2794 term_data *td = (term_data*)(Term->data);
\r
2799 /* Rectangle to erase in client coords */
\r
2800 rc.left = x * td->tile_wid + td->size_ow1;
\r
2801 rc.right = rc.left + n * td->tile_wid;
\r
2802 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2803 rc.bottom = rc.top + td->tile_hgt;
\r
2805 hdc = GetDC(td->w);
\r
2806 SetBkColor(hdc, RGB(0, 0, 0));
\r
2807 SelectObject(hdc, td->font_id);
\r
2812 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2813 ReleaseDC(td->w, hdc);
\r
2821 * Low level graphics. Assumes valid input.
\r
2823 * Draw several ("n") chars, with an attr, at a given location.
\r
2825 * All "graphic" data is handled by "Term_pict_win()", below.
\r
2827 * One would think there is a more efficient method for telling a window
\r
2828 * what color it should be using to draw with, but perhaps simply changing
\r
2829 * it every time is not too inefficient. XXX XXX XXX
\r
2831 static errr Term_text_win(int x, int y, int n, TERM_COLOR a, const char *s)
\r
2833 term_data *td = (term_data*)(Term->data);
\r
2837 #if 1 /* #ifdef JP */
\r
2838 static HBITMAP WALL;
\r
2839 static HBRUSH myBrush, oldBrush;
\r
2840 static HPEN oldPen;
\r
2841 static bool init_done = FALSE;
\r
2844 WALL = LoadBitmap(hInstance, AppName);
\r
2845 myBrush = CreatePatternBrush(WALL);
\r
2850 /* Total rectangle */
\r
2851 rc.left = x * td->tile_wid + td->size_ow1;
\r
2852 rc.right = rc.left + n * td->tile_wid;
\r
2853 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2854 rc.bottom = rc.top + td->tile_hgt;
\r
2857 hdc = GetDC(td->w);
\r
2859 /* Background color */
\r
2860 SetBkColor(hdc, RGB(0, 0, 0));
\r
2862 /* Foreground color */
\r
2865 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
\r
2867 else if (paletted)
\r
2869 SetTextColor(hdc, win_clr[a&0x0F]);
\r
2873 SetTextColor(hdc, win_clr[a]);
\r
2876 /* Use the font */
\r
2877 SelectObject(hdc, td->font_id);
\r
2880 if (use_bg) SetBkMode(hdc, TRANSPARENT);
\r
2882 /* Bizarre size */
\r
2883 if (td->bizarre ||
\r
2884 (td->tile_hgt != td->font_hgt) ||
\r
2885 (td->tile_wid != td->font_wid))
\r
2889 /* Erase complete rectangle */
\r
2890 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2893 if (use_bg) DrawBG(hdc, &rc);
\r
2895 /* New rectangle */
\r
2896 rc.left += ((td->tile_wid - td->font_wid) / 2);
\r
2897 rc.right = rc.left + td->font_wid;
\r
2898 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
\r
2899 rc.bottom = rc.top + td->font_hgt;
\r
2901 /* Dump each character */
\r
2902 for (i = 0; i < n; i++)
\r
2905 if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
\r
2907 rc.right += td->font_wid;
\r
2909 oldBrush = SelectObject(hdc, myBrush);
\r
2910 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2912 /* Dump the wall */
\r
2913 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2915 SelectObject(hdc, oldBrush);
\r
2916 SelectObject(hdc, oldPen);
\r
2917 rc.right -= td->font_wid;
\r
2921 rc.left += 2 * td->tile_wid;
\r
2922 rc.right += 2 * td->tile_wid;
\r
2924 else if ( iskanji(*(s+i)) ) /* 2バイト文字 */
\r
2926 rc.right += td->font_wid;
\r
2927 /* Dump the text */
\r
2928 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2930 rc.right -= td->font_wid;
\r
2934 rc.left += 2 * td->tile_wid;
\r
2935 rc.right += 2 * td->tile_wid;
\r
2936 } else if (*(s+i)==127){
\r
2937 oldBrush = SelectObject(hdc, myBrush);
\r
2938 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2940 /* Dump the wall */
\r
2941 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2943 SelectObject(hdc, oldBrush);
\r
2944 SelectObject(hdc, oldPen);
\r
2947 rc.left += td->tile_wid;
\r
2948 rc.right += td->tile_wid;
\r
2950 /* Dump the text */
\r
2951 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
\r
2954 rc.left += td->tile_wid;
\r
2955 rc.right += td->tile_wid;
\r
2960 oldBrush = SelectObject(hdc, myBrush);
\r
2961 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2963 /* Dump the wall */
\r
2964 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2966 SelectObject(hdc, oldBrush);
\r
2967 SelectObject(hdc, oldPen);
\r
2970 rc.left += td->tile_wid;
\r
2971 rc.right += td->tile_wid;
\r
2973 /* Dump the text */
\r
2974 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2978 rc.left += td->tile_wid;
\r
2979 rc.right += td->tile_wid;
\r
2982 /* Dump the text */
\r
2983 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
\r
2987 rc.left += td->tile_wid;
\r
2988 rc.right += td->tile_wid;
\r
2998 /* Dump the text */
\r
2999 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
\r
3004 ReleaseDC(td->w, hdc);
\r
3012 * Low level graphics. Assumes valid input.
\r
3014 * Draw an array of "special" attr/char pairs at the given location.
\r
3016 * We use the "Term_pict_win()" function for "graphic" data, which are
\r
3017 * encoded by setting the "high-bits" of both the "attr" and the "char"
\r
3018 * data. We use the "attr" to represent the "row" of the main bitmap,
\r
3019 * and the "char" to represent the "col" of the main bitmap. The use
\r
3020 * of this function is induced by the "higher_pict" flag.
\r
3022 * If "graphics" is not available, we simply "wipe" the given grids.
\r
3024 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
3026 term_data *td = (term_data*)(Term->data);
\r
3028 #ifdef USE_GRAPHICS
\r
3031 TERM_LEN x1, y1, w1, h1, tw1, th1;
\r
3032 TERM_LEN x2, y2, w2, h2, tw2 = 0;
\r
3035 HDC hdcMask = NULL;
\r
3039 HBITMAP hbmSrcOld;
\r
3042 if (!use_graphics)
\r
3044 /* Erase the grids */
\r
3045 return (Term_wipe_win(x, y, n));
\r
3048 /* Size of bitmap cell */
\r
3049 w1 = infGraph.CellWidth;
\r
3050 h1 = infGraph.CellHeight;
\r
3051 tw1 = infGraph.TileWidth;
\r
3052 th1 = infGraph.TileHeight;
\r
3054 /* Size of window cell */
\r
3055 if (td->map_active)
\r
3057 w2 = td->map_tile_wid;
\r
3058 h2 = td->map_tile_hgt;
\r
3062 w2 = td->tile_wid;
\r
3063 h2 = td->tile_hgt;
\r
3066 /* big tile mode */
\r
3067 if (use_bigtile) tw2 *= 2;
\r
3070 /* Location of window cell */
\r
3071 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
\r
3072 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
\r
3075 hdc = GetDC(td->w);
\r
3078 hdcSrc = CreateCompatibleDC(hdc);
\r
3079 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
\r
3081 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3083 hdcMask = CreateCompatibleDC(hdc);
\r
3084 SelectObject(hdcMask, infMask.hBitmap);
\r
3087 /* Draw attr/char pairs */
\r
3088 for (i = 0; i < n; i++, x2 += w2)
\r
3094 /* Extract picture */
\r
3095 int row = (a & 0x7F);
\r
3096 int col = (c & 0x7F);
\r
3098 /* Location of bitmap cell */
\r
3102 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3104 x3 = (tcp[i] & 0x7F) * w1;
\r
3105 y3 = (tap[i] & 0x7F) * h1;
\r
3106 tw2 = tw2 * w1 / tw1;
\r
3107 h2 = h2 * h1 / th1;
\r
3109 /* Perfect size */
\r
3110 if ((tw1 == tw2) && (th1 == h2))
\r
3112 /* Copy the terrain picture from the bitmap to the window */
\r
3113 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
\r
3115 /* Mask out the tile */
\r
3116 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
\r
3118 /* Draw the tile */
\r
3119 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
\r
3122 /* Need to stretch */
\r
3125 /* Set the correct mode for stretching the tiles */
\r
3126 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3128 /* Copy the terrain picture from the bitmap to the window */
\r
3129 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
\r
3131 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
\r
3133 /* Only draw if terrain and overlay are different */
\r
3134 if ((x1 != x3) || (y1 != y3))
\r
3136 /* Mask out the tile */
\r
3137 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
\r
3139 /* Draw the tile */
\r
3140 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
\r
3146 /* Perfect size */
\r
3147 if ((w1 == tw2) && (h1 == h2))
\r
3149 /* Copy the picture from the bitmap to the window */
\r
3150 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
\r
3153 /* Need to stretch */
\r
3156 /* Set the correct mode for stretching the tiles */
\r
3157 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3159 /* Copy the picture from the bitmap to the window */
\r
3160 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
\r
3166 SelectObject(hdcSrc, hbmSrcOld);
\r
3169 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3172 SelectObject(hdcMask, hbmSrcOld);
\r
3173 DeleteDC(hdcMask);
\r
3177 ReleaseDC(td->w, hdc);
\r
3179 #else /* USE_GRAPHICS */
\r
3181 /* Just erase this grid */
\r
3182 return (Term_wipe_win(x, y, n));
\r
3184 #endif /* USE_GRAPHICS */
\r
3191 static void windows_map(void)
\r
3193 term_data *td = &data[0];
\r
3196 TERM_LEN x, min_x, max_x;
\r
3197 TERM_LEN y, min_y, max_y;
\r
3202 /* Only in graphics mode */
\r
3203 if (!use_graphics) return;
\r
3205 /* Clear screen */
\r
3206 Term_xtra_win_clear();
\r
3208 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
\r
3209 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
\r
3210 td->map_active = TRUE;
\r
3219 /* Draw the map */
\r
3220 for (x = min_x; x < max_x; x++)
\r
3222 for (y = min_y; y < max_y; y++)
\r
3224 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
\r
3226 /* Ignore non-graphics */
\r
3227 if ((a & 0x80) && (c & 0x80))
\r
3229 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
\r
3234 /* Hilite the player */
\r
3235 Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
\r
3237 /* Wait for a keypress, flush key buffer */
\r
3238 Term_inkey(&c, TRUE, TRUE);
\r
3241 /* Switch off the map display */
\r
3242 td->map_active = FALSE;
\r
3244 /* Restore screen */
\r
3245 Term_xtra_win_clear();
\r
3250 /*** Other routines ***/
\r
3254 * Create and initialize a "term_data" given a title
\r
3256 static void term_data_link(term_data *td)
\r
3260 /* Initialize the term */
\r
3261 term_init(t, td->cols, td->rows, td->keys);
\r
3263 /* Use a "software" cursor */
\r
3264 t->soft_cursor = TRUE;
\r
3266 /* Use "Term_pict" for "graphic" data */
\r
3267 t->higher_pict = TRUE;
\r
3269 /* Erase with "white space" */
\r
3270 t->attr_blank = TERM_WHITE;
\r
3271 t->char_blank = ' ';
\r
3274 /* Prepare the init/nuke hooks */
\r
3275 t->init_hook = Term_init_win;
\r
3276 t->nuke_hook = Term_nuke_win;
\r
3279 /* Prepare the template hooks */
\r
3280 t->user_hook = Term_user_win;
\r
3281 t->xtra_hook = Term_xtra_win;
\r
3282 t->curs_hook = Term_curs_win;
\r
3283 t->bigcurs_hook = Term_bigcurs_win;
\r
3284 t->wipe_hook = Term_wipe_win;
\r
3285 t->text_hook = Term_text_win;
\r
3286 t->pict_hook = Term_pict_win;
\r
3288 /* Remember where we came from */
\r
3289 t->data = (vptr)(td);
\r
3294 * Create the windows
\r
3296 * First, instantiate the "default" values, then read the "ini_file"
\r
3297 * to over-ride selected values, then create the windows, and fonts.
\r
3299 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
\r
3300 * must make active to realize the palette. XXX XXX XXX
\r
3302 static void init_windows(void)
\r
3308 #if 0 /* #ifndef JP */
\r
3314 WIPE(td, term_data);
\r
3318 td->s = angband_term_name[0];
\r
3324 td->visible = TRUE;
\r
3329 td->pos_x = 7 * 30;
\r
3330 td->pos_y = 7 * 20;
\r
3331 td->posfix = FALSE;
\r
3332 #if 1 /* #ifdef JP */
\r
3333 td->bizarre = TRUE;
\r
3336 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3339 WIPE(td, term_data);
\r
3340 td->s = angband_term_name[i];
\r
3344 td->visible = FALSE;
\r
3349 td->pos_x = (7 - i) * 30;
\r
3350 td->pos_y = (7 - i) * 20;
\r
3351 td->posfix = FALSE;
\r
3352 #if 1 /* #ifdef JP */
\r
3353 td->bizarre = TRUE;
\r
3362 /* Main window (need these before term_getsize gets called) */
\r
3364 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
\r
3365 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
\r
3367 td->dwExStyle = 0;
\r
3368 td->visible = TRUE;
\r
3370 /* Sub windows (need these before term_getsize gets called) */
\r
3371 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3374 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
\r
3375 td->dwExStyle = (WS_EX_TOOLWINDOW);
\r
3380 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3384 #if 1 /* #ifdef JP */
\r
3385 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
\r
3386 td->lf.lfCharSet = DEFAULT_CHARSET;
\r
3387 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
\r
3388 /* Activate the chosen font */
\r
3389 term_force_font(td, NULL);
\r
3390 if(!td->tile_wid) td->tile_wid = td->font_wid;
\r
3391 if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
\r
3393 /* Access the standard font file */
\r
3394 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
\r
3396 /* Activate the chosen font */
\r
3397 if (term_force_font(td, buf))
\r
3399 /* Access the standard font file */
\r
3400 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
3402 /* Force the use of that font */
\r
3403 (void)term_force_font(td, buf);
\r
3407 td->tile_hgt = 13;
\r
3409 /* Assume not bizarre */
\r
3410 td->bizarre = FALSE;
\r
3415 /* Analyze the font */
\r
3418 /* Resize the window */
\r
3419 term_window_resize(td);
\r
3423 /* Sub windows (reverse order) */
\r
3424 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
\r
3429 td->w = CreateWindowEx(td->dwExStyle, AngList,
\r
3430 td->s, td->dwStyle,
\r
3431 td->pos_x, td->pos_y,
\r
3432 td->size_wid, td->size_hgt,
\r
3433 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3435 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
\r
3439 td->size_hack = TRUE;
\r
3440 ShowWindow(td->w, SW_SHOW);
\r
3441 td->size_hack = FALSE;
\r
3444 term_data_link(td);
\r
3445 angband_term[i] = &td->t;
\r
3449 /* Activate the window */
\r
3450 SetActiveWindow(td->w);
\r
3453 if (data[i].posfix)
\r
3455 term_window_pos(&data[i], HWND_TOPMOST);
\r
3459 term_window_pos(&data[i], td->w);
\r
3469 td->w = CreateWindowEx(td->dwExStyle, AppName,
\r
3470 td->s, td->dwStyle,
\r
3471 td->pos_x, td->pos_y,
\r
3472 td->size_wid, td->size_hgt,
\r
3473 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3475 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
\r
3477 term_data_link(td);
\r
3478 angband_term[0] = &td->t;
\r
3479 normsize.x = td->cols;
\r
3480 normsize.y = td->rows;
\r
3482 /* Activate the main window */
\r
3483 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
\r
3484 else ShowWindow(td->w, SW_SHOW);
\r
3486 /* Bring main window back to top */
\r
3487 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
3490 /* New palette XXX XXX XXX */
\r
3491 (void)new_palette();
\r
3494 /* Create a "brush" for drawing the "cursor" */
\r
3495 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
\r
3498 /* Process pending messages */
\r
3499 (void)Term_xtra_win_flush();
\r
3505 * Prepare the menus
\r
3507 static void setup_menus(void)
\r
3511 HMENU hm = GetMenu(data[0].w);
\r
3514 /* Menu "File", Disable all */
\r
3515 EnableMenuItem(hm, IDM_FILE_NEW,
\r
3516 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3517 EnableMenuItem(hm, IDM_FILE_OPEN,
\r
3518 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3519 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3520 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3521 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3522 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3523 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3524 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3527 /* No character available */
\r
3528 if (!character_generated)
\r
3530 /* Menu "File", Item "New" */
\r
3531 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
\r
3533 /* Menu "File", Item "Open" */
\r
3534 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
\r
3537 /* A character available */
\r
3538 if (character_generated)
\r
3540 /* Menu "File", Item "Save" */
\r
3541 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3542 MF_BYCOMMAND | MF_ENABLED);
\r
3545 /* Menu "File", Item "Exit" */
\r
3546 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3547 MF_BYCOMMAND | MF_ENABLED);
\r
3549 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3550 MF_BYCOMMAND | MF_ENABLED);
\r
3553 /* Menu "Window::Visibility" */
\r
3554 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3556 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3557 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3559 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3560 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
\r
3562 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3563 MF_BYCOMMAND | MF_ENABLED);
\r
3566 /* Menu "Window::Font" */
\r
3567 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3569 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3570 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3572 if (data[i].visible)
\r
3574 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3575 MF_BYCOMMAND | MF_ENABLED);
\r
3579 /* Menu "Window::Window Position Fix" */
\r
3580 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3582 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3583 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3585 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3586 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
\r
3588 if (data[i].visible)
\r
3590 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3591 MF_BYCOMMAND | MF_ENABLED);
\r
3595 /* Menu "Window::Bizarre Display" */
\r
3596 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3598 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3599 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3601 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3602 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
\r
3604 if (data[i].visible)
\r
3606 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3607 MF_BYCOMMAND | MF_ENABLED);
\r
3612 /* Menu "Window::Increase Tile Width" */
\r
3613 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3615 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3616 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3618 if (data[i].visible)
\r
3620 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3621 MF_BYCOMMAND | MF_ENABLED);
\r
3626 /* Menu "Window::Decrease Tile Width" */
\r
3627 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3629 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3630 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3632 if (data[i].visible)
\r
3634 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3635 MF_BYCOMMAND | MF_ENABLED);
\r
3640 /* Menu "Window::Increase Tile Height" */
\r
3641 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3643 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3644 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3646 if (data[i].visible)
\r
3648 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3649 MF_BYCOMMAND | MF_ENABLED);
\r
3654 /* Menu "Window::Decrease Tile Height" */
\r
3655 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3657 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3658 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3660 if (data[i].visible)
\r
3662 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3663 MF_BYCOMMAND | MF_ENABLED);
\r
3668 /* Menu "Options", disable all */
\r
3669 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3670 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3671 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3672 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3673 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3674 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3675 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3676 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3677 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3678 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3680 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3681 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3684 /* Menu "Options", Item "Map" */
\r
3685 if (use_graphics != GRAPHICS_NONE)
\r
3686 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
\r
3688 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
\r
3689 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3691 /* Menu "Options", update all */
\r
3692 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3693 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
\r
3694 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3695 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
\r
3696 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3697 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
\r
3698 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
\r
3699 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
\r
3700 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3701 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
\r
3702 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
\r
3703 (arg_music ? MF_CHECKED : MF_UNCHECKED));
\r
3704 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3705 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
\r
3706 CheckMenuItem(hm, IDM_OPTIONS_BG,
\r
3707 (use_bg ? MF_CHECKED : MF_UNCHECKED));
\r
3709 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3710 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
\r
3713 #ifdef USE_GRAPHICS
\r
3714 /* Menu "Options", Item "Graphics" */
\r
3715 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
\r
3716 /* Menu "Options", Item "Graphics" */
\r
3717 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
\r
3718 /* Menu "Options", Item "Graphics" */
\r
3719 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
\r
3720 /* Menu "Options", Item "Graphics" */
\r
3721 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
\r
3722 #endif /* USE_GRAPHICS */
\r
3725 /* Menu "Options", Item "Sound" */
\r
3726 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
\r
3727 #endif /* USE_SOUND */
\r
3730 /* Menu "Options", Item "ScreenSaver" */
\r
3731 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3732 MF_BYCOMMAND | MF_ENABLED);
\r
3733 #endif /* USE_SAVER */
\r
3738 * Check for double clicked (or dragged) savefile
\r
3740 * Apparently, Windows copies the entire filename into the first
\r
3741 * piece of the "command line string". Perhaps we should extract
\r
3742 * the "basename" of that filename and append it to the "save" dir.
\r
3744 static void check_for_save_file(LPSTR cmd_line)
\r
3754 /* Extract filename */
\r
3755 strcat(savefile, s);
\r
3757 /* Validate the file */
\r
3758 validate_file(savefile);
\r
3760 /* Game in progress */
\r
3761 game_in_progress = TRUE;
\r
3769 * Process a menu command
\r
3771 static void process_menus(WORD wCmd)
\r
3783 case IDM_FILE_NEW:
\r
3787 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3789 else if (game_in_progress)
\r
3791 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
\r
3795 game_in_progress = TRUE;
\r
3804 case IDM_FILE_OPEN:
\r
3808 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3810 else if (game_in_progress)
\r
3812 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
\r
3816 memset(&ofn, 0, sizeof(ofn));
\r
3817 ofn.lStructSize = sizeof(ofn);
\r
3818 ofn.hwndOwner = data[0].w;
\r
3819 ofn.lpstrFilter = "Save Files (*.)\0*\0";
\r
3820 ofn.nFilterIndex = 1;
\r
3821 ofn.lpstrFile = savefile;
\r
3822 ofn.nMaxFile = 1024;
\r
3823 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
\r
3824 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
\r
3826 if (GetOpenFileName(&ofn))
\r
3828 /* Load 'savefile' */
\r
3829 validate_file(savefile);
\r
3830 game_in_progress = TRUE;
\r
3840 case IDM_FILE_SAVE:
\r
3842 if (game_in_progress && character_generated)
\r
3847 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
\r
3851 /* Hack -- Forget messages */
\r
3854 /* Save the game */
\r
3856 do_cmd_save_game(FALSE);
\r
3857 #else /* ZANGBAND */
\r
3858 do_cmd_save_game();
\r
3859 #endif /* ZANGBAND */
\r
3863 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
\r
3869 case IDM_FILE_EXIT:
\r
3871 if (game_in_progress && character_generated)
\r
3876 plog(_("今は終了できません。", "You may not do that right now."));
\r
3880 /* Hack -- Forget messages */
\r
3887 /* Save the game */
\r
3889 /* do_cmd_save_game(FALSE); */
\r
3890 #else /* ZANGBAND */
\r
3891 /* do_cmd_save_game(); */
\r
3892 #endif /* ZANGBAND */
\r
3893 Term_key_push(SPECIAL_KEY_QUIT);
\r
3901 case IDM_FILE_SCORE:
\r
3905 /* Build the filename */
\r
3906 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
\r
3908 /* Open the binary high score file, for reading */
\r
3909 highscore_fd = fd_open(buf, O_RDONLY);
\r
3911 /* Paranoia -- No score file */
\r
3912 if (highscore_fd < 0)
\r
3914 msg_print("Score file unavailable.");
\r
3921 /* Clear screen */
\r
3924 /* Display the scores */
\r
3925 display_scores_aux(0, MAX_HISCORES, -1, NULL);
\r
3927 /* Shut the high score file */
\r
3928 (void)fd_close(highscore_fd);
\r
3930 /* Forget the high score fd */
\r
3931 highscore_fd = -1;
\r
3936 /* Hack - Flush it */
\r
3944 case IDM_FILE_MOVIE:
\r
3948 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3950 else if (game_in_progress)
\r
3952 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
\r
3956 memset(&ofn, 0, sizeof(ofn));
\r
3957 ofn.lStructSize = sizeof(ofn);
\r
3958 ofn.hwndOwner = data[0].w;
\r
3959 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
\r
3960 ofn.nFilterIndex = 1;
\r
3961 ofn.lpstrFile = savefile;
\r
3962 ofn.nMaxFile = 1024;
\r
3963 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
\r
3964 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
3966 if (GetOpenFileName(&ofn))
\r
3968 /* Load 'savefile' */
\r
3969 prepare_browse_movie_aux(savefile);
\r
3979 case IDM_WINDOW_VIS_0:
\r
3981 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
\r
3985 /* Window visibility */
\r
3986 case IDM_WINDOW_VIS_1:
\r
3987 case IDM_WINDOW_VIS_2:
\r
3988 case IDM_WINDOW_VIS_3:
\r
3989 case IDM_WINDOW_VIS_4:
\r
3990 case IDM_WINDOW_VIS_5:
\r
3991 case IDM_WINDOW_VIS_6:
\r
3992 case IDM_WINDOW_VIS_7:
\r
3994 i = wCmd - IDM_WINDOW_VIS_0;
\r
3996 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4002 td->visible = TRUE;
\r
4003 ShowWindow(td->w, SW_SHOW);
\r
4004 term_data_redraw(td);
\r
4008 td->visible = FALSE;
\r
4009 td->posfix = FALSE;
\r
4010 ShowWindow(td->w, SW_HIDE);
\r
4016 /* Window fonts */
\r
4017 case IDM_WINDOW_FONT_0:
\r
4018 case IDM_WINDOW_FONT_1:
\r
4019 case IDM_WINDOW_FONT_2:
\r
4020 case IDM_WINDOW_FONT_3:
\r
4021 case IDM_WINDOW_FONT_4:
\r
4022 case IDM_WINDOW_FONT_5:
\r
4023 case IDM_WINDOW_FONT_6:
\r
4024 case IDM_WINDOW_FONT_7:
\r
4026 i = wCmd - IDM_WINDOW_FONT_0;
\r
4028 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4032 term_change_font(td);
\r
4037 /* Window Z Position */
\r
4038 case IDM_WINDOW_POS_1:
\r
4039 case IDM_WINDOW_POS_2:
\r
4040 case IDM_WINDOW_POS_3:
\r
4041 case IDM_WINDOW_POS_4:
\r
4042 case IDM_WINDOW_POS_5:
\r
4043 case IDM_WINDOW_POS_6:
\r
4044 case IDM_WINDOW_POS_7:
\r
4046 i = wCmd - IDM_WINDOW_POS_0;
\r
4048 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4052 if (!td->posfix && td->visible)
\r
4054 td->posfix = TRUE;
\r
4055 term_window_pos(td, HWND_TOPMOST);
\r
4059 td->posfix = FALSE;
\r
4060 term_window_pos(td, data[0].w);
\r
4066 /* Bizarre Display */
\r
4067 case IDM_WINDOW_BIZ_0:
\r
4068 case IDM_WINDOW_BIZ_1:
\r
4069 case IDM_WINDOW_BIZ_2:
\r
4070 case IDM_WINDOW_BIZ_3:
\r
4071 case IDM_WINDOW_BIZ_4:
\r
4072 case IDM_WINDOW_BIZ_5:
\r
4073 case IDM_WINDOW_BIZ_6:
\r
4074 case IDM_WINDOW_BIZ_7:
\r
4076 i = wCmd - IDM_WINDOW_BIZ_0;
\r
4078 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4082 td->bizarre = !td->bizarre;
\r
4086 term_window_resize(td);
\r
4091 /* Increase Tile Width */
\r
4092 case IDM_WINDOW_I_WID_0:
\r
4093 case IDM_WINDOW_I_WID_1:
\r
4094 case IDM_WINDOW_I_WID_2:
\r
4095 case IDM_WINDOW_I_WID_3:
\r
4096 case IDM_WINDOW_I_WID_4:
\r
4097 case IDM_WINDOW_I_WID_5:
\r
4098 case IDM_WINDOW_I_WID_6:
\r
4099 case IDM_WINDOW_I_WID_7:
\r
4101 i = wCmd - IDM_WINDOW_I_WID_0;
\r
4103 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4107 td->tile_wid += 1;
\r
4111 term_window_resize(td);
\r
4116 /* Decrease Tile Height */
\r
4117 case IDM_WINDOW_D_WID_0:
\r
4118 case IDM_WINDOW_D_WID_1:
\r
4119 case IDM_WINDOW_D_WID_2:
\r
4120 case IDM_WINDOW_D_WID_3:
\r
4121 case IDM_WINDOW_D_WID_4:
\r
4122 case IDM_WINDOW_D_WID_5:
\r
4123 case IDM_WINDOW_D_WID_6:
\r
4124 case IDM_WINDOW_D_WID_7:
\r
4126 i = wCmd - IDM_WINDOW_D_WID_0;
\r
4128 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4132 td->tile_wid -= 1;
\r
4136 term_window_resize(td);
\r
4141 /* Increase Tile Height */
\r
4142 case IDM_WINDOW_I_HGT_0:
\r
4143 case IDM_WINDOW_I_HGT_1:
\r
4144 case IDM_WINDOW_I_HGT_2:
\r
4145 case IDM_WINDOW_I_HGT_3:
\r
4146 case IDM_WINDOW_I_HGT_4:
\r
4147 case IDM_WINDOW_I_HGT_5:
\r
4148 case IDM_WINDOW_I_HGT_6:
\r
4149 case IDM_WINDOW_I_HGT_7:
\r
4151 i = wCmd - IDM_WINDOW_I_HGT_0;
\r
4153 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4157 td->tile_hgt += 1;
\r
4161 term_window_resize(td);
\r
4166 /* Decrease Tile Height */
\r
4167 case IDM_WINDOW_D_HGT_0:
\r
4168 case IDM_WINDOW_D_HGT_1:
\r
4169 case IDM_WINDOW_D_HGT_2:
\r
4170 case IDM_WINDOW_D_HGT_3:
\r
4171 case IDM_WINDOW_D_HGT_4:
\r
4172 case IDM_WINDOW_D_HGT_5:
\r
4173 case IDM_WINDOW_D_HGT_6:
\r
4174 case IDM_WINDOW_D_HGT_7:
\r
4176 i = wCmd - IDM_WINDOW_D_HGT_0;
\r
4178 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4182 td->tile_hgt -= 1;
\r
4186 term_window_resize(td);
\r
4191 case IDM_OPTIONS_NO_GRAPHICS:
\r
4196 plog("You may not do that right now.");
\r
4200 /* Toggle "arg_graphics" */
\r
4201 if (arg_graphics != GRAPHICS_NONE)
\r
4203 arg_graphics = GRAPHICS_NONE;
\r
4205 /* React to changes */
\r
4206 Term_xtra_win_react();
\r
4208 /* Hack -- Force redraw */
\r
4209 Term_key_push(KTRL('R'));
\r
4215 case IDM_OPTIONS_OLD_GRAPHICS:
\r
4220 plog("You may not do that right now.");
\r
4224 /* Toggle "arg_graphics" */
\r
4225 if (arg_graphics != GRAPHICS_ORIGINAL)
\r
4227 arg_graphics = GRAPHICS_ORIGINAL;
\r
4229 /* React to changes */
\r
4230 Term_xtra_win_react();
\r
4232 /* Hack -- Force redraw */
\r
4233 Term_key_push(KTRL('R'));
\r
4239 case IDM_OPTIONS_NEW_GRAPHICS:
\r
4244 plog("You may not do that right now.");
\r
4248 /* Toggle "arg_graphics" */
\r
4249 if (arg_graphics != GRAPHICS_ADAM_BOLT)
\r
4251 arg_graphics = GRAPHICS_ADAM_BOLT;
\r
4253 /* React to changes */
\r
4254 Term_xtra_win_react();
\r
4256 /* Hack -- Force redraw */
\r
4257 Term_key_push(KTRL('R'));
\r
4263 case IDM_OPTIONS_NEW2_GRAPHICS:
\r
4268 plog("You may not do that right now.");
\r
4272 /* Toggle "arg_graphics" */
\r
4273 if (arg_graphics != GRAPHICS_HENGBAND)
\r
4275 arg_graphics = GRAPHICS_HENGBAND;
\r
4277 /* React to changes */
\r
4278 Term_xtra_win_react();
\r
4280 /* Hack -- Force redraw */
\r
4281 Term_key_push(KTRL('R'));
\r
4287 case IDM_OPTIONS_BIGTILE:
\r
4294 plog("You may not do that right now.");
\r
4298 /* Toggle "arg_sound" */
\r
4299 arg_bigtile = !arg_bigtile;
\r
4302 Term_activate(&td->t);
\r
4304 /* Resize the term */
\r
4305 Term_resize(td->cols, td->rows);
\r
4307 /* Redraw later */
\r
4308 InvalidateRect(td->w, NULL, TRUE);
\r
4313 case IDM_OPTIONS_MUSIC:
\r
4318 plog("You may not do that right now.");
\r
4322 /* Toggle "arg_sound" */
\r
4323 arg_music = !arg_music;
\r
4325 /* React to changes */
\r
4326 Term_xtra_win_react();
\r
4328 /* Hack -- Force redraw */
\r
4329 Term_key_push(KTRL('R'));
\r
4334 case IDM_OPTIONS_SOUND:
\r
4339 plog("You may not do that right now.");
\r
4343 /* Toggle "arg_sound" */
\r
4344 arg_sound = !arg_sound;
\r
4346 /* React to changes */
\r
4347 Term_xtra_win_react();
\r
4349 /* Hack -- Force redraw */
\r
4350 Term_key_push(KTRL('R'));
\r
4356 case IDM_OPTIONS_BG:
\r
4361 plog("You may not do that right now.");
\r
4365 /* Toggle "use_bg" */
\r
4370 /* React to changes */
\r
4371 Term_xtra_win_react();
\r
4373 /* Hack -- Force redraw */
\r
4374 Term_key_push(KTRL('R'));
\r
4380 case IDM_OPTIONS_OPEN_BG:
\r
4385 plog("You may not do that right now.");
\r
4390 memset(&ofn, 0, sizeof(ofn));
\r
4391 ofn.lStructSize = sizeof(ofn);
\r
4392 ofn.hwndOwner = data[0].w;
\r
4393 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
\r
4394 ofn.nFilterIndex = 1;
\r
4395 ofn.lpstrFile = bg_bitmap_file;
\r
4396 ofn.nMaxFile = 1023;
\r
4397 ofn.lpstrInitialDir = NULL;
\r
4398 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
\r
4399 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
\r
4401 if (GetOpenFileName(&ofn))
\r
4403 /* Load 'savefile' */
\r
4408 /* React to changes */
\r
4409 Term_xtra_win_react();
\r
4411 /* Hack -- Force redraw */
\r
4412 Term_key_push(KTRL('R'));
\r
4417 case IDM_DUMP_SCREEN_HTML:
\r
4419 static char buf[1024] = "";
\r
4420 memset(&ofn, 0, sizeof(ofn));
\r
4421 ofn.lStructSize = sizeof(ofn);
\r
4422 ofn.hwndOwner = data[0].w;
\r
4423 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
\r
4424 ofn.nFilterIndex = 1;
\r
4425 ofn.lpstrFile = buf;
\r
4426 ofn.nMaxFile = 1023;
\r
4427 ofn.lpstrDefExt = "html";
\r
4428 ofn.lpstrInitialDir = NULL;
\r
4429 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
\r
4430 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
\r
4432 if (GetSaveFileName(&ofn))
\r
4434 do_cmd_save_screen_html_aux(buf, 0);
\r
4441 case IDM_OPTIONS_SAVER:
\r
4445 DestroyWindow(hwndSaver);
\r
4450 /* Create a screen scaver window */
\r
4451 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
\r
4452 "Angband Screensaver",
\r
4453 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
\r
4454 0, 0, GetSystemMetrics(SM_CXSCREEN),
\r
4455 GetSystemMetrics(SM_CYSCREEN),
\r
4456 NULL, NULL, hInstance, NULL);
\r
4460 /* Push the window to the bottom XXX XXX XXX */
\r
4461 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
4465 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
\r
4473 case IDM_OPTIONS_MAP:
\r
4479 case IDM_HELP_CONTENTS:
\r
4483 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
\r
4484 if (check_file(tmp))
\r
4486 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
\r
4491 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4492 plog("代わりにオンラインヘルプを使用してください。");
\r
4494 plog_fmt("Cannot find help file: %s", tmp);
\r
4495 plog("Use the online help files instead.");
\r
4500 #else /* HTML_HELP */
\r
4503 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
\r
4504 if (check_file(tmp))
\r
4506 sprintf(buf, "winhelp.exe %s", tmp);
\r
4507 WinExec(buf, SW_NORMAL);
\r
4512 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4513 plog("代わりにオンラインヘルプを使用してください。");
\r
4515 plog_fmt("Cannot find help file: %s", tmp);
\r
4516 plog("Use the online help files instead.");
\r
4521 #endif /* HTML_HELP */
\r
4527 static bool process_keydown(WPARAM wParam, LPARAM lParam)
\r
4534 /* Extract the modifiers */
\r
4535 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
\r
4536 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
\r
4537 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
\r
4539 Term_no_press = (ma) ? TRUE : FALSE;
\r
4541 /* Handle "special" keys */
\r
4542 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
\r
4544 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
\r
4545 bool numpad = FALSE;
\r
4547 /* Begin the macro trigger */
\r
4548 Term_keypress(31);
\r
4550 /* Send the modifiers */
\r
4551 if (mc) Term_keypress('C');
\r
4552 if (ms) Term_keypress('S');
\r
4553 if (ma) Term_keypress('A');
\r
4555 /* Extract "scan code" */
\r
4556 i = LOBYTE(HIWORD(lParam));
\r
4558 /* Introduce the scan code */
\r
4559 Term_keypress('x');
\r
4561 /* Extended key bit */
\r
4564 /* Numpad Enter and '/' are extended key */
\r
4566 Term_no_press = TRUE;
\r
4567 case VK_RETURN: /* Enter */
\r
4570 /* Other extended keys are on full keyboard */
\r
4584 case VK_SEPARATOR:
\r
4586 Term_no_press = TRUE;
\r
4590 case VK_PRIOR: /* Page Up */
\r
4591 case VK_NEXT: /* Page Down */
\r
4598 numpad = !ext_key;
\r
4601 /* Special modifiers for keypad keys */
\r
4602 if (numpad) Term_keypress('K');
\r
4604 /* Encode the hexidecimal scan code */
\r
4605 Term_keypress(hexsym[i/16]);
\r
4606 Term_keypress(hexsym[i%16]);
\r
4608 /* End the macro trigger */
\r
4609 Term_keypress(13);
\r
4619 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4620 WPARAM wParam, LPARAM lParam);
\r
4621 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4622 WPARAM wParam, LPARAM lParam)
\r
4623 #else /* __MWERKS__ */
\r
4624 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4625 WPARAM wParam, LPARAM lParam)
\r
4626 #endif /* __MWERKS__ */
\r
4632 MINMAXINFO FAR *lpmmi;
\r
4638 /* Acquire proper "term_data" info */
\r
4639 td = (term_data *)GetWindowLong(hWnd, 0);
\r
4641 /* Handle message */
\r
4647 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
4655 mop.dwCallback=(DWORD)hWnd;
\r
4660 case WM_GETMINMAXINFO:
\r
4662 MINMAXINFO FAR *lpmmi;
\r
4665 lpmmi = (MINMAXINFO FAR *)lParam;
\r
4667 /* this message was sent before WM_NCCREATE */
\r
4668 if (!td) return 1;
\r
4670 /* Minimum window size is 80x24 */
\r
4671 rc.left = rc.top = 0;
\r
4672 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
4673 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
4676 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
4678 /* Save minimum size */
\r
4679 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
4680 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
4687 BeginPaint(hWnd, &ps);
\r
4688 if (td) term_data_redraw(td);
\r
4689 EndPaint(hWnd, &ps);
\r
4690 ValidateRect(hWnd, NULL);
\r
4695 case MM_MCINOTIFY:
\r
4697 if(wParam == MCI_NOTIFY_SUCCESSFUL)
\r
4699 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
4700 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
4706 case WM_SYSKEYDOWN:
\r
4709 if (process_keydown(wParam, lParam))
\r
4716 if (Term_no_press) Term_no_press = FALSE;
\r
4717 else Term_keypress(wParam);
\r
4721 case WM_LBUTTONDOWN:
\r
4723 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4724 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4725 mouse_down = TRUE;
\r
4731 case WM_LBUTTONUP:
\r
4736 TERM_LEN dx = abs(oldx - mousex) + 1;
\r
4737 TERM_LEN dy = abs(oldy - mousey) + 1;
\r
4738 TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
\r
4739 TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
\r
4741 mouse_down = FALSE;
\r
4742 paint_rect = FALSE;
\r
4745 sz = (dx + 3) * dy;
\r
4747 sz = (dx + 2) * dy;
\r
4749 hGlobal = GlobalAlloc(GHND, sz + 1);
\r
4750 if (hGlobal == NULL) return 0;
\r
4751 lpStr = (LPSTR)GlobalLock(hGlobal);
\r
4753 for (i = 0; i < dy; i++)
\r
4757 char **scr = data[0].t.scr->c;
\r
4759 C_MAKE(s, (dx + 1), char);
\r
4760 strncpy(s, &scr[oy + i][ox], dx);
\r
4764 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
\r
4767 if (ox + dx < data[0].cols)
\r
4769 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
\r
4772 for (j = 0; j < dx; j++)
\r
4774 if (s[j] == 127) s[j] = '#';
\r
4778 for (j = 0; j < dx; j++)
\r
4780 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
\r
4790 GlobalUnlock(hGlobal);
\r
4791 if (OpenClipboard(hWnd) == 0)
\r
4793 GlobalFree(hGlobal);
\r
4797 SetClipboardData(CF_TEXT, hGlobal);
\r
4805 case WM_MOUSEMOVE:
\r
4810 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4811 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4816 dx = abs(oldx - mousex) + 1;
\r
4817 dy = abs(oldy - mousey) + 1;
\r
4818 ox = (oldx > mousex) ? mousex : oldx;
\r
4819 oy = (oldy > mousey) ? mousey : oldy;
\r
4820 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4824 paint_rect = TRUE;
\r
4827 dx = abs(cx - mousex) + 1;
\r
4828 dy = abs(cy - mousey) + 1;
\r
4829 ox = (cx > mousex) ? mousex : cx;
\r
4830 oy = (cy > mousey) ? mousey : cy;
\r
4831 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4847 if (game_in_progress && character_generated)
\r
4851 plog(_("今は終了できません。", "You may not do that right now."));
\r
4855 /* Hack -- Forget messages */
\r
4862 /* Save the game */
\r
4864 /* do_cmd_save_game(FALSE); */
\r
4865 #else /* ZANGBAND */
\r
4866 /* do_cmd_save_game(); */
\r
4867 #endif /* ZANGBAND */
\r
4868 Term_key_push(SPECIAL_KEY_QUIT);
\r
4875 case WM_QUERYENDSESSION:
\r
4877 if (game_in_progress && character_generated)
\r
4879 /* Hack -- Forget messages */
\r
4882 /* Mega-Hack -- Delay death */
\r
4883 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
\r
4884 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
\r
4886 /* Hardcode panic save */
\r
4887 p_ptr->panic_save = 1;
\r
4889 /* Forbid suspend */
\r
4890 signals_ignore_tstp();
\r
4892 /* Indicate panic save */
\r
4893 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
\r
4896 (void)save_player();
\r
4910 process_menus(LOWORD(wParam));
\r
4916 /* this message was sent before WM_NCCREATE */
\r
4917 if (!td) return 1;
\r
4919 /* it was sent from inside CreateWindowEx */
\r
4920 if (!td->w) return 1;
\r
4922 /* was sent from WM_SIZE */
\r
4923 if (td->size_hack) return 1;
\r
4927 case SIZE_MINIMIZED:
\r
4929 /* Hide sub-windows */
\r
4930 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4932 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
\r
4937 case SIZE_MAXIMIZED:
\r
4939 /* fall through XXX XXX XXX */
\r
4942 case SIZE_RESTORED:
\r
4944 TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
4945 TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
4948 if ((td->cols != cols) || (td->rows != rows))
\r
4950 /* Save the new size */
\r
4954 if (!IsZoomed(td->w) && !IsIconic(td->w))
\r
4956 normsize.x = td->cols;
\r
4957 normsize.y = td->rows;
\r
4961 Term_activate(&td->t);
\r
4963 /* Resize the term */
\r
4964 Term_resize(td->cols, td->rows);
\r
4966 /* Redraw later */
\r
4967 InvalidateRect(td->w, NULL, TRUE);
\r
4970 td->size_hack = TRUE;
\r
4972 /* Show sub-windows */
\r
4973 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4975 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
\r
4978 td->size_hack = FALSE;
\r
4986 case WM_PALETTECHANGED:
\r
4988 /* Ignore if palette change caused by itself */
\r
4989 if ((HWND)wParam == hWnd) return 0;
\r
4991 /* Fall through... */
\r
4994 case WM_QUERYNEWPALETTE:
\r
4996 if (!paletted) return 0;
\r
4998 hdc = GetDC(hWnd);
\r
5000 SelectPalette(hdc, hPal, FALSE);
\r
5002 i = RealizePalette(hdc);
\r
5004 /* if any palette entries changed, repaint the window. */
\r
5005 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5007 ReleaseDC(hWnd, hdc);
\r
5014 if (wParam && !HIWORD(lParam))
\r
5016 /* Do something to sub-windows */
\r
5017 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5019 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
\r
5022 /* Focus on main window */
\r
5031 case WM_ACTIVATEAPP:
\r
5033 if (IsIconic(td->w)) break;
\r
5035 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5037 if(data[i].visible)
\r
5039 if (wParam == TRUE)
\r
5041 ShowWindow(data[i].w, SW_SHOW);
\r
5045 ShowWindow(data[i].w, SW_HIDE);
\r
5052 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5057 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5058 WPARAM wParam, LPARAM lParam);
\r
5059 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5060 WPARAM wParam, LPARAM lParam)
\r
5061 #else /* __MWERKS__ */
\r
5062 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5063 WPARAM wParam, LPARAM lParam)
\r
5064 #endif /* __MWERKS__ */
\r
5068 MINMAXINFO FAR *lpmmi;
\r
5076 /* Acquire proper "term_data" info */
\r
5077 td = (term_data *)GetWindowLong(hWnd, 0);
\r
5079 /* Process message */
\r
5085 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
5095 case WM_GETMINMAXINFO:
\r
5097 MINMAXINFO FAR *lpmmi;
\r
5100 lpmmi = (MINMAXINFO FAR *)lParam;
\r
5102 /* this message was sent before WM_NCCREATE */
\r
5103 if (!td) return 1;
\r
5105 /* Minimum window size is 80x24 */
\r
5106 rc.left = rc.top = 0;
\r
5107 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
5108 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
5111 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
5113 /* Save minimum size */
\r
5114 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
5115 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
5125 /* this message was sent before WM_NCCREATE */
\r
5126 if (!td) return 1;
\r
5128 /* it was sent from inside CreateWindowEx */
\r
5129 if (!td->w) return 1;
\r
5131 /* was sent from inside WM_SIZE */
\r
5132 if (td->size_hack) return 1;
\r
5134 td->size_hack = TRUE;
\r
5136 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
5137 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
5140 if ((td->cols != cols) || (td->rows != rows))
\r
5142 /* Save old term */
\r
5143 term *old_term = Term;
\r
5145 /* Save the new size */
\r
5150 Term_activate(&td->t);
\r
5152 /* Resize the term */
\r
5153 Term_resize(td->cols, td->rows);
\r
5156 Term_activate(old_term);
\r
5158 /* Redraw later */
\r
5159 InvalidateRect(td->w, NULL, TRUE);
\r
5161 /* HACK - Redraw all windows */
\r
5162 p_ptr->window = 0xFFFFFFFF;
\r
5166 td->size_hack = FALSE;
\r
5173 BeginPaint(hWnd, &ps);
\r
5174 if (td) term_data_redraw(td);
\r
5175 EndPaint(hWnd, &ps);
\r
5179 case WM_SYSKEYDOWN:
\r
5182 if (process_keydown(wParam, lParam))
\r
5189 if (Term_no_press) Term_no_press = FALSE;
\r
5190 else Term_keypress(wParam);
\r
5194 case WM_PALETTECHANGED:
\r
5196 /* ignore if palette change caused by itself */
\r
5197 if ((HWND)wParam == hWnd) return FALSE;
\r
5198 /* otherwise, fall through!!! */
\r
5201 case WM_QUERYNEWPALETTE:
\r
5203 if (!paletted) return 0;
\r
5204 hdc = GetDC(hWnd);
\r
5205 SelectPalette(hdc, hPal, FALSE);
\r
5206 i = RealizePalette(hdc);
\r
5207 /* if any palette entries changed, repaint the window. */
\r
5208 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5209 ReleaseDC(hWnd, hdc);
\r
5213 case WM_NCLBUTTONDOWN:
\r
5217 if (wParam == HTCLOSE) wParam = HTSYSMENU;
\r
5218 #endif /* HTCLOSE */
\r
5220 if (wParam == HTSYSMENU)
\r
5224 td->visible = FALSE;
\r
5225 ShowWindow(td->w, SW_HIDE);
\r
5235 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5241 #define MOUSE_SENS 40
\r
5244 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5245 WPARAM wParam, LPARAM lParam);
\r
5246 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5247 WPARAM wParam, LPARAM lParam)
\r
5248 #else /* __MWERKS__ */
\r
5249 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5250 WPARAM wParam, LPARAM lParam)
\r
5251 #endif /* __MWERKS__ */
\r
5253 static int iMouse = 0;
\r
5254 static WORD xMouse = 0;
\r
5255 static WORD yMouse = 0;
\r
5269 case WM_SETCURSOR:
\r
5278 if (LOWORD(wParam) == WA_INACTIVE) break;
\r
5280 /* else fall through */
\r
5284 case WM_LBUTTONDOWN:
\r
5285 case WM_MBUTTONDOWN:
\r
5286 case WM_RBUTTONDOWN:
\r
5289 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5293 case WM_MOUSEMOVE:
\r
5297 dx = LOWORD(lParam) - xMouse;
\r
5298 dy = HIWORD(lParam) - yMouse;
\r
5300 if (dx < 0) dx = -dx;
\r
5301 if (dy < 0) dy = -dy;
\r
5303 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
\r
5305 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5309 /* Save last location */
\r
5311 xMouse = LOWORD(lParam);
\r
5312 yMouse = HIWORD(lParam);
\r
5319 DestroyWindow(hwndSaver);
\r
5326 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5329 #endif /* USE_SAVER */
\r
5335 /*** Temporary Hooks ***/
\r
5339 * Display warning message (see "z-util.c")
\r
5341 static void hack_plog(cptr str)
\r
5343 /* Give a warning */
\r
5347 MessageBox(NULL, str, "警告!",
\r
5348 MB_ICONEXCLAMATION | MB_OK);
\r
5350 MessageBox(NULL, str, "Warning",
\r
5351 MB_ICONEXCLAMATION | MB_OK);
\r
5359 * Display error message and quit (see "z-util.c")
\r
5361 static void hack_quit(cptr str)
\r
5363 /* Give a warning */
\r
5367 MessageBox(NULL, str, "エラー!",
\r
5368 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5370 MessageBox(NULL, str, "Error",
\r
5371 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5376 /* Unregister the classes */
\r
5377 UnregisterClass(AppName, hInstance);
\r
5379 /* Destroy the icon */
\r
5380 if (hIcon) DestroyIcon(hIcon);
\r
5388 /*** Various hooks ***/
\r
5392 * Display warning message (see "z-util.c")
\r
5394 static void hook_plog(cptr str)
\r
5400 MessageBox(data[0].w, str, "警告!",
\r
5401 MB_ICONEXCLAMATION | MB_OK);
\r
5403 MessageBox(data[0].w, str, "Warning",
\r
5404 MB_ICONEXCLAMATION | MB_OK);
\r
5412 * Display error message and quit (see "z-util.c")
\r
5414 static void hook_quit(cptr str)
\r
5419 /* Give a warning */
\r
5423 MessageBox(data[0].w, str, "エラー!",
\r
5424 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5426 MessageBox(data[0].w, str, "Error",
\r
5427 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5433 /* Save the preferences */
\r
5437 /*** Could use 'Term_nuke_win()' XXX XXX XXX */
\r
5439 /* Destroy all windows */
\r
5440 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
\r
5442 term_force_font(&data[i], NULL);
\r
5443 if (data[i].font_want) string_free(data[i].font_want);
\r
5444 if (data[i].w) DestroyWindow(data[i].w);
\r
5448 /* Free the bitmap stuff */
\r
5449 #ifdef USE_GRAPHICS
\r
5450 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
\r
5451 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
\r
5453 if (infMask.hPalette) DeleteObject(infMask.hPalette);
\r
5454 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
\r
5456 #endif /* USE_GRAPHICS */
\r
5458 /*** Free some other stuff ***/
\r
5460 DeleteObject(hbrYellow);
\r
5465 if (hPal) DeleteObject(hPal);
\r
5467 UnregisterClass(AppName, hInstance);
\r
5469 if (hIcon) DestroyIcon(hIcon);
\r
5476 /*** Initialize ***/
\r
5482 static void init_stuff(void)
\r
5489 /* Get program name with full path */
\r
5490 GetModuleFileName(hInstance, path, 512);
\r
5492 /* Save the "program name" XXX XXX XXX */
\r
5495 /* Get the name of the "*.ini" file */
\r
5496 strcpy(path + strlen(path) - 4, ".INI");
\r
5498 /* Save the the name of the ini-file */
\r
5499 ini_file = string_make(path);
\r
5501 /* Analyze the path */
\r
5504 /* Get the path */
\r
5505 for (; i > 0; i--)
\r
5507 if (path[i] == '\\')
\r
5514 /* Add "lib" to the path */
\r
5515 strcpy(path + i + 1, "lib\\");
\r
5517 /* Validate the path */
\r
5518 validate_dir(path, TRUE);
\r
5520 /* Init the file paths */
\r
5521 init_file_paths(path);
\r
5523 /* Hack -- Validate the paths */
\r
5524 validate_dir(ANGBAND_DIR_APEX, FALSE);
\r
5525 validate_dir(ANGBAND_DIR_BONE, FALSE);
\r
5527 /* Allow missing 'edit' directory */
\r
5528 if (!check_dir(ANGBAND_DIR_EDIT))
\r
5530 /* Must have 'data'! */
\r
5531 validate_dir(ANGBAND_DIR_DATA, TRUE);
\r
5535 /* Don't need 'data' */
\r
5536 validate_dir(ANGBAND_DIR_DATA, FALSE);
\r
5539 validate_dir(ANGBAND_DIR_FILE, TRUE);
\r
5540 validate_dir(ANGBAND_DIR_HELP, FALSE);
\r
5541 validate_dir(ANGBAND_DIR_INFO, FALSE);
\r
5542 validate_dir(ANGBAND_DIR_PREF, TRUE);
\r
5543 validate_dir(ANGBAND_DIR_SAVE, FALSE);
\r
5544 validate_dir(ANGBAND_DIR_USER, TRUE);
\r
5545 validate_dir(ANGBAND_DIR_XTRA, TRUE);
\r
5547 /* Build the filename */
\r
5548 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
\r
5550 /* Hack -- Validate the "news.txt" file */
\r
5551 validate_file(path);
\r
5554 #if 0 /* #ifndef JP */
\r
5555 /* Build the "font" path */
\r
5556 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
\r
5558 /* Allocate the path */
\r
5559 ANGBAND_DIR_XTRA_FONT = string_make(path);
\r
5561 /* Validate the "font" directory */
\r
5562 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
\r
5564 /* Build the filename */
\r
5565 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
5567 /* Hack -- Validate the basic font */
\r
5568 validate_file(path);
\r
5572 #ifdef USE_GRAPHICS
\r
5574 /* Build the "graf" path */
\r
5575 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
\r
5577 /* Allocate the path */
\r
5578 ANGBAND_DIR_XTRA_GRAF = string_make(path);
\r
5580 /* Validate the "graf" directory */
\r
5581 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
\r
5583 #endif /* USE_GRAPHICS */
\r
5588 /* Build the "sound" path */
\r
5589 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
\r
5591 /* Allocate the path */
\r
5592 ANGBAND_DIR_XTRA_SOUND = string_make(path);
\r
5594 /* Validate the "sound" directory */
\r
5595 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
\r
5597 #endif /* USE_SOUND */
\r
5601 /* Build the "music" path */
\r
5602 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
\r
5604 /* Allocate the path */
\r
5605 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
\r
5607 /* Validate the "music" directory */
\r
5608 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
\r
5610 #endif /* USE_MUSIC */
\r
5612 /* Build the "help" path */
\r
5613 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
\r
5615 /* Allocate the path */
\r
5616 ANGBAND_DIR_XTRA_HELP = string_make(path);
\r
5618 /* Validate the "help" directory */
\r
5619 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
\r
5623 * @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
\r
5625 static bool is_already_running(void)
\r
5627 bool result = FALSE;
\r
5630 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
\r
5631 if (GetLastError() == ERROR_ALREADY_EXISTS)
\r
5640 * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
\r
5642 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
\r
5643 LPSTR lpCmdLine, int nCmdShow)
\r
5651 setlocale( LC_ALL, "ja_JP" );
\r
5656 /* Save globally */
\r
5657 hInstance = hInst;
\r
5660 /* Prevent multiple run */
\r
5661 if (is_already_running())
\r
5664 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
\r
5665 _("エラー!", "Error") ,
\r
5666 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5671 if (hPrevInst == NULL)
\r
5673 wc.style = CS_CLASSDC;
\r
5674 wc.lpfnWndProc = AngbandWndProc;
\r
5675 wc.cbClsExtra = 0;
\r
5676 wc.cbWndExtra = 4; /* one long pointer to term_data */
\r
5677 wc.hInstance = hInst;
\r
5678 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
\r
5679 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
\r
5680 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
\r
5681 wc.lpszMenuName = AppName;
\r
5682 wc.lpszClassName = AppName;
\r
5684 if (!RegisterClass(&wc)) exit(1);
\r
5686 wc.lpfnWndProc = AngbandListProc;
\r
5687 wc.lpszMenuName = NULL;
\r
5688 wc.lpszClassName = AngList;
\r
5690 if (!RegisterClass(&wc)) exit(2);
\r
5694 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
\r
5695 wc.lpfnWndProc = AngbandSaverProc;
\r
5696 wc.hCursor = NULL;
\r
5697 wc.lpszMenuName = NULL;
\r
5698 wc.lpszClassName = "WindowsScreenSaverClass";
\r
5700 if (!RegisterClass(&wc)) exit(3);
\r
5706 /* Temporary hooks */
\r
5707 plog_aux = hack_plog;
\r
5708 quit_aux = hack_quit;
\r
5709 core_aux = hack_quit;
\r
5711 /* Prepare the filepaths */
\r
5714 /* Initialize the keypress analyzer */
\r
5715 for (i = 0; special_key_list[i]; ++i)
\r
5717 special_key[special_key_list[i]] = TRUE;
\r
5719 /* Initialize the keypress analyzer */
\r
5720 for (i = 0; ignore_key_list[i]; ++i)
\r
5722 ignore_key[ignore_key_list[i]] = TRUE;
\r
5725 /* Determine if display is 16/256/true color */
\r
5726 hdc = GetDC(NULL);
\r
5727 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
\r
5728 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
\r
5729 ReleaseDC(NULL, hdc);
\r
5731 /* Initialize the colors */
\r
5732 for (i = 0; i < 256; i++)
\r
5736 /* Extract desired values */
\r
5737 rv = angband_color_table[i][1];
\r
5738 gv = angband_color_table[i][2];
\r
5739 bv = angband_color_table[i][3];
\r
5741 /* Extract the "complex" code */
\r
5742 win_clr[i] = PALETTERGB(rv, gv, bv);
\r
5744 /* Save the "simple" code */
\r
5745 angband_color_table[i][0] = win_pal[i];
\r
5748 /* Prepare the windows */
\r
5754 /* Activate hooks */
\r
5755 plog_aux = hook_plog;
\r
5756 quit_aux = hook_quit;
\r
5757 core_aux = hook_quit;
\r
5759 /* Set the system suffix */
\r
5760 ANGBAND_SYS = "win";
\r
5762 /* Set the keyboard suffix */
\r
5763 if (7 != GetKeyboardType(0))
\r
5764 ANGBAND_KEYBOARD = "0";
\r
5767 /* Japanese keyboard */
\r
5768 switch (GetKeyboardType(1))
\r
5770 case 0x0D01: case 0x0D02:
\r
5771 case 0x0D03: case 0x0D04:
\r
5772 case 0x0D05: case 0x0D06:
\r
5774 ANGBAND_KEYBOARD = "NEC98";
\r
5778 ANGBAND_KEYBOARD = "JAPAN";
\r
5782 /* Catch nasty signals */
\r
5786 Term_activate(term_screen);
\r
5789 /* We are now initialized */
\r
5790 initialized = TRUE;
\r
5792 if(lpCmdLine[0] == '-'){
\r
5793 switch(lpCmdLine[1])
\r
5798 if (!lpCmdLine[2]) break;
\r
5799 chuukei_server = TRUE;
\r
5800 if(connect_chuukei_server(&lpCmdLine[2])<0){
\r
5801 msg_print("connect fail");
\r
5804 msg_print("connect");
\r
5812 if (!lpCmdLine[2]) break;
\r
5813 chuukei_client = TRUE;
\r
5814 connect_chuukei_server(&lpCmdLine[2]);
\r
5822 if (!lpCmdLine[2]) break;
\r
5823 prepare_browse_movie(&lpCmdLine[2]);
\r
5833 /* Did the user double click on a save file? */
\r
5834 if(!chuukei_server) check_for_save_file(lpCmdLine);
\r
5836 /* Did the user double click on a save file? */
\r
5837 check_for_save_file(lpCmdLine);
\r
5840 /* Prompt the user */
\r
5841 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
\r
5845 /* Process messages forever */
\r
5846 while (GetMessage(&msg, NULL, 0, 0))
\r
5848 TranslateMessage(&msg);
\r
5849 DispatchMessage(&msg);
\r
5860 #endif /* WINDOWS */
\r