#include "wizard/spoiler-util.h"
#include "wizard/wizard-spoiler.h"
#include "world/world.h"
-
+#include <algorithm>
+#include <commdlg.h>
#include <cstdlib>
+#include <direct.h>
#include <locale>
#include <string>
+#include <string_view>
#include <vector>
-#include <commdlg.h>
-#include <direct.h>
-
/*
* Window names
*/
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]);
+ return td == &data[0];
}
static term_data *my_td; //!< Hack -- global "window creation" pointer
POINT normsize; //!< Remember normal size of main window when maxmized
/* bg */
bg_mode current_bg_mode = bg_mode::BG_NONE;
#define DEFAULT_BG_FILENAME "bg.bmp"
-char wallpaper_file[MAIN_WIN_MAX_PATH] = ""; //!< 壁紙ファイル名。
+std::filesystem::path wallpaper_path = ""; //!< 壁紙ファイル名。
/*
* Show sub-windows even when Hengband is not in focus
/*!
* @brief Validate a file
*/
-static void validate_file(concptr s)
+static void validate_file(const std::filesystem::path &s)
{
- if (check_file(s))
+ if (std::filesystem::is_regular_file(s)) {
return;
+ }
- quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
+ const auto &file = s.string();
+ quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), file.data());
}
/*!
* @brief Validate a directory
*/
-static void validate_dir(concptr s, bool vital)
+static void validate_dir(const std::filesystem::path &s, bool vital)
{
- if (check_dir(s))
+ if (std::filesystem::is_directory(s)) {
return;
+ }
+ const auto &dir = s.string();
if (vital) {
- quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
- } else if (mkdir(s)) {
- quit_fmt("Unable to create directory:\n%s", s);
+ quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), dir.data());
+ } else if (mkdir(dir.data())) {
+ quit_fmt("Unable to create directory:\n%s", dir.data());
}
}
*/
static void term_getsize(term_data *td)
{
- if (td->cols < 1)
+ if (td->cols < 1) {
td->cols = 1;
- if (td->rows < 1)
+ }
+ if (td->rows < 1) {
td->rows = 1;
+ }
TERM_LEN wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2;
TERM_LEN hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2;
GAME_TEXT sec_name[128];
char buf[1024];
- if (!td->w)
+ if (!td->w) {
return;
+ }
wsprintfA(sec_name, "Term-%d", i);
GetWindowPlacement(td->w, &lpwndpl);
RECT rc = lpwndpl.rcNormalPosition;
- if (i == 0)
+ if (i == 0) {
wsprintfA(buf, "%d", normsize.x);
- else
+ } else {
wsprintfA(buf, "%d", td->cols);
+ }
WritePrivateProfileStringA(sec_name, "NumCols", buf, ini_file);
- if (i == 0)
+ if (i == 0) {
wsprintfA(buf, "%d", normsize.y);
- else
+ } else {
wsprintfA(buf, "%d", td->rows);
+ }
WritePrivateProfileStringA(sec_name, "NumRows", buf, ini_file);
if (i == 0) {
strcpy(buf, arg_sound ? "1" : "0");
WritePrivateProfileStringA("Angband", "Sound", buf, ini_file);
+ WritePrivateProfileStringA("Angband", "SoundVolumeTableIndex", std::to_string(arg_sound_volume_table_index).data(), ini_file);
strcpy(buf, arg_music ? "1" : "0");
WritePrivateProfileStringA("Angband", "Music", buf, ini_file);
strcpy(buf, use_pause_music_inactive ? "1" : "0");
+ WritePrivateProfileStringA("Angband", "MusicVolumeTableIndex", std::to_string(arg_music_volume_table_index).data(), ini_file);
WritePrivateProfileStringA("Angband", "MusicPauseInactive", buf, 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] = "";
- strncat(tmp, ANGBAND_DIR, path_length);
-
- int n = strncmp(tmp, savefile, path_length);
- if (n == 0) {
- char relative_path[1024] = "";
- snprintf(relative_path, sizeof(relative_path), ".\\%s", (savefile + path_length));
- WritePrivateProfileStringA("Angband", "SaveFile", relative_path, ini_file);
+ const auto &wallpaper_filename = wallpaper_path.string();
+ WritePrivateProfileStringA("Angband", "BackGroundBitmap", !wallpaper_path.empty() ? wallpaper_filename.data() : DEFAULT_BG_FILENAME, ini_file);
+
+ auto angband_dir_str = ANGBAND_DIR.string();
+ const auto path_length = angband_dir_str.length() - 4; // "\lib" を除く.
+ angband_dir_str = angband_dir_str.substr(0, path_length);
+ const auto savefile_str = savefile.string();
+ if (angband_dir_str == savefile_str) {
+ const auto relative_path = format(".\\%s", (savefile_str.data() + path_length));
+ WritePrivateProfileStringA("Angband", "SaveFile", relative_path.data(), ini_file);
} else {
- WritePrivateProfileStringA("Angband", "SaveFile", savefile, ini_file);
+ WritePrivateProfileStringA("Angband", "SaveFile", savefile_str.data(), ini_file);
}
strcpy(buf, keep_subwindows ? "1" : "0");
/*!
* @brief callback for EnumDisplayMonitors API
*/
-BOOL CALLBACK monitorenumproc([[maybe_unused]] HMONITOR hMon, [[maybe_unused]] HDC hdcMon, [[maybe_unused]] LPRECT lpMon, LPARAM dwDate)
+BOOL CALLBACK monitor_enum_procedure([[maybe_unused]] HMONITOR hMon, [[maybe_unused]] HDC hdcMon, [[maybe_unused]] LPRECT lpMon, LPARAM dwDate)
{
bool *result = (bool *)dwDate;
*result = true;
// 保存座標がモニタ内の領域にあるかチェック
RECT rect = { posx, posy, posx + 128, posy + 128 };
bool in_any_monitor = false;
- ::EnumDisplayMonitors(NULL, &rect, monitorenumproc, (LPARAM)&in_any_monitor);
+ ::EnumDisplayMonitors(NULL, &rect, monitor_enum_procedure, (LPARAM)&in_any_monitor);
if (in_any_monitor) {
// いずれかのモニタに表示可能、ウインドウ位置を復元
td->pos_x = posx;
arg_bigtile = (GetPrivateProfileIntA("Angband", "Bigtile", false, ini_file) != 0);
use_bigtile = arg_bigtile;
arg_sound = (GetPrivateProfileIntA("Angband", "Sound", 0, ini_file) != 0);
+ arg_sound_volume_table_index = std::clamp<int>(GetPrivateProfileIntA("Angband", "SoundVolumeTableIndex", 0, ini_file), 0, SOUND_VOLUME_TABLE.size() - 1);
arg_music = (GetPrivateProfileIntA("Angband", "Music", 0, ini_file) != 0);
+ arg_music_volume_table_index = std::clamp<int>(GetPrivateProfileIntA("Angband", "MusicVolumeTableIndex", 0, ini_file), 0, main_win_music::VOLUME_TABLE.size() - 1);
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) {
- int path_length = strlen(ANGBAND_DIR) - 4; /* \libの4文字分を削除 */
+ char wallpaper_buf[1024]{};
+ GetPrivateProfileStringA("Angband", "BackGroundBitmap", DEFAULT_BG_FILENAME, wallpaper_buf, 1023, ini_file);
+ wallpaper_path = wallpaper_buf;
+ char savefile_buf[1024]{};
+ GetPrivateProfileStringA("Angband", "SaveFile", "", savefile_buf, 1023, ini_file);
+ if (strncmp(".\\", savefile_buf, 2) == 0) {
+ std::string angband_dir_str(ANGBAND_DIR.string());
+ const auto path_length = angband_dir_str.length() - 4; // "\lib" を除く.
+ angband_dir_str = angband_dir_str.substr(0, path_length);
char tmp[1024] = "";
- strncat(tmp, ANGBAND_DIR, path_length);
- strncat(tmp, savefile + 2, strlen(savefile) - 2 + path_length);
- strncpy(savefile, tmp, strlen(tmp));
+ strncat(tmp, angband_dir_str.data(), path_length);
+ strncat(tmp, savefile_buf + 2, std::string_view(savefile_buf).length() - 2 + path_length);
+ savefile = tmp;
+ } else {
+ savefile = savefile_buf;
}
keep_subwindows = (GetPrivateProfileIntA("Angband", "KeepSubwindows", 0, ini_file) != 0);
current_bg_mode = new_mode;
if (current_bg_mode != bg_mode::BG_NONE) {
init_background();
- if (!load_bg(wallpaper_file)) {
+ if (!load_bg(wallpaper_path)) {
current_bg_mode = bg_mode::BG_NONE;
- if (show_error)
- plog_fmt(_("壁紙用ファイル '%s' を読み込めません。", "Can't load the image file '%s'."), wallpaper_file);
+ if (show_error) {
+ const auto &wallaper_filename = wallpaper_path.string();
+ plog_fmt(_("壁紙用ファイル '%s' を読み込めません。", "Can't load the image file '%s'."), wallaper_filename.data());
+ }
}
} else {
delete_bg();
const bool mode_changed = (current_bg_mode != old_bg_mode);
if (mode_changed || force_redraw) {
// 全ウインドウ再描画
- term_type *old = Term;
+ term_type *old = game_term;
for (int i = 0; i < MAX_TERM_DATA; i++) {
term_data *td = &data[i];
if (td->visible) {
term_activate(old);
}
- return (current_bg_mode == new_mode);
+ return current_bg_mode == new_mode;
}
/*!
*/
static void term_window_resize(term_data *td)
{
- if (!td->w)
+ if (!td->w) {
return;
+ }
SetWindowPos(td->w, 0, 0, 0, td->size_wid, td->size_hgt, SWP_NOMOVE | SWP_NOZORDER);
if (!td->size_hack) {
*/
static errr term_force_font(term_data *td)
{
- if (td->font_id)
+ if (td->font_id) {
DeleteObject(td->font_id);
+ }
td->font_id = CreateFontIndirectW(&(td->lf));
int wid = td->lf.lfWidth;
int hgt = td->lf.lfHeight;
- if (!td->font_id)
+ if (!td->font_id) {
return 1;
+ }
if (!wid || !hgt) {
HDC hdcDesktop;
cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;
cf.lpLogFont = &(td->lf);
- if (!ChooseFontW(&cf))
+ if (!ChooseFontW(&cf)) {
return;
+ }
term_force_font(td);
td->tile_wid = td->font_wid;
*/
static void rebuild_term(term_data *td, bool resize_window = true)
{
- term_type *old = Term;
+ term_type *old = game_term;
td->size_hack = true;
term_activate(&td->t);
term_getsize(td);
/*!
* @brief React to global changes
*/
-static errr term_xtra_win_react(player_type *player_ptr)
+static errr term_xtra_win_react(PlayerType *player_ptr)
{
refresh_color_table();
*/
static errr term_xtra_win_clear(void)
{
- term_data *td = (term_data *)(Term->data);
+ term_data *td = (term_data *)(game_term->data);
RECT rc;
GetClientRect(td->w, &rc);
*/
static errr term_xtra_win_sound(int v)
{
- if (!use_sound)
+ if (!use_sound) {
return 1;
- return play_sound(v);
+ }
+ return play_sound(v, SOUND_VOLUME_TABLE[arg_sound_volume_table_index]);
}
/*!
/*!
* @brief Do a "special thing"
- * @todo z-termに影響があるのでplayer_typeの追加は保留
+ * @todo z-termに影響があるのでPlayerTypeの追加は保留
*/
static errr term_xtra_win(int n, int v)
{
switch (n) {
case TERM_XTRA_NOISE: {
- return (term_xtra_win_noise());
+ return term_xtra_win_noise();
}
case TERM_XTRA_FRESH: {
- term_data *td = (term_data *)(Term->data);
- if (td->w)
+ term_data *td = (term_data *)(game_term->data);
+ if (td->w) {
UpdateWindow(td->w);
+ }
return 0;
}
case TERM_XTRA_MUSIC_BASIC:
return term_xtra_win_scene(v);
}
case TERM_XTRA_SOUND: {
- return (term_xtra_win_sound(v));
+ return term_xtra_win_sound(v);
}
case TERM_XTRA_BORED: {
- return (term_xtra_win_event(0));
+ return term_xtra_win_event(0);
}
case TERM_XTRA_EVENT: {
- return (term_xtra_win_event(v));
+ return term_xtra_win_event(v);
}
case TERM_XTRA_FLUSH: {
- return (term_xtra_win_flush());
+ return term_xtra_win_flush();
}
case TERM_XTRA_CLEAR: {
- return (term_xtra_win_clear());
+ return term_xtra_win_clear();
}
case TERM_XTRA_REACT: {
- return (term_xtra_win_react(p_ptr));
+ return term_xtra_win_react(p_ptr);
}
case TERM_XTRA_DELAY: {
- return (term_xtra_win_delay(v));
+ return term_xtra_win_delay(v);
}
}
*/
static errr term_curs_win(int x, int y)
{
- term_data *td = (term_data *)(Term->data);
+ term_data *td = (term_data *)(game_term->data);
int tile_wid, tile_hgt;
tile_wid = td->tile_wid;
tile_hgt = td->tile_hgt;
*/
static errr term_bigcurs_win(int x, int y)
{
- term_data *td = (term_data *)(Term->data);
+ term_data *td = (term_data *)(game_term->data);
int tile_wid, tile_hgt;
tile_wid = td->tile_wid;
tile_hgt = td->tile_hgt;
*/
static errr term_wipe_win(int x, int y, int n)
{
- term_data *td = (term_data *)(Term->data);
+ term_data *td = (term_data *)(game_term->data);
RECT rc;
rc.left = x * td->tile_wid + td->size_ow1;
rc.right = rc.left + n * td->tile_wid;
HDC hdc = td->get_hdc();
SetBkColor(hdc, RGB(0, 0, 0));
SelectObject(hdc, td->font_id);
- if (current_bg_mode != bg_mode::BG_NONE)
+ if (current_bg_mode != bg_mode::BG_NONE) {
draw_bg(hdc, &rc);
- else
+ } else {
ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
+ }
td->refresh(&rc);
return 0;
*/
static errr term_text_win(int x, int y, int n, TERM_COLOR a, concptr s)
{
- term_data *td = (term_data *)(Term->data);
+ term_data *td = (term_data *)(game_term->data);
static HBITMAP WALL;
static HBRUSH myBrush, oldBrush;
static HPEN oldPen;
SetTextColor(hdc, win_clr[a]);
SelectObject(hdc, td->font_id);
- if (current_bg_mode != bg_mode::BG_NONE)
+ if (current_bg_mode != bg_mode::BG_NONE) {
SetBkMode(hdc, TRANSPARENT);
+ }
ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
- if (current_bg_mode != bg_mode::BG_NONE)
+ if (current_bg_mode != bg_mode::BG_NONE) {
draw_bg(hdc, &rc);
+ }
rc.left += ((td->tile_wid - td->font_wid) / 2);
rc.right = rc.left + td->font_wid;
to_wchar wc(tmp);
const auto *buf = wc.wc_str();
rc.right += td->font_wid;
- if (buf == NULL)
+ if (buf == NULL) {
ExtTextOutA(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, s + i, 2, NULL);
- else
+ } 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;
*/
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)
{
- term_data *td = (term_data *)(Term->data);
+ term_data *td = (term_data *)(game_term->data);
int i;
HDC hdcMask = NULL;
if (!use_graphics) {
- return (term_wipe_win(x, y, n));
+ return term_wipe_win(x, y, n);
}
const tile_info &infGraph = graphic.get_tile_info();
w2 = td->tile_wid;
h2 = td->tile_hgt;
tw2 = w2;
- if (use_bigtile)
+ if (use_bigtile) {
tw2 *= 2;
+ }
TERM_LEN x2 = x * w2 + td->size_ow1 + infGraph.OffsetX;
TERM_LEN y2 = y * h2 + td->size_oh1 + infGraph.OffsetY;
*td = {};
td->name = win_term_name[0];
- td->rows = 24;
- td->cols = 80;
+ td->rows = MAIN_TERM_MIN_ROWS;
+ td->cols = MAIN_TERM_MIN_COLS;
td->visible = true;
td->size_ow1 = 2;
td->size_ow2 = 2;
td = &data[i];
*td = {};
td->name = win_term_name[i];
- td->rows = 24;
- td->cols = 80;
+ td->rows = TERM_DEFAULT_ROWS;
+ td->cols = TERM_DEFAULT_COLS;
td->visible = false;
td->size_ow1 = 1;
td->size_ow2 = 1;
td->lf.lfCharSet = _(SHIFTJIS_CHARSET, DEFAULT_CHARSET);
td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
term_force_font(td);
- if (!td->tile_wid)
+ if (!td->tile_wid) {
td->tile_wid = td->font_wid;
- if (!td->tile_hgt)
+ }
+ if (!td->tile_hgt) {
td->tile_hgt = td->font_hgt;
+ }
term_getsize(td);
term_window_resize(td);
}
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)
+ if (!td->w) {
quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
+ }
td->size_hack = true;
term_getsize(td);
td->size_hack = false;
term_data_link(td);
- angband_term[i] = &td->t;
+ angband_terms[i] = &td->t;
if (td->visible) {
/* Activate the window */
td = &data[0];
my_td = td;
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);
+ 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"));
+ if (!td->w) {
+ quit(_("メインウィンドウの作成に失敗しました", "Failed to create main window"));
+ }
/* Resize */
td->size_hack = true;
td->size_hack = false;
term_data_link(td);
- angband_term[0] = &td->t;
+ angband_terms[0] = &td->t;
normsize.x = td->cols;
normsize.y = td->rows;
- if (win_maximized)
+ if (win_maximized) {
ShowWindow(td->w, SW_SHOWMAXIMIZED);
- else
+ } else {
ShowWindow(td->w, SW_SHOW);
+ }
SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
hbrYellow = CreateSolidBrush(win_clr[TERM_YELLOW]);
CheckMenuItem(hm, IDM_OPTIONS_NEW2_GRAPHICS, (arg_graphics == enum2i(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));
+ CheckMenuRadioItem(hm, IDM_OPTIONS_MUSIC_VOLUME_100, IDM_OPTIONS_MUSIC_VOLUME_010,
+ IDM_OPTIONS_MUSIC_VOLUME_100 + arg_music_volume_table_index, MF_BYCOMMAND);
CheckMenuItem(hm, IDM_OPTIONS_MUSIC_PAUSE_INACTIVE, (use_pause_music_inactive ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(hm, IDM_OPTIONS_SOUND, (arg_sound ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuRadioItem(hm, IDM_OPTIONS_SOUND_VOLUME_100, IDM_OPTIONS_SOUND_VOLUME_010,
+ IDM_OPTIONS_SOUND_VOLUME_100 + arg_sound_volume_table_index, MF_BYCOMMAND);
CheckMenuItem(hm, IDM_OPTIONS_NO_BG, ((current_bg_mode == bg_mode::BG_NONE) ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(hm, IDM_OPTIONS_BG, ((current_bg_mode == bg_mode::BG_ONE) ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(hm, IDM_OPTIONS_PRESET_BG, ((current_bg_mode == bg_mode::BG_PRESET) ? MF_CHECKED : MF_UNCHECKED));
*/
static void check_for_save_file(const std::string &savefile_option)
{
- if (savefile_option.empty())
+ if (savefile_option.empty()) {
return;
+ }
- strcpy(savefile, savefile_option.c_str());
+ savefile = savefile_option;
validate_file(savefile);
game_in_progress = true;
}
/*!
* @brief Process a menu command
*/
-static void process_menus(player_type *player_ptr, WORD wCmd)
+static void process_menus(PlayerType *player_ptr, WORD wCmd)
{
if (!initialized) {
plog(_("まだ初期化中です...", "You cannot do that yet..."));
plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
} else {
game_in_progress = true;
- savefile[0] = '\0';
+ savefile = "";
}
break;
ofn.lpstrFilter = L"Save Files (*.)\0*\0";
ofn.nFilterIndex = 1;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
-
- if (get_open_filename(&ofn, ANGBAND_DIR_SAVE, savefile, MAIN_WIN_MAX_PATH)) {
+ const auto &filename = get_open_filename(&ofn, ANGBAND_DIR_SAVE, savefile, MAIN_WIN_MAX_PATH);
+ if (filename.has_value()) {
+ savefile = filename.value();
validate_file(savefile);
game_in_progress = true;
}
break;
}
case IDM_FILE_SCORE: {
- char buf[1024];
- path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
- highscore_fd = fd_open(buf, O_RDONLY);
+ const auto &path = path_build(ANGBAND_DIR_APEX, "scores.raw");
+ highscore_fd = fd_open(path, O_RDONLY);
if (highscore_fd < 0) {
msg_print("Score file unavailable.");
} else {
ofn.lpstrFilter = L"Angband Movie Files (*.amv)\0*.amv\0";
ofn.nFilterIndex = 1;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
-
- if (get_open_filename(&ofn, ANGBAND_DIR_USER, savefile, MAIN_WIN_MAX_PATH)) {
- prepare_browse_movie_without_path_build(savefile);
+ const auto &filename = get_open_filename(&ofn, ANGBAND_DIR_USER, savefile, MAIN_WIN_MAX_PATH);
+ if (filename.has_value()) {
+ savefile = filename.value();
+ prepare_browse_movie_without_path_build(savefile.string());
movie_in_progress = true;
}
}
case IDM_WINDOW_VIS_6:
case IDM_WINDOW_VIS_7: {
int i = wCmd - IDM_WINDOW_VIS_0;
- if ((i < 0) || (i >= MAX_TERM_DATA))
+ if ((i < 0) || (i >= MAX_TERM_DATA)) {
break;
+ }
td = &data[i];
if (!td->visible) {
case IDM_WINDOW_FONT_6:
case IDM_WINDOW_FONT_7: {
int i = wCmd - IDM_WINDOW_FONT_0;
- if ((i < 0) || (i >= MAX_TERM_DATA))
+ if ((i < 0) || (i >= MAX_TERM_DATA)) {
break;
+ }
td = &data[i];
term_change_font(td);
case IDM_WINDOW_POS_6:
case IDM_WINDOW_POS_7: {
int i = wCmd - IDM_WINDOW_POS_0;
- if ((i < 0) || (i >= MAX_TERM_DATA))
+ if ((i < 0) || (i >= MAX_TERM_DATA)) {
break;
+ }
td = &data[i];
if (!td->posfix && td->visible) {
case IDM_WINDOW_I_WID_6:
case IDM_WINDOW_I_WID_7: {
int i = wCmd - IDM_WINDOW_I_WID_0;
- if ((i < 0) || (i >= MAX_TERM_DATA))
+ if ((i < 0) || (i >= MAX_TERM_DATA)) {
break;
+ }
td = &data[i];
td->tile_wid += 1;
case IDM_WINDOW_D_WID_6:
case IDM_WINDOW_D_WID_7: {
int i = wCmd - IDM_WINDOW_D_WID_0;
- if ((i < 0) || (i >= MAX_TERM_DATA))
+ if ((i < 0) || (i >= MAX_TERM_DATA)) {
break;
+ }
td = &data[i];
td->tile_wid -= 1;
case IDM_WINDOW_I_HGT_6:
case IDM_WINDOW_I_HGT_7: {
int i = wCmd - IDM_WINDOW_I_HGT_0;
- if ((i < 0) || (i >= MAX_TERM_DATA))
+ if ((i < 0) || (i >= MAX_TERM_DATA)) {
break;
+ }
td = &data[i];
td->tile_hgt += 1;
case IDM_WINDOW_D_HGT_6:
case IDM_WINDOW_D_HGT_7: {
int i = wCmd - IDM_WINDOW_D_HGT_0;
- if ((i < 0) || (i >= MAX_TERM_DATA))
+ if ((i < 0) || (i >= MAX_TERM_DATA)) {
break;
+ }
td = &data[i];
td->tile_hgt -= 1;
case IDM_OPTIONS_NO_GRAPHICS: {
if (arg_graphics != enum2i(graphics_mode::GRAPHICS_NONE)) {
arg_graphics = enum2i(graphics_mode::GRAPHICS_NONE);
- if (game_in_progress)
+ if (game_in_progress) {
do_cmd_redraw(player_ptr);
+ }
}
break;
}
case IDM_OPTIONS_OLD_GRAPHICS: {
if (arg_graphics != enum2i(graphics_mode::GRAPHICS_ORIGINAL)) {
arg_graphics = enum2i(graphics_mode::GRAPHICS_ORIGINAL);
- if (game_in_progress)
+ if (game_in_progress) {
do_cmd_redraw(player_ptr);
+ }
}
break;
case IDM_OPTIONS_NEW_GRAPHICS: {
if (arg_graphics != enum2i(graphics_mode::GRAPHICS_ADAM_BOLT)) {
arg_graphics = enum2i(graphics_mode::GRAPHICS_ADAM_BOLT);
- if (game_in_progress)
+ if (game_in_progress) {
do_cmd_redraw(player_ptr);
+ }
}
break;
case IDM_OPTIONS_NEW2_GRAPHICS: {
if (arg_graphics != enum2i(graphics_mode::GRAPHICS_HENGBAND)) {
arg_graphics = enum2i(graphics_mode::GRAPHICS_HENGBAND);
- if (game_in_progress)
+ if (game_in_progress) {
do_cmd_redraw(player_ptr);
+ }
}
break;
use_music = arg_music;
if (use_music) {
init_music();
- if (game_in_progress)
+ if (game_in_progress) {
select_floor_music(player_ptr);
+ }
} else {
main_win_music::stop_music();
}
break;
}
+ case IDM_OPTIONS_MUSIC_VOLUME_100:
+ case IDM_OPTIONS_MUSIC_VOLUME_090:
+ case IDM_OPTIONS_MUSIC_VOLUME_080:
+ case IDM_OPTIONS_MUSIC_VOLUME_070:
+ case IDM_OPTIONS_MUSIC_VOLUME_060:
+ case IDM_OPTIONS_MUSIC_VOLUME_050:
+ case IDM_OPTIONS_MUSIC_VOLUME_040:
+ case IDM_OPTIONS_MUSIC_VOLUME_030:
+ case IDM_OPTIONS_MUSIC_VOLUME_020:
+ case IDM_OPTIONS_MUSIC_VOLUME_010: {
+ arg_music_volume_table_index = wCmd - IDM_OPTIONS_MUSIC_VOLUME_100;
+ if (use_music) {
+ main_win_music::set_music_volume(main_win_music::VOLUME_TABLE[arg_music_volume_table_index]);
+ }
+ break;
+ }
case IDM_OPTIONS_MUSIC_PAUSE_INACTIVE: {
use_pause_music_inactive = !use_pause_music_inactive;
break;
}
case IDM_OPTIONS_OPEN_MUSIC_DIR: {
- std::vector<char> buf(MAIN_WIN_MAX_PATH);
- path_build(&buf[0], MAIN_WIN_MAX_PATH, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
- open_dir_in_explorer(&buf[0]);
+ const auto &path = path_build(ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
+ open_dir_in_explorer(path.string());
break;
}
case IDM_OPTIONS_SOUND: {
change_sound_mode(arg_sound);
break;
}
+ case IDM_OPTIONS_SOUND_VOLUME_100:
+ case IDM_OPTIONS_SOUND_VOLUME_090:
+ case IDM_OPTIONS_SOUND_VOLUME_080:
+ case IDM_OPTIONS_SOUND_VOLUME_070:
+ case IDM_OPTIONS_SOUND_VOLUME_060:
+ case IDM_OPTIONS_SOUND_VOLUME_050:
+ case IDM_OPTIONS_SOUND_VOLUME_040:
+ case IDM_OPTIONS_SOUND_VOLUME_030:
+ case IDM_OPTIONS_SOUND_VOLUME_020:
+ case IDM_OPTIONS_SOUND_VOLUME_010: {
+ arg_sound_volume_table_index = wCmd - IDM_OPTIONS_SOUND_VOLUME_100;
+ break;
+ }
case IDM_OPTIONS_OPEN_SOUND_DIR: {
- std::vector<char> buf(MAIN_WIN_MAX_PATH);
- path_build(&buf[0], MAIN_WIN_MAX_PATH, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
- open_dir_in_explorer(&buf[0]);
+ const auto &path = path_build(ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
+ open_dir_in_explorer(path.string());
break;
}
case IDM_OPTIONS_NO_BG: {
break;
}
case IDM_OPTIONS_BG: {
- if (change_bg_mode(bg_mode::BG_ONE))
+ if (change_bg_mode(bg_mode::BG_ONE)) {
break;
+ }
// 壁紙の設定に失敗した(ファイルが存在しない等)場合、壁紙に使うファイルを選択させる
}
- [[fallthrough]]; /* Fall through */
+ [[fallthrough]];
case IDM_OPTIONS_OPEN_BG: {
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.nFilterIndex = 1;
ofn.lpstrTitle = _(L"壁紙を選んでね。", L"Choose wall paper.");
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
-
- if (get_open_filename(&ofn, nullptr, wallpaper_file, MAIN_WIN_MAX_PATH)) {
+ const auto &filename = get_open_filename(&ofn, "", wallpaper_path, MAIN_WIN_MAX_PATH);
+ if (filename.has_value()) {
+ wallpaper_path = filename.value();
change_bg_mode(bg_mode::BG_ONE, true, true);
}
break;
static errr term_keypress(int k)
{
/* Refuse to enqueue non-keys */
- if (!k)
+ if (!k) {
return -1;
+ }
/* Store the char, advance the queue */
- Term->key_queue[Term->key_head++] = (char)k;
+ game_term->key_queue[game_term->key_head++] = (char)k;
/* Circular queue, handle wrap */
- if (Term->key_head == Term->key_size)
- Term->key_head = 0;
+ if (game_term->key_head == game_term->key_size) {
+ game_term->key_head = 0;
+ }
- if (Term->key_head != Term->key_tail)
+ if (game_term->key_head != game_term->key_tail) {
return 0;
+ }
return 1;
}
bool numpad = false;
term_keypress(31);
- if (mc)
+ if (mc) {
term_keypress('C');
- if (ms)
+ }
+ if (ms) {
term_keypress('S');
- if (ma)
+ }
+ if (ma) {
term_keypress('A');
+ }
int i = LOBYTE(HIWORD(lParam));
term_keypress('x');
switch (wParam) {
case VK_DIVIDE:
term_no_press = true;
- [[fallthrough]]; /* Fall through */
+ [[fallthrough]];
case VK_RETURN:
numpad = ext_key;
break;
case VK_SEPARATOR:
case VK_DECIMAL:
term_no_press = true;
- [[fallthrough]]; /* Fall through */
+ [[fallthrough]];
case VK_CLEAR:
case VK_HOME:
case VK_END:
numpad = !ext_key;
}
- if (numpad)
+ if (numpad) {
term_keypress('K');
+ }
term_keypress(hexsym[i / 16]);
term_keypress(hexsym[i % 16]);
switch (uMsg) {
case WM_ACTIVATEAPP: {
if (wParam) {
- if (use_pause_music_inactive)
+ if (use_pause_music_inactive) {
main_win_music::resume_music();
+ }
} else {
- if (use_pause_music_inactive)
+ if (use_pause_music_inactive) {
main_win_music::pause_music();
+ }
}
break;
}
case WM_WINDOWPOSCHANGING: {
- if (!IsIconic(hWnd))
- if (use_pause_music_inactive)
+ if (!IsIconic(hWnd)) {
+ if (use_pause_music_inactive) {
main_win_music::resume_music();
+ }
+ }
break;
}
}
handle_stuff(p_ptr);
}
}
-}
+}
/*!
* @brief Windowのリサイズをハンドリング
*/
static bool handle_window_resize(term_data *td, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- if (!td)
+ if (!td) {
return false;
- if (!td->w)
+ }
+ 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 int min_cols = (is_main) ? MAIN_TERM_MIN_COLS : 20;
+ const int min_rows = (is_main) ? MAIN_TERM_MIN_ROWS : 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 };
break;
}
case WM_SIZE: {
- if (td->size_hack)
+ 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)
+ if (data[i].visible) {
ShowWindow(data[i].w, SW_HIDE);
+ }
}
return true;
td->size_hack = true;
for (int i = 1; i < MAX_TERM_DATA; i++) {
- if (data[i].visible)
+ if (data[i].visible) {
ShowWindow(data[i].w, SW_SHOWNA);
+ }
}
td->size_hack = false;
/*!
* @brief メインウインドウ用ウインドウプロシージャ
*/
-LRESULT PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+LRESULT PASCAL angband_window_procedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
term_data *td = (term_data *)GetWindowLong(hWnd, 0);
handle_app_active(hWnd, uMsg, wParam, lParam);
- if (handle_window_resize(td, uMsg, wParam, lParam))
+ if (handle_window_resize(td, uMsg, wParam, lParam)) {
return 0;
+ }
switch (uMsg) {
case WM_NCCREATE: {
case WM_PAINT: {
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
- if (td)
+ if (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;
}
case MM_MCINOTIFY: {
- main_win_music::on_mci_notify(wParam, lParam);
+ main_win_music::on_mci_notify(wParam, lParam, main_win_music::VOLUME_TABLE[arg_music_volume_table_index]);
return 0;
}
case WM_SYSKEYDOWN:
case WM_KEYDOWN: {
- if (process_keydown(wParam, lParam))
+ if (process_keydown(wParam, lParam)) {
return 0;
+ }
break;
}
case WM_CHAR: {
// wParam is WCHAR because using RegisterClassW
- if (term_no_press)
+ if (term_no_press) {
term_no_press = false;
- else {
+ } else {
WCHAR wc[2] = { (WCHAR)wParam, '\0' };
term_keypress(to_multibyte(wc).c_str());
}
return 0;
}
case WM_LBUTTONDOWN: {
- if (macro_running())
+ if (macro_running()) {
return 0;
+ }
mousex = std::min(LOWORD(lParam) / td->tile_wid, td->cols - 1);
mousey = std::min(HIWORD(lParam) / td->tile_hgt, td->rows - 1);
mouse_down = true;
return 0;
}
case WM_LBUTTONUP: {
- if (!mouse_down)
+ if (!mouse_down) {
return 0;
+ }
HGLOBAL hGlobal;
LPSTR lpStr;
TERM_LEN dx = abs(oldx - mousex) + 1;
int sz = (dx + 2) * dy;
#endif
hGlobal = GlobalAlloc(GHND, sz + 1);
- if (hGlobal == NULL)
+ if (hGlobal == NULL) {
return 0;
+ }
lpStr = (LPSTR)GlobalLock(hGlobal);
for (int i = 0; i < dy; i++) {
strncpy(s.data(), &scr[oy + i][ox], dx);
if (ox > 0) {
- if (iskanji(scr[oy + i][ox - 1]))
+ if (iskanji(scr[oy + i][ox - 1])) {
s[0] = ' ';
+ }
}
if (ox + dx < data[0].cols) {
- if (iskanji(scr[oy + i][ox + dx - 1]))
+ if (iskanji(scr[oy + i][ox + dx - 1])) {
s[dx - 1] = ' ';
+ }
}
for (int j = 0; j < dx; j++) {
- if (s[j] == 127)
+ if (s[j] == 127) {
s[j] = '#';
+ }
*lpStr++ = s[j];
}
#else
return 0;
}
case WM_MOUSEMOVE: {
- if (!mouse_down)
+ if (!mouse_down) {
return 0;
+ }
int dx, dy;
int cx = std::min(LOWORD(lParam) / td->tile_wid, td->cols - 1);
}
msg_flag = false;
- if (p_ptr->chp < 0)
+ if (p_ptr->chp < 0) {
p_ptr->is_dead = false;
+ }
exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
p_ptr->panic_save = 1;
signals_ignore_tstp();
- (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
- (void)save_player(p_ptr, SAVE_TYPE_CLOSE_GAME);
+ p_ptr->died_from = _("(緊急セーブ)", "(panic save)");
+ (void)save_player(p_ptr, SaveType::CLOSE_GAME);
quit(nullptr);
return 0;
}
return 0;
}
case WM_ACTIVATE: {
- if (!wParam || HIWORD(lParam))
+ if (!wParam || HIWORD(lParam)) {
break;
+ }
for (int i = 1; i < MAX_TERM_DATA; i++) {
- if (!data[i].posfix)
+ if (!data[i].posfix) {
term_window_pos(&data[i], hWnd);
+ }
}
SetFocus(hWnd);
return 0;
}
case WM_ACTIVATEAPP: {
- if (IsIconic(td->w))
+ if (IsIconic(td->w)) {
break;
+ }
for (int i = 1; i < MAX_TERM_DATA; i++) {
if (data[i].visible) {
}
}
}
- [[fallthrough]]; /* Fall through */
+ [[fallthrough]];
case WM_ENABLE: {
if (wParam == FALSE && keep_subwindows) {
for (int i = 1; i < MAX_TERM_DATA; i++) {
LRESULT PASCAL AngbandListProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
term_data *td = (term_data *)GetWindowLong(hWnd, 0);
- if (handle_window_resize(td, uMsg, wParam, lParam))
+ if (handle_window_resize(td, uMsg, wParam, lParam)) {
return 0;
+ }
switch (uMsg) {
case WM_NCCREATE: {
case WM_PAINT: {
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
- if (td)
+ if (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;
}
case WM_SYSKEYDOWN:
case WM_KEYDOWN: {
- if (process_keydown(wParam, lParam))
+ if (process_keydown(wParam, lParam)) {
return 0;
+ }
break;
}
case WM_CHAR: {
// wParam is WCHAR because using RegisterClassW
- if (term_no_press)
+ if (term_no_press) {
term_no_press = false;
- else {
+ } else {
WCHAR wc[2] = { (WCHAR)wParam, '\0' };
term_keypress(to_multibyte(wc).c_str());
}
return 0;
}
case WM_NCLBUTTONDOWN: {
- if (wParam == HTCLOSE)
+ if (wParam == HTCLOSE) {
wParam = HTSYSMENU;
+ }
if (wParam == HTSYSMENU) {
if (td->visible) {
save_prefs();
for (int i = MAX_TERM_DATA - 1; i >= 0; --i) {
term_force_font(&data[i]);
- if (data[i].font_want)
+ if (data[i].font_want) {
string_free(data[i].font_want);
- if (data[i].w)
+ }
+ if (data[i].w) {
DestroyWindow(data[i].w);
+ }
data[i].w = 0;
}
finalize_sound();
UnregisterClassW(AppName, hInstance);
- if (hIcon)
+ if (hIcon) {
DestroyIcon(hIcon);
+ }
exit(0);
}
/*!
* @brief Init some stuff
*/
-static void init_stuff(void)
+static void init_stuff()
{
char path[MAIN_WIN_MAX_PATH];
DWORD path_len = GetModuleFileNameA(hInstance, path, MAIN_WIN_MAX_PATH);
strcpy(path + i + 1, "lib\\");
validate_dir(path, true);
- init_file_paths(path, path);
+ init_file_paths(path);
validate_dir(ANGBAND_DIR_APEX, false);
validate_dir(ANGBAND_DIR_BONE, false);
if (!check_dir(ANGBAND_DIR_EDIT)) {
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"));
+ const auto &path_news = path_build(ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
+ validate_file(path_news);
- validate_file(path);
- path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
- ANGBAND_DIR_XTRA_GRAF = string_make(path);
+ ANGBAND_DIR_XTRA_GRAF = path_build(ANGBAND_DIR_XTRA, "graf");
validate_dir(ANGBAND_DIR_XTRA_GRAF, true);
- path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
- ANGBAND_DIR_XTRA_SOUND = string_make(path);
+ ANGBAND_DIR_XTRA_SOUND = path_build(ANGBAND_DIR_XTRA, "sound");
validate_dir(ANGBAND_DIR_XTRA_SOUND, false);
- path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
- ANGBAND_DIR_XTRA_MUSIC = string_make(path);
+ ANGBAND_DIR_XTRA_MUSIC = path_build(ANGBAND_DIR_XTRA, "music");
validate_dir(ANGBAND_DIR_XTRA_MUSIC, false);
for (i = 0; special_key_list[i]; ++i) {
}
ANGBAND_SYS = "win";
- if (7 != GetKeyboardType(0))
+ if (7 != GetKeyboardType(0)) {
ANGBAND_KEYBOARD = "0";
- else {
+ } else {
switch (GetKeyboardType(1)) {
case 0x0D01:
case 0x0D02:
init_angband(p_ptr, true);
switch (output_all_spoilers()) {
- case spoiler_output_status::SPOILER_OUTPUT_SUCCESS:
+ case SpoilerOutputResultType::SUCCESSFUL:
fprintf(stdout, "Successfully created a spoiler file.");
- case spoiler_output_status::SPOILER_OUTPUT_FAIL_FOPEN:
+ break;
+ case SpoilerOutputResultType::FILE_OPEN_FAILED:
fprintf(stderr, "Cannot create spoiler file.");
- case spoiler_output_status::SPOILER_OUTPUT_FAIL_FCLOSE:
+ break;
+ case SpoilerOutputResultType::FILE_CLOSE_FAILED:
fprintf(stderr, "Cannot close spoiler file.");
+ break;
default:
break;
}
{
WNDCLASSW wc{};
wc.style = CS_CLASSDC;
- wc.lpfnWndProc = AngbandWndProc;
+ wc.lpfnWndProc = angband_window_procedure;
wc.cbClsExtra = 0;
wc.cbWndExtra = 4;
wc.hInstance = hInstance;
wc.lpszMenuName = AppName;
wc.lpszClassName = AppName;
- if (!RegisterClassW(&wc))
+ if (!RegisterClassW(&wc)) {
exit(1);
+ }
wc.lpfnWndProc = AngbandListProc;
wc.lpszMenuName = NULL;
wc.lpszClassName = AngList;
- if (!RegisterClassW(&wc))
+ if (!RegisterClassW(&wc)) {
exit(2);
+ }
}
/*!
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);
+ constexpr auto mes = _(L"変愚蛮怒はすでに起動しています。", L"Hengband is already running.");
+ constexpr auto caption = _(L"エラー!", L"Error");
+ MessageBoxW(NULL, mes, caption, MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
return 0;
}
// before term_data initialize
plog_aux = [](concptr str) {
- if (str)
+ if (str) {
MessageBoxW(NULL, to_wchar(str).wc_str(), _(L"警告!", L"Warning"), MB_ICONEXCLAMATION | MB_OK);
+ }
};
quit_aux = [](concptr str) {
if (str) {
}
UnregisterClassW(AppName, hInstance);
- if (hIcon)
+ if (hIcon) {
DestroyIcon(hIcon);
+ }
exit(0);
};
core_aux = quit_aux;
init_stuff();
-
- HDC hdc = GetDC(NULL);
- if (GetDeviceCaps(hdc, BITSPIXEL) <= 8) {
- quit(_("画面を16ビット以上のカラーモードにして下さい。", "Please switch to High Color (16-bit) or higher color mode."));
- }
- ReleaseDC(NULL, hdc);
-
refresh_color_table();
init_windows();
change_graphics_mode(static_cast<graphics_mode>(arg_graphics));
signals_init();
term_activate(term_screen);
- init_angband(p_ptr, false);
- initialized = true;
+ {
+ TermCenteredOffsetSetter tcos(MAIN_TERM_MIN_COLS, MAIN_TERM_MIN_ROWS);
- check_for_save_file(command_line.get_savefile_option());
- prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
- term_fresh();
+ 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();
+ }
change_sound_mode(arg_sound);
use_music = arg_music;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
- if (game_in_progress || movie_in_progress)
+ 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') {
+ } else if (savefile.empty()) {
// new game
play_game(p_ptr, true, false);
} else {