3 * @brief Windows版固有実装(メインエントリポイント含む)
5 * @author Hengband Team
6 * @todo main関数を含むファイルの割に長過ぎる。main-win-utils.cなどといった形で分割したい
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 * The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
36 * and/or color redefinitions.
40 * The "lib/user/font-win.prf" contains attr/char mappings for use with the
41 * normal "lib/xtra/font/*.fon" font files.
45 * The "lib/user/graf-win.prf" contains attr/char mappings for use with the
46 * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
51 * Compiling this file, and using the resulting executable, requires
52 * several extra files not distributed with the standard Angband code.
53 * In any case, some "*.fon" files (including "8X13.FON" if nothing else)
54 * must be placed into "lib/xtra/font/". All of these extra files can be found
55 * in the "ext-win" archive.
59 * The "term_xtra_win_clear()" function should probably do a low-level
60 * clear of the current window, and redraw the borders and other things,
61 * if only for efficiency.
65 * A simpler method is needed for selecting the "tile size" for windows.
69 * The various "warning" messages assume the existance of the "screen.w"
70 * window, I think, and only a few calls actually check for its existance,
71 * this may be okay since "NULL" means "on top of all windows". (?) The
72 * user must never be allowed to "hide" the main window, or the "menubar"
77 * Special "Windows Help Files" can be placed into "lib/xtra/help/" for
78 * use with the "winhelp.exe" program. These files *may* be available
79 * at the ftp site somewhere, but I have not seen them.
83 * Initial framework (and most code) by Ben Harrison (benh@phial.com).
85 * Original code by Skirmantas Kligys (kligys@scf.usc.edu).
87 * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
88 * and Chris R. Martin (crm7479@tam2000.tamu.edu).
96 #include "autopick/autopick-pref-processor.h"
97 #include "cmd-io/cmd-process-screen.h"
98 #include "cmd-io/cmd-save.h"
99 #include "core/game-play.h"
100 #include "core/player-processor.h"
101 #include "core/scores.h"
102 #include "core/special-internal-keys.h"
103 #include "core/stuff-handler.h"
104 #include "core/visuals-reseter.h"
105 #include "dungeon/quest.h"
106 #include "floor/floor-base-definitions.h"
107 #include "floor/floor-events.h"
108 #include "game-option/runtime-arguments.h"
109 #include "game-option/special-options.h"
110 #include "io/files-util.h"
111 #include "io/input-key-acceptor.h"
112 #include "io/record-play-movie.h"
113 #include "io/signal-handlers.h"
114 #include "io/write-diary.h"
115 #include "main-win/main-win-bg.h"
116 #include "main-win/main-win-file-utils.h"
117 #include "main-win/main-win-mci.h"
118 #include "main-win/main-win-music.h"
119 #include "main-win/main-win-sound.h"
120 #include "main/angband-initializer.h"
121 #include "main/sound-of-music.h"
122 #include "monster-floor/monster-lite.h"
123 #include "save/save.h"
124 #include "system/angband-version.h"
125 #include "system/angband.h"
126 #include "system/floor-type-definition.h"
127 #include "system/system-variables.h"
128 #include "term/gameterm.h"
129 #include "term/screen-processor.h"
130 #include "term/term-color-types.h"
131 #include "util/angband-files.h"
132 #include "util/int-char-converter.h"
133 #include "util/string-processor.h"
134 #include "view/display-map.h"
135 #include "view/display-messages.h"
136 #include "wizard/spoiler-util.h"
137 #include "wizard/wizard-spoiler.h"
138 #include "world/world.h"
145 * Include the support for loading bitmaps
147 #include "term/readdib.h"
149 #define MOUSE_SENS 40
152 * Available graphic modes
154 #define GRAPHICS_NONE 0
155 #define GRAPHICS_ORIGINAL 1
156 #define GRAPHICS_ADAM_BOLT 2
157 #define GRAPHICS_HENGBAND 3
160 * Menu constants -- see "ANGBAND.RC"
162 #define IDM_FILE_NEW 100
163 #define IDM_FILE_OPEN 101
164 #define IDM_FILE_SAVE 110
165 #define IDM_FILE_SCORE 120
166 #define IDM_FILE_MOVIE 121
167 #define IDM_FILE_EXIT 130
169 #define IDM_WINDOW_VIS_0 200
170 #define IDM_WINDOW_VIS_1 201
171 #define IDM_WINDOW_VIS_2 202
172 #define IDM_WINDOW_VIS_3 203
173 #define IDM_WINDOW_VIS_4 204
174 #define IDM_WINDOW_VIS_5 205
175 #define IDM_WINDOW_VIS_6 206
176 #define IDM_WINDOW_VIS_7 207
178 #define IDM_WINDOW_FONT_0 210
179 #define IDM_WINDOW_FONT_1 211
180 #define IDM_WINDOW_FONT_2 212
181 #define IDM_WINDOW_FONT_3 213
182 #define IDM_WINDOW_FONT_4 214
183 #define IDM_WINDOW_FONT_5 215
184 #define IDM_WINDOW_FONT_6 216
185 #define IDM_WINDOW_FONT_7 217
187 #define IDM_WINDOW_POS_0 220
188 #define IDM_WINDOW_POS_1 221
189 #define IDM_WINDOW_POS_2 222
190 #define IDM_WINDOW_POS_3 223
191 #define IDM_WINDOW_POS_4 224
192 #define IDM_WINDOW_POS_5 225
193 #define IDM_WINDOW_POS_6 226
194 #define IDM_WINDOW_POS_7 227
196 #define IDM_WINDOW_BIZ_0 230
197 #define IDM_WINDOW_BIZ_1 231
198 #define IDM_WINDOW_BIZ_2 232
199 #define IDM_WINDOW_BIZ_3 233
200 #define IDM_WINDOW_BIZ_4 234
201 #define IDM_WINDOW_BIZ_5 235
202 #define IDM_WINDOW_BIZ_6 236
203 #define IDM_WINDOW_BIZ_7 237
205 #define IDM_WINDOW_I_WID_0 240
206 #define IDM_WINDOW_I_WID_1 241
207 #define IDM_WINDOW_I_WID_2 242
208 #define IDM_WINDOW_I_WID_3 243
209 #define IDM_WINDOW_I_WID_4 244
210 #define IDM_WINDOW_I_WID_5 245
211 #define IDM_WINDOW_I_WID_6 246
212 #define IDM_WINDOW_I_WID_7 247
214 #define IDM_WINDOW_D_WID_0 250
215 #define IDM_WINDOW_D_WID_1 251
216 #define IDM_WINDOW_D_WID_2 252
217 #define IDM_WINDOW_D_WID_3 253
218 #define IDM_WINDOW_D_WID_4 254
219 #define IDM_WINDOW_D_WID_5 255
220 #define IDM_WINDOW_D_WID_6 256
221 #define IDM_WINDOW_D_WID_7 257
223 #define IDM_WINDOW_I_HGT_0 260
224 #define IDM_WINDOW_I_HGT_1 261
225 #define IDM_WINDOW_I_HGT_2 262
226 #define IDM_WINDOW_I_HGT_3 263
227 #define IDM_WINDOW_I_HGT_4 264
228 #define IDM_WINDOW_I_HGT_5 265
229 #define IDM_WINDOW_I_HGT_6 266
230 #define IDM_WINDOW_I_HGT_7 267
232 #define IDM_WINDOW_D_HGT_0 270
233 #define IDM_WINDOW_D_HGT_1 271
234 #define IDM_WINDOW_D_HGT_2 272
235 #define IDM_WINDOW_D_HGT_3 273
236 #define IDM_WINDOW_D_HGT_4 274
237 #define IDM_WINDOW_D_HGT_5 275
238 #define IDM_WINDOW_D_HGT_6 276
239 #define IDM_WINDOW_D_HGT_7 277
241 #define IDM_WINDOW_KEEP_SUBWINDOWS 280
243 #define IDM_OPTIONS_NO_GRAPHICS 400
244 #define IDM_OPTIONS_OLD_GRAPHICS 401
245 #define IDM_OPTIONS_NEW_GRAPHICS 402
246 #define IDM_OPTIONS_NEW2_GRAPHICS 403
247 #define IDM_OPTIONS_BIGTILE 409
248 #define IDM_OPTIONS_SOUND 410
249 #define IDM_OPTIONS_MUSIC 411
250 #define IDM_OPTIONS_SAVER 420
251 #define IDM_OPTIONS_MAP 430
252 #define IDM_OPTIONS_BG 440
253 #define IDM_OPTIONS_OPEN_BG 441
255 #define IDM_DUMP_SCREEN_HTML 450
257 #define IDM_HELP_CONTENTS 901
260 * Foreground color bits
262 #define VID_BLACK 0x00
263 #define VID_BLUE 0x01
264 #define VID_GREEN 0x02
265 #define VID_CYAN 0x03
267 #define VID_MAGENTA 0x05
268 #define VID_YELLOW 0x06
269 #define VID_WHITE 0x07
274 #define VID_BRIGHT 0x08
278 * @brief ターム情報構造体 / Extra "term" data
281 * pos_x / pos_y は各タームの左上点座標を指す。
284 * tile_wid / tile_hgt は[ウィンドウ]メニューのタイルの幅/高さを~を
285 * 1ドットずつ調整するステータスを指す。
286 * また、フォントを変更すると都度自動調整される。
289 * Note the use of "font_want" for the names of the font file requested by
290 * the user, and the use of "font_file" for the currently active font file.
292 * The "font_file" is uppercased, and takes the form "8X13.FON", while
293 * "font_want" can be in almost any form as long as it could be construed
294 * as attempting to represent the name of a font.
305 TERM_LEN rows; /* int -> uint */
308 uint pos_x; //!< タームの左上X座標
309 uint pos_y; //!< タームの左上Y座標
324 int font_wid; //!< フォント横幅
325 int font_hgt; //!< フォント縦幅
326 int tile_wid; //!< タイル横幅
327 int tile_hgt; //!< タイル縦幅
338 #define MAX_TERM_DATA 8 //!< Maximum number of windows
340 static term_data data[MAX_TERM_DATA]; //!< An array of term_data's
341 static term_data *my_td; //!< Hack -- global "window creation" pointer
342 POINT normsize; //!< Remember normal size of main window when maxmized
345 * was main window maximized on previous playing
347 bool win_maximized = FALSE;
352 bool game_in_progress = FALSE;
355 * note when "open"/"new" become valid
357 bool initialized = FALSE;
360 * screen paletted, i.e. 256 colors
362 bool paletted = FALSE;
365 * 16 colors screen, don't use RGB()
367 bool colors16 = FALSE;
370 * Saved instance handle
372 static HINSTANCE hInstance;
375 * Yellow brush for the cursor
377 static HBRUSH hbrYellow;
387 static HPALETTE hPal;
390 static int use_bg = 0; //!< 背景使用フラグ、1なら使用。
391 #define DEFAULT_BG_FILENAME "bg.bmp"
394 * The screen saver window
396 static HWND hwndSaver;
399 * 現在使用中のタイルID(0ならば未使用)
400 * Flag set once "graphics" has been initialized
402 static byte current_graphics_mode = 0;
407 static DIBINIT infGraph;
410 * The global bitmap mask
412 static DIBINIT infMask;
415 * Show sub-windows even when Hengband is not in focus
417 static bool keep_subwindows = TRUE;
420 * Full path to ANGBAND.INI
422 static concptr ini_file = NULL;
425 * Name of application
427 static concptr AppName = "ANGBAND";
430 * Name of sub-window type
432 static concptr AngList = "AngList";
437 static concptr ANGBAND_DIR_XTRA_GRAF;
438 static concptr ANGBAND_DIR_XTRA_HELP;
441 * The "complex" color values
443 static COLORREF win_clr[256];
446 * Flag for macro trigger with dump ASCII
448 static bool term_no_press = FALSE;
453 static bool mouse_down = FALSE;
454 static bool paint_rect = FALSE;
455 static TERM_LEN mousex = 0, mousey = 0;
456 static TERM_LEN oldx, oldy;
459 * @brief The "simple" color values
461 * See "main-ibm.c" for original table information
462 * The entries below are taken from the "color bits" defined above.
463 * Note that many of the choices below suck, but so do crappy monitors.
465 static BYTE win_pal[256] = {
466 VID_BLACK, /* Dark */
467 VID_WHITE, /* White */
468 VID_CYAN, /* Slate XXX */
469 VID_RED | VID_BRIGHT, /* Orange XXX */
471 VID_GREEN, /* Green */
473 VID_YELLOW, /* Umber XXX */
474 VID_BLACK | VID_BRIGHT, /* Light Dark */
475 VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
476 VID_MAGENTA, /* Violet XXX */
477 VID_YELLOW | VID_BRIGHT, /* Yellow */
478 VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
479 VID_GREEN | VID_BRIGHT, /* Light Green */
480 VID_BLUE | VID_BRIGHT, /* Light Blue */
481 VID_YELLOW /* Light Umber XXX */
485 * Hack -- define which keys are "special"
487 static bool special_key[256];
488 static bool ignore_key[256];
491 * Hack -- initialization list for "special_key"
493 static byte special_key_list[] = {
494 VK_CLEAR, VK_PAUSE, VK_CAPITAL, VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI, VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE, VK_PRIOR, VK_NEXT, VK_END,
495 VK_HOME, VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN, VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT, VK_INSERT, VK_DELETE, VK_HELP, VK_APPS, VK_NUMPAD0, VK_NUMPAD1,
496 VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7, VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD, VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL,
497 VK_DIVIDE, VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12, VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18, VK_F19,
498 VK_F20, VK_F21, VK_F22, VK_F23, VK_F24, VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL, VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM, VK_NONAME, VK_PA1,
502 static byte ignore_key_list[] = {
503 VK_ESCAPE, VK_TAB, VK_SPACE, 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
504 VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL, VK_LMENU, VK_RMENU, 0 /* End of List */
510 static void validate_file(concptr s)
515 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
519 * Validate a directory
521 static void validate_dir(concptr s, bool vital)
527 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
528 } else if (mkdir(s)) {
529 quit_fmt("Unable to create directory:\n%s", s);
534 * @brief (Windows版固有実装)Get the "size" for a window
536 static void term_getsize(term_data *td)
543 TERM_LEN wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
544 TERM_LEN hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
548 GetWindowRect(td->w, &rw);
549 GetClientRect(td->w, &rc);
551 td->size_wid = (rw.right - rw.left) - (rc.right - rc.left) + wid;
552 td->size_hgt = (rw.bottom - rw.top) - (rc.bottom - rc.top) + hgt;
557 /* Tempolary calculation */
562 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
563 td->size_wid = rc.right - rc.left;
564 td->size_hgt = rc.bottom - rc.top;
569 * Write the "prefs" for a single term
571 static void save_prefs_aux(int i)
573 term_data *td = &data[i];
574 GAME_TEXT sec_name[128];
580 sprintf(sec_name, "Term-%d", i);
583 strcpy(buf, td->visible ? "1" : "0");
584 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
588 strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "MS ゴシック");
590 strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "Courier");
593 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
595 wsprintf(buf, "%d", td->lf.lfWidth);
596 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
597 wsprintf(buf, "%d", td->lf.lfHeight);
598 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
599 wsprintf(buf, "%d", td->lf.lfWeight);
600 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
602 strcpy(buf, td->bizarre ? "1" : "0");
603 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
605 wsprintf(buf, "%d", td->tile_wid);
606 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
608 wsprintf(buf, "%d", td->tile_hgt);
609 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
611 WINDOWPLACEMENT lpwndpl;
612 lpwndpl.length = sizeof(WINDOWPLACEMENT);
613 GetWindowPlacement(td->w, &lpwndpl);
615 RECT rc = lpwndpl.rcNormalPosition;
617 wsprintf(buf, "%d", normsize.x);
619 wsprintf(buf, "%d", td->cols);
621 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
624 wsprintf(buf, "%d", normsize.y);
626 wsprintf(buf, "%d", td->rows);
628 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
630 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
631 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
634 GetWindowRect(td->w, &rc);
635 wsprintf(buf, "%d", rc.left);
636 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
638 wsprintf(buf, "%d", rc.top);
639 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
641 strcpy(buf, td->posfix ? "1" : "0");
642 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
648 * We assume that the windows have all been initialized
650 static void save_prefs(void)
653 sprintf(buf, "%d", arg_graphics);
654 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
656 strcpy(buf, arg_bigtile ? "1" : "0");
657 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
659 strcpy(buf, arg_sound ? "1" : "0");
660 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
662 strcpy(buf, arg_music ? "1" : "0");
663 WritePrivateProfileString("Angband", "Music", buf, ini_file);
665 strcpy(buf, use_bg ? "1" : "0");
666 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
667 WritePrivateProfileString("Angband", "BackGroundBitmap", bg_bitmap_file[0] != '\0' ? bg_bitmap_file : DEFAULT_BG_FILENAME, ini_file);
669 int path_length = strlen(ANGBAND_DIR) - 4; /* \libの4文字分を削除 */
671 strncat(tmp, ANGBAND_DIR, path_length);
673 int n = strncmp(tmp, savefile, path_length);
675 char relative_path[1024] = "";
676 snprintf(relative_path, sizeof(relative_path), ".\\%s", (savefile + path_length));
677 WritePrivateProfileString("Angband", "SaveFile", relative_path, ini_file);
679 WritePrivateProfileString("Angband", "SaveFile", savefile, ini_file);
682 strcpy(buf, keep_subwindows ? "1" : "0");
683 WritePrivateProfileString("Angband", "KeepSubwindows", buf, ini_file);
685 for (int i = 0; i < MAX_TERM_DATA; ++i) {
691 * Load the "prefs" for a single term
693 static void load_prefs_aux(int i)
695 term_data *td = &data[i];
696 GAME_TEXT sec_name[128];
699 int dispx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
700 int dispy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
704 sprintf(sec_name, "Term-%d", i);
705 sprintf(sec_name, "Term-%d", i);
707 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
711 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
713 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
716 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
718 td->font_want = string_make(tmp);
721 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
722 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
723 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
725 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
726 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
728 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
729 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
730 normsize.x = td->cols;
731 normsize.y = td->rows;
734 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
737 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
738 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
739 td->pos_x = MIN(MAX(0, posx), dispx - 128);
740 td->pos_y = MIN(MAX(0, posy), dispy - 128);
743 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
750 static void load_prefs(void)
752 arg_graphics = (byte)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
753 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
754 use_bigtile = arg_bigtile;
755 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
756 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
757 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
758 GetPrivateProfileString("Angband", "BackGroundBitmap", DEFAULT_BG_FILENAME, bg_bitmap_file, 1023, ini_file);
759 GetPrivateProfileString("Angband", "SaveFile", "", savefile, 1023, ini_file);
761 int n = strncmp(".\\", savefile, 2);
763 int path_length = strlen(ANGBAND_DIR) - 4; /* \libの4文字分を削除 */
765 strncat(tmp, ANGBAND_DIR, path_length);
766 strncat(tmp, savefile + 2, strlen(savefile) - 2 + path_length);
767 strncpy(savefile, tmp, strlen(tmp));
770 keep_subwindows = (GetPrivateProfileInt("Angband", "KeepSubwindows", 0, ini_file) != 0);
771 for (int i = 0; i < MAX_TERM_DATA; ++i) {
777 * Create the new global palette based on the bitmap palette
778 * (if any), and the standard 16 entry palette derived from
779 * "win_clr[]" which is used for the basic 16 Angband colors.
781 * This function is never called before all windows are ready.
783 * This function returns FALSE if the new palette could not be
784 * prepared, which should normally be a fatal error. XXX XXX
786 * Note that only some machines actually use a "palette".
788 static int new_palette(void)
793 LPLOGPALETTE pLogPal;
803 HPALETTE hBmPal = static_cast<HPALETTE>(infGraph.hPalette);
805 lppeSize = 256 * sizeof(PALETTEENTRY);
806 lppe = (LPPALETTEENTRY)std::malloc(lppeSize);
807 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
808 if ((nEntries == 0) || (nEntries > 220)) {
809 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
815 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
816 pLogPal = (LPLOGPALETTE)std::malloc(pLogPalSize);
817 pLogPal->palVersion = 0x300;
818 pLogPal->palNumEntries = nEntries + 16;
819 for (i = 0; i < nEntries; i++) {
820 pLogPal->palPalEntry[i] = lppe[i];
823 for (i = 0; i < 16; i++) {
825 p = &(pLogPal->palPalEntry[i + nEntries]);
826 p->peRed = GetRValue(win_clr[i]);
827 p->peGreen = GetGValue(win_clr[i]);
828 p->peBlue = GetBValue(win_clr[i]);
829 p->peFlags = PC_NOCOLLAPSE;
835 HPALETTE hNewPal = CreatePalette(pLogPal);
837 quit(_("パレットを作成できません!", "Cannot create palette!"));
841 HDC hdc = GetDC(td->w);
842 SelectPalette(hdc, hNewPal, 0);
843 i = RealizePalette(hdc);
844 ReleaseDC(td->w, hdc);
846 quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
848 for (i = 1; i < MAX_TERM_DATA; i++) {
851 SelectPalette(hdc, hNewPal, 0);
852 ReleaseDC(td->w, hdc);
863 * @brief グラフィクスを初期化する / Initialize graphics
866 * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
867 * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
870 static bool init_graphics(void)
873 BYTE wid, hgt, twid, thgt, ox, oy;
876 if (arg_graphics == GRAPHICS_ADAM_BOLT) {
885 ANGBAND_GRAF = "new";
886 } else if (arg_graphics == GRAPHICS_HENGBAND) {
895 ANGBAND_GRAF = "ne2";
904 ANGBAND_GRAF = "old";
907 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
908 if (!ReadDIB(data[0].w, buf, &infGraph)) {
909 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
913 infGraph.CellWidth = wid;
914 infGraph.CellHeight = hgt;
915 infGraph.TileWidth = twid;
916 infGraph.TileHeight = thgt;
917 infGraph.OffsetX = ox;
918 infGraph.OffsetY = oy;
920 if (arg_graphics == GRAPHICS_ADAM_BOLT) {
921 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
922 if (!ReadDIB(data[0].w, buf, &infMask)) {
923 plog_fmt("Cannot read bitmap file '%s'", buf);
928 if (arg_graphics == GRAPHICS_HENGBAND) {
929 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
930 if (!ReadDIB(data[0].w, buf, &infMask)) {
931 plog_fmt("Cannot read bitmap file '%s'", buf);
936 if (!new_palette()) {
937 plog(_("パレットを実現できません!", "Cannot activate palette!"));
941 current_graphics_mode = arg_graphics;
942 return current_graphics_mode != 0;
948 static void init_music(void)
950 // Flag set once "music" has been initialized
951 static bool can_use_music = FALSE;
953 if (!can_use_music) {
954 main_win_music::load_music_prefs(current_world_ptr->max_d_idx, max_q_idx);
955 can_use_music = TRUE;
962 static void init_sound(void)
964 // Flag set once "sound" has been initialized
965 static bool can_use_sound = FALSE;
967 if (!can_use_sound) {
969 can_use_sound = TRUE;
974 * Initialize background
976 static void init_background(void)
978 // Flag set once "background" has been initialized
979 static bool can_use_background = FALSE;
981 if (!can_use_background) {
983 can_use_background = TRUE;
988 * @brief Resize a window
990 static void term_window_resize(term_data *td)
995 SetWindowPos(td->w, 0, 0, 0, td->size_wid, td->size_hgt, SWP_NOMOVE | SWP_NOZORDER);
996 InvalidateRect(td->w, NULL, TRUE);
1000 * @brief Force the use of a new "font file" for a term_data.
1001 * This function may be called before the "window" is ready.
1002 * This function returns zero only if everything succeeds.
1003 * @note that the "font name" must be capitalized!!!
1006 static errr term_force_font(term_data *td, concptr path)
1009 DeleteObject(td->font_id);
1012 td->font_id = CreateFontIndirect(&(td->lf));
1013 int wid = td->lf.lfWidth;
1014 int hgt = td->lf.lfHeight;
1023 hdcDesktop = GetDC(HWND_DESKTOP);
1024 hfOld = static_cast<HFONT>(SelectObject(hdcDesktop, td->font_id));
1025 GetTextMetrics(hdcDesktop, &tm);
1026 SelectObject(hdcDesktop, hfOld);
1027 ReleaseDC(HWND_DESKTOP, hdcDesktop);
1029 wid = tm.tmAveCharWidth;
1040 * Allow the user to change the font for this window.
1042 static void term_change_font(term_data *td)
1045 memset(&cf, 0, sizeof(cf));
1046 cf.lStructSize = sizeof(cf);
1047 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
1048 cf.lpLogFont = &(td->lf);
1050 if (!ChooseFont(&cf))
1053 term_force_font(td, NULL);
1055 td->tile_wid = td->font_wid;
1056 td->tile_hgt = td->font_hgt;
1058 term_window_resize(td);
1062 * Allow the user to lock this window.
1064 static void term_window_pos(term_data *td, HWND hWnd)
1066 SetWindowPos(td->w, hWnd, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1069 static void windows_map(player_type *player_ptr);
1072 * Hack -- redraw a term_data
1074 static void term_data_redraw(player_type *player_ptr, term_data *td)
1076 if (td->map_active) {
1077 windows_map(player_ptr);
1081 term_activate(&td->t);
1083 term_activate(term_screen);
1086 void term_inversed_area(HWND hWnd, int x, int y, int w, int h)
1088 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
1089 int tx = td->size_ow1 + x * td->tile_wid;
1090 int ty = td->size_oh1 + y * td->tile_hgt;
1091 int tw = w * td->tile_wid - 1;
1092 int th = h * td->tile_hgt - 1;
1094 HDC hdc = GetDC(hWnd);
1095 HBRUSH myBrush = CreateSolidBrush(RGB(255, 255, 255));
1096 HBRUSH oldBrush = static_cast<HBRUSH>(SelectObject(hdc, myBrush));
1097 HPEN oldPen = static_cast<HPEN>(SelectObject(hdc, GetStockObject(NULL_PEN)));
1099 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
1101 SelectObject(hdc, oldBrush);
1102 SelectObject(hdc, oldPen);
1106 * @brief //!< Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
1108 static errr term_user_win(int n)
1115 * React to global changes
1117 static errr term_xtra_win_react(player_type *player_ptr)
1120 for (int i = 0; i < 256; i++) {
1121 win_pal[i] = angband_color_table[i][0];
1126 bool change = FALSE;
1127 for (int i = 0; i < 256; i++) {
1128 rv = angband_color_table[i][1];
1129 gv = angband_color_table[i][2];
1130 bv = angband_color_table[i][3];
1131 code = PALETTERGB(rv, gv, bv);
1132 if (win_clr[i] != code) {
1139 (void)new_palette();
1142 if (use_sound != arg_sound) {
1144 use_sound = arg_sound;
1147 if (use_music != arg_music) {
1149 use_music = arg_music;
1151 main_win_music::stop_music();
1153 select_floor_music(player_ptr);
1156 if (use_graphics != (arg_graphics > 0)) {
1157 if (arg_graphics && !init_graphics()) {
1158 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
1159 arg_graphics = GRAPHICS_NONE;
1162 use_graphics = (arg_graphics > 0);
1163 reset_visuals(player_ptr, process_autopick_file_command);
1166 for (int i = 0; i < MAX_TERM_DATA; i++) {
1167 term_type *old = Term;
1168 term_data *td = &data[i];
1169 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt)) {
1170 term_activate(&td->t);
1171 term_resize(td->cols, td->rows);
1181 * Process at least one event
1183 static errr term_xtra_win_event(int v)
1187 if (GetMessage(&msg, NULL, 0, 0)) {
1188 TranslateMessage(&msg);
1189 DispatchMessage(&msg);
1192 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
1193 TranslateMessage(&msg);
1194 DispatchMessage(&msg);
1202 * Process all pending events
1204 static errr term_xtra_win_flush(void)
1207 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
1208 TranslateMessage(&msg);
1209 DispatchMessage(&msg);
1216 * Hack -- clear the screen
1218 * Make this more efficient
1220 static errr term_xtra_win_clear(void)
1222 term_data *td = (term_data *)(Term->data);
1225 rc.left = td->size_ow1;
1226 rc.right = rc.left + td->cols * td->tile_wid;
1227 rc.top = td->size_oh1;
1228 rc.bottom = rc.top + td->rows * td->tile_hgt;
1230 HDC hdc = GetDC(td->w);
1231 SetBkColor(hdc, RGB(0, 0, 0));
1232 SelectObject(hdc, td->font_id);
1233 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
1241 ReleaseDC(td->w, hdc);
1246 * Hack -- make a noise
1248 static errr term_xtra_win_noise(void)
1250 MessageBeep(MB_ICONASTERISK);
1255 * Hack -- make a sound
1257 static errr term_xtra_win_sound(int v)
1261 return play_sound(v);
1265 * Hack -- play a music
1267 static errr term_xtra_win_music(int n, int v)
1269 // FIXME use_musicの値に関わらずミュートを実行している
1270 if (n == TERM_XTRA_MUSIC_MUTE)
1271 main_win_music::stop_music();
1277 return main_win_music::play_music(n, v);
1281 * Delay for "x" milliseconds
1283 static int term_xtra_win_delay(int v)
1290 * @brief Do a "special thing"
1291 * @todo z-termに影響があるのでplayer_typeの追加は保留
1293 static errr term_xtra_win(int n, int v)
1296 case TERM_XTRA_NOISE: {
1297 return (term_xtra_win_noise());
1299 case TERM_XTRA_MUSIC_BASIC:
1300 case TERM_XTRA_MUSIC_DUNGEON:
1301 case TERM_XTRA_MUSIC_QUEST:
1302 case TERM_XTRA_MUSIC_TOWN:
1303 case TERM_XTRA_MUSIC_MUTE: {
1304 return (term_xtra_win_music(n, v));
1306 case TERM_XTRA_SOUND: {
1307 return (term_xtra_win_sound(v));
1309 case TERM_XTRA_BORED: {
1310 return (term_xtra_win_event(0));
1312 case TERM_XTRA_EVENT: {
1313 return (term_xtra_win_event(v));
1315 case TERM_XTRA_FLUSH: {
1316 return (term_xtra_win_flush());
1318 case TERM_XTRA_CLEAR: {
1319 return (term_xtra_win_clear());
1321 case TERM_XTRA_REACT: {
1322 return (term_xtra_win_react(p_ptr));
1324 case TERM_XTRA_DELAY: {
1325 return (term_xtra_win_delay(v));
1333 * Low level graphics (Assumes valid input).
1335 * Draw a "cursor" at (x,y), using a "yellow box".
1337 static errr term_curs_win(int x, int y)
1339 term_data *td = (term_data *)(Term->data);
1340 int tile_wid, tile_hgt;
1341 if (td->map_active) {
1342 tile_wid = td->map_tile_wid;
1343 tile_hgt = td->map_tile_hgt;
1345 tile_wid = td->tile_wid;
1346 tile_hgt = td->tile_hgt;
1350 rc.left = x * tile_wid + td->size_ow1;
1351 rc.right = rc.left + tile_wid;
1352 rc.top = y * tile_hgt + td->size_oh1;
1353 rc.bottom = rc.top + tile_hgt;
1355 HDC hdc = GetDC(td->w);
1356 FrameRect(hdc, &rc, hbrYellow);
1357 ReleaseDC(td->w, hdc);
1362 * Low level graphics (Assumes valid input).
1364 * Draw a "big cursor" at (x,y), using a "yellow box".
1366 static errr term_bigcurs_win(int x, int y)
1368 term_data *td = (term_data *)(Term->data);
1369 int tile_wid, tile_hgt;
1370 if (td->map_active) {
1371 term_curs_win(x, y);
1374 tile_wid = td->tile_wid;
1375 tile_hgt = td->tile_hgt;
1379 rc.left = x * tile_wid + td->size_ow1;
1380 rc.right = rc.left + 2 * tile_wid;
1381 rc.top = y * tile_hgt + td->size_oh1;
1382 rc.bottom = rc.top + tile_hgt;
1384 HDC hdc = GetDC(td->w);
1385 FrameRect(hdc, &rc, hbrYellow);
1386 ReleaseDC(td->w, hdc);
1391 * Low level graphics (Assumes valid input).
1393 * Erase a "block" of "n" characters starting at (x,y).
1395 static errr term_wipe_win(int x, int y, int n)
1397 term_data *td = (term_data *)(Term->data);
1399 rc.left = x * td->tile_wid + td->size_ow1;
1400 rc.right = rc.left + n * td->tile_wid;
1401 rc.top = y * td->tile_hgt + td->size_oh1;
1402 rc.bottom = rc.top + td->tile_hgt;
1404 HDC hdc = GetDC(td->w);
1405 SetBkColor(hdc, RGB(0, 0, 0));
1406 SelectObject(hdc, td->font_id);
1410 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
1412 ReleaseDC(td->w, hdc);
1417 * Low level graphics. Assumes valid input.
1419 * Draw several ("n") chars, with an attr, at a given location.
1421 * All "graphic" data is handled by "term_pict_win()", below.
1423 * One would think there is a more efficient method for telling a window
1424 * what color it should be using to draw with, but perhaps simply changing
1425 * it every time is not too inefficient.
1427 static errr term_text_win(int x, int y, int n, TERM_COLOR a, concptr s)
1429 term_data *td = (term_data *)(Term->data);
1430 static HBITMAP WALL;
1431 static HBRUSH myBrush, oldBrush;
1433 static bool init_done = FALSE;
1436 WALL = LoadBitmap(hInstance, AppName);
1437 myBrush = CreatePatternBrush(WALL);
1442 rc.left = x * td->tile_wid + td->size_ow1;
1443 rc.right = rc.left + n * td->tile_wid;
1444 rc.top = y * td->tile_hgt + td->size_oh1;
1445 rc.bottom = rc.top + td->tile_hgt;
1447 HDC hdc = GetDC(td->w);
1448 SetBkColor(hdc, RGB(0, 0, 0));
1450 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
1451 } else if (paletted) {
1452 SetTextColor(hdc, win_clr[a & 0x0F]);
1454 SetTextColor(hdc, win_clr[a]);
1457 SelectObject(hdc, td->font_id);
1459 SetBkMode(hdc, TRANSPARENT);
1461 if (td->bizarre || (td->tile_hgt != td->font_hgt) || (td->tile_wid != td->font_wid)) {
1462 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
1466 rc.left += ((td->tile_wid - td->font_wid) / 2);
1467 rc.right = rc.left + td->font_wid;
1468 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
1469 rc.bottom = rc.top + td->font_hgt;
1471 for (int i = 0; i < n; i++) {
1473 if (use_bigtile && *(s + i) == "■"[0] && *(s + i + 1) == "■"[1]) {
1474 rc.right += td->font_wid;
1475 oldBrush = static_cast<HBRUSH>(SelectObject(hdc, myBrush));
1476 oldPen = static_cast<HPEN>(SelectObject(hdc, GetStockObject(NULL_PEN)));
1477 Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
1478 SelectObject(hdc, oldBrush);
1479 SelectObject(hdc, oldPen);
1480 rc.right -= td->font_wid;
1482 rc.left += 2 * td->tile_wid;
1483 rc.right += 2 * td->tile_wid;
1484 } else if (iskanji(*(s + i))) /* 2バイト文字 */
1486 rc.right += td->font_wid;
1487 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 2, NULL);
1488 rc.right -= td->font_wid;
1490 rc.left += 2 * td->tile_wid;
1491 rc.right += 2 * td->tile_wid;
1492 } else if (*(s + i) == 127) {
1493 oldBrush = static_cast<HBRUSH>(SelectObject(hdc, myBrush));
1494 oldPen = static_cast<HPEN>(SelectObject(hdc, GetStockObject(NULL_PEN)));
1495 Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
1496 SelectObject(hdc, oldBrush);
1497 SelectObject(hdc, oldPen);
1498 rc.left += td->tile_wid;
1499 rc.right += td->tile_wid;
1501 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
1502 rc.left += td->tile_wid;
1503 rc.right += td->tile_wid;
1506 if (*(s + i) == 127) {
1507 oldBrush = static_cast<HBRUSH>(SelectObject(hdc, myBrush));
1508 oldPen = static_cast<HPEN>(SelectObject(hdc, GetStockObject(NULL_PEN)));
1509 Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
1510 SelectObject(hdc, oldBrush);
1511 SelectObject(hdc, oldPen);
1512 rc.left += td->tile_wid;
1513 rc.right += td->tile_wid;
1515 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
1516 rc.left += td->tile_wid;
1517 rc.right += td->tile_wid;
1522 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc, s, n, NULL);
1525 ReleaseDC(td->w, hdc);
1530 * Low level graphics. Assumes valid input.
1532 * Draw an array of "special" attr/char pairs at the given location.
1534 * We use the "term_pict_win()" function for "graphic" data, which are
1535 * encoded by setting the "high-bits" of both the "attr" and the "char"
1536 * data. We use the "attr" to represent the "row" of the main bitmap,
1537 * and the "char" to represent the "col" of the main bitmap. The use
1538 * of this function is induced by the "higher_pict" flag.
1540 * If "graphics" is not available, we simply "wipe" the given grids.
1542 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)
1544 term_data *td = (term_data *)(Term->data);
1547 if (!use_graphics) {
1548 return (term_wipe_win(x, y, n));
1551 TERM_LEN w1 = infGraph.CellWidth;
1552 TERM_LEN h1 = infGraph.CellHeight;
1553 TERM_LEN tw1 = infGraph.TileWidth;
1554 TERM_LEN th1 = infGraph.TileHeight;
1555 TERM_LEN w2, h2, tw2 = 0;
1556 if (td->map_active) {
1557 w2 = td->map_tile_wid;
1558 h2 = td->map_tile_hgt;
1567 TERM_LEN x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
1568 TERM_LEN y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
1569 HDC hdc = GetDC(td->w);
1570 HDC hdcSrc = CreateCompatibleDC(hdc);
1571 HBITMAP hbmSrcOld = static_cast<HBITMAP>(SelectObject(hdcSrc, infGraph.hBitmap));
1573 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND) {
1574 hdcMask = CreateCompatibleDC(hdc);
1575 SelectObject(hdcMask, infMask.hBitmap);
1578 for (i = 0; i < n; i++, x2 += w2) {
1579 TERM_COLOR a = ap[i];
1581 int row = (a & 0x7F);
1582 int col = (c & 0x7F);
1583 TERM_LEN x1 = col * w1;
1584 TERM_LEN y1 = row * h1;
1586 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND) {
1587 TERM_LEN x3 = (tcp[i] & 0x7F) * w1;
1588 TERM_LEN y3 = (tap[i] & 0x7F) * h1;
1589 tw2 = tw2 * w1 / tw1;
1591 if ((tw1 == tw2) && (th1 == h2)) {
1592 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
1593 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
1594 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
1598 SetStretchBltMode(hdc, COLORONCOLOR);
1599 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
1600 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
1601 if ((x1 != x3) || (y1 != y3)) {
1602 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
1603 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
1609 if ((w1 == tw2) && (h1 == h2)) {
1610 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
1614 SetStretchBltMode(hdc, COLORONCOLOR);
1615 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
1618 SelectObject(hdcSrc, hbmSrcOld);
1620 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND) {
1621 SelectObject(hdcMask, hbmSrcOld);
1625 ReleaseDC(td->w, hdc);
1629 static void windows_map(player_type *player_ptr)
1631 term_data *td = &data[0];
1636 term_xtra_win_clear();
1637 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
1638 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
1639 td->map_active = TRUE;
1643 TERM_LEN max_x = player_ptr->current_floor_ptr->width;
1644 TERM_LEN max_y = player_ptr->current_floor_ptr->height;
1647 for (TERM_LEN x = min_x; x < max_x; x++) {
1648 for (TERM_LEN y = min_y; y < max_y; y++) {
1651 map_info(player_ptr, y, x, &a, (char *)&c, &ta, (char *)&tc);
1652 if ((a & 0x80) && (c & 0x80)) {
1653 term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
1658 term_curs_win(player_ptr->x - min_x, player_ptr->y - min_y);
1659 term_inkey(&c, TRUE, TRUE);
1661 td->map_active = FALSE;
1662 term_xtra_win_clear();
1667 * Create and initialize a "term_data" given a title
1669 static void term_data_link(term_data *td)
1671 term_type *t = &td->t;
1672 term_init(t, td->cols, td->rows, FILE_READ_BUFF_SIZE);
1673 t->soft_cursor = TRUE;
1674 t->higher_pict = TRUE;
1675 t->attr_blank = TERM_WHITE;
1676 t->char_blank = ' ';
1677 t->user_hook = term_user_win;
1678 t->xtra_hook = term_xtra_win;
1679 t->curs_hook = term_curs_win;
1680 t->bigcurs_hook = term_bigcurs_win;
1681 t->wipe_hook = term_wipe_win;
1682 t->text_hook = term_text_win;
1683 t->pict_hook = term_pict_win;
1684 t->data = (vptr)(td);
1688 * Create the windows
1690 * First, instantiate the "default" values, then read the "ini_file"
1691 * to over-ride selected values, then create the windows, and fonts.
1693 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
1694 * must make active to realize the palette.
1696 static void init_windows(void)
1700 WIPE(td, term_data);
1704 td->s = angband_term_name[0];
1720 for (int i = 1; i < MAX_TERM_DATA; i++) {
1722 WIPE(td, term_data);
1723 td->s = angband_term_name[i];
1727 td->visible = FALSE;
1732 td->pos_x = (7 - i) * 30;
1733 td->pos_y = (7 - i) * 20;
1740 /* Atrributes of main window */
1742 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_VISIBLE);
1746 /* Attributes of sub windows */
1747 for (int i = 1; i < MAX_TERM_DATA; i++) {
1749 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
1750 td->dwExStyle = (WS_EX_TOOLWINDOW);
1753 /* Font of each window */
1754 for (int i = 0; i < MAX_TERM_DATA; i++) {
1756 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
1757 td->lf.lfCharSet = DEFAULT_CHARSET;
1758 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
1759 term_force_font(td, NULL);
1761 td->tile_wid = td->font_wid;
1763 td->tile_hgt = td->font_hgt;
1765 term_window_resize(td);
1768 /* Create sub windows */
1769 for (int i = MAX_TERM_DATA - 1; i >= 1; --i) {
1774 = CreateWindowEx(td->dwExStyle, AngList, td->s, td->dwStyle, td->pos_x, td->pos_y, td->size_wid, td->size_hgt, HWND_DESKTOP, NULL, hInstance, NULL);
1778 quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
1780 td->size_hack = TRUE;
1782 term_window_resize(td);
1785 ShowWindow(td->w, SW_SHOW);
1787 td->size_hack = FALSE;
1790 angband_term[i] = &td->t;
1793 /* Activate the window */
1794 SetActiveWindow(td->w);
1798 term_window_pos(td, HWND_TOPMOST);
1800 term_window_pos(td, td->w);
1804 /* Create main window */
1807 td->w = CreateWindowEx(td->dwExStyle, AppName, td->s, td->dwStyle, td->pos_x, td->pos_y, td->size_wid, td->size_hgt, HWND_DESKTOP, NULL, hInstance, NULL);
1811 quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
1814 td->size_hack = TRUE;
1816 term_window_resize(td);
1817 td->size_hack = FALSE;
1820 angband_term[0] = &td->t;
1821 normsize.x = td->cols;
1822 normsize.y = td->rows;
1825 ShowWindow(td->w, SW_SHOWMAXIMIZED);
1827 ShowWindow(td->w, SW_SHOW);
1829 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
1830 (void)new_palette();
1831 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
1832 (void)term_xtra_win_flush();
1838 static void setup_menus(void)
1840 HMENU hm = GetMenu(data[0].w);
1841 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1842 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1843 EnableMenuItem(hm, IDM_FILE_SAVE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1844 EnableMenuItem(hm, IDM_FILE_EXIT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1845 EnableMenuItem(hm, IDM_FILE_SCORE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1847 if (!current_world_ptr->character_generated) {
1848 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
1849 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
1852 if (current_world_ptr->character_generated) {
1853 EnableMenuItem(hm, IDM_FILE_SAVE, MF_BYCOMMAND | MF_ENABLED);
1856 EnableMenuItem(hm, IDM_FILE_EXIT, MF_BYCOMMAND | MF_ENABLED);
1857 EnableMenuItem(hm, IDM_FILE_SCORE, MF_BYCOMMAND | MF_ENABLED);
1859 for (int i = 0; i < MAX_TERM_DATA; i++) {
1860 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1861 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i, (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
1862 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i, MF_BYCOMMAND | MF_ENABLED);
1865 for (int i = 0; i < MAX_TERM_DATA; i++) {
1866 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1868 if (data[i].visible) {
1869 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i, MF_BYCOMMAND | MF_ENABLED);
1873 for (int i = 0; i < MAX_TERM_DATA; i++) {
1874 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1875 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i, (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
1876 if (data[i].visible) {
1877 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i, MF_BYCOMMAND | MF_ENABLED);
1881 for (int i = 0; i < MAX_TERM_DATA; i++) {
1882 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1883 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i, (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
1884 if (data[i].visible) {
1885 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i, MF_BYCOMMAND | MF_ENABLED);
1889 for (int i = 0; i < MAX_TERM_DATA; i++) {
1890 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1891 if (data[i].visible) {
1892 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i, MF_BYCOMMAND | MF_ENABLED);
1896 for (int i = 0; i < MAX_TERM_DATA; i++) {
1897 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1898 if (data[i].visible) {
1899 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i, MF_BYCOMMAND | MF_ENABLED);
1903 for (int i = 0; i < MAX_TERM_DATA; i++) {
1904 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1905 if (data[i].visible) {
1906 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i, MF_BYCOMMAND | MF_ENABLED);
1910 for (int i = 0; i < MAX_TERM_DATA; i++) {
1911 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1913 if (data[i].visible) {
1914 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i, MF_BYCOMMAND | MF_ENABLED);
1917 EnableMenuItem(hm, IDM_WINDOW_KEEP_SUBWINDOWS, MF_BYCOMMAND | MF_ENABLED);
1918 CheckMenuItem(hm, IDM_WINDOW_KEEP_SUBWINDOWS, (keep_subwindows ? MF_CHECKED : MF_UNCHECKED));
1920 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1921 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1922 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1923 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1924 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1927 EnableMenuItem(hm, IDM_OPTIONS_SAVER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1930 if (use_graphics != GRAPHICS_NONE)
1931 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
1933 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1935 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
1936 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
1937 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
1938 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS, (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
1939 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE, (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
1940 CheckMenuItem(hm, IDM_OPTIONS_MUSIC, (arg_music ? MF_CHECKED : MF_UNCHECKED));
1941 CheckMenuItem(hm, IDM_OPTIONS_SOUND, (arg_sound ? MF_CHECKED : MF_UNCHECKED));
1942 CheckMenuItem(hm, IDM_OPTIONS_BG, (use_bg ? MF_CHECKED : MF_UNCHECKED));
1945 CheckMenuItem(hm, IDM_OPTIONS_SAVER, (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
1947 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
1948 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
1949 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
1950 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
1951 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
1952 EnableMenuItem(hm, IDM_OPTIONS_SAVER, MF_BYCOMMAND | MF_ENABLED);
1956 * Check for double clicked (or dragged) savefile
1958 * Apparently, Windows copies the entire filename into the first
1959 * piece of the "command line string". Perhaps we should extract
1960 * the "basename" of that filename and append it to the "save" dir.
1962 static void check_for_save_file(player_type *player_ptr, LPSTR cmd_line)
1969 strcpy(savefile, s);
1970 validate_file(savefile);
1971 game_in_progress = TRUE;
1972 play_game(player_ptr, FALSE, FALSE);
1976 * Process a menu command
1978 static void process_menus(player_type *player_ptr, WORD wCmd)
1983 case IDM_FILE_NEW: {
1985 plog(_("まだ初期化中です...", "You cannot do that yet..."));
1986 } else if (game_in_progress) {
1987 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
1989 game_in_progress = TRUE;
1991 strcpy(savefile, "");
1992 play_game(player_ptr, TRUE, FALSE);
1998 case IDM_FILE_OPEN: {
2000 plog(_("まだ初期化中です...", "You cannot do that yet..."));
2001 } else if (game_in_progress) {
2002 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
2004 memset(&ofn, 0, sizeof(ofn));
2005 ofn.lStructSize = sizeof(ofn);
2006 ofn.hwndOwner = data[0].w;
2007 ofn.lpstrFilter = "Save Files (*.)\0*\0";
2008 ofn.nFilterIndex = 1;
2009 ofn.lpstrFile = savefile;
2010 ofn.nMaxFile = 1024;
2011 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
2012 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
2014 if (GetOpenFileName(&ofn)) {
2015 validate_file(savefile);
2016 game_in_progress = TRUE;
2018 play_game(player_ptr, FALSE, FALSE);
2025 case IDM_FILE_SAVE: {
2026 if (game_in_progress && current_world_ptr->character_generated) {
2028 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
2033 do_cmd_save_game(player_ptr, FALSE);
2035 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
2040 case IDM_FILE_EXIT: {
2041 if (game_in_progress && current_world_ptr->character_generated) {
2043 plog(_("今は終了できません。", "You may not do that right now."));
2048 forget_lite(player_ptr->current_floor_ptr);
2049 forget_view(player_ptr->current_floor_ptr);
2050 clear_mon_lite(player_ptr->current_floor_ptr);
2052 term_key_push(SPECIAL_KEY_QUIT);
2059 case IDM_FILE_SCORE: {
2061 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
2062 highscore_fd = fd_open(buf, O_RDONLY);
2063 if (highscore_fd < 0) {
2064 msg_print("Score file unavailable.");
2068 display_scores_aux(0, MAX_HISCORES, -1, NULL);
2069 (void)fd_close(highscore_fd);
2077 case IDM_FILE_MOVIE: {
2079 plog(_("まだ初期化中です...", "You cannot do that yet..."));
2080 } else if (game_in_progress) {
2081 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
2083 memset(&ofn, 0, sizeof(ofn));
2084 ofn.lStructSize = sizeof(ofn);
2085 ofn.hwndOwner = data[0].w;
2086 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
2087 ofn.nFilterIndex = 1;
2088 ofn.lpstrFile = savefile;
2089 ofn.nMaxFile = 1024;
2090 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
2091 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
2093 if (GetOpenFileName(&ofn)) {
2094 prepare_browse_movie_without_path_build(savefile);
2095 play_game(player_ptr, FALSE, TRUE);
2103 case IDM_WINDOW_VIS_0: {
2104 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
2107 case IDM_WINDOW_VIS_1:
2108 case IDM_WINDOW_VIS_2:
2109 case IDM_WINDOW_VIS_3:
2110 case IDM_WINDOW_VIS_4:
2111 case IDM_WINDOW_VIS_5:
2112 case IDM_WINDOW_VIS_6:
2113 case IDM_WINDOW_VIS_7: {
2114 int i = wCmd - IDM_WINDOW_VIS_0;
2115 if ((i < 0) || (i >= MAX_TERM_DATA))
2121 ShowWindow(td->w, SW_SHOW);
2122 term_data_redraw(player_ptr, td);
2124 td->visible = FALSE;
2126 ShowWindow(td->w, SW_HIDE);
2131 case IDM_WINDOW_FONT_0:
2132 case IDM_WINDOW_FONT_1:
2133 case IDM_WINDOW_FONT_2:
2134 case IDM_WINDOW_FONT_3:
2135 case IDM_WINDOW_FONT_4:
2136 case IDM_WINDOW_FONT_5:
2137 case IDM_WINDOW_FONT_6:
2138 case IDM_WINDOW_FONT_7: {
2139 int i = wCmd - IDM_WINDOW_FONT_0;
2140 if ((i < 0) || (i >= MAX_TERM_DATA))
2144 term_change_font(td);
2147 case IDM_WINDOW_POS_1:
2148 case IDM_WINDOW_POS_2:
2149 case IDM_WINDOW_POS_3:
2150 case IDM_WINDOW_POS_4:
2151 case IDM_WINDOW_POS_5:
2152 case IDM_WINDOW_POS_6:
2153 case IDM_WINDOW_POS_7: {
2154 int i = wCmd - IDM_WINDOW_POS_0;
2155 if ((i < 0) || (i >= MAX_TERM_DATA))
2159 if (!td->posfix && td->visible) {
2161 term_window_pos(td, HWND_TOPMOST);
2164 term_window_pos(td, data[0].w);
2169 case IDM_WINDOW_BIZ_0:
2170 case IDM_WINDOW_BIZ_1:
2171 case IDM_WINDOW_BIZ_2:
2172 case IDM_WINDOW_BIZ_3:
2173 case IDM_WINDOW_BIZ_4:
2174 case IDM_WINDOW_BIZ_5:
2175 case IDM_WINDOW_BIZ_6:
2176 case IDM_WINDOW_BIZ_7: {
2177 int i = wCmd - IDM_WINDOW_BIZ_0;
2178 if ((i < 0) || (i >= MAX_TERM_DATA))
2182 td->bizarre = !td->bizarre;
2184 term_window_resize(td);
2187 case IDM_WINDOW_I_WID_0:
2188 case IDM_WINDOW_I_WID_1:
2189 case IDM_WINDOW_I_WID_2:
2190 case IDM_WINDOW_I_WID_3:
2191 case IDM_WINDOW_I_WID_4:
2192 case IDM_WINDOW_I_WID_5:
2193 case IDM_WINDOW_I_WID_6:
2194 case IDM_WINDOW_I_WID_7: {
2195 int i = wCmd - IDM_WINDOW_I_WID_0;
2196 if ((i < 0) || (i >= MAX_TERM_DATA))
2202 term_window_resize(td);
2205 case IDM_WINDOW_D_WID_0:
2206 case IDM_WINDOW_D_WID_1:
2207 case IDM_WINDOW_D_WID_2:
2208 case IDM_WINDOW_D_WID_3:
2209 case IDM_WINDOW_D_WID_4:
2210 case IDM_WINDOW_D_WID_5:
2211 case IDM_WINDOW_D_WID_6:
2212 case IDM_WINDOW_D_WID_7: {
2213 int i = wCmd - IDM_WINDOW_D_WID_0;
2214 if ((i < 0) || (i >= MAX_TERM_DATA))
2220 term_window_resize(td);
2223 case IDM_WINDOW_I_HGT_0:
2224 case IDM_WINDOW_I_HGT_1:
2225 case IDM_WINDOW_I_HGT_2:
2226 case IDM_WINDOW_I_HGT_3:
2227 case IDM_WINDOW_I_HGT_4:
2228 case IDM_WINDOW_I_HGT_5:
2229 case IDM_WINDOW_I_HGT_6:
2230 case IDM_WINDOW_I_HGT_7: {
2231 int i = wCmd - IDM_WINDOW_I_HGT_0;
2232 if ((i < 0) || (i >= MAX_TERM_DATA))
2238 term_window_resize(td);
2241 case IDM_WINDOW_D_HGT_0:
2242 case IDM_WINDOW_D_HGT_1:
2243 case IDM_WINDOW_D_HGT_2:
2244 case IDM_WINDOW_D_HGT_3:
2245 case IDM_WINDOW_D_HGT_4:
2246 case IDM_WINDOW_D_HGT_5:
2247 case IDM_WINDOW_D_HGT_6:
2248 case IDM_WINDOW_D_HGT_7: {
2249 int i = wCmd - IDM_WINDOW_D_HGT_0;
2250 if ((i < 0) || (i >= MAX_TERM_DATA))
2256 term_window_resize(td);
2259 case IDM_WINDOW_KEEP_SUBWINDOWS: {
2260 keep_subwindows = !keep_subwindows;
2263 case IDM_OPTIONS_NO_GRAPHICS: {
2265 plog("You may not do that right now.");
2269 if (arg_graphics != GRAPHICS_NONE) {
2270 arg_graphics = GRAPHICS_NONE;
2271 term_xtra_win_react(player_ptr);
2272 term_key_push(KTRL('R'));
2277 case IDM_OPTIONS_OLD_GRAPHICS: {
2279 plog("You may not do that right now.");
2283 if (arg_graphics != GRAPHICS_ORIGINAL) {
2284 arg_graphics = GRAPHICS_ORIGINAL;
2285 term_xtra_win_react(player_ptr);
2286 term_key_push(KTRL('R'));
2291 case IDM_OPTIONS_NEW_GRAPHICS: {
2293 plog("You may not do that right now.");
2297 if (arg_graphics != GRAPHICS_ADAM_BOLT) {
2298 arg_graphics = GRAPHICS_ADAM_BOLT;
2299 term_xtra_win_react(player_ptr);
2300 term_key_push(KTRL('R'));
2305 case IDM_OPTIONS_NEW2_GRAPHICS: {
2307 plog("You may not do that right now.");
2311 if (arg_graphics != GRAPHICS_HENGBAND) {
2312 arg_graphics = GRAPHICS_HENGBAND;
2313 term_xtra_win_react(player_ptr);
2314 term_key_push(KTRL('R'));
2319 case IDM_OPTIONS_BIGTILE: {
2322 plog("You may not do that right now.");
2326 arg_bigtile = !arg_bigtile;
2327 term_activate(&td->t);
2328 term_resize(td->cols, td->rows);
2329 InvalidateRect(td->w, NULL, TRUE);
2332 case IDM_OPTIONS_MUSIC: {
2334 plog("You may not do that right now.");
2338 arg_music = !arg_music;
2339 term_xtra_win_react(player_ptr);
2340 term_key_push(KTRL('R'));
2343 case IDM_OPTIONS_SOUND: {
2345 plog("You may not do that right now.");
2349 arg_sound = !arg_sound;
2350 term_xtra_win_react(player_ptr);
2351 term_key_push(KTRL('R'));
2354 case IDM_OPTIONS_BG: {
2356 plog("You may not do that right now.");
2368 term_xtra_win_react(player_ptr);
2369 term_key_push(KTRL('R'));
2372 case IDM_OPTIONS_OPEN_BG: {
2374 plog("You may not do that right now.");
2378 memset(&ofn, 0, sizeof(ofn));
2379 ofn.lStructSize = sizeof(ofn);
2380 ofn.hwndOwner = data[0].w;
2381 ofn.lpstrFilter = "Image Files (*.bmp;*.png;*.jpg;*.jpeg;)\0*.bmp;*.png;*.jpg;*.jpeg;\0";
2382 ofn.nFilterIndex = 1;
2383 ofn.lpstrFile = bg_bitmap_file;
2384 ofn.nMaxFile = 1023;
2385 ofn.lpstrInitialDir = NULL;
2386 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
2387 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
2389 if (GetOpenFileName(&ofn)) {
2394 term_xtra_win_react(player_ptr);
2395 term_key_push(KTRL('R'));
2398 case IDM_DUMP_SCREEN_HTML: {
2399 static char buf[1024] = "";
2400 memset(&ofn, 0, sizeof(ofn));
2401 ofn.lStructSize = sizeof(ofn);
2402 ofn.hwndOwner = data[0].w;
2403 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
2404 ofn.nFilterIndex = 1;
2405 ofn.lpstrFile = buf;
2406 ofn.nMaxFile = 1023;
2407 ofn.lpstrDefExt = "html";
2408 ofn.lpstrInitialDir = NULL;
2409 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
2410 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
2412 if (GetSaveFileName(&ofn)) {
2413 do_cmd_save_screen_html_aux(buf, 0);
2418 case IDM_OPTIONS_SAVER: {
2420 DestroyWindow(hwndSaver);
2425 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass", "Angband Screensaver", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE, 0, 0,
2426 GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL);
2429 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
2431 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
2436 case IDM_OPTIONS_MAP: {
2437 windows_map(player_ptr);
2441 case IDM_HELP_CONTENTS: {
2444 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
2445 if (check_file(tmp)) {
2446 sprintf(buf, "winhelp.exe %s", tmp);
2447 WinExec(buf, SW_NORMAL);
2451 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
2452 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
2459 * Add a keypress to the "queue"
2461 static errr term_keypress(int k)
2463 /* Refuse to enqueue non-keys */
2467 /* Store the char, advance the queue */
2468 Term->key_queue[Term->key_head++] = (char)k;
2470 /* Circular queue, handle wrap */
2471 if (Term->key_head == Term->key_size)
2474 if (Term->key_head != Term->key_tail)
2480 static bool process_keydown(WPARAM wParam, LPARAM lParam)
2486 if (GetKeyState(VK_CONTROL) & 0x8000)
2488 if (GetKeyState(VK_SHIFT) & 0x8000)
2490 if (GetKeyState(VK_MENU) & 0x8000)
2493 term_no_press = (ma) ? TRUE : FALSE;
2494 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)])) {
2495 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
2496 bool numpad = FALSE;
2506 int i = LOBYTE(HIWORD(lParam));
2510 term_no_press = TRUE;
2511 [[fallthrough]]; /* Fall through */
2530 term_no_press = TRUE;
2531 [[fallthrough]]; /* Fall through */
2549 term_keypress(hexsym[i / 16]);
2550 term_keypress(hexsym[i % 16]);
2560 * @todo WNDCLASSに影響があるのでplayer_type*の追加は保留
2562 LRESULT PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2566 td = (term_data *)GetWindowLong(hWnd, 0);
2570 SetWindowLong(hWnd, 0, (LONG)(my_td));
2574 mop.dwCallback = (DWORD)hWnd;
2577 case WM_GETMINMAXINFO: {
2581 lpmmi = (MINMAXINFO *)lParam;
2585 rc.left = rc.top = 0;
2586 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
2587 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
2589 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
2591 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
2592 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
2597 BeginPaint(hWnd, &ps);
2599 term_data_redraw(p_ptr, td);
2600 EndPaint(hWnd, &ps);
2601 ValidateRect(hWnd, NULL);
2604 case MM_MCINOTIFY: {
2605 if (wParam == MCI_NOTIFY_SUCCESSFUL) {
2606 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
2607 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
2614 if (process_keydown(wParam, lParam))
2620 term_no_press = FALSE;
2622 term_keypress(wParam);
2625 case WM_LBUTTONDOWN: {
2626 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
2627 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
2633 case WM_LBUTTONUP: {
2636 TERM_LEN dx = abs(oldx - mousex) + 1;
2637 TERM_LEN dy = abs(oldy - mousey) + 1;
2638 TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
2639 TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
2645 int sz = (dx + 3) * dy;
2647 int sz = (dx + 2) * dy;
2649 hGlobal = GlobalAlloc(GHND, sz + 1);
2650 if (hGlobal == NULL)
2652 lpStr = (LPSTR)GlobalLock(hGlobal);
2654 for (int i = 0; i < dy; i++) {
2657 char **scr = data[0].t.scr->c;
2659 C_MAKE(s, (dx + 1), char);
2660 strncpy(s, &scr[oy + i][ox], dx);
2663 if (iskanji(scr[oy + i][ox - 1]))
2667 if (ox + dx < data[0].cols) {
2668 if (iskanji(scr[oy + i][ox + dx - 1]))
2672 for (int j = 0; j < dx; j++) {
2678 for (int j = 0; j < dx; j++) {
2679 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
2688 GlobalUnlock(hGlobal);
2689 if (OpenClipboard(hWnd) == 0) {
2690 GlobalFree(hGlobal);
2695 SetClipboardData(CF_TEXT, hGlobal);
2700 case WM_MOUSEMOVE: {
2705 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
2706 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
2710 dx = abs(oldx - mousex) + 1;
2711 dy = abs(oldy - mousey) + 1;
2712 ox = (oldx > mousex) ? mousex : oldx;
2713 oy = (oldy > mousey) ? mousey : oldy;
2714 term_inversed_area(hWnd, ox, oy, dx, dy);
2719 dx = abs(cx - mousex) + 1;
2720 dy = abs(cy - mousey) + 1;
2721 ox = (cx > mousex) ? mousex : cx;
2722 oy = (cy > mousey) ? mousey : cy;
2723 term_inversed_area(hWnd, ox, oy, dx, dy);
2734 if (!game_in_progress || !current_world_ptr->character_generated) {
2740 plog(_("今は終了できません。", "You may not do that right now."));
2745 forget_lite(p_ptr->current_floor_ptr);
2746 forget_view(p_ptr->current_floor_ptr);
2747 clear_mon_lite(p_ptr->current_floor_ptr);
2748 term_key_push(SPECIAL_KEY_QUIT);
2751 case WM_QUERYENDSESSION: {
2752 if (!game_in_progress || !current_world_ptr->character_generated) {
2759 p_ptr->is_dead = FALSE;
2760 exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
2762 p_ptr->panic_save = 1;
2763 signals_ignore_tstp();
2764 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
2765 (void)save_player(p_ptr, SAVE_TYPE_CLOSE_GAME);
2774 process_menus(p_ptr, LOWORD(wParam));
2785 //!< @todo 二重のswitch文。後で分割する.
2787 case SIZE_MINIMIZED: {
2788 for (int i = 1; i < MAX_TERM_DATA; i++) {
2789 if (data[i].visible)
2790 ShowWindow(data[i].w, SW_HIDE);
2795 case SIZE_MAXIMIZED:
2796 case SIZE_RESTORED: {
2797 TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
2798 TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
2799 if ((td->cols != cols) || (td->rows != rows)) {
2802 if (!IsZoomed(td->w) && !IsIconic(td->w)) {
2803 normsize.x = td->cols;
2804 normsize.y = td->rows;
2807 term_activate(&td->t);
2808 term_resize(td->cols, td->rows);
2809 InvalidateRect(td->w, NULL, TRUE);
2812 td->size_hack = TRUE;
2813 for (int i = 1; i < MAX_TERM_DATA; i++) {
2814 if (data[i].visible)
2815 ShowWindow(data[i].w, SW_SHOW);
2818 td->size_hack = FALSE;
2826 case WM_PALETTECHANGED: {
2827 if ((HWND)wParam == hWnd)
2830 [[fallthrough]]; /* Fall through */
2831 case WM_QUERYNEWPALETTE: {
2835 HDC hdc = GetDC(hWnd);
2836 SelectPalette(hdc, hPal, FALSE);
2837 int i = RealizePalette(hdc);
2839 InvalidateRect(hWnd, NULL, TRUE);
2841 ReleaseDC(hWnd, hdc);
2845 if (!wParam || HIWORD(lParam))
2848 for (int i = 1; i < MAX_TERM_DATA; i++) {
2849 if (!data[i].posfix)
2850 term_window_pos(&data[i], hWnd);
2856 case WM_ACTIVATEAPP: {
2857 if (IsIconic(td->w))
2860 for (int i = 1; i < MAX_TERM_DATA; i++) {
2861 if (data[i].visible) {
2862 if (wParam == TRUE) {
2863 ShowWindow(data[i].w, SW_SHOW);
2865 ShowWindow(data[i].w, SW_HIDE);
2870 [[fallthrough]]; /* Fall through */
2872 if (wParam == FALSE && keep_subwindows) {
2873 for (int i = 0; i < MAX_TERM_DATA; i++) {
2874 if (data[i].visible) {
2875 ShowWindow(data[i].w, SW_SHOW);
2882 return DefWindowProc(hWnd, uMsg, wParam, lParam);
2886 * @todo WNDCLASSに影響があるのでplayer_type*の追加は保留
2888 LRESULT PASCAL AngbandListProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2892 td = (term_data *)GetWindowLong(hWnd, 0);
2896 SetWindowLong(hWnd, 0, (LONG)(my_td));
2902 case WM_GETMINMAXINFO: {
2906 lpmmi = (MINMAXINFO *)lParam;
2910 rc.left = rc.top = 0;
2911 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
2912 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
2914 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
2915 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
2916 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
2927 td->size_hack = TRUE;
2929 TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
2930 TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
2931 if ((td->cols != cols) || (td->rows != rows)) {
2932 term_type *old_term = Term;
2935 term_activate(&td->t);
2936 term_resize(td->cols, td->rows);
2937 term_activate(old_term);
2938 InvalidateRect(td->w, NULL, TRUE);
2939 p_ptr->window_flags = 0xFFFFFFFF;
2940 handle_stuff(p_ptr);
2943 td->size_hack = FALSE;
2947 BeginPaint(hWnd, &ps);
2949 term_data_redraw(p_ptr, td);
2950 EndPaint(hWnd, &ps);
2955 if (process_keydown(wParam, lParam))
2962 term_no_press = FALSE;
2964 term_keypress(wParam);
2967 case WM_PALETTECHANGED: {
2968 if ((HWND)wParam == hWnd)
2971 [[fallthrough]]; /* Fall through */
2972 case WM_QUERYNEWPALETTE: {
2976 HDC hdc = GetDC(hWnd);
2977 SelectPalette(hdc, hPal, FALSE);
2978 int i = RealizePalette(hdc);
2980 InvalidateRect(hWnd, NULL, TRUE);
2982 ReleaseDC(hWnd, hdc);
2985 case WM_NCLBUTTONDOWN: {
2986 if (wParam == HTCLOSE)
2989 if (wParam == HTSYSMENU) {
2991 td->visible = FALSE;
2992 ShowWindow(td->w, SW_HIDE);
3002 return DefWindowProc(hWnd, uMsg, wParam, lParam);
3005 LRESULT PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3007 static int iMouse = 0;
3008 static WORD xMouse = 0;
3009 static WORD yMouse = 0;
3016 case WM_SETCURSOR: {
3021 case WM_LBUTTONDOWN:
3022 case WM_MBUTTONDOWN:
3023 case WM_RBUTTONDOWN:
3025 SendMessage(hWnd, WM_CLOSE, 0, 0);
3028 case WM_MOUSEMOVE: {
3030 int dx = LOWORD(lParam) - xMouse;
3031 int dy = HIWORD(lParam) - yMouse;
3038 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS)) {
3039 SendMessage(hWnd, WM_CLOSE, 0, 0);
3044 xMouse = LOWORD(lParam);
3045 yMouse = HIWORD(lParam);
3050 DestroyWindow(hwndSaver);
3056 return DefWindowProc(hWnd, uMsg, wParam, lParam);
3060 * Display warning message (see "z-util.c")
3062 static void hack_plog(concptr str)
3066 MessageBox(NULL, str, "警告!", MB_ICONEXCLAMATION | MB_OK);
3068 MessageBox(NULL, str, "Warning", MB_ICONEXCLAMATION | MB_OK);
3074 * Display error message and quit (see "z-util.c")
3076 static void hack_quit(concptr str)
3080 MessageBox(NULL, str, "エラー!", MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
3082 MessageBox(NULL, str, "Error", MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
3086 UnregisterClass(AppName, hInstance);
3094 * Display warning message (see "z-util.c")
3096 static void hook_plog(concptr str)
3100 MessageBox(data[0].w, str, "警告!", MB_ICONEXCLAMATION | MB_OK);
3102 MessageBox(data[0].w, str, "Warning", MB_ICONEXCLAMATION | MB_OK);
3108 * Display error message and quit (see "z-util.c")
3110 static void hook_quit(concptr str)
3114 MessageBox(data[0].w, str, "エラー!", MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
3116 MessageBox(data[0].w, str, "Error", MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
3121 for (int i = MAX_TERM_DATA - 1; i >= 0; --i) {
3122 term_force_font(&data[i], NULL);
3123 if (data[i].font_want)
3124 string_free(data[i].font_want);
3126 DestroyWindow(data[i].w);
3130 if (infGraph.hPalette)
3131 DeleteObject(infGraph.hPalette);
3132 if (infGraph.hBitmap)
3133 DeleteObject(infGraph.hBitmap);
3134 if (infMask.hPalette)
3135 DeleteObject(infMask.hPalette);
3136 if (infMask.hBitmap)
3137 DeleteObject(infMask.hBitmap);
3139 DeleteObject(hbrYellow);
3145 UnregisterClass(AppName, hInstance);
3155 static void init_stuff(void)
3158 GetModuleFileName(hInstance, path, 512);
3160 strcpy(path + strlen(path) - 4, ".INI");
3161 ini_file = string_make(path);
3162 int i = strlen(path);
3164 for (; i > 0; i--) {
3165 if (path[i] == '\\') {
3170 strcpy(path + i + 1, "lib\\");
3171 validate_dir(path, TRUE);
3172 init_file_paths(path, path);
3173 validate_dir(ANGBAND_DIR_APEX, FALSE);
3174 validate_dir(ANGBAND_DIR_BONE, FALSE);
3175 if (!check_dir(ANGBAND_DIR_EDIT)) {
3176 validate_dir(ANGBAND_DIR_DATA, TRUE);
3178 validate_dir(ANGBAND_DIR_DATA, FALSE);
3181 validate_dir(ANGBAND_DIR_FILE, TRUE);
3182 validate_dir(ANGBAND_DIR_HELP, FALSE);
3183 validate_dir(ANGBAND_DIR_INFO, FALSE);
3184 validate_dir(ANGBAND_DIR_PREF, TRUE);
3185 validate_dir(ANGBAND_DIR_SAVE, FALSE);
3186 validate_dir(ANGBAND_DIR_DEBUG_SAVE, FALSE);
3187 validate_dir(ANGBAND_DIR_USER, TRUE);
3188 validate_dir(ANGBAND_DIR_XTRA, TRUE);
3189 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
3191 validate_file(path);
3192 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
3193 ANGBAND_DIR_XTRA_GRAF = string_make(path);
3194 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
3196 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
3197 ANGBAND_DIR_XTRA_SOUND = string_make(path);
3198 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
3200 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
3201 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
3202 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
3204 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
3205 ANGBAND_DIR_XTRA_HELP = string_make(path);
3209 * @brief コマンドラインから全スポイラー出力を行う
3210 * Create Spoiler files from Command Line
3211 * @return spoiler_output_status
3213 static spoiler_output_status create_debug_spoiler(LPSTR cmd_line)
3219 return SPOILER_OUTPUT_CANCEL;
3220 option = "--output-spoilers";
3222 if (strncmp(s, option, strlen(option)) != 0)
3223 return SPOILER_OUTPUT_CANCEL;
3226 init_angband(p_ptr, process_autopick_file_command, TRUE);
3228 return output_all_spoilers();
3232 * @todo よく見るとhMutexはちゃんと使われていない……?
3233 * @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
3235 static bool is_already_running(void)
3238 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
3239 if (GetLastError() == ERROR_ALREADY_EXISTS) {
3247 * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
3249 int WINAPI WinMain(_In_ HINSTANCE hInst, _In_opt_ HINSTANCE hPrevInst, _In_ LPSTR lpCmdLine, _In_ int nCmdShow)
3255 setlocale(LC_ALL, "ja_JP");
3258 if (is_already_running()) {
3260 NULL, _("変愚蛮怒はすでに起動しています。", "Hengband is already running."), _("エラー!", "Error"), MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
3264 switch (create_debug_spoiler(lpCmdLine)) {
3265 case SPOILER_OUTPUT_SUCCESS:
3266 fprintf(stdout, "Successfully created a spoiler file.");
3269 case SPOILER_OUTPUT_FAIL_FOPEN:
3270 fprintf(stderr, "Cannot create spoiler file.");
3273 case SPOILER_OUTPUT_FAIL_FCLOSE:
3274 fprintf(stderr, "Cannot close spoiler file.");
3281 if (hPrevInst == NULL) {
3282 wc.style = CS_CLASSDC;
3283 wc.lpfnWndProc = AngbandWndProc;
3286 wc.hInstance = hInst;
3287 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
3288 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
3289 wc.hbrBackground = static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH));
3290 wc.lpszMenuName = AppName;
3291 wc.lpszClassName = AppName;
3293 if (!RegisterClass(&wc))
3296 wc.lpfnWndProc = AngbandListProc;
3297 wc.lpszMenuName = NULL;
3298 wc.lpszClassName = AngList;
3300 if (!RegisterClass(&wc))
3303 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
3304 wc.lpfnWndProc = AngbandSaverProc;
3306 wc.lpszMenuName = NULL;
3307 wc.lpszClassName = "WindowsScreenSaverClass";
3309 if (!RegisterClass(&wc))
3313 plog_aux = hack_plog;
3314 quit_aux = hack_quit;
3315 core_aux = hack_quit;
3318 for (int i = 0; special_key_list[i]; ++i) {
3319 special_key[special_key_list[i]] = TRUE;
3322 for (int i = 0; ignore_key_list[i]; ++i) {
3323 ignore_key[ignore_key_list[i]] = TRUE;
3327 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
3328 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
3329 ReleaseDC(NULL, hdc);
3331 for (int i = 0; i < 256; i++) {
3332 byte rv = angband_color_table[i][1];
3333 byte gv = angband_color_table[i][2];
3334 byte bv = angband_color_table[i][3];
3335 win_clr[i] = PALETTERGB(rv, gv, bv);
3336 angband_color_table[i][0] = win_pal[i];
3345 plog_aux = hook_plog;
3346 quit_aux = hook_quit;
3347 core_aux = hook_quit;
3349 ANGBAND_SYS = "win";
3350 if (7 != GetKeyboardType(0))
3351 ANGBAND_KEYBOARD = "0";
3353 switch (GetKeyboardType(1)) {
3361 ANGBAND_KEYBOARD = "NEC98";
3365 ANGBAND_KEYBOARD = "JAPAN";
3370 term_activate(term_screen);
3371 init_angband(p_ptr, process_autopick_file_command, FALSE);
3373 check_for_save_file(p_ptr, lpCmdLine);
3374 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
3376 while (GetMessage(&msg, NULL, 0, 0)) {
3377 TranslateMessage(&msg);
3378 DispatchMessage(&msg);
3384 #endif /* WINDOWS */