2 * todo main関数を含むファイルの割に長過ぎる。main-win-utils.cなどといった形で分割したい
4 * @brief Windows版固有実装(メインエントリポイント含む)
6 * @author Hengband Team
10 * Windows98かその前後の頃を起点としたAPI実装。
12 * DirectXといった昨今描画に標準的となったライブラリも用いていない。
13 * タイルの描画処理などについては、現在動作の詳細を検証中。
17 * Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others
19 * This software may be copied and distributed for educational, research,
20 * and not for profit purposes provided that this copyright and statement
21 * are included in all such copies.
24 * This file helps Angband work with Windows computers.
26 * To use this file, use an appropriate "Makefile" or "Project File",
27 * make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and
28 * make sure to obtain various extra files as described below.
30 * The official compilation uses the CodeWarrior Pro compiler, which
31 * includes a special project file and precompilable header file.
35 * <del>See also "main-dos.c" and "main-ibm.c".</del>
39 * The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
40 * and/or color redefinitions.
44 * The "lib/user/font-win.prf" contains attr/char mappings for use with the
45 * normal "lib/xtra/font/*.fon" font files.
49 * The "lib/user/graf-win.prf" contains attr/char mappings for use with the
50 * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
55 * Compiling this file, and using the resulting executable, requires
56 * several extra files not distributed with the standard Angband code.
57 * In any case, some "*.fon" files (including "8X13.FON" if nothing else)
58 * must be placed into "lib/xtra/font/". All of these extra files can be found
59 * in the "ext-win" archive.
63 * The "term_xtra_win_clear()" function should probably do a low-level
64 * clear of the current window, and redraw the borders and other things,
65 * if only for efficiency.
69 * A simpler method is needed for selecting the "tile size" for windows.
73 * The various "warning" messages assume the existance of the "screen.w"
74 * window, I think, and only a few calls actually check for its existance,
75 * this may be okay since "NULL" means "on top of all windows". (?) The
76 * user must never be allowed to "hide" the main window, or the "menubar"
81 * Special "Windows Help Files" can be placed into "lib/xtra/help/" for
82 * use with the "winhelp.exe" program. These files *may* be available
83 * at the ftp site somewhere, but I have not seen them.
87 * Initial framework (and most code) by Ben Harrison (benh@phial.com).
89 * Original code by Skirmantas Kligys (kligys@scf.usc.edu).
91 * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
92 * and Chris R. Martin (crm7479@tam2000.tamu.edu).
100 #include "cmd-dump.h"
101 #include "view-mainwindow.h"
103 #include "floor-events.h"
122 * Extract the "WIN32" flag from the compiler
124 #if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__)
131 * Available graphic modes
133 #define GRAPHICS_NONE 0
134 #define GRAPHICS_ORIGINAL 1
135 #define GRAPHICS_ADAM_BOLT 2
136 #define GRAPHICS_HENGBAND 3
139 * Hack -- allow use of "screen saver" mode
145 * Menu constants -- see "ANGBAND.RC"
148 #define IDM_FILE_NEW 100
149 #define IDM_FILE_OPEN 101
150 #define IDM_FILE_SAVE 110
151 #define IDM_FILE_SCORE 120
152 #define IDM_FILE_MOVIE 121
153 #define IDM_FILE_EXIT 130
155 #define IDM_WINDOW_VIS_0 200
156 #define IDM_WINDOW_VIS_1 201
157 #define IDM_WINDOW_VIS_2 202
158 #define IDM_WINDOW_VIS_3 203
159 #define IDM_WINDOW_VIS_4 204
160 #define IDM_WINDOW_VIS_5 205
161 #define IDM_WINDOW_VIS_6 206
162 #define IDM_WINDOW_VIS_7 207
164 #define IDM_WINDOW_FONT_0 210
165 #define IDM_WINDOW_FONT_1 211
166 #define IDM_WINDOW_FONT_2 212
167 #define IDM_WINDOW_FONT_3 213
168 #define IDM_WINDOW_FONT_4 214
169 #define IDM_WINDOW_FONT_5 215
170 #define IDM_WINDOW_FONT_6 216
171 #define IDM_WINDOW_FONT_7 217
173 #define IDM_WINDOW_POS_0 220
174 #define IDM_WINDOW_POS_1 221
175 #define IDM_WINDOW_POS_2 222
176 #define IDM_WINDOW_POS_3 223
177 #define IDM_WINDOW_POS_4 224
178 #define IDM_WINDOW_POS_5 225
179 #define IDM_WINDOW_POS_6 226
180 #define IDM_WINDOW_POS_7 227
182 #define IDM_WINDOW_BIZ_0 230
183 #define IDM_WINDOW_BIZ_1 231
184 #define IDM_WINDOW_BIZ_2 232
185 #define IDM_WINDOW_BIZ_3 233
186 #define IDM_WINDOW_BIZ_4 234
187 #define IDM_WINDOW_BIZ_5 235
188 #define IDM_WINDOW_BIZ_6 236
189 #define IDM_WINDOW_BIZ_7 237
191 #define IDM_WINDOW_I_WID_0 240
192 #define IDM_WINDOW_I_WID_1 241
193 #define IDM_WINDOW_I_WID_2 242
194 #define IDM_WINDOW_I_WID_3 243
195 #define IDM_WINDOW_I_WID_4 244
196 #define IDM_WINDOW_I_WID_5 245
197 #define IDM_WINDOW_I_WID_6 246
198 #define IDM_WINDOW_I_WID_7 247
200 #define IDM_WINDOW_D_WID_0 250
201 #define IDM_WINDOW_D_WID_1 251
202 #define IDM_WINDOW_D_WID_2 252
203 #define IDM_WINDOW_D_WID_3 253
204 #define IDM_WINDOW_D_WID_4 254
205 #define IDM_WINDOW_D_WID_5 255
206 #define IDM_WINDOW_D_WID_6 256
207 #define IDM_WINDOW_D_WID_7 257
209 #define IDM_WINDOW_I_HGT_0 260
210 #define IDM_WINDOW_I_HGT_1 261
211 #define IDM_WINDOW_I_HGT_2 262
212 #define IDM_WINDOW_I_HGT_3 263
213 #define IDM_WINDOW_I_HGT_4 264
214 #define IDM_WINDOW_I_HGT_5 265
215 #define IDM_WINDOW_I_HGT_6 266
216 #define IDM_WINDOW_I_HGT_7 267
218 #define IDM_WINDOW_D_HGT_0 270
219 #define IDM_WINDOW_D_HGT_1 271
220 #define IDM_WINDOW_D_HGT_2 272
221 #define IDM_WINDOW_D_HGT_3 273
222 #define IDM_WINDOW_D_HGT_4 274
223 #define IDM_WINDOW_D_HGT_5 275
224 #define IDM_WINDOW_D_HGT_6 276
225 #define IDM_WINDOW_D_HGT_7 277
227 #define IDM_OPTIONS_NO_GRAPHICS 400
228 #define IDM_OPTIONS_OLD_GRAPHICS 401
229 #define IDM_OPTIONS_NEW_GRAPHICS 402
230 #define IDM_OPTIONS_NEW2_GRAPHICS 403
231 #define IDM_OPTIONS_BIGTILE 409
232 #define IDM_OPTIONS_SOUND 410
233 #define IDM_OPTIONS_MUSIC 411
234 #define IDM_OPTIONS_SAVER 420
235 #define IDM_OPTIONS_MAP 430
236 #define IDM_OPTIONS_BG 440
237 #define IDM_OPTIONS_OPEN_BG 441
239 #define IDM_DUMP_SCREEN_HTML 450
241 #define IDM_HELP_CONTENTS 901
244 * Exclude parts of WINDOWS.H that are not needed
246 #define NOCOMM /* Comm driver APIs and definitions */
247 #define NOLOGERROR /* LogError() and related definitions */
248 #define NOPROFILER /* Profiler APIs */
249 #define NOLFILEIO /* _l* file I/O routines */
250 #define NOOPENFILE /* OpenFile and related definitions */
251 #define NORESOURCE /* Resource management */
252 #define NOATOM /* Atom management */
253 #define NOLANGUAGE /* Character test routines */
254 #define NOLSTRING /* lstr* string management routines */
255 #define NODBCS /* Double-byte character set routines */
256 #define NOKEYBOARDINFO /* Keyboard driver routines */
257 #define NOCOLOR /* COLOR_* color values */
258 #define NODRAWTEXT /* DrawText() and related definitions */
259 #define NOSCALABLEFONT /* Truetype scalable font support */
260 #define NOMETAFILE /* Metafile support */
261 #define NOSYSTEMPARAMSINFO /* SystemParametersInfo() and SPI_* definitions */
262 #define NODEFERWINDOWPOS /* DeferWindowPos and related definitions */
263 #define NOKEYSTATES /* MK_* message key state flags */
264 #define NOWH /* SetWindowsHook and related WH_* definitions */
265 #define NOCLIPBOARD /* Clipboard APIs and definitions */
266 #define NOICONS /* IDI_* icon IDs */
267 #define NOMDI /* MDI support */
268 #define NOHELP /* Help support */
270 /* Not defined since it breaks Borland C++ 5.5 */
271 /* #define NOCTLMGR */ /* Control management and controls */
274 * Exclude parts of WINDOWS.H that are not needed (Win32)
276 #define WIN32_LEAN_AND_MEAN
277 #define NONLS /* All NLS defines and routines */
278 #define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
279 #define NOKANJI /* Kanji support stuff. */
280 #define NOMCX /* Modem Configuration Extensions */
283 * Include the "windows" support file
288 * Exclude parts of MMSYSTEM.H that are not needed
290 #define MMNODRV /* Installable driver support */
291 #define MMNOWAVE /* Waveform support */
292 #define MMNOMIDI /* MIDI support */
293 #define MMNOAUX /* Auxiliary audio support */
294 #define MMNOTIMER /* Timer support */
295 #define MMNOJOY /* Joystick support */
296 #define MMNOMCI /* MCI support */
297 #define MMNOMMIO /* Multimedia file I/O support */
298 #define MMNOMMSYSTEM /* General MMSYSTEM functions */
302 * Standard sound names
304 const concptr angband_sound_name[SOUND_MAX] =
376 * Standard music names
378 const concptr angband_music_basic_name[MUSIC_BASIC_MAX] =
404 * Include some more files. Note: the Cygnus Cygwin compiler
405 * doesn't use mmsystem.h instead it includes the winmm library
406 * which performs a similar function.
408 #include <mmsystem.h>
412 * HTML-Help requires htmlhelp.h and htmlhelp.lib from Microsoft's
413 * HTML Workshop < http://msdn.microsoft.com/workshop/author/htmlhelp/ >.
415 /* #define HTML_HELP */
418 #include <htmlhelp.h>
419 #endif /* HTML_HELP */
422 * Include the support for loading bitmaps
427 * Hack -- Fake declarations from "dos.h"
430 #define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
432 #define FA_LABEL 0x08 /* Volume label */
433 #define FA_DIREC 0x10 /* Directory */
434 unsigned _cdecl _dos_getfileattr(concptr, unsigned *);
438 * Silliness in WIN32 drawing routine
441 # define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL)
445 * Silliness for Windows 95
447 #ifndef WS_EX_TOOLWINDOW
448 # define WS_EX_TOOLWINDOW 0
452 * Foreground color bits (hard-coded by DOS)
454 #define VID_BLACK 0x00
455 #define VID_BLUE 0x01
456 #define VID_GREEN 0x02
457 #define VID_CYAN 0x03
459 #define VID_MAGENTA 0x05
460 #define VID_YELLOW 0x06
461 #define VID_WHITE 0x07
464 * Bright text (hard-coded by DOS)
466 #define VID_BRIGHT 0x08
469 * Background color bits (hard-coded by DOS)
471 #define VUD_BLACK 0x00
472 #define VUD_BLUE 0x10
473 #define VUD_GREEN 0x20
474 #define VUD_CYAN 0x30
476 #define VUD_MAGENTA 0x50
477 #define VUD_YELLOW 0x60
478 #define VUD_WHITE 0x70
481 * Blinking text (hard-coded by DOS)
483 #define VUD_BRIGHT 0x80
489 typedef struct _term_data term_data;
493 * @brief ターム情報構造体 / Extra "term" data
496 * pos_x / pos_y は各タームの左上点座標を指す。
499 * tile_wid / tile_hgt は[ウィンドウ]メニューのタイルの幅/高さを~を
500 * 1ドットずつ調整するステータスを指す。
501 * また、フォントを変更すると都度自動調整される。
504 * Note the use of "font_want" for the names of the font file requested by
505 * the user, and the use of "font_file" for the currently active font file.
507 * The "font_file" is uppercased, and takes the form "8X13.FON", while
508 * "font_want" can be in almost any form as long as it could be construed
509 * as attempting to represent the name of a font.
521 TERM_LEN rows; /* int -> uint */
524 uint pos_x; //!< タームの左上X座標
525 uint pos_y; //!< タームの左上Y座標
540 int font_wid; //!< フォント横幅
541 int font_hgt; //!< フォント縦幅
542 int tile_wid; //!< タイル横幅
543 int tile_hgt; //!< タイル縦幅
555 #define MAX_TERM_DATA 8 //!< Maximum number of windows
557 static term_data data[MAX_TERM_DATA]; //!< An array of term_data's
558 static term_data *my_td; //!< Hack -- global "window creation" pointer
559 POINT normsize; //!< Remember normal size of main window when maxmized
562 * was main window maximized on previous playing
564 bool win_maximized = FALSE;
569 bool game_in_progress = FALSE;
572 * note when "open"/"new" become valid
574 bool initialized = FALSE;
577 * screen paletted, i.e. 256 colors
579 bool paletted = FALSE;
582 * 16 colors screen, don't use RGB()
584 bool colors16 = FALSE;
587 * Saved instance handle
589 static HINSTANCE hInstance;
592 * Yellow brush for the cursor
594 static HBRUSH hbrYellow;
604 static HPALETTE hPal;
607 static HBITMAP hBG = NULL;
608 static int use_bg = 0; //!< 背景使用フラグ、1なら私用。
609 static char bg_bitmap_file[1024] = "bg.bmp"; //!< 現在の背景ビットマップファイル名。
614 * The screen saver window
616 static HWND hwndSaver;
618 #endif /* USE_SAVER */
622 * 現在使用中のタイルID(0ならば未使用)
623 * Flag set once "graphics" has been initialized
625 static byte_hack current_graphics_mode = 0;
630 static DIBINIT infGraph;
633 * The global bitmap mask
635 static DIBINIT infMask;
639 * Flag set once "sound" has been initialized
641 static bool can_use_sound = FALSE;
643 #define SAMPLE_SOUND_MAX 16
645 * An array of sound file names
647 static concptr sound_file[SOUND_MAX][SAMPLE_SOUND_MAX];
649 #define SAMPLE_MUSIC_MAX 16
650 static concptr music_file[MUSIC_BASIC_MAX][SAMPLE_MUSIC_MAX];
651 static concptr dungeon_music_file[1000][SAMPLE_MUSIC_MAX];
652 static concptr town_music_file[1000][SAMPLE_MUSIC_MAX];
653 static concptr quest_music_file[1000][SAMPLE_MUSIC_MAX];
654 static bool can_use_music = FALSE;
656 static MCI_OPEN_PARMS mop;
657 static char mci_device_type[256];
659 int current_music_type = 0;
660 int current_music_id = 0;
663 * Full path to ANGBAND.INI
665 static concptr ini_file = NULL;
668 * Name of application
670 static concptr AppName = "ANGBAND";
673 * Name of sub-window type
675 static concptr AngList = "AngList";
680 static concptr ANGBAND_DIR_XTRA_GRAF;
681 static concptr ANGBAND_DIR_XTRA_SOUND;
682 static concptr ANGBAND_DIR_XTRA_MUSIC;
683 static concptr ANGBAND_DIR_XTRA_HELP;
684 static concptr ANGBAND_DIR_XTRA_MUSIC;
687 * The "complex" color values
689 static COLORREF win_clr[256];
693 * Flag for macro trigger with dump ASCII
695 static bool term_no_press = FALSE;
700 static bool mouse_down = FALSE;
701 static bool paint_rect = FALSE;
702 static TERM_LEN mousex = 0, mousey = 0;
703 static TERM_LEN oldx, oldy;
707 * @brief The "simple" color values
709 * See "main-ibm.c" for original table information
710 * The entries below are taken from the "color bits" defined above.
711 * Note that many of the choices below suck, but so do crappy monitors.
713 static BYTE win_pal[256] =
715 VID_BLACK, /* Dark */
716 VID_WHITE, /* White */
717 VID_CYAN, /* Slate XXX */
718 VID_RED | VID_BRIGHT, /* Orange XXX */
720 VID_GREEN, /* Green */
722 VID_YELLOW, /* Umber XXX */
723 VID_BLACK | VID_BRIGHT, /* Light Dark */
724 VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
725 VID_MAGENTA, /* Violet XXX */
726 VID_YELLOW | VID_BRIGHT, /* Yellow */
727 VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
728 VID_GREEN | VID_BRIGHT, /* Light Green */
729 VID_BLUE | VID_BRIGHT, /* Light Blue */
730 VID_YELLOW /* Light Umber XXX */
735 * Hack -- define which keys are "special"
737 static bool special_key[256];
738 static bool ignore_key[256];
741 * Hack -- initialization list for "special_key"
743 static byte special_key_list[] = {
744 VK_CLEAR, VK_PAUSE, VK_CAPITAL,
745 VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI,
746 VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE,
747 VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
748 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN,
749 VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT,
750 VK_INSERT, VK_DELETE, VK_HELP, VK_APPS,
751 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
752 VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
753 VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD,
754 VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE,
755 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
756 VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
757 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
758 VK_F19,VK_F20, VK_F21, VK_F22, VK_F23, VK_F24,
759 VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL,
760 VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM,
765 static byte ignore_key_list[] = {
766 VK_ESCAPE, VK_TAB, VK_SPACE,
767 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
768 VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN,
769 VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL,
774 /* Function prototype */
776 static bool is_already_running(void);
780 static void delete_bg(void)
789 static int init_bg(void)
791 char * bmfile = bg_bitmap_file;
794 if (use_bg == 0) return 0;
796 hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
798 plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
806 static void DrawBG(HDC hdc, RECT *r)
811 int x = r->left, y = r->top;
812 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
818 GetObject(hBG, sizeof(bm), &bm);
819 swid = bm.bmWidth; shgt = bm.bmHeight;
821 hdcSrc = CreateCompatibleDC(hdc);
822 hOld = SelectObject(hdcSrc, hBG);
826 cwid = MIN(swid - sx, r->right - nx);
829 chgt = MIN(shgt - sy, r->bottom - ny);
830 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
832 } while (ny < r->bottom);
835 } while (nx < r->right);
837 SelectObject(hdcSrc, hOld);
843 * Check for existance of a file
845 static bool check_file(concptr s)
865 attrib = GetFileAttributes(path);
867 /* Require valid filename */
868 if (attrib == INVALID_FILE_NAME) return FALSE;
870 /* Prohibit directory */
871 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return FALSE;
875 /* Examine and verify */
876 if (_dos_getfileattr(path, &attrib)) return FALSE;
878 /* Prohibit something */
879 if (attrib & FA_LABEL) return FALSE;
881 /* Prohibit directory */
882 if (attrib & FA_DIREC) return FALSE;
892 * Check for existance of a directory
894 static bool check_dir(concptr s)
916 /* Remove trailing backslash */
917 if (i && (path[i - 1] == '\\')) path[--i] = '\0';
922 attrib = GetFileAttributes(path);
924 /* Require valid filename */
925 if (attrib == INVALID_FILE_NAME) return FALSE;
927 /* Require directory */
928 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return FALSE;
932 /* Examine and verify */
933 if (_dos_getfileattr(path, &attrib)) return FALSE;
935 /* Prohibit something */
936 if (attrib & FA_LABEL) return FALSE;
938 /* Require directory */
939 if (!(attrib & FA_DIREC)) return FALSE;
951 static void validate_file(concptr s)
956 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
962 * Validate a directory
964 static void validate_dir(concptr s, bool vital)
969 /* This directory contains needed data */
972 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
974 /* Attempt to create this directory */
977 quit_fmt("Unable to create directory:\n%s", s);
984 * @brief (Windows版固有実装)Get the "size" for a window
986 static void term_getsize(term_data *td)
990 if (td->cols < 1) td->cols = 1;
991 if (td->rows < 1) td->rows = 1;
994 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
995 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
997 /* Fake window size */
999 rc.right = rc.left + wid;
1001 rc.bottom = rc.top + hgt;
1003 /* rc.right += 1; */
1004 /* rc.bottom += 1; */
1007 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
1010 td->size_wid = rc.right - rc.left;
1011 td->size_hgt = rc.bottom - rc.top;
1013 /* See CreateWindowEx */
1016 /* Extract actual location */
1017 GetWindowRect(td->w, &rc);
1019 /* Save the location */
1020 td->pos_x = rc.left;
1026 * Write the "prefs" for a single term
1028 static void save_prefs_aux(int i)
1030 term_data *td = &data[i];
1031 GAME_TEXT sec_name[128];
1035 WINDOWPLACEMENT lpwndpl;
1038 /* Make section name */
1039 sprintf(sec_name, "Term-%d", i);
1044 strcpy(buf, td->visible ? "1" : "0");
1045 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
1050 strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "MS ゴシック");
1052 strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "Courier");
1055 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
1057 wsprintf(buf, "%d", td->lf.lfWidth);
1058 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
1059 wsprintf(buf, "%d", td->lf.lfHeight);
1060 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
1061 wsprintf(buf, "%d", td->lf.lfWeight);
1062 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
1064 strcpy(buf, td->bizarre ? "1" : "0");
1065 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
1068 wsprintf(buf, "%d", td->tile_wid);
1069 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
1072 wsprintf(buf, "%d", td->tile_hgt);
1073 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
1075 /* Get window placement and dimensions */
1076 lpwndpl.length = sizeof(WINDOWPLACEMENT);
1077 GetWindowPlacement(td->w, &lpwndpl);
1079 /* Acquire position in *normal* mode (not minimized) */
1080 rc = lpwndpl.rcNormalPosition;
1082 /* Window size (x) */
1083 if (i == 0) wsprintf(buf, "%d", normsize.x);
1084 else wsprintf(buf, "%d", td->cols);
1085 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
1087 /* Window size (y) */
1088 if (i == 0) wsprintf(buf, "%d", normsize.y);
1089 else wsprintf(buf, "%d", td->rows);
1090 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
1092 /* Maxmized (only main window) */
1095 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
1096 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
1099 /* Acquire position */
1100 GetWindowRect(td->w, &rc);
1102 /* Window position (x) */
1103 wsprintf(buf, "%d", rc.left);
1104 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
1106 /* Window position (y) */
1107 wsprintf(buf, "%d", rc.top);
1108 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
1110 /* Window Z position */
1113 strcpy(buf, td->posfix ? "1" : "0");
1114 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
1121 * We assume that the windows have all been initialized
1123 static void save_prefs(void)
1129 /* Save the "arg_graphics" flag */
1130 sprintf(buf, "%d", arg_graphics);
1131 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
1133 /* Save the "arg_bigtile" flag */
1134 strcpy(buf, arg_bigtile ? "1" : "0");
1135 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
1137 /* Save the "arg_sound" flag */
1138 strcpy(buf, arg_sound ? "1" : "0");
1139 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
1141 /* Save the "arg_sound" flag */
1142 strcpy(buf, arg_music ? "1" : "0");
1143 WritePrivateProfileString("Angband", "Music", buf, ini_file);
1146 strcpy(buf, use_bg ? "1" : "0");
1147 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
1148 WritePrivateProfileString("Angband", "BackGroundBitmap",
1149 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
1151 /* Save window prefs */
1152 for (i = 0; i < MAX_TERM_DATA; ++i)
1160 * Load the "prefs" for a single term
1162 static void load_prefs_aux(int i)
1164 term_data *td = &data[i];
1165 GAME_TEXT sec_name[128];
1168 int wid, hgt, posx, posy;
1169 int dispx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
1170 int dispy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
1174 /* Make section name */
1175 sprintf(sec_name, "Term-%d", i);
1177 /* Make section name */
1178 sprintf(sec_name, "Term-%d", i);
1183 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
1186 /* Desired font, with default */
1188 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
1190 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
1195 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
1197 /* Analyze font, save desired font name */
1198 td->font_want = string_make(tmp);
1200 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
1201 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
1202 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
1205 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
1206 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
1209 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
1210 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
1211 normsize.x = td->cols; normsize.y = td->rows;
1216 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
1219 /* Window position */
1220 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
1221 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
1222 td->pos_x = MIN(MAX(0, posx), dispx - 128);
1223 td->pos_y = MIN(MAX(0, posy), dispy - 128);
1225 /* Window Z position */
1228 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
1236 static void load_prefs(void)
1240 /* Extract the "arg_graphics" flag */
1241 arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
1243 /* Extract the "arg_bigtile" flag */
1244 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
1245 use_bigtile = arg_bigtile;
1247 /* Extract the "arg_sound" flag */
1248 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
1250 /* Extract the "arg_sound" flag */
1251 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
1254 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
1255 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
1257 /* Load window prefs */
1258 for (i = 0; i < MAX_TERM_DATA; ++i)
1266 * - Taken from files.c.
1268 * Extract "tokens" from a buffer
1270 * This function uses "whitespace" as delimiters, and treats any amount of
1271 * whitespace as a single delimiter. We will never return any empty tokens.
1272 * When given an empty buffer, or a buffer containing only "whitespace", we
1273 * will return no tokens. We will never extract more than "num" tokens.
1275 * By running a token through the "text_to_ascii()" function, you can allow
1276 * that token to include (encoded) whitespace, using "\s" to encode spaces.
1278 * We save pointers to the tokens in "tokens", and return the number found.
1280 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
1290 /* Skip leading whitespace */
1291 for (; *s && iswspace(*s); ++s) /* loop */;
1296 /* Find next whitespace, if any */
1297 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
1299 /* Nuke and advance (if necessary) */
1300 if (*t) *t++ = '\0';
1302 /* Save the token */
1314 static void load_sound_prefs(void)
1318 char ini_path[1024];
1319 char wav_path[1024];
1320 char *zz[SAMPLE_SOUND_MAX];
1322 /* Access the sound.cfg */
1324 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
1326 for (i = 0; i < SOUND_MAX; i++)
1328 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
1330 num = tokenize_whitespace(tmp, SAMPLE_SOUND_MAX, zz);
1332 for (j = 0; j < num; j++)
1334 /* Access the sound */
1335 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
1337 /* Save the sound filename, if it exists */
1338 if (check_file(wav_path))
1339 sound_file[i][j] = string_make(zz[j]);
1345 static void load_music_prefs(void)
1349 char ini_path[1024];
1350 char wav_path[1024];
1351 char *zz[SAMPLE_MUSIC_MAX];
1354 /* Access the music.cfg */
1356 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
1358 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
1360 for (i = 0; i < MUSIC_BASIC_MAX; i++)
1362 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
1364 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
1366 for (j = 0; j < num; j++)
1368 /* Access the sound */
1369 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
1371 /* Save the sound filename, if it exists */
1372 if (check_file(wav_path))
1373 music_file[i][j] = string_make(zz[j]);
1377 for (i = 0; i < current_world_ptr->max_d_idx; i++)
1379 sprintf(key, "dungeon%03d", i);
1380 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
1382 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
1384 for (j = 0; j < num; j++)
1386 /* Access the sound */
1387 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
1389 /* Save the sound filename, if it exists */
1390 if (check_file(wav_path))
1391 dungeon_music_file[i][j] = string_make(zz[j]);
1395 for (i = 0; i < max_q_idx; i++)
1397 sprintf(key, "quest%03d", i);
1398 GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
1400 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
1402 for (j = 0; j < num; j++)
1404 /* Access the sound */
1405 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
1407 /* Save the sound filename, if it exists */
1408 if (check_file(wav_path))
1409 quest_music_file[i][j] = string_make(zz[j]);
1413 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
1415 sprintf(key, "town%03d", i);
1416 GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
1418 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
1420 for (j = 0; j < num; j++)
1422 /* Access the sound */
1423 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
1425 /* Save the sound filename, if it exists */
1426 if (check_file(wav_path))
1427 town_music_file[i][j] = string_make(zz[j]);
1436 * Create the new global palette based on the bitmap palette
1437 * (if any), and the standard 16 entry palette derived from
1438 * "win_clr[]" which is used for the basic 16 Angband colors.
1440 * This function is never called before all windows are ready.
1442 * This function returns FALSE if the new palette could not be
1443 * prepared, which should normally be a fatal error. XXX XXX
1445 * Note that only some machines actually use a "palette".
1447 static int new_palette(void)
1455 LPLOGPALETTE pLogPal;
1456 LPPALETTEENTRY lppe;
1461 /* This makes no sense */
1462 if (!paletted) return TRUE;
1470 /* Check the bitmap palette */
1471 hBmPal = infGraph.hPalette;
1473 /* Use the bitmap */
1476 lppeSize = 256 * sizeof(PALETTEENTRY);
1477 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
1478 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
1479 if ((nEntries == 0) || (nEntries > 220))
1482 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
1485 rnfree(lppe, lppeSize);
1492 /* Size of palette */
1493 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
1495 /* Allocate palette */
1496 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
1499 pLogPal->palVersion = 0x300;
1501 /* Make room for bitmap and normal data */
1502 pLogPal->palNumEntries = nEntries + 16;
1504 /* Save the bitmap data */
1505 for (i = 0; i < nEntries; i++)
1507 pLogPal->palPalEntry[i] = lppe[i];
1510 /* Save the normal data */
1511 for (i = 0; i < 16; i++)
1515 /* Access the entry */
1516 p = &(pLogPal->palPalEntry[i + nEntries]);
1518 /* Save the colors */
1519 p->peRed = GetRValue(win_clr[i]);
1520 p->peGreen = GetGValue(win_clr[i]);
1521 p->peBlue = GetBValue(win_clr[i]);
1523 /* Save the flags */
1524 p->peFlags = PC_NOCOLLAPSE;
1527 /* Free something */
1528 if (lppe) rnfree(lppe, lppeSize);
1530 /* Create a new palette, or fail */
1531 hNewPal = CreatePalette(pLogPal);
1532 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
1534 /* Free the palette */
1535 rnfree(pLogPal, pLogPalSize);
1540 /* Realize the palette */
1542 SelectPalette(hdc, hNewPal, 0);
1543 i = RealizePalette(hdc);
1544 ReleaseDC(td->w, hdc);
1545 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
1549 for (i = 1; i < MAX_TERM_DATA; i++)
1554 SelectPalette(hdc, hNewPal, 0);
1555 ReleaseDC(td->w, hdc);
1558 /* Delete old palette */
1559 if (hPal) DeleteObject(hPal);
1561 /* Save new palette */
1570 * @brief グラフィクスを初期化する / Initialize graphics
1573 * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
1574 * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
1577 static bool init_graphics(void)
1579 /* Initialize once */
1581 BYTE wid, hgt, twid, thgt, ox, oy;
1584 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1594 ANGBAND_GRAF = "new";
1596 else if (arg_graphics == GRAPHICS_HENGBAND)
1616 ANGBAND_GRAF = "ne2";
1627 ANGBAND_GRAF = "old";
1630 /* Access the bitmap file */
1631 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
1633 /* Load the bitmap or quit */
1634 if (!ReadDIB(data[0].w, buf, &infGraph))
1636 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
1640 /* Save the new sizes */
1641 infGraph.CellWidth = wid;
1642 infGraph.CellHeight = hgt;
1643 infGraph.TileWidth = twid;
1644 infGraph.TileHeight = thgt;
1645 infGraph.OffsetX = ox;
1646 infGraph.OffsetY = oy;
1648 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1650 /* Access the mask file */
1651 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
1653 /* Load the bitmap or quit */
1654 if (!ReadDIB(data[0].w, buf, &infMask))
1656 plog_fmt("Cannot read bitmap file '%s'", buf);
1660 if (arg_graphics == GRAPHICS_HENGBAND)
1662 /* Access the mask file */
1663 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
1665 /* Load the bitmap or quit */
1666 if (!ReadDIB(data[0].w, buf, &infMask))
1668 plog_fmt("Cannot read bitmap file '%s'", buf);
1673 /* Activate a palette */
1678 plog(_("パレットを実現できません!", "Cannot activate palette!"));
1682 /* Graphics available */
1683 current_graphics_mode = arg_graphics;
1684 return (current_graphics_mode);
1691 static bool init_music(void)
1693 /* Initialize once */
1696 /* Load the prefs */
1699 /* Sound available */
1700 can_use_music = TRUE;
1702 return (can_use_music);
1706 * Hack -- Stop a music
1708 static void stop_music(void)
1710 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
1711 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
1718 static bool init_sound(void)
1720 /* Initialize once */
1723 /* Load the prefs */
1726 /* Sound available */
1727 can_use_sound = TRUE;
1729 return (can_use_sound);
1736 static void term_window_resize(term_data *td)
1738 /* Require window */
1741 /* Resize the window */
1742 SetWindowPos(td->w, 0, 0, 0,
1743 td->size_wid, td->size_hgt,
1744 SWP_NOMOVE | SWP_NOZORDER);
1747 InvalidateRect(td->w, NULL, TRUE);
1752 * Force the use of a new "font file" for a term_data
1754 * This function may be called before the "window" is ready
1756 * This function returns zero only if everything succeeds.
1758 * Note that the "font name" must be capitalized!!!
1760 static errr term_force_font(term_data *td, concptr path)
1764 /* Forget the old font (if needed) */
1765 if (td->font_id) DeleteObject(td->font_id);
1770 /* Create the font (using the 'base' of the font file name!) */
1771 td->font_id = CreateFontIndirect(&(td->lf));
1772 wid = td->lf.lfWidth;
1773 hgt = td->lf.lfHeight;
1774 if (!td->font_id) return 1;
1776 /* Hack -- Unknown size */
1783 /* all this trouble to get the cell size */
1784 hdcDesktop = GetDC(HWND_DESKTOP);
1785 hfOld = SelectObject(hdcDesktop, td->font_id);
1786 GetTextMetrics(hdcDesktop, &tm);
1787 SelectObject(hdcDesktop, hfOld);
1788 ReleaseDC(HWND_DESKTOP, hdcDesktop);
1790 /* Font size info */
1791 wid = tm.tmAveCharWidth;
1795 /* Save the size info */
1806 * Allow the user to change the font for this window.
1808 static void term_change_font(term_data *td)
1812 memset(&cf, 0, sizeof(cf));
1813 cf.lStructSize = sizeof(cf);
1814 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
1815 cf.lpLogFont = &(td->lf);
1817 if (ChooseFont(&cf))
1819 /* Force the font */
1820 term_force_font(td, NULL);
1822 /* Assume not bizarre */
1825 /* Reset the tile info */
1826 td->tile_wid = td->font_wid;
1827 td->tile_hgt = td->font_hgt;
1829 /* Analyze the font */
1832 /* Resize the window */
1833 term_window_resize(td);
1839 * Allow the user to lock this window.
1841 static void term_window_pos(term_data *td, HWND hWnd)
1843 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
1844 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1847 static void windows_map(player_type *player_ptr);
1850 * Hack -- redraw a term_data
1852 static void term_data_redraw(player_type *player_ptr, term_data *td)
1856 /* Redraw the map */
1857 windows_map(player_ptr);
1861 /* Activate the term */
1862 Term_activate(&td->t);
1864 /* Redraw the contents */
1867 /* Restore the term */
1868 Term_activate(term_screen);
1873 void term_inversed_area(HWND hWnd, int x, int y, int w, int h)
1877 HBRUSH myBrush, oldBrush;
1879 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
1880 int tx = td->size_ow1 + x * td->tile_wid;
1881 int ty = td->size_oh1 + y * td->tile_hgt;
1882 int tw = w * td->tile_wid - 1;
1883 int th = h * td->tile_hgt - 1;
1886 myBrush = CreateSolidBrush(RGB(255, 255, 255));
1887 oldBrush = SelectObject(hdc, myBrush);
1888 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
1890 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
1892 SelectObject(hdc, oldBrush);
1893 SelectObject(hdc, oldPen);
1898 * @brief //!< Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
1900 static errr term_user_win(int n)
1911 * React to global changes
1913 static errr term_xtra_win_react(player_type *player_ptr)
1920 /* Save the default colors */
1921 for (i = 0; i < 256; i++)
1923 /* Simply accept the desired colors */
1924 win_pal[i] = angband_color_table[i][0];
1935 bool change = FALSE;
1937 /* Save the default colors */
1938 for (i = 0; i < 256; i++)
1940 /* Extract desired values */
1941 rv = angband_color_table[i][1];
1942 gv = angband_color_table[i][2];
1943 bv = angband_color_table[i][3];
1945 /* Extract a full color code */
1946 code = PALETTERGB(rv, gv, bv);
1948 /* Activate changes */
1949 if (win_clr[i] != code)
1951 /* Note the change */
1954 /* Apply the desired color */
1959 /* Activate the palette if needed */
1960 if (change) (void)new_palette();
1963 /* Handle "arg_sound" */
1964 if (use_sound != arg_sound)
1966 /* Initialize (if needed) */
1967 if (arg_sound && !init_sound())
1970 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
1976 /* Change setting */
1977 use_sound = arg_sound;
1980 /* Handle "arg_sound" */
1981 if (use_music != arg_music)
1983 /* Initialize (if needed) */
1984 if (arg_music && !init_music())
1987 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
1992 /* Change setting */
1993 use_music = arg_music;
1995 if (!arg_music) stop_music();
1996 else select_floor_music(player_ptr);
2000 /* Handle "arg_graphics" */
2001 if (use_graphics != arg_graphics)
2003 /* Initialize (if needed) */
2004 if (arg_graphics && !init_graphics())
2007 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
2010 arg_graphics = GRAPHICS_NONE;
2013 /* Change setting */
2014 use_graphics = arg_graphics;
2017 reset_visuals(player_ptr);
2020 /* Clean up windows */
2021 for (i = 0; i < MAX_TERM_DATA; i++)
2025 term_data *td = &data[i];
2027 /* Update resized windows */
2028 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
2031 Term_activate(&td->t);
2033 /* Hack -- Resize the term */
2034 Term_resize(td->cols, td->rows);
2036 /* Redraw the contents */
2049 * Process at least one event
2051 static errr term_xtra_win_event(int v)
2055 /* Wait for an event */
2059 if (GetMessage(&msg, NULL, 0, 0))
2061 TranslateMessage(&msg);
2062 DispatchMessage(&msg);
2066 /* Check for an event */
2070 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2072 TranslateMessage(&msg);
2073 DispatchMessage(&msg);
2083 * Process all pending events
2085 static errr term_xtra_win_flush(void)
2089 /* Process all pending events */
2090 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2092 TranslateMessage(&msg);
2093 DispatchMessage(&msg);
2102 * Hack -- clear the screen
2104 * Make this more efficient
2106 static errr term_xtra_win_clear(void)
2108 term_data *td = (term_data*)(Term->data);
2113 /* Rectangle to erase */
2114 rc.left = td->size_ow1;
2115 rc.right = rc.left + td->cols * td->tile_wid;
2116 rc.top = td->size_oh1;
2117 rc.bottom = rc.top + td->rows * td->tile_hgt;
2121 SetBkColor(hdc, RGB(0, 0, 0));
2122 SelectObject(hdc, td->font_id);
2123 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2128 rc.left = 0; rc.top = 0;
2131 ReleaseDC(td->w, hdc);
2139 * Hack -- make a noise
2141 static errr term_xtra_win_noise(void)
2143 MessageBeep(MB_ICONASTERISK);
2149 * Hack -- make a sound
2151 static errr term_xtra_win_sound(int v)
2156 /* Sound disabled */
2157 if (!use_sound) return 1;
2160 if ((v < 0) || (v >= SOUND_MAX)) return 1;
2162 /* Count the samples */
2163 for (i = 0; i < SAMPLE_SOUND_MAX; i++)
2165 if (!sound_file[v][i])
2170 if (i == 0) return 1;
2172 /* Build the path */
2173 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
2177 /* Play the sound, catch errors */
2178 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
2182 /* Play the sound, catch errors */
2183 return (sndPlaySound(buf, SND_ASYNC));
2189 * Hack -- play a music
2191 static errr term_xtra_win_music(int n, int v)
2195 /* Sound disabled */
2196 if (n == TERM_XTRA_MUSIC_MUTE)
2198 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
2199 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
2202 if (!use_music) return 1;
2205 if (n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return 1;
2206 else if (v < 0 || v >= 1000) return(1); /*!< TODO */
2210 case TERM_XTRA_MUSIC_BASIC:
2211 for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!music_file[v][i]) break;
2213 case TERM_XTRA_MUSIC_DUNGEON:
2214 for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!dungeon_music_file[v][i]) break;
2216 case TERM_XTRA_MUSIC_QUEST:
2217 for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!quest_music_file[v][i]) break;
2219 case TERM_XTRA_MUSIC_TOWN:
2220 for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!town_music_file[v][i]) break;
2232 case TERM_XTRA_MUSIC_BASIC:
2233 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
2235 case TERM_XTRA_MUSIC_DUNGEON:
2236 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
2238 case TERM_XTRA_MUSIC_QUEST:
2239 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
2241 case TERM_XTRA_MUSIC_TOWN:
2242 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
2246 if (current_music_type == n && current_music_id == v)
2250 current_music_type = n;
2251 current_music_id = v;
2255 mop.lpstrDeviceType = mci_device_type;
2256 mop.lpstrElementName = buf;
2257 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
2258 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
2259 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
2260 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
2261 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
2269 * Delay for "x" milliseconds
2271 static int term_xtra_win_delay(int v)
2285 t = GetTickCount() + v;
2288 while (GetTickCount() < t)
2290 /* Handle messages */
2291 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2293 TranslateMessage(&msg);
2294 DispatchMessage(&msg);
2306 * todo z-termに影響があるのでplayer_typeの追加は保留
2307 * Do a "special thing"
2309 static errr term_xtra_win(int n, int v)
2311 /* Handle a subset of the legal requests */
2314 /* Make a bell sound */
2315 case TERM_XTRA_NOISE:
2317 return (term_xtra_win_noise());
2321 case TERM_XTRA_MUSIC_BASIC:
2322 case TERM_XTRA_MUSIC_DUNGEON:
2323 case TERM_XTRA_MUSIC_QUEST:
2324 case TERM_XTRA_MUSIC_TOWN:
2326 return (term_xtra_win_music(n, v));
2329 /* Make a special sound */
2330 case TERM_XTRA_SOUND:
2332 return (term_xtra_win_sound(v));
2335 /* Process random events */
2336 case TERM_XTRA_BORED:
2338 return (term_xtra_win_event(0));
2341 /* Process an event */
2342 case TERM_XTRA_EVENT:
2344 return (term_xtra_win_event(v));
2347 /* Flush all events */
2348 case TERM_XTRA_FLUSH:
2350 return (term_xtra_win_flush());
2353 /* Clear the screen */
2354 case TERM_XTRA_CLEAR:
2356 return (term_xtra_win_clear());
2359 /* React to global changes */
2360 case TERM_XTRA_REACT:
2362 return (term_xtra_win_react(p_ptr));
2365 /* Delay for some milliseconds */
2366 case TERM_XTRA_DELAY:
2368 return (term_xtra_win_delay(v));
2378 * Low level graphics (Assumes valid input).
2380 * Draw a "cursor" at (x,y), using a "yellow box".
2382 static errr term_curs_win(int x, int y)
2384 term_data *td = (term_data*)(Term->data);
2389 int tile_wid, tile_hgt;
2393 tile_wid = td->map_tile_wid;
2394 tile_hgt = td->map_tile_hgt;
2398 tile_wid = td->tile_wid;
2399 tile_hgt = td->tile_hgt;
2402 /* Frame the grid */
2403 rc.left = x * tile_wid + td->size_ow1;
2404 rc.right = rc.left + tile_wid;
2405 rc.top = y * tile_hgt + td->size_oh1;
2406 rc.bottom = rc.top + tile_hgt;
2408 /* Cursor is done as a yellow "box" */
2410 FrameRect(hdc, &rc, hbrYellow);
2411 ReleaseDC(td->w, hdc);
2419 * Low level graphics (Assumes valid input).
2421 * Draw a "big cursor" at (x,y), using a "yellow box".
2423 static errr term_bigcurs_win(int x, int y)
2425 term_data *td = (term_data*)(Term->data);
2430 int tile_wid, tile_hgt;
2434 /* Normal cursor in map window */
2435 term_curs_win(x, y);
2440 tile_wid = td->tile_wid;
2441 tile_hgt = td->tile_hgt;
2444 /* Frame the grid */
2445 rc.left = x * tile_wid + td->size_ow1;
2446 rc.right = rc.left + 2 * tile_wid;
2447 rc.top = y * tile_hgt + td->size_oh1;
2448 rc.bottom = rc.top + tile_hgt;
2450 /* Cursor is done as a yellow "box" */
2452 FrameRect(hdc, &rc, hbrYellow);
2453 ReleaseDC(td->w, hdc);
2461 * Low level graphics (Assumes valid input).
2463 * Erase a "block" of "n" characters starting at (x,y).
2465 static errr term_wipe_win(int x, int y, int n)
2467 term_data *td = (term_data*)(Term->data);
2472 /* Rectangle to erase in client coords */
2473 rc.left = x * td->tile_wid + td->size_ow1;
2474 rc.right = rc.left + n * td->tile_wid;
2475 rc.top = y * td->tile_hgt + td->size_oh1;
2476 rc.bottom = rc.top + td->tile_hgt;
2479 SetBkColor(hdc, RGB(0, 0, 0));
2480 SelectObject(hdc, td->font_id);
2485 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2486 ReleaseDC(td->w, hdc);
2494 * Low level graphics. Assumes valid input.
2496 * Draw several ("n") chars, with an attr, at a given location.
2498 * All "graphic" data is handled by "term_pict_win()", below.
2500 * One would think there is a more efficient method for telling a window
2501 * what color it should be using to draw with, but perhaps simply changing
2502 * it every time is not too inefficient.
2504 static errr term_text_win(int x, int y, int n, TERM_COLOR a, concptr s)
2506 term_data *td = (term_data*)(Term->data);
2510 static HBITMAP WALL;
2511 static HBRUSH myBrush, oldBrush;
2513 static bool init_done = FALSE;
2516 WALL = LoadBitmap(hInstance, AppName);
2517 myBrush = CreatePatternBrush(WALL);
2521 /* Total rectangle */
2522 rc.left = x * td->tile_wid + td->size_ow1;
2523 rc.right = rc.left + n * td->tile_wid;
2524 rc.top = y * td->tile_hgt + td->size_oh1;
2525 rc.bottom = rc.top + td->tile_hgt;
2530 /* Background color */
2531 SetBkColor(hdc, RGB(0, 0, 0));
2533 /* Foreground color */
2536 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
2540 SetTextColor(hdc, win_clr[a & 0x0F]);
2544 SetTextColor(hdc, win_clr[a]);
2548 SelectObject(hdc, td->font_id);
2551 if (use_bg) SetBkMode(hdc, TRANSPARENT);
2555 (td->tile_hgt != td->font_hgt) ||
2556 (td->tile_wid != td->font_wid))
2560 /* Erase complete rectangle */
2561 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2564 if (use_bg) DrawBG(hdc, &rc);
2567 rc.left += ((td->tile_wid - td->font_wid) / 2);
2568 rc.right = rc.left + td->font_wid;
2569 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
2570 rc.bottom = rc.top + td->font_hgt;
2572 /* Dump each character */
2573 for (i = 0; i < n; i++)
2576 if (use_bigtile && *(s + i) == "■"[0] && *(s + i + 1) == "■"[1])
2578 rc.right += td->font_wid;
2580 oldBrush = SelectObject(hdc, myBrush);
2581 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
2584 Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
2586 SelectObject(hdc, oldBrush);
2587 SelectObject(hdc, oldPen);
2588 rc.right -= td->font_wid;
2592 rc.left += 2 * td->tile_wid;
2593 rc.right += 2 * td->tile_wid;
2595 else if (iskanji(*(s + i))) /* 2バイト文字 */
2597 rc.right += td->font_wid;
2599 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2601 rc.right -= td->font_wid;
2605 rc.left += 2 * td->tile_wid;
2606 rc.right += 2 * td->tile_wid;
2608 else if (*(s + i) == 127) {
2609 oldBrush = SelectObject(hdc, myBrush);
2610 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
2613 Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
2615 SelectObject(hdc, oldBrush);
2616 SelectObject(hdc, oldPen);
2619 rc.left += td->tile_wid;
2620 rc.right += td->tile_wid;
2624 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
2627 rc.left += td->tile_wid;
2628 rc.right += td->tile_wid;
2631 if (*(s + i) == 127) {
2632 oldBrush = SelectObject(hdc, myBrush);
2633 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
2636 Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
2638 SelectObject(hdc, oldBrush);
2639 SelectObject(hdc, oldPen);
2642 rc.left += td->tile_wid;
2643 rc.right += td->tile_wid;
2647 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2651 rc.left += td->tile_wid;
2652 rc.right += td->tile_wid;
2663 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
2668 ReleaseDC(td->w, hdc);
2676 * Low level graphics. Assumes valid input.
2678 * Draw an array of "special" attr/char pairs at the given location.
2680 * We use the "term_pict_win()" function for "graphic" data, which are
2681 * encoded by setting the "high-bits" of both the "attr" and the "char"
2682 * data. We use the "attr" to represent the "row" of the main bitmap,
2683 * and the "char" to represent the "col" of the main bitmap. The use
2684 * of this function is induced by the "higher_pict" flag.
2686 * If "graphics" is not available, we simply "wipe" the given grids.
2688 static errr term_pict_win(TERM_LEN x, TERM_LEN y, int n, const TERM_COLOR *ap, concptr cp, const TERM_COLOR *tap, concptr tcp)
2690 term_data *td = (term_data*)(Term->data);
2692 TERM_LEN x1, y1, w1, h1, tw1, th1;
2693 TERM_LEN x2, y2, w2, h2, tw2 = 0;
2703 /* Erase the grids */
2704 return (term_wipe_win(x, y, n));
2707 /* Size of bitmap cell */
2708 w1 = infGraph.CellWidth;
2709 h1 = infGraph.CellHeight;
2710 tw1 = infGraph.TileWidth;
2711 th1 = infGraph.TileHeight;
2713 /* Size of window cell */
2716 w2 = td->map_tile_wid;
2717 h2 = td->map_tile_hgt;
2726 if (use_bigtile) tw2 *= 2;
2729 /* Location of window cell */
2730 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
2731 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
2737 hdcSrc = CreateCompatibleDC(hdc);
2738 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
2740 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
2742 hdcMask = CreateCompatibleDC(hdc);
2743 SelectObject(hdcMask, infMask.hBitmap);
2746 /* Draw attr/char pairs */
2747 for (i = 0; i < n; i++, x2 += w2)
2749 TERM_COLOR a = ap[i];
2753 /* Extract picture */
2754 int row = (a & 0x7F);
2755 int col = (c & 0x7F);
2757 /* Location of bitmap cell */
2761 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
2763 x3 = (tcp[i] & 0x7F) * w1;
2764 y3 = (tap[i] & 0x7F) * h1;
2765 tw2 = tw2 * w1 / tw1;
2769 if ((tw1 == tw2) && (th1 == h2))
2771 /* Copy the terrain picture from the bitmap to the window */
2772 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
2774 /* Mask out the tile */
2775 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
2778 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
2781 /* Need to stretch */
2784 /* Set the correct mode for stretching the tiles */
2785 SetStretchBltMode(hdc, COLORONCOLOR);
2787 /* Copy the terrain picture from the bitmap to the window */
2788 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
2790 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
2792 /* Only draw if terrain and overlay are different */
2793 if ((x1 != x3) || (y1 != y3))
2795 /* Mask out the tile */
2796 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
2799 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
2806 if ((w1 == tw2) && (h1 == h2))
2808 /* Copy the picture from the bitmap to the window */
2809 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
2812 /* Need to stretch */
2815 /* Set the correct mode for stretching the tiles */
2816 SetStretchBltMode(hdc, COLORONCOLOR);
2818 /* Copy the picture from the bitmap to the window */
2819 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
2825 SelectObject(hdcSrc, hbmSrcOld);
2828 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
2831 SelectObject(hdcMask, hbmSrcOld);
2836 ReleaseDC(td->w, hdc);
2843 static void windows_map(player_type *player_ptr)
2845 term_data *td = &data[0];
2848 TERM_LEN x, min_x, max_x;
2849 TERM_LEN y, min_y, max_y;
2854 /* Only in graphics mode */
2855 if (!use_graphics) return;
2856 term_xtra_win_clear();
2858 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
2859 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
2860 td->map_active = TRUE;
2865 max_x = player_ptr->current_floor_ptr->width;
2866 max_y = player_ptr->current_floor_ptr->height;
2870 for (x = min_x; x < max_x; x++)
2872 for (y = min_y; y < max_y; y++)
2874 map_info(player_ptr, y, x, &a, (char*)&c, &ta, (char*)&tc);
2876 /* Ignore non-graphics */
2877 if ((a & 0x80) && (c & 0x80))
2879 term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
2884 /* Hilite the player */
2885 term_curs_win(player_ptr->x - min_x, player_ptr->y - min_y);
2887 /* Wait for a keypress, flush key buffer */
2888 Term_inkey(&c, TRUE, TRUE);
2891 /* Switch off the map display */
2892 td->map_active = FALSE;
2894 /* Restore screen */
2895 term_xtra_win_clear();
2900 /*** Other routines ***/
2904 * Create and initialize a "term_data" given a title
2906 static void term_data_link(term_data *td)
2910 /* Initialize the term */
2911 term_init(t, td->cols, td->rows, td->keys);
2913 /* Use a "software" cursor */
2914 t->soft_cursor = TRUE;
2916 /* Use "term_pict" for "graphic" data */
2917 t->higher_pict = TRUE;
2919 /* Erase with "white space" */
2920 t->attr_blank = TERM_WHITE;
2921 t->char_blank = ' ';
2923 /* Prepare the template hooks */
2924 t->user_hook = term_user_win;
2925 t->xtra_hook = term_xtra_win;
2926 t->curs_hook = term_curs_win;
2927 t->bigcurs_hook = term_bigcurs_win;
2928 t->wipe_hook = term_wipe_win;
2929 t->text_hook = term_text_win;
2930 t->pict_hook = term_pict_win;
2932 /* Remember where we came from */
2933 t->data = (vptr)(td);
2938 * Create the windows
2940 * First, instantiate the "default" values, then read the "ini_file"
2941 * to over-ride selected values, then create the windows, and fonts.
2943 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
2944 * must make active to realize the palette.
2946 static void init_windows(void)
2954 WIPE(td, term_data);
2958 td->s = angband_term_name[0];
2974 for (i = 1; i < MAX_TERM_DATA; i++)
2977 WIPE(td, term_data);
2978 td->s = angband_term_name[i];
2982 td->visible = FALSE;
2987 td->pos_x = (7 - i) * 30;
2988 td->pos_y = (7 - i) * 20;
2996 /* Main window (need these before term_getsize gets called) */
2998 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
2999 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
3004 /* Sub windows (need these before term_getsize gets called) */
3005 for (i = 1; i < MAX_TERM_DATA; i++)
3008 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
3009 td->dwExStyle = (WS_EX_TOOLWINDOW);
3014 for (i = 0; i < MAX_TERM_DATA; i++)
3018 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
3019 td->lf.lfCharSet = DEFAULT_CHARSET;
3020 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
3021 /* Activate the chosen font */
3022 term_force_font(td, NULL);
3023 if (!td->tile_wid) td->tile_wid = td->font_wid;
3024 if (!td->tile_hgt) td->tile_hgt = td->font_hgt;
3026 /* Analyze the font */
3029 /* Resize the window */
3030 term_window_resize(td);
3034 /* Sub windows (reverse order) */
3035 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
3040 td->w = CreateWindowEx(td->dwExStyle, AngList,
3042 td->pos_x, td->pos_y,
3043 td->size_wid, td->size_hgt,
3044 HWND_DESKTOP, NULL, hInstance, NULL);
3046 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
3050 td->size_hack = TRUE;
3051 ShowWindow(td->w, SW_SHOW);
3052 td->size_hack = FALSE;
3056 angband_term[i] = &td->t;
3060 /* Activate the window */
3061 SetActiveWindow(td->w);
3066 term_window_pos(&data[i], HWND_TOPMOST);
3070 term_window_pos(&data[i], td->w);
3080 td->w = CreateWindowEx(td->dwExStyle, AppName,
3082 td->pos_x, td->pos_y,
3083 td->size_wid, td->size_hgt,
3084 HWND_DESKTOP, NULL, hInstance, NULL);
3086 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
3089 angband_term[0] = &td->t;
3090 normsize.x = td->cols;
3091 normsize.y = td->rows;
3093 /* Activate the main window */
3094 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
3095 else ShowWindow(td->w, SW_SHOW);
3097 /* Bring main window back to top */
3098 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
3102 (void)new_palette();
3105 /* Create a "brush" for drawing the "cursor" */
3106 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
3109 /* Process pending messages */
3110 (void)term_xtra_win_flush();
3118 static void setup_menus(void)
3122 HMENU hm = GetMenu(data[0].w);
3125 /* Menu "File", Disable all */
3126 EnableMenuItem(hm, IDM_FILE_NEW,
3127 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3128 EnableMenuItem(hm, IDM_FILE_OPEN,
3129 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3130 EnableMenuItem(hm, IDM_FILE_SAVE,
3131 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3132 EnableMenuItem(hm, IDM_FILE_EXIT,
3133 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3134 EnableMenuItem(hm, IDM_FILE_SCORE,
3135 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3138 /* No character available */
3139 if (!current_world_ptr->character_generated)
3141 /* Menu "File", Item "New" */
3142 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
3144 /* Menu "File", Item "Open" */
3145 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
3148 /* A character available */
3149 if (current_world_ptr->character_generated)
3151 /* Menu "File", Item "Save" */
3152 EnableMenuItem(hm, IDM_FILE_SAVE,
3153 MF_BYCOMMAND | MF_ENABLED);
3156 /* Menu "File", Item "Exit" */
3157 EnableMenuItem(hm, IDM_FILE_EXIT,
3158 MF_BYCOMMAND | MF_ENABLED);
3160 EnableMenuItem(hm, IDM_FILE_SCORE,
3161 MF_BYCOMMAND | MF_ENABLED);
3164 /* Menu "Window::Visibility" */
3165 for (i = 0; i < MAX_TERM_DATA; i++)
3167 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3168 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3170 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3171 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
3173 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3174 MF_BYCOMMAND | MF_ENABLED);
3177 /* Menu "Window::Font" */
3178 for (i = 0; i < MAX_TERM_DATA; i++)
3180 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3181 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3183 if (data[i].visible)
3185 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3186 MF_BYCOMMAND | MF_ENABLED);
3190 /* Menu "Window::Window Position Fix" */
3191 for (i = 0; i < MAX_TERM_DATA; i++)
3193 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3194 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3196 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
3197 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
3199 if (data[i].visible)
3201 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3202 MF_BYCOMMAND | MF_ENABLED);
3206 /* Menu "Window::Bizarre Display" */
3207 for (i = 0; i < MAX_TERM_DATA; i++)
3209 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3210 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3212 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3213 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
3215 if (data[i].visible)
3217 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3218 MF_BYCOMMAND | MF_ENABLED);
3223 /* Menu "Window::Increase Tile Width" */
3224 for (i = 0; i < MAX_TERM_DATA; i++)
3226 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3227 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3229 if (data[i].visible)
3231 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3232 MF_BYCOMMAND | MF_ENABLED);
3237 /* Menu "Window::Decrease Tile Width" */
3238 for (i = 0; i < MAX_TERM_DATA; i++)
3240 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3241 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3243 if (data[i].visible)
3245 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3246 MF_BYCOMMAND | MF_ENABLED);
3251 /* Menu "Window::Increase Tile Height" */
3252 for (i = 0; i < MAX_TERM_DATA; i++)
3254 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3255 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3257 if (data[i].visible)
3259 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3260 MF_BYCOMMAND | MF_ENABLED);
3265 /* Menu "Window::Decrease Tile Height" */
3266 for (i = 0; i < MAX_TERM_DATA; i++)
3268 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3269 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3271 if (data[i].visible)
3273 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3274 MF_BYCOMMAND | MF_ENABLED);
3279 /* Menu "Options", disable all */
3280 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3281 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3282 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3283 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3284 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3285 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3286 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
3287 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3288 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
3289 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3293 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3294 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3297 /* Menu "Options", Item "Map" */
3298 if (use_graphics != GRAPHICS_NONE)
3299 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
3301 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
3302 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3304 /* Menu "Options", update all */
3305 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3306 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
3307 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3308 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
3309 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3310 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
3311 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
3312 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
3313 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
3314 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
3315 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
3316 (arg_music ? MF_CHECKED : MF_UNCHECKED));
3317 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
3318 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
3319 CheckMenuItem(hm, IDM_OPTIONS_BG,
3320 (use_bg ? MF_CHECKED : MF_UNCHECKED));
3324 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
3325 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
3328 /* Menu "Options", Item "Graphics" */
3329 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
3330 /* Menu "Options", Item "Graphics" */
3331 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
3332 /* Menu "Options", Item "Graphics" */
3333 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
3334 /* Menu "Options", Item "Graphics" */
3335 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
3337 /* Menu "Options", Item "Sound" */
3338 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
3341 /* Menu "Options", Item "ScreenSaver" */
3342 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3343 MF_BYCOMMAND | MF_ENABLED);
3344 #endif /* USE_SAVER */
3349 * Check for double clicked (or dragged) savefile
3351 * Apparently, Windows copies the entire filename into the first
3352 * piece of the "command line string". Perhaps we should extract
3353 * the "basename" of that filename and append it to the "save" dir.
3355 static void check_for_save_file(player_type *player_ptr, LPSTR cmd_line)
3365 /* Extract filename */
3366 strcat(savefile, s);
3368 /* Validate the file */
3369 validate_file(savefile);
3371 /* Game in progress */
3372 game_in_progress = TRUE;
3375 play_game(player_ptr, FALSE);
3380 * Process a menu command
3382 static void process_menus(player_type *player_ptr, WORD wCmd)
3398 plog(_("まだ初期化中です...", "You cannot do that yet..."));
3400 else if (game_in_progress)
3402 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
3406 game_in_progress = TRUE;
3408 play_game(player_ptr, TRUE);
3419 plog(_("まだ初期化中です...", "You cannot do that yet..."));
3421 else if (game_in_progress)
3423 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
3427 memset(&ofn, 0, sizeof(ofn));
3428 ofn.lStructSize = sizeof(ofn);
3429 ofn.hwndOwner = data[0].w;
3430 ofn.lpstrFilter = "Save Files (*.)\0*\0";
3431 ofn.nFilterIndex = 1;
3432 ofn.lpstrFile = savefile;
3433 ofn.nMaxFile = 1024;
3434 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
3435 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
3437 if (GetOpenFileName(&ofn))
3439 /* Load 'savefile' */
3440 validate_file(savefile);
3441 game_in_progress = TRUE;
3443 play_game(player_ptr, FALSE);
3453 if (game_in_progress && current_world_ptr->character_generated)
3457 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
3461 /* Hack -- Forget messages */
3465 do_cmd_save_game(player_ptr, FALSE);
3469 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
3476 if (game_in_progress && current_world_ptr->character_generated)
3480 plog(_("今は終了できません。", "You may not do that right now."));
3484 /* Hack -- Forget messages */
3487 forget_lite(player_ptr->current_floor_ptr);
3488 forget_view(player_ptr->current_floor_ptr);
3489 clear_mon_lite(player_ptr->current_floor_ptr);
3491 Term_key_push(SPECIAL_KEY_QUIT);
3499 case IDM_FILE_SCORE:
3502 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
3504 /* Open the binary high score file, for reading */
3505 highscore_fd = fd_open(buf, O_RDONLY);
3507 /* Paranoia -- No score file */
3508 if (highscore_fd < 0)
3510 msg_print("Score file unavailable.");
3517 /* Display the scores */
3518 display_scores_aux(0, MAX_HISCORES, -1, NULL);
3520 /* Shut the high score file */
3521 (void)fd_close(highscore_fd);
3523 /* Forget the high score fd */
3527 /* Hack - Flush it */
3535 case IDM_FILE_MOVIE:
3539 plog(_("まだ初期化中です...", "You cannot do that yet..."));
3541 else if (game_in_progress)
3543 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
3547 memset(&ofn, 0, sizeof(ofn));
3548 ofn.lStructSize = sizeof(ofn);
3549 ofn.hwndOwner = data[0].w;
3550 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
3551 ofn.nFilterIndex = 1;
3552 ofn.lpstrFile = savefile;
3553 ofn.nMaxFile = 1024;
3554 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
3555 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
3557 if (GetOpenFileName(&ofn))
3559 /* Load 'savefile' */
3560 prepare_browse_movie_aux(savefile);
3561 play_game(player_ptr, FALSE);
3570 case IDM_WINDOW_VIS_0:
3572 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
3576 /* Window visibility */
3577 case IDM_WINDOW_VIS_1:
3578 case IDM_WINDOW_VIS_2:
3579 case IDM_WINDOW_VIS_3:
3580 case IDM_WINDOW_VIS_4:
3581 case IDM_WINDOW_VIS_5:
3582 case IDM_WINDOW_VIS_6:
3583 case IDM_WINDOW_VIS_7:
3585 i = wCmd - IDM_WINDOW_VIS_0;
3587 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3594 ShowWindow(td->w, SW_SHOW);
3595 term_data_redraw(player_ptr, td);
3599 td->visible = FALSE;
3601 ShowWindow(td->w, SW_HIDE);
3608 case IDM_WINDOW_FONT_0:
3609 case IDM_WINDOW_FONT_1:
3610 case IDM_WINDOW_FONT_2:
3611 case IDM_WINDOW_FONT_3:
3612 case IDM_WINDOW_FONT_4:
3613 case IDM_WINDOW_FONT_5:
3614 case IDM_WINDOW_FONT_6:
3615 case IDM_WINDOW_FONT_7:
3617 i = wCmd - IDM_WINDOW_FONT_0;
3619 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3623 term_change_font(td);
3628 /* Window Z Position */
3629 case IDM_WINDOW_POS_1:
3630 case IDM_WINDOW_POS_2:
3631 case IDM_WINDOW_POS_3:
3632 case IDM_WINDOW_POS_4:
3633 case IDM_WINDOW_POS_5:
3634 case IDM_WINDOW_POS_6:
3635 case IDM_WINDOW_POS_7:
3637 i = wCmd - IDM_WINDOW_POS_0;
3639 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3643 if (!td->posfix && td->visible)
3646 term_window_pos(td, HWND_TOPMOST);
3651 term_window_pos(td, data[0].w);
3657 /* Bizarre Display */
3658 case IDM_WINDOW_BIZ_0:
3659 case IDM_WINDOW_BIZ_1:
3660 case IDM_WINDOW_BIZ_2:
3661 case IDM_WINDOW_BIZ_3:
3662 case IDM_WINDOW_BIZ_4:
3663 case IDM_WINDOW_BIZ_5:
3664 case IDM_WINDOW_BIZ_6:
3665 case IDM_WINDOW_BIZ_7:
3667 i = wCmd - IDM_WINDOW_BIZ_0;
3669 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3673 td->bizarre = !td->bizarre;
3677 term_window_resize(td);
3682 /* Increase Tile Width */
3683 case IDM_WINDOW_I_WID_0:
3684 case IDM_WINDOW_I_WID_1:
3685 case IDM_WINDOW_I_WID_2:
3686 case IDM_WINDOW_I_WID_3:
3687 case IDM_WINDOW_I_WID_4:
3688 case IDM_WINDOW_I_WID_5:
3689 case IDM_WINDOW_I_WID_6:
3690 case IDM_WINDOW_I_WID_7:
3692 i = wCmd - IDM_WINDOW_I_WID_0;
3694 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3702 term_window_resize(td);
3707 /* Decrease Tile Height */
3708 case IDM_WINDOW_D_WID_0:
3709 case IDM_WINDOW_D_WID_1:
3710 case IDM_WINDOW_D_WID_2:
3711 case IDM_WINDOW_D_WID_3:
3712 case IDM_WINDOW_D_WID_4:
3713 case IDM_WINDOW_D_WID_5:
3714 case IDM_WINDOW_D_WID_6:
3715 case IDM_WINDOW_D_WID_7:
3717 i = wCmd - IDM_WINDOW_D_WID_0;
3719 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3727 term_window_resize(td);
3732 /* Increase Tile Height */
3733 case IDM_WINDOW_I_HGT_0:
3734 case IDM_WINDOW_I_HGT_1:
3735 case IDM_WINDOW_I_HGT_2:
3736 case IDM_WINDOW_I_HGT_3:
3737 case IDM_WINDOW_I_HGT_4:
3738 case IDM_WINDOW_I_HGT_5:
3739 case IDM_WINDOW_I_HGT_6:
3740 case IDM_WINDOW_I_HGT_7:
3742 i = wCmd - IDM_WINDOW_I_HGT_0;
3744 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3752 term_window_resize(td);
3757 /* Decrease Tile Height */
3758 case IDM_WINDOW_D_HGT_0:
3759 case IDM_WINDOW_D_HGT_1:
3760 case IDM_WINDOW_D_HGT_2:
3761 case IDM_WINDOW_D_HGT_3:
3762 case IDM_WINDOW_D_HGT_4:
3763 case IDM_WINDOW_D_HGT_5:
3764 case IDM_WINDOW_D_HGT_6:
3765 case IDM_WINDOW_D_HGT_7:
3767 i = wCmd - IDM_WINDOW_D_HGT_0;
3769 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3777 term_window_resize(td);
3782 case IDM_OPTIONS_NO_GRAPHICS:
3786 plog("You may not do that right now.");
3790 if (arg_graphics != GRAPHICS_NONE)
3792 arg_graphics = GRAPHICS_NONE;
3793 term_xtra_win_react(player_ptr);
3794 Term_key_push(KTRL('R'));
3800 case IDM_OPTIONS_OLD_GRAPHICS:
3804 plog("You may not do that right now.");
3808 if (arg_graphics != GRAPHICS_ORIGINAL)
3810 arg_graphics = GRAPHICS_ORIGINAL;
3811 term_xtra_win_react(player_ptr);
3812 Term_key_push(KTRL('R'));
3818 case IDM_OPTIONS_NEW_GRAPHICS:
3822 plog("You may not do that right now.");
3826 if (arg_graphics != GRAPHICS_ADAM_BOLT)
3828 arg_graphics = GRAPHICS_ADAM_BOLT;
3829 term_xtra_win_react(player_ptr);
3830 Term_key_push(KTRL('R'));
3836 case IDM_OPTIONS_NEW2_GRAPHICS:
3840 plog("You may not do that right now.");
3844 if (arg_graphics != GRAPHICS_HENGBAND)
3846 arg_graphics = GRAPHICS_HENGBAND;
3847 term_xtra_win_react(player_ptr);
3848 Term_key_push(KTRL('R'));
3854 case IDM_OPTIONS_BIGTILE:
3859 plog("You may not do that right now.");
3863 arg_bigtile = !arg_bigtile;
3864 Term_activate(&td->t);
3865 Term_resize(td->cols, td->rows);
3866 InvalidateRect(td->w, NULL, TRUE);
3870 case IDM_OPTIONS_MUSIC:
3874 plog("You may not do that right now.");
3878 arg_music = !arg_music;
3879 term_xtra_win_react(player_ptr);
3880 Term_key_push(KTRL('R'));
3884 case IDM_OPTIONS_SOUND:
3888 plog("You may not do that right now.");
3892 arg_sound = !arg_sound;
3893 term_xtra_win_react(player_ptr);
3894 Term_key_push(KTRL('R'));
3899 case IDM_OPTIONS_BG:
3903 plog("You may not do that right now.");
3909 term_xtra_win_react(player_ptr);
3910 Term_key_push(KTRL('R'));
3915 case IDM_OPTIONS_OPEN_BG:
3919 plog("You may not do that right now.");
3924 memset(&ofn, 0, sizeof(ofn));
3925 ofn.lStructSize = sizeof(ofn);
3926 ofn.hwndOwner = data[0].w;
3927 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
3928 ofn.nFilterIndex = 1;
3929 ofn.lpstrFile = bg_bitmap_file;
3930 ofn.nMaxFile = 1023;
3931 ofn.lpstrInitialDir = NULL;
3932 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
3933 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
3935 if (GetOpenFileName(&ofn))
3937 /* Load 'savefile' */
3942 /* React to changes */
3943 term_xtra_win_react(player_ptr);
3945 /* Hack -- Force redraw */
3946 Term_key_push(KTRL('R'));
3951 case IDM_DUMP_SCREEN_HTML:
3953 static char buf[1024] = "";
3954 memset(&ofn, 0, sizeof(ofn));
3955 ofn.lStructSize = sizeof(ofn);
3956 ofn.hwndOwner = data[0].w;
3957 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
3958 ofn.nFilterIndex = 1;
3959 ofn.lpstrFile = buf;
3960 ofn.nMaxFile = 1023;
3961 ofn.lpstrDefExt = "html";
3962 ofn.lpstrInitialDir = NULL;
3963 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
3964 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
3966 if (GetSaveFileName(&ofn))
3968 do_cmd_save_screen_html_aux(buf, 0);
3975 case IDM_OPTIONS_SAVER:
3979 DestroyWindow(hwndSaver);
3984 /* Create a screen scaver window */
3985 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
3986 "Angband Screensaver",
3987 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
3988 0, 0, GetSystemMetrics(SM_CXSCREEN),
3989 GetSystemMetrics(SM_CYSCREEN),
3990 NULL, NULL, hInstance, NULL);
3994 /* Push the window to the bottom */
3995 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
3999 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
4007 case IDM_OPTIONS_MAP:
4009 windows_map(player_ptr);
4013 case IDM_HELP_CONTENTS:
4017 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
4018 if (check_file(tmp))
4020 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
4024 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
4025 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
4028 #else /* HTML_HELP */
4031 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
4032 if (check_file(tmp))
4034 sprintf(buf, "winhelp.exe %s", tmp);
4035 WinExec(buf, SW_NORMAL);
4039 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
4040 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
4044 #endif /* HTML_HELP */
4050 static bool process_keydown(WPARAM wParam, LPARAM lParam)
4057 /* Extract the modifiers */
4058 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
4059 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
4060 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
4062 term_no_press = (ma) ? TRUE : FALSE;
4064 /* Handle "special" keys */
4065 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]))
4067 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
4068 bool numpad = FALSE;
4070 /* Begin the macro trigger */
4073 /* Send the modifiers */
4074 if (mc) Term_keypress('C');
4075 if (ms) Term_keypress('S');
4076 if (ma) Term_keypress('A');
4078 /* Extract "scan code" */
4079 i = LOBYTE(HIWORD(lParam));
4081 /* Introduce the scan code */
4084 /* Extended key bit */
4087 /* Numpad Enter and '/' are extended key */
4089 term_no_press = TRUE;
4090 case VK_RETURN: /* Enter */
4093 /* Other extended keys are on full keyboard */
4109 term_no_press = TRUE;
4113 case VK_PRIOR: /* Page Up */
4114 case VK_NEXT: /* Page Down */
4124 /* Special modifiers for keypad keys */
4125 if (numpad) Term_keypress('K');
4127 /* Encode the hexidecimal scan code */
4128 Term_keypress(hexsym[i / 16]);
4129 Term_keypress(hexsym[i % 16]);
4131 /* End the macro trigger */
4142 * todo WNDCLASSに影響があるのでplayer_type*の追加は保留
4145 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4146 WPARAM wParam, LPARAM lParam);
4147 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4148 WPARAM wParam, LPARAM lParam)
4149 #else /* __MWERKS__ */
4150 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
4151 #endif /* __MWERKS__ */
4159 /* Acquire proper "term_data" info */
4160 td = (term_data *)GetWindowLong(hWnd, 0);
4162 /* Handle message */
4167 SetWindowLong(hWnd, 0, (LONG)(my_td));
4173 mop.dwCallback = (DWORD)hWnd;
4177 case WM_GETMINMAXINFO:
4179 MINMAXINFO FAR *lpmmi;
4182 lpmmi = (MINMAXINFO FAR *)lParam;
4184 /* this message was sent before WM_NCCREATE */
4187 /* Minimum window size is 80x24 */
4188 rc.left = rc.top = 0;
4189 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
4190 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4193 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4195 /* Save minimum size */
4196 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4197 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4204 BeginPaint(hWnd, &ps);
4205 if (td) term_data_redraw(p_ptr, td);
4206 EndPaint(hWnd, &ps);
4207 ValidateRect(hWnd, NULL);
4213 if (wParam == MCI_NOTIFY_SUCCESSFUL)
4215 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
4216 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
4224 if (process_keydown(wParam, lParam))
4231 if (term_no_press) term_no_press = FALSE;
4232 else Term_keypress(wParam);
4236 case WM_LBUTTONDOWN:
4238 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
4239 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
4251 TERM_LEN dx = abs(oldx - mousex) + 1;
4252 TERM_LEN dy = abs(oldy - mousey) + 1;
4253 TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
4254 TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
4264 hGlobal = GlobalAlloc(GHND, sz + 1);
4265 if (hGlobal == NULL) return 0;
4266 lpStr = (LPSTR)GlobalLock(hGlobal);
4268 for (i = 0; i < dy; i++)
4272 char **scr = data[0].t.scr->c;
4274 C_MAKE(s, (dx + 1), char);
4275 strncpy(s, &scr[oy + i][ox], dx);
4279 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
4282 if (ox + dx < data[0].cols)
4284 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
4287 for (j = 0; j < dx; j++)
4289 if (s[j] == 127) s[j] = '#';
4293 for (j = 0; j < dx; j++)
4295 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
4305 GlobalUnlock(hGlobal);
4306 if (OpenClipboard(hWnd) == 0)
4308 GlobalFree(hGlobal);
4312 SetClipboardData(CF_TEXT, hGlobal);
4325 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
4326 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
4331 dx = abs(oldx - mousex) + 1;
4332 dy = abs(oldy - mousey) + 1;
4333 ox = (oldx > mousex) ? mousex : oldx;
4334 oy = (oldy > mousey) ? mousey : oldy;
4335 term_inversed_area(hWnd, ox, oy, dx, dy);
4342 dx = abs(cx - mousex) + 1;
4343 dy = abs(cy - mousey) + 1;
4344 ox = (cx > mousex) ? mousex : cx;
4345 oy = (cy > mousey) ? mousey : cy;
4346 term_inversed_area(hWnd, ox, oy, dx, dy);
4362 if (game_in_progress && current_world_ptr->character_generated)
4366 plog(_("今は終了できません。", "You may not do that right now."));
4370 /* Hack -- Forget messages */
4373 forget_lite(p_ptr->current_floor_ptr);
4374 forget_view(p_ptr->current_floor_ptr);
4375 clear_mon_lite(p_ptr->current_floor_ptr);
4377 Term_key_push(SPECIAL_KEY_QUIT);
4384 case WM_QUERYENDSESSION:
4386 if (game_in_progress && current_world_ptr->character_generated)
4388 /* Hack -- Forget messages */
4391 /* Mega-Hack -- Delay death */
4392 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
4393 exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
4395 /* Hardcode panic save */
4396 p_ptr->panic_save = 1;
4398 /* Forbid suspend */
4399 signals_ignore_tstp();
4401 /* Indicate panic save */
4402 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
4405 (void)save_player(p_ptr);
4419 process_menus(p_ptr, LOWORD(wParam));
4425 /* this message was sent before WM_NCCREATE */
4428 /* it was sent from inside CreateWindowEx */
4429 if (!td->w) return 1;
4431 /* was sent from WM_SIZE */
4432 if (td->size_hack) return 1;
4436 case SIZE_MINIMIZED:
4438 /* Hide sub-windows */
4439 for (i = 1; i < MAX_TERM_DATA; i++)
4441 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
4446 case SIZE_MAXIMIZED:
4453 TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4454 TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4457 if ((td->cols != cols) || (td->rows != rows))
4459 /* Save the new size */
4463 if (!IsZoomed(td->w) && !IsIconic(td->w))
4465 normsize.x = td->cols;
4466 normsize.y = td->rows;
4470 Term_activate(&td->t);
4472 /* Resize the term */
4473 Term_resize(td->cols, td->rows);
4476 InvalidateRect(td->w, NULL, TRUE);
4479 td->size_hack = TRUE;
4481 /* Show sub-windows */
4482 for (i = 1; i < MAX_TERM_DATA; i++)
4484 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
4487 td->size_hack = FALSE;
4495 case WM_PALETTECHANGED:
4497 /* Ignore if palette change caused by itself */
4498 if ((HWND)wParam == hWnd) return 0;
4500 /* Fall through... */
4503 case WM_QUERYNEWPALETTE:
4505 if (!paletted) return 0;
4509 SelectPalette(hdc, hPal, FALSE);
4511 i = RealizePalette(hdc);
4513 /* if any palette entries changed, repaint the window. */
4514 if (i) InvalidateRect(hWnd, NULL, TRUE);
4516 ReleaseDC(hWnd, hdc);
4523 if (wParam && !HIWORD(lParam))
4525 /* Do something to sub-windows */
4526 for (i = 1; i < MAX_TERM_DATA; i++)
4528 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
4531 /* Focus on main window */
4540 case WM_ACTIVATEAPP:
4542 if (IsIconic(td->w)) break;
4544 for (i = 1; i < MAX_TERM_DATA; i++)
4546 if (data[i].visible)
4550 ShowWindow(data[i].w, SW_SHOW);
4554 ShowWindow(data[i].w, SW_HIDE);
4561 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4566 * todo WNDCLASSに影響があるのでplayer_type*の追加は保留
4569 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4570 WPARAM wParam, LPARAM lParam);
4571 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4572 WPARAM wParam, LPARAM lParam)
4573 #else /* __MWERKS__ */
4574 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4575 WPARAM wParam, LPARAM lParam)
4576 #endif /* __MWERKS__ */
4584 /* Acquire proper "term_data" info */
4585 td = (term_data *)GetWindowLong(hWnd, 0);
4587 /* Process message */
4592 SetWindowLong(hWnd, 0, (LONG)(my_td));
4601 case WM_GETMINMAXINFO:
4603 MINMAXINFO FAR *lpmmi;
4606 lpmmi = (MINMAXINFO FAR *)lParam;
4608 /* this message was sent before WM_NCCREATE */
4611 /* Minimum window size is 80x24 */
4612 rc.left = rc.top = 0;
4613 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
4614 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4617 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4619 /* Save minimum size */
4620 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4621 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4631 /* this message was sent before WM_NCCREATE */
4634 /* it was sent from inside CreateWindowEx */
4635 if (!td->w) return 1;
4637 /* was sent from inside WM_SIZE */
4638 if (td->size_hack) return 1;
4640 td->size_hack = TRUE;
4642 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4643 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4646 if ((td->cols != cols) || (td->rows != rows))
4649 term *old_term = Term;
4651 /* Save the new size */
4656 Term_activate(&td->t);
4658 /* Resize the term */
4659 Term_resize(td->cols, td->rows);
4662 Term_activate(old_term);
4665 InvalidateRect(td->w, NULL, TRUE);
4667 /* HACK - Redraw all windows */
4668 p_ptr->window = 0xFFFFFFFF;
4669 handle_stuff(p_ptr);
4672 td->size_hack = FALSE;
4679 BeginPaint(hWnd, &ps);
4680 if (td) term_data_redraw(p_ptr, td);
4681 EndPaint(hWnd, &ps);
4688 if (process_keydown(wParam, lParam))
4695 if (term_no_press) term_no_press = FALSE;
4696 else Term_keypress(wParam);
4700 case WM_PALETTECHANGED:
4702 /* ignore if palette change caused by itself */
4703 if ((HWND)wParam == hWnd) return FALSE;
4704 /* otherwise, fall through!!! */
4707 case WM_QUERYNEWPALETTE:
4709 if (!paletted) return 0;
4711 SelectPalette(hdc, hPal, FALSE);
4712 i = RealizePalette(hdc);
4713 /* if any palette entries changed, repaint the window. */
4714 if (i) InvalidateRect(hWnd, NULL, TRUE);
4715 ReleaseDC(hWnd, hdc);
4719 case WM_NCLBUTTONDOWN:
4723 if (wParam == HTCLOSE) wParam = HTSYSMENU;
4724 #endif /* HTCLOSE */
4726 if (wParam == HTSYSMENU)
4730 td->visible = FALSE;
4731 ShowWindow(td->w, SW_HIDE);
4741 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4747 #define MOUSE_SENS 40
4750 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4751 WPARAM wParam, LPARAM lParam);
4752 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4753 WPARAM wParam, LPARAM lParam)
4754 #else /* __MWERKS__ */
4755 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4756 WPARAM wParam, LPARAM lParam)
4757 #endif /* __MWERKS__ */
4759 static int iMouse = 0;
4760 static WORD xMouse = 0;
4761 static WORD yMouse = 0;
4780 case WM_LBUTTONDOWN:
4781 case WM_MBUTTONDOWN:
4782 case WM_RBUTTONDOWN:
4785 SendMessage(hWnd, WM_CLOSE, 0, 0);
4793 dx = LOWORD(lParam) - xMouse;
4794 dy = HIWORD(lParam) - yMouse;
4796 if (dx < 0) dx = -dx;
4797 if (dy < 0) dy = -dy;
4799 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
4801 SendMessage(hWnd, WM_CLOSE, 0, 0);
4805 /* Save last location */
4807 xMouse = LOWORD(lParam);
4808 yMouse = HIWORD(lParam);
4815 DestroyWindow(hwndSaver);
4821 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4824 #endif /* USE_SAVER */
4830 /*** Temporary Hooks ***/
4834 * Display warning message (see "z-util.c")
4836 static void hack_plog(concptr str)
4838 /* Give a warning */
4842 MessageBox(NULL, str, "警告!",
4843 MB_ICONEXCLAMATION | MB_OK);
4845 MessageBox(NULL, str, "Warning",
4846 MB_ICONEXCLAMATION | MB_OK);
4854 * Display error message and quit (see "z-util.c")
4856 static void hack_quit(concptr str)
4858 /* Give a warning */
4862 MessageBox(NULL, str, "エラー!",
4863 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
4865 MessageBox(NULL, str, "Error",
4866 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
4871 /* Unregister the classes */
4872 UnregisterClass(AppName, hInstance);
4874 /* Destroy the icon */
4875 if (hIcon) DestroyIcon(hIcon);
4882 /*** Various hooks ***/
4886 * Display warning message (see "z-util.c")
4888 static void hook_plog(concptr str)
4894 MessageBox(data[0].w, str, "警告!",
4895 MB_ICONEXCLAMATION | MB_OK);
4897 MessageBox(data[0].w, str, "Warning",
4898 MB_ICONEXCLAMATION | MB_OK);
4906 * Display error message and quit (see "z-util.c")
4908 static void hook_quit(concptr str)
4913 /* Give a warning */
4917 MessageBox(data[0].w, str, "エラー!",
4918 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
4920 MessageBox(data[0].w, str, "Error",
4921 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
4927 /* Save the preferences */
4930 /* Destroy all windows */
4931 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
4933 term_force_font(&data[i], NULL);
4934 if (data[i].font_want) string_free(data[i].font_want);
4935 if (data[i].w) DestroyWindow(data[i].w);
4939 /* Free the bitmap stuff */
4940 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
4941 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
4943 if (infMask.hPalette) DeleteObject(infMask.hPalette);
4944 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
4946 /*** Free some other stuff ***/
4948 DeleteObject(hbrYellow);
4953 if (hPal) DeleteObject(hPal);
4955 UnregisterClass(AppName, hInstance);
4957 if (hIcon) DestroyIcon(hIcon);
4964 /*** Initialize ***/
4970 static void init_stuff(void)
4977 /* Get program name with full path */
4978 GetModuleFileName(hInstance, path, 512);
4980 /* Save the "program name" */
4983 /* Get the name of the "*.ini" file */
4984 strcpy(path + strlen(path) - 4, ".INI");
4986 /* Save the the name of the ini-file */
4987 ini_file = string_make(path);
4989 /* Analyze the path */
4995 if (path[i] == '\\')
5002 /* Add "lib" to the path */
5003 strcpy(path + i + 1, "lib\\");
5005 /* Validate the path */
5006 validate_dir(path, TRUE);
5008 /* Init the file paths */
5009 init_file_paths(path);
5011 /* Hack -- Validate the paths */
5012 validate_dir(ANGBAND_DIR_APEX, FALSE);
5013 validate_dir(ANGBAND_DIR_BONE, FALSE);
5015 /* Allow missing 'edit' directory */
5016 if (!check_dir(ANGBAND_DIR_EDIT))
5018 /* Must have 'data'! */
5019 validate_dir(ANGBAND_DIR_DATA, TRUE);
5023 /* Don't need 'data' */
5024 validate_dir(ANGBAND_DIR_DATA, FALSE);
5027 validate_dir(ANGBAND_DIR_FILE, TRUE);
5028 validate_dir(ANGBAND_DIR_HELP, FALSE);
5029 validate_dir(ANGBAND_DIR_INFO, FALSE);
5030 validate_dir(ANGBAND_DIR_PREF, TRUE);
5031 validate_dir(ANGBAND_DIR_SAVE, FALSE);
5032 validate_dir(ANGBAND_DIR_USER, TRUE);
5033 validate_dir(ANGBAND_DIR_XTRA, TRUE);
5034 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
5036 /* Hack -- Validate the "news.txt" file */
5037 validate_file(path);
5039 /* Build the "graf" path */
5040 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
5042 /* Allocate the path */
5043 ANGBAND_DIR_XTRA_GRAF = string_make(path);
5045 /* Validate the "graf" directory */
5046 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
5048 /* Build the "sound" path */
5049 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
5051 /* Allocate the path */
5052 ANGBAND_DIR_XTRA_SOUND = string_make(path);
5054 /* Validate the "sound" directory */
5055 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
5057 /* Build the "music" path */
5058 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
5060 /* Allocate the path */
5061 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
5063 /* Validate the "music" directory */
5064 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
5066 /* Build the "help" path */
5067 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
5069 /* Allocate the path */
5070 ANGBAND_DIR_XTRA_HELP = string_make(path);
5072 /* Validate the "help" directory */
5073 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
5078 * @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
5080 static bool is_already_running(void)
5082 bool result = FALSE;
5085 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
5086 if (GetLastError() == ERROR_ALREADY_EXISTS)
5095 * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
5097 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
5098 LPSTR lpCmdLine, int nCmdShow)
5106 setlocale(LC_ALL, "ja_JP.utf8");
5115 /* Prevent multiple run */
5116 if (is_already_running())
5119 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
5121 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5125 if (hPrevInst == NULL)
5127 wc.style = CS_CLASSDC;
5128 wc.lpfnWndProc = AngbandWndProc;
5130 wc.cbWndExtra = 4; /* one long pointer to term_data */
5131 wc.hInstance = hInst;
5132 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
5133 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
5134 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
5135 wc.lpszMenuName = AppName;
5136 wc.lpszClassName = AppName;
5138 if (!RegisterClass(&wc)) exit(1);
5140 wc.lpfnWndProc = AngbandListProc;
5141 wc.lpszMenuName = NULL;
5142 wc.lpszClassName = AngList;
5144 if (!RegisterClass(&wc)) exit(2);
5148 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
5149 wc.lpfnWndProc = AngbandSaverProc;
5151 wc.lpszMenuName = NULL;
5152 wc.lpszClassName = "WindowsScreenSaverClass";
5154 if (!RegisterClass(&wc)) exit(3);
5160 /* Temporary hooks */
5161 plog_aux = hack_plog;
5162 quit_aux = hack_quit;
5163 core_aux = hack_quit;
5165 /* Prepare the filepaths */
5168 /* Initialize the keypress analyzer */
5169 for (i = 0; special_key_list[i]; ++i)
5171 special_key[special_key_list[i]] = TRUE;
5173 /* Initialize the keypress analyzer */
5174 for (i = 0; ignore_key_list[i]; ++i)
5176 ignore_key[ignore_key_list[i]] = TRUE;
5179 /* Determine if display is 16/256/true color */
5181 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
5182 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
5183 ReleaseDC(NULL, hdc);
5185 /* Initialize the colors */
5186 for (i = 0; i < 256; i++)
5190 /* Extract desired values */
5191 rv = angband_color_table[i][1];
5192 gv = angband_color_table[i][2];
5193 bv = angband_color_table[i][3];
5195 /* Extract the "complex" code */
5196 win_clr[i] = PALETTERGB(rv, gv, bv);
5198 /* Save the "simple" code */
5199 angband_color_table[i][0] = win_pal[i];
5202 /* Prepare the windows */
5208 /* Activate hooks */
5209 plog_aux = hook_plog;
5210 quit_aux = hook_quit;
5211 core_aux = hook_quit;
5213 /* Set the system suffix */
5214 ANGBAND_SYS = "win";
5216 /* Set the keyboard suffix */
5217 if (7 != GetKeyboardType(0))
5218 ANGBAND_KEYBOARD = "0";
5221 /* Japanese keyboard */
5222 switch (GetKeyboardType(1))
5224 case 0x0D01: case 0x0D02:
5225 case 0x0D03: case 0x0D04:
5226 case 0x0D05: case 0x0D06:
5228 ANGBAND_KEYBOARD = "NEC98";
5232 ANGBAND_KEYBOARD = "JAPAN";
5236 /* Catch nasty signals */
5239 Term_activate(term_screen);
5240 init_angband(p_ptr);
5242 /* We are now initialized */
5245 if (lpCmdLine[0] == '-') {
5246 switch (lpCmdLine[1])
5251 if (!lpCmdLine[2]) break;
5252 chuukei_server = TRUE;
5253 if (connect_chuukei_server(&lpCmdLine[2]) < 0) {
5254 msg_print("connect fail");
5257 msg_print("connect");
5265 if (!lpCmdLine[2]) break;
5266 chuukei_client = TRUE;
5267 connect_chuukei_server(&lpCmdLine[2]);
5268 play_game(player_ptr, FALSE);
5275 if (!lpCmdLine[2]) break;
5276 prepare_browse_movie(&lpCmdLine[2]);
5277 play_game(player_ptr, FALSE);
5286 /* Did the user double click on a save file? */
5287 if (!chuukei_server) check_for_save_file(lpCmdLine);
5289 /* Did the user double click on a save file? */
5290 check_for_save_file(p_ptr, lpCmdLine);
5293 /* Prompt the user */
5294 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
5298 /* Process messages forever */
5299 while (GetMessage(&msg, NULL, 0, 0))
5301 TranslateMessage(&msg);
5302 DispatchMessage(&msg);
5309 #endif /* WINDOWS */