1 /* File: main-win.c */
\r
4 * Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others
\r
6 * This software may be copied and distributed for educational, research,
\r
7 * and not for profit purposes provided that this copyright and statement
\r
8 * are included in all such copies.
\r
13 * This file helps Angband work with Windows computers.
\r
15 * To use this file, use an appropriate "Makefile" or "Project File",
\r
16 * make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and
\r
17 * make sure to obtain various extra files as described below.
\r
19 * The official compilation uses the CodeWarrior Pro compiler, which
\r
20 * includes a special project file and precompilable header file.
\r
23 * See also "main-dos.c" and "main-ibm.c".
\r
26 * The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
\r
27 * and/or color redefinitions.
\r
29 * The "lib/user/font-win.prf" contains attr/char mappings for use with the
\r
30 * normal "lib/xtra/font/*.fon" font files.
\r
32 * The "lib/user/graf-win.prf" contains attr/char mappings for use with the
\r
33 * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
\r
37 * Compiling this file, and using the resulting executable, requires
\r
38 * several extra files not distributed with the standard Angband code.
\r
39 * If "USE_GRAPHICS" is defined, then "readdib.h" and "readdib.c" must
\r
40 * be placed into "src/", and the "8X8.BMP" bitmap file must be placed
\r
41 * into "lib/xtra/graf". In any case, some "*.fon" files (including
\r
42 * "8X13.FON" if nothing else) must be placed into "lib/xtra/font/".
\r
43 * If "USE_SOUND" is defined, then some special library (for example,
\r
44 * "winmm.lib") may need to be linked in, and desired "*.WAV" sound
\r
45 * files must be placed into "lib/xtra/sound/". All of these extra
\r
46 * files can be found in the "ext-win" archive.
\r
49 * The "Term_xtra_win_clear()" function should probably do a low-level
\r
50 * clear of the current window, and redraw the borders and other things,
\r
51 * if only for efficiency. XXX XXX XXX
\r
53 * A simpler method is needed for selecting the "tile size" for windows.
\r
56 * The various "warning" messages assume the existance of the "screen.w"
\r
57 * window, I think, and only a few calls actually check for its existance,
\r
58 * this may be okay since "NULL" means "on top of all windows". (?) The
\r
59 * user must never be allowed to "hide" the main window, or the "menubar"
\r
60 * will disappear. XXX XXX XXX
\r
62 * Special "Windows Help Files" can be placed into "lib/xtra/help/" for
\r
63 * use with the "winhelp.exe" program. These files *may* be available
\r
64 * at the ftp site somewhere, but I have not seen them. XXX XXX XXX
\r
67 * Initial framework (and most code) by Ben Harrison (benh@phial.com).
\r
69 * Original code by Skirmantas Kligys (kligys@scf.usc.edu).
\r
71 * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
\r
72 * and Chris R. Martin (crm7479@tam2000.tamu.edu).
\r
75 #include "angband.h"
\r
78 #include <windows.h>
\r
84 * Extract the "WIN32" flag from the compiler
\r
86 #if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__)
\r
94 * Hack -- allow use of "screen saver" mode
\r
100 * Menu constants -- see "ANGBAND.RC"
\r
103 #define IDM_FILE_NEW 100
\r
104 #define IDM_FILE_OPEN 101
\r
105 #define IDM_FILE_SAVE 110
\r
106 #define IDM_FILE_SCORE 120
\r
107 #define IDM_FILE_MOVIE 121
\r
108 #define IDM_FILE_EXIT 130
\r
110 #define IDM_WINDOW_VIS_0 200
\r
111 #define IDM_WINDOW_VIS_1 201
\r
112 #define IDM_WINDOW_VIS_2 202
\r
113 #define IDM_WINDOW_VIS_3 203
\r
114 #define IDM_WINDOW_VIS_4 204
\r
115 #define IDM_WINDOW_VIS_5 205
\r
116 #define IDM_WINDOW_VIS_6 206
\r
117 #define IDM_WINDOW_VIS_7 207
\r
119 #define IDM_WINDOW_FONT_0 210
\r
120 #define IDM_WINDOW_FONT_1 211
\r
121 #define IDM_WINDOW_FONT_2 212
\r
122 #define IDM_WINDOW_FONT_3 213
\r
123 #define IDM_WINDOW_FONT_4 214
\r
124 #define IDM_WINDOW_FONT_5 215
\r
125 #define IDM_WINDOW_FONT_6 216
\r
126 #define IDM_WINDOW_FONT_7 217
\r
128 #define IDM_WINDOW_POS_0 220
\r
129 #define IDM_WINDOW_POS_1 221
\r
130 #define IDM_WINDOW_POS_2 222
\r
131 #define IDM_WINDOW_POS_3 223
\r
132 #define IDM_WINDOW_POS_4 224
\r
133 #define IDM_WINDOW_POS_5 225
\r
134 #define IDM_WINDOW_POS_6 226
\r
135 #define IDM_WINDOW_POS_7 227
\r
137 #define IDM_WINDOW_BIZ_0 230
\r
138 #define IDM_WINDOW_BIZ_1 231
\r
139 #define IDM_WINDOW_BIZ_2 232
\r
140 #define IDM_WINDOW_BIZ_3 233
\r
141 #define IDM_WINDOW_BIZ_4 234
\r
142 #define IDM_WINDOW_BIZ_5 235
\r
143 #define IDM_WINDOW_BIZ_6 236
\r
144 #define IDM_WINDOW_BIZ_7 237
\r
146 #define IDM_WINDOW_I_WID_0 240
\r
147 #define IDM_WINDOW_I_WID_1 241
\r
148 #define IDM_WINDOW_I_WID_2 242
\r
149 #define IDM_WINDOW_I_WID_3 243
\r
150 #define IDM_WINDOW_I_WID_4 244
\r
151 #define IDM_WINDOW_I_WID_5 245
\r
152 #define IDM_WINDOW_I_WID_6 246
\r
153 #define IDM_WINDOW_I_WID_7 247
\r
155 #define IDM_WINDOW_D_WID_0 250
\r
156 #define IDM_WINDOW_D_WID_1 251
\r
157 #define IDM_WINDOW_D_WID_2 252
\r
158 #define IDM_WINDOW_D_WID_3 253
\r
159 #define IDM_WINDOW_D_WID_4 254
\r
160 #define IDM_WINDOW_D_WID_5 255
\r
161 #define IDM_WINDOW_D_WID_6 256
\r
162 #define IDM_WINDOW_D_WID_7 257
\r
164 #define IDM_WINDOW_I_HGT_0 260
\r
165 #define IDM_WINDOW_I_HGT_1 261
\r
166 #define IDM_WINDOW_I_HGT_2 262
\r
167 #define IDM_WINDOW_I_HGT_3 263
\r
168 #define IDM_WINDOW_I_HGT_4 264
\r
169 #define IDM_WINDOW_I_HGT_5 265
\r
170 #define IDM_WINDOW_I_HGT_6 266
\r
171 #define IDM_WINDOW_I_HGT_7 267
\r
173 #define IDM_WINDOW_D_HGT_0 270
\r
174 #define IDM_WINDOW_D_HGT_1 271
\r
175 #define IDM_WINDOW_D_HGT_2 272
\r
176 #define IDM_WINDOW_D_HGT_3 273
\r
177 #define IDM_WINDOW_D_HGT_4 274
\r
178 #define IDM_WINDOW_D_HGT_5 275
\r
179 #define IDM_WINDOW_D_HGT_6 276
\r
180 #define IDM_WINDOW_D_HGT_7 277
\r
182 #define IDM_OPTIONS_NO_GRAPHICS 400
\r
183 #define IDM_OPTIONS_OLD_GRAPHICS 401
\r
184 #define IDM_OPTIONS_NEW_GRAPHICS 402
\r
185 #define IDM_OPTIONS_NEW2_GRAPHICS 403
\r
186 #define IDM_OPTIONS_BIGTILE 409
\r
187 #define IDM_OPTIONS_SOUND 410
\r
188 #define IDM_OPTIONS_MUSIC 411
\r
189 #define IDM_OPTIONS_SAVER 420
\r
190 #define IDM_OPTIONS_MAP 430
\r
191 #define IDM_OPTIONS_BG 440
\r
192 #define IDM_OPTIONS_OPEN_BG 441
\r
194 #define IDM_DUMP_SCREEN_HTML 450
\r
196 #define IDM_HELP_CONTENTS 901
\r
201 * This may need to be removed for some compilers XXX XXX XXX
\r
208 * Exclude parts of WINDOWS.H that are not needed
\r
210 #define NOCOMM /* Comm driver APIs and definitions */
\r
211 #define NOLOGERROR /* LogError() and related definitions */
\r
212 #define NOPROFILER /* Profiler APIs */
\r
213 #define NOLFILEIO /* _l* file I/O routines */
\r
214 #define NOOPENFILE /* OpenFile and related definitions */
\r
215 #define NORESOURCE /* Resource management */
\r
216 #define NOATOM /* Atom management */
\r
217 #define NOLANGUAGE /* Character test routines */
\r
218 #define NOLSTRING /* lstr* string management routines */
\r
219 #define NODBCS /* Double-byte character set routines */
\r
220 #define NOKEYBOARDINFO /* Keyboard driver routines */
\r
221 #define NOCOLOR /* COLOR_* color values */
\r
222 #define NODRAWTEXT /* DrawText() and related definitions */
\r
223 #define NOSCALABLEFONT /* Truetype scalable font support */
\r
224 #define NOMETAFILE /* Metafile support */
\r
225 #define NOSYSTEMPARAMSINFO /* SystemParametersInfo() and SPI_* definitions */
\r
226 #define NODEFERWINDOWPOS /* DeferWindowPos and related definitions */
\r
227 #define NOKEYSTATES /* MK_* message key state flags */
\r
228 #define NOWH /* SetWindowsHook and related WH_* definitions */
\r
229 #define NOCLIPBOARD /* Clipboard APIs and definitions */
\r
230 #define NOICONS /* IDI_* icon IDs */
\r
231 #define NOMDI /* MDI support */
\r
232 #define NOHELP /* Help support */
\r
234 /* Not defined since it breaks Borland C++ 5.5 */
\r
235 /* #define NOCTLMGR */ /* Control management and controls */
\r
238 * Exclude parts of WINDOWS.H that are not needed (Win32)
\r
240 #define WIN32_LEAN_AND_MEAN
\r
241 #define NONLS /* All NLS defines and routines */
\r
242 #define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
\r
243 #define NOKANJI /* Kanji support stuff. */
\r
244 #define NOMCX /* Modem Configuration Extensions */
\r
247 * Include the "windows" support file
\r
249 #include <windows.h>
\r
252 * Exclude parts of MMSYSTEM.H that are not needed
\r
254 #define MMNODRV /* Installable driver support */
\r
255 #define MMNOWAVE /* Waveform support */
\r
256 #define MMNOMIDI /* MIDI support */
\r
257 #define MMNOAUX /* Auxiliary audio support */
\r
258 #define MMNOTIMER /* Timer support */
\r
259 #define MMNOJOY /* Joystick support */
\r
260 #define MMNOMCI /* MCI support */
\r
261 #define MMNOMMIO /* Multimedia file I/O support */
\r
262 #define MMNOMMSYSTEM /* General MMSYSTEM functions */
\r
265 * Include some more files. Note: the Cygnus Cygwin compiler
\r
266 * doesn't use mmsystem.h instead it includes the winmm library
\r
267 * which performs a similar function.
\r
269 #include <mmsystem.h>
\r
270 #include <commdlg.h>
\r
273 * HTML-Help requires htmlhelp.h and htmlhelp.lib from Microsoft's
\r
274 * HTML Workshop < http://msdn.microsoft.com/workshop/author/htmlhelp/ >.
\r
276 /* #define HTML_HELP */
\r
279 #include <htmlhelp.h>
\r
280 #endif /* HTML_HELP */
\r
283 * Include the support for loading bitmaps
\r
285 #ifdef USE_GRAPHICS
\r
286 # include "readdib.h"
\r
290 * Hack -- Fake declarations from "dos.h" XXX XXX XXX
\r
293 #define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
\r
295 #define FA_LABEL 0x08 /* Volume label */
\r
296 #define FA_DIREC 0x10 /* Directory */
\r
297 unsigned _cdecl _dos_getfileattr(const char *, unsigned *);
\r
301 * Silliness in WIN32 drawing routine
\r
304 # define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL)
\r
308 * Silliness for Windows 95
\r
310 #ifndef WS_EX_TOOLWINDOW
\r
311 # define WS_EX_TOOLWINDOW 0
\r
315 * Foreground color bits (hard-coded by DOS)
\r
317 #define VID_BLACK 0x00
\r
318 #define VID_BLUE 0x01
\r
319 #define VID_GREEN 0x02
\r
320 #define VID_CYAN 0x03
\r
321 #define VID_RED 0x04
\r
322 #define VID_MAGENTA 0x05
\r
323 #define VID_YELLOW 0x06
\r
324 #define VID_WHITE 0x07
\r
327 * Bright text (hard-coded by DOS)
\r
329 #define VID_BRIGHT 0x08
\r
332 * Background color bits (hard-coded by DOS)
\r
334 #define VUD_BLACK 0x00
\r
335 #define VUD_BLUE 0x10
\r
336 #define VUD_GREEN 0x20
\r
337 #define VUD_CYAN 0x30
\r
338 #define VUD_RED 0x40
\r
339 #define VUD_MAGENTA 0x50
\r
340 #define VUD_YELLOW 0x60
\r
341 #define VUD_WHITE 0x70
\r
344 * Blinking text (hard-coded by DOS)
\r
346 #define VUD_BRIGHT 0x80
\r
352 typedef struct _term_data term_data;
\r
355 * Extra "term" data
\r
357 * Note the use of "font_want" for the names of the font file requested by
\r
358 * the user, and the use of "font_file" for the currently active font file.
\r
360 * The "font_file" is uppercased, and takes the form "8X13.FON", while
\r
361 * "font_want" can be in almost any form as long as it could be construed
\r
362 * as attempting to represent the name of a font.
\r
377 TERM_POSITION rows; /* int -> uint */
\r
378 TERM_POSITION cols;
\r
413 #if 1 /* #ifdef JP */
\r
428 * Maximum number of windows XXX XXX XXX
\r
430 #define MAX_TERM_DATA 8
\r
433 * An array of term_data's
\r
435 static term_data data[MAX_TERM_DATA];
\r
438 * Hack -- global "window creation" pointer
\r
440 static term_data *my_td;
\r
443 * Remember normal size of main window when maxmized
\r
448 * was main window maximized on previous playing
\r
450 bool win_maximized = FALSE;
\r
455 bool game_in_progress = FALSE;
\r
458 * note when "open"/"new" become valid
\r
460 bool initialized = FALSE;
\r
463 * screen paletted, i.e. 256 colors
\r
465 bool paletted = FALSE;
\r
468 * 16 colors screen, don't use RGB()
\r
470 bool colors16 = FALSE;
\r
473 * Saved instance handle
\r
475 static HINSTANCE hInstance;
\r
478 * Yellow brush for the cursor
\r
480 static HBRUSH hbrYellow;
\r
485 static HICON hIcon;
\r
490 static HPALETTE hPal;
\r
493 static HBITMAP hBG = NULL;
\r
494 static int use_bg = 0;
\r
495 static char bg_bitmap_file[1024] = "bg.bmp";
\r
500 * The screen saver window
\r
502 static HWND hwndSaver;
\r
504 #endif /* USE_SAVER */
\r
507 #ifdef USE_GRAPHICS
\r
510 * Flag set once "graphics" has been initialized
\r
512 static bool can_use_graphics = FALSE;
\r
515 * The global bitmap
\r
517 static DIBINIT infGraph;
\r
520 * The global bitmap mask
\r
522 static DIBINIT infMask;
\r
524 #endif /* USE_GRAPHICS */
\r
530 * Flag set once "sound" has been initialized
\r
532 static bool can_use_sound = FALSE;
\r
534 #define SAMPLE_MAX 8
\r
536 * An array of sound file names
\r
538 static cptr sound_file[SOUND_MAX][SAMPLE_MAX];
\r
540 #endif /* USE_SOUND */
\r
546 #define SAMPLE_MUSIC_MAX 16
\r
547 static cptr music_file[MUSIC_BASIC_MAX][SAMPLE_MUSIC_MAX];
\r
548 static cptr dungeon_music_file[1000][SAMPLE_MUSIC_MAX];
\r
549 static cptr town_music_file[1000][SAMPLE_MUSIC_MAX];
\r
550 static cptr quest_music_file[1000][SAMPLE_MUSIC_MAX];
\r
551 static bool can_use_music = FALSE;
\r
553 static MCI_OPEN_PARMS mop;
\r
554 static char mci_device_type[256];
\r
556 int current_music_type = 0;
\r
557 int current_music_id = 0;
\r
559 #endif /* USE_MUSIC */
\r
563 * Full path to ANGBAND.INI
\r
565 static cptr ini_file = NULL;
\r
568 * Name of application
\r
570 static cptr AppName = "ANGBAND";
\r
573 * Name of sub-window type
\r
575 static cptr AngList = "AngList";
\r
580 static cptr ANGBAND_DIR_XTRA_GRAF;
\r
581 static cptr ANGBAND_DIR_XTRA_SOUND;
\r
582 static cptr ANGBAND_DIR_XTRA_MUSIC;
\r
583 static cptr ANGBAND_DIR_XTRA_HELP;
\r
584 #if 0 /* #ifndef JP */
\r
585 static cptr ANGBAND_DIR_XTRA_FONT;
\r
588 static cptr ANGBAND_DIR_XTRA_MUSIC;
\r
593 * The "complex" color values
\r
595 static COLORREF win_clr[256];
\r
599 * Flag for macro trigger with dump ASCII
\r
601 static bool Term_no_press = FALSE;
\r
606 static bool mouse_down = FALSE;
\r
607 static bool paint_rect = FALSE;
\r
608 static TERM_POSITION mousex = 0, mousey = 0;
\r
609 static TERM_POSITION oldx, oldy;
\r
613 * The "simple" color values
\r
615 * See "main-ibm.c" for original table information
\r
617 * The entries below are taken from the "color bits" defined above.
\r
619 * Note that many of the choices below suck, but so do crappy monitors.
\r
621 static BYTE win_pal[256] =
\r
623 VID_BLACK, /* Dark */
\r
624 VID_WHITE, /* White */
\r
625 VID_CYAN, /* Slate XXX */
\r
626 VID_RED | VID_BRIGHT, /* Orange XXX */
\r
628 VID_GREEN, /* Green */
\r
629 VID_BLUE, /* Blue */
\r
630 VID_YELLOW, /* Umber XXX */
\r
631 VID_BLACK | VID_BRIGHT, /* Light Dark */
\r
632 VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
\r
633 VID_MAGENTA, /* Violet XXX */
\r
634 VID_YELLOW | VID_BRIGHT, /* Yellow */
\r
635 VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
\r
636 VID_GREEN | VID_BRIGHT, /* Light Green */
\r
637 VID_BLUE | VID_BRIGHT, /* Light Blue */
\r
638 VID_YELLOW /* Light Umber XXX */
\r
643 * Hack -- define which keys are "special"
\r
645 static bool special_key[256];
\r
646 static bool ignore_key[256];
\r
650 * Hack -- initialization list for "special_key"
\r
652 static byte special_key_list[] = {
\r
653 VK_CLEAR, VK_PAUSE, VK_CAPITAL,
\r
654 VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI,
\r
655 VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE,
\r
656 VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
\r
657 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN,
\r
658 VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT,
\r
659 VK_INSERT, VK_DELETE, VK_HELP, VK_APPS,
\r
660 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
\r
661 VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
\r
662 VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD,
\r
663 VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE,
\r
664 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
\r
665 VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
\r
666 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
\r
667 VK_F19,VK_F20, VK_F21, VK_F22, VK_F23, VK_F24,
\r
668 VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL,
\r
669 VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM,
\r
671 0 /* End of List */
\r
674 static byte ignore_key_list[] = {
\r
675 VK_ESCAPE, VK_TAB, VK_SPACE,
\r
676 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
\r
677 VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN,
\r
678 VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL,
\r
679 VK_LMENU, VK_RMENU,
\r
680 0 /* End of List */
\r
684 * Hack -- initialization list for "special_key"
\r
686 * We ignore the modifier keys (shift, control, alt, num lock, scroll lock),
\r
687 * and the normal keys (escape, tab, return, letters, numbers, etc), but we
\r
688 * catch the keypad keys (with and without numlock set, including keypad 5),
\r
689 * the function keys (including the "menu" key which maps to F10), and the
\r
690 * "pause" key (between scroll lock and numlock). We also catch a few odd
\r
691 * keys which I do not recognize, but which are listed among keys which we
\r
692 * do catch, so they should be harmless to catch.
\r
694 static byte special_key_list[] =
\r
696 VK_CLEAR, /* 0x0C (KP<5>) */
\r
698 VK_PAUSE, /* 0x13 (pause) */
\r
700 VK_PRIOR, /* 0x21 (KP<9>) */
\r
701 VK_NEXT, /* 0x22 (KP<3>) */
\r
702 VK_END, /* 0x23 (KP<1>) */
\r
703 VK_HOME, /* 0x24 (KP<7>) */
\r
704 VK_LEFT, /* 0x25 (KP<4>) */
\r
705 VK_UP, /* 0x26 (KP<8>) */
\r
706 VK_RIGHT, /* 0x27 (KP<6>) */
\r
707 VK_DOWN, /* 0x28 (KP<2>) */
\r
708 VK_SELECT, /* 0x29 (?????) */
\r
709 VK_PRINT, /* 0x2A (?????) */
\r
710 VK_EXECUTE, /* 0x2B (?????) */
\r
711 VK_SNAPSHOT, /* 0x2C (?????) */
\r
712 VK_INSERT, /* 0x2D (KP<0>) */
\r
713 VK_DELETE, /* 0x2E (KP<.>) */
\r
714 VK_HELP, /* 0x2F (?????) */
\r
716 VK_NUMPAD0, /* 0x60 (KP<0>) */
\r
717 VK_NUMPAD1, /* 0x61 (KP<1>) */
\r
718 VK_NUMPAD2, /* 0x62 (KP<2>) */
\r
719 VK_NUMPAD3, /* 0x63 (KP<3>) */
\r
720 VK_NUMPAD4, /* 0x64 (KP<4>) */
\r
721 VK_NUMPAD5, /* 0x65 (KP<5>) */
\r
722 VK_NUMPAD6, /* 0x66 (KP<6>) */
\r
723 VK_NUMPAD7, /* 0x67 (KP<7>) */
\r
724 VK_NUMPAD8, /* 0x68 (KP<8>) */
\r
725 VK_NUMPAD9, /* 0x69 (KP<9>) */
\r
726 VK_MULTIPLY, /* 0x6A (KP<*>) */
\r
727 VK_ADD, /* 0x6B (KP<+>) */
\r
728 VK_SEPARATOR, /* 0x6C (?????) */
\r
729 VK_SUBTRACT, /* 0x6D (KP<->) */
\r
730 VK_DECIMAL, /* 0x6E (KP<.>) */
\r
731 VK_DIVIDE, /* 0x6F (KP</>) */
\r
762 /* Function prototype */
\r
764 static bool is_already_running(void);
\r
768 static void delete_bg(void)
\r
777 static int init_bg(void)
\r
779 char * bmfile = bg_bitmap_file;
\r
782 if (use_bg == 0) return 0;
\r
784 hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
\r
786 plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
\r
791 HDC wnddc, dcimage, dcbg;
\r
792 HBITMAP bmimage, bmimage_old, bmbg_old;
\r
797 wnddc = GetDC(hwnd);
\r
798 dcimage = CreateCompatibleDC(wnddc);
\r
799 dcbg = CreateCompatibleDC(wnddc);
\r
801 bmimage = LoadImage(NULL, "bg.bmp", LR_LOADFROMFILE, 0, 0, 0);
\r
802 if (!bmimage) quit("bg.bmpが読みこめない!");
\r
803 bmimage_old = SelectObject(dcimage, bmimage);
\r
805 CreateCompatibleBitmap();
\r
807 ReleaseDC(hwnd, wnddc);
\r
813 static void DrawBG(HDC hdc, RECT *r)
\r
818 int x = r->left, y = r->top;
\r
819 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
\r
821 if (!use_bg || !hBG)
\r
825 GetObject(hBG, sizeof(bm), &bm);
\r
826 swid = bm.bmWidth; shgt = bm.bmHeight;
\r
828 hdcSrc = CreateCompatibleDC(hdc);
\r
829 hOld = SelectObject(hdcSrc, hBG);
\r
833 cwid = MIN(swid - sx, r->right - nx);
\r
836 chgt = MIN(shgt - sy, r->bottom - ny);
\r
837 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
\r
839 } while (ny < r->bottom);
\r
842 } while (nx < r->right);
\r
844 SelectObject(hdcSrc, hOld);
\r
850 * Hack -- given a pathname, point at the filename
\r
852 static cptr extract_file_name(cptr s)
\r
856 /* Start at the end */
\r
857 p = s + strlen(s) - 1;
\r
859 /* Back up to divider */
\r
860 while ((p >= s) && (*p != ':') && (*p != '\\')) p--;
\r
862 /* Return file name */
\r
869 * Hack -- given a simple filename, extract the "font size" info
\r
871 * Return a pointer to a static buffer holding the capitalized base name.
\r
873 #if 0 /* #ifndef JP */
\r
874 static char *analyze_font(char *path, int *wp, int *hp)
\r
880 /* Start at the end */
\r
881 p = path + strlen(path) - 1;
\r
883 /* Back up to divider */
\r
884 while ((p >= path) && (*p != ':') && (*p != '\\')) --p;
\r
886 /* Advance to file name */
\r
890 for (s = p; *s; ++s)
\r
892 /* Capitalize (be paranoid) */
\r
893 if (islower(*s)) *s = toupper(*s);
\r
896 /* Find first 'X' */
\r
897 s = my_strchr(p, 'X');
\r
899 /* Extract font width */
\r
902 /* Extract height */
\r
903 hgt = s ? atoi(s+1) : 0;
\r
916 * Check for existance of a file
\r
918 static bool check_file(cptr s)
\r
928 unsigned int attrib;
\r
938 attrib = GetFileAttributes(path);
\r
940 /* Require valid filename */
\r
941 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
943 /* Prohibit directory */
\r
944 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return (FALSE);
\r
948 /* Examine and verify */
\r
949 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
951 /* Prohibit something */
\r
952 if (attrib & FA_LABEL) return (FALSE);
\r
954 /* Prohibit directory */
\r
955 if (attrib & FA_DIREC) return (FALSE);
\r
965 * Check for existance of a directory
\r
967 static bool check_dir(cptr s)
\r
979 unsigned int attrib;
\r
989 /* Remove trailing backslash */
\r
990 if (i && (path[i-1] == '\\')) path[--i] = '\0';
\r
995 attrib = GetFileAttributes(path);
\r
997 /* Require valid filename */
\r
998 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
1000 /* Require directory */
\r
1001 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE);
\r
1005 /* Examine and verify */
\r
1006 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
1008 /* Prohibit something */
\r
1009 if (attrib & FA_LABEL) return (FALSE);
\r
1011 /* Require directory */
\r
1012 if (!(attrib & FA_DIREC)) return (FALSE);
\r
1014 #endif /* WIN32 */
\r
1024 static void validate_file(cptr s)
\r
1026 /* Verify or fail */
\r
1027 if (!check_file(s))
\r
1029 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
\r
1035 * Validate a directory
\r
1037 static void validate_dir(cptr s, bool vital)
\r
1039 /* Verify or fail */
\r
1040 if (!check_dir(s))
\r
1042 /* This directory contains needed data */
\r
1045 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
\r
1047 /* Attempt to create this directory */
\r
1048 else if (mkdir(s))
\r
1050 quit_fmt("Unable to create directory:\n%s", s);
\r
1057 * Get the "size" for a window
\r
1059 static void term_getsize(term_data *td)
\r
1066 if (td->cols < 1) td->cols = 1;
\r
1067 if (td->rows < 1) td->rows = 1;
\r
1069 /* Window sizes */
\r
1070 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
1071 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
\r
1073 /* Fake window size */
\r
1075 rc.right = rc.left + wid;
\r
1077 rc.bottom = rc.top + hgt;
\r
1080 /* rc.right += 1; */
\r
1081 /* rc.bottom += 1; */
\r
1084 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
1087 td->size_wid = rc.right - rc.left;
\r
1088 td->size_hgt = rc.bottom - rc.top;
\r
1090 /* See CreateWindowEx */
\r
1091 if (!td->w) return;
\r
1093 /* Extract actual location */
\r
1094 GetWindowRect(td->w, &rc);
\r
1096 /* Save the location */
\r
1097 td->pos_x = rc.left;
\r
1098 td->pos_y = rc.top;
\r
1103 * Write the "prefs" for a single term
\r
1105 static void save_prefs_aux(int i)
\r
1107 term_data *td = &data[i];
\r
1108 char sec_name[128];
\r
1112 WINDOWPLACEMENT lpwndpl;
\r
1115 if (!td->w) return;
\r
1117 /* Make section name */
\r
1118 sprintf(sec_name, "Term-%d", i);
\r
1123 strcpy(buf, td->visible ? "1" : "0");
\r
1124 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
\r
1129 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "MS ゴシック");
\r
1132 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
\r
1134 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
\r
1138 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
\r
1140 #if 1 /* #ifdef JP */
\r
1141 wsprintf(buf, "%d", td->lf.lfWidth);
\r
1142 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
\r
1143 wsprintf(buf, "%d", td->lf.lfHeight);
\r
1144 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
\r
1145 wsprintf(buf, "%d", td->lf.lfWeight);
\r
1146 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
\r
1149 strcpy(buf, td->bizarre ? "1" : "0");
\r
1150 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
\r
1152 /* Tile size (x) */
\r
1153 wsprintf(buf, "%d", td->tile_wid);
\r
1154 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
\r
1156 /* Tile size (y) */
\r
1157 wsprintf(buf, "%d", td->tile_hgt);
\r
1158 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
\r
1160 /* Get window placement and dimensions */
\r
1161 lpwndpl.length = sizeof(WINDOWPLACEMENT);
\r
1162 GetWindowPlacement(td->w, &lpwndpl);
\r
1164 /* Acquire position in *normal* mode (not minimized) */
\r
1165 rc = lpwndpl.rcNormalPosition;
\r
1167 /* Window size (x) */
\r
1168 if (i == 0) wsprintf(buf, "%d", normsize.x);
\r
1169 else wsprintf(buf, "%d", td->cols);
\r
1170 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
\r
1172 /* Window size (y) */
\r
1173 if (i == 0) wsprintf(buf, "%d", normsize.y);
\r
1174 else wsprintf(buf, "%d", td->rows);
\r
1175 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
\r
1177 /* Maxmized (only main window) */
\r
1180 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
\r
1181 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
\r
1184 /* Acquire position */
\r
1185 GetWindowRect(td->w, &rc);
\r
1187 /* Window position (x) */
\r
1188 wsprintf(buf, "%d", rc.left);
\r
1189 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
\r
1191 /* Window position (y) */
\r
1192 wsprintf(buf, "%d", rc.top);
\r
1193 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
\r
1195 /* Window Z position */
\r
1198 strcpy(buf, td->posfix ? "1" : "0");
\r
1199 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
\r
1205 * Write the "prefs"
\r
1207 * We assume that the windows have all been initialized
\r
1209 static void save_prefs(void)
\r
1215 /* Save the "arg_graphics" flag */
\r
1216 sprintf(buf, "%d", arg_graphics);
\r
1217 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
\r
1219 /* Save the "arg_bigtile" flag */
\r
1220 strcpy(buf, arg_bigtile ? "1" : "0");
\r
1221 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
\r
1223 /* Save the "arg_sound" flag */
\r
1224 strcpy(buf, arg_sound ? "1" : "0");
\r
1225 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
\r
1227 /* Save the "arg_sound" flag */
\r
1228 strcpy(buf, arg_music ? "1" : "0");
\r
1229 WritePrivateProfileString("Angband", "Music", buf, ini_file);
\r
1232 strcpy(buf, use_bg ? "1" : "0");
\r
1233 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
\r
1234 WritePrivateProfileString("Angband", "BackGroundBitmap",
\r
1235 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
\r
1237 /* Save window prefs */
\r
1238 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1240 save_prefs_aux(i);
\r
1246 * Load the "prefs" for a single term
\r
1248 static void load_prefs_aux(int i)
\r
1250 term_data *td = &data[i];
\r
1251 char sec_name[128];
\r
1254 int wid, hgt, posx, posy;
\r
1255 int dispx = GetSystemMetrics( SM_CXVIRTUALSCREEN);
\r
1256 int dispy = GetSystemMetrics( SM_CYVIRTUALSCREEN);
\r
1260 /* Make section name */
\r
1261 sprintf(sec_name, "Term-%d", i);
\r
1263 /* Make section name */
\r
1264 sprintf(sec_name, "Term-%d", i);
\r
1269 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
\r
1272 /* Desired font, with default */
\r
1274 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
\r
1277 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
\r
1279 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
\r
1285 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
\r
1287 /* Analyze font, save desired font name */
\r
1288 #if 1 /* #ifdef JP */
\r
1289 td->font_want = string_make(tmp);
\r
1290 hgt = 15; wid = 0;
\r
1291 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
\r
1292 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
\r
1293 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
\r
1295 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
\r
1300 #if 1 /* #ifdef JP */
\r
1301 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
\r
1302 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
\r
1304 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
\r
1305 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
\r
1310 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
\r
1311 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
\r
1312 normsize.x = td->cols; normsize.y = td->rows;
\r
1317 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
\r
1320 /* Window position */
\r
1321 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
\r
1322 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
\r
1323 td->pos_x = MIN(MAX(0, posx), dispx-128);
\r
1324 td->pos_y = MIN(MAX(0, posy), dispy-128);
\r
1326 /* Window Z position */
\r
1329 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
\r
1335 * Load the "prefs"
\r
1337 static void load_prefs(void)
\r
1341 /* Extract the "arg_graphics" flag */
\r
1342 arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
\r
1344 /* Extract the "arg_bigtile" flag */
\r
1345 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
\r
1346 use_bigtile = arg_bigtile;
\r
1348 /* Extract the "arg_sound" flag */
\r
1349 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
\r
1351 /* Extract the "arg_sound" flag */
\r
1352 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
\r
1355 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
\r
1356 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
\r
1358 /* Load window prefs */
\r
1359 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1361 load_prefs_aux(i);
\r
1365 #if defined(USE_SOUND) || defined(USE_MUSIC)
\r
1368 * XXX XXX XXX - Taken from files.c.
\r
1370 * Extract "tokens" from a buffer
\r
1372 * This function uses "whitespace" as delimiters, and treats any amount of
\r
1373 * whitespace as a single delimiter. We will never return any empty tokens.
\r
1374 * When given an empty buffer, or a buffer containing only "whitespace", we
\r
1375 * will return no tokens. We will never extract more than "num" tokens.
\r
1377 * By running a token through the "text_to_ascii()" function, you can allow
\r
1378 * that token to include (encoded) whitespace, using "\s" to encode spaces.
\r
1380 * We save pointers to the tokens in "tokens", and return the number found.
\r
1382 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
\r
1392 /* Skip leading whitespace */
\r
1393 for ( ; *s && iswspace(*s); ++s) /* loop */;
\r
1398 /* Find next whitespace, if any */
\r
1399 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
\r
1401 /* Nuke and advance (if necessary) */
\r
1402 if (*t) *t++ = '\0';
\r
1404 /* Save the token */
\r
1415 #endif /* USE_SOUND || USE_MUSIC */
\r
1419 static void load_sound_prefs(void)
\r
1423 char ini_path[1024];
\r
1424 char wav_path[1024];
\r
1425 char *zz[SAMPLE_MAX];
\r
1427 /* Access the sound.cfg */
\r
1429 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
\r
1431 for (i = 0; i < SOUND_MAX; i++)
\r
1433 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
\r
1435 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
\r
1437 for (j = 0; j < num; j++)
\r
1439 /* Access the sound */
\r
1440 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
\r
1442 /* Save the sound filename, if it exists */
\r
1443 if (check_file(wav_path))
\r
1444 sound_file[i][j] = string_make(zz[j]);
\r
1449 #endif /* USE_SOUND */
\r
1453 static void load_music_prefs(void)
\r
1457 char ini_path[1024];
\r
1458 char wav_path[1024];
\r
1459 char *zz[SAMPLE_MAX];
\r
1462 /* Access the music.cfg */
\r
1464 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
\r
1466 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
\r
1468 for (i = 0; i < MUSIC_BASIC_MAX; i++)
\r
1470 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
\r
1472 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1474 for (j = 0; j < num; j++)
\r
1476 /* Access the sound */
\r
1477 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1479 /* Save the sound filename, if it exists */
\r
1480 if (check_file(wav_path))
\r
1481 music_file[i][j] = string_make(zz[j]);
\r
1485 for (i = 0; i < max_d_idx; i++)
\r
1487 sprintf(key, "dungeon%03d", i);
\r
1488 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
\r
1490 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1492 for (j = 0; j < num; j++)
\r
1494 /* Access the sound */
\r
1495 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1497 /* Save the sound filename, if it exists */
\r
1498 if (check_file(wav_path))
\r
1499 dungeon_music_file[i][j] = string_make(zz[j]);
\r
1503 for (i = 0; i < 1000; i++) /*!< @todo クエスト最大数指定 */
\r
1505 sprintf(key, "quest%03d", i);
\r
1506 GetPrivateProfileString("Quest", key, "", 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 quest_music_file[i][j] = string_make(zz[j]);
\r
1521 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
\r
1523 sprintf(key, "town%03d", i);
\r
1524 GetPrivateProfileString("Town", 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 town_music_file[i][j] = string_make(zz[j]);
\r
1542 #endif /* USE_MUSIC */
\r
1545 * Create the new global palette based on the bitmap palette
\r
1546 * (if any), and the standard 16 entry palette derived from
\r
1547 * "win_clr[]" which is used for the basic 16 Angband colors.
\r
1549 * This function is never called before all windows are ready.
\r
1551 * This function returns FALSE if the new palette could not be
\r
1552 * prepared, which should normally be a fatal error. XXX XXX
\r
1554 * Note that only some machines actually use a "palette".
\r
1556 static int new_palette(void)
\r
1564 LPLOGPALETTE pLogPal;
\r
1565 LPPALETTEENTRY lppe;
\r
1570 /* This makes no sense */
\r
1571 if (!paletted) return (TRUE);
\r
1579 #ifdef USE_GRAPHICS
\r
1581 /* Check the bitmap palette */
\r
1582 hBmPal = infGraph.hPalette;
\r
1584 /* Use the bitmap */
\r
1587 lppeSize = 256 * sizeof(PALETTEENTRY);
\r
1588 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
\r
1589 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
\r
1590 if ((nEntries == 0) || (nEntries > 220))
\r
1592 /* Warn the user */
\r
1593 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
\r
1596 rnfree(lppe, lppeSize);
\r
1603 #endif /* USE_GRAPHICS */
\r
1605 /* Size of palette */
\r
1606 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
\r
1608 /* Allocate palette */
\r
1609 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
\r
1612 pLogPal->palVersion = 0x300;
\r
1614 /* Make room for bitmap and normal data */
\r
1615 pLogPal->palNumEntries = nEntries + 16;
\r
1617 /* Save the bitmap data */
\r
1618 for (i = 0; i < nEntries; i++)
\r
1620 pLogPal->palPalEntry[i] = lppe[i];
\r
1623 /* Save the normal data */
\r
1624 for (i = 0; i < 16; i++)
\r
1628 /* Access the entry */
\r
1629 p = &(pLogPal->palPalEntry[i+nEntries]);
\r
1631 /* Save the colors */
\r
1632 p->peRed = GetRValue(win_clr[i]);
\r
1633 p->peGreen = GetGValue(win_clr[i]);
\r
1634 p->peBlue = GetBValue(win_clr[i]);
\r
1636 /* Save the flags */
\r
1637 p->peFlags = PC_NOCOLLAPSE;
\r
1640 /* Free something */
\r
1641 if (lppe) rnfree(lppe, lppeSize);
\r
1643 /* Create a new palette, or fail */
\r
1644 hNewPal = CreatePalette(pLogPal);
\r
1645 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
\r
1647 /* Free the palette */
\r
1648 rnfree(pLogPal, pLogPalSize);
\r
1653 /* Realize the palette */
\r
1654 hdc = GetDC(td->w);
\r
1655 SelectPalette(hdc, hNewPal, 0);
\r
1656 i = RealizePalette(hdc);
\r
1657 ReleaseDC(td->w, hdc);
\r
1658 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
\r
1662 for (i = 1; i < MAX_TERM_DATA; i++)
\r
1666 hdc = GetDC(td->w);
\r
1667 SelectPalette(hdc, hNewPal, 0);
\r
1668 ReleaseDC(td->w, hdc);
\r
1671 /* Delete old palette */
\r
1672 if (hPal) DeleteObject(hPal);
\r
1674 /* Save new palette */
\r
1682 #ifdef USE_GRAPHICS
\r
1684 * Initialize graphics
\r
1686 static bool init_graphics(void)
\r
1688 /* Initialize once */
\r
1689 /* if (can_use_graphics != arg_graphics) */
\r
1692 BYTE wid, hgt, twid, thgt, ox, oy;
\r
1695 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1703 name = "16X16.BMP";
\r
1705 ANGBAND_GRAF = "new";
\r
1707 else if (arg_graphics == GRAPHICS_HENGBAND)
\r
1716 name = "64X64.BMP";
\r
1725 name = "32X32.BMP";
\r
1727 ANGBAND_GRAF = "ne2";
\r
1738 ANGBAND_GRAF = "old";
\r
1741 /* Access the bitmap file */
\r
1742 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
\r
1744 /* Load the bitmap or quit */
\r
1745 if (!ReadDIB(data[0].w, buf, &infGraph))
\r
1747 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
\r
1751 /* Save the new sizes */
\r
1752 infGraph.CellWidth = wid;
\r
1753 infGraph.CellHeight = hgt;
\r
1754 infGraph.TileWidth = twid;
\r
1755 infGraph.TileHeight = thgt;
\r
1756 infGraph.OffsetX = ox;
\r
1757 infGraph.OffsetY = oy;
\r
1759 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1761 /* Access the mask file */
\r
1762 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
\r
1764 /* Load the bitmap or quit */
\r
1765 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1767 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1771 if (arg_graphics == GRAPHICS_HENGBAND)
\r
1773 /* Access the mask file */
\r
1774 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
\r
1776 /* Load the bitmap or quit */
\r
1777 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1779 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1784 /* Activate a palette */
\r
1785 if (!new_palette())
\r
1787 /* Free bitmap XXX XXX XXX */
\r
1790 plog(_("パレットを実現できません!", "Cannot activate palette!"));
\r
1794 /* Graphics available */
\r
1795 can_use_graphics = arg_graphics;
\r
1799 return (can_use_graphics);
\r
1801 #endif /* USE_GRAPHICS */
\r
1806 * Initialize music
\r
1808 static bool init_music(void)
\r
1810 /* Initialize once */
\r
1811 if (!can_use_music)
\r
1813 /* Load the prefs */
\r
1814 load_music_prefs();
\r
1816 /* Sound available */
\r
1817 can_use_music = TRUE;
\r
1821 return (can_use_music);
\r
1825 * Hack -- Stop a music
\r
1827 static void stop_music(void)
\r
1829 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
1830 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
1833 #endif /* USE_MUSIC */
\r
1837 * Initialize sound
\r
1839 static bool init_sound(void)
\r
1841 /* Initialize once */
\r
1842 if (!can_use_sound)
\r
1844 /* Load the prefs */
\r
1845 load_sound_prefs();
\r
1847 /* Sound available */
\r
1848 can_use_sound = TRUE;
\r
1852 return (can_use_sound);
\r
1854 #endif /* USE_SOUND */
\r
1860 static void term_window_resize(term_data *td)
\r
1862 /* Require window */
\r
1863 if (!td->w) return;
\r
1865 /* Resize the window */
\r
1866 SetWindowPos(td->w, 0, 0, 0,
\r
1867 td->size_wid, td->size_hgt,
\r
1868 SWP_NOMOVE | SWP_NOZORDER);
\r
1870 /* Redraw later */
\r
1871 InvalidateRect(td->w, NULL, TRUE);
\r
1876 * Force the use of a new "font file" for a term_data
\r
1878 * This function may be called before the "window" is ready
\r
1880 * This function returns zero only if everything succeeds.
\r
1882 * Note that the "font name" must be capitalized!!!
\r
1884 static errr term_force_font(term_data *td, cptr path)
\r
1888 #if 0 /* #ifndef JP */
\r
1894 /* Forget the old font (if needed) */
\r
1895 if (td->font_id) DeleteObject(td->font_id);
\r
1897 #if 1 /* #ifdef JP */
\r
1901 /* Create the font (using the 'base' of the font file name!) */
\r
1902 td->font_id = CreateFontIndirect(&(td->lf));
\r
1903 wid = td->lf.lfWidth;
\r
1904 hgt = td->lf.lfHeight;
\r
1905 if (!td->font_id) return (1);
\r
1907 /* Forget old font */
\r
1908 if (td->font_file)
\r
1910 bool used = FALSE;
\r
1912 /* Scan windows */
\r
1913 for (i = 0; i < MAX_TERM_DATA; i++)
\r
1915 /* Don't check when closing the application */
\r
1918 /* Check "screen" */
\r
1919 if ((td != &data[i]) &&
\r
1920 (data[i].font_file) &&
\r
1921 (streq(data[i].font_file, td->font_file)))
\r
1927 /* Remove unused font resources */
\r
1928 if (!used) RemoveFontResource(td->font_file);
\r
1930 /* Free the old name */
\r
1931 string_free(td->font_file);
\r
1934 td->font_file = NULL;
\r
1937 /* No path given */
\r
1938 if (!path) return (1);
\r
1941 strcpy(buf, path);
\r
1943 /* Analyze font path */
\r
1944 base = analyze_font(buf, &wid, &hgt);
\r
1946 /* Verify suffix */
\r
1947 if (!suffix(base, ".FON")) return (1);
\r
1950 if (!check_file(buf)) return (1);
\r
1952 /* Load the new font */
\r
1953 if (!AddFontResource(buf)) return (1);
\r
1955 /* Save new font name */
\r
1956 td->font_file = string_make(base);
\r
1958 /* Remove the "suffix" */
\r
1959 base[strlen(base)-4] = '\0';
\r
1961 /* Create the font (using the 'base' of the font file name!) */
\r
1962 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
\r
1963 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
\r
1964 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
\r
1965 FIXED_PITCH | FF_DONTCARE, base);
\r
1968 /* Hack -- Unknown size */
\r
1975 /* all this trouble to get the cell size */
\r
1976 hdcDesktop = GetDC(HWND_DESKTOP);
\r
1977 hfOld = SelectObject(hdcDesktop, td->font_id);
\r
1978 GetTextMetrics(hdcDesktop, &tm);
\r
1979 SelectObject(hdcDesktop, hfOld);
\r
1980 ReleaseDC(HWND_DESKTOP, hdcDesktop);
\r
1982 /* Font size info */
\r
1983 wid = tm.tmAveCharWidth;
\r
1984 hgt = tm.tmHeight;
\r
1987 /* Save the size info */
\r
1988 td->font_wid = wid;
\r
1989 td->font_hgt = hgt;
\r
1998 * Allow the user to change the font for this window.
\r
2000 static void term_change_font(term_data *td)
\r
2002 #if 1 /* #ifdef JP */
\r
2005 memset(&cf, 0, sizeof(cf));
\r
2006 cf.lStructSize = sizeof(cf);
\r
2007 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
\r
2008 cf.lpLogFont = &(td->lf);
\r
2010 if (ChooseFont(&cf))
\r
2012 /* Force the font */
\r
2013 term_force_font(td, NULL);
\r
2015 /* Assume not bizarre */
\r
2016 td->bizarre = TRUE;
\r
2018 /* Reset the tile info */
\r
2019 td->tile_wid = td->font_wid;
\r
2020 td->tile_hgt = td->font_hgt;
\r
2022 /* Analyze the font */
\r
2025 /* Resize the window */
\r
2026 term_window_resize(td);
\r
2032 char tmp[1024] = "";
\r
2034 /* Extract a default if possible */
\r
2035 if (td->font_file) strcpy(tmp, td->font_file);
\r
2037 /* Ask for a choice */
\r
2038 memset(&ofn, 0, sizeof(ofn));
\r
2039 ofn.lStructSize = sizeof(ofn);
\r
2040 ofn.hwndOwner = data[0].w;
\r
2041 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
\r
2042 ofn.nFilterIndex = 1;
\r
2043 ofn.lpstrFile = tmp;
\r
2044 ofn.nMaxFile = 128;
\r
2045 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
\r
2046 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
2047 ofn.lpstrDefExt = "fon";
\r
2049 /* Force choice if legal */
\r
2050 if (GetOpenFileName(&ofn))
\r
2052 /* Force the font */
\r
2053 if (term_force_font(td, tmp))
\r
2055 /* Access the standard font file */
\r
2056 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
2058 /* Force the use of that font */
\r
2059 (void)term_force_font(td, tmp);
\r
2062 /* Assume not bizarre */
\r
2063 td->bizarre = FALSE;
\r
2065 /* Reset the tile info */
\r
2066 td->tile_wid = td->font_wid;
\r
2067 td->tile_hgt = td->font_hgt;
\r
2069 /* Analyze the font */
\r
2072 /* Resize the window */
\r
2073 term_window_resize(td);
\r
2080 * Allow the user to lock this window.
\r
2082 static void term_window_pos(term_data *td, HWND hWnd)
\r
2084 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
\r
2085 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
\r
2088 static void windows_map(void);
\r
2091 * Hack -- redraw a term_data
\r
2093 static void term_data_redraw(term_data *td)
\r
2095 if (td->map_active)
\r
2097 /* Redraw the map */
\r
2102 /* Activate the term */
\r
2103 Term_activate(&td->t);
\r
2105 /* Redraw the contents */
\r
2108 /* Restore the term */
\r
2109 Term_activate(term_screen);
\r
2114 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
\r
2118 HBRUSH myBrush, oldBrush;
\r
2120 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
\r
2121 int tx = td->size_ow1 + x * td->tile_wid;
\r
2122 int ty = td->size_oh1 + y * td->tile_hgt;
\r
2123 int tw = w * td->tile_wid - 1;
\r
2124 int th = h * td->tile_hgt - 1;
\r
2126 hdc = GetDC(hWnd);
\r
2127 myBrush = CreateSolidBrush(RGB(255, 255, 255));
\r
2128 oldBrush = SelectObject(hdc, myBrush);
\r
2129 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2131 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
\r
2133 SelectObject(hdc, oldBrush);
\r
2134 SelectObject(hdc, oldPen);
\r
2139 /*** Function hooks needed by "Term" ***/
\r
2145 * Initialize a new Term
\r
2147 static void Term_init_win(term *t)
\r
2154 * Nuke an old Term
\r
2156 static void Term_nuke_win(term *t)
\r
2165 * Interact with the User
\r
2167 static errr Term_user_win(int n)
\r
2178 * React to global changes
\r
2180 static errr Term_xtra_win_react(void)
\r
2185 /* Simple color */
\r
2188 /* Save the default colors */
\r
2189 for (i = 0; i < 256; i++)
\r
2191 /* Simply accept the desired colors */
\r
2192 win_pal[i] = angband_color_table[i][0];
\r
2196 /* Complex color */
\r
2203 bool change = FALSE;
\r
2205 /* Save the default colors */
\r
2206 for (i = 0; i < 256; i++)
\r
2208 /* Extract desired values */
\r
2209 rv = angband_color_table[i][1];
\r
2210 gv = angband_color_table[i][2];
\r
2211 bv = angband_color_table[i][3];
\r
2213 /* Extract a full color code */
\r
2214 code = PALETTERGB(rv, gv, bv);
\r
2216 /* Activate changes */
\r
2217 if (win_clr[i] != code)
\r
2219 /* Note the change */
\r
2222 /* Apply the desired color */
\r
2223 win_clr[i] = code;
\r
2227 /* Activate the palette if needed */
\r
2228 if (change) (void)new_palette();
\r
2234 /* Handle "arg_sound" */
\r
2235 if (use_sound != arg_sound)
\r
2237 /* Initialize (if needed) */
\r
2238 if (arg_sound && !init_sound())
\r
2241 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
\r
2243 /* Cannot enable */
\r
2244 arg_sound = FALSE;
\r
2247 /* Change setting */
\r
2248 use_sound = arg_sound;
\r
2255 /* Handle "arg_sound" */
\r
2256 if (use_music != arg_music)
\r
2258 /* Initialize (if needed) */
\r
2259 if (arg_music && !init_music())
\r
2262 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
\r
2263 /* Cannot enable */
\r
2264 arg_music = FALSE;
\r
2267 /* Change setting */
\r
2268 use_music = arg_music;
\r
2270 if(!arg_music) stop_music();
\r
2271 else select_floor_music();
\r
2278 #ifdef USE_GRAPHICS
\r
2280 /* Handle "arg_graphics" */
\r
2281 if (use_graphics != arg_graphics)
\r
2283 /* Initialize (if needed) */
\r
2284 if (arg_graphics && !init_graphics())
\r
2287 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
\r
2289 /* Cannot enable */
\r
2290 arg_graphics = GRAPHICS_NONE;
\r
2293 /* Change setting */
\r
2294 use_graphics = arg_graphics;
\r
2296 /* Reset visuals */
\r
2297 #ifdef ANGBAND_2_8_1
\r
2299 #else /* ANGBAND_2_8_1 */
\r
2300 reset_visuals(TRUE);
\r
2301 #endif /* ANGBAND_2_8_1 */
\r
2304 #endif /* USE_GRAPHICS */
\r
2307 /* Clean up windows */
\r
2308 for (i = 0; i < MAX_TERM_DATA; i++)
\r
2312 term_data *td = &data[i];
\r
2314 /* Update resized windows */
\r
2315 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
\r
2318 Term_activate(&td->t);
\r
2320 /* Hack -- Resize the term */
\r
2321 Term_resize(td->cols, td->rows);
\r
2323 /* Redraw the contents */
\r
2327 Term_activate(old);
\r
2338 * Process at least one event
\r
2340 static errr Term_xtra_win_event(int v)
\r
2344 /* Wait for an event */
\r
2348 if (GetMessage(&msg, NULL, 0, 0))
\r
2350 TranslateMessage(&msg);
\r
2351 DispatchMessage(&msg);
\r
2355 /* Check for an event */
\r
2359 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2361 TranslateMessage(&msg);
\r
2362 DispatchMessage(&msg);
\r
2372 * Process all pending events
\r
2374 static errr Term_xtra_win_flush(void)
\r
2378 /* Process all pending events */
\r
2379 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2381 TranslateMessage(&msg);
\r
2382 DispatchMessage(&msg);
\r
2391 * Hack -- clear the screen
\r
2393 * Make this more efficient XXX XXX XXX
\r
2395 static errr Term_xtra_win_clear(void)
\r
2397 term_data *td = (term_data*)(Term->data);
\r
2402 /* Rectangle to erase */
\r
2403 rc.left = td->size_ow1;
\r
2404 rc.right = rc.left + td->cols * td->tile_wid;
\r
2405 rc.top = td->size_oh1;
\r
2406 rc.bottom = rc.top + td->rows * td->tile_hgt;
\r
2409 hdc = GetDC(td->w);
\r
2410 SetBkColor(hdc, RGB(0, 0, 0));
\r
2411 SelectObject(hdc, td->font_id);
\r
2412 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2417 rc.left = 0; rc.top = 0;
\r
2420 ReleaseDC(td->w, hdc);
\r
2428 * Hack -- make a noise
\r
2430 static errr Term_xtra_win_noise(void)
\r
2432 MessageBeep(MB_ICONASTERISK);
\r
2438 * Hack -- make a sound
\r
2440 static errr Term_xtra_win_sound(int v)
\r
2445 #endif /* USE_SOUND */
\r
2447 /* Sound disabled */
\r
2448 if (!use_sound) return (1);
\r
2450 /* Illegal sound */
\r
2451 if ((v < 0) || (v >= SOUND_MAX)) return (1);
\r
2455 /* Count the samples */
\r
2456 for (i = 0; i < SAMPLE_MAX; i++)
\r
2458 if (!sound_file[v][i])
\r
2463 if (i == 0) return (1);
\r
2465 /* Build the path */
\r
2466 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
\r
2470 /* Play the sound, catch errors */
\r
2471 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
\r
2475 /* Play the sound, catch errors */
\r
2476 return (sndPlaySound(buf, SND_ASYNC));
\r
2478 #endif /* WIN32 */
\r
2480 #else /* USE_SOUND */
\r
2485 #endif /* USE_SOUND */
\r
2489 * Hack -- play a music
\r
2491 static errr Term_xtra_win_music(int n, int v)
\r
2496 #endif /* USE_MUSIC */
\r
2498 /* Sound disabled */
\r
2500 if(!use_music) return (1);
\r
2502 /* Illegal sound */
\r
2503 if(n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return (1);
\r
2504 else if(v < 0 || v >= 1000) return(1); /*!< TODO */
\r
2510 case TERM_XTRA_MUSIC_BASIC:
\r
2511 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2513 case TERM_XTRA_MUSIC_DUNGEON:
\r
2514 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2516 case TERM_XTRA_MUSIC_QUEST:
\r
2517 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2519 case TERM_XTRA_MUSIC_TOWN:
\r
2520 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2527 //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2528 //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2534 case TERM_XTRA_MUSIC_BASIC:
\r
2535 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2537 case TERM_XTRA_MUSIC_DUNGEON:
\r
2538 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2540 case TERM_XTRA_MUSIC_QUEST:
\r
2541 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2543 case TERM_XTRA_MUSIC_TOWN:
\r
2544 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2551 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2552 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2558 case TERM_XTRA_MUSIC_BASIC:
\r
2559 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
\r
2561 case TERM_XTRA_MUSIC_DUNGEON:
\r
2562 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
\r
2564 case TERM_XTRA_MUSIC_QUEST:
\r
2565 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
\r
2567 case TERM_XTRA_MUSIC_TOWN:
\r
2568 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
\r
2572 if(current_music_type == n && current_music_id == v)
\r
2576 current_music_type = n;
\r
2577 current_music_id = v;
\r
2581 mop.lpstrDeviceType = mci_device_type;
\r
2582 mop.lpstrElementName = buf;
\r
2583 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2584 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2585 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
\r
2586 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
2587 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
2590 #endif /* WIN32 */
\r
2592 #else /* USE_MUSIC */
\r
2596 #endif /* USE_MUSIC */
\r
2602 * Delay for "x" milliseconds
\r
2604 static int Term_xtra_win_delay(int v)
\r
2618 t = GetTickCount() + v;
\r
2621 while (GetTickCount() < t)
\r
2623 /* Handle messages */
\r
2624 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2626 TranslateMessage(&msg);
\r
2627 DispatchMessage(&msg);
\r
2631 #endif /* WIN32 */
\r
2639 * Do a "special thing"
\r
2641 static errr Term_xtra_win(int n, int v)
\r
2643 /* Handle a subset of the legal requests */
\r
2646 /* Make a bell sound */
\r
2647 case TERM_XTRA_NOISE:
\r
2649 return (Term_xtra_win_noise());
\r
2652 /* Play a music */
\r
2653 case TERM_XTRA_MUSIC_BASIC:
\r
2654 case TERM_XTRA_MUSIC_DUNGEON:
\r
2655 case TERM_XTRA_MUSIC_QUEST:
\r
2656 case TERM_XTRA_MUSIC_TOWN:
\r
2658 return (Term_xtra_win_music(n, v));
\r
2661 /* Make a special sound */
\r
2662 case TERM_XTRA_SOUND:
\r
2664 return (Term_xtra_win_sound(v));
\r
2667 /* Process random events */
\r
2668 case TERM_XTRA_BORED:
\r
2670 return (Term_xtra_win_event(0));
\r
2673 /* Process an event */
\r
2674 case TERM_XTRA_EVENT:
\r
2676 return (Term_xtra_win_event(v));
\r
2679 /* Flush all events */
\r
2680 case TERM_XTRA_FLUSH:
\r
2682 return (Term_xtra_win_flush());
\r
2685 /* Clear the screen */
\r
2686 case TERM_XTRA_CLEAR:
\r
2688 return (Term_xtra_win_clear());
\r
2691 /* React to global changes */
\r
2692 case TERM_XTRA_REACT:
\r
2694 return (Term_xtra_win_react());
\r
2697 /* Delay for some milliseconds */
\r
2698 case TERM_XTRA_DELAY:
\r
2700 return (Term_xtra_win_delay(v));
\r
2711 * Low level graphics (Assumes valid input).
\r
2713 * Draw a "cursor" at (x,y), using a "yellow box".
\r
2715 static errr Term_curs_win(int x, int y)
\r
2717 term_data *td = (term_data*)(Term->data);
\r
2722 int tile_wid, tile_hgt;
\r
2724 if (td->map_active)
\r
2726 tile_wid = td->map_tile_wid;
\r
2727 tile_hgt = td->map_tile_hgt;
\r
2731 tile_wid = td->tile_wid;
\r
2732 tile_hgt = td->tile_hgt;
\r
2735 /* Frame the grid */
\r
2736 rc.left = x * tile_wid + td->size_ow1;
\r
2737 rc.right = rc.left + tile_wid;
\r
2738 rc.top = y * tile_hgt + td->size_oh1;
\r
2739 rc.bottom = rc.top + tile_hgt;
\r
2741 /* Cursor is done as a yellow "box" */
\r
2742 hdc = GetDC(td->w);
\r
2743 FrameRect(hdc, &rc, hbrYellow);
\r
2744 ReleaseDC(td->w, hdc);
\r
2752 * Low level graphics (Assumes valid input).
\r
2754 * Draw a "big cursor" at (x,y), using a "yellow box".
\r
2756 static errr Term_bigcurs_win(int x, int y)
\r
2758 term_data *td = (term_data*)(Term->data);
\r
2763 int tile_wid, tile_hgt;
\r
2765 if (td->map_active)
\r
2767 /* Normal cursor in map window */
\r
2768 Term_curs_win(x, y);
\r
2773 tile_wid = td->tile_wid;
\r
2774 tile_hgt = td->tile_hgt;
\r
2777 /* Frame the grid */
\r
2778 rc.left = x * tile_wid + td->size_ow1;
\r
2779 rc.right = rc.left + 2 * tile_wid;
\r
2780 rc.top = y * tile_hgt + td->size_oh1;
\r
2781 rc.bottom = rc.top + tile_hgt;
\r
2783 /* Cursor is done as a yellow "box" */
\r
2784 hdc = GetDC(td->w);
\r
2785 FrameRect(hdc, &rc, hbrYellow);
\r
2786 ReleaseDC(td->w, hdc);
\r
2794 * Low level graphics (Assumes valid input).
\r
2796 * Erase a "block" of "n" characters starting at (x,y).
\r
2798 static errr Term_wipe_win(int x, int y, int n)
\r
2800 term_data *td = (term_data*)(Term->data);
\r
2805 /* Rectangle to erase in client coords */
\r
2806 rc.left = x * td->tile_wid + td->size_ow1;
\r
2807 rc.right = rc.left + n * td->tile_wid;
\r
2808 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2809 rc.bottom = rc.top + td->tile_hgt;
\r
2811 hdc = GetDC(td->w);
\r
2812 SetBkColor(hdc, RGB(0, 0, 0));
\r
2813 SelectObject(hdc, td->font_id);
\r
2818 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2819 ReleaseDC(td->w, hdc);
\r
2827 * Low level graphics. Assumes valid input.
\r
2829 * Draw several ("n") chars, with an attr, at a given location.
\r
2831 * All "graphic" data is handled by "Term_pict_win()", below.
\r
2833 * One would think there is a more efficient method for telling a window
\r
2834 * what color it should be using to draw with, but perhaps simply changing
\r
2835 * it every time is not too inefficient. XXX XXX XXX
\r
2837 static errr Term_text_win(int x, int y, int n, byte a, const char *s)
\r
2839 term_data *td = (term_data*)(Term->data);
\r
2843 #if 1 /* #ifdef JP */
\r
2844 static HBITMAP WALL;
\r
2845 static HBRUSH myBrush, oldBrush;
\r
2846 static HPEN oldPen;
\r
2847 static bool init_done = FALSE;
\r
2850 WALL = LoadBitmap(hInstance, AppName);
\r
2851 myBrush = CreatePatternBrush(WALL);
\r
2856 /* Total rectangle */
\r
2857 rc.left = x * td->tile_wid + td->size_ow1;
\r
2858 rc.right = rc.left + n * td->tile_wid;
\r
2859 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2860 rc.bottom = rc.top + td->tile_hgt;
\r
2863 hdc = GetDC(td->w);
\r
2865 /* Background color */
\r
2866 SetBkColor(hdc, RGB(0, 0, 0));
\r
2868 /* Foreground color */
\r
2871 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
\r
2873 else if (paletted)
\r
2875 SetTextColor(hdc, win_clr[a&0x0F]);
\r
2879 SetTextColor(hdc, win_clr[a]);
\r
2882 /* Use the font */
\r
2883 SelectObject(hdc, td->font_id);
\r
2886 if (use_bg) SetBkMode(hdc, TRANSPARENT);
\r
2888 /* Bizarre size */
\r
2889 if (td->bizarre ||
\r
2890 (td->tile_hgt != td->font_hgt) ||
\r
2891 (td->tile_wid != td->font_wid))
\r
2895 /* Erase complete rectangle */
\r
2896 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2899 if (use_bg) DrawBG(hdc, &rc);
\r
2901 /* New rectangle */
\r
2902 rc.left += ((td->tile_wid - td->font_wid) / 2);
\r
2903 rc.right = rc.left + td->font_wid;
\r
2904 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
\r
2905 rc.bottom = rc.top + td->font_hgt;
\r
2907 /* Dump each character */
\r
2908 for (i = 0; i < n; i++)
\r
2911 if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
\r
2913 rc.right += td->font_wid;
\r
2915 oldBrush = SelectObject(hdc, myBrush);
\r
2916 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2918 /* Dump the wall */
\r
2919 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2921 SelectObject(hdc, oldBrush);
\r
2922 SelectObject(hdc, oldPen);
\r
2923 rc.right -= td->font_wid;
\r
2927 rc.left += 2 * td->tile_wid;
\r
2928 rc.right += 2 * td->tile_wid;
\r
2930 else if ( iskanji(*(s+i)) ) /* 2バイト文字 */
\r
2932 rc.right += td->font_wid;
\r
2933 /* Dump the text */
\r
2934 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2936 rc.right -= td->font_wid;
\r
2940 rc.left += 2 * td->tile_wid;
\r
2941 rc.right += 2 * td->tile_wid;
\r
2942 } else if (*(s+i)==127){
\r
2943 oldBrush = SelectObject(hdc, myBrush);
\r
2944 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2946 /* Dump the wall */
\r
2947 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2949 SelectObject(hdc, oldBrush);
\r
2950 SelectObject(hdc, oldPen);
\r
2953 rc.left += td->tile_wid;
\r
2954 rc.right += td->tile_wid;
\r
2956 /* Dump the text */
\r
2957 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
\r
2960 rc.left += td->tile_wid;
\r
2961 rc.right += td->tile_wid;
\r
2966 oldBrush = SelectObject(hdc, myBrush);
\r
2967 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2969 /* Dump the wall */
\r
2970 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2972 SelectObject(hdc, oldBrush);
\r
2973 SelectObject(hdc, oldPen);
\r
2976 rc.left += td->tile_wid;
\r
2977 rc.right += td->tile_wid;
\r
2979 /* Dump the text */
\r
2980 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2984 rc.left += td->tile_wid;
\r
2985 rc.right += td->tile_wid;
\r
2988 /* Dump the text */
\r
2989 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
\r
2993 rc.left += td->tile_wid;
\r
2994 rc.right += td->tile_wid;
\r
3004 /* Dump the text */
\r
3005 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
\r
3010 ReleaseDC(td->w, hdc);
\r
3018 * Low level graphics. Assumes valid input.
\r
3020 * Draw an array of "special" attr/char pairs at the given location.
\r
3022 * We use the "Term_pict_win()" function for "graphic" data, which are
\r
3023 * encoded by setting the "high-bits" of both the "attr" and the "char"
\r
3024 * data. We use the "attr" to represent the "row" of the main bitmap,
\r
3025 * and the "char" to represent the "col" of the main bitmap. The use
\r
3026 * of this function is induced by the "higher_pict" flag.
\r
3028 * If "graphics" is not available, we simply "wipe" the given grids.
\r
3030 static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
\r
3032 term_data *td = (term_data*)(Term->data);
\r
3034 #ifdef USE_GRAPHICS
\r
3037 int x1, y1, w1, h1, tw1, th1;
\r
3038 int x2, y2, w2, h2, tw2 = 0;
\r
3041 HDC hdcMask = NULL;
\r
3045 HBITMAP hbmSrcOld;
\r
3048 if (!use_graphics)
\r
3050 /* Erase the grids */
\r
3051 return (Term_wipe_win(x, y, n));
\r
3054 /* Size of bitmap cell */
\r
3055 w1 = infGraph.CellWidth;
\r
3056 h1 = infGraph.CellHeight;
\r
3057 tw1 = infGraph.TileWidth;
\r
3058 th1 = infGraph.TileHeight;
\r
3060 /* Size of window cell */
\r
3061 if (td->map_active)
\r
3063 w2 = td->map_tile_wid;
\r
3064 h2 = td->map_tile_hgt;
\r
3068 w2 = td->tile_wid;
\r
3069 h2 = td->tile_hgt;
\r
3072 /* big tile mode */
\r
3073 if (use_bigtile) tw2 *= 2;
\r
3076 /* Location of window cell */
\r
3077 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
\r
3078 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
\r
3081 hdc = GetDC(td->w);
\r
3084 hdcSrc = CreateCompatibleDC(hdc);
\r
3085 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
\r
3087 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3089 hdcMask = CreateCompatibleDC(hdc);
\r
3090 SelectObject(hdcMask, infMask.hBitmap);
\r
3093 /* Draw attr/char pairs */
\r
3094 for (i = 0; i < n; i++, x2 += w2)
\r
3100 /* Extract picture */
\r
3101 int row = (a & 0x7F);
\r
3102 int col = (c & 0x7F);
\r
3104 /* Location of bitmap cell */
\r
3108 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3110 x3 = (tcp[i] & 0x7F) * w1;
\r
3111 y3 = (tap[i] & 0x7F) * h1;
\r
3112 tw2 = tw2 * w1 / tw1;
\r
3113 h2 = h2 * h1 / th1;
\r
3115 /* Perfect size */
\r
3116 if ((tw1 == tw2) && (th1 == h2))
\r
3118 /* Copy the terrain picture from the bitmap to the window */
\r
3119 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
\r
3121 /* Mask out the tile */
\r
3122 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
\r
3124 /* Draw the tile */
\r
3125 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
\r
3128 /* Need to stretch */
\r
3131 /* Set the correct mode for stretching the tiles */
\r
3132 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3134 /* Copy the terrain picture from the bitmap to the window */
\r
3135 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
\r
3137 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
\r
3139 /* Only draw if terrain and overlay are different */
\r
3140 if ((x1 != x3) || (y1 != y3))
\r
3142 /* Mask out the tile */
\r
3143 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
\r
3145 /* Draw the tile */
\r
3146 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
\r
3152 /* Perfect size */
\r
3153 if ((w1 == tw2) && (h1 == h2))
\r
3155 /* Copy the picture from the bitmap to the window */
\r
3156 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
\r
3159 /* Need to stretch */
\r
3162 /* Set the correct mode for stretching the tiles */
\r
3163 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3165 /* Copy the picture from the bitmap to the window */
\r
3166 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
\r
3172 SelectObject(hdcSrc, hbmSrcOld);
\r
3175 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3178 SelectObject(hdcMask, hbmSrcOld);
\r
3179 DeleteDC(hdcMask);
\r
3183 ReleaseDC(td->w, hdc);
\r
3185 #else /* USE_GRAPHICS */
\r
3187 /* Just erase this grid */
\r
3188 return (Term_wipe_win(x, y, n));
\r
3190 #endif /* USE_GRAPHICS */
\r
3197 static void windows_map(void)
\r
3199 term_data *td = &data[0];
\r
3202 int x, min_x, max_x;
\r
3203 int y, min_y, max_y;
\r
3208 /* Only in graphics mode */
\r
3209 if (!use_graphics) return;
\r
3211 /* Clear screen */
\r
3212 Term_xtra_win_clear();
\r
3214 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
\r
3215 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
\r
3216 td->map_active = TRUE;
\r
3225 /* Draw the map */
\r
3226 for (x = min_x; x < max_x; x++)
\r
3228 for (y = min_y; y < max_y; y++)
\r
3230 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
\r
3232 /* Ignore non-graphics */
\r
3233 if ((a & 0x80) && (c & 0x80))
\r
3235 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
\r
3240 /* Hilite the player */
\r
3241 Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
\r
3243 /* Wait for a keypress, flush key buffer */
\r
3244 Term_inkey(&c, TRUE, TRUE);
\r
3247 /* Switch off the map display */
\r
3248 td->map_active = FALSE;
\r
3250 /* Restore screen */
\r
3251 Term_xtra_win_clear();
\r
3256 /*** Other routines ***/
\r
3260 * Create and initialize a "term_data" given a title
\r
3262 static void term_data_link(term_data *td)
\r
3266 /* Initialize the term */
\r
3267 term_init(t, td->cols, td->rows, td->keys);
\r
3269 /* Use a "software" cursor */
\r
3270 t->soft_cursor = TRUE;
\r
3272 /* Use "Term_pict" for "graphic" data */
\r
3273 t->higher_pict = TRUE;
\r
3275 /* Erase with "white space" */
\r
3276 t->attr_blank = TERM_WHITE;
\r
3277 t->char_blank = ' ';
\r
3280 /* Prepare the init/nuke hooks */
\r
3281 t->init_hook = Term_init_win;
\r
3282 t->nuke_hook = Term_nuke_win;
\r
3285 /* Prepare the template hooks */
\r
3286 t->user_hook = Term_user_win;
\r
3287 t->xtra_hook = Term_xtra_win;
\r
3288 t->curs_hook = Term_curs_win;
\r
3289 t->bigcurs_hook = Term_bigcurs_win;
\r
3290 t->wipe_hook = Term_wipe_win;
\r
3291 t->text_hook = Term_text_win;
\r
3292 t->pict_hook = Term_pict_win;
\r
3294 /* Remember where we came from */
\r
3295 t->data = (vptr)(td);
\r
3300 * Create the windows
\r
3302 * First, instantiate the "default" values, then read the "ini_file"
\r
3303 * to over-ride selected values, then create the windows, and fonts.
\r
3305 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
\r
3306 * must make active to realize the palette. XXX XXX XXX
\r
3308 static void init_windows(void)
\r
3314 #if 0 /* #ifndef JP */
\r
3320 WIPE(td, term_data);
\r
3324 td->s = angband_term_name[0];
\r
3330 td->visible = TRUE;
\r
3335 td->pos_x = 7 * 30;
\r
3336 td->pos_y = 7 * 20;
\r
3337 td->posfix = FALSE;
\r
3338 #if 1 /* #ifdef JP */
\r
3339 td->bizarre = TRUE;
\r
3342 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3345 WIPE(td, term_data);
\r
3346 td->s = angband_term_name[i];
\r
3350 td->visible = FALSE;
\r
3355 td->pos_x = (7 - i) * 30;
\r
3356 td->pos_y = (7 - i) * 20;
\r
3357 td->posfix = FALSE;
\r
3358 #if 1 /* #ifdef JP */
\r
3359 td->bizarre = TRUE;
\r
3368 /* Main window (need these before term_getsize gets called) */
\r
3370 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
\r
3371 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
\r
3373 td->dwExStyle = 0;
\r
3374 td->visible = TRUE;
\r
3376 /* Sub windows (need these before term_getsize gets called) */
\r
3377 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3380 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
\r
3381 td->dwExStyle = (WS_EX_TOOLWINDOW);
\r
3386 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3390 #if 1 /* #ifdef JP */
\r
3391 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
\r
3392 td->lf.lfCharSet = DEFAULT_CHARSET;
\r
3393 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
\r
3394 /* Activate the chosen font */
\r
3395 term_force_font(td, NULL);
\r
3396 if(!td->tile_wid) td->tile_wid = td->font_wid;
\r
3397 if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
\r
3399 /* Access the standard font file */
\r
3400 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
\r
3402 /* Activate the chosen font */
\r
3403 if (term_force_font(td, buf))
\r
3405 /* Access the standard font file */
\r
3406 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
3408 /* Force the use of that font */
\r
3409 (void)term_force_font(td, buf);
\r
3413 td->tile_hgt = 13;
\r
3415 /* Assume not bizarre */
\r
3416 td->bizarre = FALSE;
\r
3421 /* Analyze the font */
\r
3424 /* Resize the window */
\r
3425 term_window_resize(td);
\r
3429 /* Sub windows (reverse order) */
\r
3430 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
\r
3435 td->w = CreateWindowEx(td->dwExStyle, AngList,
\r
3436 td->s, td->dwStyle,
\r
3437 td->pos_x, td->pos_y,
\r
3438 td->size_wid, td->size_hgt,
\r
3439 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3441 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
\r
3445 td->size_hack = TRUE;
\r
3446 ShowWindow(td->w, SW_SHOW);
\r
3447 td->size_hack = FALSE;
\r
3450 term_data_link(td);
\r
3451 angband_term[i] = &td->t;
\r
3455 /* Activate the window */
\r
3456 SetActiveWindow(td->w);
\r
3459 if (data[i].posfix)
\r
3461 term_window_pos(&data[i], HWND_TOPMOST);
\r
3465 term_window_pos(&data[i], td->w);
\r
3475 td->w = CreateWindowEx(td->dwExStyle, AppName,
\r
3476 td->s, td->dwStyle,
\r
3477 td->pos_x, td->pos_y,
\r
3478 td->size_wid, td->size_hgt,
\r
3479 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3481 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
\r
3483 term_data_link(td);
\r
3484 angband_term[0] = &td->t;
\r
3485 normsize.x = td->cols;
\r
3486 normsize.y = td->rows;
\r
3488 /* Activate the main window */
\r
3489 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
\r
3490 else ShowWindow(td->w, SW_SHOW);
\r
3492 /* Bring main window back to top */
\r
3493 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
3496 /* New palette XXX XXX XXX */
\r
3497 (void)new_palette();
\r
3500 /* Create a "brush" for drawing the "cursor" */
\r
3501 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
\r
3504 /* Process pending messages */
\r
3505 (void)Term_xtra_win_flush();
\r
3511 * Prepare the menus
\r
3513 static void setup_menus(void)
\r
3517 HMENU hm = GetMenu(data[0].w);
\r
3520 /* Menu "File", Disable all */
\r
3521 EnableMenuItem(hm, IDM_FILE_NEW,
\r
3522 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3523 EnableMenuItem(hm, IDM_FILE_OPEN,
\r
3524 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3525 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3526 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3527 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3528 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3529 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3530 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3533 /* No character available */
\r
3534 if (!character_generated)
\r
3536 /* Menu "File", Item "New" */
\r
3537 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
\r
3539 /* Menu "File", Item "Open" */
\r
3540 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
\r
3543 /* A character available */
\r
3544 if (character_generated)
\r
3546 /* Menu "File", Item "Save" */
\r
3547 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3548 MF_BYCOMMAND | MF_ENABLED);
\r
3551 /* Menu "File", Item "Exit" */
\r
3552 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3553 MF_BYCOMMAND | MF_ENABLED);
\r
3555 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3556 MF_BYCOMMAND | MF_ENABLED);
\r
3559 /* Menu "Window::Visibility" */
\r
3560 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3562 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3563 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3565 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3566 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
\r
3568 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3569 MF_BYCOMMAND | MF_ENABLED);
\r
3572 /* Menu "Window::Font" */
\r
3573 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3575 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3576 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3578 if (data[i].visible)
\r
3580 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3581 MF_BYCOMMAND | MF_ENABLED);
\r
3585 /* Menu "Window::Window Position Fix" */
\r
3586 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3588 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3589 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3591 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3592 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
\r
3594 if (data[i].visible)
\r
3596 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3597 MF_BYCOMMAND | MF_ENABLED);
\r
3601 /* Menu "Window::Bizarre Display" */
\r
3602 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3604 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3605 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3607 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3608 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
\r
3610 if (data[i].visible)
\r
3612 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3613 MF_BYCOMMAND | MF_ENABLED);
\r
3618 /* Menu "Window::Increase Tile Width" */
\r
3619 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3621 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3622 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3624 if (data[i].visible)
\r
3626 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3627 MF_BYCOMMAND | MF_ENABLED);
\r
3632 /* Menu "Window::Decrease Tile Width" */
\r
3633 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3635 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3636 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3638 if (data[i].visible)
\r
3640 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3641 MF_BYCOMMAND | MF_ENABLED);
\r
3646 /* Menu "Window::Increase Tile Height" */
\r
3647 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3649 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3650 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3652 if (data[i].visible)
\r
3654 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3655 MF_BYCOMMAND | MF_ENABLED);
\r
3660 /* Menu "Window::Decrease Tile Height" */
\r
3661 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3663 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3664 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3666 if (data[i].visible)
\r
3668 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3669 MF_BYCOMMAND | MF_ENABLED);
\r
3674 /* Menu "Options", disable all */
\r
3675 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3676 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3677 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3678 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3679 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3680 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3681 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3682 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3683 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3684 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3686 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3687 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3690 /* Menu "Options", Item "Map" */
\r
3691 if (use_graphics != GRAPHICS_NONE)
\r
3692 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
\r
3694 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
\r
3695 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3697 /* Menu "Options", update all */
\r
3698 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3699 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
\r
3700 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3701 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
\r
3702 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3703 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
\r
3704 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
\r
3705 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
\r
3706 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3707 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
\r
3708 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
\r
3709 (arg_music ? MF_CHECKED : MF_UNCHECKED));
\r
3710 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3711 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
\r
3712 CheckMenuItem(hm, IDM_OPTIONS_BG,
\r
3713 (use_bg ? MF_CHECKED : MF_UNCHECKED));
\r
3715 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3716 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
\r
3719 #ifdef USE_GRAPHICS
\r
3720 /* Menu "Options", Item "Graphics" */
\r
3721 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
\r
3722 /* Menu "Options", Item "Graphics" */
\r
3723 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
\r
3724 /* Menu "Options", Item "Graphics" */
\r
3725 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
\r
3726 /* Menu "Options", Item "Graphics" */
\r
3727 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
\r
3728 #endif /* USE_GRAPHICS */
\r
3731 /* Menu "Options", Item "Sound" */
\r
3732 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
\r
3733 #endif /* USE_SOUND */
\r
3736 /* Menu "Options", Item "ScreenSaver" */
\r
3737 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3738 MF_BYCOMMAND | MF_ENABLED);
\r
3739 #endif /* USE_SAVER */
\r
3744 * Check for double clicked (or dragged) savefile
\r
3746 * Apparently, Windows copies the entire filename into the first
\r
3747 * piece of the "command line string". Perhaps we should extract
\r
3748 * the "basename" of that filename and append it to the "save" dir.
\r
3750 static void check_for_save_file(LPSTR cmd_line)
\r
3760 /* Extract filename */
\r
3761 strcat(savefile, s);
\r
3763 /* Validate the file */
\r
3764 validate_file(savefile);
\r
3766 /* Game in progress */
\r
3767 game_in_progress = TRUE;
\r
3775 * Process a menu command
\r
3777 static void process_menus(WORD wCmd)
\r
3789 case IDM_FILE_NEW:
\r
3793 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3795 else if (game_in_progress)
\r
3797 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
\r
3801 game_in_progress = TRUE;
\r
3810 case IDM_FILE_OPEN:
\r
3814 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3816 else if (game_in_progress)
\r
3818 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
\r
3822 memset(&ofn, 0, sizeof(ofn));
\r
3823 ofn.lStructSize = sizeof(ofn);
\r
3824 ofn.hwndOwner = data[0].w;
\r
3825 ofn.lpstrFilter = "Save Files (*.)\0*\0";
\r
3826 ofn.nFilterIndex = 1;
\r
3827 ofn.lpstrFile = savefile;
\r
3828 ofn.nMaxFile = 1024;
\r
3829 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
\r
3830 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
\r
3832 if (GetOpenFileName(&ofn))
\r
3834 /* Load 'savefile' */
\r
3835 validate_file(savefile);
\r
3836 game_in_progress = TRUE;
\r
3846 case IDM_FILE_SAVE:
\r
3848 if (game_in_progress && character_generated)
\r
3853 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
\r
3857 /* Hack -- Forget messages */
\r
3860 /* Save the game */
\r
3862 do_cmd_save_game(FALSE);
\r
3863 #else /* ZANGBAND */
\r
3864 do_cmd_save_game();
\r
3865 #endif /* ZANGBAND */
\r
3869 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
\r
3875 case IDM_FILE_EXIT:
\r
3877 if (game_in_progress && character_generated)
\r
3882 plog(_("今は終了できません。", "You may not do that right now."));
\r
3886 /* Hack -- Forget messages */
\r
3893 /* Save the game */
\r
3895 /* do_cmd_save_game(FALSE); */
\r
3896 #else /* ZANGBAND */
\r
3897 /* do_cmd_save_game(); */
\r
3898 #endif /* ZANGBAND */
\r
3899 Term_key_push(SPECIAL_KEY_QUIT);
\r
3907 case IDM_FILE_SCORE:
\r
3911 /* Build the filename */
\r
3912 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
\r
3914 /* Open the binary high score file, for reading */
\r
3915 highscore_fd = fd_open(buf, O_RDONLY);
\r
3917 /* Paranoia -- No score file */
\r
3918 if (highscore_fd < 0)
\r
3920 msg_print("Score file unavailable.");
\r
3927 /* Clear screen */
\r
3930 /* Display the scores */
\r
3931 display_scores_aux(0, MAX_HISCORES, -1, NULL);
\r
3933 /* Shut the high score file */
\r
3934 (void)fd_close(highscore_fd);
\r
3936 /* Forget the high score fd */
\r
3937 highscore_fd = -1;
\r
3942 /* Hack - Flush it */
\r
3950 case IDM_FILE_MOVIE:
\r
3954 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3956 else if (game_in_progress)
\r
3958 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
\r
3962 memset(&ofn, 0, sizeof(ofn));
\r
3963 ofn.lStructSize = sizeof(ofn);
\r
3964 ofn.hwndOwner = data[0].w;
\r
3965 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
\r
3966 ofn.nFilterIndex = 1;
\r
3967 ofn.lpstrFile = savefile;
\r
3968 ofn.nMaxFile = 1024;
\r
3969 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
\r
3970 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
3972 if (GetOpenFileName(&ofn))
\r
3974 /* Load 'savefile' */
\r
3975 prepare_browse_movie_aux(savefile);
\r
3985 case IDM_WINDOW_VIS_0:
\r
3987 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
\r
3991 /* Window visibility */
\r
3992 case IDM_WINDOW_VIS_1:
\r
3993 case IDM_WINDOW_VIS_2:
\r
3994 case IDM_WINDOW_VIS_3:
\r
3995 case IDM_WINDOW_VIS_4:
\r
3996 case IDM_WINDOW_VIS_5:
\r
3997 case IDM_WINDOW_VIS_6:
\r
3998 case IDM_WINDOW_VIS_7:
\r
4000 i = wCmd - IDM_WINDOW_VIS_0;
\r
4002 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4008 td->visible = TRUE;
\r
4009 ShowWindow(td->w, SW_SHOW);
\r
4010 term_data_redraw(td);
\r
4014 td->visible = FALSE;
\r
4015 td->posfix = FALSE;
\r
4016 ShowWindow(td->w, SW_HIDE);
\r
4022 /* Window fonts */
\r
4023 case IDM_WINDOW_FONT_0:
\r
4024 case IDM_WINDOW_FONT_1:
\r
4025 case IDM_WINDOW_FONT_2:
\r
4026 case IDM_WINDOW_FONT_3:
\r
4027 case IDM_WINDOW_FONT_4:
\r
4028 case IDM_WINDOW_FONT_5:
\r
4029 case IDM_WINDOW_FONT_6:
\r
4030 case IDM_WINDOW_FONT_7:
\r
4032 i = wCmd - IDM_WINDOW_FONT_0;
\r
4034 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4038 term_change_font(td);
\r
4043 /* Window Z Position */
\r
4044 case IDM_WINDOW_POS_1:
\r
4045 case IDM_WINDOW_POS_2:
\r
4046 case IDM_WINDOW_POS_3:
\r
4047 case IDM_WINDOW_POS_4:
\r
4048 case IDM_WINDOW_POS_5:
\r
4049 case IDM_WINDOW_POS_6:
\r
4050 case IDM_WINDOW_POS_7:
\r
4052 i = wCmd - IDM_WINDOW_POS_0;
\r
4054 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4058 if (!td->posfix && td->visible)
\r
4060 td->posfix = TRUE;
\r
4061 term_window_pos(td, HWND_TOPMOST);
\r
4065 td->posfix = FALSE;
\r
4066 term_window_pos(td, data[0].w);
\r
4072 /* Bizarre Display */
\r
4073 case IDM_WINDOW_BIZ_0:
\r
4074 case IDM_WINDOW_BIZ_1:
\r
4075 case IDM_WINDOW_BIZ_2:
\r
4076 case IDM_WINDOW_BIZ_3:
\r
4077 case IDM_WINDOW_BIZ_4:
\r
4078 case IDM_WINDOW_BIZ_5:
\r
4079 case IDM_WINDOW_BIZ_6:
\r
4080 case IDM_WINDOW_BIZ_7:
\r
4082 i = wCmd - IDM_WINDOW_BIZ_0;
\r
4084 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4088 td->bizarre = !td->bizarre;
\r
4092 term_window_resize(td);
\r
4097 /* Increase Tile Width */
\r
4098 case IDM_WINDOW_I_WID_0:
\r
4099 case IDM_WINDOW_I_WID_1:
\r
4100 case IDM_WINDOW_I_WID_2:
\r
4101 case IDM_WINDOW_I_WID_3:
\r
4102 case IDM_WINDOW_I_WID_4:
\r
4103 case IDM_WINDOW_I_WID_5:
\r
4104 case IDM_WINDOW_I_WID_6:
\r
4105 case IDM_WINDOW_I_WID_7:
\r
4107 i = wCmd - IDM_WINDOW_I_WID_0;
\r
4109 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4113 td->tile_wid += 1;
\r
4117 term_window_resize(td);
\r
4122 /* Decrease Tile Height */
\r
4123 case IDM_WINDOW_D_WID_0:
\r
4124 case IDM_WINDOW_D_WID_1:
\r
4125 case IDM_WINDOW_D_WID_2:
\r
4126 case IDM_WINDOW_D_WID_3:
\r
4127 case IDM_WINDOW_D_WID_4:
\r
4128 case IDM_WINDOW_D_WID_5:
\r
4129 case IDM_WINDOW_D_WID_6:
\r
4130 case IDM_WINDOW_D_WID_7:
\r
4132 i = wCmd - IDM_WINDOW_D_WID_0;
\r
4134 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4138 td->tile_wid -= 1;
\r
4142 term_window_resize(td);
\r
4147 /* Increase Tile Height */
\r
4148 case IDM_WINDOW_I_HGT_0:
\r
4149 case IDM_WINDOW_I_HGT_1:
\r
4150 case IDM_WINDOW_I_HGT_2:
\r
4151 case IDM_WINDOW_I_HGT_3:
\r
4152 case IDM_WINDOW_I_HGT_4:
\r
4153 case IDM_WINDOW_I_HGT_5:
\r
4154 case IDM_WINDOW_I_HGT_6:
\r
4155 case IDM_WINDOW_I_HGT_7:
\r
4157 i = wCmd - IDM_WINDOW_I_HGT_0;
\r
4159 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4163 td->tile_hgt += 1;
\r
4167 term_window_resize(td);
\r
4172 /* Decrease Tile Height */
\r
4173 case IDM_WINDOW_D_HGT_0:
\r
4174 case IDM_WINDOW_D_HGT_1:
\r
4175 case IDM_WINDOW_D_HGT_2:
\r
4176 case IDM_WINDOW_D_HGT_3:
\r
4177 case IDM_WINDOW_D_HGT_4:
\r
4178 case IDM_WINDOW_D_HGT_5:
\r
4179 case IDM_WINDOW_D_HGT_6:
\r
4180 case IDM_WINDOW_D_HGT_7:
\r
4182 i = wCmd - IDM_WINDOW_D_HGT_0;
\r
4184 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4188 td->tile_hgt -= 1;
\r
4192 term_window_resize(td);
\r
4197 case IDM_OPTIONS_NO_GRAPHICS:
\r
4202 plog("You may not do that right now.");
\r
4206 /* Toggle "arg_graphics" */
\r
4207 if (arg_graphics != GRAPHICS_NONE)
\r
4209 arg_graphics = GRAPHICS_NONE;
\r
4211 /* React to changes */
\r
4212 Term_xtra_win_react();
\r
4214 /* Hack -- Force redraw */
\r
4215 Term_key_push(KTRL('R'));
\r
4221 case IDM_OPTIONS_OLD_GRAPHICS:
\r
4226 plog("You may not do that right now.");
\r
4230 /* Toggle "arg_graphics" */
\r
4231 if (arg_graphics != GRAPHICS_ORIGINAL)
\r
4233 arg_graphics = GRAPHICS_ORIGINAL;
\r
4235 /* React to changes */
\r
4236 Term_xtra_win_react();
\r
4238 /* Hack -- Force redraw */
\r
4239 Term_key_push(KTRL('R'));
\r
4245 case IDM_OPTIONS_NEW_GRAPHICS:
\r
4250 plog("You may not do that right now.");
\r
4254 /* Toggle "arg_graphics" */
\r
4255 if (arg_graphics != GRAPHICS_ADAM_BOLT)
\r
4257 arg_graphics = GRAPHICS_ADAM_BOLT;
\r
4259 /* React to changes */
\r
4260 Term_xtra_win_react();
\r
4262 /* Hack -- Force redraw */
\r
4263 Term_key_push(KTRL('R'));
\r
4269 case IDM_OPTIONS_NEW2_GRAPHICS:
\r
4274 plog("You may not do that right now.");
\r
4278 /* Toggle "arg_graphics" */
\r
4279 if (arg_graphics != GRAPHICS_HENGBAND)
\r
4281 arg_graphics = GRAPHICS_HENGBAND;
\r
4283 /* React to changes */
\r
4284 Term_xtra_win_react();
\r
4286 /* Hack -- Force redraw */
\r
4287 Term_key_push(KTRL('R'));
\r
4293 case IDM_OPTIONS_BIGTILE:
\r
4300 plog("You may not do that right now.");
\r
4304 /* Toggle "arg_sound" */
\r
4305 arg_bigtile = !arg_bigtile;
\r
4308 Term_activate(&td->t);
\r
4310 /* Resize the term */
\r
4311 Term_resize(td->cols, td->rows);
\r
4313 /* Redraw later */
\r
4314 InvalidateRect(td->w, NULL, TRUE);
\r
4319 case IDM_OPTIONS_MUSIC:
\r
4324 plog("You may not do that right now.");
\r
4328 /* Toggle "arg_sound" */
\r
4329 arg_music = !arg_music;
\r
4331 /* React to changes */
\r
4332 Term_xtra_win_react();
\r
4334 /* Hack -- Force redraw */
\r
4335 Term_key_push(KTRL('R'));
\r
4340 case IDM_OPTIONS_SOUND:
\r
4345 plog("You may not do that right now.");
\r
4349 /* Toggle "arg_sound" */
\r
4350 arg_sound = !arg_sound;
\r
4352 /* React to changes */
\r
4353 Term_xtra_win_react();
\r
4355 /* Hack -- Force redraw */
\r
4356 Term_key_push(KTRL('R'));
\r
4362 case IDM_OPTIONS_BG:
\r
4367 plog("You may not do that right now.");
\r
4371 /* Toggle "use_bg" */
\r
4376 /* React to changes */
\r
4377 Term_xtra_win_react();
\r
4379 /* Hack -- Force redraw */
\r
4380 Term_key_push(KTRL('R'));
\r
4386 case IDM_OPTIONS_OPEN_BG:
\r
4391 plog("You may not do that right now.");
\r
4396 memset(&ofn, 0, sizeof(ofn));
\r
4397 ofn.lStructSize = sizeof(ofn);
\r
4398 ofn.hwndOwner = data[0].w;
\r
4399 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
\r
4400 ofn.nFilterIndex = 1;
\r
4401 ofn.lpstrFile = bg_bitmap_file;
\r
4402 ofn.nMaxFile = 1023;
\r
4403 ofn.lpstrInitialDir = NULL;
\r
4404 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
\r
4405 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
\r
4407 if (GetOpenFileName(&ofn))
\r
4409 /* Load 'savefile' */
\r
4414 /* React to changes */
\r
4415 Term_xtra_win_react();
\r
4417 /* Hack -- Force redraw */
\r
4418 Term_key_push(KTRL('R'));
\r
4423 case IDM_DUMP_SCREEN_HTML:
\r
4425 static char buf[1024] = "";
\r
4426 memset(&ofn, 0, sizeof(ofn));
\r
4427 ofn.lStructSize = sizeof(ofn);
\r
4428 ofn.hwndOwner = data[0].w;
\r
4429 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
\r
4430 ofn.nFilterIndex = 1;
\r
4431 ofn.lpstrFile = buf;
\r
4432 ofn.nMaxFile = 1023;
\r
4433 ofn.lpstrDefExt = "html";
\r
4434 ofn.lpstrInitialDir = NULL;
\r
4435 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
\r
4436 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
\r
4438 if (GetSaveFileName(&ofn))
\r
4440 do_cmd_save_screen_html_aux(buf, 0);
\r
4447 case IDM_OPTIONS_SAVER:
\r
4451 DestroyWindow(hwndSaver);
\r
4456 /* Create a screen scaver window */
\r
4457 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
\r
4458 "Angband Screensaver",
\r
4459 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
\r
4460 0, 0, GetSystemMetrics(SM_CXSCREEN),
\r
4461 GetSystemMetrics(SM_CYSCREEN),
\r
4462 NULL, NULL, hInstance, NULL);
\r
4466 /* Push the window to the bottom XXX XXX XXX */
\r
4467 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
4471 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
\r
4479 case IDM_OPTIONS_MAP:
\r
4485 case IDM_HELP_CONTENTS:
\r
4489 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
\r
4490 if (check_file(tmp))
\r
4492 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
\r
4497 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4498 plog("代わりにオンラインヘルプを使用してください。");
\r
4500 plog_fmt("Cannot find help file: %s", tmp);
\r
4501 plog("Use the online help files instead.");
\r
4506 #else /* HTML_HELP */
\r
4509 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
\r
4510 if (check_file(tmp))
\r
4512 sprintf(buf, "winhelp.exe %s", tmp);
\r
4513 WinExec(buf, SW_NORMAL);
\r
4518 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4519 plog("代わりにオンラインヘルプを使用してください。");
\r
4521 plog_fmt("Cannot find help file: %s", tmp);
\r
4522 plog("Use the online help files instead.");
\r
4527 #endif /* HTML_HELP */
\r
4533 static bool process_keydown(WPARAM wParam, LPARAM lParam)
\r
4540 /* Extract the modifiers */
\r
4541 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
\r
4542 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
\r
4543 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
\r
4545 Term_no_press = (ma) ? TRUE : FALSE;
\r
4547 /* Handle "special" keys */
\r
4548 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
\r
4550 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
\r
4551 bool numpad = FALSE;
\r
4553 /* Begin the macro trigger */
\r
4554 Term_keypress(31);
\r
4556 /* Send the modifiers */
\r
4557 if (mc) Term_keypress('C');
\r
4558 if (ms) Term_keypress('S');
\r
4559 if (ma) Term_keypress('A');
\r
4561 /* Extract "scan code" */
\r
4562 i = LOBYTE(HIWORD(lParam));
\r
4564 /* Introduce the scan code */
\r
4565 Term_keypress('x');
\r
4567 /* Extended key bit */
\r
4570 /* Numpad Enter and '/' are extended key */
\r
4572 Term_no_press = TRUE;
\r
4573 case VK_RETURN: /* Enter */
\r
4576 /* Other extended keys are on full keyboard */
\r
4590 case VK_SEPARATOR:
\r
4592 Term_no_press = TRUE;
\r
4596 case VK_PRIOR: /* Page Up */
\r
4597 case VK_NEXT: /* Page Down */
\r
4604 numpad = !ext_key;
\r
4607 /* Special modifiers for keypad keys */
\r
4608 if (numpad) Term_keypress('K');
\r
4610 /* Encode the hexidecimal scan code */
\r
4611 Term_keypress(hexsym[i/16]);
\r
4612 Term_keypress(hexsym[i%16]);
\r
4614 /* End the macro trigger */
\r
4615 Term_keypress(13);
\r
4625 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4626 WPARAM wParam, LPARAM lParam);
\r
4627 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4628 WPARAM wParam, LPARAM lParam)
\r
4629 #else /* __MWERKS__ */
\r
4630 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4631 WPARAM wParam, LPARAM lParam)
\r
4632 #endif /* __MWERKS__ */
\r
4638 MINMAXINFO FAR *lpmmi;
\r
4644 /* Acquire proper "term_data" info */
\r
4645 td = (term_data *)GetWindowLong(hWnd, 0);
\r
4647 /* Handle message */
\r
4653 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
4661 mop.dwCallback=(DWORD)hWnd;
\r
4666 case WM_GETMINMAXINFO:
\r
4668 MINMAXINFO FAR *lpmmi;
\r
4671 lpmmi = (MINMAXINFO FAR *)lParam;
\r
4673 /* this message was sent before WM_NCCREATE */
\r
4674 if (!td) return 1;
\r
4676 /* Minimum window size is 80x24 */
\r
4677 rc.left = rc.top = 0;
\r
4678 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
4679 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
4682 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
4684 /* Save minimum size */
\r
4685 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
4686 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
4693 BeginPaint(hWnd, &ps);
\r
4694 if (td) term_data_redraw(td);
\r
4695 EndPaint(hWnd, &ps);
\r
4696 ValidateRect(hWnd, NULL);
\r
4701 case MM_MCINOTIFY:
\r
4703 if(wParam == MCI_NOTIFY_SUCCESSFUL)
\r
4705 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
4706 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
4712 case WM_SYSKEYDOWN:
\r
4715 if (process_keydown(wParam, lParam))
\r
4722 if (Term_no_press) Term_no_press = FALSE;
\r
4723 else Term_keypress(wParam);
\r
4727 case WM_LBUTTONDOWN:
\r
4729 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4730 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4731 mouse_down = TRUE;
\r
4737 case WM_LBUTTONUP:
\r
4742 TERM_POSITION dx = abs(oldx - mousex) + 1;
\r
4743 TERM_POSITION dy = abs(oldy - mousey) + 1;
\r
4744 TERM_POSITION ox = (oldx > mousex) ? mousex : oldx;
\r
4745 TERM_POSITION oy = (oldy > mousey) ? mousey : oldy;
\r
4747 mouse_down = FALSE;
\r
4748 paint_rect = FALSE;
\r
4751 sz = (dx + 3) * dy;
\r
4753 sz = (dx + 2) * dy;
\r
4755 hGlobal = GlobalAlloc(GHND, sz + 1);
\r
4756 if (hGlobal == NULL) return 0;
\r
4757 lpStr = (LPSTR)GlobalLock(hGlobal);
\r
4759 for (i = 0; i < dy; i++)
\r
4763 char **scr = data[0].t.scr->c;
\r
4765 C_MAKE(s, (dx + 1), char);
\r
4766 strncpy(s, &scr[oy + i][ox], dx);
\r
4770 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
\r
4773 if (ox + dx < data[0].cols)
\r
4775 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
\r
4778 for (j = 0; j < dx; j++)
\r
4780 if (s[j] == 127) s[j] = '#';
\r
4784 for (j = 0; j < dx; j++)
\r
4786 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
\r
4796 GlobalUnlock(hGlobal);
\r
4797 if (OpenClipboard(hWnd) == 0)
\r
4799 GlobalFree(hGlobal);
\r
4803 SetClipboardData(CF_TEXT, hGlobal);
\r
4811 case WM_MOUSEMOVE:
\r
4816 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4817 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4822 dx = abs(oldx - mousex) + 1;
\r
4823 dy = abs(oldy - mousey) + 1;
\r
4824 ox = (oldx > mousex) ? mousex : oldx;
\r
4825 oy = (oldy > mousey) ? mousey : oldy;
\r
4826 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4830 paint_rect = TRUE;
\r
4833 dx = abs(cx - mousex) + 1;
\r
4834 dy = abs(cy - mousey) + 1;
\r
4835 ox = (cx > mousex) ? mousex : cx;
\r
4836 oy = (cy > mousey) ? mousey : cy;
\r
4837 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4853 if (game_in_progress && character_generated)
\r
4857 plog(_("今は終了できません。", "You may not do that right now."));
\r
4861 /* Hack -- Forget messages */
\r
4868 /* Save the game */
\r
4870 /* do_cmd_save_game(FALSE); */
\r
4871 #else /* ZANGBAND */
\r
4872 /* do_cmd_save_game(); */
\r
4873 #endif /* ZANGBAND */
\r
4874 Term_key_push(SPECIAL_KEY_QUIT);
\r
4881 case WM_QUERYENDSESSION:
\r
4883 if (game_in_progress && character_generated)
\r
4885 /* Hack -- Forget messages */
\r
4888 /* Mega-Hack -- Delay death */
\r
4889 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
\r
4890 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
\r
4892 /* Hardcode panic save */
\r
4893 p_ptr->panic_save = 1;
\r
4895 /* Forbid suspend */
\r
4896 signals_ignore_tstp();
\r
4898 /* Indicate panic save */
\r
4899 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
\r
4902 (void)save_player();
\r
4916 process_menus(LOWORD(wParam));
\r
4922 /* this message was sent before WM_NCCREATE */
\r
4923 if (!td) return 1;
\r
4925 /* it was sent from inside CreateWindowEx */
\r
4926 if (!td->w) return 1;
\r
4928 /* was sent from WM_SIZE */
\r
4929 if (td->size_hack) return 1;
\r
4933 case SIZE_MINIMIZED:
\r
4935 /* Hide sub-windows */
\r
4936 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4938 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
\r
4943 case SIZE_MAXIMIZED:
\r
4945 /* fall through XXX XXX XXX */
\r
4948 case SIZE_RESTORED:
\r
4950 TERM_POSITION cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
4951 TERM_POSITION rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
4954 if ((td->cols != cols) || (td->rows != rows))
\r
4956 /* Save the new size */
\r
4960 if (!IsZoomed(td->w) && !IsIconic(td->w))
\r
4962 normsize.x = td->cols;
\r
4963 normsize.y = td->rows;
\r
4967 Term_activate(&td->t);
\r
4969 /* Resize the term */
\r
4970 Term_resize(td->cols, td->rows);
\r
4972 /* Redraw later */
\r
4973 InvalidateRect(td->w, NULL, TRUE);
\r
4976 td->size_hack = TRUE;
\r
4978 /* Show sub-windows */
\r
4979 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4981 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
\r
4984 td->size_hack = FALSE;
\r
4992 case WM_PALETTECHANGED:
\r
4994 /* Ignore if palette change caused by itself */
\r
4995 if ((HWND)wParam == hWnd) return 0;
\r
4997 /* Fall through... */
\r
5000 case WM_QUERYNEWPALETTE:
\r
5002 if (!paletted) return 0;
\r
5004 hdc = GetDC(hWnd);
\r
5006 SelectPalette(hdc, hPal, FALSE);
\r
5008 i = RealizePalette(hdc);
\r
5010 /* if any palette entries changed, repaint the window. */
\r
5011 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5013 ReleaseDC(hWnd, hdc);
\r
5020 if (wParam && !HIWORD(lParam))
\r
5022 /* Do something to sub-windows */
\r
5023 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5025 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
\r
5028 /* Focus on main window */
\r
5037 case WM_ACTIVATEAPP:
\r
5039 if (IsIconic(td->w)) break;
\r
5041 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5043 if(data[i].visible)
\r
5045 if (wParam == TRUE)
\r
5047 ShowWindow(data[i].w, SW_SHOW);
\r
5051 ShowWindow(data[i].w, SW_HIDE);
\r
5058 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5063 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5064 WPARAM wParam, LPARAM lParam);
\r
5065 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5066 WPARAM wParam, LPARAM lParam)
\r
5067 #else /* __MWERKS__ */
\r
5068 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5069 WPARAM wParam, LPARAM lParam)
\r
5070 #endif /* __MWERKS__ */
\r
5074 MINMAXINFO FAR *lpmmi;
\r
5082 /* Acquire proper "term_data" info */
\r
5083 td = (term_data *)GetWindowLong(hWnd, 0);
\r
5085 /* Process message */
\r
5091 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
5101 case WM_GETMINMAXINFO:
\r
5103 MINMAXINFO FAR *lpmmi;
\r
5106 lpmmi = (MINMAXINFO FAR *)lParam;
\r
5108 /* this message was sent before WM_NCCREATE */
\r
5109 if (!td) return 1;
\r
5111 /* Minimum window size is 80x24 */
\r
5112 rc.left = rc.top = 0;
\r
5113 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
5114 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
5117 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
5119 /* Save minimum size */
\r
5120 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
5121 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
5128 TERM_POSITION cols;
\r
5129 TERM_POSITION rows;
\r
5131 /* this message was sent before WM_NCCREATE */
\r
5132 if (!td) return 1;
\r
5134 /* it was sent from inside CreateWindowEx */
\r
5135 if (!td->w) return 1;
\r
5137 /* was sent from inside WM_SIZE */
\r
5138 if (td->size_hack) return 1;
\r
5140 td->size_hack = TRUE;
\r
5142 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
5143 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
5146 if ((td->cols != cols) || (td->rows != rows))
\r
5148 /* Save old term */
\r
5149 term *old_term = Term;
\r
5151 /* Save the new size */
\r
5156 Term_activate(&td->t);
\r
5158 /* Resize the term */
\r
5159 Term_resize(td->cols, td->rows);
\r
5162 Term_activate(old_term);
\r
5164 /* Redraw later */
\r
5165 InvalidateRect(td->w, NULL, TRUE);
\r
5167 /* HACK - Redraw all windows */
\r
5168 p_ptr->window = 0xFFFFFFFF;
\r
5172 td->size_hack = FALSE;
\r
5179 BeginPaint(hWnd, &ps);
\r
5180 if (td) term_data_redraw(td);
\r
5181 EndPaint(hWnd, &ps);
\r
5185 case WM_SYSKEYDOWN:
\r
5188 if (process_keydown(wParam, lParam))
\r
5195 if (Term_no_press) Term_no_press = FALSE;
\r
5196 else Term_keypress(wParam);
\r
5200 case WM_PALETTECHANGED:
\r
5202 /* ignore if palette change caused by itself */
\r
5203 if ((HWND)wParam == hWnd) return FALSE;
\r
5204 /* otherwise, fall through!!! */
\r
5207 case WM_QUERYNEWPALETTE:
\r
5209 if (!paletted) return 0;
\r
5210 hdc = GetDC(hWnd);
\r
5211 SelectPalette(hdc, hPal, FALSE);
\r
5212 i = RealizePalette(hdc);
\r
5213 /* if any palette entries changed, repaint the window. */
\r
5214 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5215 ReleaseDC(hWnd, hdc);
\r
5219 case WM_NCLBUTTONDOWN:
\r
5223 if (wParam == HTCLOSE) wParam = HTSYSMENU;
\r
5224 #endif /* HTCLOSE */
\r
5226 if (wParam == HTSYSMENU)
\r
5230 td->visible = FALSE;
\r
5231 ShowWindow(td->w, SW_HIDE);
\r
5241 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5247 #define MOUSE_SENS 40
\r
5250 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5251 WPARAM wParam, LPARAM lParam);
\r
5252 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5253 WPARAM wParam, LPARAM lParam)
\r
5254 #else /* __MWERKS__ */
\r
5255 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5256 WPARAM wParam, LPARAM lParam)
\r
5257 #endif /* __MWERKS__ */
\r
5259 static int iMouse = 0;
\r
5260 static WORD xMouse = 0;
\r
5261 static WORD yMouse = 0;
\r
5275 case WM_SETCURSOR:
\r
5284 if (LOWORD(wParam) == WA_INACTIVE) break;
\r
5286 /* else fall through */
\r
5290 case WM_LBUTTONDOWN:
\r
5291 case WM_MBUTTONDOWN:
\r
5292 case WM_RBUTTONDOWN:
\r
5295 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5299 case WM_MOUSEMOVE:
\r
5303 dx = LOWORD(lParam) - xMouse;
\r
5304 dy = HIWORD(lParam) - yMouse;
\r
5306 if (dx < 0) dx = -dx;
\r
5307 if (dy < 0) dy = -dy;
\r
5309 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
\r
5311 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5315 /* Save last location */
\r
5317 xMouse = LOWORD(lParam);
\r
5318 yMouse = HIWORD(lParam);
\r
5325 DestroyWindow(hwndSaver);
\r
5332 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5335 #endif /* USE_SAVER */
\r
5341 /*** Temporary Hooks ***/
\r
5345 * Display warning message (see "z-util.c")
\r
5347 static void hack_plog(cptr str)
\r
5349 /* Give a warning */
\r
5353 MessageBox(NULL, str, "警告!",
\r
5354 MB_ICONEXCLAMATION | MB_OK);
\r
5356 MessageBox(NULL, str, "Warning",
\r
5357 MB_ICONEXCLAMATION | MB_OK);
\r
5365 * Display error message and quit (see "z-util.c")
\r
5367 static void hack_quit(cptr str)
\r
5369 /* Give a warning */
\r
5373 MessageBox(NULL, str, "エラー!",
\r
5374 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5376 MessageBox(NULL, str, "Error",
\r
5377 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5382 /* Unregister the classes */
\r
5383 UnregisterClass(AppName, hInstance);
\r
5385 /* Destroy the icon */
\r
5386 if (hIcon) DestroyIcon(hIcon);
\r
5394 /*** Various hooks ***/
\r
5398 * Display warning message (see "z-util.c")
\r
5400 static void hook_plog(cptr str)
\r
5406 MessageBox(data[0].w, str, "警告!",
\r
5407 MB_ICONEXCLAMATION | MB_OK);
\r
5409 MessageBox(data[0].w, str, "Warning",
\r
5410 MB_ICONEXCLAMATION | MB_OK);
\r
5418 * Display error message and quit (see "z-util.c")
\r
5420 static void hook_quit(cptr str)
\r
5425 /* Give a warning */
\r
5429 MessageBox(data[0].w, str, "エラー!",
\r
5430 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5432 MessageBox(data[0].w, str, "Error",
\r
5433 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5439 /* Save the preferences */
\r
5443 /*** Could use 'Term_nuke_win()' XXX XXX XXX */
\r
5445 /* Destroy all windows */
\r
5446 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
\r
5448 term_force_font(&data[i], NULL);
\r
5449 if (data[i].font_want) string_free(data[i].font_want);
\r
5450 if (data[i].w) DestroyWindow(data[i].w);
\r
5454 /* Free the bitmap stuff */
\r
5455 #ifdef USE_GRAPHICS
\r
5456 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
\r
5457 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
\r
5459 if (infMask.hPalette) DeleteObject(infMask.hPalette);
\r
5460 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
\r
5462 #endif /* USE_GRAPHICS */
\r
5464 /*** Free some other stuff ***/
\r
5466 DeleteObject(hbrYellow);
\r
5471 if (hPal) DeleteObject(hPal);
\r
5473 UnregisterClass(AppName, hInstance);
\r
5475 if (hIcon) DestroyIcon(hIcon);
\r
5482 /*** Initialize ***/
\r
5488 static void init_stuff(void)
\r
5495 /* Get program name with full path */
\r
5496 GetModuleFileName(hInstance, path, 512);
\r
5498 /* Save the "program name" XXX XXX XXX */
\r
5501 /* Get the name of the "*.ini" file */
\r
5502 strcpy(path + strlen(path) - 4, ".INI");
\r
5504 /* Save the the name of the ini-file */
\r
5505 ini_file = string_make(path);
\r
5507 /* Analyze the path */
\r
5510 /* Get the path */
\r
5511 for (; i > 0; i--)
\r
5513 if (path[i] == '\\')
\r
5520 /* Add "lib" to the path */
\r
5521 strcpy(path + i + 1, "lib\\");
\r
5523 /* Validate the path */
\r
5524 validate_dir(path, TRUE);
\r
5526 /* Init the file paths */
\r
5527 init_file_paths(path);
\r
5529 /* Hack -- Validate the paths */
\r
5530 validate_dir(ANGBAND_DIR_APEX, FALSE);
\r
5531 validate_dir(ANGBAND_DIR_BONE, FALSE);
\r
5533 /* Allow missing 'edit' directory */
\r
5534 if (!check_dir(ANGBAND_DIR_EDIT))
\r
5536 /* Must have 'data'! */
\r
5537 validate_dir(ANGBAND_DIR_DATA, TRUE);
\r
5541 /* Don't need 'data' */
\r
5542 validate_dir(ANGBAND_DIR_DATA, FALSE);
\r
5545 validate_dir(ANGBAND_DIR_FILE, TRUE);
\r
5546 validate_dir(ANGBAND_DIR_HELP, FALSE);
\r
5547 validate_dir(ANGBAND_DIR_INFO, FALSE);
\r
5548 validate_dir(ANGBAND_DIR_PREF, TRUE);
\r
5549 validate_dir(ANGBAND_DIR_SAVE, FALSE);
\r
5550 validate_dir(ANGBAND_DIR_USER, TRUE);
\r
5551 validate_dir(ANGBAND_DIR_XTRA, TRUE);
\r
5553 /* Build the filename */
\r
5554 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
\r
5556 /* Hack -- Validate the "news.txt" file */
\r
5557 validate_file(path);
\r
5560 #if 0 /* #ifndef JP */
\r
5561 /* Build the "font" path */
\r
5562 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
\r
5564 /* Allocate the path */
\r
5565 ANGBAND_DIR_XTRA_FONT = string_make(path);
\r
5567 /* Validate the "font" directory */
\r
5568 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
\r
5570 /* Build the filename */
\r
5571 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
5573 /* Hack -- Validate the basic font */
\r
5574 validate_file(path);
\r
5578 #ifdef USE_GRAPHICS
\r
5580 /* Build the "graf" path */
\r
5581 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
\r
5583 /* Allocate the path */
\r
5584 ANGBAND_DIR_XTRA_GRAF = string_make(path);
\r
5586 /* Validate the "graf" directory */
\r
5587 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
\r
5589 #endif /* USE_GRAPHICS */
\r
5594 /* Build the "sound" path */
\r
5595 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
\r
5597 /* Allocate the path */
\r
5598 ANGBAND_DIR_XTRA_SOUND = string_make(path);
\r
5600 /* Validate the "sound" directory */
\r
5601 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
\r
5603 #endif /* USE_SOUND */
\r
5607 /* Build the "music" path */
\r
5608 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
\r
5610 /* Allocate the path */
\r
5611 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
\r
5613 /* Validate the "music" directory */
\r
5614 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
\r
5616 #endif /* USE_MUSIC */
\r
5618 /* Build the "help" path */
\r
5619 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
\r
5621 /* Allocate the path */
\r
5622 ANGBAND_DIR_XTRA_HELP = string_make(path);
\r
5624 /* Validate the "help" directory */
\r
5625 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
\r
5628 static bool is_already_running(void)
\r
5630 bool result = FALSE;
\r
5633 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
\r
5634 if (GetLastError() == ERROR_ALREADY_EXISTS)
\r
5642 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
\r
5643 LPSTR lpCmdLine, int nCmdShow)
\r
5651 setlocale( LC_ALL, "ja_JP" );
\r
5656 /* Save globally */
\r
5657 hInstance = hInst;
\r
5660 /* Prevent multiple run */
\r
5661 if (is_already_running())
\r
5664 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
\r
5665 _("エラー!", "Error") ,
\r
5666 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5671 if (hPrevInst == NULL)
\r
5673 wc.style = CS_CLASSDC;
\r
5674 wc.lpfnWndProc = AngbandWndProc;
\r
5675 wc.cbClsExtra = 0;
\r
5676 wc.cbWndExtra = 4; /* one long pointer to term_data */
\r
5677 wc.hInstance = hInst;
\r
5678 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
\r
5679 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
\r
5680 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
\r
5681 wc.lpszMenuName = AppName;
\r
5682 wc.lpszClassName = AppName;
\r
5684 if (!RegisterClass(&wc)) exit(1);
\r
5686 wc.lpfnWndProc = AngbandListProc;
\r
5687 wc.lpszMenuName = NULL;
\r
5688 wc.lpszClassName = AngList;
\r
5690 if (!RegisterClass(&wc)) exit(2);
\r
5694 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
\r
5695 wc.lpfnWndProc = AngbandSaverProc;
\r
5696 wc.hCursor = NULL;
\r
5697 wc.lpszMenuName = NULL;
\r
5698 wc.lpszClassName = "WindowsScreenSaverClass";
\r
5700 if (!RegisterClass(&wc)) exit(3);
\r
5706 /* Temporary hooks */
\r
5707 plog_aux = hack_plog;
\r
5708 quit_aux = hack_quit;
\r
5709 core_aux = hack_quit;
\r
5711 /* Prepare the filepaths */
\r
5714 /* Initialize the keypress analyzer */
\r
5715 for (i = 0; special_key_list[i]; ++i)
\r
5717 special_key[special_key_list[i]] = TRUE;
\r
5719 /* Initialize the keypress analyzer */
\r
5720 for (i = 0; ignore_key_list[i]; ++i)
\r
5722 ignore_key[ignore_key_list[i]] = TRUE;
\r
5725 /* Determine if display is 16/256/true color */
\r
5726 hdc = GetDC(NULL);
\r
5727 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
\r
5728 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
\r
5729 ReleaseDC(NULL, hdc);
\r
5731 /* Initialize the colors */
\r
5732 for (i = 0; i < 256; i++)
\r
5736 /* Extract desired values */
\r
5737 rv = angband_color_table[i][1];
\r
5738 gv = angband_color_table[i][2];
\r
5739 bv = angband_color_table[i][3];
\r
5741 /* Extract the "complex" code */
\r
5742 win_clr[i] = PALETTERGB(rv, gv, bv);
\r
5744 /* Save the "simple" code */
\r
5745 angband_color_table[i][0] = win_pal[i];
\r
5748 /* Prepare the windows */
\r
5754 /* Activate hooks */
\r
5755 plog_aux = hook_plog;
\r
5756 quit_aux = hook_quit;
\r
5757 core_aux = hook_quit;
\r
5759 /* Set the system suffix */
\r
5760 ANGBAND_SYS = "win";
\r
5762 /* Set the keyboard suffix */
\r
5763 if (7 != GetKeyboardType(0))
\r
5764 ANGBAND_KEYBOARD = "0";
\r
5767 /* Japanese keyboard */
\r
5768 switch (GetKeyboardType(1))
\r
5770 case 0x0D01: case 0x0D02:
\r
5771 case 0x0D03: case 0x0D04:
\r
5772 case 0x0D05: case 0x0D06:
\r
5774 ANGBAND_KEYBOARD = "NEC98";
\r
5778 ANGBAND_KEYBOARD = "JAPAN";
\r
5782 /* Catch nasty signals */
\r
5786 Term_activate(term_screen);
\r
5789 /* We are now initialized */
\r
5790 initialized = TRUE;
\r
5792 if(lpCmdLine[0] == '-'){
\r
5793 switch(lpCmdLine[1])
\r
5798 if (!lpCmdLine[2]) break;
\r
5799 chuukei_server = TRUE;
\r
5800 if(connect_chuukei_server(&lpCmdLine[2])<0){
\r
5801 msg_print("connect fail");
\r
5804 msg_print("connect");
\r
5812 if (!lpCmdLine[2]) break;
\r
5813 chuukei_client = TRUE;
\r
5814 connect_chuukei_server(&lpCmdLine[2]);
\r
5822 if (!lpCmdLine[2]) break;
\r
5823 prepare_browse_movie(&lpCmdLine[2]);
\r
5833 /* Did the user double click on a save file? */
\r
5834 if(!chuukei_server) check_for_save_file(lpCmdLine);
\r
5836 /* Did the user double click on a save file? */
\r
5837 check_for_save_file(lpCmdLine);
\r
5840 /* Prompt the user */
\r
5841 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
\r
5845 /* Process messages forever */
\r
5846 while (GetMessage(&msg, NULL, 0, 0))
\r
5848 TranslateMessage(&msg);
\r
5849 DispatchMessage(&msg);
\r
5860 #endif /* WINDOWS */
\r