3 * @brief Windows版固有実装(メインエントリポイント含む)
\r
5 * @author Hengband Team
\r
9 * Windows98かその前後の頃を起点としたAPI実装。
\r
11 * DirectXといった昨今描画に標準的となったライブラリも用いていない。
\r
12 * タイルの描画処理などについては、現在動作の詳細を検証中。
\r
16 * Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others
\r
18 * This software may be copied and distributed for educational, research,
\r
19 * and not for profit purposes provided that this copyright and statement
\r
20 * are included in all such copies.
\r
23 * This file helps Angband work with Windows computers.
\r
25 * To use this file, use an appropriate "Makefile" or "Project File",
\r
26 * make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and
\r
27 * make sure to obtain various extra files as described below.
\r
29 * The official compilation uses the CodeWarrior Pro compiler, which
\r
30 * includes a special project file and precompilable header file.
\r
34 * <del>See also "main-dos.c" and "main-ibm.c".</del>
\r
38 * The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
\r
39 * and/or color redefinitions.
\r
43 * The "lib/user/font-win.prf" contains attr/char mappings for use with the
\r
44 * normal "lib/xtra/font/*.fon" font files.
\r
48 * The "lib/user/graf-win.prf" contains attr/char mappings for use with the
\r
49 * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
\r
54 * Compiling this file, and using the resulting executable, requires
\r
55 * several extra files not distributed with the standard Angband code.
\r
56 * If "USE_GRAPHICS" is defined, then "readdib.h" and "readdib.c" must
\r
57 * be placed into "src/", and the "8X8.BMP" bitmap file must be placed
\r
58 * into "lib/xtra/graf". In any case, some "*.fon" files (including
\r
59 * "8X13.FON" if nothing else) must be placed into "lib/xtra/font/".
\r
60 * If "USE_SOUND" is defined, then some special library (for example,
\r
61 * "winmm.lib") may need to be linked in, and desired "*.WAV" sound
\r
62 * files must be placed into "lib/xtra/sound/". All of these extra
\r
63 * files can be found in the "ext-win" archive.
\r
67 * The "Term_xtra_win_clear()" function should probably do a low-level
\r
68 * clear of the current window, and redraw the borders and other things,
\r
69 * if only for efficiency. XXX XXX XXX
\r
73 * A simpler method is needed for selecting the "tile size" for windows.
\r
78 * The various "warning" messages assume the existance of the "screen.w"
\r
79 * window, I think, and only a few calls actually check for its existance,
\r
80 * this may be okay since "NULL" means "on top of all windows". (?) The
\r
81 * user must never be allowed to "hide" the main window, or the "menubar"
\r
82 * will disappear. XXX XXX XXX
\r
86 * Special "Windows Help Files" can be placed into "lib/xtra/help/" for
\r
87 * use with the "winhelp.exe" program. These files *may* be available
\r
88 * at the ftp site somewhere, but I have not seen them. XXX XXX XXX
\r
92 * Initial framework (and most code) by Ben Harrison (benh@phial.com).
\r
94 * Original code by Skirmantas Kligys (kligys@scf.usc.edu).
\r
96 * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
\r
97 * and Chris R. Martin (crm7479@tam2000.tamu.edu).
\r
101 #include "angband.h"
\r
104 #include <windows.h>
\r
105 #include <direct.h>
\r
106 #include <locale.h>
\r
107 #include "z-term.h"
\r
110 * Extract the "WIN32" flag from the compiler
\r
112 #if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__)
\r
120 * Hack -- allow use of "screen saver" mode
\r
126 * Menu constants -- see "ANGBAND.RC"
\r
129 #define IDM_FILE_NEW 100
\r
130 #define IDM_FILE_OPEN 101
\r
131 #define IDM_FILE_SAVE 110
\r
132 #define IDM_FILE_SCORE 120
\r
133 #define IDM_FILE_MOVIE 121
\r
134 #define IDM_FILE_EXIT 130
\r
136 #define IDM_WINDOW_VIS_0 200
\r
137 #define IDM_WINDOW_VIS_1 201
\r
138 #define IDM_WINDOW_VIS_2 202
\r
139 #define IDM_WINDOW_VIS_3 203
\r
140 #define IDM_WINDOW_VIS_4 204
\r
141 #define IDM_WINDOW_VIS_5 205
\r
142 #define IDM_WINDOW_VIS_6 206
\r
143 #define IDM_WINDOW_VIS_7 207
\r
145 #define IDM_WINDOW_FONT_0 210
\r
146 #define IDM_WINDOW_FONT_1 211
\r
147 #define IDM_WINDOW_FONT_2 212
\r
148 #define IDM_WINDOW_FONT_3 213
\r
149 #define IDM_WINDOW_FONT_4 214
\r
150 #define IDM_WINDOW_FONT_5 215
\r
151 #define IDM_WINDOW_FONT_6 216
\r
152 #define IDM_WINDOW_FONT_7 217
\r
154 #define IDM_WINDOW_POS_0 220
\r
155 #define IDM_WINDOW_POS_1 221
\r
156 #define IDM_WINDOW_POS_2 222
\r
157 #define IDM_WINDOW_POS_3 223
\r
158 #define IDM_WINDOW_POS_4 224
\r
159 #define IDM_WINDOW_POS_5 225
\r
160 #define IDM_WINDOW_POS_6 226
\r
161 #define IDM_WINDOW_POS_7 227
\r
163 #define IDM_WINDOW_BIZ_0 230
\r
164 #define IDM_WINDOW_BIZ_1 231
\r
165 #define IDM_WINDOW_BIZ_2 232
\r
166 #define IDM_WINDOW_BIZ_3 233
\r
167 #define IDM_WINDOW_BIZ_4 234
\r
168 #define IDM_WINDOW_BIZ_5 235
\r
169 #define IDM_WINDOW_BIZ_6 236
\r
170 #define IDM_WINDOW_BIZ_7 237
\r
172 #define IDM_WINDOW_I_WID_0 240
\r
173 #define IDM_WINDOW_I_WID_1 241
\r
174 #define IDM_WINDOW_I_WID_2 242
\r
175 #define IDM_WINDOW_I_WID_3 243
\r
176 #define IDM_WINDOW_I_WID_4 244
\r
177 #define IDM_WINDOW_I_WID_5 245
\r
178 #define IDM_WINDOW_I_WID_6 246
\r
179 #define IDM_WINDOW_I_WID_7 247
\r
181 #define IDM_WINDOW_D_WID_0 250
\r
182 #define IDM_WINDOW_D_WID_1 251
\r
183 #define IDM_WINDOW_D_WID_2 252
\r
184 #define IDM_WINDOW_D_WID_3 253
\r
185 #define IDM_WINDOW_D_WID_4 254
\r
186 #define IDM_WINDOW_D_WID_5 255
\r
187 #define IDM_WINDOW_D_WID_6 256
\r
188 #define IDM_WINDOW_D_WID_7 257
\r
190 #define IDM_WINDOW_I_HGT_0 260
\r
191 #define IDM_WINDOW_I_HGT_1 261
\r
192 #define IDM_WINDOW_I_HGT_2 262
\r
193 #define IDM_WINDOW_I_HGT_3 263
\r
194 #define IDM_WINDOW_I_HGT_4 264
\r
195 #define IDM_WINDOW_I_HGT_5 265
\r
196 #define IDM_WINDOW_I_HGT_6 266
\r
197 #define IDM_WINDOW_I_HGT_7 267
\r
199 #define IDM_WINDOW_D_HGT_0 270
\r
200 #define IDM_WINDOW_D_HGT_1 271
\r
201 #define IDM_WINDOW_D_HGT_2 272
\r
202 #define IDM_WINDOW_D_HGT_3 273
\r
203 #define IDM_WINDOW_D_HGT_4 274
\r
204 #define IDM_WINDOW_D_HGT_5 275
\r
205 #define IDM_WINDOW_D_HGT_6 276
\r
206 #define IDM_WINDOW_D_HGT_7 277
\r
208 #define IDM_OPTIONS_NO_GRAPHICS 400
\r
209 #define IDM_OPTIONS_OLD_GRAPHICS 401
\r
210 #define IDM_OPTIONS_NEW_GRAPHICS 402
\r
211 #define IDM_OPTIONS_NEW2_GRAPHICS 403
\r
212 #define IDM_OPTIONS_BIGTILE 409
\r
213 #define IDM_OPTIONS_SOUND 410
\r
214 #define IDM_OPTIONS_MUSIC 411
\r
215 #define IDM_OPTIONS_SAVER 420
\r
216 #define IDM_OPTIONS_MAP 430
\r
217 #define IDM_OPTIONS_BG 440
\r
218 #define IDM_OPTIONS_OPEN_BG 441
\r
220 #define IDM_DUMP_SCREEN_HTML 450
\r
222 #define IDM_HELP_CONTENTS 901
\r
227 * This may need to be removed for some compilers XXX XXX XXX
\r
234 * Exclude parts of WINDOWS.H that are not needed
\r
236 #define NOCOMM /* Comm driver APIs and definitions */
\r
237 #define NOLOGERROR /* LogError() and related definitions */
\r
238 #define NOPROFILER /* Profiler APIs */
\r
239 #define NOLFILEIO /* _l* file I/O routines */
\r
240 #define NOOPENFILE /* OpenFile and related definitions */
\r
241 #define NORESOURCE /* Resource management */
\r
242 #define NOATOM /* Atom management */
\r
243 #define NOLANGUAGE /* Character test routines */
\r
244 #define NOLSTRING /* lstr* string management routines */
\r
245 #define NODBCS /* Double-byte character set routines */
\r
246 #define NOKEYBOARDINFO /* Keyboard driver routines */
\r
247 #define NOCOLOR /* COLOR_* color values */
\r
248 #define NODRAWTEXT /* DrawText() and related definitions */
\r
249 #define NOSCALABLEFONT /* Truetype scalable font support */
\r
250 #define NOMETAFILE /* Metafile support */
\r
251 #define NOSYSTEMPARAMSINFO /* SystemParametersInfo() and SPI_* definitions */
\r
252 #define NODEFERWINDOWPOS /* DeferWindowPos and related definitions */
\r
253 #define NOKEYSTATES /* MK_* message key state flags */
\r
254 #define NOWH /* SetWindowsHook and related WH_* definitions */
\r
255 #define NOCLIPBOARD /* Clipboard APIs and definitions */
\r
256 #define NOICONS /* IDI_* icon IDs */
\r
257 #define NOMDI /* MDI support */
\r
258 #define NOHELP /* Help support */
\r
260 /* Not defined since it breaks Borland C++ 5.5 */
\r
261 /* #define NOCTLMGR */ /* Control management and controls */
\r
264 * Exclude parts of WINDOWS.H that are not needed (Win32)
\r
266 #define WIN32_LEAN_AND_MEAN
\r
267 #define NONLS /* All NLS defines and routines */
\r
268 #define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
\r
269 #define NOKANJI /* Kanji support stuff. */
\r
270 #define NOMCX /* Modem Configuration Extensions */
\r
273 * Include the "windows" support file
\r
275 #include <windows.h>
\r
278 * Exclude parts of MMSYSTEM.H that are not needed
\r
280 #define MMNODRV /* Installable driver support */
\r
281 #define MMNOWAVE /* Waveform support */
\r
282 #define MMNOMIDI /* MIDI support */
\r
283 #define MMNOAUX /* Auxiliary audio support */
\r
284 #define MMNOTIMER /* Timer support */
\r
285 #define MMNOJOY /* Joystick support */
\r
286 #define MMNOMCI /* MCI support */
\r
287 #define MMNOMMIO /* Multimedia file I/O support */
\r
288 #define MMNOMMSYSTEM /* General MMSYSTEM functions */
\r
291 * Include some more files. Note: the Cygnus Cygwin compiler
\r
292 * doesn't use mmsystem.h instead it includes the winmm library
\r
293 * which performs a similar function.
\r
295 #include <mmsystem.h>
\r
296 #include <commdlg.h>
\r
299 * HTML-Help requires htmlhelp.h and htmlhelp.lib from Microsoft's
\r
300 * HTML Workshop < http://msdn.microsoft.com/workshop/author/htmlhelp/ >.
\r
302 /* #define HTML_HELP */
\r
305 #include <htmlhelp.h>
\r
306 #endif /* HTML_HELP */
\r
309 * Include the support for loading bitmaps
\r
311 #ifdef USE_GRAPHICS
\r
312 # include "readdib.h"
\r
316 * Hack -- Fake declarations from "dos.h" XXX XXX XXX
\r
319 #define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
\r
321 #define FA_LABEL 0x08 /* Volume label */
\r
322 #define FA_DIREC 0x10 /* Directory */
\r
323 unsigned _cdecl _dos_getfileattr(const char *, unsigned *);
\r
327 * Silliness in WIN32 drawing routine
\r
330 # define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL)
\r
334 * Silliness for Windows 95
\r
336 #ifndef WS_EX_TOOLWINDOW
\r
337 # define WS_EX_TOOLWINDOW 0
\r
341 * Foreground color bits (hard-coded by DOS)
\r
343 #define VID_BLACK 0x00
\r
344 #define VID_BLUE 0x01
\r
345 #define VID_GREEN 0x02
\r
346 #define VID_CYAN 0x03
\r
347 #define VID_RED 0x04
\r
348 #define VID_MAGENTA 0x05
\r
349 #define VID_YELLOW 0x06
\r
350 #define VID_WHITE 0x07
\r
353 * Bright text (hard-coded by DOS)
\r
355 #define VID_BRIGHT 0x08
\r
358 * Background color bits (hard-coded by DOS)
\r
360 #define VUD_BLACK 0x00
\r
361 #define VUD_BLUE 0x10
\r
362 #define VUD_GREEN 0x20
\r
363 #define VUD_CYAN 0x30
\r
364 #define VUD_RED 0x40
\r
365 #define VUD_MAGENTA 0x50
\r
366 #define VUD_YELLOW 0x60
\r
367 #define VUD_WHITE 0x70
\r
370 * Blinking text (hard-coded by DOS)
\r
372 #define VUD_BRIGHT 0x80
\r
378 typedef struct _term_data term_data;
\r
381 * @struct _term_data
\r
382 * @brief ターム情報構造体 / Extra "term" data
\r
385 * pos_x / pos_y は各タームの左上点座標を指す。
\r
388 * tile_wid / tile_hgt は[ウィンドウ]メニューのタイルの幅/高さを~を
\r
389 * 1ドットずつ調整するステータスを指す。
\r
390 * また、フォントを変更すると都度自動調整される。
\r
393 * Note the use of "font_want" for the names of the font file requested by
\r
394 * the user, and the use of "font_file" for the currently active font file.
\r
396 * The "font_file" is uppercased, and takes the form "8X13.FON", while
\r
397 * "font_want" can be in almost any form as long as it could be construed
\r
398 * as attempting to represent the name of a font.
\r
414 TERM_POSITION rows; /* int -> uint */
\r
415 TERM_POSITION cols;
\r
417 uint pos_x; //!< タームの左上X座標
\r
418 uint pos_y; //!< タームの左上Y座標
\r
440 int font_wid; //!< フォント横幅
\r
441 int font_hgt; //!< フォント縦幅
\r
443 int tile_wid; //!< タイル横幅
\r
444 int tile_hgt; //!< タイル縦幅
\r
450 #if 1 /* #ifdef JP */
\r
465 * Maximum number of windows XXX XXX XXX
\r
467 #define MAX_TERM_DATA 8
\r
470 * An array of term_data's
\r
472 static term_data data[MAX_TERM_DATA];
\r
475 * Hack -- global "window creation" pointer
\r
477 static term_data *my_td;
\r
480 * Remember normal size of main window when maxmized
\r
485 * was main window maximized on previous playing
\r
487 bool win_maximized = FALSE;
\r
492 bool game_in_progress = FALSE;
\r
495 * note when "open"/"new" become valid
\r
497 bool initialized = FALSE;
\r
500 * screen paletted, i.e. 256 colors
\r
502 bool paletted = FALSE;
\r
505 * 16 colors screen, don't use RGB()
\r
507 bool colors16 = FALSE;
\r
510 * Saved instance handle
\r
512 static HINSTANCE hInstance;
\r
515 * Yellow brush for the cursor
\r
517 static HBRUSH hbrYellow;
\r
522 static HICON hIcon;
\r
527 static HPALETTE hPal;
\r
530 static HBITMAP hBG = NULL;
\r
531 static int use_bg = 0; //!< 背景使用フラグ、1なら私用。
\r
532 static char bg_bitmap_file[1024] = "bg.bmp"; //!< 現在の背景ビットマップファイル名。
\r
537 * The screen saver window
\r
539 static HWND hwndSaver;
\r
541 #endif /* USE_SAVER */
\r
544 #ifdef USE_GRAPHICS
\r
547 * 現在使用中のタイルID(0ならば未使用)
\r
548 * Flag set once "graphics" has been initialized
\r
550 static byte_hack current_graphics_mode = 0;
\r
553 * The global bitmap
\r
555 static DIBINIT infGraph;
\r
558 * The global bitmap mask
\r
560 static DIBINIT infMask;
\r
562 #endif /* USE_GRAPHICS */
\r
568 * Flag set once "sound" has been initialized
\r
570 static bool can_use_sound = FALSE;
\r
572 #define SAMPLE_MAX 8
\r
574 * An array of sound file names
\r
576 static cptr sound_file[SOUND_MAX][SAMPLE_MAX];
\r
578 #endif /* USE_SOUND */
\r
584 #define SAMPLE_MUSIC_MAX 16
\r
585 static cptr music_file[MUSIC_BASIC_MAX][SAMPLE_MUSIC_MAX];
\r
586 static cptr dungeon_music_file[1000][SAMPLE_MUSIC_MAX];
\r
587 static cptr town_music_file[1000][SAMPLE_MUSIC_MAX];
\r
588 static cptr quest_music_file[1000][SAMPLE_MUSIC_MAX];
\r
589 static bool can_use_music = FALSE;
\r
591 static MCI_OPEN_PARMS mop;
\r
592 static char mci_device_type[256];
\r
594 int current_music_type = 0;
\r
595 int current_music_id = 0;
\r
597 #endif /* USE_MUSIC */
\r
601 * Full path to ANGBAND.INI
\r
603 static cptr ini_file = NULL;
\r
606 * Name of application
\r
608 static cptr AppName = "ANGBAND";
\r
611 * Name of sub-window type
\r
613 static cptr AngList = "AngList";
\r
618 static cptr ANGBAND_DIR_XTRA_GRAF;
\r
619 static cptr ANGBAND_DIR_XTRA_SOUND;
\r
620 static cptr ANGBAND_DIR_XTRA_MUSIC;
\r
621 static cptr ANGBAND_DIR_XTRA_HELP;
\r
622 #if 0 /* #ifndef JP */
\r
623 static cptr ANGBAND_DIR_XTRA_FONT;
\r
626 static cptr ANGBAND_DIR_XTRA_MUSIC;
\r
631 * The "complex" color values
\r
633 static COLORREF win_clr[256];
\r
637 * Flag for macro trigger with dump ASCII
\r
639 static bool Term_no_press = FALSE;
\r
644 static bool mouse_down = FALSE;
\r
645 static bool paint_rect = FALSE;
\r
646 static TERM_POSITION mousex = 0, mousey = 0;
\r
647 static TERM_POSITION oldx, oldy;
\r
651 * @brief The "simple" color values
\r
653 * See "main-ibm.c" for original table information
\r
654 * The entries below are taken from the "color bits" defined above.
\r
655 * Note that many of the choices below suck, but so do crappy monitors.
\r
657 static BYTE win_pal[256] =
\r
659 VID_BLACK, /* Dark */
\r
660 VID_WHITE, /* White */
\r
661 VID_CYAN, /* Slate XXX */
\r
662 VID_RED | VID_BRIGHT, /* Orange XXX */
\r
664 VID_GREEN, /* Green */
\r
665 VID_BLUE, /* Blue */
\r
666 VID_YELLOW, /* Umber XXX */
\r
667 VID_BLACK | VID_BRIGHT, /* Light Dark */
\r
668 VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
\r
669 VID_MAGENTA, /* Violet XXX */
\r
670 VID_YELLOW | VID_BRIGHT, /* Yellow */
\r
671 VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
\r
672 VID_GREEN | VID_BRIGHT, /* Light Green */
\r
673 VID_BLUE | VID_BRIGHT, /* Light Blue */
\r
674 VID_YELLOW /* Light Umber XXX */
\r
679 * Hack -- define which keys are "special"
\r
681 static bool special_key[256];
\r
682 static bool ignore_key[256];
\r
686 * Hack -- initialization list for "special_key"
\r
688 static byte special_key_list[] = {
\r
689 VK_CLEAR, VK_PAUSE, VK_CAPITAL,
\r
690 VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI,
\r
691 VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE,
\r
692 VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
\r
693 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN,
\r
694 VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT,
\r
695 VK_INSERT, VK_DELETE, VK_HELP, VK_APPS,
\r
696 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
\r
697 VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
\r
698 VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD,
\r
699 VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE,
\r
700 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
\r
701 VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
\r
702 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
\r
703 VK_F19,VK_F20, VK_F21, VK_F22, VK_F23, VK_F24,
\r
704 VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL,
\r
705 VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM,
\r
707 0 /* End of List */
\r
710 static byte ignore_key_list[] = {
\r
711 VK_ESCAPE, VK_TAB, VK_SPACE,
\r
712 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
\r
713 VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN,
\r
714 VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL,
\r
715 VK_LMENU, VK_RMENU,
\r
716 0 /* End of List */
\r
720 * Hack -- initialization list for "special_key"
\r
722 * We ignore the modifier keys (shift, control, alt, num lock, scroll lock),
\r
723 * and the normal keys (escape, tab, return, letters, numbers, etc), but we
\r
724 * catch the keypad keys (with and without numlock set, including keypad 5),
\r
725 * the function keys (including the "menu" key which maps to F10), and the
\r
726 * "pause" key (between scroll lock and numlock). We also catch a few odd
\r
727 * keys which I do not recognize, but which are listed among keys which we
\r
728 * do catch, so they should be harmless to catch.
\r
730 static byte special_key_list[] =
\r
732 VK_CLEAR, /* 0x0C (KP<5>) */
\r
734 VK_PAUSE, /* 0x13 (pause) */
\r
736 VK_PRIOR, /* 0x21 (KP<9>) */
\r
737 VK_NEXT, /* 0x22 (KP<3>) */
\r
738 VK_END, /* 0x23 (KP<1>) */
\r
739 VK_HOME, /* 0x24 (KP<7>) */
\r
740 VK_LEFT, /* 0x25 (KP<4>) */
\r
741 VK_UP, /* 0x26 (KP<8>) */
\r
742 VK_RIGHT, /* 0x27 (KP<6>) */
\r
743 VK_DOWN, /* 0x28 (KP<2>) */
\r
744 VK_SELECT, /* 0x29 (?????) */
\r
745 VK_PRINT, /* 0x2A (?????) */
\r
746 VK_EXECUTE, /* 0x2B (?????) */
\r
747 VK_SNAPSHOT, /* 0x2C (?????) */
\r
748 VK_INSERT, /* 0x2D (KP<0>) */
\r
749 VK_DELETE, /* 0x2E (KP<.>) */
\r
750 VK_HELP, /* 0x2F (?????) */
\r
752 VK_NUMPAD0, /* 0x60 (KP<0>) */
\r
753 VK_NUMPAD1, /* 0x61 (KP<1>) */
\r
754 VK_NUMPAD2, /* 0x62 (KP<2>) */
\r
755 VK_NUMPAD3, /* 0x63 (KP<3>) */
\r
756 VK_NUMPAD4, /* 0x64 (KP<4>) */
\r
757 VK_NUMPAD5, /* 0x65 (KP<5>) */
\r
758 VK_NUMPAD6, /* 0x66 (KP<6>) */
\r
759 VK_NUMPAD7, /* 0x67 (KP<7>) */
\r
760 VK_NUMPAD8, /* 0x68 (KP<8>) */
\r
761 VK_NUMPAD9, /* 0x69 (KP<9>) */
\r
762 VK_MULTIPLY, /* 0x6A (KP<*>) */
\r
763 VK_ADD, /* 0x6B (KP<+>) */
\r
764 VK_SEPARATOR, /* 0x6C (?????) */
\r
765 VK_SUBTRACT, /* 0x6D (KP<->) */
\r
766 VK_DECIMAL, /* 0x6E (KP<.>) */
\r
767 VK_DIVIDE, /* 0x6F (KP</>) */
\r
798 /* Function prototype */
\r
800 static bool is_already_running(void);
\r
804 static void delete_bg(void)
\r
813 static int init_bg(void)
\r
815 char * bmfile = bg_bitmap_file;
\r
818 if (use_bg == 0) return 0;
\r
820 hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
\r
822 plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
\r
827 HDC wnddc, dcimage, dcbg;
\r
828 HBITMAP bmimage, bmimage_old, bmbg_old;
\r
833 wnddc = GetDC(hwnd);
\r
834 dcimage = CreateCompatibleDC(wnddc);
\r
835 dcbg = CreateCompatibleDC(wnddc);
\r
837 bmimage = LoadImage(NULL, "bg.bmp", LR_LOADFROMFILE, 0, 0, 0);
\r
838 if (!bmimage) quit("bg.bmpが読みこめない!");
\r
839 bmimage_old = SelectObject(dcimage, bmimage);
\r
841 CreateCompatibleBitmap();
\r
843 ReleaseDC(hwnd, wnddc);
\r
849 static void DrawBG(HDC hdc, RECT *r)
\r
854 int x = r->left, y = r->top;
\r
855 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
\r
857 if (!use_bg || !hBG)
\r
861 GetObject(hBG, sizeof(bm), &bm);
\r
862 swid = bm.bmWidth; shgt = bm.bmHeight;
\r
864 hdcSrc = CreateCompatibleDC(hdc);
\r
865 hOld = SelectObject(hdcSrc, hBG);
\r
869 cwid = MIN(swid - sx, r->right - nx);
\r
872 chgt = MIN(shgt - sy, r->bottom - ny);
\r
873 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
\r
875 } while (ny < r->bottom);
\r
878 } while (nx < r->right);
\r
880 SelectObject(hdcSrc, hOld);
\r
886 * Hack -- given a pathname, point at the filename
\r
888 static cptr extract_file_name(cptr s)
\r
892 /* Start at the end */
\r
893 p = s + strlen(s) - 1;
\r
895 /* Back up to divider */
\r
896 while ((p >= s) && (*p != ':') && (*p != '\\')) p--;
\r
898 /* Return file name */
\r
905 * Hack -- given a simple filename, extract the "font size" info
\r
907 * Return a pointer to a static buffer holding the capitalized base name.
\r
909 #if 0 /* #ifndef JP */
\r
910 static char *analyze_font(char *path, int *wp, int *hp)
\r
916 /* Start at the end */
\r
917 p = path + strlen(path) - 1;
\r
919 /* Back up to divider */
\r
920 while ((p >= path) && (*p != ':') && (*p != '\\')) --p;
\r
922 /* Advance to file name */
\r
926 for (s = p; *s; ++s)
\r
928 /* Capitalize (be paranoid) */
\r
929 if (islower(*s)) *s = toupper(*s);
\r
932 /* Find first 'X' */
\r
933 s = my_strchr(p, 'X');
\r
935 /* Extract font width */
\r
938 /* Extract height */
\r
939 hgt = s ? atoi(s+1) : 0;
\r
952 * Check for existance of a file
\r
954 static bool check_file(cptr s)
\r
964 unsigned int attrib;
\r
974 attrib = GetFileAttributes(path);
\r
976 /* Require valid filename */
\r
977 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
979 /* Prohibit directory */
\r
980 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return (FALSE);
\r
984 /* Examine and verify */
\r
985 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
987 /* Prohibit something */
\r
988 if (attrib & FA_LABEL) return (FALSE);
\r
990 /* Prohibit directory */
\r
991 if (attrib & FA_DIREC) return (FALSE);
\r
1001 * Check for existance of a directory
\r
1003 static bool check_dir(cptr s)
\r
1015 unsigned int attrib;
\r
1017 #endif /* WIN32 */
\r
1022 /* Check length */
\r
1025 /* Remove trailing backslash */
\r
1026 if (i && (path[i-1] == '\\')) path[--i] = '\0';
\r
1031 attrib = GetFileAttributes(path);
\r
1033 /* Require valid filename */
\r
1034 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
1036 /* Require directory */
\r
1037 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE);
\r
1041 /* Examine and verify */
\r
1042 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
1044 /* Prohibit something */
\r
1045 if (attrib & FA_LABEL) return (FALSE);
\r
1047 /* Require directory */
\r
1048 if (!(attrib & FA_DIREC)) return (FALSE);
\r
1050 #endif /* WIN32 */
\r
1060 static void validate_file(cptr s)
\r
1062 /* Verify or fail */
\r
1063 if (!check_file(s))
\r
1065 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
\r
1071 * Validate a directory
\r
1073 static void validate_dir(cptr s, bool vital)
\r
1075 /* Verify or fail */
\r
1076 if (!check_dir(s))
\r
1078 /* This directory contains needed data */
\r
1081 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
\r
1083 /* Attempt to create this directory */
\r
1084 else if (mkdir(s))
\r
1086 quit_fmt("Unable to create directory:\n%s", s);
\r
1093 * Get the "size" for a window
\r
1095 static void term_getsize(term_data *td)
\r
1102 if (td->cols < 1) td->cols = 1;
\r
1103 if (td->rows < 1) td->rows = 1;
\r
1105 /* Window sizes */
\r
1106 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
1107 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
\r
1109 /* Fake window size */
\r
1111 rc.right = rc.left + wid;
\r
1113 rc.bottom = rc.top + hgt;
\r
1116 /* rc.right += 1; */
\r
1117 /* rc.bottom += 1; */
\r
1120 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
1123 td->size_wid = rc.right - rc.left;
\r
1124 td->size_hgt = rc.bottom - rc.top;
\r
1126 /* See CreateWindowEx */
\r
1127 if (!td->w) return;
\r
1129 /* Extract actual location */
\r
1130 GetWindowRect(td->w, &rc);
\r
1132 /* Save the location */
\r
1133 td->pos_x = rc.left;
\r
1134 td->pos_y = rc.top;
\r
1139 * Write the "prefs" for a single term
\r
1141 static void save_prefs_aux(int i)
\r
1143 term_data *td = &data[i];
\r
1144 char sec_name[128];
\r
1148 WINDOWPLACEMENT lpwndpl;
\r
1151 if (!td->w) return;
\r
1153 /* Make section name */
\r
1154 sprintf(sec_name, "Term-%d", i);
\r
1159 strcpy(buf, td->visible ? "1" : "0");
\r
1160 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
\r
1165 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "MS ゴシック");
\r
1168 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
\r
1170 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
\r
1174 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
\r
1176 #if 1 /* #ifdef JP */
\r
1177 wsprintf(buf, "%d", td->lf.lfWidth);
\r
1178 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
\r
1179 wsprintf(buf, "%d", td->lf.lfHeight);
\r
1180 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
\r
1181 wsprintf(buf, "%d", td->lf.lfWeight);
\r
1182 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
\r
1185 strcpy(buf, td->bizarre ? "1" : "0");
\r
1186 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
\r
1188 /* Tile size (x) */
\r
1189 wsprintf(buf, "%d", td->tile_wid);
\r
1190 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
\r
1192 /* Tile size (y) */
\r
1193 wsprintf(buf, "%d", td->tile_hgt);
\r
1194 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
\r
1196 /* Get window placement and dimensions */
\r
1197 lpwndpl.length = sizeof(WINDOWPLACEMENT);
\r
1198 GetWindowPlacement(td->w, &lpwndpl);
\r
1200 /* Acquire position in *normal* mode (not minimized) */
\r
1201 rc = lpwndpl.rcNormalPosition;
\r
1203 /* Window size (x) */
\r
1204 if (i == 0) wsprintf(buf, "%d", normsize.x);
\r
1205 else wsprintf(buf, "%d", td->cols);
\r
1206 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
\r
1208 /* Window size (y) */
\r
1209 if (i == 0) wsprintf(buf, "%d", normsize.y);
\r
1210 else wsprintf(buf, "%d", td->rows);
\r
1211 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
\r
1213 /* Maxmized (only main window) */
\r
1216 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
\r
1217 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
\r
1220 /* Acquire position */
\r
1221 GetWindowRect(td->w, &rc);
\r
1223 /* Window position (x) */
\r
1224 wsprintf(buf, "%d", rc.left);
\r
1225 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
\r
1227 /* Window position (y) */
\r
1228 wsprintf(buf, "%d", rc.top);
\r
1229 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
\r
1231 /* Window Z position */
\r
1234 strcpy(buf, td->posfix ? "1" : "0");
\r
1235 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
\r
1241 * Write the "prefs"
\r
1243 * We assume that the windows have all been initialized
\r
1245 static void save_prefs(void)
\r
1251 /* Save the "arg_graphics" flag */
\r
1252 sprintf(buf, "%d", arg_graphics);
\r
1253 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
\r
1255 /* Save the "arg_bigtile" flag */
\r
1256 strcpy(buf, arg_bigtile ? "1" : "0");
\r
1257 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
\r
1259 /* Save the "arg_sound" flag */
\r
1260 strcpy(buf, arg_sound ? "1" : "0");
\r
1261 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
\r
1263 /* Save the "arg_sound" flag */
\r
1264 strcpy(buf, arg_music ? "1" : "0");
\r
1265 WritePrivateProfileString("Angband", "Music", buf, ini_file);
\r
1268 strcpy(buf, use_bg ? "1" : "0");
\r
1269 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
\r
1270 WritePrivateProfileString("Angband", "BackGroundBitmap",
\r
1271 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
\r
1273 /* Save window prefs */
\r
1274 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1276 save_prefs_aux(i);
\r
1282 * Load the "prefs" for a single term
\r
1284 static void load_prefs_aux(int i)
\r
1286 term_data *td = &data[i];
\r
1287 char sec_name[128];
\r
1290 int wid, hgt, posx, posy;
\r
1291 int dispx = GetSystemMetrics( SM_CXVIRTUALSCREEN);
\r
1292 int dispy = GetSystemMetrics( SM_CYVIRTUALSCREEN);
\r
1296 /* Make section name */
\r
1297 sprintf(sec_name, "Term-%d", i);
\r
1299 /* Make section name */
\r
1300 sprintf(sec_name, "Term-%d", i);
\r
1305 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
\r
1308 /* Desired font, with default */
\r
1310 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
\r
1313 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
\r
1315 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
\r
1321 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
\r
1323 /* Analyze font, save desired font name */
\r
1324 #if 1 /* #ifdef JP */
\r
1325 td->font_want = string_make(tmp);
\r
1326 hgt = 15; wid = 0;
\r
1327 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
\r
1328 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
\r
1329 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
\r
1331 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
\r
1336 #if 1 /* #ifdef JP */
\r
1337 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
\r
1338 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
\r
1340 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
\r
1341 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
\r
1346 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
\r
1347 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
\r
1348 normsize.x = td->cols; normsize.y = td->rows;
\r
1353 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
\r
1356 /* Window position */
\r
1357 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
\r
1358 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
\r
1359 td->pos_x = MIN(MAX(0, posx), dispx-128);
\r
1360 td->pos_y = MIN(MAX(0, posy), dispy-128);
\r
1362 /* Window Z position */
\r
1365 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
\r
1371 * Load the "prefs"
\r
1373 static void load_prefs(void)
\r
1377 /* Extract the "arg_graphics" flag */
\r
1378 arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
\r
1380 /* Extract the "arg_bigtile" flag */
\r
1381 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
\r
1382 use_bigtile = arg_bigtile;
\r
1384 /* Extract the "arg_sound" flag */
\r
1385 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
\r
1387 /* Extract the "arg_sound" flag */
\r
1388 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
\r
1391 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
\r
1392 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
\r
1394 /* Load window prefs */
\r
1395 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1397 load_prefs_aux(i);
\r
1401 #if defined(USE_SOUND) || defined(USE_MUSIC)
\r
1404 * XXX XXX XXX - Taken from files.c.
\r
1406 * Extract "tokens" from a buffer
\r
1408 * This function uses "whitespace" as delimiters, and treats any amount of
\r
1409 * whitespace as a single delimiter. We will never return any empty tokens.
\r
1410 * When given an empty buffer, or a buffer containing only "whitespace", we
\r
1411 * will return no tokens. We will never extract more than "num" tokens.
\r
1413 * By running a token through the "text_to_ascii()" function, you can allow
\r
1414 * that token to include (encoded) whitespace, using "\s" to encode spaces.
\r
1416 * We save pointers to the tokens in "tokens", and return the number found.
\r
1418 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
\r
1428 /* Skip leading whitespace */
\r
1429 for ( ; *s && iswspace(*s); ++s) /* loop */;
\r
1434 /* Find next whitespace, if any */
\r
1435 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
\r
1437 /* Nuke and advance (if necessary) */
\r
1438 if (*t) *t++ = '\0';
\r
1440 /* Save the token */
\r
1451 #endif /* USE_SOUND || USE_MUSIC */
\r
1455 static void load_sound_prefs(void)
\r
1459 char ini_path[1024];
\r
1460 char wav_path[1024];
\r
1461 char *zz[SAMPLE_MAX];
\r
1463 /* Access the sound.cfg */
\r
1465 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
\r
1467 for (i = 0; i < SOUND_MAX; i++)
\r
1469 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
\r
1471 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
\r
1473 for (j = 0; j < num; j++)
\r
1475 /* Access the sound */
\r
1476 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
\r
1478 /* Save the sound filename, if it exists */
\r
1479 if (check_file(wav_path))
\r
1480 sound_file[i][j] = string_make(zz[j]);
\r
1485 #endif /* USE_SOUND */
\r
1489 static void load_music_prefs(void)
\r
1493 char ini_path[1024];
\r
1494 char wav_path[1024];
\r
1495 char *zz[SAMPLE_MAX];
\r
1498 /* Access the music.cfg */
\r
1500 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
\r
1502 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
\r
1504 for (i = 0; i < MUSIC_BASIC_MAX; i++)
\r
1506 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
\r
1508 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1510 for (j = 0; j < num; j++)
\r
1512 /* Access the sound */
\r
1513 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1515 /* Save the sound filename, if it exists */
\r
1516 if (check_file(wav_path))
\r
1517 music_file[i][j] = string_make(zz[j]);
\r
1521 for (i = 0; i < max_d_idx; i++)
\r
1523 sprintf(key, "dungeon%03d", i);
\r
1524 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
\r
1526 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1528 for (j = 0; j < num; j++)
\r
1530 /* Access the sound */
\r
1531 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1533 /* Save the sound filename, if it exists */
\r
1534 if (check_file(wav_path))
\r
1535 dungeon_music_file[i][j] = string_make(zz[j]);
\r
1539 for (i = 0; i < max_q_idx; i++)
\r
1541 sprintf(key, "quest%03d", i);
\r
1542 GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
\r
1544 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1546 for (j = 0; j < num; j++)
\r
1548 /* Access the sound */
\r
1549 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1551 /* Save the sound filename, if it exists */
\r
1552 if (check_file(wav_path))
\r
1553 quest_music_file[i][j] = string_make(zz[j]);
\r
1557 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
\r
1559 sprintf(key, "town%03d", i);
\r
1560 GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
\r
1562 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1564 for (j = 0; j < num; j++)
\r
1566 /* Access the sound */
\r
1567 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1569 /* Save the sound filename, if it exists */
\r
1570 if (check_file(wav_path))
\r
1571 town_music_file[i][j] = string_make(zz[j]);
\r
1578 #endif /* USE_MUSIC */
\r
1581 * Create the new global palette based on the bitmap palette
\r
1582 * (if any), and the standard 16 entry palette derived from
\r
1583 * "win_clr[]" which is used for the basic 16 Angband colors.
\r
1585 * This function is never called before all windows are ready.
\r
1587 * This function returns FALSE if the new palette could not be
\r
1588 * prepared, which should normally be a fatal error. XXX XXX
\r
1590 * Note that only some machines actually use a "palette".
\r
1592 static int new_palette(void)
\r
1600 LPLOGPALETTE pLogPal;
\r
1601 LPPALETTEENTRY lppe;
\r
1606 /* This makes no sense */
\r
1607 if (!paletted) return (TRUE);
\r
1615 #ifdef USE_GRAPHICS
\r
1617 /* Check the bitmap palette */
\r
1618 hBmPal = infGraph.hPalette;
\r
1620 /* Use the bitmap */
\r
1623 lppeSize = 256 * sizeof(PALETTEENTRY);
\r
1624 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
\r
1625 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
\r
1626 if ((nEntries == 0) || (nEntries > 220))
\r
1628 /* Warn the user */
\r
1629 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
\r
1632 rnfree(lppe, lppeSize);
\r
1639 #endif /* USE_GRAPHICS */
\r
1641 /* Size of palette */
\r
1642 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
\r
1644 /* Allocate palette */
\r
1645 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
\r
1648 pLogPal->palVersion = 0x300;
\r
1650 /* Make room for bitmap and normal data */
\r
1651 pLogPal->palNumEntries = nEntries + 16;
\r
1653 /* Save the bitmap data */
\r
1654 for (i = 0; i < nEntries; i++)
\r
1656 pLogPal->palPalEntry[i] = lppe[i];
\r
1659 /* Save the normal data */
\r
1660 for (i = 0; i < 16; i++)
\r
1664 /* Access the entry */
\r
1665 p = &(pLogPal->palPalEntry[i+nEntries]);
\r
1667 /* Save the colors */
\r
1668 p->peRed = GetRValue(win_clr[i]);
\r
1669 p->peGreen = GetGValue(win_clr[i]);
\r
1670 p->peBlue = GetBValue(win_clr[i]);
\r
1672 /* Save the flags */
\r
1673 p->peFlags = PC_NOCOLLAPSE;
\r
1676 /* Free something */
\r
1677 if (lppe) rnfree(lppe, lppeSize);
\r
1679 /* Create a new palette, or fail */
\r
1680 hNewPal = CreatePalette(pLogPal);
\r
1681 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
\r
1683 /* Free the palette */
\r
1684 rnfree(pLogPal, pLogPalSize);
\r
1689 /* Realize the palette */
\r
1690 hdc = GetDC(td->w);
\r
1691 SelectPalette(hdc, hNewPal, 0);
\r
1692 i = RealizePalette(hdc);
\r
1693 ReleaseDC(td->w, hdc);
\r
1694 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
\r
1698 for (i = 1; i < MAX_TERM_DATA; i++)
\r
1702 hdc = GetDC(td->w);
\r
1703 SelectPalette(hdc, hNewPal, 0);
\r
1704 ReleaseDC(td->w, hdc);
\r
1707 /* Delete old palette */
\r
1708 if (hPal) DeleteObject(hPal);
\r
1710 /* Save new palette */
\r
1718 #ifdef USE_GRAPHICS
\r
1720 * @brief グラフィクスを初期化する / Initialize graphics
\r
1723 * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
\r
1724 * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
\r
1727 static bool init_graphics(void)
\r
1729 /* Initialize once */
\r
1731 BYTE wid, hgt, twid, thgt, ox, oy;
\r
1734 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1742 name = "16X16.BMP";
\r
1744 ANGBAND_GRAF = "new";
\r
1746 else if (arg_graphics == GRAPHICS_HENGBAND)
\r
1755 name = "64X64.BMP";
\r
1764 name = "32X32.BMP";
\r
1766 ANGBAND_GRAF = "ne2";
\r
1777 ANGBAND_GRAF = "old";
\r
1780 /* Access the bitmap file */
\r
1781 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
\r
1783 /* Load the bitmap or quit */
\r
1784 if (!ReadDIB(data[0].w, buf, &infGraph))
\r
1786 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
\r
1790 /* Save the new sizes */
\r
1791 infGraph.CellWidth = wid;
\r
1792 infGraph.CellHeight = hgt;
\r
1793 infGraph.TileWidth = twid;
\r
1794 infGraph.TileHeight = thgt;
\r
1795 infGraph.OffsetX = ox;
\r
1796 infGraph.OffsetY = oy;
\r
1798 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1800 /* Access the mask file */
\r
1801 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
\r
1803 /* Load the bitmap or quit */
\r
1804 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1806 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1810 if (arg_graphics == GRAPHICS_HENGBAND)
\r
1812 /* Access the mask file */
\r
1813 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
\r
1815 /* Load the bitmap or quit */
\r
1816 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1818 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1823 /* Activate a palette */
\r
1824 if (!new_palette())
\r
1826 /* Free bitmap XXX XXX XXX */
\r
1829 plog(_("パレットを実現できません!", "Cannot activate palette!"));
\r
1833 /* Graphics available */
\r
1834 current_graphics_mode = arg_graphics;
\r
1837 return (current_graphics_mode);
\r
1839 #endif /* USE_GRAPHICS */
\r
1844 * Initialize music
\r
1846 static bool init_music(void)
\r
1848 /* Initialize once */
\r
1849 if (!can_use_music)
\r
1851 /* Load the prefs */
\r
1852 load_music_prefs();
\r
1854 /* Sound available */
\r
1855 can_use_music = TRUE;
\r
1859 return (can_use_music);
\r
1863 * Hack -- Stop a music
\r
1865 static void stop_music(void)
\r
1867 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
1868 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
1871 #endif /* USE_MUSIC */
\r
1875 * Initialize sound
\r
1877 static bool init_sound(void)
\r
1879 /* Initialize once */
\r
1880 if (!can_use_sound)
\r
1882 /* Load the prefs */
\r
1883 load_sound_prefs();
\r
1885 /* Sound available */
\r
1886 can_use_sound = TRUE;
\r
1890 return (can_use_sound);
\r
1892 #endif /* USE_SOUND */
\r
1898 static void term_window_resize(term_data *td)
\r
1900 /* Require window */
\r
1901 if (!td->w) return;
\r
1903 /* Resize the window */
\r
1904 SetWindowPos(td->w, 0, 0, 0,
\r
1905 td->size_wid, td->size_hgt,
\r
1906 SWP_NOMOVE | SWP_NOZORDER);
\r
1908 /* Redraw later */
\r
1909 InvalidateRect(td->w, NULL, TRUE);
\r
1914 * Force the use of a new "font file" for a term_data
\r
1916 * This function may be called before the "window" is ready
\r
1918 * This function returns zero only if everything succeeds.
\r
1920 * Note that the "font name" must be capitalized!!!
\r
1922 static errr term_force_font(term_data *td, cptr path)
\r
1926 #if 0 /* #ifndef JP */
\r
1932 /* Forget the old font (if needed) */
\r
1933 if (td->font_id) DeleteObject(td->font_id);
\r
1935 #if 1 /* #ifdef JP */
\r
1939 /* Create the font (using the 'base' of the font file name!) */
\r
1940 td->font_id = CreateFontIndirect(&(td->lf));
\r
1941 wid = td->lf.lfWidth;
\r
1942 hgt = td->lf.lfHeight;
\r
1943 if (!td->font_id) return (1);
\r
1945 /* Forget old font */
\r
1946 if (td->font_file)
\r
1948 bool used = FALSE;
\r
1950 /* Scan windows */
\r
1951 for (i = 0; i < MAX_TERM_DATA; i++)
\r
1953 /* Don't check when closing the application */
\r
1956 /* Check "screen" */
\r
1957 if ((td != &data[i]) &&
\r
1958 (data[i].font_file) &&
\r
1959 (streq(data[i].font_file, td->font_file)))
\r
1965 /* Remove unused font resources */
\r
1966 if (!used) RemoveFontResource(td->font_file);
\r
1968 /* Free the old name */
\r
1969 string_free(td->font_file);
\r
1972 td->font_file = NULL;
\r
1975 /* No path given */
\r
1976 if (!path) return (1);
\r
1979 strcpy(buf, path);
\r
1981 /* Analyze font path */
\r
1982 base = analyze_font(buf, &wid, &hgt);
\r
1984 /* Verify suffix */
\r
1985 if (!suffix(base, ".FON")) return (1);
\r
1988 if (!check_file(buf)) return (1);
\r
1990 /* Load the new font */
\r
1991 if (!AddFontResource(buf)) return (1);
\r
1993 /* Save new font name */
\r
1994 td->font_file = string_make(base);
\r
1996 /* Remove the "suffix" */
\r
1997 base[strlen(base)-4] = '\0';
\r
1999 /* Create the font (using the 'base' of the font file name!) */
\r
2000 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
\r
2001 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
\r
2002 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
\r
2003 FIXED_PITCH | FF_DONTCARE, base);
\r
2006 /* Hack -- Unknown size */
\r
2013 /* all this trouble to get the cell size */
\r
2014 hdcDesktop = GetDC(HWND_DESKTOP);
\r
2015 hfOld = SelectObject(hdcDesktop, td->font_id);
\r
2016 GetTextMetrics(hdcDesktop, &tm);
\r
2017 SelectObject(hdcDesktop, hfOld);
\r
2018 ReleaseDC(HWND_DESKTOP, hdcDesktop);
\r
2020 /* Font size info */
\r
2021 wid = tm.tmAveCharWidth;
\r
2022 hgt = tm.tmHeight;
\r
2025 /* Save the size info */
\r
2026 td->font_wid = wid;
\r
2027 td->font_hgt = hgt;
\r
2036 * Allow the user to change the font for this window.
\r
2038 static void term_change_font(term_data *td)
\r
2040 #if 1 /* #ifdef JP */
\r
2043 memset(&cf, 0, sizeof(cf));
\r
2044 cf.lStructSize = sizeof(cf);
\r
2045 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
\r
2046 cf.lpLogFont = &(td->lf);
\r
2048 if (ChooseFont(&cf))
\r
2050 /* Force the font */
\r
2051 term_force_font(td, NULL);
\r
2053 /* Assume not bizarre */
\r
2054 td->bizarre = TRUE;
\r
2056 /* Reset the tile info */
\r
2057 td->tile_wid = td->font_wid;
\r
2058 td->tile_hgt = td->font_hgt;
\r
2060 /* Analyze the font */
\r
2063 /* Resize the window */
\r
2064 term_window_resize(td);
\r
2070 char tmp[1024] = "";
\r
2072 /* Extract a default if possible */
\r
2073 if (td->font_file) strcpy(tmp, td->font_file);
\r
2075 /* Ask for a choice */
\r
2076 memset(&ofn, 0, sizeof(ofn));
\r
2077 ofn.lStructSize = sizeof(ofn);
\r
2078 ofn.hwndOwner = data[0].w;
\r
2079 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
\r
2080 ofn.nFilterIndex = 1;
\r
2081 ofn.lpstrFile = tmp;
\r
2082 ofn.nMaxFile = 128;
\r
2083 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
\r
2084 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
2085 ofn.lpstrDefExt = "fon";
\r
2087 /* Force choice if legal */
\r
2088 if (GetOpenFileName(&ofn))
\r
2090 /* Force the font */
\r
2091 if (term_force_font(td, tmp))
\r
2093 /* Access the standard font file */
\r
2094 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
2096 /* Force the use of that font */
\r
2097 (void)term_force_font(td, tmp);
\r
2100 /* Assume not bizarre */
\r
2101 td->bizarre = FALSE;
\r
2103 /* Reset the tile info */
\r
2104 td->tile_wid = td->font_wid;
\r
2105 td->tile_hgt = td->font_hgt;
\r
2107 /* Analyze the font */
\r
2110 /* Resize the window */
\r
2111 term_window_resize(td);
\r
2118 * Allow the user to lock this window.
\r
2120 static void term_window_pos(term_data *td, HWND hWnd)
\r
2122 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
\r
2123 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
\r
2126 static void windows_map(void);
\r
2129 * Hack -- redraw a term_data
\r
2131 static void term_data_redraw(term_data *td)
\r
2133 if (td->map_active)
\r
2135 /* Redraw the map */
\r
2140 /* Activate the term */
\r
2141 Term_activate(&td->t);
\r
2143 /* Redraw the contents */
\r
2146 /* Restore the term */
\r
2147 Term_activate(term_screen);
\r
2152 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
\r
2156 HBRUSH myBrush, oldBrush;
\r
2158 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
\r
2159 int tx = td->size_ow1 + x * td->tile_wid;
\r
2160 int ty = td->size_oh1 + y * td->tile_hgt;
\r
2161 int tw = w * td->tile_wid - 1;
\r
2162 int th = h * td->tile_hgt - 1;
\r
2164 hdc = GetDC(hWnd);
\r
2165 myBrush = CreateSolidBrush(RGB(255, 255, 255));
\r
2166 oldBrush = SelectObject(hdc, myBrush);
\r
2167 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2169 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
\r
2171 SelectObject(hdc, oldBrush);
\r
2172 SelectObject(hdc, oldPen);
\r
2177 /*** Function hooks needed by "Term" ***/
\r
2183 * Initialize a new Term
\r
2185 static void Term_init_win(term *t)
\r
2192 * Nuke an old Term
\r
2194 static void Term_nuke_win(term *t)
\r
2203 * Interact with the User
\r
2205 static errr Term_user_win(int n)
\r
2216 * React to global changes
\r
2218 static errr Term_xtra_win_react(void)
\r
2223 /* Simple color */
\r
2226 /* Save the default colors */
\r
2227 for (i = 0; i < 256; i++)
\r
2229 /* Simply accept the desired colors */
\r
2230 win_pal[i] = angband_color_table[i][0];
\r
2234 /* Complex color */
\r
2241 bool change = FALSE;
\r
2243 /* Save the default colors */
\r
2244 for (i = 0; i < 256; i++)
\r
2246 /* Extract desired values */
\r
2247 rv = angband_color_table[i][1];
\r
2248 gv = angband_color_table[i][2];
\r
2249 bv = angband_color_table[i][3];
\r
2251 /* Extract a full color code */
\r
2252 code = PALETTERGB(rv, gv, bv);
\r
2254 /* Activate changes */
\r
2255 if (win_clr[i] != code)
\r
2257 /* Note the change */
\r
2260 /* Apply the desired color */
\r
2261 win_clr[i] = code;
\r
2265 /* Activate the palette if needed */
\r
2266 if (change) (void)new_palette();
\r
2272 /* Handle "arg_sound" */
\r
2273 if (use_sound != arg_sound)
\r
2275 /* Initialize (if needed) */
\r
2276 if (arg_sound && !init_sound())
\r
2279 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
\r
2281 /* Cannot enable */
\r
2282 arg_sound = FALSE;
\r
2285 /* Change setting */
\r
2286 use_sound = arg_sound;
\r
2293 /* Handle "arg_sound" */
\r
2294 if (use_music != arg_music)
\r
2296 /* Initialize (if needed) */
\r
2297 if (arg_music && !init_music())
\r
2300 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
\r
2301 /* Cannot enable */
\r
2302 arg_music = FALSE;
\r
2305 /* Change setting */
\r
2306 use_music = arg_music;
\r
2308 if(!arg_music) stop_music();
\r
2309 else select_floor_music();
\r
2316 #ifdef USE_GRAPHICS
\r
2318 /* Handle "arg_graphics" */
\r
2319 if (use_graphics != arg_graphics)
\r
2321 /* Initialize (if needed) */
\r
2322 if (arg_graphics && !init_graphics())
\r
2325 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
\r
2327 /* Cannot enable */
\r
2328 arg_graphics = GRAPHICS_NONE;
\r
2331 /* Change setting */
\r
2332 use_graphics = arg_graphics;
\r
2334 /* Reset visuals */
\r
2335 #ifdef ANGBAND_2_8_1
\r
2337 #else /* ANGBAND_2_8_1 */
\r
2338 reset_visuals(TRUE);
\r
2339 #endif /* ANGBAND_2_8_1 */
\r
2342 #endif /* USE_GRAPHICS */
\r
2345 /* Clean up windows */
\r
2346 for (i = 0; i < MAX_TERM_DATA; i++)
\r
2350 term_data *td = &data[i];
\r
2352 /* Update resized windows */
\r
2353 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
\r
2356 Term_activate(&td->t);
\r
2358 /* Hack -- Resize the term */
\r
2359 Term_resize(td->cols, td->rows);
\r
2361 /* Redraw the contents */
\r
2365 Term_activate(old);
\r
2376 * Process at least one event
\r
2378 static errr Term_xtra_win_event(int v)
\r
2382 /* Wait for an event */
\r
2386 if (GetMessage(&msg, NULL, 0, 0))
\r
2388 TranslateMessage(&msg);
\r
2389 DispatchMessage(&msg);
\r
2393 /* Check for an event */
\r
2397 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2399 TranslateMessage(&msg);
\r
2400 DispatchMessage(&msg);
\r
2410 * Process all pending events
\r
2412 static errr Term_xtra_win_flush(void)
\r
2416 /* Process all pending events */
\r
2417 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2419 TranslateMessage(&msg);
\r
2420 DispatchMessage(&msg);
\r
2429 * Hack -- clear the screen
\r
2431 * Make this more efficient XXX XXX XXX
\r
2433 static errr Term_xtra_win_clear(void)
\r
2435 term_data *td = (term_data*)(Term->data);
\r
2440 /* Rectangle to erase */
\r
2441 rc.left = td->size_ow1;
\r
2442 rc.right = rc.left + td->cols * td->tile_wid;
\r
2443 rc.top = td->size_oh1;
\r
2444 rc.bottom = rc.top + td->rows * td->tile_hgt;
\r
2447 hdc = GetDC(td->w);
\r
2448 SetBkColor(hdc, RGB(0, 0, 0));
\r
2449 SelectObject(hdc, td->font_id);
\r
2450 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2455 rc.left = 0; rc.top = 0;
\r
2458 ReleaseDC(td->w, hdc);
\r
2466 * Hack -- make a noise
\r
2468 static errr Term_xtra_win_noise(void)
\r
2470 MessageBeep(MB_ICONASTERISK);
\r
2476 * Hack -- make a sound
\r
2478 static errr Term_xtra_win_sound(int v)
\r
2483 #endif /* USE_SOUND */
\r
2485 /* Sound disabled */
\r
2486 if (!use_sound) return (1);
\r
2488 /* Illegal sound */
\r
2489 if ((v < 0) || (v >= SOUND_MAX)) return (1);
\r
2493 /* Count the samples */
\r
2494 for (i = 0; i < SAMPLE_MAX; i++)
\r
2496 if (!sound_file[v][i])
\r
2501 if (i == 0) return (1);
\r
2503 /* Build the path */
\r
2504 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
\r
2508 /* Play the sound, catch errors */
\r
2509 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
\r
2513 /* Play the sound, catch errors */
\r
2514 return (sndPlaySound(buf, SND_ASYNC));
\r
2516 #endif /* WIN32 */
\r
2518 #else /* USE_SOUND */
\r
2523 #endif /* USE_SOUND */
\r
2527 * Hack -- play a music
\r
2529 static errr Term_xtra_win_music(int n, int v)
\r
2534 #endif /* USE_MUSIC */
\r
2536 /* Sound disabled */
\r
2538 if(!use_music) return (1);
\r
2540 /* Illegal sound */
\r
2541 if(n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return (1);
\r
2542 else if(v < 0 || v >= 1000) return(1); /*!< TODO */
\r
2548 case TERM_XTRA_MUSIC_BASIC:
\r
2549 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2551 case TERM_XTRA_MUSIC_DUNGEON:
\r
2552 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2554 case TERM_XTRA_MUSIC_QUEST:
\r
2555 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2557 case TERM_XTRA_MUSIC_TOWN:
\r
2558 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2565 //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2566 //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2572 case TERM_XTRA_MUSIC_BASIC:
\r
2573 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2575 case TERM_XTRA_MUSIC_DUNGEON:
\r
2576 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2578 case TERM_XTRA_MUSIC_QUEST:
\r
2579 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2581 case TERM_XTRA_MUSIC_TOWN:
\r
2582 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2589 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2590 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2596 case TERM_XTRA_MUSIC_BASIC:
\r
2597 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
\r
2599 case TERM_XTRA_MUSIC_DUNGEON:
\r
2600 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
\r
2602 case TERM_XTRA_MUSIC_QUEST:
\r
2603 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
\r
2605 case TERM_XTRA_MUSIC_TOWN:
\r
2606 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
\r
2610 if(current_music_type == n && current_music_id == v)
\r
2614 current_music_type = n;
\r
2615 current_music_id = v;
\r
2619 mop.lpstrDeviceType = mci_device_type;
\r
2620 mop.lpstrElementName = buf;
\r
2621 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2622 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2623 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
\r
2624 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
2625 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
2628 #endif /* WIN32 */
\r
2630 #else /* USE_MUSIC */
\r
2634 #endif /* USE_MUSIC */
\r
2640 * Delay for "x" milliseconds
\r
2642 static int Term_xtra_win_delay(int v)
\r
2656 t = GetTickCount() + v;
\r
2659 while (GetTickCount() < t)
\r
2661 /* Handle messages */
\r
2662 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2664 TranslateMessage(&msg);
\r
2665 DispatchMessage(&msg);
\r
2669 #endif /* WIN32 */
\r
2677 * Do a "special thing"
\r
2679 static errr Term_xtra_win(int n, int v)
\r
2681 /* Handle a subset of the legal requests */
\r
2684 /* Make a bell sound */
\r
2685 case TERM_XTRA_NOISE:
\r
2687 return (Term_xtra_win_noise());
\r
2690 /* Play a music */
\r
2691 case TERM_XTRA_MUSIC_BASIC:
\r
2692 case TERM_XTRA_MUSIC_DUNGEON:
\r
2693 case TERM_XTRA_MUSIC_QUEST:
\r
2694 case TERM_XTRA_MUSIC_TOWN:
\r
2696 return (Term_xtra_win_music(n, v));
\r
2699 /* Make a special sound */
\r
2700 case TERM_XTRA_SOUND:
\r
2702 return (Term_xtra_win_sound(v));
\r
2705 /* Process random events */
\r
2706 case TERM_XTRA_BORED:
\r
2708 return (Term_xtra_win_event(0));
\r
2711 /* Process an event */
\r
2712 case TERM_XTRA_EVENT:
\r
2714 return (Term_xtra_win_event(v));
\r
2717 /* Flush all events */
\r
2718 case TERM_XTRA_FLUSH:
\r
2720 return (Term_xtra_win_flush());
\r
2723 /* Clear the screen */
\r
2724 case TERM_XTRA_CLEAR:
\r
2726 return (Term_xtra_win_clear());
\r
2729 /* React to global changes */
\r
2730 case TERM_XTRA_REACT:
\r
2732 return (Term_xtra_win_react());
\r
2735 /* Delay for some milliseconds */
\r
2736 case TERM_XTRA_DELAY:
\r
2738 return (Term_xtra_win_delay(v));
\r
2749 * Low level graphics (Assumes valid input).
\r
2751 * Draw a "cursor" at (x,y), using a "yellow box".
\r
2753 static errr Term_curs_win(int x, int y)
\r
2755 term_data *td = (term_data*)(Term->data);
\r
2760 int tile_wid, tile_hgt;
\r
2762 if (td->map_active)
\r
2764 tile_wid = td->map_tile_wid;
\r
2765 tile_hgt = td->map_tile_hgt;
\r
2769 tile_wid = td->tile_wid;
\r
2770 tile_hgt = td->tile_hgt;
\r
2773 /* Frame the grid */
\r
2774 rc.left = x * tile_wid + td->size_ow1;
\r
2775 rc.right = rc.left + tile_wid;
\r
2776 rc.top = y * tile_hgt + td->size_oh1;
\r
2777 rc.bottom = rc.top + tile_hgt;
\r
2779 /* Cursor is done as a yellow "box" */
\r
2780 hdc = GetDC(td->w);
\r
2781 FrameRect(hdc, &rc, hbrYellow);
\r
2782 ReleaseDC(td->w, hdc);
\r
2790 * Low level graphics (Assumes valid input).
\r
2792 * Draw a "big cursor" at (x,y), using a "yellow box".
\r
2794 static errr Term_bigcurs_win(int x, int y)
\r
2796 term_data *td = (term_data*)(Term->data);
\r
2801 int tile_wid, tile_hgt;
\r
2803 if (td->map_active)
\r
2805 /* Normal cursor in map window */
\r
2806 Term_curs_win(x, y);
\r
2811 tile_wid = td->tile_wid;
\r
2812 tile_hgt = td->tile_hgt;
\r
2815 /* Frame the grid */
\r
2816 rc.left = x * tile_wid + td->size_ow1;
\r
2817 rc.right = rc.left + 2 * tile_wid;
\r
2818 rc.top = y * tile_hgt + td->size_oh1;
\r
2819 rc.bottom = rc.top + tile_hgt;
\r
2821 /* Cursor is done as a yellow "box" */
\r
2822 hdc = GetDC(td->w);
\r
2823 FrameRect(hdc, &rc, hbrYellow);
\r
2824 ReleaseDC(td->w, hdc);
\r
2832 * Low level graphics (Assumes valid input).
\r
2834 * Erase a "block" of "n" characters starting at (x,y).
\r
2836 static errr Term_wipe_win(int x, int y, int n)
\r
2838 term_data *td = (term_data*)(Term->data);
\r
2843 /* Rectangle to erase in client coords */
\r
2844 rc.left = x * td->tile_wid + td->size_ow1;
\r
2845 rc.right = rc.left + n * td->tile_wid;
\r
2846 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2847 rc.bottom = rc.top + td->tile_hgt;
\r
2849 hdc = GetDC(td->w);
\r
2850 SetBkColor(hdc, RGB(0, 0, 0));
\r
2851 SelectObject(hdc, td->font_id);
\r
2856 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2857 ReleaseDC(td->w, hdc);
\r
2865 * Low level graphics. Assumes valid input.
\r
2867 * Draw several ("n") chars, with an attr, at a given location.
\r
2869 * All "graphic" data is handled by "Term_pict_win()", below.
\r
2871 * One would think there is a more efficient method for telling a window
\r
2872 * what color it should be using to draw with, but perhaps simply changing
\r
2873 * it every time is not too inefficient. XXX XXX XXX
\r
2875 static errr Term_text_win(int x, int y, int n, byte a, const char *s)
\r
2877 term_data *td = (term_data*)(Term->data);
\r
2881 #if 1 /* #ifdef JP */
\r
2882 static HBITMAP WALL;
\r
2883 static HBRUSH myBrush, oldBrush;
\r
2884 static HPEN oldPen;
\r
2885 static bool init_done = FALSE;
\r
2888 WALL = LoadBitmap(hInstance, AppName);
\r
2889 myBrush = CreatePatternBrush(WALL);
\r
2894 /* Total rectangle */
\r
2895 rc.left = x * td->tile_wid + td->size_ow1;
\r
2896 rc.right = rc.left + n * td->tile_wid;
\r
2897 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2898 rc.bottom = rc.top + td->tile_hgt;
\r
2901 hdc = GetDC(td->w);
\r
2903 /* Background color */
\r
2904 SetBkColor(hdc, RGB(0, 0, 0));
\r
2906 /* Foreground color */
\r
2909 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
\r
2911 else if (paletted)
\r
2913 SetTextColor(hdc, win_clr[a&0x0F]);
\r
2917 SetTextColor(hdc, win_clr[a]);
\r
2920 /* Use the font */
\r
2921 SelectObject(hdc, td->font_id);
\r
2924 if (use_bg) SetBkMode(hdc, TRANSPARENT);
\r
2926 /* Bizarre size */
\r
2927 if (td->bizarre ||
\r
2928 (td->tile_hgt != td->font_hgt) ||
\r
2929 (td->tile_wid != td->font_wid))
\r
2933 /* Erase complete rectangle */
\r
2934 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2937 if (use_bg) DrawBG(hdc, &rc);
\r
2939 /* New rectangle */
\r
2940 rc.left += ((td->tile_wid - td->font_wid) / 2);
\r
2941 rc.right = rc.left + td->font_wid;
\r
2942 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
\r
2943 rc.bottom = rc.top + td->font_hgt;
\r
2945 /* Dump each character */
\r
2946 for (i = 0; i < n; i++)
\r
2949 if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
\r
2951 rc.right += td->font_wid;
\r
2953 oldBrush = SelectObject(hdc, myBrush);
\r
2954 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2956 /* Dump the wall */
\r
2957 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2959 SelectObject(hdc, oldBrush);
\r
2960 SelectObject(hdc, oldPen);
\r
2961 rc.right -= td->font_wid;
\r
2965 rc.left += 2 * td->tile_wid;
\r
2966 rc.right += 2 * td->tile_wid;
\r
2968 else if ( iskanji(*(s+i)) ) /* 2バイト文字 */
\r
2970 rc.right += td->font_wid;
\r
2971 /* Dump the text */
\r
2972 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2974 rc.right -= td->font_wid;
\r
2978 rc.left += 2 * td->tile_wid;
\r
2979 rc.right += 2 * td->tile_wid;
\r
2980 } else if (*(s+i)==127){
\r
2981 oldBrush = SelectObject(hdc, myBrush);
\r
2982 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2984 /* Dump the wall */
\r
2985 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2987 SelectObject(hdc, oldBrush);
\r
2988 SelectObject(hdc, oldPen);
\r
2991 rc.left += td->tile_wid;
\r
2992 rc.right += td->tile_wid;
\r
2994 /* Dump the text */
\r
2995 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
\r
2998 rc.left += td->tile_wid;
\r
2999 rc.right += td->tile_wid;
\r
3004 oldBrush = SelectObject(hdc, myBrush);
\r
3005 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
3007 /* Dump the wall */
\r
3008 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
3010 SelectObject(hdc, oldBrush);
\r
3011 SelectObject(hdc, oldPen);
\r
3014 rc.left += td->tile_wid;
\r
3015 rc.right += td->tile_wid;
\r
3017 /* Dump the text */
\r
3018 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
3022 rc.left += td->tile_wid;
\r
3023 rc.right += td->tile_wid;
\r
3026 /* Dump the text */
\r
3027 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
\r
3031 rc.left += td->tile_wid;
\r
3032 rc.right += td->tile_wid;
\r
3042 /* Dump the text */
\r
3043 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
\r
3048 ReleaseDC(td->w, hdc);
\r
3056 * Low level graphics. Assumes valid input.
\r
3058 * Draw an array of "special" attr/char pairs at the given location.
\r
3060 * We use the "Term_pict_win()" function for "graphic" data, which are
\r
3061 * encoded by setting the "high-bits" of both the "attr" and the "char"
\r
3062 * data. We use the "attr" to represent the "row" of the main bitmap,
\r
3063 * and the "char" to represent the "col" of the main bitmap. The use
\r
3064 * of this function is induced by the "higher_pict" flag.
\r
3066 * If "graphics" is not available, we simply "wipe" the given grids.
\r
3068 static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
\r
3070 term_data *td = (term_data*)(Term->data);
\r
3072 #ifdef USE_GRAPHICS
\r
3075 int x1, y1, w1, h1, tw1, th1;
\r
3076 int x2, y2, w2, h2, tw2 = 0;
\r
3079 HDC hdcMask = NULL;
\r
3083 HBITMAP hbmSrcOld;
\r
3086 if (!use_graphics)
\r
3088 /* Erase the grids */
\r
3089 return (Term_wipe_win(x, y, n));
\r
3092 /* Size of bitmap cell */
\r
3093 w1 = infGraph.CellWidth;
\r
3094 h1 = infGraph.CellHeight;
\r
3095 tw1 = infGraph.TileWidth;
\r
3096 th1 = infGraph.TileHeight;
\r
3098 /* Size of window cell */
\r
3099 if (td->map_active)
\r
3101 w2 = td->map_tile_wid;
\r
3102 h2 = td->map_tile_hgt;
\r
3106 w2 = td->tile_wid;
\r
3107 h2 = td->tile_hgt;
\r
3110 /* big tile mode */
\r
3111 if (use_bigtile) tw2 *= 2;
\r
3114 /* Location of window cell */
\r
3115 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
\r
3116 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
\r
3119 hdc = GetDC(td->w);
\r
3122 hdcSrc = CreateCompatibleDC(hdc);
\r
3123 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
\r
3125 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3127 hdcMask = CreateCompatibleDC(hdc);
\r
3128 SelectObject(hdcMask, infMask.hBitmap);
\r
3131 /* Draw attr/char pairs */
\r
3132 for (i = 0; i < n; i++, x2 += w2)
\r
3138 /* Extract picture */
\r
3139 int row = (a & 0x7F);
\r
3140 int col = (c & 0x7F);
\r
3142 /* Location of bitmap cell */
\r
3146 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3148 x3 = (tcp[i] & 0x7F) * w1;
\r
3149 y3 = (tap[i] & 0x7F) * h1;
\r
3150 tw2 = tw2 * w1 / tw1;
\r
3151 h2 = h2 * h1 / th1;
\r
3153 /* Perfect size */
\r
3154 if ((tw1 == tw2) && (th1 == h2))
\r
3156 /* Copy the terrain picture from the bitmap to the window */
\r
3157 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
\r
3159 /* Mask out the tile */
\r
3160 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
\r
3162 /* Draw the tile */
\r
3163 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
\r
3166 /* Need to stretch */
\r
3169 /* Set the correct mode for stretching the tiles */
\r
3170 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3172 /* Copy the terrain picture from the bitmap to the window */
\r
3173 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
\r
3175 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
\r
3177 /* Only draw if terrain and overlay are different */
\r
3178 if ((x1 != x3) || (y1 != y3))
\r
3180 /* Mask out the tile */
\r
3181 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
\r
3183 /* Draw the tile */
\r
3184 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
\r
3190 /* Perfect size */
\r
3191 if ((w1 == tw2) && (h1 == h2))
\r
3193 /* Copy the picture from the bitmap to the window */
\r
3194 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
\r
3197 /* Need to stretch */
\r
3200 /* Set the correct mode for stretching the tiles */
\r
3201 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3203 /* Copy the picture from the bitmap to the window */
\r
3204 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
\r
3210 SelectObject(hdcSrc, hbmSrcOld);
\r
3213 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3216 SelectObject(hdcMask, hbmSrcOld);
\r
3217 DeleteDC(hdcMask);
\r
3221 ReleaseDC(td->w, hdc);
\r
3223 #else /* USE_GRAPHICS */
\r
3225 /* Just erase this grid */
\r
3226 return (Term_wipe_win(x, y, n));
\r
3228 #endif /* USE_GRAPHICS */
\r
3235 static void windows_map(void)
\r
3237 term_data *td = &data[0];
\r
3240 int x, min_x, max_x;
\r
3241 int y, min_y, max_y;
\r
3246 /* Only in graphics mode */
\r
3247 if (!use_graphics) return;
\r
3249 /* Clear screen */
\r
3250 Term_xtra_win_clear();
\r
3252 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
\r
3253 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
\r
3254 td->map_active = TRUE;
\r
3263 /* Draw the map */
\r
3264 for (x = min_x; x < max_x; x++)
\r
3266 for (y = min_y; y < max_y; y++)
\r
3268 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
\r
3270 /* Ignore non-graphics */
\r
3271 if ((a & 0x80) && (c & 0x80))
\r
3273 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
\r
3278 /* Hilite the player */
\r
3279 Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
\r
3281 /* Wait for a keypress, flush key buffer */
\r
3282 Term_inkey(&c, TRUE, TRUE);
\r
3285 /* Switch off the map display */
\r
3286 td->map_active = FALSE;
\r
3288 /* Restore screen */
\r
3289 Term_xtra_win_clear();
\r
3294 /*** Other routines ***/
\r
3298 * Create and initialize a "term_data" given a title
\r
3300 static void term_data_link(term_data *td)
\r
3304 /* Initialize the term */
\r
3305 term_init(t, td->cols, td->rows, td->keys);
\r
3307 /* Use a "software" cursor */
\r
3308 t->soft_cursor = TRUE;
\r
3310 /* Use "Term_pict" for "graphic" data */
\r
3311 t->higher_pict = TRUE;
\r
3313 /* Erase with "white space" */
\r
3314 t->attr_blank = TERM_WHITE;
\r
3315 t->char_blank = ' ';
\r
3318 /* Prepare the init/nuke hooks */
\r
3319 t->init_hook = Term_init_win;
\r
3320 t->nuke_hook = Term_nuke_win;
\r
3323 /* Prepare the template hooks */
\r
3324 t->user_hook = Term_user_win;
\r
3325 t->xtra_hook = Term_xtra_win;
\r
3326 t->curs_hook = Term_curs_win;
\r
3327 t->bigcurs_hook = Term_bigcurs_win;
\r
3328 t->wipe_hook = Term_wipe_win;
\r
3329 t->text_hook = Term_text_win;
\r
3330 t->pict_hook = Term_pict_win;
\r
3332 /* Remember where we came from */
\r
3333 t->data = (vptr)(td);
\r
3338 * Create the windows
\r
3340 * First, instantiate the "default" values, then read the "ini_file"
\r
3341 * to over-ride selected values, then create the windows, and fonts.
\r
3343 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
\r
3344 * must make active to realize the palette. XXX XXX XXX
\r
3346 static void init_windows(void)
\r
3352 #if 0 /* #ifndef JP */
\r
3358 WIPE(td, term_data);
\r
3362 td->s = angband_term_name[0];
\r
3368 td->visible = TRUE;
\r
3373 td->pos_x = 7 * 30;
\r
3374 td->pos_y = 7 * 20;
\r
3375 td->posfix = FALSE;
\r
3376 #if 1 /* #ifdef JP */
\r
3377 td->bizarre = TRUE;
\r
3380 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3383 WIPE(td, term_data);
\r
3384 td->s = angband_term_name[i];
\r
3388 td->visible = FALSE;
\r
3393 td->pos_x = (7 - i) * 30;
\r
3394 td->pos_y = (7 - i) * 20;
\r
3395 td->posfix = FALSE;
\r
3396 #if 1 /* #ifdef JP */
\r
3397 td->bizarre = TRUE;
\r
3406 /* Main window (need these before term_getsize gets called) */
\r
3408 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
\r
3409 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
\r
3411 td->dwExStyle = 0;
\r
3412 td->visible = TRUE;
\r
3414 /* Sub windows (need these before term_getsize gets called) */
\r
3415 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3418 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
\r
3419 td->dwExStyle = (WS_EX_TOOLWINDOW);
\r
3424 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3428 #if 1 /* #ifdef JP */
\r
3429 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
\r
3430 td->lf.lfCharSet = DEFAULT_CHARSET;
\r
3431 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
\r
3432 /* Activate the chosen font */
\r
3433 term_force_font(td, NULL);
\r
3434 if(!td->tile_wid) td->tile_wid = td->font_wid;
\r
3435 if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
\r
3437 /* Access the standard font file */
\r
3438 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
\r
3440 /* Activate the chosen font */
\r
3441 if (term_force_font(td, buf))
\r
3443 /* Access the standard font file */
\r
3444 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
3446 /* Force the use of that font */
\r
3447 (void)term_force_font(td, buf);
\r
3451 td->tile_hgt = 13;
\r
3453 /* Assume not bizarre */
\r
3454 td->bizarre = FALSE;
\r
3459 /* Analyze the font */
\r
3462 /* Resize the window */
\r
3463 term_window_resize(td);
\r
3467 /* Sub windows (reverse order) */
\r
3468 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
\r
3473 td->w = CreateWindowEx(td->dwExStyle, AngList,
\r
3474 td->s, td->dwStyle,
\r
3475 td->pos_x, td->pos_y,
\r
3476 td->size_wid, td->size_hgt,
\r
3477 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3479 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
\r
3483 td->size_hack = TRUE;
\r
3484 ShowWindow(td->w, SW_SHOW);
\r
3485 td->size_hack = FALSE;
\r
3488 term_data_link(td);
\r
3489 angband_term[i] = &td->t;
\r
3493 /* Activate the window */
\r
3494 SetActiveWindow(td->w);
\r
3497 if (data[i].posfix)
\r
3499 term_window_pos(&data[i], HWND_TOPMOST);
\r
3503 term_window_pos(&data[i], td->w);
\r
3513 td->w = CreateWindowEx(td->dwExStyle, AppName,
\r
3514 td->s, td->dwStyle,
\r
3515 td->pos_x, td->pos_y,
\r
3516 td->size_wid, td->size_hgt,
\r
3517 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3519 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
\r
3521 term_data_link(td);
\r
3522 angband_term[0] = &td->t;
\r
3523 normsize.x = td->cols;
\r
3524 normsize.y = td->rows;
\r
3526 /* Activate the main window */
\r
3527 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
\r
3528 else ShowWindow(td->w, SW_SHOW);
\r
3530 /* Bring main window back to top */
\r
3531 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
3534 /* New palette XXX XXX XXX */
\r
3535 (void)new_palette();
\r
3538 /* Create a "brush" for drawing the "cursor" */
\r
3539 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
\r
3542 /* Process pending messages */
\r
3543 (void)Term_xtra_win_flush();
\r
3549 * Prepare the menus
\r
3551 static void setup_menus(void)
\r
3555 HMENU hm = GetMenu(data[0].w);
\r
3558 /* Menu "File", Disable all */
\r
3559 EnableMenuItem(hm, IDM_FILE_NEW,
\r
3560 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3561 EnableMenuItem(hm, IDM_FILE_OPEN,
\r
3562 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3563 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3564 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3565 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3566 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3567 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3568 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3571 /* No character available */
\r
3572 if (!character_generated)
\r
3574 /* Menu "File", Item "New" */
\r
3575 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
\r
3577 /* Menu "File", Item "Open" */
\r
3578 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
\r
3581 /* A character available */
\r
3582 if (character_generated)
\r
3584 /* Menu "File", Item "Save" */
\r
3585 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3586 MF_BYCOMMAND | MF_ENABLED);
\r
3589 /* Menu "File", Item "Exit" */
\r
3590 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3591 MF_BYCOMMAND | MF_ENABLED);
\r
3593 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3594 MF_BYCOMMAND | MF_ENABLED);
\r
3597 /* Menu "Window::Visibility" */
\r
3598 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3600 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3601 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3603 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3604 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
\r
3606 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3607 MF_BYCOMMAND | MF_ENABLED);
\r
3610 /* Menu "Window::Font" */
\r
3611 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3613 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3614 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3616 if (data[i].visible)
\r
3618 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3619 MF_BYCOMMAND | MF_ENABLED);
\r
3623 /* Menu "Window::Window Position Fix" */
\r
3624 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3626 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3627 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3629 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3630 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
\r
3632 if (data[i].visible)
\r
3634 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3635 MF_BYCOMMAND | MF_ENABLED);
\r
3639 /* Menu "Window::Bizarre Display" */
\r
3640 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3642 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3643 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3645 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3646 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
\r
3648 if (data[i].visible)
\r
3650 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3651 MF_BYCOMMAND | MF_ENABLED);
\r
3656 /* Menu "Window::Increase Tile Width" */
\r
3657 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3659 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3660 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3662 if (data[i].visible)
\r
3664 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3665 MF_BYCOMMAND | MF_ENABLED);
\r
3670 /* Menu "Window::Decrease Tile Width" */
\r
3671 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3673 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3674 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3676 if (data[i].visible)
\r
3678 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3679 MF_BYCOMMAND | MF_ENABLED);
\r
3684 /* Menu "Window::Increase Tile Height" */
\r
3685 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3687 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3688 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3690 if (data[i].visible)
\r
3692 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3693 MF_BYCOMMAND | MF_ENABLED);
\r
3698 /* Menu "Window::Decrease Tile Height" */
\r
3699 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3701 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3702 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3704 if (data[i].visible)
\r
3706 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3707 MF_BYCOMMAND | MF_ENABLED);
\r
3712 /* Menu "Options", disable all */
\r
3713 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3714 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3715 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3716 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3717 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3718 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3719 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3720 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3721 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3722 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3724 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3725 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3728 /* Menu "Options", Item "Map" */
\r
3729 if (use_graphics != GRAPHICS_NONE)
\r
3730 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
\r
3732 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
\r
3733 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3735 /* Menu "Options", update all */
\r
3736 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3737 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
\r
3738 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3739 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
\r
3740 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3741 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
\r
3742 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
\r
3743 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
\r
3744 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3745 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
\r
3746 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
\r
3747 (arg_music ? MF_CHECKED : MF_UNCHECKED));
\r
3748 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3749 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
\r
3750 CheckMenuItem(hm, IDM_OPTIONS_BG,
\r
3751 (use_bg ? MF_CHECKED : MF_UNCHECKED));
\r
3753 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3754 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
\r
3757 #ifdef USE_GRAPHICS
\r
3758 /* Menu "Options", Item "Graphics" */
\r
3759 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
\r
3760 /* Menu "Options", Item "Graphics" */
\r
3761 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
\r
3762 /* Menu "Options", Item "Graphics" */
\r
3763 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
\r
3764 /* Menu "Options", Item "Graphics" */
\r
3765 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
\r
3766 #endif /* USE_GRAPHICS */
\r
3769 /* Menu "Options", Item "Sound" */
\r
3770 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
\r
3771 #endif /* USE_SOUND */
\r
3774 /* Menu "Options", Item "ScreenSaver" */
\r
3775 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3776 MF_BYCOMMAND | MF_ENABLED);
\r
3777 #endif /* USE_SAVER */
\r
3782 * Check for double clicked (or dragged) savefile
\r
3784 * Apparently, Windows copies the entire filename into the first
\r
3785 * piece of the "command line string". Perhaps we should extract
\r
3786 * the "basename" of that filename and append it to the "save" dir.
\r
3788 static void check_for_save_file(LPSTR cmd_line)
\r
3798 /* Extract filename */
\r
3799 strcat(savefile, s);
\r
3801 /* Validate the file */
\r
3802 validate_file(savefile);
\r
3804 /* Game in progress */
\r
3805 game_in_progress = TRUE;
\r
3813 * Process a menu command
\r
3815 static void process_menus(WORD wCmd)
\r
3827 case IDM_FILE_NEW:
\r
3831 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3833 else if (game_in_progress)
\r
3835 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
\r
3839 game_in_progress = TRUE;
\r
3848 case IDM_FILE_OPEN:
\r
3852 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3854 else if (game_in_progress)
\r
3856 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
\r
3860 memset(&ofn, 0, sizeof(ofn));
\r
3861 ofn.lStructSize = sizeof(ofn);
\r
3862 ofn.hwndOwner = data[0].w;
\r
3863 ofn.lpstrFilter = "Save Files (*.)\0*\0";
\r
3864 ofn.nFilterIndex = 1;
\r
3865 ofn.lpstrFile = savefile;
\r
3866 ofn.nMaxFile = 1024;
\r
3867 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
\r
3868 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
\r
3870 if (GetOpenFileName(&ofn))
\r
3872 /* Load 'savefile' */
\r
3873 validate_file(savefile);
\r
3874 game_in_progress = TRUE;
\r
3884 case IDM_FILE_SAVE:
\r
3886 if (game_in_progress && character_generated)
\r
3891 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
\r
3895 /* Hack -- Forget messages */
\r
3898 /* Save the game */
\r
3900 do_cmd_save_game(FALSE);
\r
3901 #else /* ZANGBAND */
\r
3902 do_cmd_save_game();
\r
3903 #endif /* ZANGBAND */
\r
3907 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
\r
3913 case IDM_FILE_EXIT:
\r
3915 if (game_in_progress && character_generated)
\r
3920 plog(_("今は終了できません。", "You may not do that right now."));
\r
3924 /* Hack -- Forget messages */
\r
3931 /* Save the game */
\r
3933 /* do_cmd_save_game(FALSE); */
\r
3934 #else /* ZANGBAND */
\r
3935 /* do_cmd_save_game(); */
\r
3936 #endif /* ZANGBAND */
\r
3937 Term_key_push(SPECIAL_KEY_QUIT);
\r
3945 case IDM_FILE_SCORE:
\r
3949 /* Build the filename */
\r
3950 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
\r
3952 /* Open the binary high score file, for reading */
\r
3953 highscore_fd = fd_open(buf, O_RDONLY);
\r
3955 /* Paranoia -- No score file */
\r
3956 if (highscore_fd < 0)
\r
3958 msg_print("Score file unavailable.");
\r
3965 /* Clear screen */
\r
3968 /* Display the scores */
\r
3969 display_scores_aux(0, MAX_HISCORES, -1, NULL);
\r
3971 /* Shut the high score file */
\r
3972 (void)fd_close(highscore_fd);
\r
3974 /* Forget the high score fd */
\r
3975 highscore_fd = -1;
\r
3980 /* Hack - Flush it */
\r
3988 case IDM_FILE_MOVIE:
\r
3992 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3994 else if (game_in_progress)
\r
3996 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
\r
4000 memset(&ofn, 0, sizeof(ofn));
\r
4001 ofn.lStructSize = sizeof(ofn);
\r
4002 ofn.hwndOwner = data[0].w;
\r
4003 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
\r
4004 ofn.nFilterIndex = 1;
\r
4005 ofn.lpstrFile = savefile;
\r
4006 ofn.nMaxFile = 1024;
\r
4007 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
\r
4008 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
4010 if (GetOpenFileName(&ofn))
\r
4012 /* Load 'savefile' */
\r
4013 prepare_browse_movie_aux(savefile);
\r
4023 case IDM_WINDOW_VIS_0:
\r
4025 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
\r
4029 /* Window visibility */
\r
4030 case IDM_WINDOW_VIS_1:
\r
4031 case IDM_WINDOW_VIS_2:
\r
4032 case IDM_WINDOW_VIS_3:
\r
4033 case IDM_WINDOW_VIS_4:
\r
4034 case IDM_WINDOW_VIS_5:
\r
4035 case IDM_WINDOW_VIS_6:
\r
4036 case IDM_WINDOW_VIS_7:
\r
4038 i = wCmd - IDM_WINDOW_VIS_0;
\r
4040 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4046 td->visible = TRUE;
\r
4047 ShowWindow(td->w, SW_SHOW);
\r
4048 term_data_redraw(td);
\r
4052 td->visible = FALSE;
\r
4053 td->posfix = FALSE;
\r
4054 ShowWindow(td->w, SW_HIDE);
\r
4060 /* Window fonts */
\r
4061 case IDM_WINDOW_FONT_0:
\r
4062 case IDM_WINDOW_FONT_1:
\r
4063 case IDM_WINDOW_FONT_2:
\r
4064 case IDM_WINDOW_FONT_3:
\r
4065 case IDM_WINDOW_FONT_4:
\r
4066 case IDM_WINDOW_FONT_5:
\r
4067 case IDM_WINDOW_FONT_6:
\r
4068 case IDM_WINDOW_FONT_7:
\r
4070 i = wCmd - IDM_WINDOW_FONT_0;
\r
4072 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4076 term_change_font(td);
\r
4081 /* Window Z Position */
\r
4082 case IDM_WINDOW_POS_1:
\r
4083 case IDM_WINDOW_POS_2:
\r
4084 case IDM_WINDOW_POS_3:
\r
4085 case IDM_WINDOW_POS_4:
\r
4086 case IDM_WINDOW_POS_5:
\r
4087 case IDM_WINDOW_POS_6:
\r
4088 case IDM_WINDOW_POS_7:
\r
4090 i = wCmd - IDM_WINDOW_POS_0;
\r
4092 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4096 if (!td->posfix && td->visible)
\r
4098 td->posfix = TRUE;
\r
4099 term_window_pos(td, HWND_TOPMOST);
\r
4103 td->posfix = FALSE;
\r
4104 term_window_pos(td, data[0].w);
\r
4110 /* Bizarre Display */
\r
4111 case IDM_WINDOW_BIZ_0:
\r
4112 case IDM_WINDOW_BIZ_1:
\r
4113 case IDM_WINDOW_BIZ_2:
\r
4114 case IDM_WINDOW_BIZ_3:
\r
4115 case IDM_WINDOW_BIZ_4:
\r
4116 case IDM_WINDOW_BIZ_5:
\r
4117 case IDM_WINDOW_BIZ_6:
\r
4118 case IDM_WINDOW_BIZ_7:
\r
4120 i = wCmd - IDM_WINDOW_BIZ_0;
\r
4122 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4126 td->bizarre = !td->bizarre;
\r
4130 term_window_resize(td);
\r
4135 /* Increase Tile Width */
\r
4136 case IDM_WINDOW_I_WID_0:
\r
4137 case IDM_WINDOW_I_WID_1:
\r
4138 case IDM_WINDOW_I_WID_2:
\r
4139 case IDM_WINDOW_I_WID_3:
\r
4140 case IDM_WINDOW_I_WID_4:
\r
4141 case IDM_WINDOW_I_WID_5:
\r
4142 case IDM_WINDOW_I_WID_6:
\r
4143 case IDM_WINDOW_I_WID_7:
\r
4145 i = wCmd - IDM_WINDOW_I_WID_0;
\r
4147 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4151 td->tile_wid += 1;
\r
4155 term_window_resize(td);
\r
4160 /* Decrease Tile Height */
\r
4161 case IDM_WINDOW_D_WID_0:
\r
4162 case IDM_WINDOW_D_WID_1:
\r
4163 case IDM_WINDOW_D_WID_2:
\r
4164 case IDM_WINDOW_D_WID_3:
\r
4165 case IDM_WINDOW_D_WID_4:
\r
4166 case IDM_WINDOW_D_WID_5:
\r
4167 case IDM_WINDOW_D_WID_6:
\r
4168 case IDM_WINDOW_D_WID_7:
\r
4170 i = wCmd - IDM_WINDOW_D_WID_0;
\r
4172 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4176 td->tile_wid -= 1;
\r
4180 term_window_resize(td);
\r
4185 /* Increase Tile Height */
\r
4186 case IDM_WINDOW_I_HGT_0:
\r
4187 case IDM_WINDOW_I_HGT_1:
\r
4188 case IDM_WINDOW_I_HGT_2:
\r
4189 case IDM_WINDOW_I_HGT_3:
\r
4190 case IDM_WINDOW_I_HGT_4:
\r
4191 case IDM_WINDOW_I_HGT_5:
\r
4192 case IDM_WINDOW_I_HGT_6:
\r
4193 case IDM_WINDOW_I_HGT_7:
\r
4195 i = wCmd - IDM_WINDOW_I_HGT_0;
\r
4197 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4201 td->tile_hgt += 1;
\r
4205 term_window_resize(td);
\r
4210 /* Decrease Tile Height */
\r
4211 case IDM_WINDOW_D_HGT_0:
\r
4212 case IDM_WINDOW_D_HGT_1:
\r
4213 case IDM_WINDOW_D_HGT_2:
\r
4214 case IDM_WINDOW_D_HGT_3:
\r
4215 case IDM_WINDOW_D_HGT_4:
\r
4216 case IDM_WINDOW_D_HGT_5:
\r
4217 case IDM_WINDOW_D_HGT_6:
\r
4218 case IDM_WINDOW_D_HGT_7:
\r
4220 i = wCmd - IDM_WINDOW_D_HGT_0;
\r
4222 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4226 td->tile_hgt -= 1;
\r
4230 term_window_resize(td);
\r
4235 case IDM_OPTIONS_NO_GRAPHICS:
\r
4240 plog("You may not do that right now.");
\r
4244 /* Toggle "arg_graphics" */
\r
4245 if (arg_graphics != GRAPHICS_NONE)
\r
4247 arg_graphics = GRAPHICS_NONE;
\r
4249 /* React to changes */
\r
4250 Term_xtra_win_react();
\r
4252 /* Hack -- Force redraw */
\r
4253 Term_key_push(KTRL('R'));
\r
4259 case IDM_OPTIONS_OLD_GRAPHICS:
\r
4264 plog("You may not do that right now.");
\r
4268 /* Toggle "arg_graphics" */
\r
4269 if (arg_graphics != GRAPHICS_ORIGINAL)
\r
4271 arg_graphics = GRAPHICS_ORIGINAL;
\r
4273 /* React to changes */
\r
4274 Term_xtra_win_react();
\r
4276 /* Hack -- Force redraw */
\r
4277 Term_key_push(KTRL('R'));
\r
4283 case IDM_OPTIONS_NEW_GRAPHICS:
\r
4288 plog("You may not do that right now.");
\r
4292 /* Toggle "arg_graphics" */
\r
4293 if (arg_graphics != GRAPHICS_ADAM_BOLT)
\r
4295 arg_graphics = GRAPHICS_ADAM_BOLT;
\r
4297 /* React to changes */
\r
4298 Term_xtra_win_react();
\r
4300 /* Hack -- Force redraw */
\r
4301 Term_key_push(KTRL('R'));
\r
4307 case IDM_OPTIONS_NEW2_GRAPHICS:
\r
4312 plog("You may not do that right now.");
\r
4316 /* Toggle "arg_graphics" */
\r
4317 if (arg_graphics != GRAPHICS_HENGBAND)
\r
4319 arg_graphics = GRAPHICS_HENGBAND;
\r
4321 /* React to changes */
\r
4322 Term_xtra_win_react();
\r
4324 /* Hack -- Force redraw */
\r
4325 Term_key_push(KTRL('R'));
\r
4331 case IDM_OPTIONS_BIGTILE:
\r
4338 plog("You may not do that right now.");
\r
4342 /* Toggle "arg_sound" */
\r
4343 arg_bigtile = !arg_bigtile;
\r
4346 Term_activate(&td->t);
\r
4348 /* Resize the term */
\r
4349 Term_resize(td->cols, td->rows);
\r
4351 /* Redraw later */
\r
4352 InvalidateRect(td->w, NULL, TRUE);
\r
4357 case IDM_OPTIONS_MUSIC:
\r
4362 plog("You may not do that right now.");
\r
4366 /* Toggle "arg_sound" */
\r
4367 arg_music = !arg_music;
\r
4369 /* React to changes */
\r
4370 Term_xtra_win_react();
\r
4372 /* Hack -- Force redraw */
\r
4373 Term_key_push(KTRL('R'));
\r
4378 case IDM_OPTIONS_SOUND:
\r
4383 plog("You may not do that right now.");
\r
4387 /* Toggle "arg_sound" */
\r
4388 arg_sound = !arg_sound;
\r
4390 /* React to changes */
\r
4391 Term_xtra_win_react();
\r
4393 /* Hack -- Force redraw */
\r
4394 Term_key_push(KTRL('R'));
\r
4400 case IDM_OPTIONS_BG:
\r
4405 plog("You may not do that right now.");
\r
4409 /* Toggle "use_bg" */
\r
4414 /* React to changes */
\r
4415 Term_xtra_win_react();
\r
4417 /* Hack -- Force redraw */
\r
4418 Term_key_push(KTRL('R'));
\r
4424 case IDM_OPTIONS_OPEN_BG:
\r
4429 plog("You may not do that right now.");
\r
4434 memset(&ofn, 0, sizeof(ofn));
\r
4435 ofn.lStructSize = sizeof(ofn);
\r
4436 ofn.hwndOwner = data[0].w;
\r
4437 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
\r
4438 ofn.nFilterIndex = 1;
\r
4439 ofn.lpstrFile = bg_bitmap_file;
\r
4440 ofn.nMaxFile = 1023;
\r
4441 ofn.lpstrInitialDir = NULL;
\r
4442 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
\r
4443 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
\r
4445 if (GetOpenFileName(&ofn))
\r
4447 /* Load 'savefile' */
\r
4452 /* React to changes */
\r
4453 Term_xtra_win_react();
\r
4455 /* Hack -- Force redraw */
\r
4456 Term_key_push(KTRL('R'));
\r
4461 case IDM_DUMP_SCREEN_HTML:
\r
4463 static char buf[1024] = "";
\r
4464 memset(&ofn, 0, sizeof(ofn));
\r
4465 ofn.lStructSize = sizeof(ofn);
\r
4466 ofn.hwndOwner = data[0].w;
\r
4467 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
\r
4468 ofn.nFilterIndex = 1;
\r
4469 ofn.lpstrFile = buf;
\r
4470 ofn.nMaxFile = 1023;
\r
4471 ofn.lpstrDefExt = "html";
\r
4472 ofn.lpstrInitialDir = NULL;
\r
4473 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
\r
4474 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
\r
4476 if (GetSaveFileName(&ofn))
\r
4478 do_cmd_save_screen_html_aux(buf, 0);
\r
4485 case IDM_OPTIONS_SAVER:
\r
4489 DestroyWindow(hwndSaver);
\r
4494 /* Create a screen scaver window */
\r
4495 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
\r
4496 "Angband Screensaver",
\r
4497 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
\r
4498 0, 0, GetSystemMetrics(SM_CXSCREEN),
\r
4499 GetSystemMetrics(SM_CYSCREEN),
\r
4500 NULL, NULL, hInstance, NULL);
\r
4504 /* Push the window to the bottom XXX XXX XXX */
\r
4505 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
4509 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
\r
4517 case IDM_OPTIONS_MAP:
\r
4523 case IDM_HELP_CONTENTS:
\r
4527 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
\r
4528 if (check_file(tmp))
\r
4530 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
\r
4535 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4536 plog("代わりにオンラインヘルプを使用してください。");
\r
4538 plog_fmt("Cannot find help file: %s", tmp);
\r
4539 plog("Use the online help files instead.");
\r
4544 #else /* HTML_HELP */
\r
4547 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
\r
4548 if (check_file(tmp))
\r
4550 sprintf(buf, "winhelp.exe %s", tmp);
\r
4551 WinExec(buf, SW_NORMAL);
\r
4556 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4557 plog("代わりにオンラインヘルプを使用してください。");
\r
4559 plog_fmt("Cannot find help file: %s", tmp);
\r
4560 plog("Use the online help files instead.");
\r
4565 #endif /* HTML_HELP */
\r
4571 static bool process_keydown(WPARAM wParam, LPARAM lParam)
\r
4578 /* Extract the modifiers */
\r
4579 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
\r
4580 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
\r
4581 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
\r
4583 Term_no_press = (ma) ? TRUE : FALSE;
\r
4585 /* Handle "special" keys */
\r
4586 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
\r
4588 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
\r
4589 bool numpad = FALSE;
\r
4591 /* Begin the macro trigger */
\r
4592 Term_keypress(31);
\r
4594 /* Send the modifiers */
\r
4595 if (mc) Term_keypress('C');
\r
4596 if (ms) Term_keypress('S');
\r
4597 if (ma) Term_keypress('A');
\r
4599 /* Extract "scan code" */
\r
4600 i = LOBYTE(HIWORD(lParam));
\r
4602 /* Introduce the scan code */
\r
4603 Term_keypress('x');
\r
4605 /* Extended key bit */
\r
4608 /* Numpad Enter and '/' are extended key */
\r
4610 Term_no_press = TRUE;
\r
4611 case VK_RETURN: /* Enter */
\r
4614 /* Other extended keys are on full keyboard */
\r
4628 case VK_SEPARATOR:
\r
4630 Term_no_press = TRUE;
\r
4634 case VK_PRIOR: /* Page Up */
\r
4635 case VK_NEXT: /* Page Down */
\r
4642 numpad = !ext_key;
\r
4645 /* Special modifiers for keypad keys */
\r
4646 if (numpad) Term_keypress('K');
\r
4648 /* Encode the hexidecimal scan code */
\r
4649 Term_keypress(hexsym[i/16]);
\r
4650 Term_keypress(hexsym[i%16]);
\r
4652 /* End the macro trigger */
\r
4653 Term_keypress(13);
\r
4663 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4664 WPARAM wParam, LPARAM lParam);
\r
4665 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4666 WPARAM wParam, LPARAM lParam)
\r
4667 #else /* __MWERKS__ */
\r
4668 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4669 WPARAM wParam, LPARAM lParam)
\r
4670 #endif /* __MWERKS__ */
\r
4676 MINMAXINFO FAR *lpmmi;
\r
4682 /* Acquire proper "term_data" info */
\r
4683 td = (term_data *)GetWindowLong(hWnd, 0);
\r
4685 /* Handle message */
\r
4691 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
4699 mop.dwCallback=(DWORD)hWnd;
\r
4704 case WM_GETMINMAXINFO:
\r
4706 MINMAXINFO FAR *lpmmi;
\r
4709 lpmmi = (MINMAXINFO FAR *)lParam;
\r
4711 /* this message was sent before WM_NCCREATE */
\r
4712 if (!td) return 1;
\r
4714 /* Minimum window size is 80x24 */
\r
4715 rc.left = rc.top = 0;
\r
4716 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
4717 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
4720 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
4722 /* Save minimum size */
\r
4723 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
4724 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
4731 BeginPaint(hWnd, &ps);
\r
4732 if (td) term_data_redraw(td);
\r
4733 EndPaint(hWnd, &ps);
\r
4734 ValidateRect(hWnd, NULL);
\r
4739 case MM_MCINOTIFY:
\r
4741 if(wParam == MCI_NOTIFY_SUCCESSFUL)
\r
4743 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
4744 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
4750 case WM_SYSKEYDOWN:
\r
4753 if (process_keydown(wParam, lParam))
\r
4760 if (Term_no_press) Term_no_press = FALSE;
\r
4761 else Term_keypress(wParam);
\r
4765 case WM_LBUTTONDOWN:
\r
4767 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4768 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4769 mouse_down = TRUE;
\r
4775 case WM_LBUTTONUP:
\r
4780 TERM_POSITION dx = abs(oldx - mousex) + 1;
\r
4781 TERM_POSITION dy = abs(oldy - mousey) + 1;
\r
4782 TERM_POSITION ox = (oldx > mousex) ? mousex : oldx;
\r
4783 TERM_POSITION oy = (oldy > mousey) ? mousey : oldy;
\r
4785 mouse_down = FALSE;
\r
4786 paint_rect = FALSE;
\r
4789 sz = (dx + 3) * dy;
\r
4791 sz = (dx + 2) * dy;
\r
4793 hGlobal = GlobalAlloc(GHND, sz + 1);
\r
4794 if (hGlobal == NULL) return 0;
\r
4795 lpStr = (LPSTR)GlobalLock(hGlobal);
\r
4797 for (i = 0; i < dy; i++)
\r
4801 char **scr = data[0].t.scr->c;
\r
4803 C_MAKE(s, (dx + 1), char);
\r
4804 strncpy(s, &scr[oy + i][ox], dx);
\r
4808 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
\r
4811 if (ox + dx < data[0].cols)
\r
4813 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
\r
4816 for (j = 0; j < dx; j++)
\r
4818 if (s[j] == 127) s[j] = '#';
\r
4822 for (j = 0; j < dx; j++)
\r
4824 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
\r
4834 GlobalUnlock(hGlobal);
\r
4835 if (OpenClipboard(hWnd) == 0)
\r
4837 GlobalFree(hGlobal);
\r
4841 SetClipboardData(CF_TEXT, hGlobal);
\r
4849 case WM_MOUSEMOVE:
\r
4854 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4855 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4860 dx = abs(oldx - mousex) + 1;
\r
4861 dy = abs(oldy - mousey) + 1;
\r
4862 ox = (oldx > mousex) ? mousex : oldx;
\r
4863 oy = (oldy > mousey) ? mousey : oldy;
\r
4864 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4868 paint_rect = TRUE;
\r
4871 dx = abs(cx - mousex) + 1;
\r
4872 dy = abs(cy - mousey) + 1;
\r
4873 ox = (cx > mousex) ? mousex : cx;
\r
4874 oy = (cy > mousey) ? mousey : cy;
\r
4875 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4891 if (game_in_progress && character_generated)
\r
4895 plog(_("今は終了できません。", "You may not do that right now."));
\r
4899 /* Hack -- Forget messages */
\r
4906 /* Save the game */
\r
4908 /* do_cmd_save_game(FALSE); */
\r
4909 #else /* ZANGBAND */
\r
4910 /* do_cmd_save_game(); */
\r
4911 #endif /* ZANGBAND */
\r
4912 Term_key_push(SPECIAL_KEY_QUIT);
\r
4919 case WM_QUERYENDSESSION:
\r
4921 if (game_in_progress && character_generated)
\r
4923 /* Hack -- Forget messages */
\r
4926 /* Mega-Hack -- Delay death */
\r
4927 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
\r
4928 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
\r
4930 /* Hardcode panic save */
\r
4931 p_ptr->panic_save = 1;
\r
4933 /* Forbid suspend */
\r
4934 signals_ignore_tstp();
\r
4936 /* Indicate panic save */
\r
4937 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
\r
4940 (void)save_player();
\r
4954 process_menus(LOWORD(wParam));
\r
4960 /* this message was sent before WM_NCCREATE */
\r
4961 if (!td) return 1;
\r
4963 /* it was sent from inside CreateWindowEx */
\r
4964 if (!td->w) return 1;
\r
4966 /* was sent from WM_SIZE */
\r
4967 if (td->size_hack) return 1;
\r
4971 case SIZE_MINIMIZED:
\r
4973 /* Hide sub-windows */
\r
4974 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4976 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
\r
4981 case SIZE_MAXIMIZED:
\r
4983 /* fall through XXX XXX XXX */
\r
4986 case SIZE_RESTORED:
\r
4988 TERM_POSITION cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
4989 TERM_POSITION rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
4992 if ((td->cols != cols) || (td->rows != rows))
\r
4994 /* Save the new size */
\r
4998 if (!IsZoomed(td->w) && !IsIconic(td->w))
\r
5000 normsize.x = td->cols;
\r
5001 normsize.y = td->rows;
\r
5005 Term_activate(&td->t);
\r
5007 /* Resize the term */
\r
5008 Term_resize(td->cols, td->rows);
\r
5010 /* Redraw later */
\r
5011 InvalidateRect(td->w, NULL, TRUE);
\r
5014 td->size_hack = TRUE;
\r
5016 /* Show sub-windows */
\r
5017 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5019 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
\r
5022 td->size_hack = FALSE;
\r
5030 case WM_PALETTECHANGED:
\r
5032 /* Ignore if palette change caused by itself */
\r
5033 if ((HWND)wParam == hWnd) return 0;
\r
5035 /* Fall through... */
\r
5038 case WM_QUERYNEWPALETTE:
\r
5040 if (!paletted) return 0;
\r
5042 hdc = GetDC(hWnd);
\r
5044 SelectPalette(hdc, hPal, FALSE);
\r
5046 i = RealizePalette(hdc);
\r
5048 /* if any palette entries changed, repaint the window. */
\r
5049 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5051 ReleaseDC(hWnd, hdc);
\r
5058 if (wParam && !HIWORD(lParam))
\r
5060 /* Do something to sub-windows */
\r
5061 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5063 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
\r
5066 /* Focus on main window */
\r
5075 case WM_ACTIVATEAPP:
\r
5077 if (IsIconic(td->w)) break;
\r
5079 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5081 if(data[i].visible)
\r
5083 if (wParam == TRUE)
\r
5085 ShowWindow(data[i].w, SW_SHOW);
\r
5089 ShowWindow(data[i].w, SW_HIDE);
\r
5096 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5101 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5102 WPARAM wParam, LPARAM lParam);
\r
5103 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5104 WPARAM wParam, LPARAM lParam)
\r
5105 #else /* __MWERKS__ */
\r
5106 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5107 WPARAM wParam, LPARAM lParam)
\r
5108 #endif /* __MWERKS__ */
\r
5112 MINMAXINFO FAR *lpmmi;
\r
5120 /* Acquire proper "term_data" info */
\r
5121 td = (term_data *)GetWindowLong(hWnd, 0);
\r
5123 /* Process message */
\r
5129 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
5139 case WM_GETMINMAXINFO:
\r
5141 MINMAXINFO FAR *lpmmi;
\r
5144 lpmmi = (MINMAXINFO FAR *)lParam;
\r
5146 /* this message was sent before WM_NCCREATE */
\r
5147 if (!td) return 1;
\r
5149 /* Minimum window size is 80x24 */
\r
5150 rc.left = rc.top = 0;
\r
5151 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
5152 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
5155 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
5157 /* Save minimum size */
\r
5158 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
5159 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
5166 TERM_POSITION cols;
\r
5167 TERM_POSITION rows;
\r
5169 /* this message was sent before WM_NCCREATE */
\r
5170 if (!td) return 1;
\r
5172 /* it was sent from inside CreateWindowEx */
\r
5173 if (!td->w) return 1;
\r
5175 /* was sent from inside WM_SIZE */
\r
5176 if (td->size_hack) return 1;
\r
5178 td->size_hack = TRUE;
\r
5180 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
5181 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
5184 if ((td->cols != cols) || (td->rows != rows))
\r
5186 /* Save old term */
\r
5187 term *old_term = Term;
\r
5189 /* Save the new size */
\r
5194 Term_activate(&td->t);
\r
5196 /* Resize the term */
\r
5197 Term_resize(td->cols, td->rows);
\r
5200 Term_activate(old_term);
\r
5202 /* Redraw later */
\r
5203 InvalidateRect(td->w, NULL, TRUE);
\r
5205 /* HACK - Redraw all windows */
\r
5206 p_ptr->window = 0xFFFFFFFF;
\r
5210 td->size_hack = FALSE;
\r
5217 BeginPaint(hWnd, &ps);
\r
5218 if (td) term_data_redraw(td);
\r
5219 EndPaint(hWnd, &ps);
\r
5223 case WM_SYSKEYDOWN:
\r
5226 if (process_keydown(wParam, lParam))
\r
5233 if (Term_no_press) Term_no_press = FALSE;
\r
5234 else Term_keypress(wParam);
\r
5238 case WM_PALETTECHANGED:
\r
5240 /* ignore if palette change caused by itself */
\r
5241 if ((HWND)wParam == hWnd) return FALSE;
\r
5242 /* otherwise, fall through!!! */
\r
5245 case WM_QUERYNEWPALETTE:
\r
5247 if (!paletted) return 0;
\r
5248 hdc = GetDC(hWnd);
\r
5249 SelectPalette(hdc, hPal, FALSE);
\r
5250 i = RealizePalette(hdc);
\r
5251 /* if any palette entries changed, repaint the window. */
\r
5252 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5253 ReleaseDC(hWnd, hdc);
\r
5257 case WM_NCLBUTTONDOWN:
\r
5261 if (wParam == HTCLOSE) wParam = HTSYSMENU;
\r
5262 #endif /* HTCLOSE */
\r
5264 if (wParam == HTSYSMENU)
\r
5268 td->visible = FALSE;
\r
5269 ShowWindow(td->w, SW_HIDE);
\r
5279 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5285 #define MOUSE_SENS 40
\r
5288 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5289 WPARAM wParam, LPARAM lParam);
\r
5290 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5291 WPARAM wParam, LPARAM lParam)
\r
5292 #else /* __MWERKS__ */
\r
5293 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5294 WPARAM wParam, LPARAM lParam)
\r
5295 #endif /* __MWERKS__ */
\r
5297 static int iMouse = 0;
\r
5298 static WORD xMouse = 0;
\r
5299 static WORD yMouse = 0;
\r
5313 case WM_SETCURSOR:
\r
5322 if (LOWORD(wParam) == WA_INACTIVE) break;
\r
5324 /* else fall through */
\r
5328 case WM_LBUTTONDOWN:
\r
5329 case WM_MBUTTONDOWN:
\r
5330 case WM_RBUTTONDOWN:
\r
5333 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5337 case WM_MOUSEMOVE:
\r
5341 dx = LOWORD(lParam) - xMouse;
\r
5342 dy = HIWORD(lParam) - yMouse;
\r
5344 if (dx < 0) dx = -dx;
\r
5345 if (dy < 0) dy = -dy;
\r
5347 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
\r
5349 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5353 /* Save last location */
\r
5355 xMouse = LOWORD(lParam);
\r
5356 yMouse = HIWORD(lParam);
\r
5363 DestroyWindow(hwndSaver);
\r
5370 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5373 #endif /* USE_SAVER */
\r
5379 /*** Temporary Hooks ***/
\r
5383 * Display warning message (see "z-util.c")
\r
5385 static void hack_plog(cptr str)
\r
5387 /* Give a warning */
\r
5391 MessageBox(NULL, str, "警告!",
\r
5392 MB_ICONEXCLAMATION | MB_OK);
\r
5394 MessageBox(NULL, str, "Warning",
\r
5395 MB_ICONEXCLAMATION | MB_OK);
\r
5403 * Display error message and quit (see "z-util.c")
\r
5405 static void hack_quit(cptr str)
\r
5407 /* Give a warning */
\r
5411 MessageBox(NULL, str, "エラー!",
\r
5412 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5414 MessageBox(NULL, str, "Error",
\r
5415 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5420 /* Unregister the classes */
\r
5421 UnregisterClass(AppName, hInstance);
\r
5423 /* Destroy the icon */
\r
5424 if (hIcon) DestroyIcon(hIcon);
\r
5432 /*** Various hooks ***/
\r
5436 * Display warning message (see "z-util.c")
\r
5438 static void hook_plog(cptr str)
\r
5444 MessageBox(data[0].w, str, "警告!",
\r
5445 MB_ICONEXCLAMATION | MB_OK);
\r
5447 MessageBox(data[0].w, str, "Warning",
\r
5448 MB_ICONEXCLAMATION | MB_OK);
\r
5456 * Display error message and quit (see "z-util.c")
\r
5458 static void hook_quit(cptr str)
\r
5463 /* Give a warning */
\r
5467 MessageBox(data[0].w, str, "エラー!",
\r
5468 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5470 MessageBox(data[0].w, str, "Error",
\r
5471 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5477 /* Save the preferences */
\r
5481 /*** Could use 'Term_nuke_win()' XXX XXX XXX */
\r
5483 /* Destroy all windows */
\r
5484 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
\r
5486 term_force_font(&data[i], NULL);
\r
5487 if (data[i].font_want) string_free(data[i].font_want);
\r
5488 if (data[i].w) DestroyWindow(data[i].w);
\r
5492 /* Free the bitmap stuff */
\r
5493 #ifdef USE_GRAPHICS
\r
5494 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
\r
5495 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
\r
5497 if (infMask.hPalette) DeleteObject(infMask.hPalette);
\r
5498 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
\r
5500 #endif /* USE_GRAPHICS */
\r
5502 /*** Free some other stuff ***/
\r
5504 DeleteObject(hbrYellow);
\r
5509 if (hPal) DeleteObject(hPal);
\r
5511 UnregisterClass(AppName, hInstance);
\r
5513 if (hIcon) DestroyIcon(hIcon);
\r
5520 /*** Initialize ***/
\r
5526 static void init_stuff(void)
\r
5533 /* Get program name with full path */
\r
5534 GetModuleFileName(hInstance, path, 512);
\r
5536 /* Save the "program name" XXX XXX XXX */
\r
5539 /* Get the name of the "*.ini" file */
\r
5540 strcpy(path + strlen(path) - 4, ".INI");
\r
5542 /* Save the the name of the ini-file */
\r
5543 ini_file = string_make(path);
\r
5545 /* Analyze the path */
\r
5548 /* Get the path */
\r
5549 for (; i > 0; i--)
\r
5551 if (path[i] == '\\')
\r
5558 /* Add "lib" to the path */
\r
5559 strcpy(path + i + 1, "lib\\");
\r
5561 /* Validate the path */
\r
5562 validate_dir(path, TRUE);
\r
5564 /* Init the file paths */
\r
5565 init_file_paths(path);
\r
5567 /* Hack -- Validate the paths */
\r
5568 validate_dir(ANGBAND_DIR_APEX, FALSE);
\r
5569 validate_dir(ANGBAND_DIR_BONE, FALSE);
\r
5571 /* Allow missing 'edit' directory */
\r
5572 if (!check_dir(ANGBAND_DIR_EDIT))
\r
5574 /* Must have 'data'! */
\r
5575 validate_dir(ANGBAND_DIR_DATA, TRUE);
\r
5579 /* Don't need 'data' */
\r
5580 validate_dir(ANGBAND_DIR_DATA, FALSE);
\r
5583 validate_dir(ANGBAND_DIR_FILE, TRUE);
\r
5584 validate_dir(ANGBAND_DIR_HELP, FALSE);
\r
5585 validate_dir(ANGBAND_DIR_INFO, FALSE);
\r
5586 validate_dir(ANGBAND_DIR_PREF, TRUE);
\r
5587 validate_dir(ANGBAND_DIR_SAVE, FALSE);
\r
5588 validate_dir(ANGBAND_DIR_USER, TRUE);
\r
5589 validate_dir(ANGBAND_DIR_XTRA, TRUE);
\r
5591 /* Build the filename */
\r
5592 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
\r
5594 /* Hack -- Validate the "news.txt" file */
\r
5595 validate_file(path);
\r
5598 #if 0 /* #ifndef JP */
\r
5599 /* Build the "font" path */
\r
5600 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
\r
5602 /* Allocate the path */
\r
5603 ANGBAND_DIR_XTRA_FONT = string_make(path);
\r
5605 /* Validate the "font" directory */
\r
5606 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
\r
5608 /* Build the filename */
\r
5609 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
5611 /* Hack -- Validate the basic font */
\r
5612 validate_file(path);
\r
5616 #ifdef USE_GRAPHICS
\r
5618 /* Build the "graf" path */
\r
5619 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
\r
5621 /* Allocate the path */
\r
5622 ANGBAND_DIR_XTRA_GRAF = string_make(path);
\r
5624 /* Validate the "graf" directory */
\r
5625 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
\r
5627 #endif /* USE_GRAPHICS */
\r
5632 /* Build the "sound" path */
\r
5633 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
\r
5635 /* Allocate the path */
\r
5636 ANGBAND_DIR_XTRA_SOUND = string_make(path);
\r
5638 /* Validate the "sound" directory */
\r
5639 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
\r
5641 #endif /* USE_SOUND */
\r
5645 /* Build the "music" path */
\r
5646 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
\r
5648 /* Allocate the path */
\r
5649 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
\r
5651 /* Validate the "music" directory */
\r
5652 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
\r
5654 #endif /* USE_MUSIC */
\r
5656 /* Build the "help" path */
\r
5657 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
\r
5659 /* Allocate the path */
\r
5660 ANGBAND_DIR_XTRA_HELP = string_make(path);
\r
5662 /* Validate the "help" directory */
\r
5663 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
\r
5666 static bool is_already_running(void)
\r
5668 bool result = FALSE;
\r
5671 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
\r
5672 if (GetLastError() == ERROR_ALREADY_EXISTS)
\r
5680 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
\r
5681 LPSTR lpCmdLine, int nCmdShow)
\r
5689 setlocale( LC_ALL, "ja_JP" );
\r
5694 /* Save globally */
\r
5695 hInstance = hInst;
\r
5698 /* Prevent multiple run */
\r
5699 if (is_already_running())
\r
5702 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
\r
5703 _("エラー!", "Error") ,
\r
5704 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5709 if (hPrevInst == NULL)
\r
5711 wc.style = CS_CLASSDC;
\r
5712 wc.lpfnWndProc = AngbandWndProc;
\r
5713 wc.cbClsExtra = 0;
\r
5714 wc.cbWndExtra = 4; /* one long pointer to term_data */
\r
5715 wc.hInstance = hInst;
\r
5716 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
\r
5717 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
\r
5718 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
\r
5719 wc.lpszMenuName = AppName;
\r
5720 wc.lpszClassName = AppName;
\r
5722 if (!RegisterClass(&wc)) exit(1);
\r
5724 wc.lpfnWndProc = AngbandListProc;
\r
5725 wc.lpszMenuName = NULL;
\r
5726 wc.lpszClassName = AngList;
\r
5728 if (!RegisterClass(&wc)) exit(2);
\r
5732 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
\r
5733 wc.lpfnWndProc = AngbandSaverProc;
\r
5734 wc.hCursor = NULL;
\r
5735 wc.lpszMenuName = NULL;
\r
5736 wc.lpszClassName = "WindowsScreenSaverClass";
\r
5738 if (!RegisterClass(&wc)) exit(3);
\r
5744 /* Temporary hooks */
\r
5745 plog_aux = hack_plog;
\r
5746 quit_aux = hack_quit;
\r
5747 core_aux = hack_quit;
\r
5749 /* Prepare the filepaths */
\r
5752 /* Initialize the keypress analyzer */
\r
5753 for (i = 0; special_key_list[i]; ++i)
\r
5755 special_key[special_key_list[i]] = TRUE;
\r
5757 /* Initialize the keypress analyzer */
\r
5758 for (i = 0; ignore_key_list[i]; ++i)
\r
5760 ignore_key[ignore_key_list[i]] = TRUE;
\r
5763 /* Determine if display is 16/256/true color */
\r
5764 hdc = GetDC(NULL);
\r
5765 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
\r
5766 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
\r
5767 ReleaseDC(NULL, hdc);
\r
5769 /* Initialize the colors */
\r
5770 for (i = 0; i < 256; i++)
\r
5774 /* Extract desired values */
\r
5775 rv = angband_color_table[i][1];
\r
5776 gv = angband_color_table[i][2];
\r
5777 bv = angband_color_table[i][3];
\r
5779 /* Extract the "complex" code */
\r
5780 win_clr[i] = PALETTERGB(rv, gv, bv);
\r
5782 /* Save the "simple" code */
\r
5783 angband_color_table[i][0] = win_pal[i];
\r
5786 /* Prepare the windows */
\r
5792 /* Activate hooks */
\r
5793 plog_aux = hook_plog;
\r
5794 quit_aux = hook_quit;
\r
5795 core_aux = hook_quit;
\r
5797 /* Set the system suffix */
\r
5798 ANGBAND_SYS = "win";
\r
5800 /* Set the keyboard suffix */
\r
5801 if (7 != GetKeyboardType(0))
\r
5802 ANGBAND_KEYBOARD = "0";
\r
5805 /* Japanese keyboard */
\r
5806 switch (GetKeyboardType(1))
\r
5808 case 0x0D01: case 0x0D02:
\r
5809 case 0x0D03: case 0x0D04:
\r
5810 case 0x0D05: case 0x0D06:
\r
5812 ANGBAND_KEYBOARD = "NEC98";
\r
5816 ANGBAND_KEYBOARD = "JAPAN";
\r
5820 /* Catch nasty signals */
\r
5824 Term_activate(term_screen);
\r
5827 /* We are now initialized */
\r
5828 initialized = TRUE;
\r
5830 if(lpCmdLine[0] == '-'){
\r
5831 switch(lpCmdLine[1])
\r
5836 if (!lpCmdLine[2]) break;
\r
5837 chuukei_server = TRUE;
\r
5838 if(connect_chuukei_server(&lpCmdLine[2])<0){
\r
5839 msg_print("connect fail");
\r
5842 msg_print("connect");
\r
5850 if (!lpCmdLine[2]) break;
\r
5851 chuukei_client = TRUE;
\r
5852 connect_chuukei_server(&lpCmdLine[2]);
\r
5860 if (!lpCmdLine[2]) break;
\r
5861 prepare_browse_movie(&lpCmdLine[2]);
\r
5871 /* Did the user double click on a save file? */
\r
5872 if(!chuukei_server) check_for_save_file(lpCmdLine);
\r
5874 /* Did the user double click on a save file? */
\r
5875 check_for_save_file(lpCmdLine);
\r
5878 /* Prompt the user */
\r
5879 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
\r
5883 /* Process messages forever */
\r
5884 while (GetMessage(&msg, NULL, 0, 0))
\r
5886 TranslateMessage(&msg);
\r
5887 DispatchMessage(&msg);
\r
5898 #endif /* WINDOWS */
\r