/*!
- * todo main関数を含むファイルの割に長過ぎる。main-win-utils.cなどといった形で分割したい
* @file main-win.cpp
* @brief Windows版固有実装(メインエントリポイント含む)
* @date 2018/03/16
* @author Hengband Team
+ * @todo main関数を含むファイルの割に長過ぎる。main-win-utils.cなどといった形で分割したい
* @details
*
* <h3>概要</h3>
*/
#ifdef WINDOWS
+
+#include <cstdlib>
+
#include "autopick/autopick-pref-processor.h"
#include "cmd-io/cmd-process-screen.h"
#include "cmd-io/cmd-save.h"
static DIBINIT infMask;
/*
- * Flag set once "sound" has been initialized
- */
-static bool can_use_sound = FALSE;
-
-/*
* Show sub-windows even when Hengband is not in focus
*/
static bool keep_subwindows = TRUE;
/*
- * Flag set once "music" has been initialized
- */
-static bool can_use_music = FALSE;
-
-/*
* Full path to ANGBAND.INI
*/
static concptr ini_file = NULL;
HPALETTE hBmPal = static_cast<HPALETTE>(infGraph.hPalette);
if (hBmPal) {
lppeSize = 256 * sizeof(PALETTEENTRY);
- lppe = (LPPALETTEENTRY)ralloc(lppeSize);
+ lppe = (LPPALETTEENTRY)std::malloc(lppeSize);
nEntries = GetPaletteEntries(hBmPal, 0, 255, lppe);
if ((nEntries == 0) || (nEntries > 220)) {
plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
- rnfree(lppe, lppeSize);
+ std::free(lppe);
return FALSE;
}
}
pLogPalSize = sizeof(LOGPALETTE) + (nEntries + 16) * sizeof(PALETTEENTRY);
- pLogPal = (LPLOGPALETTE)ralloc(pLogPalSize);
+ pLogPal = (LPLOGPALETTE)std::malloc(pLogPalSize);
pLogPal->palVersion = 0x300;
pLogPal->palNumEntries = nEntries + 16;
for (i = 0; i < nEntries; i++) {
}
if (lppe)
- rnfree(lppe, lppeSize);
+ std::free(lppe);
HPALETTE hNewPal = CreatePalette(pLogPal);
if (!hNewPal)
quit(_("パレットを作成できません!", "Cannot create palette!"));
- rnfree(pLogPal, pLogPalSize);
+ std::free(pLogPal);
td = &data[0];
HDC hdc = GetDC(td->w);
SelectPalette(hdc, hNewPal, 0);
*/
static void init_music(void)
{
+ // Flag set once "music" has been initialized
+ static bool can_use_music = FALSE;
+
if (!can_use_music) {
main_win_music::load_music_prefs(current_world_ptr->max_d_idx, max_q_idx);
can_use_music = TRUE;
*/
static void init_sound(void)
{
+ // Flag set once "sound" has been initialized
+ static bool can_use_sound = FALSE;
+
if (!can_use_sound) {
load_sound_prefs();
can_use_sound = TRUE;
}
/*
- * Resize a window
+ * Initialize background
+ */
+static void init_background(void)
+{
+ // Flag set once "background" has been initialized
+ static bool can_use_background = FALSE;
+
+ if (!can_use_background) {
+ load_bg_prefs();
+ can_use_background = TRUE;
+ }
+}
+
+/*!
+ * @brief Resize a window
*/
static void term_window_resize(term_data *td)
{
InvalidateRect(td->w, NULL, TRUE);
}
-/*
- * todo 引数のpathを消す
- * Force the use of a new "font file" for a term_data.
+/*!
+ * @brief Force the use of a new "font file" for a term_data.
* This function may be called before the "window" is ready.
* This function returns zero only if everything succeeds.
- * Note that the "font name" must be capitalized!!!
+ * @note that the "font name" must be capitalized!!!
+ * @todo 引数のpathを消す
*/
static errr term_force_font(term_data *td, concptr path)
{
*/
static errr term_xtra_win_music(int n, int v)
{
- // FIXME use_musicの値に関わらずミュートを実行している
- if (n == TERM_XTRA_MUSIC_MUTE)
- main_win_music::stop_music();
-
if (!use_music) {
return 1;
}
}
/*
+ * Hack -- play a music matches a situation
+ */
+static errr term_xtra_win_scene()
+{
+ // TODO 場面に合った壁紙変更対応
+ if (!use_music) {
+ return 1;
+ }
+
+ return main_win_music::play_music_scene();
+}
+
+/*
* Delay for "x" milliseconds
*/
static int term_xtra_win_delay(int v)
return 0;
}
-/*
- * todo z-termに影響があるのでplayer_typeの追加は保留
- * Do a "special thing"
+/*!
+ * @brief Do a "special thing"
+ * @todo z-termに影響があるのでplayer_typeの追加は保留
*/
static errr term_xtra_win(int n, int v)
{
case TERM_XTRA_MUSIC_BASIC:
case TERM_XTRA_MUSIC_DUNGEON:
case TERM_XTRA_MUSIC_QUEST:
- case TERM_XTRA_MUSIC_TOWN:
+ case TERM_XTRA_MUSIC_TOWN: {
+ return term_xtra_win_music(n, v);
+ }
case TERM_XTRA_MUSIC_MUTE: {
- return (term_xtra_win_music(n, v));
+ return main_win_music::stop_music();
+ }
+ case TERM_XTRA_SCENE: {
+ return term_xtra_win_scene();
}
case TERM_XTRA_SOUND: {
return (term_xtra_win_sound(v));
use_bg = !use_bg;
if (use_bg) {
+ init_background();
use_bg = init_bg();
} else {
delete_bg();
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = data[0].w;
- ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0";
+ ofn.lpstrFilter = "Image Files (*.bmp;*.png;*.jpg;*.jpeg;)\0*.bmp;*.png;*.jpg;*.jpeg;\0";
ofn.nFilterIndex = 1;
ofn.lpstrFile = bg_bitmap_file;
ofn.nMaxFile = 1023;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if (GetOpenFileName(&ofn)) {
+ init_background();
use_bg = init_bg();
}
}
/*!
- * todo WNDCLASSに影響があるのでplayer_type*の追加は保留
+ * @todo WNDCLASSに影響があるのでplayer_type*の追加は保留
*/
LRESULT PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
break;
}
case WM_CREATE: {
- mop.dwCallback = (DWORD)hWnd;
+ setup_mci(hWnd);
return 0;
}
case WM_GETMINMAXINFO: {
return 0;
}
case MM_MCINOTIFY: {
- if (wParam == MCI_NOTIFY_SUCCESSFUL) {
- mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0);
- mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop);
- }
+ main_win_music::on_mci_notify(wParam, lParam);
return 0;
}
if (td->size_hack)
return 1;
- // todo 二重のswitch文。後で分割する.
+ //!< @todo 二重のswitch文。後で分割する.
switch (wParam) {
case SIZE_MINIMIZED: {
for (int i = 1; i < MAX_TERM_DATA; i++) {
}
/*!
- * todo WNDCLASSに影響があるのでplayer_type*の追加は保留
+ * @todo WNDCLASSに影響があるのでplayer_type*の追加は保留
*/
LRESULT PASCAL AngbandListProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
DeleteObject(infMask.hBitmap);
DeleteObject(hbrYellow);
- delete_bg();
+ finalize_bg();
if (hPal)
DeleteObject(hPal);
}
/*!
- * todo よく見るとhMutexはちゃんと使われていない……?
+ * @todo よく見るとhMutexはちゃんと使われていない……?
* @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
*/
static bool is_already_running(void)
init_windows();
if (use_bg) {
+ init_background();
use_bg = init_bg();
}