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 uint rows; /* int -> uint */
\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 int mousex = 0, mousey = 0;
\r
609 static int 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 static void delete_bg(void)
\r
771 static int init_bg(void)
\r
773 char * bmfile = bg_bitmap_file;
\r
776 if (use_bg == 0) return 0;
\r
778 hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
\r
780 plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
\r
785 HDC wnddc, dcimage, dcbg;
\r
786 HBITMAP bmimage, bmimage_old, bmbg_old;
\r
791 wnddc = GetDC(hwnd);
\r
792 dcimage = CreateCompatibleDC(wnddc);
\r
793 dcbg = CreateCompatibleDC(wnddc);
\r
795 bmimage = LoadImage(NULL, "bg.bmp", LR_LOADFROMFILE, 0, 0, 0);
\r
796 if (!bmimage) quit("bg.bmpが読みこめない!");
\r
797 bmimage_old = SelectObject(dcimage, bmimage);
\r
799 CreateCompatibleBitmap();
\r
801 ReleaseDC(hwnd, wnddc);
\r
807 static void DrawBG(HDC hdc, RECT *r)
\r
812 int x = r->left, y = r->top;
\r
813 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
\r
815 if (!use_bg || !hBG)
\r
819 GetObject(hBG, sizeof(bm), &bm);
\r
820 swid = bm.bmWidth; shgt = bm.bmHeight;
\r
822 hdcSrc = CreateCompatibleDC(hdc);
\r
823 hOld = SelectObject(hdcSrc, hBG);
\r
827 cwid = MIN(swid - sx, r->right - nx);
\r
830 chgt = MIN(shgt - sy, r->bottom - ny);
\r
831 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
\r
833 } while (ny < r->bottom);
\r
836 } while (nx < r->right);
\r
838 SelectObject(hdcSrc, hOld);
\r
844 * Hack -- given a pathname, point at the filename
\r
846 static cptr extract_file_name(cptr s)
\r
850 /* Start at the end */
\r
851 p = s + strlen(s) - 1;
\r
853 /* Back up to divider */
\r
854 while ((p >= s) && (*p != ':') && (*p != '\\')) p--;
\r
856 /* Return file name */
\r
863 * Hack -- given a simple filename, extract the "font size" info
\r
865 * Return a pointer to a static buffer holding the capitalized base name.
\r
867 #if 0 /* #ifndef JP */
\r
868 static char *analyze_font(char *path, int *wp, int *hp)
\r
874 /* Start at the end */
\r
875 p = path + strlen(path) - 1;
\r
877 /* Back up to divider */
\r
878 while ((p >= path) && (*p != ':') && (*p != '\\')) --p;
\r
880 /* Advance to file name */
\r
884 for (s = p; *s; ++s)
\r
886 /* Capitalize (be paranoid) */
\r
887 if (islower(*s)) *s = toupper(*s);
\r
890 /* Find first 'X' */
\r
891 s = my_strchr(p, 'X');
\r
893 /* Extract font width */
\r
896 /* Extract height */
\r
897 hgt = s ? atoi(s+1) : 0;
\r
910 * Check for existance of a file
\r
912 static bool check_file(cptr s)
\r
922 unsigned int attrib;
\r
932 attrib = GetFileAttributes(path);
\r
934 /* Require valid filename */
\r
935 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
937 /* Prohibit directory */
\r
938 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return (FALSE);
\r
942 /* Examine and verify */
\r
943 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
945 /* Prohibit something */
\r
946 if (attrib & FA_LABEL) return (FALSE);
\r
948 /* Prohibit directory */
\r
949 if (attrib & FA_DIREC) return (FALSE);
\r
959 * Check for existance of a directory
\r
961 static bool check_dir(cptr s)
\r
973 unsigned int attrib;
\r
983 /* Remove trailing backslash */
\r
984 if (i && (path[i-1] == '\\')) path[--i] = '\0';
\r
989 attrib = GetFileAttributes(path);
\r
991 /* Require valid filename */
\r
992 if (attrib == INVALID_FILE_NAME) return (FALSE);
\r
994 /* Require directory */
\r
995 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE);
\r
999 /* Examine and verify */
\r
1000 if (_dos_getfileattr(path, &attrib)) return (FALSE);
\r
1002 /* Prohibit something */
\r
1003 if (attrib & FA_LABEL) return (FALSE);
\r
1005 /* Require directory */
\r
1006 if (!(attrib & FA_DIREC)) return (FALSE);
\r
1008 #endif /* WIN32 */
\r
1018 static void validate_file(cptr s)
\r
1020 /* Verify or fail */
\r
1021 if (!check_file(s))
\r
1023 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
\r
1029 * Validate a directory
\r
1031 static void validate_dir(cptr s, bool vital)
\r
1033 /* Verify or fail */
\r
1034 if (!check_dir(s))
\r
1036 /* This directory contains needed data */
\r
1039 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
\r
1041 /* Attempt to create this directory */
\r
1042 else if (mkdir(s))
\r
1044 quit_fmt("Unable to create directory:\n%s", s);
\r
1051 * Get the "size" for a window
\r
1053 static void term_getsize(term_data *td)
\r
1060 if (td->cols < 1) td->cols = 1;
\r
1061 if (td->rows < 1) td->rows = 1;
\r
1063 /* Window sizes */
\r
1064 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
1065 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
\r
1067 /* Fake window size */
\r
1069 rc.right = rc.left + wid;
\r
1071 rc.bottom = rc.top + hgt;
\r
1074 /* rc.right += 1; */
\r
1075 /* rc.bottom += 1; */
\r
1078 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
1081 td->size_wid = rc.right - rc.left;
\r
1082 td->size_hgt = rc.bottom - rc.top;
\r
1084 /* See CreateWindowEx */
\r
1085 if (!td->w) return;
\r
1087 /* Extract actual location */
\r
1088 GetWindowRect(td->w, &rc);
\r
1090 /* Save the location */
\r
1091 td->pos_x = rc.left;
\r
1092 td->pos_y = rc.top;
\r
1097 * Write the "prefs" for a single term
\r
1099 static void save_prefs_aux(int i)
\r
1101 term_data *td = &data[i];
\r
1102 char sec_name[128];
\r
1106 WINDOWPLACEMENT lpwndpl;
\r
1109 if (!td->w) return;
\r
1111 /* Make section name */
\r
1112 sprintf(sec_name, "Term-%d", i);
\r
1117 strcpy(buf, td->visible ? "1" : "0");
\r
1118 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
\r
1123 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "MS ゴシック");
\r
1126 strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
\r
1128 strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "Courier");
\r
1132 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
\r
1134 #if 1 /* #ifdef JP */
\r
1135 wsprintf(buf, "%d", td->lf.lfWidth);
\r
1136 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
\r
1137 wsprintf(buf, "%d", td->lf.lfHeight);
\r
1138 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
\r
1139 wsprintf(buf, "%d", td->lf.lfWeight);
\r
1140 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
\r
1143 strcpy(buf, td->bizarre ? "1" : "0");
\r
1144 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
\r
1146 /* Tile size (x) */
\r
1147 wsprintf(buf, "%d", td->tile_wid);
\r
1148 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
\r
1150 /* Tile size (y) */
\r
1151 wsprintf(buf, "%d", td->tile_hgt);
\r
1152 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
\r
1154 /* Get window placement and dimensions */
\r
1155 lpwndpl.length = sizeof(WINDOWPLACEMENT);
\r
1156 GetWindowPlacement(td->w, &lpwndpl);
\r
1158 /* Acquire position in *normal* mode (not minimized) */
\r
1159 rc = lpwndpl.rcNormalPosition;
\r
1161 /* Window size (x) */
\r
1162 if (i == 0) wsprintf(buf, "%d", normsize.x);
\r
1163 else wsprintf(buf, "%d", td->cols);
\r
1164 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
\r
1166 /* Window size (y) */
\r
1167 if (i == 0) wsprintf(buf, "%d", normsize.y);
\r
1168 else wsprintf(buf, "%d", td->rows);
\r
1169 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
\r
1171 /* Maxmized (only main window) */
\r
1174 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
\r
1175 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
\r
1178 /* Acquire position */
\r
1179 GetWindowRect(td->w, &rc);
\r
1181 /* Window position (x) */
\r
1182 wsprintf(buf, "%d", rc.left);
\r
1183 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
\r
1185 /* Window position (y) */
\r
1186 wsprintf(buf, "%d", rc.top);
\r
1187 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
\r
1189 /* Window Z position */
\r
1192 strcpy(buf, td->posfix ? "1" : "0");
\r
1193 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
\r
1199 * Write the "prefs"
\r
1201 * We assume that the windows have all been initialized
\r
1203 static void save_prefs(void)
\r
1209 /* Save the "arg_graphics" flag */
\r
1210 sprintf(buf, "%d", arg_graphics);
\r
1211 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
\r
1213 /* Save the "arg_bigtile" flag */
\r
1214 strcpy(buf, arg_bigtile ? "1" : "0");
\r
1215 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
\r
1217 /* Save the "arg_sound" flag */
\r
1218 strcpy(buf, arg_sound ? "1" : "0");
\r
1219 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
\r
1221 /* Save the "arg_sound" flag */
\r
1222 strcpy(buf, arg_music ? "1" : "0");
\r
1223 WritePrivateProfileString("Angband", "Music", buf, ini_file);
\r
1226 strcpy(buf, use_bg ? "1" : "0");
\r
1227 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
\r
1228 WritePrivateProfileString("Angband", "BackGroundBitmap",
\r
1229 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
\r
1231 /* Save window prefs */
\r
1232 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1234 save_prefs_aux(i);
\r
1240 * Load the "prefs" for a single term
\r
1242 static void load_prefs_aux(int i)
\r
1244 term_data *td = &data[i];
\r
1245 char sec_name[128];
\r
1248 int wid, hgt, posx, posy;
\r
1249 int dispx = GetSystemMetrics( SM_CXVIRTUALSCREEN);
\r
1250 int dispy = GetSystemMetrics( SM_CYVIRTUALSCREEN);
\r
1254 /* Make section name */
\r
1255 sprintf(sec_name, "Term-%d", i);
\r
1257 /* Make section name */
\r
1258 sprintf(sec_name, "Term-%d", i);
\r
1263 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
\r
1266 /* Desired font, with default */
\r
1268 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
\r
1271 GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
\r
1273 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
\r
1279 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
\r
1281 /* Analyze font, save desired font name */
\r
1282 #if 1 /* #ifdef JP */
\r
1283 td->font_want = string_make(tmp);
\r
1284 hgt = 15; wid = 0;
\r
1285 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
\r
1286 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
\r
1287 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
\r
1289 td->font_want = string_make(analyze_font(tmp, &wid, &hgt));
\r
1294 #if 1 /* #ifdef JP */
\r
1295 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
\r
1296 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
\r
1298 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", wid, ini_file);
\r
1299 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", hgt, ini_file);
\r
1304 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
\r
1305 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
\r
1306 normsize.x = td->cols; normsize.y = td->rows;
\r
1311 win_maximized = GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file);
\r
1314 /* Window position */
\r
1315 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
\r
1316 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
\r
1317 td->pos_x = MIN(MAX(0, posx), dispx-128);
\r
1318 td->pos_y = MIN(MAX(0, posy), dispy-128);
\r
1320 /* Window Z position */
\r
1323 td->posfix = GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file);
\r
1329 * Load the "prefs"
\r
1331 static void load_prefs(void)
\r
1335 /* Extract the "arg_graphics" flag */
\r
1336 arg_graphics = GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
\r
1338 /* Extract the "arg_bigtile" flag */
\r
1339 arg_bigtile = GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file);
\r
1340 use_bigtile = arg_bigtile;
\r
1342 /* Extract the "arg_sound" flag */
\r
1343 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
\r
1345 /* Extract the "arg_sound" flag */
\r
1346 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
\r
1349 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
\r
1350 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
\r
1352 /* Load window prefs */
\r
1353 for (i = 0; i < MAX_TERM_DATA; ++i)
\r
1355 load_prefs_aux(i);
\r
1359 #if defined(USE_SOUND) || defined(USE_MUSIC)
\r
1362 * XXX XXX XXX - Taken from files.c.
\r
1364 * Extract "tokens" from a buffer
\r
1366 * This function uses "whitespace" as delimiters, and treats any amount of
\r
1367 * whitespace as a single delimiter. We will never return any empty tokens.
\r
1368 * When given an empty buffer, or a buffer containing only "whitespace", we
\r
1369 * will return no tokens. We will never extract more than "num" tokens.
\r
1371 * By running a token through the "text_to_ascii()" function, you can allow
\r
1372 * that token to include (encoded) whitespace, using "\s" to encode spaces.
\r
1374 * We save pointers to the tokens in "tokens", and return the number found.
\r
1376 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
\r
1388 /* Skip leading whitespace */
\r
1389 for ( ; *s && iswspace(*s); ++s) /* loop */;
\r
1394 /* Find next whitespace, if any */
\r
1395 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
\r
1397 /* Nuke and advance (if necessary) */
\r
1398 if (*t) *t++ = '\0';
\r
1400 /* Save the token */
\r
1411 #endif /* USE_SOUND || USE_MUSIC */
\r
1415 static void load_sound_prefs(void)
\r
1419 char ini_path[1024];
\r
1420 char wav_path[1024];
\r
1421 char *zz[SAMPLE_MAX];
\r
1423 /* Access the sound.cfg */
\r
1425 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
\r
1427 for (i = 0; i < SOUND_MAX; i++)
\r
1429 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
\r
1431 num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
\r
1433 for (j = 0; j < num; j++)
\r
1435 /* Access the sound */
\r
1436 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
\r
1438 /* Save the sound filename, if it exists */
\r
1439 if (check_file(wav_path))
\r
1440 sound_file[i][j] = string_make(zz[j]);
\r
1445 #endif /* USE_SOUND */
\r
1449 static void load_music_prefs(void)
\r
1453 char ini_path[1024];
\r
1454 char wav_path[1024];
\r
1455 char *zz[SAMPLE_MAX];
\r
1458 /* Access the music.cfg */
\r
1460 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
\r
1462 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
\r
1464 for (i = 0; i < MUSIC_BASIC_MAX; i++)
\r
1466 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
\r
1468 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1470 for (j = 0; j < num; j++)
\r
1472 /* Access the sound */
\r
1473 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1475 /* Save the sound filename, if it exists */
\r
1476 if (check_file(wav_path))
\r
1477 music_file[i][j] = string_make(zz[j]);
\r
1481 for (i = 0; i < max_d_idx; i++)
\r
1483 sprintf(key, "dungeon%03d", i);
\r
1484 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
\r
1486 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1488 for (j = 0; j < num; j++)
\r
1490 /* Access the sound */
\r
1491 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1493 /* Save the sound filename, if it exists */
\r
1494 if (check_file(wav_path))
\r
1495 dungeon_music_file[i][j] = string_make(zz[j]);
\r
1499 for (i = 0; i < 1000; i++) /*!< @todo クエスト最大数指定 */
\r
1501 sprintf(key, "quest%03d", i);
\r
1502 GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
\r
1504 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1506 for (j = 0; j < num; j++)
\r
1508 /* Access the sound */
\r
1509 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1511 /* Save the sound filename, if it exists */
\r
1512 if (check_file(wav_path))
\r
1513 quest_music_file[i][j] = string_make(zz[j]);
\r
1517 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
\r
1519 sprintf(key, "town%03d", i);
\r
1520 GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
\r
1522 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
\r
1524 for (j = 0; j < num; j++)
\r
1526 /* Access the sound */
\r
1527 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
\r
1529 /* Save the sound filename, if it exists */
\r
1530 if (check_file(wav_path))
\r
1531 town_music_file[i][j] = string_make(zz[j]);
\r
1538 #endif /* USE_MUSIC */
\r
1541 * Create the new global palette based on the bitmap palette
\r
1542 * (if any), and the standard 16 entry palette derived from
\r
1543 * "win_clr[]" which is used for the basic 16 Angband colors.
\r
1545 * This function is never called before all windows are ready.
\r
1547 * This function returns FALSE if the new palette could not be
\r
1548 * prepared, which should normally be a fatal error. XXX XXX
\r
1550 * Note that only some machines actually use a "palette".
\r
1552 static int new_palette(void)
\r
1560 LPLOGPALETTE pLogPal;
\r
1561 LPPALETTEENTRY lppe;
\r
1566 /* This makes no sense */
\r
1567 if (!paletted) return (TRUE);
\r
1575 #ifdef USE_GRAPHICS
\r
1577 /* Check the bitmap palette */
\r
1578 hBmPal = infGraph.hPalette;
\r
1580 /* Use the bitmap */
\r
1583 lppeSize = 256 * sizeof(PALETTEENTRY);
\r
1584 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
\r
1585 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
\r
1586 if ((nEntries == 0) || (nEntries > 220))
\r
1588 /* Warn the user */
\r
1589 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
\r
1592 rnfree(lppe, lppeSize);
\r
1599 #endif /* USE_GRAPHICS */
\r
1601 /* Size of palette */
\r
1602 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
\r
1604 /* Allocate palette */
\r
1605 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
\r
1608 pLogPal->palVersion = 0x300;
\r
1610 /* Make room for bitmap and normal data */
\r
1611 pLogPal->palNumEntries = nEntries + 16;
\r
1613 /* Save the bitmap data */
\r
1614 for (i = 0; i < nEntries; i++)
\r
1616 pLogPal->palPalEntry[i] = lppe[i];
\r
1619 /* Save the normal data */
\r
1620 for (i = 0; i < 16; i++)
\r
1624 /* Access the entry */
\r
1625 p = &(pLogPal->palPalEntry[i+nEntries]);
\r
1627 /* Save the colors */
\r
1628 p->peRed = GetRValue(win_clr[i]);
\r
1629 p->peGreen = GetGValue(win_clr[i]);
\r
1630 p->peBlue = GetBValue(win_clr[i]);
\r
1632 /* Save the flags */
\r
1633 p->peFlags = PC_NOCOLLAPSE;
\r
1636 /* Free something */
\r
1637 if (lppe) rnfree(lppe, lppeSize);
\r
1639 /* Create a new palette, or fail */
\r
1640 hNewPal = CreatePalette(pLogPal);
\r
1641 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
\r
1643 /* Free the palette */
\r
1644 rnfree(pLogPal, pLogPalSize);
\r
1649 /* Realize the palette */
\r
1650 hdc = GetDC(td->w);
\r
1651 SelectPalette(hdc, hNewPal, 0);
\r
1652 i = RealizePalette(hdc);
\r
1653 ReleaseDC(td->w, hdc);
\r
1654 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
\r
1658 for (i = 1; i < MAX_TERM_DATA; i++)
\r
1662 hdc = GetDC(td->w);
\r
1663 SelectPalette(hdc, hNewPal, 0);
\r
1664 ReleaseDC(td->w, hdc);
\r
1667 /* Delete old palette */
\r
1668 if (hPal) DeleteObject(hPal);
\r
1670 /* Save new palette */
\r
1678 #ifdef USE_GRAPHICS
\r
1680 * Initialize graphics
\r
1682 static bool init_graphics(void)
\r
1684 /* Initialize once */
\r
1685 /* if (can_use_graphics != arg_graphics) */
\r
1688 int wid, hgt, twid, thgt, ox, oy;
\r
1691 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1699 name = "16X16.BMP";
\r
1701 ANGBAND_GRAF = "new";
\r
1703 else if (arg_graphics == GRAPHICS_HENGBAND)
\r
1712 name = "64X64.BMP";
\r
1721 name = "32X32.BMP";
\r
1723 ANGBAND_GRAF = "ne2";
\r
1734 ANGBAND_GRAF = "old";
\r
1737 /* Access the bitmap file */
\r
1738 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
\r
1740 /* Load the bitmap or quit */
\r
1741 if (!ReadDIB(data[0].w, buf, &infGraph))
\r
1743 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
\r
1747 /* Save the new sizes */
\r
1748 infGraph.CellWidth = wid;
\r
1749 infGraph.CellHeight = hgt;
\r
1750 infGraph.TileWidth = twid;
\r
1751 infGraph.TileHeight = thgt;
\r
1752 infGraph.OffsetX = ox;
\r
1753 infGraph.OffsetY = oy;
\r
1755 if (arg_graphics == GRAPHICS_ADAM_BOLT)
\r
1757 /* Access the mask file */
\r
1758 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
\r
1760 /* Load the bitmap or quit */
\r
1761 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1763 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1767 if (arg_graphics == GRAPHICS_HENGBAND)
\r
1769 /* Access the mask file */
\r
1770 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
\r
1772 /* Load the bitmap or quit */
\r
1773 if (!ReadDIB(data[0].w, buf, &infMask))
\r
1775 plog_fmt("Cannot read bitmap file '%s'", buf);
\r
1780 /* Activate a palette */
\r
1781 if (!new_palette())
\r
1783 /* Free bitmap XXX XXX XXX */
\r
1786 plog(_("パレットを実現できません!", "Cannot activate palette!"));
\r
1790 /* Graphics available */
\r
1791 can_use_graphics = arg_graphics;
\r
1795 return (can_use_graphics);
\r
1797 #endif /* USE_GRAPHICS */
\r
1802 * Initialize music
\r
1804 static bool init_music(void)
\r
1806 /* Initialize once */
\r
1807 if (!can_use_music)
\r
1809 /* Load the prefs */
\r
1810 load_music_prefs();
\r
1812 /* Sound available */
\r
1813 can_use_music = TRUE;
\r
1817 return (can_use_music);
\r
1821 * Hack -- Stop a music
\r
1823 static void stop_music(void)
\r
1825 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
1826 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
1829 #endif /* USE_MUSIC */
\r
1833 * Initialize sound
\r
1835 static bool init_sound(void)
\r
1837 /* Initialize once */
\r
1838 if (!can_use_sound)
\r
1840 /* Load the prefs */
\r
1841 load_sound_prefs();
\r
1843 /* Sound available */
\r
1844 can_use_sound = TRUE;
\r
1848 return (can_use_sound);
\r
1850 #endif /* USE_SOUND */
\r
1856 static void term_window_resize(term_data *td)
\r
1858 /* Require window */
\r
1859 if (!td->w) return;
\r
1861 /* Resize the window */
\r
1862 SetWindowPos(td->w, 0, 0, 0,
\r
1863 td->size_wid, td->size_hgt,
\r
1864 SWP_NOMOVE | SWP_NOZORDER);
\r
1866 /* Redraw later */
\r
1867 InvalidateRect(td->w, NULL, TRUE);
\r
1872 * Force the use of a new "font file" for a term_data
\r
1874 * This function may be called before the "window" is ready
\r
1876 * This function returns zero only if everything succeeds.
\r
1878 * Note that the "font name" must be capitalized!!!
\r
1880 static errr term_force_font(term_data *td, cptr path)
\r
1884 #if 0 /* #ifndef JP */
\r
1890 /* Forget the old font (if needed) */
\r
1891 if (td->font_id) DeleteObject(td->font_id);
\r
1893 #if 1 /* #ifdef JP */
\r
1897 /* Create the font (using the 'base' of the font file name!) */
\r
1898 td->font_id = CreateFontIndirect(&(td->lf));
\r
1899 wid = td->lf.lfWidth;
\r
1900 hgt = td->lf.lfHeight;
\r
1901 if (!td->font_id) return (1);
\r
1903 /* Forget old font */
\r
1904 if (td->font_file)
\r
1906 bool used = FALSE;
\r
1908 /* Scan windows */
\r
1909 for (i = 0; i < MAX_TERM_DATA; i++)
\r
1911 /* Don't check when closing the application */
\r
1914 /* Check "screen" */
\r
1915 if ((td != &data[i]) &&
\r
1916 (data[i].font_file) &&
\r
1917 (streq(data[i].font_file, td->font_file)))
\r
1923 /* Remove unused font resources */
\r
1924 if (!used) RemoveFontResource(td->font_file);
\r
1926 /* Free the old name */
\r
1927 string_free(td->font_file);
\r
1930 td->font_file = NULL;
\r
1933 /* No path given */
\r
1934 if (!path) return (1);
\r
1937 strcpy(buf, path);
\r
1939 /* Analyze font path */
\r
1940 base = analyze_font(buf, &wid, &hgt);
\r
1942 /* Verify suffix */
\r
1943 if (!suffix(base, ".FON")) return (1);
\r
1946 if (!check_file(buf)) return (1);
\r
1948 /* Load the new font */
\r
1949 if (!AddFontResource(buf)) return (1);
\r
1951 /* Save new font name */
\r
1952 td->font_file = string_make(base);
\r
1954 /* Remove the "suffix" */
\r
1955 base[strlen(base)-4] = '\0';
\r
1957 /* Create the font (using the 'base' of the font file name!) */
\r
1958 td->font_id = CreateFont(hgt, wid, 0, 0, FW_DONTCARE, 0, 0, 0,
\r
1959 ANSI_CHARSET, OUT_DEFAULT_PRECIS,
\r
1960 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
\r
1961 FIXED_PITCH | FF_DONTCARE, base);
\r
1964 /* Hack -- Unknown size */
\r
1971 /* all this trouble to get the cell size */
\r
1972 hdcDesktop = GetDC(HWND_DESKTOP);
\r
1973 hfOld = SelectObject(hdcDesktop, td->font_id);
\r
1974 GetTextMetrics(hdcDesktop, &tm);
\r
1975 SelectObject(hdcDesktop, hfOld);
\r
1976 ReleaseDC(HWND_DESKTOP, hdcDesktop);
\r
1978 /* Font size info */
\r
1979 wid = tm.tmAveCharWidth;
\r
1980 hgt = tm.tmHeight;
\r
1983 /* Save the size info */
\r
1984 td->font_wid = wid;
\r
1985 td->font_hgt = hgt;
\r
1994 * Allow the user to change the font for this window.
\r
1996 static void term_change_font(term_data *td)
\r
1998 #if 1 /* #ifdef JP */
\r
2001 memset(&cf, 0, sizeof(cf));
\r
2002 cf.lStructSize = sizeof(cf);
\r
2003 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
\r
2004 cf.lpLogFont = &(td->lf);
\r
2006 if (ChooseFont(&cf))
\r
2008 /* Force the font */
\r
2009 term_force_font(td, NULL);
\r
2011 /* Assume not bizarre */
\r
2012 td->bizarre = TRUE;
\r
2014 /* Reset the tile info */
\r
2015 td->tile_wid = td->font_wid;
\r
2016 td->tile_hgt = td->font_hgt;
\r
2018 /* Analyze the font */
\r
2021 /* Resize the window */
\r
2022 term_window_resize(td);
\r
2028 char tmp[1024] = "";
\r
2030 /* Extract a default if possible */
\r
2031 if (td->font_file) strcpy(tmp, td->font_file);
\r
2033 /* Ask for a choice */
\r
2034 memset(&ofn, 0, sizeof(ofn));
\r
2035 ofn.lStructSize = sizeof(ofn);
\r
2036 ofn.hwndOwner = data[0].w;
\r
2037 ofn.lpstrFilter = "Angband Font Files (*.fon)\0*.fon\0";
\r
2038 ofn.nFilterIndex = 1;
\r
2039 ofn.lpstrFile = tmp;
\r
2040 ofn.nMaxFile = 128;
\r
2041 ofn.lpstrInitialDir = ANGBAND_DIR_XTRA_FONT;
\r
2042 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
2043 ofn.lpstrDefExt = "fon";
\r
2045 /* Force choice if legal */
\r
2046 if (GetOpenFileName(&ofn))
\r
2048 /* Force the font */
\r
2049 if (term_force_font(td, tmp))
\r
2051 /* Access the standard font file */
\r
2052 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
2054 /* Force the use of that font */
\r
2055 (void)term_force_font(td, tmp);
\r
2058 /* Assume not bizarre */
\r
2059 td->bizarre = FALSE;
\r
2061 /* Reset the tile info */
\r
2062 td->tile_wid = td->font_wid;
\r
2063 td->tile_hgt = td->font_hgt;
\r
2065 /* Analyze the font */
\r
2068 /* Resize the window */
\r
2069 term_window_resize(td);
\r
2076 * Allow the user to lock this window.
\r
2078 static void term_window_pos(term_data *td, HWND hWnd)
\r
2080 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
\r
2081 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
\r
2084 static void windows_map(void);
\r
2087 * Hack -- redraw a term_data
\r
2089 static void term_data_redraw(term_data *td)
\r
2091 if (td->map_active)
\r
2093 /* Redraw the map */
\r
2098 /* Activate the term */
\r
2099 Term_activate(&td->t);
\r
2101 /* Redraw the contents */
\r
2104 /* Restore the term */
\r
2105 Term_activate(term_screen);
\r
2110 void Term_inversed_area(HWND hWnd, int x, int y, int w, int h)
\r
2114 HBRUSH myBrush, oldBrush;
\r
2116 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
\r
2117 int tx = td->size_ow1 + x * td->tile_wid;
\r
2118 int ty = td->size_oh1 + y * td->tile_hgt;
\r
2119 int tw = w * td->tile_wid - 1;
\r
2120 int th = h * td->tile_hgt - 1;
\r
2122 hdc = GetDC(hWnd);
\r
2123 myBrush = CreateSolidBrush(RGB(255, 255, 255));
\r
2124 oldBrush = SelectObject(hdc, myBrush);
\r
2125 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2127 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
\r
2129 SelectObject(hdc, oldBrush);
\r
2130 SelectObject(hdc, oldPen);
\r
2135 /*** Function hooks needed by "Term" ***/
\r
2141 * Initialize a new Term
\r
2143 static void Term_init_win(term *t)
\r
2150 * Nuke an old Term
\r
2152 static void Term_nuke_win(term *t)
\r
2161 * Interact with the User
\r
2163 static errr Term_user_win(int n)
\r
2174 * React to global changes
\r
2176 static errr Term_xtra_win_react(void)
\r
2181 /* Simple color */
\r
2184 /* Save the default colors */
\r
2185 for (i = 0; i < 256; i++)
\r
2187 /* Simply accept the desired colors */
\r
2188 win_pal[i] = angband_color_table[i][0];
\r
2192 /* Complex color */
\r
2199 bool change = FALSE;
\r
2201 /* Save the default colors */
\r
2202 for (i = 0; i < 256; i++)
\r
2204 /* Extract desired values */
\r
2205 rv = angband_color_table[i][1];
\r
2206 gv = angband_color_table[i][2];
\r
2207 bv = angband_color_table[i][3];
\r
2209 /* Extract a full color code */
\r
2210 code = PALETTERGB(rv, gv, bv);
\r
2212 /* Activate changes */
\r
2213 if (win_clr[i] != code)
\r
2215 /* Note the change */
\r
2218 /* Apply the desired color */
\r
2219 win_clr[i] = code;
\r
2223 /* Activate the palette if needed */
\r
2224 if (change) (void)new_palette();
\r
2230 /* Handle "arg_sound" */
\r
2231 if (use_sound != arg_sound)
\r
2233 /* Initialize (if needed) */
\r
2234 if (arg_sound && !init_sound())
\r
2237 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
\r
2239 /* Cannot enable */
\r
2240 arg_sound = FALSE;
\r
2243 /* Change setting */
\r
2244 use_sound = arg_sound;
\r
2251 /* Handle "arg_sound" */
\r
2252 if (use_music != arg_music)
\r
2254 /* Initialize (if needed) */
\r
2255 if (arg_music && !init_music())
\r
2258 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
\r
2259 /* Cannot enable */
\r
2260 arg_music = FALSE;
\r
2263 /* Change setting */
\r
2264 use_music = arg_music;
\r
2266 if(!arg_music) stop_music();
\r
2267 else select_floor_music();
\r
2274 #ifdef USE_GRAPHICS
\r
2276 /* Handle "arg_graphics" */
\r
2277 if (use_graphics != arg_graphics)
\r
2279 /* Initialize (if needed) */
\r
2280 if (arg_graphics && !init_graphics())
\r
2283 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
\r
2285 /* Cannot enable */
\r
2286 arg_graphics = GRAPHICS_NONE;
\r
2289 /* Change setting */
\r
2290 use_graphics = arg_graphics;
\r
2292 /* Reset visuals */
\r
2293 #ifdef ANGBAND_2_8_1
\r
2295 #else /* ANGBAND_2_8_1 */
\r
2296 reset_visuals(TRUE);
\r
2297 #endif /* ANGBAND_2_8_1 */
\r
2300 #endif /* USE_GRAPHICS */
\r
2303 /* Clean up windows */
\r
2304 for (i = 0; i < MAX_TERM_DATA; i++)
\r
2308 term_data *td = &data[i];
\r
2310 /* Update resized windows */
\r
2311 if ((td->cols != (uint)td->t.wid) || (td->rows != (uint)td->t.hgt))
\r
2314 Term_activate(&td->t);
\r
2316 /* Hack -- Resize the term */
\r
2317 Term_resize(td->cols, td->rows);
\r
2319 /* Redraw the contents */
\r
2323 Term_activate(old);
\r
2334 * Process at least one event
\r
2336 static errr Term_xtra_win_event(int v)
\r
2340 /* Wait for an event */
\r
2344 if (GetMessage(&msg, NULL, 0, 0))
\r
2346 TranslateMessage(&msg);
\r
2347 DispatchMessage(&msg);
\r
2351 /* Check for an event */
\r
2355 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2357 TranslateMessage(&msg);
\r
2358 DispatchMessage(&msg);
\r
2368 * Process all pending events
\r
2370 static errr Term_xtra_win_flush(void)
\r
2374 /* Process all pending events */
\r
2375 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2377 TranslateMessage(&msg);
\r
2378 DispatchMessage(&msg);
\r
2387 * Hack -- clear the screen
\r
2389 * Make this more efficient XXX XXX XXX
\r
2391 static errr Term_xtra_win_clear(void)
\r
2393 term_data *td = (term_data*)(Term->data);
\r
2398 /* Rectangle to erase */
\r
2399 rc.left = td->size_ow1;
\r
2400 rc.right = rc.left + td->cols * td->tile_wid;
\r
2401 rc.top = td->size_oh1;
\r
2402 rc.bottom = rc.top + td->rows * td->tile_hgt;
\r
2405 hdc = GetDC(td->w);
\r
2406 SetBkColor(hdc, RGB(0, 0, 0));
\r
2407 SelectObject(hdc, td->font_id);
\r
2408 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2413 rc.left = 0; rc.top = 0;
\r
2416 ReleaseDC(td->w, hdc);
\r
2424 * Hack -- make a noise
\r
2426 static errr Term_xtra_win_noise(void)
\r
2428 MessageBeep(MB_ICONASTERISK);
\r
2434 * Hack -- make a sound
\r
2436 static errr Term_xtra_win_sound(int v)
\r
2441 #endif /* USE_SOUND */
\r
2443 /* Sound disabled */
\r
2444 if (!use_sound) return (1);
\r
2446 /* Illegal sound */
\r
2447 if ((v < 0) || (v >= SOUND_MAX)) return (1);
\r
2451 /* Count the samples */
\r
2452 for (i = 0; i < SAMPLE_MAX; i++)
\r
2454 if (!sound_file[v][i])
\r
2459 if (i == 0) return (1);
\r
2461 /* Build the path */
\r
2462 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
\r
2466 /* Play the sound, catch errors */
\r
2467 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
\r
2471 /* Play the sound, catch errors */
\r
2472 return (sndPlaySound(buf, SND_ASYNC));
\r
2474 #endif /* WIN32 */
\r
2476 #else /* USE_SOUND */
\r
2481 #endif /* USE_SOUND */
\r
2485 * Hack -- play a music
\r
2487 static errr Term_xtra_win_music(int n, int v)
\r
2492 #endif /* USE_MUSIC */
\r
2494 /* Sound disabled */
\r
2496 if(!use_music) return (1);
\r
2498 /* Illegal sound */
\r
2499 if(n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return (1);
\r
2500 else if(v < 0 || v >= 1000) return(1); /*!< TODO */
\r
2506 case TERM_XTRA_MUSIC_BASIC:
\r
2507 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2509 case TERM_XTRA_MUSIC_DUNGEON:
\r
2510 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2512 case TERM_XTRA_MUSIC_QUEST:
\r
2513 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2515 case TERM_XTRA_MUSIC_TOWN:
\r
2516 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2523 //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2524 //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2530 case TERM_XTRA_MUSIC_BASIC:
\r
2531 for (i = 0; i < SAMPLE_MAX; i++) if(!music_file[v][i]) break;
\r
2533 case TERM_XTRA_MUSIC_DUNGEON:
\r
2534 for (i = 0; i < SAMPLE_MAX; i++) if(!dungeon_music_file[v][i]) break;
\r
2536 case TERM_XTRA_MUSIC_QUEST:
\r
2537 for (i = 0; i < SAMPLE_MAX; i++) if(!quest_music_file[v][i]) break;
\r
2539 case TERM_XTRA_MUSIC_TOWN:
\r
2540 for (i = 0; i < SAMPLE_MAX; i++) if(!town_music_file[v][i]) break;
\r
2547 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2548 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2554 case TERM_XTRA_MUSIC_BASIC:
\r
2555 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
\r
2557 case TERM_XTRA_MUSIC_DUNGEON:
\r
2558 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
\r
2560 case TERM_XTRA_MUSIC_QUEST:
\r
2561 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
\r
2563 case TERM_XTRA_MUSIC_TOWN:
\r
2564 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
\r
2568 if(current_music_type == n && current_music_id == v)
\r
2572 current_music_type = n;
\r
2573 current_music_id = v;
\r
2577 mop.lpstrDeviceType = mci_device_type;
\r
2578 mop.lpstrElementName = buf;
\r
2579 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
\r
2580 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
\r
2581 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
\r
2582 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
2583 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
2586 #endif /* WIN32 */
\r
2588 #else /* USE_MUSIC */
\r
2592 #endif /* USE_MUSIC */
\r
2598 * Delay for "x" milliseconds
\r
2600 static int Term_xtra_win_delay(int v)
\r
2614 t = GetTickCount() + v;
\r
2617 while (GetTickCount() < t)
\r
2619 /* Handle messages */
\r
2620 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
\r
2622 TranslateMessage(&msg);
\r
2623 DispatchMessage(&msg);
\r
2627 #endif /* WIN32 */
\r
2635 * Do a "special thing"
\r
2637 static errr Term_xtra_win(int n, int v)
\r
2639 /* Handle a subset of the legal requests */
\r
2642 /* Make a bell sound */
\r
2643 case TERM_XTRA_NOISE:
\r
2645 return (Term_xtra_win_noise());
\r
2648 /* Play a music */
\r
2649 case TERM_XTRA_MUSIC_BASIC:
\r
2650 case TERM_XTRA_MUSIC_DUNGEON:
\r
2651 case TERM_XTRA_MUSIC_QUEST:
\r
2652 case TERM_XTRA_MUSIC_TOWN:
\r
2654 return (Term_xtra_win_music(n, v));
\r
2657 /* Make a special sound */
\r
2658 case TERM_XTRA_SOUND:
\r
2660 return (Term_xtra_win_sound(v));
\r
2663 /* Process random events */
\r
2664 case TERM_XTRA_BORED:
\r
2666 return (Term_xtra_win_event(0));
\r
2669 /* Process an event */
\r
2670 case TERM_XTRA_EVENT:
\r
2672 return (Term_xtra_win_event(v));
\r
2675 /* Flush all events */
\r
2676 case TERM_XTRA_FLUSH:
\r
2678 return (Term_xtra_win_flush());
\r
2681 /* Clear the screen */
\r
2682 case TERM_XTRA_CLEAR:
\r
2684 return (Term_xtra_win_clear());
\r
2687 /* React to global changes */
\r
2688 case TERM_XTRA_REACT:
\r
2690 return (Term_xtra_win_react());
\r
2693 /* Delay for some milliseconds */
\r
2694 case TERM_XTRA_DELAY:
\r
2696 return (Term_xtra_win_delay(v));
\r
2707 * Low level graphics (Assumes valid input).
\r
2709 * Draw a "cursor" at (x,y), using a "yellow box".
\r
2711 static errr Term_curs_win(int x, int y)
\r
2713 term_data *td = (term_data*)(Term->data);
\r
2718 int tile_wid, tile_hgt;
\r
2720 if (td->map_active)
\r
2722 tile_wid = td->map_tile_wid;
\r
2723 tile_hgt = td->map_tile_hgt;
\r
2727 tile_wid = td->tile_wid;
\r
2728 tile_hgt = td->tile_hgt;
\r
2731 /* Frame the grid */
\r
2732 rc.left = x * tile_wid + td->size_ow1;
\r
2733 rc.right = rc.left + tile_wid;
\r
2734 rc.top = y * tile_hgt + td->size_oh1;
\r
2735 rc.bottom = rc.top + tile_hgt;
\r
2737 /* Cursor is done as a yellow "box" */
\r
2738 hdc = GetDC(td->w);
\r
2739 FrameRect(hdc, &rc, hbrYellow);
\r
2740 ReleaseDC(td->w, hdc);
\r
2748 * Low level graphics (Assumes valid input).
\r
2750 * Draw a "big cursor" at (x,y), using a "yellow box".
\r
2752 static errr Term_bigcurs_win(int x, int y)
\r
2754 term_data *td = (term_data*)(Term->data);
\r
2759 int tile_wid, tile_hgt;
\r
2761 if (td->map_active)
\r
2763 /* Normal cursor in map window */
\r
2764 Term_curs_win(x, y);
\r
2769 tile_wid = td->tile_wid;
\r
2770 tile_hgt = td->tile_hgt;
\r
2773 /* Frame the grid */
\r
2774 rc.left = x * tile_wid + td->size_ow1;
\r
2775 rc.right = rc.left + 2 * tile_wid;
\r
2776 rc.top = y * tile_hgt + td->size_oh1;
\r
2777 rc.bottom = rc.top + tile_hgt;
\r
2779 /* Cursor is done as a yellow "box" */
\r
2780 hdc = GetDC(td->w);
\r
2781 FrameRect(hdc, &rc, hbrYellow);
\r
2782 ReleaseDC(td->w, hdc);
\r
2790 * Low level graphics (Assumes valid input).
\r
2792 * Erase a "block" of "n" characters starting at (x,y).
\r
2794 static errr Term_wipe_win(int x, int y, int n)
\r
2796 term_data *td = (term_data*)(Term->data);
\r
2801 /* Rectangle to erase in client coords */
\r
2802 rc.left = x * td->tile_wid + td->size_ow1;
\r
2803 rc.right = rc.left + n * td->tile_wid;
\r
2804 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2805 rc.bottom = rc.top + td->tile_hgt;
\r
2807 hdc = GetDC(td->w);
\r
2808 SetBkColor(hdc, RGB(0, 0, 0));
\r
2809 SelectObject(hdc, td->font_id);
\r
2814 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2815 ReleaseDC(td->w, hdc);
\r
2823 * Low level graphics. Assumes valid input.
\r
2825 * Draw several ("n") chars, with an attr, at a given location.
\r
2827 * All "graphic" data is handled by "Term_pict_win()", below.
\r
2829 * One would think there is a more efficient method for telling a window
\r
2830 * what color it should be using to draw with, but perhaps simply changing
\r
2831 * it every time is not too inefficient. XXX XXX XXX
\r
2833 static errr Term_text_win(int x, int y, int n, byte a, const char *s)
\r
2835 term_data *td = (term_data*)(Term->data);
\r
2839 #if 1 /* #ifdef JP */
\r
2840 static HBITMAP WALL;
\r
2841 static HBRUSH myBrush, oldBrush;
\r
2842 static HPEN oldPen;
\r
2843 static bool init_done = FALSE;
\r
2846 WALL = LoadBitmap(hInstance, AppName);
\r
2847 myBrush = CreatePatternBrush(WALL);
\r
2852 /* Total rectangle */
\r
2853 rc.left = x * td->tile_wid + td->size_ow1;
\r
2854 rc.right = rc.left + n * td->tile_wid;
\r
2855 rc.top = y * td->tile_hgt + td->size_oh1;
\r
2856 rc.bottom = rc.top + td->tile_hgt;
\r
2859 hdc = GetDC(td->w);
\r
2861 /* Background color */
\r
2862 SetBkColor(hdc, RGB(0, 0, 0));
\r
2864 /* Foreground color */
\r
2867 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
\r
2869 else if (paletted)
\r
2871 SetTextColor(hdc, win_clr[a&0x0F]);
\r
2875 SetTextColor(hdc, win_clr[a]);
\r
2878 /* Use the font */
\r
2879 SelectObject(hdc, td->font_id);
\r
2882 if (use_bg) SetBkMode(hdc, TRANSPARENT);
\r
2884 /* Bizarre size */
\r
2885 if (td->bizarre ||
\r
2886 (td->tile_hgt != td->font_hgt) ||
\r
2887 (td->tile_wid != td->font_wid))
\r
2891 /* Erase complete rectangle */
\r
2892 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
\r
2895 if (use_bg) DrawBG(hdc, &rc);
\r
2897 /* New rectangle */
\r
2898 rc.left += ((td->tile_wid - td->font_wid) / 2);
\r
2899 rc.right = rc.left + td->font_wid;
\r
2900 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
\r
2901 rc.bottom = rc.top + td->font_hgt;
\r
2903 /* Dump each character */
\r
2904 for (i = 0; i < n; i++)
\r
2907 if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
\r
2909 rc.right += td->font_wid;
\r
2911 oldBrush = SelectObject(hdc, myBrush);
\r
2912 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2914 /* Dump the wall */
\r
2915 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2917 SelectObject(hdc, oldBrush);
\r
2918 SelectObject(hdc, oldPen);
\r
2919 rc.right -= td->font_wid;
\r
2923 rc.left += 2 * td->tile_wid;
\r
2924 rc.right += 2 * td->tile_wid;
\r
2926 else if ( iskanji(*(s+i)) ) /* 2バイト文字 */
\r
2928 rc.right += td->font_wid;
\r
2929 /* Dump the text */
\r
2930 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2932 rc.right -= td->font_wid;
\r
2936 rc.left += 2 * td->tile_wid;
\r
2937 rc.right += 2 * td->tile_wid;
\r
2938 } else if (*(s+i)==127){
\r
2939 oldBrush = SelectObject(hdc, myBrush);
\r
2940 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2942 /* Dump the wall */
\r
2943 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2945 SelectObject(hdc, oldBrush);
\r
2946 SelectObject(hdc, oldPen);
\r
2949 rc.left += td->tile_wid;
\r
2950 rc.right += td->tile_wid;
\r
2952 /* Dump the text */
\r
2953 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s+i, 1, NULL);
\r
2956 rc.left += td->tile_wid;
\r
2957 rc.right += td->tile_wid;
\r
2962 oldBrush = SelectObject(hdc, myBrush);
\r
2963 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN) );
\r
2965 /* Dump the wall */
\r
2966 Rectangle(hdc, rc.left, rc.top, rc.right+1, rc.bottom+1);
\r
2968 SelectObject(hdc, oldBrush);
\r
2969 SelectObject(hdc, oldPen);
\r
2972 rc.left += td->tile_wid;
\r
2973 rc.right += td->tile_wid;
\r
2975 /* Dump the text */
\r
2976 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
\r
2980 rc.left += td->tile_wid;
\r
2981 rc.right += td->tile_wid;
\r
2984 /* Dump the text */
\r
2985 ExtTextOut(hdc, rc.left, rc.top, 0, &rc,
\r
2989 rc.left += td->tile_wid;
\r
2990 rc.right += td->tile_wid;
\r
3000 /* Dump the text */
\r
3001 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
\r
3006 ReleaseDC(td->w, hdc);
\r
3014 * Low level graphics. Assumes valid input.
\r
3016 * Draw an array of "special" attr/char pairs at the given location.
\r
3018 * We use the "Term_pict_win()" function for "graphic" data, which are
\r
3019 * encoded by setting the "high-bits" of both the "attr" and the "char"
\r
3020 * data. We use the "attr" to represent the "row" of the main bitmap,
\r
3021 * and the "char" to represent the "col" of the main bitmap. The use
\r
3022 * of this function is induced by the "higher_pict" flag.
\r
3024 * If "graphics" is not available, we simply "wipe" the given grids.
\r
3026 static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
\r
3028 term_data *td = (term_data*)(Term->data);
\r
3030 #ifdef USE_GRAPHICS
\r
3033 int x1, y1, w1, h1, tw1, th1;
\r
3034 int x2, y2, w2, h2, tw2 = 0;
\r
3037 HDC hdcMask = NULL;
\r
3041 HBITMAP hbmSrcOld;
\r
3044 if (!use_graphics)
\r
3046 /* Erase the grids */
\r
3047 return (Term_wipe_win(x, y, n));
\r
3050 /* Size of bitmap cell */
\r
3051 w1 = infGraph.CellWidth;
\r
3052 h1 = infGraph.CellHeight;
\r
3053 tw1 = infGraph.TileWidth;
\r
3054 th1 = infGraph.TileHeight;
\r
3056 /* Size of window cell */
\r
3057 if (td->map_active)
\r
3059 w2 = td->map_tile_wid;
\r
3060 h2 = td->map_tile_hgt;
\r
3064 w2 = td->tile_wid;
\r
3065 h2 = td->tile_hgt;
\r
3068 /* big tile mode */
\r
3069 if (use_bigtile) tw2 *= 2;
\r
3072 /* Location of window cell */
\r
3073 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
\r
3074 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
\r
3077 hdc = GetDC(td->w);
\r
3080 hdcSrc = CreateCompatibleDC(hdc);
\r
3081 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
\r
3083 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3085 hdcMask = CreateCompatibleDC(hdc);
\r
3086 SelectObject(hdcMask, infMask.hBitmap);
\r
3089 /* Draw attr/char pairs */
\r
3090 for (i = 0; i < n; i++, x2 += w2)
\r
3096 /* Extract picture */
\r
3097 int row = (a & 0x7F);
\r
3098 int col = (c & 0x7F);
\r
3100 /* Location of bitmap cell */
\r
3104 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3106 x3 = (tcp[i] & 0x7F) * w1;
\r
3107 y3 = (tap[i] & 0x7F) * h1;
\r
3108 tw2 = tw2 * w1 / tw1;
\r
3109 h2 = h2 * h1 / th1;
\r
3111 /* Perfect size */
\r
3112 if ((tw1 == tw2) && (th1 == h2))
\r
3114 /* Copy the terrain picture from the bitmap to the window */
\r
3115 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
\r
3117 /* Mask out the tile */
\r
3118 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
\r
3120 /* Draw the tile */
\r
3121 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
\r
3124 /* Need to stretch */
\r
3127 /* Set the correct mode for stretching the tiles */
\r
3128 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3130 /* Copy the terrain picture from the bitmap to the window */
\r
3131 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
\r
3133 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
\r
3135 /* Only draw if terrain and overlay are different */
\r
3136 if ((x1 != x3) || (y1 != y3))
\r
3138 /* Mask out the tile */
\r
3139 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
\r
3141 /* Draw the tile */
\r
3142 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
\r
3148 /* Perfect size */
\r
3149 if ((w1 == tw2) && (h1 == h2))
\r
3151 /* Copy the picture from the bitmap to the window */
\r
3152 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
\r
3155 /* Need to stretch */
\r
3158 /* Set the correct mode for stretching the tiles */
\r
3159 SetStretchBltMode(hdc, COLORONCOLOR);
\r
3161 /* Copy the picture from the bitmap to the window */
\r
3162 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
\r
3168 SelectObject(hdcSrc, hbmSrcOld);
\r
3171 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
\r
3174 SelectObject(hdcMask, hbmSrcOld);
\r
3175 DeleteDC(hdcMask);
\r
3179 ReleaseDC(td->w, hdc);
\r
3181 #else /* USE_GRAPHICS */
\r
3183 /* Just erase this grid */
\r
3184 return (Term_wipe_win(x, y, n));
\r
3186 #endif /* USE_GRAPHICS */
\r
3193 static void windows_map(void)
\r
3195 term_data *td = &data[0];
\r
3197 int x, min_x, max_x;
\r
3198 int y, min_y, max_y;
\r
3202 /* Only in graphics mode */
\r
3203 if (!use_graphics) return;
\r
3205 /* Clear screen */
\r
3206 Term_xtra_win_clear();
\r
3208 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
\r
3209 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
\r
3210 td->map_active = TRUE;
\r
3219 /* Draw the map */
\r
3220 for (x = min_x; x < max_x; x++)
\r
3222 for (y = min_y; y < max_y; y++)
\r
3224 map_info(y, x, &a, (char*)&c, &ta, (char*)&tc);
\r
3226 /* Ignore non-graphics */
\r
3227 if ((a & 0x80) && (c & 0x80))
\r
3229 Term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
\r
3234 /* Hilite the player */
\r
3235 Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
\r
3237 /* Wait for a keypress, flush key buffer */
\r
3238 Term_inkey(&c, TRUE, TRUE);
\r
3241 /* Switch off the map display */
\r
3242 td->map_active = FALSE;
\r
3244 /* Restore screen */
\r
3245 Term_xtra_win_clear();
\r
3250 /*** Other routines ***/
\r
3254 * Create and initialize a "term_data" given a title
\r
3256 static void term_data_link(term_data *td)
\r
3260 /* Initialize the term */
\r
3261 term_init(t, td->cols, td->rows, td->keys);
\r
3263 /* Use a "software" cursor */
\r
3264 t->soft_cursor = TRUE;
\r
3266 /* Use "Term_pict" for "graphic" data */
\r
3267 t->higher_pict = TRUE;
\r
3269 /* Erase with "white space" */
\r
3270 t->attr_blank = TERM_WHITE;
\r
3271 t->char_blank = ' ';
\r
3274 /* Prepare the init/nuke hooks */
\r
3275 t->init_hook = Term_init_win;
\r
3276 t->nuke_hook = Term_nuke_win;
\r
3279 /* Prepare the template hooks */
\r
3280 t->user_hook = Term_user_win;
\r
3281 t->xtra_hook = Term_xtra_win;
\r
3282 t->curs_hook = Term_curs_win;
\r
3283 t->bigcurs_hook = Term_bigcurs_win;
\r
3284 t->wipe_hook = Term_wipe_win;
\r
3285 t->text_hook = Term_text_win;
\r
3286 t->pict_hook = Term_pict_win;
\r
3288 /* Remember where we came from */
\r
3289 t->data = (vptr)(td);
\r
3294 * Create the windows
\r
3296 * First, instantiate the "default" values, then read the "ini_file"
\r
3297 * to over-ride selected values, then create the windows, and fonts.
\r
3299 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
\r
3300 * must make active to realize the palette. XXX XXX XXX
\r
3302 static void init_windows(void)
\r
3308 #if 0 /* #ifndef JP */
\r
3314 WIPE(td, term_data);
\r
3318 td->s = angband_term_name[0];
\r
3324 td->visible = TRUE;
\r
3329 td->pos_x = 7 * 30;
\r
3330 td->pos_y = 7 * 20;
\r
3331 td->posfix = FALSE;
\r
3332 #if 1 /* #ifdef JP */
\r
3333 td->bizarre = TRUE;
\r
3336 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3339 WIPE(td, term_data);
\r
3340 td->s = angband_term_name[i];
\r
3344 td->visible = FALSE;
\r
3349 td->pos_x = (7 - i) * 30;
\r
3350 td->pos_y = (7 - i) * 20;
\r
3351 td->posfix = FALSE;
\r
3352 #if 1 /* #ifdef JP */
\r
3353 td->bizarre = TRUE;
\r
3362 /* Main window (need these before term_getsize gets called) */
\r
3364 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
\r
3365 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
\r
3367 td->dwExStyle = 0;
\r
3368 td->visible = TRUE;
\r
3370 /* Sub windows (need these before term_getsize gets called) */
\r
3371 for (i = 1; i < MAX_TERM_DATA; i++)
\r
3374 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
\r
3375 td->dwExStyle = (WS_EX_TOOLWINDOW);
\r
3380 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3384 #if 1 /* #ifdef JP */
\r
3385 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
\r
3386 td->lf.lfCharSet = DEFAULT_CHARSET;
\r
3387 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
\r
3388 /* Activate the chosen font */
\r
3389 term_force_font(td, NULL);
\r
3390 if(!td->tile_wid) td->tile_wid = td->font_wid;
\r
3391 if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
\r
3393 /* Access the standard font file */
\r
3394 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
\r
3396 /* Activate the chosen font */
\r
3397 if (term_force_font(td, buf))
\r
3399 /* Access the standard font file */
\r
3400 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
3402 /* Force the use of that font */
\r
3403 (void)term_force_font(td, buf);
\r
3407 td->tile_hgt = 13;
\r
3409 /* Assume not bizarre */
\r
3410 td->bizarre = FALSE;
\r
3415 /* Analyze the font */
\r
3418 /* Resize the window */
\r
3419 term_window_resize(td);
\r
3423 /* Sub windows (reverse order) */
\r
3424 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
\r
3429 td->w = CreateWindowEx(td->dwExStyle, AngList,
\r
3430 td->s, td->dwStyle,
\r
3431 td->pos_x, td->pos_y,
\r
3432 td->size_wid, td->size_hgt,
\r
3433 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3435 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
\r
3439 td->size_hack = TRUE;
\r
3440 ShowWindow(td->w, SW_SHOW);
\r
3441 td->size_hack = FALSE;
\r
3444 term_data_link(td);
\r
3445 angband_term[i] = &td->t;
\r
3449 /* Activate the window */
\r
3450 SetActiveWindow(td->w);
\r
3453 if (data[i].posfix)
\r
3455 term_window_pos(&data[i], HWND_TOPMOST);
\r
3459 term_window_pos(&data[i], td->w);
\r
3469 td->w = CreateWindowEx(td->dwExStyle, AppName,
\r
3470 td->s, td->dwStyle,
\r
3471 td->pos_x, td->pos_y,
\r
3472 td->size_wid, td->size_hgt,
\r
3473 HWND_DESKTOP, NULL, hInstance, NULL);
\r
3475 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
\r
3477 term_data_link(td);
\r
3478 angband_term[0] = &td->t;
\r
3479 normsize.x = td->cols;
\r
3480 normsize.y = td->rows;
\r
3482 /* Activate the main window */
\r
3483 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
\r
3484 else ShowWindow(td->w, SW_SHOW);
\r
3486 /* Bring main window back to top */
\r
3487 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
3490 /* New palette XXX XXX XXX */
\r
3491 (void)new_palette();
\r
3494 /* Create a "brush" for drawing the "cursor" */
\r
3495 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
\r
3498 /* Process pending messages */
\r
3499 (void)Term_xtra_win_flush();
\r
3505 * Prepare the menus
\r
3507 static void setup_menus(void)
\r
3511 HMENU hm = GetMenu(data[0].w);
\r
3514 /* Menu "File", Disable all */
\r
3515 EnableMenuItem(hm, IDM_FILE_NEW,
\r
3516 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3517 EnableMenuItem(hm, IDM_FILE_OPEN,
\r
3518 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3519 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3520 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3521 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3522 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3523 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3524 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3527 /* No character available */
\r
3528 if (!character_generated)
\r
3530 /* Menu "File", Item "New" */
\r
3531 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
\r
3533 /* Menu "File", Item "Open" */
\r
3534 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
\r
3537 /* A character available */
\r
3538 if (character_generated)
\r
3540 /* Menu "File", Item "Save" */
\r
3541 EnableMenuItem(hm, IDM_FILE_SAVE,
\r
3542 MF_BYCOMMAND | MF_ENABLED);
\r
3545 /* Menu "File", Item "Exit" */
\r
3546 EnableMenuItem(hm, IDM_FILE_EXIT,
\r
3547 MF_BYCOMMAND | MF_ENABLED);
\r
3549 EnableMenuItem(hm, IDM_FILE_SCORE,
\r
3550 MF_BYCOMMAND | MF_ENABLED);
\r
3553 /* Menu "Window::Visibility" */
\r
3554 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3556 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3557 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3559 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3560 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
\r
3562 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
\r
3563 MF_BYCOMMAND | MF_ENABLED);
\r
3566 /* Menu "Window::Font" */
\r
3567 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3569 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3570 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3572 if (data[i].visible)
\r
3574 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
\r
3575 MF_BYCOMMAND | MF_ENABLED);
\r
3579 /* Menu "Window::Window Position Fix" */
\r
3580 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3582 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3583 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3585 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3586 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
\r
3588 if (data[i].visible)
\r
3590 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
\r
3591 MF_BYCOMMAND | MF_ENABLED);
\r
3595 /* Menu "Window::Bizarre Display" */
\r
3596 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3598 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3599 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3601 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3602 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
\r
3604 if (data[i].visible)
\r
3606 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
\r
3607 MF_BYCOMMAND | MF_ENABLED);
\r
3612 /* Menu "Window::Increase Tile Width" */
\r
3613 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3615 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3616 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3618 if (data[i].visible)
\r
3620 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
\r
3621 MF_BYCOMMAND | MF_ENABLED);
\r
3626 /* Menu "Window::Decrease Tile Width" */
\r
3627 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3629 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3630 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3632 if (data[i].visible)
\r
3634 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
\r
3635 MF_BYCOMMAND | MF_ENABLED);
\r
3640 /* Menu "Window::Increase Tile Height" */
\r
3641 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3643 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3644 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3646 if (data[i].visible)
\r
3648 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
\r
3649 MF_BYCOMMAND | MF_ENABLED);
\r
3654 /* Menu "Window::Decrease Tile Height" */
\r
3655 for (i = 0; i < MAX_TERM_DATA; i++)
\r
3657 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3658 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3660 if (data[i].visible)
\r
3662 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
\r
3663 MF_BYCOMMAND | MF_ENABLED);
\r
3668 /* Menu "Options", disable all */
\r
3669 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3670 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3671 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3672 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3673 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3674 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3675 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3676 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3677 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3678 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3680 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3681 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3684 /* Menu "Options", Item "Map" */
\r
3685 if (use_graphics != GRAPHICS_NONE)
\r
3686 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
\r
3688 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
\r
3689 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
\r
3691 /* Menu "Options", update all */
\r
3692 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
\r
3693 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
\r
3694 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
\r
3695 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
\r
3696 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
\r
3697 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
\r
3698 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
\r
3699 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
\r
3700 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
\r
3701 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
\r
3702 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
\r
3703 (arg_music ? MF_CHECKED : MF_UNCHECKED));
\r
3704 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
\r
3705 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
\r
3706 CheckMenuItem(hm, IDM_OPTIONS_BG,
\r
3707 (use_bg ? MF_CHECKED : MF_UNCHECKED));
\r
3709 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3710 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
\r
3713 #ifdef USE_GRAPHICS
\r
3714 /* Menu "Options", Item "Graphics" */
\r
3715 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
\r
3716 /* Menu "Options", Item "Graphics" */
\r
3717 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
\r
3718 /* Menu "Options", Item "Graphics" */
\r
3719 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
\r
3720 /* Menu "Options", Item "Graphics" */
\r
3721 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
\r
3722 #endif /* USE_GRAPHICS */
\r
3725 /* Menu "Options", Item "Sound" */
\r
3726 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
\r
3727 #endif /* USE_SOUND */
\r
3730 /* Menu "Options", Item "ScreenSaver" */
\r
3731 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
\r
3732 MF_BYCOMMAND | MF_ENABLED);
\r
3733 #endif /* USE_SAVER */
\r
3738 * Check for double clicked (or dragged) savefile
\r
3740 * Apparently, Windows copies the entire filename into the first
\r
3741 * piece of the "command line string". Perhaps we should extract
\r
3742 * the "basename" of that filename and append it to the "save" dir.
\r
3744 static void check_for_save_file(LPSTR cmd_line)
\r
3754 /* Extract filename */
\r
3755 strcat(savefile, s);
\r
3757 /* Validate the file */
\r
3758 validate_file(savefile);
\r
3760 /* Game in progress */
\r
3761 game_in_progress = TRUE;
\r
3769 * Process a menu command
\r
3771 static void process_menus(WORD wCmd)
\r
3783 case IDM_FILE_NEW:
\r
3787 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3789 else if (game_in_progress)
\r
3791 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
\r
3795 game_in_progress = TRUE;
\r
3804 case IDM_FILE_OPEN:
\r
3808 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3810 else if (game_in_progress)
\r
3812 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
\r
3816 memset(&ofn, 0, sizeof(ofn));
\r
3817 ofn.lStructSize = sizeof(ofn);
\r
3818 ofn.hwndOwner = data[0].w;
\r
3819 ofn.lpstrFilter = "Save Files (*.)\0*\0";
\r
3820 ofn.nFilterIndex = 1;
\r
3821 ofn.lpstrFile = savefile;
\r
3822 ofn.nMaxFile = 1024;
\r
3823 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
\r
3824 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
\r
3826 if (GetOpenFileName(&ofn))
\r
3828 /* Load 'savefile' */
\r
3829 validate_file(savefile);
\r
3830 game_in_progress = TRUE;
\r
3840 case IDM_FILE_SAVE:
\r
3842 if (game_in_progress && character_generated)
\r
3847 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
\r
3851 /* Hack -- Forget messages */
\r
3854 /* Save the game */
\r
3856 do_cmd_save_game(FALSE);
\r
3857 #else /* ZANGBAND */
\r
3858 do_cmd_save_game();
\r
3859 #endif /* ZANGBAND */
\r
3863 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
\r
3869 case IDM_FILE_EXIT:
\r
3871 if (game_in_progress && character_generated)
\r
3876 plog(_("今は終了できません。", "You may not do that right now."));
\r
3880 /* Hack -- Forget messages */
\r
3887 /* Save the game */
\r
3889 /* do_cmd_save_game(FALSE); */
\r
3890 #else /* ZANGBAND */
\r
3891 /* do_cmd_save_game(); */
\r
3892 #endif /* ZANGBAND */
\r
3893 Term_key_push(SPECIAL_KEY_QUIT);
\r
3901 case IDM_FILE_SCORE:
\r
3905 /* Build the filename */
\r
3906 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
\r
3908 /* Open the binary high score file, for reading */
\r
3909 highscore_fd = fd_open(buf, O_RDONLY);
\r
3911 /* Paranoia -- No score file */
\r
3912 if (highscore_fd < 0)
\r
3914 msg_print("Score file unavailable.");
\r
3921 /* Clear screen */
\r
3924 /* Display the scores */
\r
3925 display_scores_aux(0, MAX_HISCORES, -1, NULL);
\r
3927 /* Shut the high score file */
\r
3928 (void)fd_close(highscore_fd);
\r
3930 /* Forget the high score fd */
\r
3931 highscore_fd = -1;
\r
3936 /* Hack - Flush it */
\r
3944 case IDM_FILE_MOVIE:
\r
3948 plog(_("まだ初期化中です...", "You cannot do that yet..."));
\r
3950 else if (game_in_progress)
\r
3952 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
\r
3956 memset(&ofn, 0, sizeof(ofn));
\r
3957 ofn.lStructSize = sizeof(ofn);
\r
3958 ofn.hwndOwner = data[0].w;
\r
3959 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
\r
3960 ofn.nFilterIndex = 1;
\r
3961 ofn.lpstrFile = savefile;
\r
3962 ofn.nMaxFile = 1024;
\r
3963 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
\r
3964 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
\r
3966 if (GetOpenFileName(&ofn))
\r
3968 /* Load 'savefile' */
\r
3969 prepare_browse_movie_aux(savefile);
\r
3979 case IDM_WINDOW_VIS_0:
\r
3981 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
\r
3985 /* Window visibility */
\r
3986 case IDM_WINDOW_VIS_1:
\r
3987 case IDM_WINDOW_VIS_2:
\r
3988 case IDM_WINDOW_VIS_3:
\r
3989 case IDM_WINDOW_VIS_4:
\r
3990 case IDM_WINDOW_VIS_5:
\r
3991 case IDM_WINDOW_VIS_6:
\r
3992 case IDM_WINDOW_VIS_7:
\r
3994 i = wCmd - IDM_WINDOW_VIS_0;
\r
3996 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4002 td->visible = TRUE;
\r
4003 ShowWindow(td->w, SW_SHOW);
\r
4004 term_data_redraw(td);
\r
4008 td->visible = FALSE;
\r
4009 td->posfix = FALSE;
\r
4010 ShowWindow(td->w, SW_HIDE);
\r
4016 /* Window fonts */
\r
4017 case IDM_WINDOW_FONT_0:
\r
4018 case IDM_WINDOW_FONT_1:
\r
4019 case IDM_WINDOW_FONT_2:
\r
4020 case IDM_WINDOW_FONT_3:
\r
4021 case IDM_WINDOW_FONT_4:
\r
4022 case IDM_WINDOW_FONT_5:
\r
4023 case IDM_WINDOW_FONT_6:
\r
4024 case IDM_WINDOW_FONT_7:
\r
4026 i = wCmd - IDM_WINDOW_FONT_0;
\r
4028 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4032 term_change_font(td);
\r
4037 /* Window Z Position */
\r
4038 case IDM_WINDOW_POS_1:
\r
4039 case IDM_WINDOW_POS_2:
\r
4040 case IDM_WINDOW_POS_3:
\r
4041 case IDM_WINDOW_POS_4:
\r
4042 case IDM_WINDOW_POS_5:
\r
4043 case IDM_WINDOW_POS_6:
\r
4044 case IDM_WINDOW_POS_7:
\r
4046 i = wCmd - IDM_WINDOW_POS_0;
\r
4048 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4052 if (!td->posfix && td->visible)
\r
4054 td->posfix = TRUE;
\r
4055 term_window_pos(td, HWND_TOPMOST);
\r
4059 td->posfix = FALSE;
\r
4060 term_window_pos(td, data[0].w);
\r
4066 /* Bizarre Display */
\r
4067 case IDM_WINDOW_BIZ_0:
\r
4068 case IDM_WINDOW_BIZ_1:
\r
4069 case IDM_WINDOW_BIZ_2:
\r
4070 case IDM_WINDOW_BIZ_3:
\r
4071 case IDM_WINDOW_BIZ_4:
\r
4072 case IDM_WINDOW_BIZ_5:
\r
4073 case IDM_WINDOW_BIZ_6:
\r
4074 case IDM_WINDOW_BIZ_7:
\r
4076 i = wCmd - IDM_WINDOW_BIZ_0;
\r
4078 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4082 td->bizarre = !td->bizarre;
\r
4086 term_window_resize(td);
\r
4091 /* Increase Tile Width */
\r
4092 case IDM_WINDOW_I_WID_0:
\r
4093 case IDM_WINDOW_I_WID_1:
\r
4094 case IDM_WINDOW_I_WID_2:
\r
4095 case IDM_WINDOW_I_WID_3:
\r
4096 case IDM_WINDOW_I_WID_4:
\r
4097 case IDM_WINDOW_I_WID_5:
\r
4098 case IDM_WINDOW_I_WID_6:
\r
4099 case IDM_WINDOW_I_WID_7:
\r
4101 i = wCmd - IDM_WINDOW_I_WID_0;
\r
4103 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4107 td->tile_wid += 1;
\r
4111 term_window_resize(td);
\r
4116 /* Decrease Tile Height */
\r
4117 case IDM_WINDOW_D_WID_0:
\r
4118 case IDM_WINDOW_D_WID_1:
\r
4119 case IDM_WINDOW_D_WID_2:
\r
4120 case IDM_WINDOW_D_WID_3:
\r
4121 case IDM_WINDOW_D_WID_4:
\r
4122 case IDM_WINDOW_D_WID_5:
\r
4123 case IDM_WINDOW_D_WID_6:
\r
4124 case IDM_WINDOW_D_WID_7:
\r
4126 i = wCmd - IDM_WINDOW_D_WID_0;
\r
4128 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4132 td->tile_wid -= 1;
\r
4136 term_window_resize(td);
\r
4141 /* Increase Tile Height */
\r
4142 case IDM_WINDOW_I_HGT_0:
\r
4143 case IDM_WINDOW_I_HGT_1:
\r
4144 case IDM_WINDOW_I_HGT_2:
\r
4145 case IDM_WINDOW_I_HGT_3:
\r
4146 case IDM_WINDOW_I_HGT_4:
\r
4147 case IDM_WINDOW_I_HGT_5:
\r
4148 case IDM_WINDOW_I_HGT_6:
\r
4149 case IDM_WINDOW_I_HGT_7:
\r
4151 i = wCmd - IDM_WINDOW_I_HGT_0;
\r
4153 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4157 td->tile_hgt += 1;
\r
4161 term_window_resize(td);
\r
4166 /* Decrease Tile Height */
\r
4167 case IDM_WINDOW_D_HGT_0:
\r
4168 case IDM_WINDOW_D_HGT_1:
\r
4169 case IDM_WINDOW_D_HGT_2:
\r
4170 case IDM_WINDOW_D_HGT_3:
\r
4171 case IDM_WINDOW_D_HGT_4:
\r
4172 case IDM_WINDOW_D_HGT_5:
\r
4173 case IDM_WINDOW_D_HGT_6:
\r
4174 case IDM_WINDOW_D_HGT_7:
\r
4176 i = wCmd - IDM_WINDOW_D_HGT_0;
\r
4178 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
\r
4182 td->tile_hgt -= 1;
\r
4186 term_window_resize(td);
\r
4191 case IDM_OPTIONS_NO_GRAPHICS:
\r
4196 plog("You may not do that right now.");
\r
4200 /* Toggle "arg_graphics" */
\r
4201 if (arg_graphics != GRAPHICS_NONE)
\r
4203 arg_graphics = GRAPHICS_NONE;
\r
4205 /* React to changes */
\r
4206 Term_xtra_win_react();
\r
4208 /* Hack -- Force redraw */
\r
4209 Term_key_push(KTRL('R'));
\r
4215 case IDM_OPTIONS_OLD_GRAPHICS:
\r
4220 plog("You may not do that right now.");
\r
4224 /* Toggle "arg_graphics" */
\r
4225 if (arg_graphics != GRAPHICS_ORIGINAL)
\r
4227 arg_graphics = GRAPHICS_ORIGINAL;
\r
4229 /* React to changes */
\r
4230 Term_xtra_win_react();
\r
4232 /* Hack -- Force redraw */
\r
4233 Term_key_push(KTRL('R'));
\r
4239 case IDM_OPTIONS_NEW_GRAPHICS:
\r
4244 plog("You may not do that right now.");
\r
4248 /* Toggle "arg_graphics" */
\r
4249 if (arg_graphics != GRAPHICS_ADAM_BOLT)
\r
4251 arg_graphics = GRAPHICS_ADAM_BOLT;
\r
4253 /* React to changes */
\r
4254 Term_xtra_win_react();
\r
4256 /* Hack -- Force redraw */
\r
4257 Term_key_push(KTRL('R'));
\r
4263 case IDM_OPTIONS_NEW2_GRAPHICS:
\r
4268 plog("You may not do that right now.");
\r
4272 /* Toggle "arg_graphics" */
\r
4273 if (arg_graphics != GRAPHICS_HENGBAND)
\r
4275 arg_graphics = GRAPHICS_HENGBAND;
\r
4277 /* React to changes */
\r
4278 Term_xtra_win_react();
\r
4280 /* Hack -- Force redraw */
\r
4281 Term_key_push(KTRL('R'));
\r
4287 case IDM_OPTIONS_BIGTILE:
\r
4289 term_data *td = &data[0];
\r
4294 plog("You may not do that right now.");
\r
4298 /* Toggle "arg_sound" */
\r
4299 arg_bigtile = !arg_bigtile;
\r
4302 Term_activate(&td->t);
\r
4304 /* Resize the term */
\r
4305 Term_resize(td->cols, td->rows);
\r
4307 /* Redraw later */
\r
4308 InvalidateRect(td->w, NULL, TRUE);
\r
4313 case IDM_OPTIONS_MUSIC:
\r
4318 plog("You may not do that right now.");
\r
4322 /* Toggle "arg_sound" */
\r
4323 arg_music = !arg_music;
\r
4325 /* React to changes */
\r
4326 Term_xtra_win_react();
\r
4328 /* Hack -- Force redraw */
\r
4329 Term_key_push(KTRL('R'));
\r
4334 case IDM_OPTIONS_SOUND:
\r
4339 plog("You may not do that right now.");
\r
4343 /* Toggle "arg_sound" */
\r
4344 arg_sound = !arg_sound;
\r
4346 /* React to changes */
\r
4347 Term_xtra_win_react();
\r
4349 /* Hack -- Force redraw */
\r
4350 Term_key_push(KTRL('R'));
\r
4356 case IDM_OPTIONS_BG:
\r
4361 plog("You may not do that right now.");
\r
4365 /* Toggle "use_bg" */
\r
4370 /* React to changes */
\r
4371 Term_xtra_win_react();
\r
4373 /* Hack -- Force redraw */
\r
4374 Term_key_push(KTRL('R'));
\r
4380 case IDM_OPTIONS_OPEN_BG:
\r
4385 plog("You may not do that right now.");
\r
4390 memset(&ofn, 0, sizeof(ofn));
\r
4391 ofn.lStructSize = sizeof(ofn);
\r
4392 ofn.hwndOwner = data[0].w;
\r
4393 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
\r
4394 ofn.nFilterIndex = 1;
\r
4395 ofn.lpstrFile = bg_bitmap_file;
\r
4396 ofn.nMaxFile = 1023;
\r
4397 ofn.lpstrInitialDir = NULL;
\r
4398 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
\r
4399 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
\r
4401 if (GetOpenFileName(&ofn))
\r
4403 /* Load 'savefile' */
\r
4408 /* React to changes */
\r
4409 Term_xtra_win_react();
\r
4411 /* Hack -- Force redraw */
\r
4412 Term_key_push(KTRL('R'));
\r
4417 case IDM_DUMP_SCREEN_HTML:
\r
4419 static char buf[1024] = "";
\r
4420 memset(&ofn, 0, sizeof(ofn));
\r
4421 ofn.lStructSize = sizeof(ofn);
\r
4422 ofn.hwndOwner = data[0].w;
\r
4423 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
\r
4424 ofn.nFilterIndex = 1;
\r
4425 ofn.lpstrFile = buf;
\r
4426 ofn.nMaxFile = 1023;
\r
4427 ofn.lpstrDefExt = "html";
\r
4428 ofn.lpstrInitialDir = NULL;
\r
4429 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
\r
4430 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
\r
4432 if (GetSaveFileName(&ofn))
\r
4434 do_cmd_save_screen_html_aux(buf, 0);
\r
4441 case IDM_OPTIONS_SAVER:
\r
4445 DestroyWindow(hwndSaver);
\r
4450 /* Create a screen scaver window */
\r
4451 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
\r
4452 "Angband Screensaver",
\r
4453 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
\r
4454 0, 0, GetSystemMetrics(SM_CXSCREEN),
\r
4455 GetSystemMetrics(SM_CYSCREEN),
\r
4456 NULL, NULL, hInstance, NULL);
\r
4460 /* Push the window to the bottom XXX XXX XXX */
\r
4461 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
\r
4465 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
\r
4473 case IDM_OPTIONS_MAP:
\r
4479 case IDM_HELP_CONTENTS:
\r
4483 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
\r
4484 if (check_file(tmp))
\r
4486 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
\r
4491 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4492 plog("代わりにオンラインヘルプを使用してください。");
\r
4494 plog_fmt("Cannot find help file: %s", tmp);
\r
4495 plog("Use the online help files instead.");
\r
4500 #else /* HTML_HELP */
\r
4503 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
\r
4504 if (check_file(tmp))
\r
4506 sprintf(buf, "winhelp.exe %s", tmp);
\r
4507 WinExec(buf, SW_NORMAL);
\r
4512 plog_fmt("ヘルプファイル[%s]が見付かりません。", tmp);
\r
4513 plog("代わりにオンラインヘルプを使用してください。");
\r
4515 plog_fmt("Cannot find help file: %s", tmp);
\r
4516 plog("Use the online help files instead.");
\r
4521 #endif /* HTML_HELP */
\r
4527 static bool process_keydown(WPARAM wParam, LPARAM lParam)
\r
4534 /* Extract the modifiers */
\r
4535 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
\r
4536 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
\r
4537 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
\r
4539 Term_no_press = (ma) ? TRUE : FALSE;
\r
4541 /* Handle "special" keys */
\r
4542 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
\r
4544 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
\r
4545 bool numpad = FALSE;
\r
4547 /* Begin the macro trigger */
\r
4548 Term_keypress(31);
\r
4550 /* Send the modifiers */
\r
4551 if (mc) Term_keypress('C');
\r
4552 if (ms) Term_keypress('S');
\r
4553 if (ma) Term_keypress('A');
\r
4555 /* Extract "scan code" */
\r
4556 i = LOBYTE(HIWORD(lParam));
\r
4558 /* Introduce the scan code */
\r
4559 Term_keypress('x');
\r
4561 /* Extended key bit */
\r
4564 /* Numpad Enter and '/' are extended key */
\r
4566 Term_no_press = TRUE;
\r
4567 case VK_RETURN: /* Enter */
\r
4570 /* Other extended keys are on full keyboard */
\r
4584 case VK_SEPARATOR:
\r
4586 Term_no_press = TRUE;
\r
4590 case VK_PRIOR: /* Page Up */
\r
4591 case VK_NEXT: /* Page Down */
\r
4598 numpad = !ext_key;
\r
4601 /* Special modifiers for keypad keys */
\r
4602 if (numpad) Term_keypress('K');
\r
4604 /* Encode the hexidecimal scan code */
\r
4605 Term_keypress(hexsym[i/16]);
\r
4606 Term_keypress(hexsym[i%16]);
\r
4608 /* End the macro trigger */
\r
4609 Term_keypress(13);
\r
4619 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4620 WPARAM wParam, LPARAM lParam);
\r
4621 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4622 WPARAM wParam, LPARAM lParam)
\r
4623 #else /* __MWERKS__ */
\r
4624 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
\r
4625 WPARAM wParam, LPARAM lParam)
\r
4626 #endif /* __MWERKS__ */
\r
4632 MINMAXINFO FAR *lpmmi;
\r
4638 /* Acquire proper "term_data" info */
\r
4639 td = (term_data *)GetWindowLong(hWnd, 0);
\r
4641 /* Handle message */
\r
4647 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
4655 mop.dwCallback=(DWORD)hWnd;
\r
4660 case WM_GETMINMAXINFO:
\r
4662 MINMAXINFO FAR *lpmmi;
\r
4665 lpmmi = (MINMAXINFO FAR *)lParam;
\r
4667 /* this message was sent before WM_NCCREATE */
\r
4668 if (!td) return 1;
\r
4670 /* Minimum window size is 80x24 */
\r
4671 rc.left = rc.top = 0;
\r
4672 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
4673 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
4676 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
4678 /* Save minimum size */
\r
4679 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
4680 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
4687 BeginPaint(hWnd, &ps);
\r
4688 if (td) term_data_redraw(td);
\r
4689 EndPaint(hWnd, &ps);
\r
4690 ValidateRect(hWnd, NULL);
\r
4695 case MM_MCINOTIFY:
\r
4697 if(wParam == MCI_NOTIFY_SUCCESSFUL)
\r
4699 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
\r
4700 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
\r
4706 case WM_SYSKEYDOWN:
\r
4709 if (process_keydown(wParam, lParam))
\r
4716 if (Term_no_press) Term_no_press = FALSE;
\r
4717 else Term_keypress(wParam);
\r
4721 case WM_LBUTTONDOWN:
\r
4723 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4724 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4725 mouse_down = TRUE;
\r
4731 case WM_LBUTTONUP:
\r
4736 int dx = abs(oldx - mousex) + 1;
\r
4737 int dy = abs(oldy - mousey) + 1;
\r
4738 int ox = (oldx > mousex) ? mousex : oldx;
\r
4739 int oy = (oldy > mousey) ? mousey : oldy;
\r
4741 mouse_down = FALSE;
\r
4742 paint_rect = FALSE;
\r
4745 sz = (dx + 3) * dy;
\r
4747 sz = (dx + 2) * dy;
\r
4749 hGlobal = GlobalAlloc(GHND, sz + 1);
\r
4750 if (hGlobal == NULL) return 0;
\r
4751 lpStr = (LPSTR)GlobalLock(hGlobal);
\r
4753 for (i = 0; i < dy; i++)
\r
4757 char **scr = data[0].t.scr->c;
\r
4759 C_MAKE(s, (dx + 1), char);
\r
4760 strncpy(s, &scr[oy + i][ox], dx);
\r
4764 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
\r
4767 if (ox + dx < data[0].cols)
\r
4769 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
\r
4772 for (j = 0; j < dx; j++)
\r
4774 if (s[j] == 127) s[j] = '#';
\r
4778 for (j = 0; j < dx; j++)
\r
4780 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
\r
4790 GlobalUnlock(hGlobal);
\r
4791 if (OpenClipboard(hWnd) == 0)
\r
4793 GlobalFree(hGlobal);
\r
4797 SetClipboardData(CF_TEXT, hGlobal);
\r
4805 case WM_MOUSEMOVE:
\r
4810 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
\r
4811 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
\r
4816 dx = abs(oldx - mousex) + 1;
\r
4817 dy = abs(oldy - mousey) + 1;
\r
4818 ox = (oldx > mousex) ? mousex : oldx;
\r
4819 oy = (oldy > mousey) ? mousey : oldy;
\r
4820 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4824 paint_rect = TRUE;
\r
4827 dx = abs(cx - mousex) + 1;
\r
4828 dy = abs(cy - mousey) + 1;
\r
4829 ox = (cx > mousex) ? mousex : cx;
\r
4830 oy = (cy > mousey) ? mousey : cy;
\r
4831 Term_inversed_area(hWnd, ox, oy, dx, dy);
\r
4847 if (game_in_progress && character_generated)
\r
4851 plog(_("今は終了できません。", "You may not do that right now."));
\r
4855 /* Hack -- Forget messages */
\r
4862 /* Save the game */
\r
4864 /* do_cmd_save_game(FALSE); */
\r
4865 #else /* ZANGBAND */
\r
4866 /* do_cmd_save_game(); */
\r
4867 #endif /* ZANGBAND */
\r
4868 Term_key_push(SPECIAL_KEY_QUIT);
\r
4875 case WM_QUERYENDSESSION:
\r
4877 if (game_in_progress && character_generated)
\r
4879 /* Hack -- Forget messages */
\r
4882 /* Mega-Hack -- Delay death */
\r
4883 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
\r
4884 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
\r
4886 /* Hardcode panic save */
\r
4887 p_ptr->panic_save = 1;
\r
4889 /* Forbid suspend */
\r
4890 signals_ignore_tstp();
\r
4892 /* Indicate panic save */
\r
4893 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
\r
4896 (void)save_player();
\r
4910 process_menus(LOWORD(wParam));
\r
4916 /* this message was sent before WM_NCCREATE */
\r
4917 if (!td) return 1;
\r
4919 /* it was sent from inside CreateWindowEx */
\r
4920 if (!td->w) return 1;
\r
4922 /* was sent from WM_SIZE */
\r
4923 if (td->size_hack) return 1;
\r
4927 case SIZE_MINIMIZED:
\r
4929 /* Hide sub-windows */
\r
4930 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4932 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
\r
4937 case SIZE_MAXIMIZED:
\r
4939 /* fall through XXX XXX XXX */
\r
4942 case SIZE_RESTORED:
\r
4944 uint cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
4945 uint rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
4948 if ((td->cols != cols) || (td->rows != rows))
\r
4950 /* Save the new size */
\r
4954 if (!IsZoomed(td->w) && !IsIconic(td->w))
\r
4956 normsize.x = td->cols;
\r
4957 normsize.y = td->rows;
\r
4961 Term_activate(&td->t);
\r
4963 /* Resize the term */
\r
4964 Term_resize(td->cols, td->rows);
\r
4966 /* Redraw later */
\r
4967 InvalidateRect(td->w, NULL, TRUE);
\r
4970 td->size_hack = TRUE;
\r
4972 /* Show sub-windows */
\r
4973 for (i = 1; i < MAX_TERM_DATA; i++)
\r
4975 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
\r
4978 td->size_hack = FALSE;
\r
4986 case WM_PALETTECHANGED:
\r
4988 /* Ignore if palette change caused by itself */
\r
4989 if ((HWND)wParam == hWnd) return 0;
\r
4991 /* Fall through... */
\r
4994 case WM_QUERYNEWPALETTE:
\r
4996 if (!paletted) return 0;
\r
4998 hdc = GetDC(hWnd);
\r
5000 SelectPalette(hdc, hPal, FALSE);
\r
5002 i = RealizePalette(hdc);
\r
5004 /* if any palette entries changed, repaint the window. */
\r
5005 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5007 ReleaseDC(hWnd, hdc);
\r
5014 if (wParam && !HIWORD(lParam))
\r
5016 /* Do something to sub-windows */
\r
5017 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5019 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
\r
5022 /* Focus on main window */
\r
5031 case WM_ACTIVATEAPP:
\r
5033 if (IsIconic(td->w)) break;
\r
5035 for (i = 1; i < MAX_TERM_DATA; i++)
\r
5037 if(data[i].visible)
\r
5039 if (wParam == TRUE)
\r
5041 ShowWindow(data[i].w, SW_SHOW);
\r
5045 ShowWindow(data[i].w, SW_HIDE);
\r
5052 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5057 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5058 WPARAM wParam, LPARAM lParam);
\r
5059 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5060 WPARAM wParam, LPARAM lParam)
\r
5061 #else /* __MWERKS__ */
\r
5062 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
\r
5063 WPARAM wParam, LPARAM lParam)
\r
5064 #endif /* __MWERKS__ */
\r
5068 MINMAXINFO FAR *lpmmi;
\r
5076 /* Acquire proper "term_data" info */
\r
5077 td = (term_data *)GetWindowLong(hWnd, 0);
\r
5079 /* Process message */
\r
5085 SetWindowLong(hWnd, 0, (LONG)(my_td));
\r
5095 case WM_GETMINMAXINFO:
\r
5097 MINMAXINFO FAR *lpmmi;
\r
5100 lpmmi = (MINMAXINFO FAR *)lParam;
\r
5102 /* this message was sent before WM_NCCREATE */
\r
5103 if (!td) return 1;
\r
5105 /* Minimum window size is 80x24 */
\r
5106 rc.left = rc.top = 0;
\r
5107 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
\r
5108 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
\r
5111 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
\r
5113 /* Save minimum size */
\r
5114 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
\r
5115 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
\r
5125 /* this message was sent before WM_NCCREATE */
\r
5126 if (!td) return 1;
\r
5128 /* it was sent from inside CreateWindowEx */
\r
5129 if (!td->w) return 1;
\r
5131 /* was sent from inside WM_SIZE */
\r
5132 if (td->size_hack) return 1;
\r
5134 td->size_hack = TRUE;
\r
5136 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
\r
5137 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
\r
5140 if ((td->cols != cols) || (td->rows != rows))
\r
5142 /* Save old term */
\r
5143 term *old_term = Term;
\r
5145 /* Save the new size */
\r
5150 Term_activate(&td->t);
\r
5152 /* Resize the term */
\r
5153 Term_resize(td->cols, td->rows);
\r
5156 Term_activate(old_term);
\r
5158 /* Redraw later */
\r
5159 InvalidateRect(td->w, NULL, TRUE);
\r
5161 /* HACK - Redraw all windows */
\r
5162 p_ptr->window = 0xFFFFFFFF;
\r
5166 td->size_hack = FALSE;
\r
5173 BeginPaint(hWnd, &ps);
\r
5174 if (td) term_data_redraw(td);
\r
5175 EndPaint(hWnd, &ps);
\r
5179 case WM_SYSKEYDOWN:
\r
5182 if (process_keydown(wParam, lParam))
\r
5189 if (Term_no_press) Term_no_press = FALSE;
\r
5190 else Term_keypress(wParam);
\r
5194 case WM_PALETTECHANGED:
\r
5196 /* ignore if palette change caused by itself */
\r
5197 if ((HWND)wParam == hWnd) return FALSE;
\r
5198 /* otherwise, fall through!!! */
\r
5201 case WM_QUERYNEWPALETTE:
\r
5203 if (!paletted) return 0;
\r
5204 hdc = GetDC(hWnd);
\r
5205 SelectPalette(hdc, hPal, FALSE);
\r
5206 i = RealizePalette(hdc);
\r
5207 /* if any palette entries changed, repaint the window. */
\r
5208 if (i) InvalidateRect(hWnd, NULL, TRUE);
\r
5209 ReleaseDC(hWnd, hdc);
\r
5213 case WM_NCLBUTTONDOWN:
\r
5217 if (wParam == HTCLOSE) wParam = HTSYSMENU;
\r
5218 #endif /* HTCLOSE */
\r
5220 if (wParam == HTSYSMENU)
\r
5224 td->visible = FALSE;
\r
5225 ShowWindow(td->w, SW_HIDE);
\r
5235 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5241 #define MOUSE_SENS 40
\r
5244 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5245 WPARAM wParam, LPARAM lParam);
\r
5246 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5247 WPARAM wParam, LPARAM lParam)
\r
5248 #else /* __MWERKS__ */
\r
5249 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
\r
5250 WPARAM wParam, LPARAM lParam)
\r
5251 #endif /* __MWERKS__ */
\r
5253 static int iMouse = 0;
\r
5254 static WORD xMouse = 0;
\r
5255 static WORD yMouse = 0;
\r
5269 case WM_SETCURSOR:
\r
5278 if (LOWORD(wParam) == WA_INACTIVE) break;
\r
5280 /* else fall through */
\r
5284 case WM_LBUTTONDOWN:
\r
5285 case WM_MBUTTONDOWN:
\r
5286 case WM_RBUTTONDOWN:
\r
5289 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5293 case WM_MOUSEMOVE:
\r
5297 dx = LOWORD(lParam) - xMouse;
\r
5298 dy = HIWORD(lParam) - yMouse;
\r
5300 if (dx < 0) dx = -dx;
\r
5301 if (dy < 0) dy = -dy;
\r
5303 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
\r
5305 SendMessage(hWnd, WM_CLOSE, 0, 0);
\r
5309 /* Save last location */
\r
5311 xMouse = LOWORD(lParam);
\r
5312 yMouse = HIWORD(lParam);
\r
5319 DestroyWindow(hwndSaver);
\r
5326 return DefWindowProc(hWnd, uMsg, wParam, lParam);
\r
5329 #endif /* USE_SAVER */
\r
5335 /*** Temporary Hooks ***/
\r
5339 * Display warning message (see "z-util.c")
\r
5341 static void hack_plog(cptr str)
\r
5343 /* Give a warning */
\r
5347 MessageBox(NULL, str, "警告!",
\r
5348 MB_ICONEXCLAMATION | MB_OK);
\r
5350 MessageBox(NULL, str, "Warning",
\r
5351 MB_ICONEXCLAMATION | MB_OK);
\r
5359 * Display error message and quit (see "z-util.c")
\r
5361 static void hack_quit(cptr str)
\r
5363 /* Give a warning */
\r
5367 MessageBox(NULL, str, "エラー!",
\r
5368 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5370 MessageBox(NULL, str, "Error",
\r
5371 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5376 /* Unregister the classes */
\r
5377 UnregisterClass(AppName, hInstance);
\r
5379 /* Destroy the icon */
\r
5380 if (hIcon) DestroyIcon(hIcon);
\r
5388 /*** Various hooks ***/
\r
5392 * Display warning message (see "z-util.c")
\r
5394 static void hook_plog(cptr str)
\r
5400 MessageBox(data[0].w, str, "警告!",
\r
5401 MB_ICONEXCLAMATION | MB_OK);
\r
5403 MessageBox(data[0].w, str, "Warning",
\r
5404 MB_ICONEXCLAMATION | MB_OK);
\r
5412 * Display error message and quit (see "z-util.c")
\r
5414 static void hook_quit(cptr str)
\r
5419 /* Give a warning */
\r
5423 MessageBox(data[0].w, str, "エラー!",
\r
5424 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5426 MessageBox(data[0].w, str, "Error",
\r
5427 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5433 /* Save the preferences */
\r
5437 /*** Could use 'Term_nuke_win()' XXX XXX XXX */
\r
5439 /* Destroy all windows */
\r
5440 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
\r
5442 term_force_font(&data[i], NULL);
\r
5443 if (data[i].font_want) string_free(data[i].font_want);
\r
5444 if (data[i].w) DestroyWindow(data[i].w);
\r
5448 /* Free the bitmap stuff */
\r
5449 #ifdef USE_GRAPHICS
\r
5450 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
\r
5451 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
\r
5453 if (infMask.hPalette) DeleteObject(infMask.hPalette);
\r
5454 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
\r
5456 #endif /* USE_GRAPHICS */
\r
5458 /*** Free some other stuff ***/
\r
5460 DeleteObject(hbrYellow);
\r
5465 if (hPal) DeleteObject(hPal);
\r
5467 UnregisterClass(AppName, hInstance);
\r
5469 if (hIcon) DestroyIcon(hIcon);
\r
5476 /*** Initialize ***/
\r
5482 static void init_stuff(void)
\r
5489 /* Get program name with full path */
\r
5490 GetModuleFileName(hInstance, path, 512);
\r
5492 /* Save the "program name" XXX XXX XXX */
\r
5495 /* Get the name of the "*.ini" file */
\r
5496 strcpy(path + strlen(path) - 4, ".INI");
\r
5498 /* Save the the name of the ini-file */
\r
5499 ini_file = string_make(path);
\r
5501 /* Analyze the path */
\r
5504 /* Get the path */
\r
5505 for (; i > 0; i--)
\r
5507 if (path[i] == '\\')
\r
5514 /* Add "lib" to the path */
\r
5515 strcpy(path + i + 1, "lib\\");
\r
5517 /* Validate the path */
\r
5518 validate_dir(path, TRUE);
\r
5520 /* Init the file paths */
\r
5521 init_file_paths(path);
\r
5523 /* Hack -- Validate the paths */
\r
5524 validate_dir(ANGBAND_DIR_APEX, FALSE);
\r
5525 validate_dir(ANGBAND_DIR_BONE, FALSE);
\r
5527 /* Allow missing 'edit' directory */
\r
5528 if (!check_dir(ANGBAND_DIR_EDIT))
\r
5530 /* Must have 'data'! */
\r
5531 validate_dir(ANGBAND_DIR_DATA, TRUE);
\r
5535 /* Don't need 'data' */
\r
5536 validate_dir(ANGBAND_DIR_DATA, FALSE);
\r
5539 validate_dir(ANGBAND_DIR_FILE, TRUE);
\r
5540 validate_dir(ANGBAND_DIR_HELP, FALSE);
\r
5541 validate_dir(ANGBAND_DIR_INFO, FALSE);
\r
5542 validate_dir(ANGBAND_DIR_PREF, TRUE);
\r
5543 validate_dir(ANGBAND_DIR_SAVE, FALSE);
\r
5544 validate_dir(ANGBAND_DIR_USER, TRUE);
\r
5545 validate_dir(ANGBAND_DIR_XTRA, TRUE);
\r
5547 /* Build the filename */
\r
5548 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
\r
5550 /* Hack -- Validate the "news.txt" file */
\r
5551 validate_file(path);
\r
5554 #if 0 /* #ifndef JP */
\r
5555 /* Build the "font" path */
\r
5556 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "font");
\r
5558 /* Allocate the path */
\r
5559 ANGBAND_DIR_XTRA_FONT = string_make(path);
\r
5561 /* Validate the "font" directory */
\r
5562 validate_dir(ANGBAND_DIR_XTRA_FONT, TRUE);
\r
5564 /* Build the filename */
\r
5565 path_build(path, sizeof(path), ANGBAND_DIR_XTRA_FONT, "8X13.FON");
\r
5567 /* Hack -- Validate the basic font */
\r
5568 validate_file(path);
\r
5572 #ifdef USE_GRAPHICS
\r
5574 /* Build the "graf" path */
\r
5575 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
\r
5577 /* Allocate the path */
\r
5578 ANGBAND_DIR_XTRA_GRAF = string_make(path);
\r
5580 /* Validate the "graf" directory */
\r
5581 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
\r
5583 #endif /* USE_GRAPHICS */
\r
5588 /* Build the "sound" path */
\r
5589 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
\r
5591 /* Allocate the path */
\r
5592 ANGBAND_DIR_XTRA_SOUND = string_make(path);
\r
5594 /* Validate the "sound" directory */
\r
5595 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
\r
5597 #endif /* USE_SOUND */
\r
5601 /* Build the "music" path */
\r
5602 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
\r
5604 /* Allocate the path */
\r
5605 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
\r
5607 /* Validate the "music" directory */
\r
5608 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
\r
5610 #endif /* USE_MUSIC */
\r
5612 /* Build the "help" path */
\r
5613 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
\r
5615 /* Allocate the path */
\r
5616 ANGBAND_DIR_XTRA_HELP = string_make(path);
\r
5618 /* Validate the "help" directory */
\r
5619 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
\r
5622 bool is_already_running()
\r
5624 bool result = FALSE;
\r
5627 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
\r
5628 if (GetLastError() == ERROR_ALREADY_EXISTS)
\r
5636 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
\r
5637 LPSTR lpCmdLine, int nCmdShow)
\r
5645 setlocale( LC_ALL, "ja_JP" );
\r
5650 /* Save globally */
\r
5651 hInstance = hInst;
\r
5654 /* Prevent multiple run */
\r
5655 if (is_already_running())
\r
5658 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
\r
5659 _("エラー!", "Error") ,
\r
5660 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
\r
5665 if (hPrevInst == NULL)
\r
5667 wc.style = CS_CLASSDC;
\r
5668 wc.lpfnWndProc = AngbandWndProc;
\r
5669 wc.cbClsExtra = 0;
\r
5670 wc.cbWndExtra = 4; /* one long pointer to term_data */
\r
5671 wc.hInstance = hInst;
\r
5672 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
\r
5673 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
\r
5674 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
\r
5675 wc.lpszMenuName = AppName;
\r
5676 wc.lpszClassName = AppName;
\r
5678 if (!RegisterClass(&wc)) exit(1);
\r
5680 wc.lpfnWndProc = AngbandListProc;
\r
5681 wc.lpszMenuName = NULL;
\r
5682 wc.lpszClassName = AngList;
\r
5684 if (!RegisterClass(&wc)) exit(2);
\r
5688 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
\r
5689 wc.lpfnWndProc = AngbandSaverProc;
\r
5690 wc.hCursor = NULL;
\r
5691 wc.lpszMenuName = NULL;
\r
5692 wc.lpszClassName = "WindowsScreenSaverClass";
\r
5694 if (!RegisterClass(&wc)) exit(3);
\r
5700 /* Temporary hooks */
\r
5701 plog_aux = hack_plog;
\r
5702 quit_aux = hack_quit;
\r
5703 core_aux = hack_quit;
\r
5705 /* Prepare the filepaths */
\r
5708 /* Initialize the keypress analyzer */
\r
5709 for (i = 0; special_key_list[i]; ++i)
\r
5711 special_key[special_key_list[i]] = TRUE;
\r
5713 /* Initialize the keypress analyzer */
\r
5714 for (i = 0; ignore_key_list[i]; ++i)
\r
5716 ignore_key[ignore_key_list[i]] = TRUE;
\r
5719 /* Determine if display is 16/256/true color */
\r
5720 hdc = GetDC(NULL);
\r
5721 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
\r
5722 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
\r
5723 ReleaseDC(NULL, hdc);
\r
5725 /* Initialize the colors */
\r
5726 for (i = 0; i < 256; i++)
\r
5730 /* Extract desired values */
\r
5731 rv = angband_color_table[i][1];
\r
5732 gv = angband_color_table[i][2];
\r
5733 bv = angband_color_table[i][3];
\r
5735 /* Extract the "complex" code */
\r
5736 win_clr[i] = PALETTERGB(rv, gv, bv);
\r
5738 /* Save the "simple" code */
\r
5739 angband_color_table[i][0] = win_pal[i];
\r
5742 /* Prepare the windows */
\r
5748 /* Activate hooks */
\r
5749 plog_aux = hook_plog;
\r
5750 quit_aux = hook_quit;
\r
5751 core_aux = hook_quit;
\r
5753 /* Set the system suffix */
\r
5754 ANGBAND_SYS = "win";
\r
5756 /* Set the keyboard suffix */
\r
5757 if (7 != GetKeyboardType(0))
\r
5758 ANGBAND_KEYBOARD = "0";
\r
5761 /* Japanese keyboard */
\r
5762 switch (GetKeyboardType(1))
\r
5764 case 0x0D01: case 0x0D02:
\r
5765 case 0x0D03: case 0x0D04:
\r
5766 case 0x0D05: case 0x0D06:
\r
5768 ANGBAND_KEYBOARD = "NEC98";
\r
5772 ANGBAND_KEYBOARD = "JAPAN";
\r
5776 /* Catch nasty signals */
\r
5780 Term_activate(term_screen);
\r
5783 /* We are now initialized */
\r
5784 initialized = TRUE;
\r
5786 if(lpCmdLine[0] == '-'){
\r
5787 switch(lpCmdLine[1])
\r
5792 if (!lpCmdLine[2]) break;
\r
5793 chuukei_server = TRUE;
\r
5794 if(connect_chuukei_server(&lpCmdLine[2])<0){
\r
5795 msg_print("connect fail");
\r
5798 msg_print("connect");
\r
5806 if (!lpCmdLine[2]) break;
\r
5807 chuukei_client = TRUE;
\r
5808 connect_chuukei_server(&lpCmdLine[2]);
\r
5816 if (!lpCmdLine[2]) break;
\r
5817 prepare_browse_movie(&lpCmdLine[2]);
\r
5827 /* Did the user double click on a save file? */
\r
5828 if(!chuukei_server) check_for_save_file(lpCmdLine);
\r
5830 /* Did the user double click on a save file? */
\r
5831 check_for_save_file(lpCmdLine);
\r
5834 /* Prompt the user */
\r
5835 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
\r
5839 /* Process messages forever */
\r
5840 while (GetMessage(&msg, NULL, 0, 0))
\r
5842 TranslateMessage(&msg);
\r
5843 DispatchMessage(&msg);
\r
5854 #endif /* WINDOWS */
\r