3 * @brief Windows版固有実装(メインエントリポイント含む)
5 * @author Hengband Team
9 * Windows98かその前後の頃を起点としたAPI実装。
11 * DirectXといった昨今描画に標準的となったライブラリも用いていない。
12 * タイルの描画処理などについては、現在動作の詳細を検証中。
16 * Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others
18 * This software may be copied and distributed for educational, research,
19 * and not for profit purposes provided that this copyright and statement
20 * are included in all such copies.
23 * This file helps Angband work with Windows computers.
25 * To use this file, use an appropriate "Makefile" or "Project File",
26 * make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and
27 * make sure to obtain various extra files as described below.
29 * The official compilation uses the CodeWarrior Pro compiler, which
30 * includes a special project file and precompilable header file.
34 * <del>See also "main-dos.c" and "main-ibm.c".</del>
38 * The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
39 * and/or color redefinitions.
43 * The "lib/user/font-win.prf" contains attr/char mappings for use with the
44 * normal "lib/xtra/font/*.fon" font files.
48 * The "lib/user/graf-win.prf" contains attr/char mappings for use with the
49 * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
54 * Compiling this file, and using the resulting executable, requires
55 * several extra files not distributed with the standard Angband code.
56 * If "USE_GRAPHICS" is defined, then "readdib.h" and "readdib.c" must
57 * be placed into "src/", and the "8X8.BMP" bitmap file must be placed
58 * into "lib/xtra/graf". In any case, some "*.fon" files (including
59 * "8X13.FON" if nothing else) must be placed into "lib/xtra/font/".
60 * If "USE_SOUND" is defined, then some special library (for example,
61 * "winmm.lib") may need to be linked in, and desired "*.WAV" sound
62 * files must be placed into "lib/xtra/sound/". All of these extra
63 * files can be found in the "ext-win" archive.
67 * The "term_xtra_win_clear()" function should probably do a low-level
68 * clear of the current window, and redraw the borders and other things,
69 * if only for efficiency.
73 * A simpler method is needed for selecting the "tile size" for windows.
77 * The various "warning" messages assume the existance of the "screen.w"
78 * window, I think, and only a few calls actually check for its existance,
79 * this may be okay since "NULL" means "on top of all windows". (?) The
80 * user must never be allowed to "hide" the main window, or the "menubar"
85 * Special "Windows Help Files" can be placed into "lib/xtra/help/" for
86 * use with the "winhelp.exe" program. These files *may* be available
87 * at the ftp site somewhere, but I have not seen them.
91 * Initial framework (and most code) by Ben Harrison (benh@phial.com).
93 * Original code by Skirmantas Kligys (kligys@scf.usc.edu).
95 * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
96 * and Chris R. Martin (crm7479@tam2000.tamu.edu).
104 #include "cmd-dump.h"
105 #include "view-mainwindow.h"
107 #include "floor-events.h"
126 * Extract the "WIN32" flag from the compiler
128 #if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__)
135 * Available graphic modes
137 #define GRAPHICS_NONE 0
138 #define GRAPHICS_ORIGINAL 1
139 #define GRAPHICS_ADAM_BOLT 2
140 #define GRAPHICS_HENGBAND 3
143 * Hack -- allow use of "screen saver" mode
149 * Menu constants -- see "ANGBAND.RC"
152 #define IDM_FILE_NEW 100
153 #define IDM_FILE_OPEN 101
154 #define IDM_FILE_SAVE 110
155 #define IDM_FILE_SCORE 120
156 #define IDM_FILE_MOVIE 121
157 #define IDM_FILE_EXIT 130
159 #define IDM_WINDOW_VIS_0 200
160 #define IDM_WINDOW_VIS_1 201
161 #define IDM_WINDOW_VIS_2 202
162 #define IDM_WINDOW_VIS_3 203
163 #define IDM_WINDOW_VIS_4 204
164 #define IDM_WINDOW_VIS_5 205
165 #define IDM_WINDOW_VIS_6 206
166 #define IDM_WINDOW_VIS_7 207
168 #define IDM_WINDOW_FONT_0 210
169 #define IDM_WINDOW_FONT_1 211
170 #define IDM_WINDOW_FONT_2 212
171 #define IDM_WINDOW_FONT_3 213
172 #define IDM_WINDOW_FONT_4 214
173 #define IDM_WINDOW_FONT_5 215
174 #define IDM_WINDOW_FONT_6 216
175 #define IDM_WINDOW_FONT_7 217
177 #define IDM_WINDOW_POS_0 220
178 #define IDM_WINDOW_POS_1 221
179 #define IDM_WINDOW_POS_2 222
180 #define IDM_WINDOW_POS_3 223
181 #define IDM_WINDOW_POS_4 224
182 #define IDM_WINDOW_POS_5 225
183 #define IDM_WINDOW_POS_6 226
184 #define IDM_WINDOW_POS_7 227
186 #define IDM_WINDOW_BIZ_0 230
187 #define IDM_WINDOW_BIZ_1 231
188 #define IDM_WINDOW_BIZ_2 232
189 #define IDM_WINDOW_BIZ_3 233
190 #define IDM_WINDOW_BIZ_4 234
191 #define IDM_WINDOW_BIZ_5 235
192 #define IDM_WINDOW_BIZ_6 236
193 #define IDM_WINDOW_BIZ_7 237
195 #define IDM_WINDOW_I_WID_0 240
196 #define IDM_WINDOW_I_WID_1 241
197 #define IDM_WINDOW_I_WID_2 242
198 #define IDM_WINDOW_I_WID_3 243
199 #define IDM_WINDOW_I_WID_4 244
200 #define IDM_WINDOW_I_WID_5 245
201 #define IDM_WINDOW_I_WID_6 246
202 #define IDM_WINDOW_I_WID_7 247
204 #define IDM_WINDOW_D_WID_0 250
205 #define IDM_WINDOW_D_WID_1 251
206 #define IDM_WINDOW_D_WID_2 252
207 #define IDM_WINDOW_D_WID_3 253
208 #define IDM_WINDOW_D_WID_4 254
209 #define IDM_WINDOW_D_WID_5 255
210 #define IDM_WINDOW_D_WID_6 256
211 #define IDM_WINDOW_D_WID_7 257
213 #define IDM_WINDOW_I_HGT_0 260
214 #define IDM_WINDOW_I_HGT_1 261
215 #define IDM_WINDOW_I_HGT_2 262
216 #define IDM_WINDOW_I_HGT_3 263
217 #define IDM_WINDOW_I_HGT_4 264
218 #define IDM_WINDOW_I_HGT_5 265
219 #define IDM_WINDOW_I_HGT_6 266
220 #define IDM_WINDOW_I_HGT_7 267
222 #define IDM_WINDOW_D_HGT_0 270
223 #define IDM_WINDOW_D_HGT_1 271
224 #define IDM_WINDOW_D_HGT_2 272
225 #define IDM_WINDOW_D_HGT_3 273
226 #define IDM_WINDOW_D_HGT_4 274
227 #define IDM_WINDOW_D_HGT_5 275
228 #define IDM_WINDOW_D_HGT_6 276
229 #define IDM_WINDOW_D_HGT_7 277
231 #define IDM_OPTIONS_NO_GRAPHICS 400
232 #define IDM_OPTIONS_OLD_GRAPHICS 401
233 #define IDM_OPTIONS_NEW_GRAPHICS 402
234 #define IDM_OPTIONS_NEW2_GRAPHICS 403
235 #define IDM_OPTIONS_BIGTILE 409
236 #define IDM_OPTIONS_SOUND 410
237 #define IDM_OPTIONS_MUSIC 411
238 #define IDM_OPTIONS_SAVER 420
239 #define IDM_OPTIONS_MAP 430
240 #define IDM_OPTIONS_BG 440
241 #define IDM_OPTIONS_OPEN_BG 441
243 #define IDM_DUMP_SCREEN_HTML 450
245 #define IDM_HELP_CONTENTS 901
248 * Exclude parts of WINDOWS.H that are not needed
250 #define NOCOMM /* Comm driver APIs and definitions */
251 #define NOLOGERROR /* LogError() and related definitions */
252 #define NOPROFILER /* Profiler APIs */
253 #define NOLFILEIO /* _l* file I/O routines */
254 #define NOOPENFILE /* OpenFile and related definitions */
255 #define NORESOURCE /* Resource management */
256 #define NOATOM /* Atom management */
257 #define NOLANGUAGE /* Character test routines */
258 #define NOLSTRING /* lstr* string management routines */
259 #define NODBCS /* Double-byte character set routines */
260 #define NOKEYBOARDINFO /* Keyboard driver routines */
261 #define NOCOLOR /* COLOR_* color values */
262 #define NODRAWTEXT /* DrawText() and related definitions */
263 #define NOSCALABLEFONT /* Truetype scalable font support */
264 #define NOMETAFILE /* Metafile support */
265 #define NOSYSTEMPARAMSINFO /* SystemParametersInfo() and SPI_* definitions */
266 #define NODEFERWINDOWPOS /* DeferWindowPos and related definitions */
267 #define NOKEYSTATES /* MK_* message key state flags */
268 #define NOWH /* SetWindowsHook and related WH_* definitions */
269 #define NOCLIPBOARD /* Clipboard APIs and definitions */
270 #define NOICONS /* IDI_* icon IDs */
271 #define NOMDI /* MDI support */
272 #define NOHELP /* Help support */
274 /* Not defined since it breaks Borland C++ 5.5 */
275 /* #define NOCTLMGR */ /* Control management and controls */
278 * Exclude parts of WINDOWS.H that are not needed (Win32)
280 #define WIN32_LEAN_AND_MEAN
281 #define NONLS /* All NLS defines and routines */
282 #define NOSERVICE /* All Service Controller routines, SERVICE_ equates, etc. */
283 #define NOKANJI /* Kanji support stuff. */
284 #define NOMCX /* Modem Configuration Extensions */
287 * Include the "windows" support file
292 * Exclude parts of MMSYSTEM.H that are not needed
294 #define MMNODRV /* Installable driver support */
295 #define MMNOWAVE /* Waveform support */
296 #define MMNOMIDI /* MIDI support */
297 #define MMNOAUX /* Auxiliary audio support */
298 #define MMNOTIMER /* Timer support */
299 #define MMNOJOY /* Joystick support */
300 #define MMNOMCI /* MCI support */
301 #define MMNOMMIO /* Multimedia file I/O support */
302 #define MMNOMMSYSTEM /* General MMSYSTEM functions */
306 * Standard sound names
308 const concptr angband_sound_name[SOUND_MAX] =
380 * Standard music names
382 const concptr angband_music_basic_name[MUSIC_BASIC_MAX] =
408 * Include some more files. Note: the Cygnus Cygwin compiler
409 * doesn't use mmsystem.h instead it includes the winmm library
410 * which performs a similar function.
412 #include <mmsystem.h>
416 * HTML-Help requires htmlhelp.h and htmlhelp.lib from Microsoft's
417 * HTML Workshop < http://msdn.microsoft.com/workshop/author/htmlhelp/ >.
419 /* #define HTML_HELP */
422 #include <htmlhelp.h>
423 #endif /* HTML_HELP */
426 * Include the support for loading bitmaps
429 # include "readdib.h"
433 * Hack -- Fake declarations from "dos.h"
436 #define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
438 #define FA_LABEL 0x08 /* Volume label */
439 #define FA_DIREC 0x10 /* Directory */
440 unsigned _cdecl _dos_getfileattr(concptr, unsigned *);
444 * Silliness in WIN32 drawing routine
447 # define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL)
451 * Silliness for Windows 95
453 #ifndef WS_EX_TOOLWINDOW
454 # define WS_EX_TOOLWINDOW 0
458 * Foreground color bits (hard-coded by DOS)
460 #define VID_BLACK 0x00
461 #define VID_BLUE 0x01
462 #define VID_GREEN 0x02
463 #define VID_CYAN 0x03
465 #define VID_MAGENTA 0x05
466 #define VID_YELLOW 0x06
467 #define VID_WHITE 0x07
470 * Bright text (hard-coded by DOS)
472 #define VID_BRIGHT 0x08
475 * Background color bits (hard-coded by DOS)
477 #define VUD_BLACK 0x00
478 #define VUD_BLUE 0x10
479 #define VUD_GREEN 0x20
480 #define VUD_CYAN 0x30
482 #define VUD_MAGENTA 0x50
483 #define VUD_YELLOW 0x60
484 #define VUD_WHITE 0x70
487 * Blinking text (hard-coded by DOS)
489 #define VUD_BRIGHT 0x80
495 typedef struct _term_data term_data;
499 * @brief ターム情報構造体 / Extra "term" data
502 * pos_x / pos_y は各タームの左上点座標を指す。
505 * tile_wid / tile_hgt は[ウィンドウ]メニューのタイルの幅/高さを~を
506 * 1ドットずつ調整するステータスを指す。
507 * また、フォントを変更すると都度自動調整される。
510 * Note the use of "font_want" for the names of the font file requested by
511 * the user, and the use of "font_file" for the currently active font file.
513 * The "font_file" is uppercased, and takes the form "8X13.FON", while
514 * "font_want" can be in almost any form as long as it could be construed
515 * as attempting to represent the name of a font.
527 TERM_LEN rows; /* int -> uint */
530 uint pos_x; //!< タームの左上X座標
531 uint pos_y; //!< タームの左上Y座標
546 int font_wid; //!< フォント横幅
547 int font_hgt; //!< フォント縦幅
548 int tile_wid; //!< タイル横幅
549 int tile_hgt; //!< タイル縦幅
561 #define MAX_TERM_DATA 8 //!< Maximum number of windows
563 static term_data data[MAX_TERM_DATA]; //!< An array of term_data's
564 static term_data *my_td; //!< Hack -- global "window creation" pointer
565 POINT normsize; //!< Remember normal size of main window when maxmized
568 * was main window maximized on previous playing
570 bool win_maximized = FALSE;
575 bool game_in_progress = FALSE;
578 * note when "open"/"new" become valid
580 bool initialized = FALSE;
583 * screen paletted, i.e. 256 colors
585 bool paletted = FALSE;
588 * 16 colors screen, don't use RGB()
590 bool colors16 = FALSE;
593 * Saved instance handle
595 static HINSTANCE hInstance;
598 * Yellow brush for the cursor
600 static HBRUSH hbrYellow;
610 static HPALETTE hPal;
613 static HBITMAP hBG = NULL;
614 static int use_bg = 0; //!< 背景使用フラグ、1なら私用。
615 static char bg_bitmap_file[1024] = "bg.bmp"; //!< 現在の背景ビットマップファイル名。
620 * The screen saver window
622 static HWND hwndSaver;
624 #endif /* USE_SAVER */
630 * 現在使用中のタイルID(0ならば未使用)
631 * Flag set once "graphics" has been initialized
633 static byte_hack current_graphics_mode = 0;
638 static DIBINIT infGraph;
641 * The global bitmap mask
643 static DIBINIT infMask;
645 #endif /* USE_GRAPHICS */
651 * Flag set once "sound" has been initialized
653 static bool can_use_sound = FALSE;
655 #define SAMPLE_SOUND_MAX 16
657 * An array of sound file names
659 static concptr sound_file[SOUND_MAX][SAMPLE_SOUND_MAX];
661 #endif /* USE_SOUND */
667 #define SAMPLE_MUSIC_MAX 16
668 static concptr music_file[MUSIC_BASIC_MAX][SAMPLE_MUSIC_MAX];
669 static concptr dungeon_music_file[1000][SAMPLE_MUSIC_MAX];
670 static concptr town_music_file[1000][SAMPLE_MUSIC_MAX];
671 static concptr quest_music_file[1000][SAMPLE_MUSIC_MAX];
672 static bool can_use_music = FALSE;
674 static MCI_OPEN_PARMS mop;
675 static char mci_device_type[256];
677 int current_music_type = 0;
678 int current_music_id = 0;
680 #endif /* USE_MUSIC */
684 * Full path to ANGBAND.INI
686 static concptr ini_file = NULL;
689 * Name of application
691 static concptr AppName = "ANGBAND";
694 * Name of sub-window type
696 static concptr AngList = "AngList";
701 static concptr ANGBAND_DIR_XTRA_GRAF;
702 static concptr ANGBAND_DIR_XTRA_SOUND;
703 static concptr ANGBAND_DIR_XTRA_MUSIC;
704 static concptr ANGBAND_DIR_XTRA_HELP;
706 static concptr ANGBAND_DIR_XTRA_MUSIC;
711 * The "complex" color values
713 static COLORREF win_clr[256];
717 * Flag for macro trigger with dump ASCII
719 static bool term_no_press = FALSE;
724 static bool mouse_down = FALSE;
725 static bool paint_rect = FALSE;
726 static TERM_LEN mousex = 0, mousey = 0;
727 static TERM_LEN oldx, oldy;
731 * @brief The "simple" color values
733 * See "main-ibm.c" for original table information
734 * The entries below are taken from the "color bits" defined above.
735 * Note that many of the choices below suck, but so do crappy monitors.
737 static BYTE win_pal[256] =
739 VID_BLACK, /* Dark */
740 VID_WHITE, /* White */
741 VID_CYAN, /* Slate XXX */
742 VID_RED | VID_BRIGHT, /* Orange XXX */
744 VID_GREEN, /* Green */
746 VID_YELLOW, /* Umber XXX */
747 VID_BLACK | VID_BRIGHT, /* Light Dark */
748 VID_CYAN | VID_BRIGHT, /* Light Slate XXX */
749 VID_MAGENTA, /* Violet XXX */
750 VID_YELLOW | VID_BRIGHT, /* Yellow */
751 VID_MAGENTA | VID_BRIGHT, /* Light Red XXX */
752 VID_GREEN | VID_BRIGHT, /* Light Green */
753 VID_BLUE | VID_BRIGHT, /* Light Blue */
754 VID_YELLOW /* Light Umber XXX */
759 * Hack -- define which keys are "special"
761 static bool special_key[256];
762 static bool ignore_key[256];
765 * Hack -- initialization list for "special_key"
767 static byte special_key_list[] = {
768 VK_CLEAR, VK_PAUSE, VK_CAPITAL,
769 VK_KANA, VK_JUNJA, VK_FINAL, VK_KANJI,
770 VK_CONVERT, VK_NONCONVERT, VK_ACCEPT, VK_MODECHANGE,
771 VK_PRIOR, VK_NEXT, VK_END, VK_HOME,
772 VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN,
773 VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT,
774 VK_INSERT, VK_DELETE, VK_HELP, VK_APPS,
775 VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
776 VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
777 VK_NUMPAD8, VK_NUMPAD9, VK_MULTIPLY, VK_ADD,
778 VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE,
779 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
780 VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12,
781 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
782 VK_F19,VK_F20, VK_F21, VK_F22, VK_F23, VK_F24,
783 VK_NUMLOCK, VK_SCROLL, VK_ATTN, VK_CRSEL,
784 VK_EXSEL, VK_EREOF, VK_PLAY, VK_ZOOM,
789 static byte ignore_key_list[] = {
790 VK_ESCAPE, VK_TAB, VK_SPACE,
791 'F', 'W', 'O', /*'H',*/ /* these are menu characters.*/
792 VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN,
793 VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL,
798 /* Function prototype */
800 static bool is_already_running(void);
804 static void delete_bg(void)
813 static int init_bg(void)
815 char * bmfile = bg_bitmap_file;
818 if (use_bg == 0) return 0;
820 hBG = LoadImage(NULL, bmfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
822 plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
830 static void DrawBG(HDC hdc, RECT *r)
835 int x = r->left, y = r->top;
836 int nx, ny, sx, sy, swid, shgt, cwid, chgt;
842 GetObject(hBG, sizeof(bm), &bm);
843 swid = bm.bmWidth; shgt = bm.bmHeight;
845 hdcSrc = CreateCompatibleDC(hdc);
846 hOld = SelectObject(hdcSrc, hBG);
850 cwid = MIN(swid - sx, r->right - nx);
853 chgt = MIN(shgt - sy, r->bottom - ny);
854 BitBlt(hdc, nx, ny, cwid, chgt, hdcSrc, sx, sy, SRCCOPY);
856 } while (ny < r->bottom);
859 } while (nx < r->right);
861 SelectObject(hdcSrc, hOld);
867 * Check for existance of a file
869 static bool check_file(concptr s)
889 attrib = GetFileAttributes(path);
891 /* Require valid filename */
892 if (attrib == INVALID_FILE_NAME) return FALSE;
894 /* Prohibit directory */
895 if (attrib & FILE_ATTRIBUTE_DIRECTORY) return FALSE;
899 /* Examine and verify */
900 if (_dos_getfileattr(path, &attrib)) return FALSE;
902 /* Prohibit something */
903 if (attrib & FA_LABEL) return FALSE;
905 /* Prohibit directory */
906 if (attrib & FA_DIREC) return FALSE;
916 * Check for existance of a directory
918 static bool check_dir(concptr s)
940 /* Remove trailing backslash */
941 if (i && (path[i - 1] == '\\')) path[--i] = '\0';
946 attrib = GetFileAttributes(path);
948 /* Require valid filename */
949 if (attrib == INVALID_FILE_NAME) return FALSE;
951 /* Require directory */
952 if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return FALSE;
956 /* Examine and verify */
957 if (_dos_getfileattr(path, &attrib)) return FALSE;
959 /* Prohibit something */
960 if (attrib & FA_LABEL) return FALSE;
962 /* Require directory */
963 if (!(attrib & FA_DIREC)) return FALSE;
975 static void validate_file(concptr s)
980 quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
986 * Validate a directory
988 static void validate_dir(concptr s, bool vital)
993 /* This directory contains needed data */
996 quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
998 /* Attempt to create this directory */
1001 quit_fmt("Unable to create directory:\n%s", s);
1008 * @brief (Windows版固有実装)Get the "size" for a window
1010 static void term_getsize(term_data *td)
1014 if (td->cols < 1) td->cols = 1;
1015 if (td->rows < 1) td->rows = 1;
1018 wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
1019 hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
1021 /* Fake window size */
1023 rc.right = rc.left + wid;
1025 rc.bottom = rc.top + hgt;
1027 /* rc.right += 1; */
1028 /* rc.bottom += 1; */
1031 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
1034 td->size_wid = rc.right - rc.left;
1035 td->size_hgt = rc.bottom - rc.top;
1037 /* See CreateWindowEx */
1040 /* Extract actual location */
1041 GetWindowRect(td->w, &rc);
1043 /* Save the location */
1044 td->pos_x = rc.left;
1050 * Write the "prefs" for a single term
1052 static void save_prefs_aux(int i)
1054 term_data *td = &data[i];
1055 GAME_TEXT sec_name[128];
1059 WINDOWPLACEMENT lpwndpl;
1062 /* Make section name */
1063 sprintf(sec_name, "Term-%d", i);
1068 strcpy(buf, td->visible ? "1" : "0");
1069 WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
1074 strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "MS ゴシック");
1076 strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "Courier");
1079 WritePrivateProfileString(sec_name, "Font", buf, ini_file);
1081 wsprintf(buf, "%d", td->lf.lfWidth);
1082 WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
1083 wsprintf(buf, "%d", td->lf.lfHeight);
1084 WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
1085 wsprintf(buf, "%d", td->lf.lfWeight);
1086 WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
1088 strcpy(buf, td->bizarre ? "1" : "0");
1089 WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file);
1092 wsprintf(buf, "%d", td->tile_wid);
1093 WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
1096 wsprintf(buf, "%d", td->tile_hgt);
1097 WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
1099 /* Get window placement and dimensions */
1100 lpwndpl.length = sizeof(WINDOWPLACEMENT);
1101 GetWindowPlacement(td->w, &lpwndpl);
1103 /* Acquire position in *normal* mode (not minimized) */
1104 rc = lpwndpl.rcNormalPosition;
1106 /* Window size (x) */
1107 if (i == 0) wsprintf(buf, "%d", normsize.x);
1108 else wsprintf(buf, "%d", td->cols);
1109 WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
1111 /* Window size (y) */
1112 if (i == 0) wsprintf(buf, "%d", normsize.y);
1113 else wsprintf(buf, "%d", td->rows);
1114 WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
1116 /* Maxmized (only main window) */
1119 strcpy(buf, IsZoomed(td->w) ? "1" : "0");
1120 WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
1123 /* Acquire position */
1124 GetWindowRect(td->w, &rc);
1126 /* Window position (x) */
1127 wsprintf(buf, "%d", rc.left);
1128 WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
1130 /* Window position (y) */
1131 wsprintf(buf, "%d", rc.top);
1132 WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
1134 /* Window Z position */
1137 strcpy(buf, td->posfix ? "1" : "0");
1138 WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
1145 * We assume that the windows have all been initialized
1147 static void save_prefs(void)
1153 /* Save the "arg_graphics" flag */
1154 sprintf(buf, "%d", arg_graphics);
1155 WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
1157 /* Save the "arg_bigtile" flag */
1158 strcpy(buf, arg_bigtile ? "1" : "0");
1159 WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
1161 /* Save the "arg_sound" flag */
1162 strcpy(buf, arg_sound ? "1" : "0");
1163 WritePrivateProfileString("Angband", "Sound", buf, ini_file);
1165 /* Save the "arg_sound" flag */
1166 strcpy(buf, arg_music ? "1" : "0");
1167 WritePrivateProfileString("Angband", "Music", buf, ini_file);
1170 strcpy(buf, use_bg ? "1" : "0");
1171 WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
1172 WritePrivateProfileString("Angband", "BackGroundBitmap",
1173 bg_bitmap_file[0] != '\0' ? bg_bitmap_file : "bg.bmp", ini_file);
1175 /* Save window prefs */
1176 for (i = 0; i < MAX_TERM_DATA; ++i)
1184 * Load the "prefs" for a single term
1186 static void load_prefs_aux(int i)
1188 term_data *td = &data[i];
1189 GAME_TEXT sec_name[128];
1192 int wid, hgt, posx, posy;
1193 int dispx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
1194 int dispy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
1198 /* Make section name */
1199 sprintf(sec_name, "Term-%d", i);
1201 /* Make section name */
1202 sprintf(sec_name, "Term-%d", i);
1207 td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
1210 /* Desired font, with default */
1212 GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
1214 GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
1219 td->bizarre = (GetPrivateProfileInt(sec_name, "Bizarre", td->bizarre, ini_file) != 0);
1221 /* Analyze font, save desired font name */
1222 td->font_want = string_make(tmp);
1224 td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
1225 td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
1226 td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
1229 td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
1230 td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
1233 td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
1234 td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
1235 normsize.x = td->cols; normsize.y = td->rows;
1240 win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
1243 /* Window position */
1244 posx = GetPrivateProfileInt(sec_name, "PositionX", posx, ini_file);
1245 posy = GetPrivateProfileInt(sec_name, "PositionY", posy, ini_file);
1246 td->pos_x = MIN(MAX(0, posx), dispx - 128);
1247 td->pos_y = MIN(MAX(0, posy), dispy - 128);
1249 /* Window Z position */
1252 td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
1260 static void load_prefs(void)
1264 /* Extract the "arg_graphics" flag */
1265 arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
1267 /* Extract the "arg_bigtile" flag */
1268 arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
1269 use_bigtile = arg_bigtile;
1271 /* Extract the "arg_sound" flag */
1272 arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
1274 /* Extract the "arg_sound" flag */
1275 arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
1278 use_bg = GetPrivateProfileInt("Angband", "BackGround", 0, ini_file);
1279 GetPrivateProfileString("Angband", "BackGroundBitmap", "bg.bmp", bg_bitmap_file, 1023, ini_file);
1281 /* Load window prefs */
1282 for (i = 0; i < MAX_TERM_DATA; ++i)
1288 #if defined(USE_SOUND) || defined(USE_MUSIC)
1291 * - Taken from files.c.
1293 * Extract "tokens" from a buffer
1295 * This function uses "whitespace" as delimiters, and treats any amount of
1296 * whitespace as a single delimiter. We will never return any empty tokens.
1297 * When given an empty buffer, or a buffer containing only "whitespace", we
1298 * will return no tokens. We will never extract more than "num" tokens.
1300 * By running a token through the "text_to_ascii()" function, you can allow
1301 * that token to include (encoded) whitespace, using "\s" to encode spaces.
1303 * We save pointers to the tokens in "tokens", and return the number found.
1305 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
1315 /* Skip leading whitespace */
1316 for (; *s && iswspace(*s); ++s) /* loop */;
1321 /* Find next whitespace, if any */
1322 for (t = s; *t && !iswspace(*t); ++t) /* loop */;
1324 /* Nuke and advance (if necessary) */
1325 if (*t) *t++ = '\0';
1327 /* Save the token */
1338 #endif /* USE_SOUND || USE_MUSIC */
1342 static void load_sound_prefs(void)
1346 char ini_path[1024];
1347 char wav_path[1024];
1348 char *zz[SAMPLE_SOUND_MAX];
1350 /* Access the sound.cfg */
1352 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
1354 for (i = 0; i < SOUND_MAX; i++)
1356 GetPrivateProfileString("Sound", angband_sound_name[i], "", tmp, 1024, ini_path);
1358 num = tokenize_whitespace(tmp, SAMPLE_SOUND_MAX, zz);
1360 for (j = 0; j < num; j++)
1362 /* Access the sound */
1363 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_SOUND, zz[j]);
1365 /* Save the sound filename, if it exists */
1366 if (check_file(wav_path))
1367 sound_file[i][j] = string_make(zz[j]);
1372 #endif /* USE_SOUND */
1376 static void load_music_prefs(void)
1380 char ini_path[1024];
1381 char wav_path[1024];
1382 char *zz[SAMPLE_MUSIC_MAX];
1385 /* Access the music.cfg */
1387 path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
1389 GetPrivateProfileString("Device", "type", "", mci_device_type, 256, ini_path);
1391 for (i = 0; i < MUSIC_BASIC_MAX; i++)
1393 GetPrivateProfileString("Basic", angband_music_basic_name[i], "", tmp, 1024, ini_path);
1395 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
1397 for (j = 0; j < num; j++)
1399 /* Access the sound */
1400 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
1402 /* Save the sound filename, if it exists */
1403 if (check_file(wav_path))
1404 music_file[i][j] = string_make(zz[j]);
1408 for (i = 0; i < current_world_ptr->max_d_idx; i++)
1410 sprintf(key, "dungeon%03d", i);
1411 GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path);
1413 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
1415 for (j = 0; j < num; j++)
1417 /* Access the sound */
1418 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
1420 /* Save the sound filename, if it exists */
1421 if (check_file(wav_path))
1422 dungeon_music_file[i][j] = string_make(zz[j]);
1426 for (i = 0; i < max_q_idx; i++)
1428 sprintf(key, "quest%03d", i);
1429 GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
1431 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
1433 for (j = 0; j < num; j++)
1435 /* Access the sound */
1436 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
1438 /* Save the sound filename, if it exists */
1439 if (check_file(wav_path))
1440 quest_music_file[i][j] = string_make(zz[j]);
1444 for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
1446 sprintf(key, "town%03d", i);
1447 GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
1449 num = tokenize_whitespace(tmp, SAMPLE_MUSIC_MAX, zz);
1451 for (j = 0; j < num; j++)
1453 /* Access the sound */
1454 path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
1456 /* Save the sound filename, if it exists */
1457 if (check_file(wav_path))
1458 town_music_file[i][j] = string_make(zz[j]);
1465 #endif /* USE_MUSIC */
1468 * Create the new global palette based on the bitmap palette
1469 * (if any), and the standard 16 entry palette derived from
1470 * "win_clr[]" which is used for the basic 16 Angband colors.
1472 * This function is never called before all windows are ready.
1474 * This function returns FALSE if the new palette could not be
1475 * prepared, which should normally be a fatal error. XXX XXX
1477 * Note that only some machines actually use a "palette".
1479 static int new_palette(void)
1487 LPLOGPALETTE pLogPal;
1488 LPPALETTEENTRY lppe;
1493 /* This makes no sense */
1494 if (!paletted) return TRUE;
1504 /* Check the bitmap palette */
1505 hBmPal = infGraph.hPalette;
1507 /* Use the bitmap */
1510 lppeSize = 256 * sizeof(PALETTEENTRY);
1511 lppe = (LPPALETTEENTRY)ralloc(lppeSize);
1512 nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
1513 if ((nEntries == 0) || (nEntries > 220))
1516 plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
1519 rnfree(lppe, lppeSize);
1526 #endif /* USE_GRAPHICS */
1528 /* Size of palette */
1529 pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
1531 /* Allocate palette */
1532 pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
1535 pLogPal->palVersion = 0x300;
1537 /* Make room for bitmap and normal data */
1538 pLogPal->palNumEntries = nEntries + 16;
1540 /* Save the bitmap data */
1541 for (i = 0; i < nEntries; i++)
1543 pLogPal->palPalEntry[i] = lppe[i];
1546 /* Save the normal data */
1547 for (i = 0; i < 16; i++)
1551 /* Access the entry */
1552 p = &(pLogPal->palPalEntry[i + nEntries]);
1554 /* Save the colors */
1555 p->peRed = GetRValue(win_clr[i]);
1556 p->peGreen = GetGValue(win_clr[i]);
1557 p->peBlue = GetBValue(win_clr[i]);
1559 /* Save the flags */
1560 p->peFlags = PC_NOCOLLAPSE;
1563 /* Free something */
1564 if (lppe) rnfree(lppe, lppeSize);
1566 /* Create a new palette, or fail */
1567 hNewPal = CreatePalette(pLogPal);
1568 if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
1570 /* Free the palette */
1571 rnfree(pLogPal, pLogPalSize);
1576 /* Realize the palette */
1578 SelectPalette(hdc, hNewPal, 0);
1579 i = RealizePalette(hdc);
1580 ReleaseDC(td->w, hdc);
1581 if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
1585 for (i = 1; i < MAX_TERM_DATA; i++)
1590 SelectPalette(hdc, hNewPal, 0);
1591 ReleaseDC(td->w, hdc);
1594 /* Delete old palette */
1595 if (hPal) DeleteObject(hPal);
1597 /* Save new palette */
1607 * @brief グラフィクスを初期化する / Initialize graphics
1610 * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
1611 * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
1614 static bool init_graphics(void)
1616 /* Initialize once */
1618 BYTE wid, hgt, twid, thgt, ox, oy;
1621 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1631 ANGBAND_GRAF = "new";
1633 else if (arg_graphics == GRAPHICS_HENGBAND)
1653 ANGBAND_GRAF = "ne2";
1664 ANGBAND_GRAF = "old";
1667 /* Access the bitmap file */
1668 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
1670 /* Load the bitmap or quit */
1671 if (!ReadDIB(data[0].w, buf, &infGraph))
1673 plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
1677 /* Save the new sizes */
1678 infGraph.CellWidth = wid;
1679 infGraph.CellHeight = hgt;
1680 infGraph.TileWidth = twid;
1681 infGraph.TileHeight = thgt;
1682 infGraph.OffsetX = ox;
1683 infGraph.OffsetY = oy;
1685 if (arg_graphics == GRAPHICS_ADAM_BOLT)
1687 /* Access the mask file */
1688 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
1690 /* Load the bitmap or quit */
1691 if (!ReadDIB(data[0].w, buf, &infMask))
1693 plog_fmt("Cannot read bitmap file '%s'", buf);
1697 if (arg_graphics == GRAPHICS_HENGBAND)
1699 /* Access the mask file */
1700 path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
1702 /* Load the bitmap or quit */
1703 if (!ReadDIB(data[0].w, buf, &infMask))
1705 plog_fmt("Cannot read bitmap file '%s'", buf);
1710 /* Activate a palette */
1715 plog(_("パレットを実現できません!", "Cannot activate palette!"));
1719 /* Graphics available */
1720 current_graphics_mode = arg_graphics;
1721 return (current_graphics_mode);
1723 #endif /* USE_GRAPHICS */
1730 static bool init_music(void)
1732 /* Initialize once */
1735 /* Load the prefs */
1738 /* Sound available */
1739 can_use_music = TRUE;
1741 return (can_use_music);
1745 * Hack -- Stop a music
1747 static void stop_music(void)
1749 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
1750 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
1753 #endif /* USE_MUSIC */
1759 static bool init_sound(void)
1761 /* Initialize once */
1764 /* Load the prefs */
1767 /* Sound available */
1768 can_use_sound = TRUE;
1770 return (can_use_sound);
1772 #endif /* USE_SOUND */
1778 static void term_window_resize(term_data *td)
1780 /* Require window */
1783 /* Resize the window */
1784 SetWindowPos(td->w, 0, 0, 0,
1785 td->size_wid, td->size_hgt,
1786 SWP_NOMOVE | SWP_NOZORDER);
1789 InvalidateRect(td->w, NULL, TRUE);
1794 * Force the use of a new "font file" for a term_data
1796 * This function may be called before the "window" is ready
1798 * This function returns zero only if everything succeeds.
1800 * Note that the "font name" must be capitalized!!!
1802 static errr term_force_font(term_data *td, concptr path)
1806 /* Forget the old font (if needed) */
1807 if (td->font_id) DeleteObject(td->font_id);
1812 /* Create the font (using the 'base' of the font file name!) */
1813 td->font_id = CreateFontIndirect(&(td->lf));
1814 wid = td->lf.lfWidth;
1815 hgt = td->lf.lfHeight;
1816 if (!td->font_id) return 1;
1818 /* Hack -- Unknown size */
1825 /* all this trouble to get the cell size */
1826 hdcDesktop = GetDC(HWND_DESKTOP);
1827 hfOld = SelectObject(hdcDesktop, td->font_id);
1828 GetTextMetrics(hdcDesktop, &tm);
1829 SelectObject(hdcDesktop, hfOld);
1830 ReleaseDC(HWND_DESKTOP, hdcDesktop);
1832 /* Font size info */
1833 wid = tm.tmAveCharWidth;
1837 /* Save the size info */
1848 * Allow the user to change the font for this window.
1850 static void term_change_font(term_data *td)
1854 memset(&cf, 0, sizeof(cf));
1855 cf.lStructSize = sizeof(cf);
1856 cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
1857 cf.lpLogFont = &(td->lf);
1859 if (ChooseFont(&cf))
1861 /* Force the font */
1862 term_force_font(td, NULL);
1864 /* Assume not bizarre */
1867 /* Reset the tile info */
1868 td->tile_wid = td->font_wid;
1869 td->tile_hgt = td->font_hgt;
1871 /* Analyze the font */
1874 /* Resize the window */
1875 term_window_resize(td);
1881 * Allow the user to lock this window.
1883 static void term_window_pos(term_data *td, HWND hWnd)
1885 SetWindowPos(td->w, hWnd, 0, 0, 0, 0,
1886 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1889 static void windows_map(player_type *player_ptr);
1892 * Hack -- redraw a term_data
1894 static void term_data_redraw(player_type *player_ptr, term_data *td)
1898 /* Redraw the map */
1899 windows_map(player_ptr);
1903 /* Activate the term */
1904 Term_activate(&td->t);
1906 /* Redraw the contents */
1909 /* Restore the term */
1910 Term_activate(term_screen);
1915 void term_inversed_area(HWND hWnd, int x, int y, int w, int h)
1919 HBRUSH myBrush, oldBrush;
1921 term_data *td = (term_data *)GetWindowLong(hWnd, 0);
1922 int tx = td->size_ow1 + x * td->tile_wid;
1923 int ty = td->size_oh1 + y * td->tile_hgt;
1924 int tw = w * td->tile_wid - 1;
1925 int th = h * td->tile_hgt - 1;
1928 myBrush = CreateSolidBrush(RGB(255, 255, 255));
1929 oldBrush = SelectObject(hdc, myBrush);
1930 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
1932 PatBlt(hdc, tx, ty, tw, th, PATINVERT);
1934 SelectObject(hdc, oldBrush);
1935 SelectObject(hdc, oldPen);
1940 * @brief //!< Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
1942 static errr term_user_win(int n)
1953 * React to global changes
1955 static errr term_xtra_win_react(player_type *player_ptr)
1962 /* Save the default colors */
1963 for (i = 0; i < 256; i++)
1965 /* Simply accept the desired colors */
1966 win_pal[i] = angband_color_table[i][0];
1977 bool change = FALSE;
1979 /* Save the default colors */
1980 for (i = 0; i < 256; i++)
1982 /* Extract desired values */
1983 rv = angband_color_table[i][1];
1984 gv = angband_color_table[i][2];
1985 bv = angband_color_table[i][3];
1987 /* Extract a full color code */
1988 code = PALETTERGB(rv, gv, bv);
1990 /* Activate changes */
1991 if (win_clr[i] != code)
1993 /* Note the change */
1996 /* Apply the desired color */
2001 /* Activate the palette if needed */
2002 if (change) (void)new_palette();
2008 /* Handle "arg_sound" */
2009 if (use_sound != arg_sound)
2011 /* Initialize (if needed) */
2012 if (arg_sound && !init_sound())
2015 plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
2021 /* Change setting */
2022 use_sound = arg_sound;
2029 /* Handle "arg_sound" */
2030 if (use_music != arg_music)
2032 /* Initialize (if needed) */
2033 if (arg_music && !init_music())
2036 plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
2041 /* Change setting */
2042 use_music = arg_music;
2044 if (!arg_music) stop_music();
2045 else select_floor_music(player_ptr);
2054 /* Handle "arg_graphics" */
2055 if (use_graphics != arg_graphics)
2057 /* Initialize (if needed) */
2058 if (arg_graphics && !init_graphics())
2061 plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
2064 arg_graphics = GRAPHICS_NONE;
2067 /* Change setting */
2068 use_graphics = arg_graphics;
2071 #ifdef ANGBAND_2_8_1
2072 reset_visuals(player_ptr);
2073 #else /* ANGBAND_2_8_1 */
2074 reset_visuals(TRUE);
2075 #endif /* ANGBAND_2_8_1 */
2078 #endif /* USE_GRAPHICS */
2081 /* Clean up windows */
2082 for (i = 0; i < MAX_TERM_DATA; i++)
2086 term_data *td = &data[i];
2088 /* Update resized windows */
2089 if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
2092 Term_activate(&td->t);
2094 /* Hack -- Resize the term */
2095 Term_resize(td->cols, td->rows);
2097 /* Redraw the contents */
2110 * Process at least one event
2112 static errr term_xtra_win_event(int v)
2116 /* Wait for an event */
2120 if (GetMessage(&msg, NULL, 0, 0))
2122 TranslateMessage(&msg);
2123 DispatchMessage(&msg);
2127 /* Check for an event */
2131 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2133 TranslateMessage(&msg);
2134 DispatchMessage(&msg);
2144 * Process all pending events
2146 static errr term_xtra_win_flush(void)
2150 /* Process all pending events */
2151 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2153 TranslateMessage(&msg);
2154 DispatchMessage(&msg);
2163 * Hack -- clear the screen
2165 * Make this more efficient
2167 static errr term_xtra_win_clear(void)
2169 term_data *td = (term_data*)(Term->data);
2174 /* Rectangle to erase */
2175 rc.left = td->size_ow1;
2176 rc.right = rc.left + td->cols * td->tile_wid;
2177 rc.top = td->size_oh1;
2178 rc.bottom = rc.top + td->rows * td->tile_hgt;
2182 SetBkColor(hdc, RGB(0, 0, 0));
2183 SelectObject(hdc, td->font_id);
2184 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2189 rc.left = 0; rc.top = 0;
2192 ReleaseDC(td->w, hdc);
2200 * Hack -- make a noise
2202 static errr term_xtra_win_noise(void)
2204 MessageBeep(MB_ICONASTERISK);
2210 * Hack -- make a sound
2212 static errr term_xtra_win_sound(int v)
2217 #endif /* USE_SOUND */
2219 /* Sound disabled */
2220 if (!use_sound) return 1;
2223 if ((v < 0) || (v >= SOUND_MAX)) return 1;
2227 /* Count the samples */
2228 for (i = 0; i < SAMPLE_SOUND_MAX; i++)
2230 if (!sound_file[v][i])
2235 if (i == 0) return 1;
2237 /* Build the path */
2238 path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]);
2242 /* Play the sound, catch errors */
2243 return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC));
2247 /* Play the sound, catch errors */
2248 return (sndPlaySound(buf, SND_ASYNC));
2252 #else /* USE_SOUND */
2256 #endif /* USE_SOUND */
2260 * Hack -- play a music
2262 static errr term_xtra_win_music(int n, int v)
2267 #endif /* USE_MUSIC */
2269 /* Sound disabled */
2270 if (n == TERM_XTRA_MUSIC_MUTE)
2272 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
2273 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
2276 if (!use_music) return 1;
2279 if (n == TERM_XTRA_MUSIC_BASIC && ((v < 0) || (v >= MUSIC_BASIC_MAX))) return 1;
2280 else if (v < 0 || v >= 1000) return(1); /*!< TODO */
2286 case TERM_XTRA_MUSIC_BASIC:
2287 for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!music_file[v][i]) break;
2289 case TERM_XTRA_MUSIC_DUNGEON:
2290 for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!dungeon_music_file[v][i]) break;
2292 case TERM_XTRA_MUSIC_QUEST:
2293 for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!quest_music_file[v][i]) break;
2295 case TERM_XTRA_MUSIC_TOWN:
2296 for (i = 0; i < SAMPLE_MUSIC_MAX; i++) if (!town_music_file[v][i]) break;
2308 case TERM_XTRA_MUSIC_BASIC:
2309 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, music_file[v][Rand_external(i)]);
2311 case TERM_XTRA_MUSIC_DUNGEON:
2312 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, dungeon_music_file[v][Rand_external(i)]);
2314 case TERM_XTRA_MUSIC_QUEST:
2315 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, quest_music_file[v][Rand_external(i)]);
2317 case TERM_XTRA_MUSIC_TOWN:
2318 path_build(buf, 1024, ANGBAND_DIR_XTRA_MUSIC, town_music_file[v][Rand_external(i)]);
2322 if (current_music_type == n && current_music_id == v)
2326 current_music_type = n;
2327 current_music_id = v;
2331 mop.lpstrDeviceType = mci_device_type;
2332 mop.lpstrElementName = buf;
2333 mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
2334 mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
2335 mciSendCommand(mop.wDeviceID, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mop);
2336 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
2337 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
2342 #else /* USE_MUSIC */
2346 #endif /* USE_MUSIC */
2352 * Delay for "x" milliseconds
2354 static int term_xtra_win_delay(int v)
2368 t = GetTickCount() + v;
2371 while (GetTickCount() < t)
2373 /* Handle messages */
2374 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
2376 TranslateMessage(&msg);
2377 DispatchMessage(&msg);
2389 * todo z-termに影響があるのでplayer_typeの追加は保留
2390 * Do a "special thing"
2392 static errr term_xtra_win(int n, int v)
2394 /* Handle a subset of the legal requests */
2397 /* Make a bell sound */
2398 case TERM_XTRA_NOISE:
2400 return (term_xtra_win_noise());
2404 case TERM_XTRA_MUSIC_BASIC:
2405 case TERM_XTRA_MUSIC_DUNGEON:
2406 case TERM_XTRA_MUSIC_QUEST:
2407 case TERM_XTRA_MUSIC_TOWN:
2409 return (term_xtra_win_music(n, v));
2412 /* Make a special sound */
2413 case TERM_XTRA_SOUND:
2415 return (term_xtra_win_sound(v));
2418 /* Process random events */
2419 case TERM_XTRA_BORED:
2421 return (term_xtra_win_event(0));
2424 /* Process an event */
2425 case TERM_XTRA_EVENT:
2427 return (term_xtra_win_event(v));
2430 /* Flush all events */
2431 case TERM_XTRA_FLUSH:
2433 return (term_xtra_win_flush());
2436 /* Clear the screen */
2437 case TERM_XTRA_CLEAR:
2439 return (term_xtra_win_clear());
2442 /* React to global changes */
2443 case TERM_XTRA_REACT:
2445 return (term_xtra_win_react(p_ptr));
2448 /* Delay for some milliseconds */
2449 case TERM_XTRA_DELAY:
2451 return (term_xtra_win_delay(v));
2461 * Low level graphics (Assumes valid input).
2463 * Draw a "cursor" at (x,y), using a "yellow box".
2465 static errr term_curs_win(int x, int y)
2467 term_data *td = (term_data*)(Term->data);
2472 int tile_wid, tile_hgt;
2476 tile_wid = td->map_tile_wid;
2477 tile_hgt = td->map_tile_hgt;
2481 tile_wid = td->tile_wid;
2482 tile_hgt = td->tile_hgt;
2485 /* Frame the grid */
2486 rc.left = x * tile_wid + td->size_ow1;
2487 rc.right = rc.left + tile_wid;
2488 rc.top = y * tile_hgt + td->size_oh1;
2489 rc.bottom = rc.top + tile_hgt;
2491 /* Cursor is done as a yellow "box" */
2493 FrameRect(hdc, &rc, hbrYellow);
2494 ReleaseDC(td->w, hdc);
2502 * Low level graphics (Assumes valid input).
2504 * Draw a "big cursor" at (x,y), using a "yellow box".
2506 static errr term_bigcurs_win(int x, int y)
2508 term_data *td = (term_data*)(Term->data);
2513 int tile_wid, tile_hgt;
2517 /* Normal cursor in map window */
2518 term_curs_win(x, y);
2523 tile_wid = td->tile_wid;
2524 tile_hgt = td->tile_hgt;
2527 /* Frame the grid */
2528 rc.left = x * tile_wid + td->size_ow1;
2529 rc.right = rc.left + 2 * tile_wid;
2530 rc.top = y * tile_hgt + td->size_oh1;
2531 rc.bottom = rc.top + tile_hgt;
2533 /* Cursor is done as a yellow "box" */
2535 FrameRect(hdc, &rc, hbrYellow);
2536 ReleaseDC(td->w, hdc);
2544 * Low level graphics (Assumes valid input).
2546 * Erase a "block" of "n" characters starting at (x,y).
2548 static errr term_wipe_win(int x, int y, int n)
2550 term_data *td = (term_data*)(Term->data);
2555 /* Rectangle to erase in client coords */
2556 rc.left = x * td->tile_wid + td->size_ow1;
2557 rc.right = rc.left + n * td->tile_wid;
2558 rc.top = y * td->tile_hgt + td->size_oh1;
2559 rc.bottom = rc.top + td->tile_hgt;
2562 SetBkColor(hdc, RGB(0, 0, 0));
2563 SelectObject(hdc, td->font_id);
2568 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2569 ReleaseDC(td->w, hdc);
2577 * Low level graphics. Assumes valid input.
2579 * Draw several ("n") chars, with an attr, at a given location.
2581 * All "graphic" data is handled by "term_pict_win()", below.
2583 * One would think there is a more efficient method for telling a window
2584 * what color it should be using to draw with, but perhaps simply changing
2585 * it every time is not too inefficient.
2587 static errr term_text_win(int x, int y, int n, TERM_COLOR a, concptr s)
2589 term_data *td = (term_data*)(Term->data);
2593 static HBITMAP WALL;
2594 static HBRUSH myBrush, oldBrush;
2596 static bool init_done = FALSE;
2599 WALL = LoadBitmap(hInstance, AppName);
2600 myBrush = CreatePatternBrush(WALL);
2604 /* Total rectangle */
2605 rc.left = x * td->tile_wid + td->size_ow1;
2606 rc.right = rc.left + n * td->tile_wid;
2607 rc.top = y * td->tile_hgt + td->size_oh1;
2608 rc.bottom = rc.top + td->tile_hgt;
2613 /* Background color */
2614 SetBkColor(hdc, RGB(0, 0, 0));
2616 /* Foreground color */
2619 SetTextColor(hdc, PALETTEINDEX(win_pal[a]));
2623 SetTextColor(hdc, win_clr[a & 0x0F]);
2627 SetTextColor(hdc, win_clr[a]);
2631 SelectObject(hdc, td->font_id);
2634 if (use_bg) SetBkMode(hdc, TRANSPARENT);
2638 (td->tile_hgt != td->font_hgt) ||
2639 (td->tile_wid != td->font_wid))
2643 /* Erase complete rectangle */
2644 ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
2647 if (use_bg) DrawBG(hdc, &rc);
2650 rc.left += ((td->tile_wid - td->font_wid) / 2);
2651 rc.right = rc.left + td->font_wid;
2652 rc.top += ((td->tile_hgt - td->font_hgt) / 2);
2653 rc.bottom = rc.top + td->font_hgt;
2655 /* Dump each character */
2656 for (i = 0; i < n; i++)
2659 if (use_bigtile && *(s + i) == "■"[0] && *(s + i + 1) == "■"[1])
2661 rc.right += td->font_wid;
2663 oldBrush = SelectObject(hdc, myBrush);
2664 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
2667 Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
2669 SelectObject(hdc, oldBrush);
2670 SelectObject(hdc, oldPen);
2671 rc.right -= td->font_wid;
2675 rc.left += 2 * td->tile_wid;
2676 rc.right += 2 * td->tile_wid;
2678 else if (iskanji(*(s + i))) /* 2バイト文字 */
2680 rc.right += td->font_wid;
2682 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2684 rc.right -= td->font_wid;
2688 rc.left += 2 * td->tile_wid;
2689 rc.right += 2 * td->tile_wid;
2691 else if (*(s + i) == 127) {
2692 oldBrush = SelectObject(hdc, myBrush);
2693 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
2696 Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
2698 SelectObject(hdc, oldBrush);
2699 SelectObject(hdc, oldPen);
2702 rc.left += td->tile_wid;
2703 rc.right += td->tile_wid;
2707 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
2710 rc.left += td->tile_wid;
2711 rc.right += td->tile_wid;
2714 if (*(s + i) == 127) {
2715 oldBrush = SelectObject(hdc, myBrush);
2716 oldPen = SelectObject(hdc, GetStockObject(NULL_PEN));
2719 Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
2721 SelectObject(hdc, oldBrush);
2722 SelectObject(hdc, oldPen);
2725 rc.left += td->tile_wid;
2726 rc.right += td->tile_wid;
2730 ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc,
2734 rc.left += td->tile_wid;
2735 rc.right += td->tile_wid;
2746 ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE | ETO_CLIPPED, &rc,
2751 ReleaseDC(td->w, hdc);
2759 * Low level graphics. Assumes valid input.
2761 * Draw an array of "special" attr/char pairs at the given location.
2763 * We use the "term_pict_win()" function for "graphic" data, which are
2764 * encoded by setting the "high-bits" of both the "attr" and the "char"
2765 * data. We use the "attr" to represent the "row" of the main bitmap,
2766 * and the "char" to represent the "col" of the main bitmap. The use
2767 * of this function is induced by the "higher_pict" flag.
2769 * If "graphics" is not available, we simply "wipe" the given grids.
2771 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)
2773 term_data *td = (term_data*)(Term->data);
2778 TERM_LEN x1, y1, w1, h1, tw1, th1;
2779 TERM_LEN x2, y2, w2, h2, tw2 = 0;
2789 /* Erase the grids */
2790 return (term_wipe_win(x, y, n));
2793 /* Size of bitmap cell */
2794 w1 = infGraph.CellWidth;
2795 h1 = infGraph.CellHeight;
2796 tw1 = infGraph.TileWidth;
2797 th1 = infGraph.TileHeight;
2799 /* Size of window cell */
2802 w2 = td->map_tile_wid;
2803 h2 = td->map_tile_hgt;
2812 if (use_bigtile) tw2 *= 2;
2815 /* Location of window cell */
2816 x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
2817 y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
2823 hdcSrc = CreateCompatibleDC(hdc);
2824 hbmSrcOld = SelectObject(hdcSrc, infGraph.hBitmap);
2826 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
2828 hdcMask = CreateCompatibleDC(hdc);
2829 SelectObject(hdcMask, infMask.hBitmap);
2832 /* Draw attr/char pairs */
2833 for (i = 0; i < n; i++, x2 += w2)
2835 TERM_COLOR a = ap[i];
2839 /* Extract picture */
2840 int row = (a & 0x7F);
2841 int col = (c & 0x7F);
2843 /* Location of bitmap cell */
2847 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
2849 x3 = (tcp[i] & 0x7F) * w1;
2850 y3 = (tap[i] & 0x7F) * h1;
2851 tw2 = tw2 * w1 / tw1;
2855 if ((tw1 == tw2) && (th1 == h2))
2857 /* Copy the terrain picture from the bitmap to the window */
2858 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, SRCCOPY);
2860 /* Mask out the tile */
2861 BitBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, SRCAND);
2864 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCPAINT);
2867 /* Need to stretch */
2870 /* Set the correct mode for stretching the tiles */
2871 SetStretchBltMode(hdc, COLORONCOLOR);
2873 /* Copy the terrain picture from the bitmap to the window */
2874 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x3, y3, w1, h1, SRCAND);
2876 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x3, y3, w1, h1, SRCPAINT);
2878 /* Only draw if terrain and overlay are different */
2879 if ((x1 != x3) || (y1 != y3))
2881 /* Mask out the tile */
2882 StretchBlt(hdc, x2, y2, tw2, h2, hdcMask, x1, y1, w1, h1, SRCAND);
2885 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
2892 if ((w1 == tw2) && (h1 == h2))
2894 /* Copy the picture from the bitmap to the window */
2895 BitBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, SRCCOPY);
2898 /* Need to stretch */
2901 /* Set the correct mode for stretching the tiles */
2902 SetStretchBltMode(hdc, COLORONCOLOR);
2904 /* Copy the picture from the bitmap to the window */
2905 StretchBlt(hdc, x2, y2, tw2, h2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
2911 SelectObject(hdcSrc, hbmSrcOld);
2914 if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND)
2917 SelectObject(hdcMask, hbmSrcOld);
2922 ReleaseDC(td->w, hdc);
2924 #else /* USE_GRAPHICS */
2926 /* Just erase this grid */
2927 return (Term_wipe_win(x, y, n));
2929 #endif /* USE_GRAPHICS */
2936 static void windows_map(player_type *player_ptr)
2938 term_data *td = &data[0];
2941 TERM_LEN x, min_x, max_x;
2942 TERM_LEN y, min_y, max_y;
2947 /* Only in graphics mode */
2948 if (!use_graphics) return;
2949 term_xtra_win_clear();
2951 td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
2952 td->map_tile_hgt = (td->tile_hgt * td->rows) / MAX_HGT;
2953 td->map_active = TRUE;
2958 max_x = player_ptr->current_floor_ptr->width;
2959 max_y = player_ptr->current_floor_ptr->height;
2963 for (x = min_x; x < max_x; x++)
2965 for (y = min_y; y < max_y; y++)
2967 map_info(player_ptr, y, x, &a, (char*)&c, &ta, (char*)&tc);
2969 /* Ignore non-graphics */
2970 if ((a & 0x80) && (c & 0x80))
2972 term_pict_win(x - min_x, y - min_y, 1, &a, &c, &ta, &tc);
2977 /* Hilite the player */
2978 term_curs_win(player_ptr->x - min_x, player_ptr->y - min_y);
2980 /* Wait for a keypress, flush key buffer */
2981 Term_inkey(&c, TRUE, TRUE);
2984 /* Switch off the map display */
2985 td->map_active = FALSE;
2987 /* Restore screen */
2988 term_xtra_win_clear();
2993 /*** Other routines ***/
2997 * Create and initialize a "term_data" given a title
2999 static void term_data_link(term_data *td)
3003 /* Initialize the term */
3004 term_init(t, td->cols, td->rows, td->keys);
3006 /* Use a "software" cursor */
3007 t->soft_cursor = TRUE;
3009 /* Use "term_pict" for "graphic" data */
3010 t->higher_pict = TRUE;
3012 /* Erase with "white space" */
3013 t->attr_blank = TERM_WHITE;
3014 t->char_blank = ' ';
3016 /* Prepare the template hooks */
3017 t->user_hook = term_user_win;
3018 t->xtra_hook = term_xtra_win;
3019 t->curs_hook = term_curs_win;
3020 t->bigcurs_hook = term_bigcurs_win;
3021 t->wipe_hook = term_wipe_win;
3022 t->text_hook = term_text_win;
3023 t->pict_hook = term_pict_win;
3025 /* Remember where we came from */
3026 t->data = (vptr)(td);
3031 * Create the windows
3033 * First, instantiate the "default" values, then read the "ini_file"
3034 * to over-ride selected values, then create the windows, and fonts.
3036 * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
3037 * must make active to realize the palette.
3039 static void init_windows(void)
3047 WIPE(td, term_data);
3051 td->s = angband_term_name[0];
3067 for (i = 1; i < MAX_TERM_DATA; i++)
3070 WIPE(td, term_data);
3071 td->s = angband_term_name[i];
3075 td->visible = FALSE;
3080 td->pos_x = (7 - i) * 30;
3081 td->pos_y = (7 - i) * 20;
3089 /* Main window (need these before term_getsize gets called) */
3091 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU |
3092 WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION |
3097 /* Sub windows (need these before term_getsize gets called) */
3098 for (i = 1; i < MAX_TERM_DATA; i++)
3101 td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU);
3102 td->dwExStyle = (WS_EX_TOOLWINDOW);
3107 for (i = 0; i < MAX_TERM_DATA; i++)
3111 strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
3112 td->lf.lfCharSet = DEFAULT_CHARSET;
3113 td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
3114 /* Activate the chosen font */
3115 term_force_font(td, NULL);
3116 if (!td->tile_wid) td->tile_wid = td->font_wid;
3117 if (!td->tile_hgt) td->tile_hgt = td->font_hgt;
3119 /* Analyze the font */
3122 /* Resize the window */
3123 term_window_resize(td);
3127 /* Sub windows (reverse order) */
3128 for (i = MAX_TERM_DATA - 1; i >= 1; --i)
3133 td->w = CreateWindowEx(td->dwExStyle, AngList,
3135 td->pos_x, td->pos_y,
3136 td->size_wid, td->size_hgt,
3137 HWND_DESKTOP, NULL, hInstance, NULL);
3139 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
3143 td->size_hack = TRUE;
3144 ShowWindow(td->w, SW_SHOW);
3145 td->size_hack = FALSE;
3149 angband_term[i] = &td->t;
3153 /* Activate the window */
3154 SetActiveWindow(td->w);
3159 term_window_pos(&data[i], HWND_TOPMOST);
3163 term_window_pos(&data[i], td->w);
3173 td->w = CreateWindowEx(td->dwExStyle, AppName,
3175 td->pos_x, td->pos_y,
3176 td->size_wid, td->size_hgt,
3177 HWND_DESKTOP, NULL, hInstance, NULL);
3179 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
3182 angband_term[0] = &td->t;
3183 normsize.x = td->cols;
3184 normsize.y = td->rows;
3186 /* Activate the main window */
3187 if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED);
3188 else ShowWindow(td->w, SW_SHOW);
3190 /* Bring main window back to top */
3191 SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
3195 (void)new_palette();
3198 /* Create a "brush" for drawing the "cursor" */
3199 hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
3202 /* Process pending messages */
3203 (void)term_xtra_win_flush();
3211 static void setup_menus(void)
3215 HMENU hm = GetMenu(data[0].w);
3218 /* Menu "File", Disable all */
3219 EnableMenuItem(hm, IDM_FILE_NEW,
3220 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3221 EnableMenuItem(hm, IDM_FILE_OPEN,
3222 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3223 EnableMenuItem(hm, IDM_FILE_SAVE,
3224 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3225 EnableMenuItem(hm, IDM_FILE_EXIT,
3226 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3227 EnableMenuItem(hm, IDM_FILE_SCORE,
3228 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3231 /* No character available */
3232 if (!current_world_ptr->character_generated)
3234 /* Menu "File", Item "New" */
3235 EnableMenuItem(hm, IDM_FILE_NEW, MF_BYCOMMAND | MF_ENABLED);
3237 /* Menu "File", Item "Open" */
3238 EnableMenuItem(hm, IDM_FILE_OPEN, MF_BYCOMMAND | MF_ENABLED);
3241 /* A character available */
3242 if (current_world_ptr->character_generated)
3244 /* Menu "File", Item "Save" */
3245 EnableMenuItem(hm, IDM_FILE_SAVE,
3246 MF_BYCOMMAND | MF_ENABLED);
3249 /* Menu "File", Item "Exit" */
3250 EnableMenuItem(hm, IDM_FILE_EXIT,
3251 MF_BYCOMMAND | MF_ENABLED);
3253 EnableMenuItem(hm, IDM_FILE_SCORE,
3254 MF_BYCOMMAND | MF_ENABLED);
3257 /* Menu "Window::Visibility" */
3258 for (i = 0; i < MAX_TERM_DATA; i++)
3260 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3261 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3263 CheckMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3264 (data[i].visible ? MF_CHECKED : MF_UNCHECKED));
3266 EnableMenuItem(hm, IDM_WINDOW_VIS_0 + i,
3267 MF_BYCOMMAND | MF_ENABLED);
3270 /* Menu "Window::Font" */
3271 for (i = 0; i < MAX_TERM_DATA; i++)
3273 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3274 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3276 if (data[i].visible)
3278 EnableMenuItem(hm, IDM_WINDOW_FONT_0 + i,
3279 MF_BYCOMMAND | MF_ENABLED);
3283 /* Menu "Window::Window Position Fix" */
3284 for (i = 0; i < MAX_TERM_DATA; i++)
3286 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3287 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3289 CheckMenuItem(hm, IDM_WINDOW_POS_0 + i,
3290 (data[i].posfix ? MF_CHECKED : MF_UNCHECKED));
3292 if (data[i].visible)
3294 EnableMenuItem(hm, IDM_WINDOW_POS_0 + i,
3295 MF_BYCOMMAND | MF_ENABLED);
3299 /* Menu "Window::Bizarre Display" */
3300 for (i = 0; i < MAX_TERM_DATA; i++)
3302 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3303 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3305 CheckMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3306 (data[i].bizarre ? MF_CHECKED : MF_UNCHECKED));
3308 if (data[i].visible)
3310 EnableMenuItem(hm, IDM_WINDOW_BIZ_0 + i,
3311 MF_BYCOMMAND | MF_ENABLED);
3316 /* Menu "Window::Increase Tile Width" */
3317 for (i = 0; i < MAX_TERM_DATA; i++)
3319 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3320 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3322 if (data[i].visible)
3324 EnableMenuItem(hm, IDM_WINDOW_I_WID_0 + i,
3325 MF_BYCOMMAND | MF_ENABLED);
3330 /* Menu "Window::Decrease Tile Width" */
3331 for (i = 0; i < MAX_TERM_DATA; i++)
3333 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3334 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3336 if (data[i].visible)
3338 EnableMenuItem(hm, IDM_WINDOW_D_WID_0 + i,
3339 MF_BYCOMMAND | MF_ENABLED);
3344 /* Menu "Window::Increase Tile Height" */
3345 for (i = 0; i < MAX_TERM_DATA; i++)
3347 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3348 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3350 if (data[i].visible)
3352 EnableMenuItem(hm, IDM_WINDOW_I_HGT_0 + i,
3353 MF_BYCOMMAND | MF_ENABLED);
3358 /* Menu "Window::Decrease Tile Height" */
3359 for (i = 0; i < MAX_TERM_DATA; i++)
3361 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3362 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3364 if (data[i].visible)
3366 EnableMenuItem(hm, IDM_WINDOW_D_HGT_0 + i,
3367 MF_BYCOMMAND | MF_ENABLED);
3372 /* Menu "Options", disable all */
3373 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3374 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3375 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3376 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3377 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3378 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3379 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE,
3380 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3381 EnableMenuItem(hm, IDM_OPTIONS_SOUND,
3382 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3386 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3387 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3390 /* Menu "Options", Item "Map" */
3391 if (use_graphics != GRAPHICS_NONE)
3392 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP, MF_BYCOMMAND | MF_ENABLED);
3394 EnableMenuItem(GetMenu(data[0].w), IDM_OPTIONS_MAP,
3395 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
3397 /* Menu "Options", update all */
3398 CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS,
3399 (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
3400 CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS,
3401 (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
3402 CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS,
3403 (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
3404 CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS,
3405 (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
3406 CheckMenuItem(hm, IDM_OPTIONS_BIGTILE,
3407 (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
3408 CheckMenuItem(hm, IDM_OPTIONS_MUSIC,
3409 (arg_music ? MF_CHECKED : MF_UNCHECKED));
3410 CheckMenuItem(hm, IDM_OPTIONS_SOUND,
3411 (arg_sound ? MF_CHECKED : MF_UNCHECKED));
3412 CheckMenuItem(hm, IDM_OPTIONS_BG,
3413 (use_bg ? MF_CHECKED : MF_UNCHECKED));
3417 CheckMenuItem(hm, IDM_OPTIONS_SAVER,
3418 (hwndSaver ? MF_CHECKED : MF_UNCHECKED));
3422 /* Menu "Options", Item "Graphics" */
3423 EnableMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, MF_ENABLED);
3424 /* Menu "Options", Item "Graphics" */
3425 EnableMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, MF_ENABLED);
3426 /* Menu "Options", Item "Graphics" */
3427 EnableMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, MF_ENABLED);
3428 /* Menu "Options", Item "Graphics" */
3429 EnableMenuItem(hm, IDM_OPTIONS_BIGTILE, MF_ENABLED);
3430 #endif /* USE_GRAPHICS */
3433 /* Menu "Options", Item "Sound" */
3434 EnableMenuItem(hm, IDM_OPTIONS_SOUND, MF_ENABLED);
3435 #endif /* USE_SOUND */
3438 /* Menu "Options", Item "ScreenSaver" */
3439 EnableMenuItem(hm, IDM_OPTIONS_SAVER,
3440 MF_BYCOMMAND | MF_ENABLED);
3441 #endif /* USE_SAVER */
3446 * Check for double clicked (or dragged) savefile
3448 * Apparently, Windows copies the entire filename into the first
3449 * piece of the "command line string". Perhaps we should extract
3450 * the "basename" of that filename and append it to the "save" dir.
3452 static void check_for_save_file(player_type *player_ptr, LPSTR cmd_line)
3462 /* Extract filename */
3463 strcat(savefile, s);
3465 /* Validate the file */
3466 validate_file(savefile);
3468 /* Game in progress */
3469 game_in_progress = TRUE;
3472 play_game(player_ptr, FALSE);
3477 * Process a menu command
3479 static void process_menus(player_type *player_ptr, WORD wCmd)
3495 plog(_("まだ初期化中です...", "You cannot do that yet..."));
3497 else if (game_in_progress)
3499 plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
3503 game_in_progress = TRUE;
3505 play_game(player_ptr, TRUE);
3516 plog(_("まだ初期化中です...", "You cannot do that yet..."));
3518 else if (game_in_progress)
3520 plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
3524 memset(&ofn, 0, sizeof(ofn));
3525 ofn.lStructSize = sizeof(ofn);
3526 ofn.hwndOwner = data[0].w;
3527 ofn.lpstrFilter = "Save Files (*.)\0*\0";
3528 ofn.nFilterIndex = 1;
3529 ofn.lpstrFile = savefile;
3530 ofn.nMaxFile = 1024;
3531 ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
3532 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
3534 if (GetOpenFileName(&ofn))
3536 /* Load 'savefile' */
3537 validate_file(savefile);
3538 game_in_progress = TRUE;
3540 play_game(player_ptr, FALSE);
3550 if (game_in_progress && current_world_ptr->character_generated)
3554 plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
3558 /* Hack -- Forget messages */
3563 do_cmd_save_game(player_ptr, FALSE);
3564 #else /* ZANGBAND */
3566 #endif /* ZANGBAND */
3570 plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
3577 if (game_in_progress && current_world_ptr->character_generated)
3581 plog(_("今は終了できません。", "You may not do that right now."));
3585 /* Hack -- Forget messages */
3588 forget_lite(player_ptr->current_floor_ptr);
3589 forget_view(player_ptr->current_floor_ptr);
3590 clear_mon_lite(player_ptr->current_floor_ptr);
3594 /* do_cmd_save_game(FALSE); */
3595 #else /* ZANGBAND */
3596 /* do_cmd_save_game(); */
3597 #endif /* ZANGBAND */
3598 Term_key_push(SPECIAL_KEY_QUIT);
3606 case IDM_FILE_SCORE:
3609 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
3611 /* Open the binary high score file, for reading */
3612 highscore_fd = fd_open(buf, O_RDONLY);
3614 /* Paranoia -- No score file */
3615 if (highscore_fd < 0)
3617 msg_print("Score file unavailable.");
3624 /* Display the scores */
3625 display_scores_aux(0, MAX_HISCORES, -1, NULL);
3627 /* Shut the high score file */
3628 (void)fd_close(highscore_fd);
3630 /* Forget the high score fd */
3634 /* Hack - Flush it */
3642 case IDM_FILE_MOVIE:
3646 plog(_("まだ初期化中です...", "You cannot do that yet..."));
3648 else if (game_in_progress)
3650 plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
3654 memset(&ofn, 0, sizeof(ofn));
3655 ofn.lStructSize = sizeof(ofn);
3656 ofn.hwndOwner = data[0].w;
3657 ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
3658 ofn.nFilterIndex = 1;
3659 ofn.lpstrFile = savefile;
3660 ofn.nMaxFile = 1024;
3661 ofn.lpstrInitialDir = ANGBAND_DIR_USER;
3662 ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
3664 if (GetOpenFileName(&ofn))
3666 /* Load 'savefile' */
3667 prepare_browse_movie_aux(savefile);
3668 play_game(player_ptr, FALSE);
3677 case IDM_WINDOW_VIS_0:
3679 plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
3683 /* Window visibility */
3684 case IDM_WINDOW_VIS_1:
3685 case IDM_WINDOW_VIS_2:
3686 case IDM_WINDOW_VIS_3:
3687 case IDM_WINDOW_VIS_4:
3688 case IDM_WINDOW_VIS_5:
3689 case IDM_WINDOW_VIS_6:
3690 case IDM_WINDOW_VIS_7:
3692 i = wCmd - IDM_WINDOW_VIS_0;
3694 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3701 ShowWindow(td->w, SW_SHOW);
3702 term_data_redraw(player_ptr, td);
3706 td->visible = FALSE;
3708 ShowWindow(td->w, SW_HIDE);
3715 case IDM_WINDOW_FONT_0:
3716 case IDM_WINDOW_FONT_1:
3717 case IDM_WINDOW_FONT_2:
3718 case IDM_WINDOW_FONT_3:
3719 case IDM_WINDOW_FONT_4:
3720 case IDM_WINDOW_FONT_5:
3721 case IDM_WINDOW_FONT_6:
3722 case IDM_WINDOW_FONT_7:
3724 i = wCmd - IDM_WINDOW_FONT_0;
3726 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3730 term_change_font(td);
3735 /* Window Z Position */
3736 case IDM_WINDOW_POS_1:
3737 case IDM_WINDOW_POS_2:
3738 case IDM_WINDOW_POS_3:
3739 case IDM_WINDOW_POS_4:
3740 case IDM_WINDOW_POS_5:
3741 case IDM_WINDOW_POS_6:
3742 case IDM_WINDOW_POS_7:
3744 i = wCmd - IDM_WINDOW_POS_0;
3746 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3750 if (!td->posfix && td->visible)
3753 term_window_pos(td, HWND_TOPMOST);
3758 term_window_pos(td, data[0].w);
3764 /* Bizarre Display */
3765 case IDM_WINDOW_BIZ_0:
3766 case IDM_WINDOW_BIZ_1:
3767 case IDM_WINDOW_BIZ_2:
3768 case IDM_WINDOW_BIZ_3:
3769 case IDM_WINDOW_BIZ_4:
3770 case IDM_WINDOW_BIZ_5:
3771 case IDM_WINDOW_BIZ_6:
3772 case IDM_WINDOW_BIZ_7:
3774 i = wCmd - IDM_WINDOW_BIZ_0;
3776 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3780 td->bizarre = !td->bizarre;
3784 term_window_resize(td);
3789 /* Increase Tile Width */
3790 case IDM_WINDOW_I_WID_0:
3791 case IDM_WINDOW_I_WID_1:
3792 case IDM_WINDOW_I_WID_2:
3793 case IDM_WINDOW_I_WID_3:
3794 case IDM_WINDOW_I_WID_4:
3795 case IDM_WINDOW_I_WID_5:
3796 case IDM_WINDOW_I_WID_6:
3797 case IDM_WINDOW_I_WID_7:
3799 i = wCmd - IDM_WINDOW_I_WID_0;
3801 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3809 term_window_resize(td);
3814 /* Decrease Tile Height */
3815 case IDM_WINDOW_D_WID_0:
3816 case IDM_WINDOW_D_WID_1:
3817 case IDM_WINDOW_D_WID_2:
3818 case IDM_WINDOW_D_WID_3:
3819 case IDM_WINDOW_D_WID_4:
3820 case IDM_WINDOW_D_WID_5:
3821 case IDM_WINDOW_D_WID_6:
3822 case IDM_WINDOW_D_WID_7:
3824 i = wCmd - IDM_WINDOW_D_WID_0;
3826 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3834 term_window_resize(td);
3839 /* Increase Tile Height */
3840 case IDM_WINDOW_I_HGT_0:
3841 case IDM_WINDOW_I_HGT_1:
3842 case IDM_WINDOW_I_HGT_2:
3843 case IDM_WINDOW_I_HGT_3:
3844 case IDM_WINDOW_I_HGT_4:
3845 case IDM_WINDOW_I_HGT_5:
3846 case IDM_WINDOW_I_HGT_6:
3847 case IDM_WINDOW_I_HGT_7:
3849 i = wCmd - IDM_WINDOW_I_HGT_0;
3851 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3859 term_window_resize(td);
3864 /* Decrease Tile Height */
3865 case IDM_WINDOW_D_HGT_0:
3866 case IDM_WINDOW_D_HGT_1:
3867 case IDM_WINDOW_D_HGT_2:
3868 case IDM_WINDOW_D_HGT_3:
3869 case IDM_WINDOW_D_HGT_4:
3870 case IDM_WINDOW_D_HGT_5:
3871 case IDM_WINDOW_D_HGT_6:
3872 case IDM_WINDOW_D_HGT_7:
3874 i = wCmd - IDM_WINDOW_D_HGT_0;
3876 if ((i < 0) || (i >= MAX_TERM_DATA)) break;
3884 term_window_resize(td);
3889 case IDM_OPTIONS_NO_GRAPHICS:
3893 plog("You may not do that right now.");
3897 if (arg_graphics != GRAPHICS_NONE)
3899 arg_graphics = GRAPHICS_NONE;
3900 term_xtra_win_react(player_ptr);
3901 Term_key_push(KTRL('R'));
3907 case IDM_OPTIONS_OLD_GRAPHICS:
3911 plog("You may not do that right now.");
3915 if (arg_graphics != GRAPHICS_ORIGINAL)
3917 arg_graphics = GRAPHICS_ORIGINAL;
3918 term_xtra_win_react(player_ptr);
3919 Term_key_push(KTRL('R'));
3925 case IDM_OPTIONS_NEW_GRAPHICS:
3929 plog("You may not do that right now.");
3933 if (arg_graphics != GRAPHICS_ADAM_BOLT)
3935 arg_graphics = GRAPHICS_ADAM_BOLT;
3936 term_xtra_win_react(player_ptr);
3937 Term_key_push(KTRL('R'));
3943 case IDM_OPTIONS_NEW2_GRAPHICS:
3947 plog("You may not do that right now.");
3951 if (arg_graphics != GRAPHICS_HENGBAND)
3953 arg_graphics = GRAPHICS_HENGBAND;
3954 term_xtra_win_react(player_ptr);
3955 Term_key_push(KTRL('R'));
3961 case IDM_OPTIONS_BIGTILE:
3966 plog("You may not do that right now.");
3970 arg_bigtile = !arg_bigtile;
3971 Term_activate(&td->t);
3972 Term_resize(td->cols, td->rows);
3973 InvalidateRect(td->w, NULL, TRUE);
3977 case IDM_OPTIONS_MUSIC:
3981 plog("You may not do that right now.");
3985 arg_music = !arg_music;
3986 term_xtra_win_react(player_ptr);
3987 Term_key_push(KTRL('R'));
3991 case IDM_OPTIONS_SOUND:
3995 plog("You may not do that right now.");
3999 arg_sound = !arg_sound;
4000 term_xtra_win_react(player_ptr);
4001 Term_key_push(KTRL('R'));
4006 case IDM_OPTIONS_BG:
4010 plog("You may not do that right now.");
4016 term_xtra_win_react(player_ptr);
4017 Term_key_push(KTRL('R'));
4022 case IDM_OPTIONS_OPEN_BG:
4026 plog("You may not do that right now.");
4031 memset(&ofn, 0, sizeof(ofn));
4032 ofn.lStructSize = sizeof(ofn);
4033 ofn.hwndOwner = data[0].w;
4034 ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
4035 ofn.nFilterIndex = 1;
4036 ofn.lpstrFile = bg_bitmap_file;
4037 ofn.nMaxFile = 1023;
4038 ofn.lpstrInitialDir = NULL;
4039 ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
4040 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
4042 if (GetOpenFileName(&ofn))
4044 /* Load 'savefile' */
4049 /* React to changes */
4050 term_xtra_win_react(player_ptr);
4052 /* Hack -- Force redraw */
4053 Term_key_push(KTRL('R'));
4058 case IDM_DUMP_SCREEN_HTML:
4060 static char buf[1024] = "";
4061 memset(&ofn, 0, sizeof(ofn));
4062 ofn.lStructSize = sizeof(ofn);
4063 ofn.hwndOwner = data[0].w;
4064 ofn.lpstrFilter = "HTML Files (*.html)\0*.html\0";
4065 ofn.nFilterIndex = 1;
4066 ofn.lpstrFile = buf;
4067 ofn.nMaxFile = 1023;
4068 ofn.lpstrDefExt = "html";
4069 ofn.lpstrInitialDir = NULL;
4070 ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
4071 ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
4073 if (GetSaveFileName(&ofn))
4075 do_cmd_save_screen_html_aux(buf, 0);
4082 case IDM_OPTIONS_SAVER:
4086 DestroyWindow(hwndSaver);
4091 /* Create a screen scaver window */
4092 hwndSaver = CreateWindowEx(WS_EX_TOPMOST, "WindowsScreenSaverClass",
4093 "Angband Screensaver",
4094 WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
4095 0, 0, GetSystemMetrics(SM_CXSCREEN),
4096 GetSystemMetrics(SM_CYSCREEN),
4097 NULL, NULL, hInstance, NULL);
4101 /* Push the window to the bottom */
4102 SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
4106 plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
4114 case IDM_OPTIONS_MAP:
4116 windows_map(player_ptr);
4120 case IDM_HELP_CONTENTS:
4124 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.chm");
4125 if (check_file(tmp))
4127 HtmlHelp(data[0].w, tmp, HH_DISPLAY_TOPIC, 0);
4131 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
4132 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
4135 #else /* HTML_HELP */
4138 path_build(tmp, sizeof(tmp), ANGBAND_DIR_XTRA_HELP, "zangband.hlp");
4139 if (check_file(tmp))
4141 sprintf(buf, "winhelp.exe %s", tmp);
4142 WinExec(buf, SW_NORMAL);
4146 plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
4147 plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
4151 #endif /* HTML_HELP */
4157 static bool process_keydown(WPARAM wParam, LPARAM lParam)
4164 /* Extract the modifiers */
4165 if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
4166 if (GetKeyState(VK_SHIFT) & 0x8000) ms = TRUE;
4167 if (GetKeyState(VK_MENU) & 0x8000) ma = TRUE;
4169 term_no_press = (ma) ? TRUE : FALSE;
4171 /* Handle "special" keys */
4172 if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]))
4174 bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
4175 bool numpad = FALSE;
4177 /* Begin the macro trigger */
4180 /* Send the modifiers */
4181 if (mc) Term_keypress('C');
4182 if (ms) Term_keypress('S');
4183 if (ma) Term_keypress('A');
4185 /* Extract "scan code" */
4186 i = LOBYTE(HIWORD(lParam));
4188 /* Introduce the scan code */
4191 /* Extended key bit */
4194 /* Numpad Enter and '/' are extended key */
4196 term_no_press = TRUE;
4197 case VK_RETURN: /* Enter */
4200 /* Other extended keys are on full keyboard */
4216 term_no_press = TRUE;
4220 case VK_PRIOR: /* Page Up */
4221 case VK_NEXT: /* Page Down */
4231 /* Special modifiers for keypad keys */
4232 if (numpad) Term_keypress('K');
4234 /* Encode the hexidecimal scan code */
4235 Term_keypress(hexsym[i / 16]);
4236 Term_keypress(hexsym[i % 16]);
4238 /* End the macro trigger */
4249 * todo WNDCLASSに影響があるのでplayer_type*の追加は保留
4252 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4253 WPARAM wParam, LPARAM lParam);
4254 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
4255 WPARAM wParam, LPARAM lParam)
4256 #else /* __MWERKS__ */
4257 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
4258 #endif /* __MWERKS__ */
4266 /* Acquire proper "term_data" info */
4267 td = (term_data *)GetWindowLong(hWnd, 0);
4269 /* Handle message */
4274 SetWindowLong(hWnd, 0, (LONG)(my_td));
4281 mop.dwCallback = (DWORD)hWnd;
4286 case WM_GETMINMAXINFO:
4288 MINMAXINFO FAR *lpmmi;
4291 lpmmi = (MINMAXINFO FAR *)lParam;
4293 /* this message was sent before WM_NCCREATE */
4296 /* Minimum window size is 80x24 */
4297 rc.left = rc.top = 0;
4298 rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
4299 rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4302 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4304 /* Save minimum size */
4305 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4306 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4313 BeginPaint(hWnd, &ps);
4314 if (td) term_data_redraw(p_ptr, td);
4315 EndPaint(hWnd, &ps);
4316 ValidateRect(hWnd, NULL);
4323 if (wParam == MCI_NOTIFY_SUCCESSFUL)
4325 mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
4326 mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
4335 if (process_keydown(wParam, lParam))
4342 if (term_no_press) term_no_press = FALSE;
4343 else Term_keypress(wParam);
4347 case WM_LBUTTONDOWN:
4349 mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
4350 mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
4362 TERM_LEN dx = abs(oldx - mousex) + 1;
4363 TERM_LEN dy = abs(oldy - mousey) + 1;
4364 TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
4365 TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
4375 hGlobal = GlobalAlloc(GHND, sz + 1);
4376 if (hGlobal == NULL) return 0;
4377 lpStr = (LPSTR)GlobalLock(hGlobal);
4379 for (i = 0; i < dy; i++)
4383 char **scr = data[0].t.scr->c;
4385 C_MAKE(s, (dx + 1), char);
4386 strncpy(s, &scr[oy + i][ox], dx);
4390 if (iskanji(scr[oy + i][ox - 1])) s[0] = ' ';
4393 if (ox + dx < data[0].cols)
4395 if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
4398 for (j = 0; j < dx; j++)
4400 if (s[j] == 127) s[j] = '#';
4404 for (j = 0; j < dx; j++)
4406 *lpStr++ = data[0].t.scr->c[oy + i][ox + j];
4416 GlobalUnlock(hGlobal);
4417 if (OpenClipboard(hWnd) == 0)
4419 GlobalFree(hGlobal);
4423 SetClipboardData(CF_TEXT, hGlobal);
4436 int cx = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
4437 int cy = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
4442 dx = abs(oldx - mousex) + 1;
4443 dy = abs(oldy - mousey) + 1;
4444 ox = (oldx > mousex) ? mousex : oldx;
4445 oy = (oldy > mousey) ? mousey : oldy;
4446 term_inversed_area(hWnd, ox, oy, dx, dy);
4453 dx = abs(cx - mousex) + 1;
4454 dy = abs(cy - mousey) + 1;
4455 ox = (cx > mousex) ? mousex : cx;
4456 oy = (cy > mousey) ? mousey : cy;
4457 term_inversed_area(hWnd, ox, oy, dx, dy);
4473 if (game_in_progress && current_world_ptr->character_generated)
4477 plog(_("今は終了できません。", "You may not do that right now."));
4481 /* Hack -- Forget messages */
4484 forget_lite(p_ptr->current_floor_ptr);
4485 forget_view(p_ptr->current_floor_ptr);
4486 clear_mon_lite(p_ptr->current_floor_ptr);
4490 /* do_cmd_save_game(FALSE); */
4491 #else /* ZANGBAND */
4492 /* do_cmd_save_game(); */
4493 #endif /* ZANGBAND */
4494 Term_key_push(SPECIAL_KEY_QUIT);
4501 case WM_QUERYENDSESSION:
4503 if (game_in_progress && current_world_ptr->character_generated)
4505 /* Hack -- Forget messages */
4508 /* Mega-Hack -- Delay death */
4509 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
4510 exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
4512 /* Hardcode panic save */
4513 p_ptr->panic_save = 1;
4515 /* Forbid suspend */
4516 signals_ignore_tstp();
4518 /* Indicate panic save */
4519 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
4522 (void)save_player(p_ptr);
4536 process_menus(p_ptr, LOWORD(wParam));
4542 /* this message was sent before WM_NCCREATE */
4545 /* it was sent from inside CreateWindowEx */
4546 if (!td->w) return 1;
4548 /* was sent from WM_SIZE */
4549 if (td->size_hack) return 1;
4553 case SIZE_MINIMIZED:
4555 /* Hide sub-windows */
4556 for (i = 1; i < MAX_TERM_DATA; i++)
4558 if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
4563 case SIZE_MAXIMIZED:
4570 TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4571 TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4574 if ((td->cols != cols) || (td->rows != rows))
4576 /* Save the new size */
4580 if (!IsZoomed(td->w) && !IsIconic(td->w))
4582 normsize.x = td->cols;
4583 normsize.y = td->rows;
4587 Term_activate(&td->t);
4589 /* Resize the term */
4590 Term_resize(td->cols, td->rows);
4593 InvalidateRect(td->w, NULL, TRUE);
4596 td->size_hack = TRUE;
4598 /* Show sub-windows */
4599 for (i = 1; i < MAX_TERM_DATA; i++)
4601 if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
4604 td->size_hack = FALSE;
4612 case WM_PALETTECHANGED:
4614 /* Ignore if palette change caused by itself */
4615 if ((HWND)wParam == hWnd) return 0;
4617 /* Fall through... */
4620 case WM_QUERYNEWPALETTE:
4622 if (!paletted) return 0;
4626 SelectPalette(hdc, hPal, FALSE);
4628 i = RealizePalette(hdc);
4630 /* if any palette entries changed, repaint the window. */
4631 if (i) InvalidateRect(hWnd, NULL, TRUE);
4633 ReleaseDC(hWnd, hdc);
4640 if (wParam && !HIWORD(lParam))
4642 /* Do something to sub-windows */
4643 for (i = 1; i < MAX_TERM_DATA; i++)
4645 if (!data[i].posfix) term_window_pos(&data[i], hWnd);
4648 /* Focus on main window */
4657 case WM_ACTIVATEAPP:
4659 if (IsIconic(td->w)) break;
4661 for (i = 1; i < MAX_TERM_DATA; i++)
4663 if (data[i].visible)
4667 ShowWindow(data[i].w, SW_SHOW);
4671 ShowWindow(data[i].w, SW_HIDE);
4678 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4683 * todo WNDCLASSに影響があるのでplayer_type*の追加は保留
4686 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4687 WPARAM wParam, LPARAM lParam);
4688 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4689 WPARAM wParam, LPARAM lParam)
4690 #else /* __MWERKS__ */
4691 LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
4692 WPARAM wParam, LPARAM lParam)
4693 #endif /* __MWERKS__ */
4701 /* Acquire proper "term_data" info */
4702 td = (term_data *)GetWindowLong(hWnd, 0);
4704 /* Process message */
4709 SetWindowLong(hWnd, 0, (LONG)(my_td));
4718 case WM_GETMINMAXINFO:
4720 MINMAXINFO FAR *lpmmi;
4723 lpmmi = (MINMAXINFO FAR *)lParam;
4725 /* this message was sent before WM_NCCREATE */
4728 /* Minimum window size is 80x24 */
4729 rc.left = rc.top = 0;
4730 rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
4731 rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
4734 AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
4736 /* Save minimum size */
4737 lpmmi->ptMinTrackSize.x = rc.right - rc.left;
4738 lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
4748 /* this message was sent before WM_NCCREATE */
4751 /* it was sent from inside CreateWindowEx */
4752 if (!td->w) return 1;
4754 /* was sent from inside WM_SIZE */
4755 if (td->size_hack) return 1;
4757 td->size_hack = TRUE;
4759 cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
4760 rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
4763 if ((td->cols != cols) || (td->rows != rows))
4766 term *old_term = Term;
4768 /* Save the new size */
4773 Term_activate(&td->t);
4775 /* Resize the term */
4776 Term_resize(td->cols, td->rows);
4779 Term_activate(old_term);
4782 InvalidateRect(td->w, NULL, TRUE);
4784 /* HACK - Redraw all windows */
4785 p_ptr->window = 0xFFFFFFFF;
4786 handle_stuff(p_ptr);
4789 td->size_hack = FALSE;
4796 BeginPaint(hWnd, &ps);
4797 if (td) term_data_redraw(p_ptr, td);
4798 EndPaint(hWnd, &ps);
4805 if (process_keydown(wParam, lParam))
4812 if (term_no_press) term_no_press = FALSE;
4813 else Term_keypress(wParam);
4817 case WM_PALETTECHANGED:
4819 /* ignore if palette change caused by itself */
4820 if ((HWND)wParam == hWnd) return FALSE;
4821 /* otherwise, fall through!!! */
4824 case WM_QUERYNEWPALETTE:
4826 if (!paletted) return 0;
4828 SelectPalette(hdc, hPal, FALSE);
4829 i = RealizePalette(hdc);
4830 /* if any palette entries changed, repaint the window. */
4831 if (i) InvalidateRect(hWnd, NULL, TRUE);
4832 ReleaseDC(hWnd, hdc);
4836 case WM_NCLBUTTONDOWN:
4840 if (wParam == HTCLOSE) wParam = HTSYSMENU;
4841 #endif /* HTCLOSE */
4843 if (wParam == HTSYSMENU)
4847 td->visible = FALSE;
4848 ShowWindow(td->w, SW_HIDE);
4858 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4864 #define MOUSE_SENS 40
4867 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4868 WPARAM wParam, LPARAM lParam);
4869 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4870 WPARAM wParam, LPARAM lParam)
4871 #else /* __MWERKS__ */
4872 LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
4873 WPARAM wParam, LPARAM lParam)
4874 #endif /* __MWERKS__ */
4876 static int iMouse = 0;
4877 static WORD xMouse = 0;
4878 static WORD yMouse = 0;
4897 case WM_LBUTTONDOWN:
4898 case WM_MBUTTONDOWN:
4899 case WM_RBUTTONDOWN:
4902 SendMessage(hWnd, WM_CLOSE, 0, 0);
4910 dx = LOWORD(lParam) - xMouse;
4911 dy = HIWORD(lParam) - yMouse;
4913 if (dx < 0) dx = -dx;
4914 if (dy < 0) dy = -dy;
4916 if ((dx > MOUSE_SENS) || (dy > MOUSE_SENS))
4918 SendMessage(hWnd, WM_CLOSE, 0, 0);
4922 /* Save last location */
4924 xMouse = LOWORD(lParam);
4925 yMouse = HIWORD(lParam);
4932 DestroyWindow(hwndSaver);
4938 return DefWindowProc(hWnd, uMsg, wParam, lParam);
4941 #endif /* USE_SAVER */
4947 /*** Temporary Hooks ***/
4951 * Display warning message (see "z-util.c")
4953 static void hack_plog(concptr str)
4955 /* Give a warning */
4959 MessageBox(NULL, str, "警告!",
4960 MB_ICONEXCLAMATION | MB_OK);
4962 MessageBox(NULL, str, "Warning",
4963 MB_ICONEXCLAMATION | MB_OK);
4971 * Display error message and quit (see "z-util.c")
4973 static void hack_quit(concptr str)
4975 /* Give a warning */
4979 MessageBox(NULL, str, "エラー!",
4980 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
4982 MessageBox(NULL, str, "Error",
4983 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
4988 /* Unregister the classes */
4989 UnregisterClass(AppName, hInstance);
4991 /* Destroy the icon */
4992 if (hIcon) DestroyIcon(hIcon);
4999 /*** Various hooks ***/
5003 * Display warning message (see "z-util.c")
5005 static void hook_plog(concptr str)
5011 MessageBox(data[0].w, str, "警告!",
5012 MB_ICONEXCLAMATION | MB_OK);
5014 MessageBox(data[0].w, str, "Warning",
5015 MB_ICONEXCLAMATION | MB_OK);
5023 * Display error message and quit (see "z-util.c")
5025 static void hook_quit(concptr str)
5030 /* Give a warning */
5034 MessageBox(data[0].w, str, "エラー!",
5035 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5037 MessageBox(data[0].w, str, "Error",
5038 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5044 /* Save the preferences */
5047 /* Destroy all windows */
5048 for (i = MAX_TERM_DATA - 1; i >= 0; --i)
5050 term_force_font(&data[i], NULL);
5051 if (data[i].font_want) string_free(data[i].font_want);
5052 if (data[i].w) DestroyWindow(data[i].w);
5056 /* Free the bitmap stuff */
5058 if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
5059 if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
5061 if (infMask.hPalette) DeleteObject(infMask.hPalette);
5062 if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
5064 #endif /* USE_GRAPHICS */
5066 /*** Free some other stuff ***/
5068 DeleteObject(hbrYellow);
5073 if (hPal) DeleteObject(hPal);
5075 UnregisterClass(AppName, hInstance);
5077 if (hIcon) DestroyIcon(hIcon);
5084 /*** Initialize ***/
5090 static void init_stuff(void)
5097 /* Get program name with full path */
5098 GetModuleFileName(hInstance, path, 512);
5100 /* Save the "program name" */
5103 /* Get the name of the "*.ini" file */
5104 strcpy(path + strlen(path) - 4, ".INI");
5106 /* Save the the name of the ini-file */
5107 ini_file = string_make(path);
5109 /* Analyze the path */
5115 if (path[i] == '\\')
5122 /* Add "lib" to the path */
5123 strcpy(path + i + 1, "lib\\");
5125 /* Validate the path */
5126 validate_dir(path, TRUE);
5128 /* Init the file paths */
5129 init_file_paths(path);
5131 /* Hack -- Validate the paths */
5132 validate_dir(ANGBAND_DIR_APEX, FALSE);
5133 validate_dir(ANGBAND_DIR_BONE, FALSE);
5135 /* Allow missing 'edit' directory */
5136 if (!check_dir(ANGBAND_DIR_EDIT))
5138 /* Must have 'data'! */
5139 validate_dir(ANGBAND_DIR_DATA, TRUE);
5143 /* Don't need 'data' */
5144 validate_dir(ANGBAND_DIR_DATA, FALSE);
5147 validate_dir(ANGBAND_DIR_FILE, TRUE);
5148 validate_dir(ANGBAND_DIR_HELP, FALSE);
5149 validate_dir(ANGBAND_DIR_INFO, FALSE);
5150 validate_dir(ANGBAND_DIR_PREF, TRUE);
5151 validate_dir(ANGBAND_DIR_SAVE, FALSE);
5152 validate_dir(ANGBAND_DIR_USER, TRUE);
5153 validate_dir(ANGBAND_DIR_XTRA, TRUE);
5154 path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
5156 /* Hack -- Validate the "news.txt" file */
5157 validate_file(path);
5161 /* Build the "graf" path */
5162 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
5164 /* Allocate the path */
5165 ANGBAND_DIR_XTRA_GRAF = string_make(path);
5167 /* Validate the "graf" directory */
5168 validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
5170 #endif /* USE_GRAPHICS */
5175 /* Build the "sound" path */
5176 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
5178 /* Allocate the path */
5179 ANGBAND_DIR_XTRA_SOUND = string_make(path);
5181 /* Validate the "sound" directory */
5182 validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
5184 #endif /* USE_SOUND */
5188 /* Build the "music" path */
5189 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
5191 /* Allocate the path */
5192 ANGBAND_DIR_XTRA_MUSIC = string_make(path);
5194 /* Validate the "music" directory */
5195 validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
5197 #endif /* USE_MUSIC */
5199 /* Build the "help" path */
5200 path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
5202 /* Allocate the path */
5203 ANGBAND_DIR_XTRA_HELP = string_make(path);
5205 /* Validate the "help" directory */
5206 /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
5210 * @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
5212 static bool is_already_running(void)
5214 bool result = FALSE;
5217 hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
5218 if (GetLastError() == ERROR_ALREADY_EXISTS)
5227 * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
5229 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
5230 LPSTR lpCmdLine, int nCmdShow)
5238 setlocale(LC_ALL, "ja_JP.utf8");
5247 /* Prevent multiple run */
5248 if (is_already_running())
5251 _("変愚蛮怒はすでに起動しています。", "Hengband is already running."),
5253 MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
5257 if (hPrevInst == NULL)
5259 wc.style = CS_CLASSDC;
5260 wc.lpfnWndProc = AngbandWndProc;
5262 wc.cbWndExtra = 4; /* one long pointer to term_data */
5263 wc.hInstance = hInst;
5264 wc.hIcon = hIcon = LoadIcon(hInst, AppName);
5265 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
5266 wc.hbrBackground = GetStockObject(BLACK_BRUSH);
5267 wc.lpszMenuName = AppName;
5268 wc.lpszClassName = AppName;
5270 if (!RegisterClass(&wc)) exit(1);
5272 wc.lpfnWndProc = AngbandListProc;
5273 wc.lpszMenuName = NULL;
5274 wc.lpszClassName = AngList;
5276 if (!RegisterClass(&wc)) exit(2);
5280 wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
5281 wc.lpfnWndProc = AngbandSaverProc;
5283 wc.lpszMenuName = NULL;
5284 wc.lpszClassName = "WindowsScreenSaverClass";
5286 if (!RegisterClass(&wc)) exit(3);
5292 /* Temporary hooks */
5293 plog_aux = hack_plog;
5294 quit_aux = hack_quit;
5295 core_aux = hack_quit;
5297 /* Prepare the filepaths */
5300 /* Initialize the keypress analyzer */
5301 for (i = 0; special_key_list[i]; ++i)
5303 special_key[special_key_list[i]] = TRUE;
5305 /* Initialize the keypress analyzer */
5306 for (i = 0; ignore_key_list[i]; ++i)
5308 ignore_key[ignore_key_list[i]] = TRUE;
5311 /* Determine if display is 16/256/true color */
5313 colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
5314 paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
5315 ReleaseDC(NULL, hdc);
5317 /* Initialize the colors */
5318 for (i = 0; i < 256; i++)
5322 /* Extract desired values */
5323 rv = angband_color_table[i][1];
5324 gv = angband_color_table[i][2];
5325 bv = angband_color_table[i][3];
5327 /* Extract the "complex" code */
5328 win_clr[i] = PALETTERGB(rv, gv, bv);
5330 /* Save the "simple" code */
5331 angband_color_table[i][0] = win_pal[i];
5334 /* Prepare the windows */
5340 /* Activate hooks */
5341 plog_aux = hook_plog;
5342 quit_aux = hook_quit;
5343 core_aux = hook_quit;
5345 /* Set the system suffix */
5346 ANGBAND_SYS = "win";
5348 /* Set the keyboard suffix */
5349 if (7 != GetKeyboardType(0))
5350 ANGBAND_KEYBOARD = "0";
5353 /* Japanese keyboard */
5354 switch (GetKeyboardType(1))
5356 case 0x0D01: case 0x0D02:
5357 case 0x0D03: case 0x0D04:
5358 case 0x0D05: case 0x0D06:
5360 ANGBAND_KEYBOARD = "NEC98";
5364 ANGBAND_KEYBOARD = "JAPAN";
5368 /* Catch nasty signals */
5371 Term_activate(term_screen);
5372 init_angband(p_ptr);
5374 /* We are now initialized */
5377 if (lpCmdLine[0] == '-') {
5378 switch (lpCmdLine[1])
5383 if (!lpCmdLine[2]) break;
5384 chuukei_server = TRUE;
5385 if (connect_chuukei_server(&lpCmdLine[2]) < 0) {
5386 msg_print("connect fail");
5389 msg_print("connect");
5397 if (!lpCmdLine[2]) break;
5398 chuukei_client = TRUE;
5399 connect_chuukei_server(&lpCmdLine[2]);
5400 play_game(player_ptr, FALSE);
5407 if (!lpCmdLine[2]) break;
5408 prepare_browse_movie(&lpCmdLine[2]);
5409 play_game(player_ptr, FALSE);
5418 /* Did the user double click on a save file? */
5419 if (!chuukei_server) check_for_save_file(lpCmdLine);
5421 /* Did the user double click on a save file? */
5422 check_for_save_file(p_ptr, lpCmdLine);
5425 /* Prompt the user */
5426 prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
5430 /* Process messages forever */
5431 while (GetMessage(&msg, NULL, 0, 0))
5433 TranslateMessage(&msg);
5434 DispatchMessage(&msg);
5441 #endif /* WINDOWS */