-/* File: main-win.c */\r
-\r
-/*\r
- * Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others\r
- *\r
- * This software may be copied and distributed for educational, research,\r
- * and not for profit purposes provided that this copyright and statement\r
- * are included in all such copies.\r
- */\r
-\r
-\r
-/*\r
- * This file helps Angband work with Windows computers.\r
- *\r
- * To use this file, use an appropriate "Makefile" or "Project File",\r
- * make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and\r
- * make sure to obtain various extra files as described below.\r
- *\r
- * The official compilation uses the CodeWarrior Pro compiler, which\r
- * includes a special project file and precompilable header file.\r
- *\r
- *\r
- * See also "main-dos.c" and "main-ibm.c".\r
- *\r
- *\r
- * The "lib/user/pref-win.prf" file contains keymaps, macro definitions,\r
- * and/or color redefinitions.\r
- *\r
- * The "lib/user/font-win.prf" contains attr/char mappings for use with the\r
- * normal "lib/xtra/font/*.fon" font files.\r
- *\r
- * The "lib/user/graf-win.prf" contains attr/char mappings for use with the\r
- * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu\r
- * item.\r
- *\r
- *\r
- * Compiling this file, and using the resulting executable, requires\r
- * several extra files not distributed with the standard Angband code.\r
- * If "USE_GRAPHICS" is defined, then "readdib.h" and "readdib.c" must\r
- * be placed into "src/", and the "8X8.BMP" bitmap file must be placed\r
- * into "lib/xtra/graf". In any case, some "*.fon" files (including\r
- * "8X13.FON" if nothing else) must be placed into "lib/xtra/font/".\r
- * If "USE_SOUND" is defined, then some special library (for example,\r
- * "winmm.lib") may need to be linked in, and desired "*.WAV" sound\r
- * files must be placed into "lib/xtra/sound/". All of these extra\r
- * files can be found in the "ext-win" archive.\r
- *\r
- *\r
- * The "Term_xtra_win_clear()" function should probably do a low-level\r
- * clear of the current window, and redraw the borders and other things,\r
- * if only for efficiency. XXX XXX XXX\r
- *\r
- * A simpler method is needed for selecting the "tile size" for windows.\r
- * XXX XXX XXX\r
- *\r
- * The various "warning" messages assume the existance of the "screen.w"\r
- * window, I think, and only a few calls actually check for its existance,\r
- * this may be okay since "NULL" means "on top of all windows". (?) The\r
- * user must never be allowed to "hide" the main window, or the "menubar"\r
- * will disappear. XXX XXX XXX\r
- *\r
- * Special "Windows Help Files" can be placed into "lib/xtra/help/" for\r
- * use with the "winhelp.exe" program. These files *may* be available\r
- * at the ftp site somewhere, but I have not seen them. XXX XXX XXX\r
- *\r
- *\r
- * Initial framework (and most code) by Ben Harrison (benh@phial.com).\r
- *\r
- * Original code by Skirmantas Kligys (kligys@scf.usc.edu).\r
- *\r
- * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),\r
- * and Chris R. Martin (crm7479@tam2000.tamu.edu).\r
- */\r
+/*!\r
+* @file main-win.c\r
+* @brief Windows版固有実装(メインエントリポイント含む)\r
+* @date 2018/03/16\r
+* @author Hengband Team\r
+* @detail\r
+*\r
+* <h3>概要</h3>\r
+* Windows98かその前後の頃を起点としたAPI実装。\r
+* 各種のゲームエンジンは無論、\r
+* DirectXといった昨今描画に標準的となったライブラリも用いていない。\r
+* タイルの描画処理などについては、現在動作の詳細を検証中。\r
+*\r
+* <h3>フォーク元の概要</h3>\r
+* <p>\r
+* Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others\r
+*\r
+* This software may be copied and distributed for educational, research,\r
+* and not for profit purposes provided that this copyright and statement\r
+* are included in all such copies.\r
+* </p>\r
+* <p>\r
+* This file helps Angband work with Windows computers.\r
+*\r
+* To use this file, use an appropriate "Makefile" or "Project File",\r
+* make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and\r
+* make sure to obtain various extra files as described below.\r
+*\r
+* The official compilation uses the CodeWarrior Pro compiler, which\r
+* includes a special project file and precompilable header file.\r
+* </p>\r
+*\r
+* <p>\r
+* <del>See also "main-dos.c" and "main-ibm.c".</del>\r
+* </p>\r
+*\r
+* <p>\r
+* The "lib/user/pref-win.prf" file contains keymaps, macro definitions,\r
+* and/or color redefinitions.\r
+* </p>\r
+*\r
+* <p>\r
+* The "lib/user/font-win.prf" contains attr/char mappings for use with the\r
+* normal "lib/xtra/font/*.fon" font files.\r
+* </p>\r
+*\r
+* <p>\r
+* The "lib/user/graf-win.prf" contains attr/char mappings for use with the\r
+* special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu\r
+* item.\r
+* </p>\r
+*\r
+* <p>\r
+* Compiling this file, and using the resulting executable, requires\r
+* several extra files not distributed with the standard Angband code.\r
+* If "USE_GRAPHICS" is defined, then "readdib.h" and "readdib.c" must\r
+* be placed into "src/", and the "8X8.BMP" bitmap file must be placed\r
+* into "lib/xtra/graf". In any case, some "*.fon" files (including\r
+* "8X13.FON" if nothing else) must be placed into "lib/xtra/font/".\r
+* If "USE_SOUND" is defined, then some special library (for example,\r
+* "winmm.lib") may need to be linked in, and desired "*.WAV" sound\r
+* files must be placed into "lib/xtra/sound/". All of these extra\r
+* files can be found in the "ext-win" archive.\r
+* </p>\r
+*\r
+* <p>\r
+* The "Term_xtra_win_clear()" function should probably do a low-level\r
+* clear of the current window, and redraw the borders and other things,\r
+* if only for efficiency. XXX XXX XXX\r
+* </p>\r
+*\r
+* <p>\r
+* A simpler method is needed for selecting the "tile size" for windows.\r
+* XXX XXX XXX\r
+* </p>\r
+*\r
+* <p>\r
+* The various "warning" messages assume the existance of the "screen.w"\r
+* window, I think, and only a few calls actually check for its existance,\r
+* this may be okay since "NULL" means "on top of all windows". (?) The\r
+* user must never be allowed to "hide" the main window, or the "menubar"\r
+* will disappear. XXX XXX XXX\r
+* </p>\r
+*\r
+* <p>\r
+* Special "Windows Help Files" can be placed into "lib/xtra/help/" for\r
+* use with the "winhelp.exe" program. These files *may* be available\r
+* at the ftp site somewhere, but I have not seen them. XXX XXX XXX\r
+* </p>\r
+*\r
+* <p>\r
+* Initial framework (and most code) by Ben Harrison (benh@phial.com).\r
+*\r
+* Original code by Skirmantas Kligys (kligys@scf.usc.edu).\r
+*\r
+* Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),\r
+* and Chris R. Martin (crm7479@tam2000.tamu.edu).\r
+* </p>\r
+*/\r
\r
#include "angband.h"\r
\r
*/\r
typedef struct _term_data term_data;\r
\r
-/*\r
- * Extra "term" data\r
- *\r
+/*!\r
+ * @struct _term_data\r
+ * @brief ターム情報構造体 / Extra "term" data\r
+ * @details\r
+ * <p>\r
+ * pos_x / pos_y は各タームの左上点座標を指す。\r
+ * </p>\r
+ * <p>\r
+ * tile_wid / tile_hgt は[ウィンドウ]メニューのタイルの幅/高さを~を\r
+ * 1ドットずつ調整するステータスを指す。\r
+ * また、フォントを変更すると都度自動調整される。\r
+ * </p>\r
+ * <p>\r
* Note the use of "font_want" for the names of the font file requested by\r
* the user, and the use of "font_file" for the currently active font file.\r
*\r
* The "font_file" is uppercased, and takes the form "8X13.FON", while\r
* "font_want" can be in almost any form as long as it could be construed\r
* as attempting to represent the name of a font.\r
+ * </p>\r
*/\r
struct _term_data\r
{\r
\r
uint keys;\r
\r
- uint rows; /* int -> uint */\r
- uint cols;\r
+ TERM_POSITION rows; /* int -> uint */\r
+ TERM_POSITION cols;\r
\r
- uint pos_x;\r
- uint pos_y;\r
+ uint pos_x; //!< タームの左上X座標\r
+ uint pos_y; //!< タームの左上Y座標\r
uint size_wid;\r
uint size_hgt;\r
uint size_ow1;\r
\r
HFONT font_id;\r
\r
- uint font_wid;\r
- uint font_hgt;\r
+ int font_wid; //!< フォント横幅\r
+ int font_hgt; //!< フォント縦幅\r
\r
- uint tile_wid;\r
- uint tile_hgt;\r
+ int tile_wid; //!< タイル横幅\r
+ int tile_hgt; //!< タイル縦幅\r
\r
uint map_tile_wid;\r
uint map_tile_hgt;\r
\r
/* bg */\r
static HBITMAP hBG = NULL;\r
-static int use_bg = 0;\r
-static char bg_bitmap_file[1024] = "bg.bmp";\r
+static int use_bg = 0; //!< 背景使用フラグ、1なら私用。\r
+static char bg_bitmap_file[1024] = "bg.bmp"; //!< 現在の背景ビットマップファイル名。\r
\r
#ifdef USE_SAVER\r
\r
\r
#ifdef USE_GRAPHICS\r
\r
-/*\r
+/*!\r
+ * 現在使用中のタイルID(0ならば未使用)\r
* Flag set once "graphics" has been initialized\r
*/\r
-static bool can_use_graphics = FALSE;\r
+static byte_hack current_graphics_mode = 0;\r
\r
/*\r
* The global bitmap\r
*/\r
static bool mouse_down = FALSE;\r
static bool paint_rect = FALSE;\r
-static int mousex = 0, mousey = 0;\r
-static int oldx, oldy;\r
+static TERM_POSITION mousex = 0, mousey = 0;\r
+static TERM_POSITION oldx, oldy;\r
\r
\r
-/*\r
- * The "simple" color values\r
- *\r
+/*!\r
+ * @brief The "simple" color values\r
+ * @details\r
* See "main-ibm.c" for original table information\r
- *\r
* The entries below are taken from the "color bits" defined above.\r
- *\r
* Note that many of the choices below suck, but so do crappy monitors.\r
*/\r
static BYTE win_pal[256] =\r
};\r
#endif\r
\r
+\r
+/* Function prototype */\r
+\r
+static bool is_already_running(void);\r
+\r
+\r
/* bg */\r
static void delete_bg(void)\r
{\r
/* Window size */\r
if (i == 0)\r
{\r
- win_maximized = GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file);\r
+ win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);\r
}\r
\r
/* Window position */\r
/* Window Z position */\r
if (i > 0)\r
{\r
- td->posfix = GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file);\r
+ td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);\r
}\r
}\r
\r
int i;\r
\r
/* Extract the "arg_graphics" flag */\r
- arg_graphics = GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);\r
+ arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);\r
\r
/* Extract the "arg_bigtile" flag */\r
- arg_bigtile = GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file);\r
+ arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);\r
use_bigtile = arg_bigtile;\r
\r
/* Extract the "arg_sound" flag */\r
*/\r
static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)\r
{\r
- int k = 0;\r
-\r
+ s16b k = 0;\r
char *s = buf;\r
\r
-\r
/* Process */\r
while (k < num)\r
{\r
}\r
}\r
\r
- for (i = 0; i < 1000; i++) /*!< @todo クエスト最大数指定 */\r
+ for (i = 0; i < max_q_idx; i++)\r
{\r
sprintf(key, "quest%03d", i);\r
GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);\r
\r
\r
#ifdef USE_GRAPHICS\r
-/*\r
- * Initialize graphics\r
+/*!\r
+ * @brief グラフィクスを初期化する / Initialize graphics\r
+ * @details\r
+ * <ul>\r
+ * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>\r
+ * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>\r
+ * </ul>\r
*/\r
static bool init_graphics(void)\r
{\r
/* Initialize once */\r
- /* if (can_use_graphics != arg_graphics) */\r
- {\r
- char buf[1024];\r
- int wid, hgt, twid, thgt, ox, oy;\r
- cptr name;\r
+ char buf[1024];\r
+ BYTE wid, hgt, twid, thgt, ox, oy;\r
+ cptr name;\r
\r
- if (arg_graphics == GRAPHICS_ADAM_BOLT)\r
- {\r
- wid = 16;\r
- hgt = 16;\r
- twid = 16;\r
- thgt = 16;\r
- ox = 0;\r
- oy = 0;\r
- name = "16X16.BMP";\r
-\r
- ANGBAND_GRAF = "new";\r
- }\r
- else if (arg_graphics == GRAPHICS_HENGBAND)\r
- {\r
- /*! @todo redraw \r
- wid = 64;\r
- hgt = 64;\r
- twid = 32;\r
- thgt = 32;\r
- ox = -16;\r
- oy = -24;\r
- name = "64X64.BMP";\r
- */\r
-\r
- wid = 32;\r
- hgt = 32;\r
- twid = 32;\r
- thgt = 32;\r
- ox = 0;\r
- oy = 0;\r
- name = "32X32.BMP";\r
-\r
- ANGBAND_GRAF = "ne2";\r
- }\r
- else\r
- {\r
- wid = 8;\r
- hgt = 8;\r
- twid = 8;\r
- thgt = 8;\r
- ox = 0;\r
- oy = 0;\r
- name = "8X8.BMP";\r
- ANGBAND_GRAF = "old";\r
- }\r
+ if (arg_graphics == GRAPHICS_ADAM_BOLT)\r
+ {\r
+ wid = 16;\r
+ hgt = 16;\r
+ twid = 16;\r
+ thgt = 16;\r
+ ox = 0;\r
+ oy = 0;\r
+ name = "16X16.BMP";\r
+\r
+ ANGBAND_GRAF = "new";\r
+ }\r
+ else if (arg_graphics == GRAPHICS_HENGBAND)\r
+ {\r
+ /*! @todo redraw\r
+ wid = 64;\r
+ hgt = 64;\r
+ twid = 32;\r
+ thgt = 32;\r
+ ox = -16;\r
+ oy = -24;\r
+ name = "64X64.BMP";\r
+ */\r
+\r
+ wid = 32;\r
+ hgt = 32;\r
+ twid = 32;\r
+ thgt = 32;\r
+ ox = 0;\r
+ oy = 0;\r
+ name = "32X32.BMP";\r
+\r
+ ANGBAND_GRAF = "ne2";\r
+ }\r
+ else\r
+ {\r
+ wid = 8;\r
+ hgt = 8;\r
+ twid = 8;\r
+ thgt = 8;\r
+ ox = 0;\r
+ oy = 0;\r
+ name = "8X8.BMP";\r
+ ANGBAND_GRAF = "old";\r
+ }\r
\r
- /* Access the bitmap file */\r
- path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);\r
+ /* Access the bitmap file */\r
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);\r
\r
- /* Load the bitmap or quit */\r
- if (!ReadDIB(data[0].w, buf, &infGraph))\r
- {\r
- plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);\r
- return (FALSE);\r
- }\r
+ /* Load the bitmap or quit */\r
+ if (!ReadDIB(data[0].w, buf, &infGraph))\r
+ {\r
+ plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);\r
+ return (FALSE);\r
+ }\r
\r
- /* Save the new sizes */\r
- infGraph.CellWidth = wid;\r
- infGraph.CellHeight = hgt;\r
- infGraph.TileWidth = twid;\r
- infGraph.TileHeight = thgt;\r
- infGraph.OffsetX = ox;\r
- infGraph.OffsetY = oy;\r
+ /* Save the new sizes */\r
+ infGraph.CellWidth = wid;\r
+ infGraph.CellHeight = hgt;\r
+ infGraph.TileWidth = twid;\r
+ infGraph.TileHeight = thgt;\r
+ infGraph.OffsetX = ox;\r
+ infGraph.OffsetY = oy;\r
\r
- if (arg_graphics == GRAPHICS_ADAM_BOLT)\r
- {\r
- /* Access the mask file */\r
- path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");\r
+ if (arg_graphics == GRAPHICS_ADAM_BOLT)\r
+ {\r
+ /* Access the mask file */\r
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");\r
\r
- /* Load the bitmap or quit */\r
- if (!ReadDIB(data[0].w, buf, &infMask))\r
- {\r
- plog_fmt("Cannot read bitmap file '%s'", buf);\r
- return (FALSE);\r
- }\r
- }\r
- if (arg_graphics == GRAPHICS_HENGBAND)\r
+ /* Load the bitmap or quit */\r
+ if (!ReadDIB(data[0].w, buf, &infMask))\r
{\r
- /* Access the mask file */\r
- path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");\r
-\r
- /* Load the bitmap or quit */\r
- if (!ReadDIB(data[0].w, buf, &infMask))\r
- {\r
- plog_fmt("Cannot read bitmap file '%s'", buf);\r
- return (FALSE);\r
- }\r
+ plog_fmt("Cannot read bitmap file '%s'", buf);\r
+ return (FALSE);\r
}\r
+ }\r
+ if (arg_graphics == GRAPHICS_HENGBAND)\r
+ {\r
+ /* Access the mask file */\r
+ path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");\r
\r
- /* Activate a palette */\r
- if (!new_palette())\r
+ /* Load the bitmap or quit */\r
+ if (!ReadDIB(data[0].w, buf, &infMask))\r
{\r
- /* Free bitmap XXX XXX XXX */\r
-\r
- /* Oops */\r
- plog(_("パレットを実現できません!", "Cannot activate palette!"));\r
+ plog_fmt("Cannot read bitmap file '%s'", buf);\r
return (FALSE);\r
}\r
+ }\r
\r
- /* Graphics available */\r
- can_use_graphics = arg_graphics;\r
+ /* Activate a palette */\r
+ if (!new_palette())\r
+ {\r
+ /* Free bitmap XXX XXX XXX */\r
+\r
+ /* Oops */\r
+ plog(_("パレットを実現できません!", "Cannot activate palette!"));\r
+ return (FALSE);\r
}\r
\r
+ /* Graphics available */\r
+ current_graphics_mode = arg_graphics;\r
+\r
/* Result */\r
- return (can_use_graphics);\r
+ return (current_graphics_mode);\r
}\r
#endif /* USE_GRAPHICS */\r
\r
term_data *td = &data[i];\r
\r
/* Update resized windows */\r
- if ((td->cols != (uint)td->t.wid) || (td->rows != (uint)td->t.hgt))\r
+ if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))\r
{\r
/* Activate */\r
Term_activate(&td->t);\r
static void windows_map(void)\r
{\r
term_data *td = &data[0];\r
- byte a, c;\r
+ byte a;\r
+ char c;\r
int x, min_x, max_x;\r
int y, min_y, max_y;\r
\r
- byte ta, tc;\r
+ byte ta;\r
+ char tc;\r
\r
/* Only in graphics mode */\r
if (!use_graphics) return;\r
\r
case IDM_OPTIONS_BIGTILE:\r
{\r
- term_data *td = &data[0];\r
+ td = &data[0];\r
\r
/* Paranoia */\r
if (!inkey_flag)\r
{\r
HGLOBAL hGlobal;\r
LPSTR lpStr;\r
- int i, j, sz;\r
- int dx = abs(oldx - mousex) + 1;\r
- int dy = abs(oldy - mousey) + 1;\r
- int ox = (oldx > mousex) ? mousex : oldx;\r
- int oy = (oldy > mousey) ? mousey : oldy;\r
+ int j, sz;\r
+ TERM_POSITION dx = abs(oldx - mousex) + 1;\r
+ TERM_POSITION dy = abs(oldy - mousey) + 1;\r
+ TERM_POSITION ox = (oldx > mousex) ? mousex : oldx;\r
+ TERM_POSITION oy = (oldy > mousey) ? mousey : oldy;\r
\r
mouse_down = FALSE;\r
paint_rect = FALSE;\r
\r
case SIZE_RESTORED:\r
{\r
- uint cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;\r
- uint rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;\r
+ TERM_POSITION cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;\r
+ TERM_POSITION rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;\r
\r
/* New size */\r
if ((td->cols != cols) || (td->rows != rows))\r
\r
case WM_SIZE:\r
{\r
- uint cols;\r
- uint rows;\r
+ TERM_POSITION cols;\r
+ TERM_POSITION rows;\r
\r
/* this message was sent before WM_NCCREATE */\r
if (!td) return 1;\r
/* validate_dir(ANGBAND_DIR_XTRA_HELP); */\r
}\r
\r
-bool is_already_running()\r
+static bool is_already_running(void)\r
{\r
bool result = FALSE;\r
HANDLE hMutex;\r