*
* <p>
* The "lib/user/graf-win.prf" contains attr/char mappings for use with the
- * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
+ * special bitmap files in "lib/xtra/graf", which are activated by a menu
* item.
* </p>
*
#include "cmd-visual/cmd-draw.h"
#include "core/game-play.h"
#include "core/player-processor.h"
+#include "core/score-util.h"
#include "core/scores.h"
#include "core/special-internal-keys.h"
#include "core/stuff-handler.h"
#include "core/visuals-reseter.h"
+#include "core/window-redrawer.h"
#include "floor/floor-events.h"
#include "game-option/runtime-arguments.h"
#include "game-option/special-options.h"
#include "io/record-play-movie.h"
#include "io/signal-handlers.h"
#include "io/write-diary.h"
+#include "main-win/commandline-win.h"
#include "main-win/graphics-win.h"
#include "main-win/main-win-bg.h"
#include "main-win/main-win-file-utils.h"
#include "main-win/main-win-menuitem.h"
#include "main-win/main-win-music.h"
#include "main-win/main-win-sound.h"
+#include "main-win/main-win-term.h"
#include "main-win/main-win-utils.h"
#include "main/angband-initializer.h"
#include "main/sound-of-music.h"
#include "util/int-char-converter.h"
#include "util/string-processor.h"
#include "view/display-messages.h"
+#include "view/display-scores.h"
#include "wizard/spoiler-util.h"
#include "wizard/wizard-spoiler.h"
#include "world/world.h"
#include <cstdlib>
#include <locale>
+#include <string>
#include <commdlg.h>
#include <direct.h>
-/*!
- * @struct term_data
- * @brief ターム情報構造体 / Extra "term" data
- * @details
- * <p>
- * pos_x / pos_y は各タームの左上点座標を指す。
- * </p>
- * <p>
- * tile_wid / tile_hgt は[ウィンドウ]メニューのタイルの幅/高さを~を
- * 1ドットずつ調整するステータスを指す。
- * また、フォントを変更すると都度自動調整される。
- * </p>
- * <p>
- * Note the use of "font_want" for the names of the font file requested by
- * the user.
- * </p>
+/*
+ * Window names
*/
-typedef struct {
- term_type t;
- concptr s;
- HWND w;
- DWORD dwStyle;
- DWORD dwExStyle;
-
- uint keys;
- TERM_LEN rows; /* int -> uint */
- TERM_LEN cols;
-
- uint pos_x; //!< タームの左上X座標
- uint pos_y; //!< タームの左上Y座標
- uint size_wid;
- uint size_hgt;
- uint size_ow1;
- uint size_oh1;
- uint size_ow2;
- uint size_oh2;
-
- bool size_hack;
- bool xtra_hack;
- bool visible;
- concptr font_want;
- HFONT font_id;
- int font_wid; //!< フォント横幅
- int font_hgt; //!< フォント縦幅
- int tile_wid; //!< タイル横幅
- int tile_hgt; //!< タイル縦幅
-
- LOGFONT lf;
-
- bool posfix;
-} term_data;
+LPCWSTR win_term_name[] = { L"Hengband", L"Term-1", L"Term-2", L"Term-3", L"Term-4", L"Term-5", L"Term-6", L"Term-7" };
#define MAX_TERM_DATA 8 //!< Maximum number of windows
static term_data data[MAX_TERM_DATA]; //!< An array of term_data's
+static bool is_main_term(term_data *td)
+{
+ return (td == &data[0]);
+}
static term_data *my_td; //!< Hack -- global "window creation" pointer
POINT normsize; //!< Remember normal size of main window when maxmized
/*
* was main window maximized on previous playing
*/
-bool win_maximized = FALSE;
+bool win_maximized = false;
/*
* game in progress
*/
-bool game_in_progress = FALSE;
+bool game_in_progress = false;
+
+/*
+ * movie in progress
+ */
+bool movie_in_progress = false;
/*
* note when "open"/"new" become valid
*/
-bool initialized = FALSE;
+bool initialized = false;
/*
* Saved instance handle
#define DEFAULT_BG_FILENAME "bg.bmp"
char wallpaper_file[MAIN_WIN_MAX_PATH] = ""; //!< 壁紙ファイル名。
-/*!
- * 現在使用中のタイルID(0ならば未使用)
- * Flag set once "graphics" has been initialized
- */
-static byte current_graphics_mode = 0;
-
-/*
- * The global tile
- */
-static tile_info infGraph;
-
-/*
- * The global tile mask
- */
-static tile_info infMask;
-
/*
* Show sub-windows even when Hengband is not in focus
*/
-static bool keep_subwindows = TRUE;
+static bool keep_subwindows = true;
/*
* Full path to ANGBAND.INI
/*
* Name of application
*/
-static concptr AppName = "ANGBAND";
+static LPCWSTR AppName = L"ANGBAND";
/*
* Name of sub-window type
*/
-static concptr AngList = "AngList";
-
-/*
- * Directory names
- */
-static concptr ANGBAND_DIR_XTRA_GRAF;
+static LPCWSTR AngList = L"AngList";
/*
* The "complex" color values
/*
* Flag for macro trigger with dump ASCII
*/
-static bool term_no_press = FALSE;
+static bool term_no_press = false;
/*
* Copy and paste
*/
-static bool mouse_down = FALSE;
-static bool paint_rect = FALSE;
+static bool mouse_down = false;
+static bool paint_rect = false;
static TERM_LEN mousex = 0, mousey = 0;
static TERM_LEN oldx, oldy;
VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL, VK_LMENU, VK_RMENU, 0 /* End of List */
};
-/*
- * Validate a file
+/*!
+ * @brief Validate a file
*/
static void validate_file(concptr s)
{
quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
}
-/*
- * Validate a directory
+/*!
+ * @brief Validate a directory
*/
static void validate_dir(concptr s, bool vital)
{
}
}
-/*
- * Write the "prefs" for a single term
+/*!
+ * @brief Write the "prefs" for a single term
*/
static void save_prefs_aux(int i)
{
if (!td->w)
return;
- sprintf(sec_name, "Term-%d", i);
+ wsprintfA(sec_name, "Term-%d", i);
if (i > 0) {
strcpy(buf, td->visible ? "1" : "0");
- WritePrivateProfileString(sec_name, "Visible", buf, ini_file);
+ WritePrivateProfileStringA(sec_name, "Visible", buf, ini_file);
}
-#ifdef JP
- strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "MS ゴシック");
-#else
- strcpy(buf, td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : "Courier");
-#endif
-
- WritePrivateProfileString(sec_name, "Font", buf, ini_file);
+ auto pwchar = td->lf.lfFaceName[0] != '\0' ? td->lf.lfFaceName : _(L"MS ゴシック", L"Courier");
+ WritePrivateProfileStringA(sec_name, "Font", to_multibyte(pwchar).c_str(), ini_file);
- wsprintf(buf, "%d", td->lf.lfWidth);
- WritePrivateProfileString(sec_name, "FontWid", buf, ini_file);
- wsprintf(buf, "%d", td->lf.lfHeight);
- WritePrivateProfileString(sec_name, "FontHgt", buf, ini_file);
- wsprintf(buf, "%d", td->lf.lfWeight);
- WritePrivateProfileString(sec_name, "FontWgt", buf, ini_file);
+ wsprintfA(buf, "%d", td->lf.lfWidth);
+ WritePrivateProfileStringA(sec_name, "FontWid", buf, ini_file);
+ wsprintfA(buf, "%d", td->lf.lfHeight);
+ WritePrivateProfileStringA(sec_name, "FontHgt", buf, ini_file);
+ wsprintfA(buf, "%d", td->lf.lfWeight);
+ WritePrivateProfileStringA(sec_name, "FontWgt", buf, ini_file);
- wsprintf(buf, "%d", td->tile_wid);
- WritePrivateProfileString(sec_name, "TileWid", buf, ini_file);
+ wsprintfA(buf, "%d", td->tile_wid);
+ WritePrivateProfileStringA(sec_name, "TileWid", buf, ini_file);
- wsprintf(buf, "%d", td->tile_hgt);
- WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file);
+ wsprintfA(buf, "%d", td->tile_hgt);
+ WritePrivateProfileStringA(sec_name, "TileHgt", buf, ini_file);
WINDOWPLACEMENT lpwndpl;
lpwndpl.length = sizeof(WINDOWPLACEMENT);
RECT rc = lpwndpl.rcNormalPosition;
if (i == 0)
- wsprintf(buf, "%d", normsize.x);
+ wsprintfA(buf, "%d", normsize.x);
else
- wsprintf(buf, "%d", td->cols);
+ wsprintfA(buf, "%d", td->cols);
- WritePrivateProfileString(sec_name, "NumCols", buf, ini_file);
+ WritePrivateProfileStringA(sec_name, "NumCols", buf, ini_file);
if (i == 0)
- wsprintf(buf, "%d", normsize.y);
+ wsprintfA(buf, "%d", normsize.y);
else
- wsprintf(buf, "%d", td->rows);
+ wsprintfA(buf, "%d", td->rows);
- WritePrivateProfileString(sec_name, "NumRows", buf, ini_file);
+ WritePrivateProfileStringA(sec_name, "NumRows", buf, ini_file);
if (i == 0) {
strcpy(buf, IsZoomed(td->w) ? "1" : "0");
- WritePrivateProfileString(sec_name, "Maximized", buf, ini_file);
+ WritePrivateProfileStringA(sec_name, "Maximized", buf, ini_file);
}
GetWindowRect(td->w, &rc);
- wsprintf(buf, "%d", rc.left);
- WritePrivateProfileString(sec_name, "PositionX", buf, ini_file);
+ wsprintfA(buf, "%d", rc.left);
+ WritePrivateProfileStringA(sec_name, "PositionX", buf, ini_file);
- wsprintf(buf, "%d", rc.top);
- WritePrivateProfileString(sec_name, "PositionY", buf, ini_file);
+ wsprintfA(buf, "%d", rc.top);
+ WritePrivateProfileStringA(sec_name, "PositionY", buf, ini_file);
if (i > 0) {
strcpy(buf, td->posfix ? "1" : "0");
- WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file);
+ WritePrivateProfileStringA(sec_name, "PositionFix", buf, ini_file);
}
}
-/*
- * Write the "prefs"
+/*!
+ * @brief Write the "prefs"
* We assume that the windows have all been initialized
*/
static void save_prefs(void)
{
char buf[128];
- sprintf(buf, "%d", arg_graphics);
- WritePrivateProfileString("Angband", "Graphics", buf, ini_file);
+ wsprintfA(buf, "%d", arg_graphics);
+ WritePrivateProfileStringA("Angband", "Graphics", buf, ini_file);
strcpy(buf, arg_bigtile ? "1" : "0");
- WritePrivateProfileString("Angband", "Bigtile", buf, ini_file);
+ WritePrivateProfileStringA("Angband", "Bigtile", buf, ini_file);
strcpy(buf, arg_sound ? "1" : "0");
- WritePrivateProfileString("Angband", "Sound", buf, ini_file);
+ WritePrivateProfileStringA("Angband", "Sound", buf, ini_file);
strcpy(buf, arg_music ? "1" : "0");
- WritePrivateProfileString("Angband", "Music", buf, ini_file);
+ WritePrivateProfileStringA("Angband", "Music", buf, ini_file);
strcpy(buf, use_pause_music_inactive ? "1" : "0");
- WritePrivateProfileString("Angband", "MusicPauseInactive", buf, ini_file);
+ WritePrivateProfileStringA("Angband", "MusicPauseInactive", buf, ini_file);
- sprintf(buf, "%d", current_bg_mode);
- WritePrivateProfileString("Angband", "BackGround", buf, ini_file);
- WritePrivateProfileString("Angband", "BackGroundBitmap", wallpaper_file[0] != '\0' ? wallpaper_file : DEFAULT_BG_FILENAME, ini_file);
+ wsprintfA(buf, "%d", current_bg_mode);
+ WritePrivateProfileStringA("Angband", "BackGround", buf, ini_file);
+ WritePrivateProfileStringA("Angband", "BackGroundBitmap", wallpaper_file[0] != '\0' ? wallpaper_file : DEFAULT_BG_FILENAME, ini_file);
int path_length = strlen(ANGBAND_DIR) - 4; /* \libの4文字分を削除 */
char tmp[1024] = "";
if (n == 0) {
char relative_path[1024] = "";
snprintf(relative_path, sizeof(relative_path), ".\\%s", (savefile + path_length));
- WritePrivateProfileString("Angband", "SaveFile", relative_path, ini_file);
+ WritePrivateProfileStringA("Angband", "SaveFile", relative_path, ini_file);
} else {
- WritePrivateProfileString("Angband", "SaveFile", savefile, ini_file);
+ WritePrivateProfileStringA("Angband", "SaveFile", savefile, ini_file);
}
strcpy(buf, keep_subwindows ? "1" : "0");
- WritePrivateProfileString("Angband", "KeepSubwindows", buf, ini_file);
+ WritePrivateProfileStringA("Angband", "KeepSubwindows", buf, ini_file);
for (int i = 0; i < MAX_TERM_DATA; ++i) {
save_prefs_aux(i);
}
}
-/*
- * callback for EnumDisplayMonitors API
+/*!
+ * @brief callback for EnumDisplayMonitors API
*/
BOOL CALLBACK monitorenumproc([[maybe_unused]] HMONITOR hMon, [[maybe_unused]] HDC hdcMon, [[maybe_unused]] LPRECT lpMon, LPARAM dwDate)
{
bool *result = (bool *)dwDate;
*result = true;
- return FALSE;
+ return false;
}
-/*
- * Load the "prefs" for a single term
+/*!
+ * @brief Load the "prefs" for a single term
*/
static void load_prefs_aux(int i)
{
GAME_TEXT sec_name[128];
char tmp[1024];
- sprintf(sec_name, "Term-%d", i);
- sprintf(sec_name, "Term-%d", i);
+ wsprintfA(sec_name, "Term-%d", i);
if (i > 0) {
- td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0);
+ td->visible = (GetPrivateProfileIntA(sec_name, "Visible", td->visible, ini_file) != 0);
}
-#ifdef JP
- GetPrivateProfileString(sec_name, "Font", "MS ゴシック", tmp, 127, ini_file);
-#else
- GetPrivateProfileString(sec_name, "Font", "Courier", tmp, 127, ini_file);
-#endif
+ GetPrivateProfileStringA(sec_name, "Font", _("MS ゴシック", "Courier"), tmp, 127, ini_file);
td->font_want = string_make(tmp);
int hgt = 15;
int wid = 0;
- td->lf.lfWidth = GetPrivateProfileInt(sec_name, "FontWid", wid, ini_file);
- td->lf.lfHeight = GetPrivateProfileInt(sec_name, "FontHgt", hgt, ini_file);
- td->lf.lfWeight = GetPrivateProfileInt(sec_name, "FontWgt", 0, ini_file);
+ td->lf.lfWidth = GetPrivateProfileIntA(sec_name, "FontWid", wid, ini_file);
+ td->lf.lfHeight = GetPrivateProfileIntA(sec_name, "FontHgt", hgt, ini_file);
+ td->lf.lfWeight = GetPrivateProfileIntA(sec_name, "FontWgt", 0, ini_file);
- td->tile_wid = GetPrivateProfileInt(sec_name, "TileWid", td->lf.lfWidth, ini_file);
- td->tile_hgt = GetPrivateProfileInt(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
+ td->tile_wid = GetPrivateProfileIntA(sec_name, "TileWid", td->lf.lfWidth, ini_file);
+ td->tile_hgt = GetPrivateProfileIntA(sec_name, "TileHgt", td->lf.lfHeight, ini_file);
- td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file);
- td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file);
+ td->cols = GetPrivateProfileIntA(sec_name, "NumCols", td->cols, ini_file);
+ td->rows = GetPrivateProfileIntA(sec_name, "NumRows", td->rows, ini_file);
normsize.x = td->cols;
normsize.y = td->rows;
if (i == 0) {
- win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
+ win_maximized = (GetPrivateProfileIntA(sec_name, "Maximized", win_maximized, ini_file) != 0);
}
- int posx = GetPrivateProfileInt(sec_name, "PositionX", 0, ini_file);
- int posy = GetPrivateProfileInt(sec_name, "PositionY", 0, ini_file);
+ int posx = GetPrivateProfileIntA(sec_name, "PositionX", 0, ini_file);
+ int posy = GetPrivateProfileIntA(sec_name, "PositionY", 0, ini_file);
// 保存座標がモニタ内の領域にあるかチェック
RECT rect = { posx, posy, posx + 128, posy + 128 };
bool in_any_monitor = false;
}
if (i > 0) {
- td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
+ td->posfix = (GetPrivateProfileIntA(sec_name, "PositionFix", td->posfix, ini_file) != 0);
}
}
-/*
- * Load the "prefs"
+/*!
+ * @brief Load the "prefs"
*/
static void load_prefs(void)
{
- arg_graphics = (byte)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
- arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
+ arg_graphics = (byte)GetPrivateProfileIntA("Angband", "Graphics", static_cast<byte>(graphics_mode::GRAPHICS_NONE), ini_file);
+ arg_bigtile = (GetPrivateProfileIntA("Angband", "Bigtile", false, ini_file) != 0);
use_bigtile = arg_bigtile;
- arg_sound = (GetPrivateProfileInt("Angband", "Sound", 0, ini_file) != 0);
- arg_music = (GetPrivateProfileInt("Angband", "Music", 0, ini_file) != 0);
- use_pause_music_inactive = (GetPrivateProfileInt("Angband", "MusicPauseInactive", 0, ini_file) != 0);
- current_bg_mode = static_cast<bg_mode>(GetPrivateProfileInt("Angband", "BackGround", 0, ini_file));
- GetPrivateProfileString("Angband", "BackGroundBitmap", DEFAULT_BG_FILENAME, wallpaper_file, 1023, ini_file);
- GetPrivateProfileString("Angband", "SaveFile", "", savefile, 1023, ini_file);
+ arg_sound = (GetPrivateProfileIntA("Angband", "Sound", 0, ini_file) != 0);
+ arg_music = (GetPrivateProfileIntA("Angband", "Music", 0, ini_file) != 0);
+ use_pause_music_inactive = (GetPrivateProfileIntA("Angband", "MusicPauseInactive", 0, ini_file) != 0);
+ current_bg_mode = static_cast<bg_mode>(GetPrivateProfileIntA("Angband", "BackGround", 0, ini_file));
+ GetPrivateProfileStringA("Angband", "BackGroundBitmap", DEFAULT_BG_FILENAME, wallpaper_file, 1023, ini_file);
+ GetPrivateProfileStringA("Angband", "SaveFile", "", savefile, 1023, ini_file);
int n = strncmp(".\\", savefile, 2);
if (n == 0) {
strncpy(savefile, tmp, strlen(tmp));
}
- keep_subwindows = (GetPrivateProfileInt("Angband", "KeepSubwindows", 0, ini_file) != 0);
+ keep_subwindows = (GetPrivateProfileIntA("Angband", "KeepSubwindows", 0, ini_file) != 0);
for (int i = 0; i < MAX_TERM_DATA; ++i) {
load_prefs_aux(i);
}
}
/*!
- * @brief グラフィクスを初期化する / Initialize graphics
- * @details
- * <ul>
- * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
- * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
- * </ul>
- */
-static bool init_graphics(void)
-{
- char buf[MAIN_WIN_MAX_PATH];
- BYTE wid, hgt, twid, thgt, ox, oy;
- concptr name;
- concptr name_mask = NULL;
-
- infGraph.delete_bitmap();
- infMask.delete_bitmap();
-
- if (arg_graphics == GRAPHICS_ADAM_BOLT) {
- wid = 16;
- hgt = 16;
- twid = 16;
- thgt = 16;
- ox = 0;
- oy = 0;
- name = "16X16.BMP";
- name_mask = "mask.bmp";
-
- ANGBAND_GRAF = "new";
- } else if (arg_graphics == GRAPHICS_HENGBAND) {
- wid = 32;
- hgt = 32;
- twid = 32;
- thgt = 32;
- ox = 0;
- oy = 0;
- name = "32X32.BMP";
- name_mask = "mask32.bmp";
-
- ANGBAND_GRAF = "ne2";
- } else {
- wid = 8;
- hgt = 8;
- twid = 8;
- thgt = 8;
- ox = 0;
- oy = 0;
- name = "8X8.BMP";
- ANGBAND_GRAF = "old";
- }
-
- path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
- infGraph.hBitmap = read_graphic(buf);
- if (!infGraph.hBitmap) {
- plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
- return FALSE;
- }
-
- infGraph.CellWidth = wid;
- infGraph.CellHeight = hgt;
- infGraph.TileWidth = twid;
- infGraph.TileHeight = thgt;
- infGraph.OffsetX = ox;
- infGraph.OffsetY = oy;
-
- if (name_mask) {
- path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name_mask);
- infMask.hBitmap = read_graphic(buf);
- if (!infMask.hBitmap) {
- plog_fmt("Cannot read bitmap file '%s'", buf);
- return FALSE;
- }
- }
-
- current_graphics_mode = arg_graphics;
- return (current_graphics_mode != GRAPHICS_NONE);
-}
-
-/*
- * Initialize music
+ * @brief Initialize music
*/
static void init_music(void)
{
// Flag set once "music" has been initialized
- static bool can_use_music = FALSE;
+ static bool can_use_music = false;
if (!can_use_music) {
main_win_music::load_music_prefs();
- can_use_music = TRUE;
+ can_use_music = true;
}
}
-/*
- * Initialize sound
+/*!
+ * @brief Initialize sound
*/
static void init_sound(void)
{
// Flag set once "sound" has been initialized
- static bool can_use_sound = FALSE;
+ static bool can_use_sound = false;
if (!can_use_sound) {
load_sound_prefs();
- can_use_sound = TRUE;
+ can_use_sound = true;
}
}
}
}
-/*
- * Initialize background
+/*!
+ * @brief Initialize background
*/
static void init_background(void)
{
// Flag set once "background" has been initialized
- static bool can_use_background = FALSE;
+ static bool can_use_background = false;
if (!can_use_background) {
load_bg_prefs();
- can_use_background = TRUE;
+ can_use_background = true;
}
}
const bool mode_changed = (current_bg_mode != old_bg_mode);
if (mode_changed || force_redraw) {
// 全ウインドウ再描画
+ term_type *old = Term;
for (int i = 0; i < MAX_TERM_DATA; i++) {
term_data *td = &data[i];
- if (td->visible)
- InvalidateRect(td->w, NULL, FALSE);
+ if (td->visible) {
+ term_activate(&td->t);
+ term_redraw();
+ }
}
+ term_activate(old);
}
return (current_bg_mode == new_mode);
return;
SetWindowPos(td->w, 0, 0, 0, td->size_wid, td->size_hgt, SWP_NOMOVE | SWP_NOZORDER);
- InvalidateRect(td->w, NULL, TRUE);
+ if (!td->size_hack) {
+ td->dispose_offscreen();
+ term_activate(&td->t);
+ term_redraw();
+ }
}
/*!
if (td->font_id)
DeleteObject(td->font_id);
- td->font_id = CreateFontIndirect(&(td->lf));
+ td->font_id = CreateFontIndirectW(&(td->lf));
int wid = td->lf.lfWidth;
int hgt = td->lf.lfHeight;
if (!td->font_id)
return 0;
}
-/*
- * Allow the user to change the font for this window.
+/*!
+ * @brief Allow the user to change the font for this window.
*/
static void term_change_font(term_data *td)
{
- CHOOSEFONT cf;
+ CHOOSEFONTW cf;
memset(&cf, 0, sizeof(cf));
cf.lStructSize = sizeof(cf);
cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
cf.lpLogFont = &(td->lf);
- if (!ChooseFont(&cf))
+ if (!ChooseFontW(&cf))
return;
term_force_font(td);
term_window_resize(td);
}
-/*
- * Allow the user to lock this window.
+/*!
+ * @brief Allow the user to lock this window.
*/
static void term_window_pos(term_data *td, HWND hWnd)
{
SetWindowPos(td->w, hWnd, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
}
-/*
- * Hack -- redraw a term_data
+/*!
+ * @brief Hack -- redraw a term_data
*/
static void term_data_redraw(term_data *td)
{
term_activate(term_screen);
}
+/*!
+ * @brief termの反転色表示
+ */
void term_inversed_area(HWND hWnd, int x, int y, int w, int h)
{
term_data *td = (term_data *)GetWindowLong(hWnd, 0);
int tw = w * td->tile_wid - 1;
int th = h * td->tile_hgt - 1;
- HDC hdc = GetDC(hWnd);
+ HDC hdc = td->get_hdc();
HBRUSH myBrush = CreateSolidBrush(RGB(255, 255, 255));
HBRUSH oldBrush = static_cast<HBRUSH>(SelectObject(hdc, myBrush));
HPEN oldPen = static_cast<HPEN>(SelectObject(hdc, GetStockObject(NULL_PEN)));
SelectObject(hdc, oldBrush);
SelectObject(hdc, oldPen);
+
+ RECT rect{ tx, ty, tx + tw, ty + th };
+ td->refresh(&rect);
}
/*!
- * @brief //!< Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
+ * @brief Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
*/
static errr term_user_win(int n)
{
return 0;
}
+/*!
+ * @brief カラーパレットの変更?
+ */
static void refresh_color_table()
{
for (int i = 0; i < 256; i++) {
}
}
-/*
- * React to global changes
+/*!
+ * @brief グラフィクスのモード変更
+ */
+static void change_graphics_mode(graphics_mode mode)
+{
+ graphics_mode ret = graphic.change_graphics(mode);
+ if (ret != mode) {
+ plog(_("グラフィクスを初期化できません!", "Cannot initialize graphics!"));
+ }
+ arg_graphics = static_cast<byte>(ret);
+ use_graphics = (arg_graphics > 0);
+}
+
+/*!
+ * @brief ターミナルのサイズ更新
+ * @details 行数、列数の変更に対応する。
+ * @param td term_dataのポインタ
+ * @param resize_window trueの場合に再計算されたウインドウサイズにリサイズする
+ */
+static void rebuild_term(term_data *td, bool resize_window = true)
+{
+ term_type *old = Term;
+ td->size_hack = true;
+ term_activate(&td->t);
+ term_getsize(td);
+ if (resize_window) {
+ term_window_resize(td);
+ }
+ td->dispose_offscreen();
+ term_resize(td->cols, td->rows);
+ td->size_hack = false;
+ term_activate(old);
+}
+
+/*!
+ * @brief React to global changes
*/
static errr term_xtra_win_react(player_type *player_ptr)
{
refresh_color_table();
- if (arg_graphics && !init_graphics()) {
- plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
- arg_graphics = GRAPHICS_NONE;
+ const byte current_mode = static_cast<byte>(graphic.get_mode());
+ if (current_mode != arg_graphics) {
+ change_graphics_mode(static_cast<graphics_mode>(arg_graphics));
+ reset_visuals(player_ptr);
}
- use_graphics = (arg_graphics > 0);
- reset_visuals(player_ptr);
for (int i = 0; i < MAX_TERM_DATA; i++) {
term_type *old = Term;
term_data *td = &data[i];
if ((td->cols != td->t.wid) || (td->rows != td->t.hgt)) {
- term_activate(&td->t);
- term_resize(td->cols, td->rows);
- term_redraw();
- term_activate(old);
+ rebuild_term(td);
}
}
return 0;
}
-/*
- * Process at least one event
+/*!
+ * @brief Process at least one event
*/
static errr term_xtra_win_event(int v)
{
return 0;
}
-/*
- * Process all pending events
+/*!
+ * @brief Process all pending events
*/
static errr term_xtra_win_flush(void)
{
return 0;
}
-/*
- * Hack -- clear the screen
- *
+/*!
+ * @brief Hack -- clear the screen
+ * @details
* Make this more efficient
*/
static errr term_xtra_win_clear(void)
term_data *td = (term_data *)(Term->data);
RECT rc;
- rc.left = td->size_ow1;
- rc.right = rc.left + td->cols * td->tile_wid;
- rc.top = td->size_oh1;
- rc.bottom = rc.top + td->rows * td->tile_hgt;
+ GetClientRect(td->w, &rc);
- HDC hdc = GetDC(td->w);
+ HDC hdc = td->get_hdc();
SetBkColor(hdc, RGB(0, 0, 0));
SelectObject(hdc, td->font_id);
ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
draw_bg(hdc, &rc);
}
- ReleaseDC(td->w, hdc);
+ td->refresh();
return 0;
}
-/*
- * Hack -- make a noise
+/*!
+ * @brief Hack -- make a noise
*/
static errr term_xtra_win_noise(void)
{
return 0;
}
-/*
- * Hack -- make a sound
+/*!
+ * @brief Hack -- make a sound
*/
static errr term_xtra_win_sound(int v)
{
return play_sound(v);
}
-/*
- * Hack -- play a music
+/*!
+ * @brief Hack -- play a music
*/
static errr term_xtra_win_music(int n, int v)
{
return main_win_music::play_music(n, v);
}
-/*
- * Hack -- play a music matches a situation
+/*!
+ * @brief Hack -- play a music matches a situation
*/
static errr term_xtra_win_scene(int v)
{
return main_win_music::play_music_scene(v);
}
-/*
- * Delay for "x" milliseconds
+/*!
+ * @brief Delay for "x" milliseconds
*/
static int term_xtra_win_delay(int v)
{
case TERM_XTRA_NOISE: {
return (term_xtra_win_noise());
}
+ case TERM_XTRA_FRESH: {
+ term_data *td = (term_data *)(Term->data);
+ if (td->w)
+ UpdateWindow(td->w);
+ return 0;
+ }
case TERM_XTRA_MUSIC_BASIC:
case TERM_XTRA_MUSIC_DUNGEON:
case TERM_XTRA_MUSIC_QUEST:
return 1;
}
-/*
- * Low level graphics (Assumes valid input).
- *
+/*!
+ * @brief Low level graphics (Assumes valid input).
+ * @details
* Draw a "cursor" at (x,y), using a "yellow box".
*/
static errr term_curs_win(int x, int y)
rc.top = y * tile_hgt + td->size_oh1;
rc.bottom = rc.top + tile_hgt;
- HDC hdc = GetDC(td->w);
+ HDC hdc = td->get_hdc();
FrameRect(hdc, &rc, hbrYellow);
- ReleaseDC(td->w, hdc);
+ td->refresh(&rc);
return 0;
}
-/*
- * Low level graphics (Assumes valid input).
- *
+/*!
+ * @brief Low level graphics (Assumes valid input).
+ * @details
* Draw a "big cursor" at (x,y), using a "yellow box".
*/
static errr term_bigcurs_win(int x, int y)
rc.top = y * tile_hgt + td->size_oh1;
rc.bottom = rc.top + tile_hgt;
- HDC hdc = GetDC(td->w);
+ HDC hdc = td->get_hdc();
FrameRect(hdc, &rc, hbrYellow);
- ReleaseDC(td->w, hdc);
+ td->refresh(&rc);
return 0;
}
-/*
- * Low level graphics (Assumes valid input).
- *
+/*!
+ * @brief Low level graphics (Assumes valid input).
+ * @details
* Erase a "block" of "n" characters starting at (x,y).
*/
static errr term_wipe_win(int x, int y, int n)
rc.top = y * td->tile_hgt + td->size_oh1;
rc.bottom = rc.top + td->tile_hgt;
- HDC hdc = GetDC(td->w);
+ HDC hdc = td->get_hdc();
SetBkColor(hdc, RGB(0, 0, 0));
SelectObject(hdc, td->font_id);
if (current_bg_mode != bg_mode::BG_NONE)
else
ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
- ReleaseDC(td->w, hdc);
+ td->refresh(&rc);
return 0;
}
-/*
- * Low level graphics. Assumes valid input.
- *
+/*!
+ * @brief Low level graphics. Assumes valid input.
+ * @details
* Draw several ("n") chars, with an attr, at a given location.
*
* All "graphic" data is handled by "term_pict_win()", below.
static HBITMAP WALL;
static HBRUSH myBrush, oldBrush;
static HPEN oldPen;
- static bool init_done = FALSE;
+ static bool init_done = false;
if (!init_done) {
- WALL = LoadBitmap(hInstance, AppName);
+ WALL = LoadBitmapW(hInstance, AppName);
myBrush = CreatePatternBrush(WALL);
- init_done = TRUE;
+ init_done = true;
}
RECT rc{ static_cast<LONG>(x * td->tile_wid + td->size_ow1), static_cast<LONG>(y * td->tile_hgt + td->size_oh1),
static_cast<LONG>(rc.left + n * td->tile_wid), static_cast<LONG>(rc.top + td->tile_hgt) };
+ RECT rc_start = rc;
- HDC hdc = GetDC(td->w);
+ HDC hdc = td->get_hdc();
SetBkColor(hdc, RGB(0, 0, 0));
SetTextColor(hdc, win_clr[a]);
rc.right += 2 * td->tile_wid;
} else if (iskanji(*(s + i))) /* 2バイト文字 */
{
+ char tmp[] = { *(s + i), *(s + i + 1), '\0' };
+ to_wchar wc(tmp);
+ const auto *buf = wc.wc_str();
rc.right += td->font_wid;
- ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 2, NULL);
+ if (buf == NULL)
+ ExtTextOutA(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 2, NULL);
+ else
+ ExtTextOutW(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, buf, wcslen(buf), NULL);
rc.right -= td->font_wid;
i++;
rc.left += 2 * td->tile_wid;
rc.left += td->tile_wid;
rc.right += td->tile_wid;
} else {
- ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
+ ExtTextOutA(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
rc.left += td->tile_wid;
rc.right += td->tile_wid;
}
rc.left += td->tile_wid;
rc.right += td->tile_wid;
} else {
- ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
+ ExtTextOutA(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 1, NULL);
rc.left += td->tile_wid;
rc.right += td->tile_wid;
}
#endif
}
- ReleaseDC(td->w, hdc);
+ rc.left = rc_start.left;
+ rc.top = rc_start.top;
+ td->refresh(&rc);
return 0;
}
-/*
- * Low level graphics. Assumes valid input.
- *
+/*!
+ * @brief Low level graphics. Assumes valid input.
+ * @details
* Draw an array of "special" attr/char pairs at the given location.
*
* We use the "term_pict_win()" function for "graphic" data, which are
return (term_wipe_win(x, y, n));
}
+ const tile_info &infGraph = graphic.get_tile_info();
+ const bool has_mask = (infGraph.hBitmapMask != NULL);
TERM_LEN w1 = infGraph.CellWidth;
TERM_LEN h1 = infGraph.CellHeight;
TERM_LEN tw1 = infGraph.TileWidth;
TERM_LEN x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
TERM_LEN y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
- HDC hdc = GetDC(td->w);
+ HDC hdc = td->get_hdc();
HDC hdcSrc = CreateCompatibleDC(hdc);
HBITMAP hbmSrcOld = static_cast<HBITMAP>(SelectObject(hdcSrc, infGraph.hBitmap));
- if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND) {
+ if (has_mask) {
hdcMask = CreateCompatibleDC(hdc);
- SelectObject(hdcMask, infMask.hBitmap);
+ SelectObject(hdcMask, infGraph.hBitmapMask);
}
for (i = 0; i < n; i++, x2 += w2) {
TERM_LEN x1 = col * w1;
TERM_LEN y1 = row * h1;
- if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND) {
+ if (has_mask) {
TERM_LEN x3 = (tcp[i] & 0x7F) * w1;
TERM_LEN y3 = (tap[i] & 0x7F) * h1;
tw2 = tw2 * w1 / tw1;
SelectObject(hdcSrc, hbmSrcOld);
DeleteDC(hdcSrc);
- if (arg_graphics == GRAPHICS_ADAM_BOLT || arg_graphics == GRAPHICS_HENGBAND) {
+ if (has_mask) {
SelectObject(hdcMask, hbmSrcOld);
DeleteDC(hdcMask);
}
- ReleaseDC(td->w, hdc);
+ td->refresh();
return 0;
}
-/*
- * Create and initialize a "term_data" given a title
+/*!
+ * @brief Create and initialize a "term_data" given a title
*/
static void term_data_link(term_data *td)
{
term_type *t = &td->t;
term_init(t, td->cols, td->rows, FILE_READ_BUFF_SIZE);
- t->soft_cursor = TRUE;
- t->higher_pict = TRUE;
+ t->soft_cursor = true;
+ t->higher_pict = true;
t->attr_blank = TERM_WHITE;
t->char_blank = ' ';
t->user_hook = term_user_win;
t->data = (vptr)(td);
}
-/*
- * Create the windows
- *
+/*!
+ * @brief Create the windows
+ * @details
* First, instantiate the "default" values, then read the "ini_file"
* to over-ride selected values, then create the windows, and fonts.
*
term_data *td;
td = &data[0];
WIPE(td, term_data);
-#ifdef JP
- td->s = "変愚蛮怒";
-#else
- td->s = angband_term_name[0];
-#endif
+ td->name = win_term_name[0];
- td->keys = 1024;
td->rows = 24;
td->cols = 80;
- td->visible = TRUE;
+ td->visible = true;
td->size_ow1 = 2;
td->size_ow2 = 2;
td->size_oh1 = 2;
td->size_oh2 = 2;
td->pos_x = 7 * 30;
td->pos_y = 7 * 20;
- td->posfix = FALSE;
+ td->posfix = false;
for (int i = 1; i < MAX_TERM_DATA; i++) {
td = &data[i];
WIPE(td, term_data);
- td->s = angband_term_name[i];
- td->keys = 16;
+ td->name = win_term_name[i];
td->rows = 24;
td->cols = 80;
- td->visible = FALSE;
+ td->visible = false;
td->size_ow1 = 1;
td->size_ow2 = 1;
td->size_oh1 = 1;
td->size_oh2 = 1;
td->pos_x = (7 - i) * 30;
td->pos_y = (7 - i) * 20;
- td->posfix = FALSE;
+ td->posfix = false;
}
load_prefs();
td = &data[0];
td->dwStyle = (WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_VISIBLE);
td->dwExStyle = 0;
- td->visible = TRUE;
+ td->visible = true;
/* Attributes of sub windows */
for (int i = 1; i < MAX_TERM_DATA; i++) {
/* Font of each window */
for (int i = 0; i < MAX_TERM_DATA; i++) {
td = &data[i];
- strncpy(td->lf.lfFaceName, td->font_want, LF_FACESIZE);
- td->lf.lfCharSet = DEFAULT_CHARSET;
+ wcsncpy(td->lf.lfFaceName, to_wchar(td->font_want).wc_str(), LF_FACESIZE);
+ td->lf.lfCharSet = _(SHIFTJIS_CHARSET, DEFAULT_CHARSET);
td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
term_force_font(td);
if (!td->tile_wid)
td = &data[i];
my_td = td;
- td->w
- = CreateWindowEx(td->dwExStyle, AngList, td->s, td->dwStyle, td->pos_x, td->pos_y, td->size_wid, td->size_hgt, HWND_DESKTOP, NULL, hInstance, NULL);
+ td->w = CreateWindowExW(
+ td->dwExStyle, AngList, td->name, td->dwStyle, td->pos_x, td->pos_y, td->size_wid, td->size_hgt, HWND_DESKTOP, NULL, hInstance, NULL);
my_td = NULL;
if (!td->w)
quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
- td->size_hack = TRUE;
+ td->size_hack = true;
term_getsize(td);
term_window_resize(td);
if (td->visible) {
ShowWindow(td->w, SW_SHOW);
}
- td->size_hack = FALSE;
+ td->size_hack = false;
term_data_link(td);
angband_term[i] = &td->t;
/* Create main window */
td = &data[0];
my_td = td;
- td->w = CreateWindowEx(td->dwExStyle, AppName, td->s, td->dwStyle, td->pos_x, td->pos_y, td->size_wid, td->size_hgt, HWND_DESKTOP, NULL, hInstance, NULL);
+ td->w = CreateWindowExW(
+ td->dwExStyle, AppName, _(L"変愚蛮怒", td->name), td->dwStyle, td->pos_x, td->pos_y, td->size_wid, td->size_hgt, HWND_DESKTOP, NULL, hInstance, NULL);
my_td = NULL;
if (!td->w)
quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
/* Resize */
- td->size_hack = TRUE;
+ td->size_hack = true;
term_getsize(td);
term_window_resize(td);
- td->size_hack = FALSE;
+ td->size_hack = false;
term_data_link(td);
angband_term[0] = &td->t;
(void)term_xtra_win_flush();
}
-/*
- * Prepare the menus
+/*!
+ * @brief Prepare the menus
*/
static void setup_menus(void)
{
}
CheckMenuItem(hm, IDM_WINDOW_KEEP_SUBWINDOWS, (keep_subwindows ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, (arg_graphics == GRAPHICS_NONE ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, (arg_graphics == GRAPHICS_ORIGINAL ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, (arg_graphics == GRAPHICS_ADAM_BOLT ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS, (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_NO_GRAPHICS, (arg_graphics == static_cast<byte>(graphics_mode::GRAPHICS_NONE) ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_OLD_GRAPHICS, (arg_graphics == static_cast<byte>(graphics_mode::GRAPHICS_ORIGINAL) ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_NEW_GRAPHICS, (arg_graphics == static_cast<byte>(graphics_mode::GRAPHICS_ADAM_BOLT) ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS, (arg_graphics == static_cast<byte>(graphics_mode::GRAPHICS_HENGBAND) ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(hm, IDM_OPTIONS_BIGTILE, (arg_bigtile ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(hm, IDM_OPTIONS_MUSIC, (arg_music ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(hm, IDM_OPTIONS_MUSIC_PAUSE_INACTIVE, (use_pause_music_inactive ? MF_CHECKED : MF_UNCHECKED));
EnableMenuItem(hm, IDM_OPTIONS_PRESET_BG, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
}
-/*
- * Check for double clicked (or dragged) savefile
- *
+/*!
+ * @brief Check for double clicked (or dragged) savefile
+ * @details
* Apparently, Windows copies the entire filename into the first
* piece of the "command line string". Perhaps we should extract
* the "basename" of that filename and append it to the "save" dir.
+ * @param savefile_option savefile path
*/
-static void check_for_save_file(player_type *player_ptr, LPSTR cmd_line)
+static void check_for_save_file(const std::string &savefile_option)
{
- char *s;
- s = cmd_line;
- if (!*s)
+ if (savefile_option.empty())
return;
- strcpy(savefile, s);
+ strcpy(savefile, savefile_option.c_str());
validate_file(savefile);
- game_in_progress = TRUE;
- play_game(player_ptr, FALSE, FALSE);
+ game_in_progress = true;
}
-/*
- * Process a menu command
+/*!
+ * @brief Process a menu command
*/
static void process_menus(player_type *player_ptr, WORD wCmd)
{
}
term_data *td;
- OPENFILENAME ofn;
+ OPENFILENAMEW ofn;
switch (wCmd) {
case IDM_FILE_NEW: {
- if (game_in_progress) {
+ if (game_in_progress || movie_in_progress) {
plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
} else {
- game_in_progress = TRUE;
- term_flush();
- strcpy(savefile, "");
- play_game(player_ptr, TRUE, FALSE);
- quit(NULL);
+ game_in_progress = true;
+ savefile[0] = '\0';
}
break;
}
case IDM_FILE_OPEN: {
- if (game_in_progress) {
+ if (game_in_progress || movie_in_progress) {
plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
} else {
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = data[0].w;
- ofn.lpstrFilter = "Save Files (*.)\0*\0";
+ ofn.lpstrFilter = L"Save Files (*.)\0*\0";
ofn.nFilterIndex = 1;
- ofn.lpstrFile = savefile;
- ofn.nMaxFile = 1024;
- ofn.lpstrInitialDir = ANGBAND_DIR_SAVE;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
- if (GetOpenFileName(&ofn)) {
+ if (get_open_filename(&ofn, ANGBAND_DIR_SAVE, savefile, MAIN_WIN_MAX_PATH)) {
validate_file(savefile);
- game_in_progress = TRUE;
- term_flush();
- play_game(player_ptr, FALSE, FALSE);
- quit(NULL);
+ game_in_progress = true;
}
}
break;
}
- msg_flag = FALSE;
- do_cmd_save_game(player_ptr, FALSE);
+ msg_flag = false;
+ do_cmd_save_game(player_ptr, false);
} else {
plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
}
break;
}
- msg_flag = FALSE;
+ msg_flag = false;
forget_lite(player_ptr->current_floor_ptr);
forget_view(player_ptr->current_floor_ptr);
clear_mon_lite(player_ptr->current_floor_ptr);
} else {
screen_save();
term_clear();
- display_scores_aux(0, MAX_HISCORES, -1, NULL);
+ display_scores(0, MAX_HISCORES, -1, NULL);
(void)fd_close(highscore_fd);
highscore_fd = -1;
screen_load();
break;
}
case IDM_FILE_MOVIE: {
- if (game_in_progress) {
+ if (game_in_progress || movie_in_progress) {
plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
} else {
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = data[0].w;
- ofn.lpstrFilter = "Angband Movie Files (*.amv)\0*.amv\0";
+ ofn.lpstrFilter = L"Angband Movie Files (*.amv)\0*.amv\0";
ofn.nFilterIndex = 1;
- ofn.lpstrFile = savefile;
- ofn.nMaxFile = 1024;
- ofn.lpstrInitialDir = ANGBAND_DIR_USER;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
- if (GetOpenFileName(&ofn)) {
+ if (get_open_filename(&ofn, ANGBAND_DIR_USER, savefile, MAIN_WIN_MAX_PATH)) {
prepare_browse_movie_without_path_build(savefile);
- play_game(player_ptr, FALSE, TRUE);
- quit(NULL);
- return;
+ movie_in_progress = true;
}
}
td = &data[i];
if (!td->visible) {
- td->visible = TRUE;
+ td->visible = true;
ShowWindow(td->w, SW_SHOW);
term_data_redraw(td);
} else {
- td->visible = FALSE;
- td->posfix = FALSE;
+ td->visible = false;
+ td->posfix = false;
ShowWindow(td->w, SW_HIDE);
}
td = &data[i];
if (!td->posfix && td->visible) {
- td->posfix = TRUE;
+ td->posfix = true;
term_window_pos(td, HWND_TOPMOST);
} else {
- td->posfix = FALSE;
+ td->posfix = false;
term_window_pos(td, data[0].w);
}
break;
}
case IDM_OPTIONS_NO_GRAPHICS: {
- if (arg_graphics != GRAPHICS_NONE) {
- arg_graphics = GRAPHICS_NONE;
+ if (arg_graphics != static_cast<byte>(graphics_mode::GRAPHICS_NONE)) {
+ arg_graphics = static_cast<byte>(graphics_mode::GRAPHICS_NONE);
if (game_in_progress)
do_cmd_redraw(player_ptr);
}
break;
}
case IDM_OPTIONS_OLD_GRAPHICS: {
- if (arg_graphics != GRAPHICS_ORIGINAL) {
- arg_graphics = GRAPHICS_ORIGINAL;
+ if (arg_graphics != static_cast<byte>(graphics_mode::GRAPHICS_ORIGINAL)) {
+ arg_graphics = static_cast<byte>(graphics_mode::GRAPHICS_ORIGINAL);
if (game_in_progress)
do_cmd_redraw(player_ptr);
}
break;
}
case IDM_OPTIONS_NEW_GRAPHICS: {
- if (arg_graphics != GRAPHICS_ADAM_BOLT) {
- arg_graphics = GRAPHICS_ADAM_BOLT;
+ if (arg_graphics != static_cast<byte>(graphics_mode::GRAPHICS_ADAM_BOLT)) {
+ arg_graphics = static_cast<byte>(graphics_mode::GRAPHICS_ADAM_BOLT);
if (game_in_progress)
do_cmd_redraw(player_ptr);
}
break;
}
case IDM_OPTIONS_NEW2_GRAPHICS: {
- if (arg_graphics != GRAPHICS_HENGBAND) {
- arg_graphics = GRAPHICS_HENGBAND;
+ if (arg_graphics != static_cast<byte>(graphics_mode::GRAPHICS_HENGBAND)) {
+ arg_graphics = static_cast<byte>(graphics_mode::GRAPHICS_HENGBAND);
if (game_in_progress)
do_cmd_redraw(player_ptr);
}
case IDM_OPTIONS_BIGTILE: {
td = &data[0];
arg_bigtile = !arg_bigtile;
- term_activate(&td->t);
- term_resize(td->cols, td->rows);
- InvalidateRect(td->w, NULL, TRUE);
+ rebuild_term(td);
break;
}
case IDM_OPTIONS_MUSIC: {
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = data[0].w;
- ofn.lpstrFilter = "Image Files (*.bmp;*.png;*.jpg;*.jpeg;)\0*.bmp;*.png;*.jpg;*.jpeg;\0";
+ ofn.lpstrFilter = L"Image Files (*.bmp;*.png;*.jpg;*.jpeg;)\0*.bmp;*.png;*.jpg;*.jpeg;\0";
ofn.nFilterIndex = 1;
- ofn.lpstrFile = wallpaper_file;
- ofn.nMaxFile = 1023;
- ofn.lpstrInitialDir = NULL;
- ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
+ ofn.lpstrTitle = _(L"壁紙を選んでね。", L"Choose wall paper.");
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
- if (GetOpenFileName(&ofn)) {
+ if (get_open_filename(&ofn, NULL, wallpaper_file, MAIN_WIN_MAX_PATH)) {
change_bg_mode(bg_mode::BG_ONE, true, true);
}
break;
}
}
-/*
- * Add a keypress to the "queue"
+/*!
+ * @brief Add a keypress to the "queue"
*/
static errr term_keypress(int k)
{
return 1;
}
+/*!
+ * @brief Add a keypress to the "queue"
+ * @details マルチバイト文字をkey_queueに追加する。
+ * @param str マルチバイト文字列
+ */
+static void term_keypress(char *str)
+{
+ if (str) {
+ char *psrc = str;
+ while (*psrc) {
+ term_keypress(*psrc);
+ ++psrc;
+ }
+ }
+}
+
+/*!
+ * @brief キーダウンのハンドラ
+ */
static bool process_keydown(WPARAM wParam, LPARAM lParam)
{
- bool mc = FALSE;
- bool ms = FALSE;
- bool ma = FALSE;
+ bool mc = false;
+ bool ms = false;
+ bool ma = false;
if (GetKeyState(VK_CONTROL) & 0x8000)
- mc = TRUE;
+ mc = true;
if (GetKeyState(VK_SHIFT) & 0x8000)
- ms = TRUE;
+ ms = true;
if (GetKeyState(VK_MENU) & 0x8000)
- ma = TRUE;
+ ma = true;
- term_no_press = (ma) ? TRUE : FALSE;
+ term_no_press = (ma) ? true : false;
if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)])) {
- bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
- bool numpad = FALSE;
+ bool ext_key = (lParam & 0x1000000L) ? true : false;
+ bool numpad = false;
term_keypress(31);
if (mc)
term_keypress('x');
switch (wParam) {
case VK_DIVIDE:
- term_no_press = TRUE;
+ term_no_press = true;
[[fallthrough]]; /* Fall through */
case VK_RETURN:
numpad = ext_key;
case VK_SUBTRACT:
case VK_SEPARATOR:
case VK_DECIMAL:
- term_no_press = TRUE;
+ term_no_press = true;
[[fallthrough]]; /* Fall through */
case VK_CLEAR:
case VK_HOME:
return 0;
}
+/*!
+ * @brief ウィンドウのアクティブ/非アクティブのハンドラ
+ */
static void handle_app_active(HWND hWnd, UINT uMsg, WPARAM wParam, [[maybe_unused]] LPARAM lParam)
{
switch (uMsg) {
}
/*!
+ * @brief ターミナルのサイズをウインドウのサイズに合わせる
+ * @param td term_dataのポインタ
+ * @param recalc_window_size trueの場合に行列数からウインドウサイズを再計算し設定する
+ */
+static void fit_term_size_to_window(term_data *td, bool recalc_window_size = false)
+{
+ RECT rc;
+ ::GetClientRect(td->w, &rc);
+ int width = rc.right - rc.left;
+ int height = rc.bottom - rc.top;
+
+ TERM_LEN cols = (width - td->size_ow1 - td->size_ow2) / td->tile_wid;
+ TERM_LEN rows = (height - td->size_oh1 - td->size_oh2) / td->tile_hgt;
+ if ((td->cols != cols) || (td->rows != rows)) {
+ td->cols = cols;
+ td->rows = rows;
+ if (is_main_term(td) && !IsZoomed(td->w) && !IsIconic(td->w)) {
+ normsize.x = td->cols;
+ normsize.y = td->rows;
+ }
+
+ rebuild_term(td, recalc_window_size);
+
+ if (!is_main_term(td)) {
+ p_ptr->window_flags = PW_ALL;
+ handle_stuff(p_ptr);
+ }
+ }
+}
+
+/*!
+ * @brief Windowのリサイズをハンドリング
+ * @retval true ウインドウメッセージを処理した
+ * @retval false ウインドウメッセージを処理していない
+ */
+static bool handle_window_resize(term_data *td, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ if (!td)
+ return false;
+ if (!td->w)
+ return false;
+
+ switch (uMsg) {
+ case WM_GETMINMAXINFO: {
+ const bool is_main = is_main_term(td);
+ const int min_cols = (is_main) ? 80 : 20;
+ const int min_rows = (is_main) ? 24 : 3;
+ const LONG w = min_cols * td->tile_wid + td->size_ow1 + td->size_ow2;
+ const LONG h = min_rows * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
+ RECT rc{ 0, 0, w, h };
+ AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
+
+ MINMAXINFO *lpmmi = (MINMAXINFO *)lParam;
+ lpmmi->ptMinTrackSize.x = rc.right - rc.left;
+ lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
+
+ return true;
+ }
+ case WM_EXITSIZEMOVE: {
+ fit_term_size_to_window(td, true);
+ return true;
+ }
+ case WM_WINDOWPOSCHANGED: {
+ if (!td->size_hack) {
+ WINDOWPOS *pos = (WINDOWPOS *)lParam;
+ if ((pos->flags & (SWP_NOCOPYBITS | SWP_NOSIZE)) == 0) {
+ fit_term_size_to_window(td);
+ return true;
+ }
+ }
+ break;
+ }
+ case WM_SIZE: {
+ if (td->size_hack)
+ break;
+
+ //!< @todo 二重のswitch文。後で分割する.
+ switch (wParam) {
+ case SIZE_MINIMIZED: {
+ for (int i = 1; i < MAX_TERM_DATA; i++) {
+ if (data[i].visible)
+ ShowWindow(data[i].w, SW_HIDE);
+ }
+
+ return true;
+ }
+ case SIZE_MAXIMIZED:
+ case SIZE_RESTORED: {
+ fit_term_size_to_window(td);
+
+ td->size_hack = true;
+ for (int i = 1; i < MAX_TERM_DATA; i++) {
+ if (data[i].visible)
+ ShowWindow(data[i].w, SW_SHOWNA);
+ }
+
+ td->size_hack = false;
+
+ return true;
+ }
+ }
+
+ break;
+ }
+ }
+
+ return false;
+}
+
+/*!
* @brief メインウインドウ用ウインドウプロシージャ
*/
LRESULT PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- PAINTSTRUCT ps;
- term_data *td;
- td = (term_data *)GetWindowLong(hWnd, 0);
+ term_data *td = (term_data *)GetWindowLong(hWnd, 0);
handle_app_active(hWnd, uMsg, wParam, lParam);
+ if (handle_window_resize(td, uMsg, wParam, lParam))
+ return 0;
switch (uMsg) {
case WM_NCCREATE: {
setup_mci(hWnd);
return 0;
}
- case WM_GETMINMAXINFO: {
- MINMAXINFO *lpmmi;
- RECT rc;
-
- lpmmi = (MINMAXINFO *)lParam;
- if (!td)
- return 1;
-
- rc.left = rc.top = 0;
- rc.right = rc.left + 80 * td->tile_wid + td->size_ow1 + td->size_ow2;
- rc.bottom = rc.top + 24 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
-
- AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
-
- lpmmi->ptMinTrackSize.x = rc.right - rc.left;
- lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
-
- return 0;
- }
case WM_ERASEBKGND: {
return 1;
}
case WM_PAINT: {
- BeginPaint(hWnd, &ps);
+ PAINTSTRUCT ps;
+ HDC hdc = BeginPaint(hWnd, &ps);
if (td)
- term_data_redraw(td);
+ if (!td->render(ps.rcPaint)) {
+ SetBkColor(hdc, RGB(0, 0, 0));
+ ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &ps.rcPaint, NULL, 0, NULL);
+ }
EndPaint(hWnd, &ps);
ValidateRect(hWnd, NULL);
return 0;
break;
}
case WM_CHAR: {
+ // wParam is WCHAR because using RegisterClassW
if (term_no_press)
- term_no_press = FALSE;
- else
- term_keypress(wParam);
+ term_no_press = false;
+ else {
+ WCHAR wc[2] = { (WCHAR)wParam, '\0' };
+ term_keypress(to_multibyte(wc).c_str());
+ }
return 0;
}
case WM_LBUTTONDOWN: {
+ if (macro_running())
+ return 0;
mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
mousey = MIN(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
- mouse_down = TRUE;
+ mouse_down = true;
oldx = mousex;
oldy = mousey;
return 0;
}
case WM_LBUTTONUP: {
+ if (!mouse_down)
+ return 0;
HGLOBAL hGlobal;
LPSTR lpStr;
TERM_LEN dx = abs(oldx - mousex) + 1;
TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
- mouse_down = FALSE;
- paint_rect = FALSE;
+ mouse_down = false;
+ paint_rect = false;
#ifdef JP
int sz = (dx + 3) * dy;
oy = (oldy > mousey) ? mousey : oldy;
term_inversed_area(hWnd, ox, oy, dx, dy);
} else {
- paint_rect = TRUE;
+ paint_rect = true;
}
dx = abs(cx - mousex) + 1;
return 0;
}
- msg_flag = FALSE;
+ msg_flag = false;
forget_lite(p_ptr->current_floor_ptr);
forget_view(p_ptr->current_floor_ptr);
clear_mon_lite(p_ptr->current_floor_ptr);
return 0;
}
- msg_flag = FALSE;
+ msg_flag = false;
if (p_ptr->chp < 0)
- p_ptr->is_dead = FALSE;
+ p_ptr->is_dead = false;
exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
p_ptr->panic_save = 1;
process_menus(p_ptr, LOWORD(wParam));
return 0;
}
- case WM_SIZE: {
- if (!td)
- return 1;
- if (!td->w)
- return 1;
- if (td->size_hack)
- return 1;
-
- //!< @todo 二重のswitch文。後で分割する.
- switch (wParam) {
- case SIZE_MINIMIZED: {
- for (int i = 1; i < MAX_TERM_DATA; i++) {
- if (data[i].visible)
- ShowWindow(data[i].w, SW_HIDE);
- }
-
- return 0;
- }
- case SIZE_MAXIMIZED:
- case SIZE_RESTORED: {
- TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
- TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
- if ((td->cols != cols) || (td->rows != rows)) {
- td->cols = cols;
- td->rows = rows;
- if (!IsZoomed(td->w) && !IsIconic(td->w)) {
- normsize.x = td->cols;
- normsize.y = td->rows;
- }
-
- term_activate(&td->t);
- term_resize(td->cols, td->rows);
- InvalidateRect(td->w, NULL, TRUE);
- }
-
- td->size_hack = TRUE;
- for (int i = 1; i < MAX_TERM_DATA; i++) {
- if (data[i].visible)
- ShowWindow(data[i].w, SW_SHOW);
- }
-
- td->size_hack = FALSE;
-
- return 0;
- }
- }
-
- break;
- }
case WM_ACTIVATE: {
if (!wParam || HIWORD(lParam))
break;
for (int i = 1; i < MAX_TERM_DATA; i++) {
if (data[i].visible) {
- if (wParam == TRUE) {
- ShowWindow(data[i].w, SW_SHOW);
+ if (wParam == 1) {
+ ShowWindow(data[i].w, SW_SHOWNA);
} else {
ShowWindow(data[i].w, SW_HIDE);
}
[[fallthrough]]; /* Fall through */
case WM_ENABLE: {
if (wParam == FALSE && keep_subwindows) {
- for (int i = 0; i < MAX_TERM_DATA; i++) {
+ for (int i = 1; i < MAX_TERM_DATA; i++) {
if (data[i].visible) {
- ShowWindow(data[i].w, SW_SHOW);
+ ShowWindow(data[i].w, SW_SHOWNA);
}
}
}
*/
LRESULT PASCAL AngbandListProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- term_data *td;
- PAINTSTRUCT ps;
- td = (term_data *)GetWindowLong(hWnd, 0);
+ term_data *td = (term_data *)GetWindowLong(hWnd, 0);
+ if (handle_window_resize(td, uMsg, wParam, lParam))
+ return 0;
switch (uMsg) {
case WM_NCCREATE: {
case WM_CREATE: {
return 0;
}
- case WM_GETMINMAXINFO: {
- MINMAXINFO *lpmmi;
- RECT rc;
-
- lpmmi = (MINMAXINFO *)lParam;
- if (!td)
- return 1;
-
- rc.left = rc.top = 0;
- rc.right = rc.left + 20 * td->tile_wid + td->size_ow1 + td->size_ow2;
- rc.bottom = rc.top + 3 * td->tile_hgt + td->size_oh1 + td->size_oh2 + 1;
-
- AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
- lpmmi->ptMinTrackSize.x = rc.right - rc.left;
- lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
- return 0;
- }
- case WM_SIZE: {
- if (!td)
- return 1;
- if (!td->w)
- return 1;
- if (td->size_hack)
- return 1;
-
- td->size_hack = TRUE;
-
- TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
- TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
- if ((td->cols != cols) || (td->rows != rows)) {
- term_type *old_term = Term;
- td->cols = cols;
- td->rows = rows;
- term_activate(&td->t);
- term_resize(td->cols, td->rows);
- term_activate(old_term);
- InvalidateRect(td->w, NULL, TRUE);
- p_ptr->window_flags = 0xFFFFFFFF;
- handle_stuff(p_ptr);
- }
-
- td->size_hack = FALSE;
- return 0;
- }
case WM_ERASEBKGND: {
return 1;
}
case WM_PAINT: {
- BeginPaint(hWnd, &ps);
+ PAINTSTRUCT ps;
+ HDC hdc = BeginPaint(hWnd, &ps);
if (td)
- term_data_redraw(td);
+ if (!td->render(ps.rcPaint)) {
+ SetBkColor(hdc, RGB(0, 0, 0));
+ ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &ps.rcPaint, NULL, 0, NULL);
+ }
EndPaint(hWnd, &ps);
return 0;
}
break;
}
case WM_CHAR: {
+ // wParam is WCHAR because using RegisterClassW
if (term_no_press)
- term_no_press = FALSE;
- else
- term_keypress(wParam);
+ term_no_press = false;
+ else {
+ WCHAR wc[2] = { (WCHAR)wParam, '\0' };
+ term_keypress(to_multibyte(wc).c_str());
+ }
return 0;
}
case WM_NCLBUTTONDOWN: {
if (wParam == HTSYSMENU) {
if (td->visible) {
- td->visible = FALSE;
+ td->visible = false;
ShowWindow(td->w, SW_HIDE);
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
-/*
- * Display warning message (see "z-util.c")
- */
-static void hack_plog(concptr str)
-{
- if (str) {
- MessageBoxW(NULL, to_wchar(str).wc_str(), _(L"警告!", L"Warning"), MB_ICONEXCLAMATION | MB_OK);
- }
-}
-
-/*
- * Display error message and quit (see "z-util.c")
- */
-static void hack_quit(concptr str)
-{
- if (str) {
- MessageBoxW(NULL, to_wchar(str).wc_str(), _(L"エラー!", L"Error"), MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
- }
-
- UnregisterClass(AppName, hInstance);
- if (hIcon)
- DestroyIcon(hIcon);
-
- exit(0);
-}
-
-/*
- * Display warning message (see "z-util.c")
+/*!
+ * @brief Display warning message (see "z-util.c")
*/
static void hook_plog(concptr str)
{
}
}
-/*
- * Display error message and quit (see "z-util.c")
+/*!
+ * @brief Display error message and quit (see "z-util.c")
*/
static void hook_quit(concptr str)
{
data[i].w = 0;
}
- infGraph.delete_bitmap();
- infMask.delete_bitmap();
-
DeleteObject(hbrYellow);
finalize_bg();
- finalize_graphics();
+ graphic.finalize();
- UnregisterClass(AppName, hInstance);
+ UnregisterClassW(AppName, hInstance);
if (hIcon)
DestroyIcon(hIcon);
exit(0);
}
-/*
- * Init some stuff
+/*!
+ * @brief Init some stuff
*/
static void init_stuff(void)
{
- char path[1024];
- GetModuleFileName(hInstance, path, 512);
- argv0 = path;
- strcpy(path + strlen(path) - 4, ".INI");
+ char path[MAIN_WIN_MAX_PATH];
+ DWORD path_len = GetModuleFileNameA(hInstance, path, MAIN_WIN_MAX_PATH);
+ strcpy(path + path_len - 4, ".INI");
ini_file = string_make(path);
- int i = strlen(path);
+ int i = path_len;
for (; i > 0; i--) {
if (path[i] == '\\') {
break;
}
strcpy(path + i + 1, "lib\\");
- validate_dir(path, TRUE);
+ validate_dir(path, true);
init_file_paths(path, path);
- validate_dir(ANGBAND_DIR_APEX, FALSE);
- validate_dir(ANGBAND_DIR_BONE, FALSE);
+ validate_dir(ANGBAND_DIR_APEX, false);
+ validate_dir(ANGBAND_DIR_BONE, false);
if (!check_dir(ANGBAND_DIR_EDIT)) {
- validate_dir(ANGBAND_DIR_DATA, TRUE);
+ validate_dir(ANGBAND_DIR_DATA, true);
} else {
- validate_dir(ANGBAND_DIR_DATA, FALSE);
+ validate_dir(ANGBAND_DIR_DATA, false);
}
- validate_dir(ANGBAND_DIR_FILE, TRUE);
- validate_dir(ANGBAND_DIR_HELP, FALSE);
- validate_dir(ANGBAND_DIR_INFO, FALSE);
- validate_dir(ANGBAND_DIR_PREF, TRUE);
- validate_dir(ANGBAND_DIR_SAVE, FALSE);
- validate_dir(ANGBAND_DIR_DEBUG_SAVE, FALSE);
- validate_dir(ANGBAND_DIR_USER, TRUE);
- validate_dir(ANGBAND_DIR_XTRA, TRUE);
+ validate_dir(ANGBAND_DIR_FILE, true);
+ validate_dir(ANGBAND_DIR_HELP, false);
+ validate_dir(ANGBAND_DIR_INFO, false);
+ validate_dir(ANGBAND_DIR_PREF, true);
+ validate_dir(ANGBAND_DIR_SAVE, false);
+ validate_dir(ANGBAND_DIR_DEBUG_SAVE, false);
+ validate_dir(ANGBAND_DIR_USER, true);
+ validate_dir(ANGBAND_DIR_XTRA, true);
path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
validate_file(path);
path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
ANGBAND_DIR_XTRA_GRAF = string_make(path);
- validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
+ validate_dir(ANGBAND_DIR_XTRA_GRAF, true);
path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
ANGBAND_DIR_XTRA_SOUND = string_make(path);
- validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
+ validate_dir(ANGBAND_DIR_XTRA_SOUND, false);
path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
ANGBAND_DIR_XTRA_MUSIC = string_make(path);
- validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
+ validate_dir(ANGBAND_DIR_XTRA_MUSIC, false);
+
+ for (i = 0; special_key_list[i]; ++i) {
+ special_key[special_key_list[i]] = true;
+ }
+
+ for (i = 0; ignore_key_list[i]; ++i) {
+ ignore_key[ignore_key_list[i]] = true;
+ }
+
+ ANGBAND_SYS = "win";
+ if (7 != GetKeyboardType(0))
+ ANGBAND_KEYBOARD = "0";
+ else {
+ switch (GetKeyboardType(1)) {
+ case 0x0D01:
+ case 0x0D02:
+ case 0x0D03:
+ case 0x0D04:
+ case 0x0D05:
+ case 0x0D06:
+ /* NEC PC-98x1 */
+ ANGBAND_KEYBOARD = "NEC98";
+ break;
+ default:
+ /* PC/AT */
+ ANGBAND_KEYBOARD = "JAPAN";
+ }
+ }
}
/*!
- * @brief コマンドラインから全スポイラー出力を行う
- * Create Spoiler files from Command Line
- * @return spoiler_output_status
+ * @brief 全スポイラー出力を行う
+ * Create Spoiler files
+ * @details スポイラー出力処理の成功、失敗に関わらずプロセスを終了する。
*/
-static spoiler_output_status create_debug_spoiler(LPSTR cmd_line)
+void create_debug_spoiler(void)
{
- char *s;
- concptr option;
- s = cmd_line;
- if (!*s)
- return SPOILER_OUTPUT_CANCEL;
- option = "--output-spoilers";
+ init_stuff();
+ init_angband(p_ptr, true);
- if (strncmp(s, option, strlen(option)) != 0)
- return SPOILER_OUTPUT_CANCEL;
+ switch (output_all_spoilers()) {
+ case spoiler_output_status::SPOILER_OUTPUT_SUCCESS:
+ fprintf(stdout, "Successfully created a spoiler file.");
+ case spoiler_output_status::SPOILER_OUTPUT_FAIL_FOPEN:
+ fprintf(stderr, "Cannot create spoiler file.");
+ case spoiler_output_status::SPOILER_OUTPUT_FAIL_FCLOSE:
+ fprintf(stderr, "Cannot close spoiler file.");
+ default:
+ break;
+ }
- init_stuff();
- init_angband(p_ptr, TRUE);
+ quit(NULL);
+}
- return output_all_spoilers();
+/*!
+ * @brief メインウインドウ、サブウインドウのウインドウクラス登録
+ */
+static void register_wndclass(void)
+{
+ WNDCLASSW wc{};
+ wc.style = CS_CLASSDC;
+ wc.lpfnWndProc = AngbandWndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 4;
+ wc.hInstance = hInstance;
+ wc.hIcon = hIcon = LoadIconW(hInstance, AppName);
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = NULL;
+ wc.lpszMenuName = AppName;
+ wc.lpszClassName = AppName;
+
+ if (!RegisterClassW(&wc))
+ exit(1);
+
+ wc.lpfnWndProc = AngbandListProc;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = AngList;
+
+ if (!RegisterClassW(&wc))
+ exit(2);
}
/*!
* @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
*/
-int WINAPI WinMain(_In_ HINSTANCE hInst, _In_opt_ HINSTANCE hPrevInst, _In_ LPSTR lpCmdLine, [[maybe_unused]] _In_ int nCmdShow)
+int WINAPI WinMain(
+ _In_ HINSTANCE hInst, [[maybe_unused]] _In_opt_ HINSTANCE hPrevInst, [[maybe_unused]] _In_ LPSTR lpCmdLine, [[maybe_unused]] _In_ int nCmdShow)
{
setlocale(LC_ALL, "ja_JP");
hInstance = hInst;
if (is_already_running()) {
MessageBoxW(
NULL, _(L"変愚蛮怒はすでに起動しています。", L"Hengband is already running."), _(L"エラー!", L"Error"), MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
- return FALSE;
- }
-
- switch (create_debug_spoiler(lpCmdLine)) {
- case SPOILER_OUTPUT_SUCCESS:
- fprintf(stdout, "Successfully created a spoiler file.");
- quit(NULL);
- return 0;
- case SPOILER_OUTPUT_FAIL_FOPEN:
- fprintf(stderr, "Cannot create spoiler file.");
- quit(NULL);
return 0;
- case SPOILER_OUTPUT_FAIL_FCLOSE:
- fprintf(stderr, "Cannot close spoiler file.");
- quit(NULL);
- return 0;
- default:
- break;
}
- if (hPrevInst == NULL) {
- WNDCLASS wc;
- wc.style = CS_CLASSDC;
- wc.lpfnWndProc = AngbandWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 4;
- wc.hInstance = hInst;
- wc.hIcon = hIcon = LoadIcon(hInst, AppName);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = NULL;
- wc.lpszMenuName = AppName;
- wc.lpszClassName = AppName;
+ command_line.handle();
+ register_wndclass();
- if (!RegisterClass(&wc))
- exit(1);
-
- wc.lpfnWndProc = AngbandListProc;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = AngList;
+ // before term_data initialize
+ plog_aux = [](concptr str) {
+ if (str)
+ MessageBoxW(NULL, to_wchar(str).wc_str(), _(L"警告!", L"Warning"), MB_ICONEXCLAMATION | MB_OK);
+ };
+ quit_aux = [](concptr str) {
+ if (str) {
+ MessageBoxW(NULL, to_wchar(str).wc_str(), _(L"エラー!", L"Error"), MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
+ }
- if (!RegisterClass(&wc))
- exit(2);
- }
+ UnregisterClassW(AppName, hInstance);
+ if (hIcon)
+ DestroyIcon(hIcon);
- plog_aux = hack_plog;
- quit_aux = hack_quit;
- core_aux = hack_quit;
+ exit(0);
+ };
+ core_aux = quit_aux;
init_stuff();
- for (int i = 0; special_key_list[i]; ++i) {
- special_key[special_key_list[i]] = TRUE;
- }
-
- for (int i = 0; ignore_key_list[i]; ++i) {
- ignore_key[ignore_key_list[i]] = TRUE;
- }
HDC hdc = GetDC(NULL);
if (GetDeviceCaps(hdc, BITSPIXEL) <= 8) {
refresh_color_table();
init_windows();
+ change_graphics_mode(static_cast<graphics_mode>(arg_graphics));
change_bg_mode(current_bg_mode, true);
+ // after term_data initialize
plog_aux = hook_plog;
quit_aux = hook_quit;
core_aux = hook_quit;
- ANGBAND_SYS = "win";
- if (7 != GetKeyboardType(0))
- ANGBAND_KEYBOARD = "0";
- else {
- switch (GetKeyboardType(1)) {
- case 0x0D01:
- case 0x0D02:
- case 0x0D03:
- case 0x0D04:
- case 0x0D05:
- case 0x0D06:
- /* NEC PC-98x1 */
- ANGBAND_KEYBOARD = "NEC98";
- break;
- default:
- /* PC/AT */
- ANGBAND_KEYBOARD = "JAPAN";
- }
- }
-
signals_init();
term_activate(term_screen);
- init_angband(p_ptr, FALSE);
- initialized = TRUE;
- check_for_save_file(p_ptr, lpCmdLine);
+ init_angband(p_ptr, false);
+ initialized = true;
+
+ check_for_save_file(command_line.get_savefile_option());
prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
term_fresh();
init_music();
}
+ // ユーザーがゲーム開始を選択するまで待つループ
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
+ if (game_in_progress || movie_in_progress)
+ break;
+ }
+
+ term_flush();
+ if (movie_in_progress) {
+ // selected movie
+ play_game(p_ptr, false, true);
+ } else if (savefile[0] == '\0') {
+ // new game
+ play_game(p_ptr, true, false);
+ } else {
+ // selected savefile
+ play_game(p_ptr, false, false);
}
quit(NULL);