static bool process_keydown(WPARAM wParam, LPARAM lParam)
{
- int i;
bool mc = FALSE;
bool ms = FALSE;
bool ma = FALSE;
term_no_press = (ma) ? TRUE : FALSE;
- /* Handle "special" keys */
if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]))
{
bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
bool numpad = FALSE;
- /* Begin the macro trigger */
Term_keypress(31);
-
- /* Send the modifiers */
if (mc) Term_keypress('C');
if (ms) Term_keypress('S');
if (ma) Term_keypress('A');
- /* Extract "scan code" */
- i = LOBYTE(HIWORD(lParam));
-
- /* Introduce the scan code */
+ int i = LOBYTE(HIWORD(lParam));
Term_keypress('x');
-
- /* Extended key bit */
switch (wParam)
{
- /* Numpad Enter and '/' are extended key */
case VK_DIVIDE:
term_no_press = TRUE;
- case VK_RETURN: /* Enter */
+ case VK_RETURN:
numpad = ext_key;
break;
- /* Other extended keys are on full keyboard */
case VK_NUMPAD0:
case VK_NUMPAD1:
case VK_NUMPAD2:
case VK_CLEAR:
case VK_HOME:
case VK_END:
- case VK_PRIOR: /* Page Up */
- case VK_NEXT: /* Page Down */
+ case VK_PRIOR:
+ case VK_NEXT:
case VK_INSERT:
case VK_DELETE:
case VK_UP:
numpad = !ext_key;
}
- /* Special modifiers for keypad keys */
if (numpad) Term_keypress('K');
- /* Encode the hexidecimal scan code */
Term_keypress(hexsym[i / 16]);
Term_keypress(hexsym[i % 16]);
-
- /* End the macro trigger */
Term_keypress(13);
return 1;
PAINTSTRUCT ps;
HDC hdc;
term_data *td;
- int i;
-
-
- /* Acquire proper "term_data" info */
td = (term_data *)GetWindowLong(hWnd, 0);
- /* Handle message */
switch (uMsg)
{
case WM_NCCREATE:
SetWindowLong(hWnd, 0, (LONG)(my_td));
break;
}
-
case WM_CREATE:
{
mop.dwCallback = (DWORD)hWnd;
return 0;
}
-
case WM_GETMINMAXINFO:
{
MINMAXINFO FAR *lpmmi;
RECT rc;
lpmmi = (MINMAXINFO FAR *)lParam;
-
- /* this message was sent before WM_NCCREATE */
if (!td) return 1;
- /* Minimum window size is 80x24 */
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;
- /* Adjust */
AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
- /* Save minimum size */
lpmmi->ptMinTrackSize.x = rc.right - rc.left;
lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
return 0;
}
-
case WM_PAINT:
{
BeginPaint(hWnd, &ps);
ValidateRect(hWnd, NULL);
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);
}
+
return 0;
}
-
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
{
return 0;
break;
}
-
case WM_CHAR:
{
if (term_no_press) term_no_press = FALSE;
else Term_keypress(wParam);
return 0;
}
-
case WM_LBUTTONDOWN:
{
mousex = MIN(LOWORD(lParam) / td->tile_wid, td->cols - 1);
oldy = mousey;
return 0;
}
-
case WM_LBUTTONUP:
{
HGLOBAL hGlobal;
LPSTR lpStr;
- int j, sz;
TERM_LEN dx = abs(oldx - mousex) + 1;
TERM_LEN dy = abs(oldy - mousey) + 1;
TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
paint_rect = FALSE;
#ifdef JP
- sz = (dx + 3) * dy;
+ int sz = (dx + 3) * dy;
#else
- sz = (dx + 2) * dy;
+ int sz = (dx + 2) * dy;
#endif
hGlobal = GlobalAlloc(GHND, sz + 1);
if (hGlobal == NULL) return 0;
lpStr = (LPSTR)GlobalLock(hGlobal);
- for (i = 0; i < dy; i++)
+ for (int i = 0; i < dy; i++)
{
#ifdef JP
char *s;
if (iskanji(scr[oy + i][ox + dx - 1])) s[dx - 1] = ' ';
}
- for (j = 0; j < dx; j++)
+ for (int j = 0; j < dx; j++)
{
if (s[j] == 127) s[j] = '#';
*lpStr++ = s[j];
return 0;
}
-
case WM_MOUSEMOVE:
{
if (mouse_down)
oldx = cx;
oldy = cy;
}
+
return 0;
}
-
case WM_INITMENU:
{
setup_menus();
return 0;
}
-
case WM_CLOSE:
{
if (game_in_progress && current_world_ptr->character_generated)
return 0;
}
- /* Hack -- Forget messages */
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);
-
Term_key_push(SPECIAL_KEY_QUIT);
return 0;
}
+
quit(NULL);
return 0;
}
-
case WM_QUERYENDSESSION:
{
if (game_in_progress && current_world_ptr->character_generated)
{
- /* Hack -- Forget messages */
msg_flag = FALSE;
-
- /* Mega-Hack -- Delay death */
if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
- /* Hardcode panic save */
p_ptr->panic_save = 1;
-
- /* Forbid suspend */
signals_ignore_tstp();
-
- /* Indicate panic save */
(void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
-
- /* Panic save */
(void)save_player(p_ptr);
}
+
quit(NULL);
return 0;
}
-
case WM_QUIT:
{
quit(NULL);
return 0;
}
-
case WM_COMMAND:
{
process_menus(p_ptr, LOWORD(wParam));
return 0;
}
-
case WM_SIZE:
{
- /* this message was sent before WM_NCCREATE */
if (!td) return 1;
-
- /* it was sent from inside CreateWindowEx */
if (!td->w) return 1;
-
- /* was sent from WM_SIZE */
if (td->size_hack) return 1;
switch (wParam)
case SIZE_MINIMIZED:
{
/* Hide sub-windows */
- for (i = 1; i < MAX_TERM_DATA; i++)
+ for (int i = 1; i < MAX_TERM_DATA; i++)
{
if (data[i].visible) ShowWindow(data[i].w, SW_HIDE);
}
+
return 0;
}
-
case SIZE_MAXIMIZED:
{
/* fall through */
}
-
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;
-
- /* New size */
if ((td->cols != cols) || (td->rows != rows))
{
- /* Save the new size */
td->cols = cols;
td->rows = rows;
-
if (!IsZoomed(td->w) && !IsIconic(td->w))
{
normsize.x = td->cols;
normsize.y = td->rows;
}
- /* Activate */
Term_activate(&td->t);
-
- /* Resize the term */
Term_resize(td->cols, td->rows);
-
- /* Redraw later */
InvalidateRect(td->w, NULL, TRUE);
}
td->size_hack = TRUE;
-
- /* Show sub-windows */
- for (i = 1; i < MAX_TERM_DATA; i++)
+ for (int i = 1; i < MAX_TERM_DATA; i++)
{
if (data[i].visible) ShowWindow(data[i].w, SW_SHOW);
}
return 0;
}
}
+
break;
}
-
case WM_PALETTECHANGED:
{
- /* Ignore if palette change caused by itself */
if ((HWND)wParam == hWnd) return 0;
-
- /* Fall through... */
}
-
case WM_QUERYNEWPALETTE:
{
if (!paletted) return 0;
hdc = GetDC(hWnd);
-
SelectPalette(hdc, hPal, FALSE);
-
- i = RealizePalette(hdc);
-
- /* if any palette entries changed, repaint the window. */
+ int i = RealizePalette(hdc);
if (i) InvalidateRect(hWnd, NULL, TRUE);
ReleaseDC(hWnd, hdc);
-
return 0;
}
-
case WM_ACTIVATE:
{
if (wParam && !HIWORD(lParam))
{
- /* Do something to sub-windows */
- for (i = 1; i < MAX_TERM_DATA; i++)
+ for (int i = 1; i < MAX_TERM_DATA; i++)
{
if (!data[i].posfix) term_window_pos(&data[i], hWnd);
}
- /* Focus on main window */
SetFocus(hWnd);
-
return 0;
}
break;
}
-
case WM_ACTIVATEAPP:
{
if (IsIconic(td->w)) break;
- for (i = 1; i < MAX_TERM_DATA; i++)
+ for (int i = 1; i < MAX_TERM_DATA; i++)
{
if (data[i].visible)
{
term_data *td;
PAINTSTRUCT ps;
HDC hdc;
- int i;
-
-
- /* Acquire proper "term_data" info */
td = (term_data *)GetWindowLong(hWnd, 0);
- /* Process message */
switch (uMsg)
{
case WM_NCCREATE:
SetWindowLong(hWnd, 0, (LONG)(my_td));
break;
}
-
case WM_CREATE:
{
return 0;
}
-
case WM_GETMINMAXINFO:
{
MINMAXINFO FAR *lpmmi;
RECT rc;
lpmmi = (MINMAXINFO FAR *)lParam;
-
- /* this message was sent before WM_NCCREATE */
if (!td) return 1;
- /* Minimum window size is 80x24 */
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;
- /* Adjust */
AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle);
-
- /* Save minimum size */
lpmmi->ptMinTrackSize.x = rc.right - rc.left;
lpmmi->ptMinTrackSize.y = rc.bottom - rc.top;
return 0;
}
-
case WM_SIZE:
{
- TERM_LEN cols;
- TERM_LEN rows;
-
- /* this message was sent before WM_NCCREATE */
if (!td) return 1;
-
- /* it was sent from inside CreateWindowEx */
if (!td->w) return 1;
-
- /* was sent from inside WM_SIZE */
if (td->size_hack) return 1;
td->size_hack = TRUE;
- cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
- rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
-
- /* New size */
+ 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))
{
- /* Save old term */
term *old_term = Term;
-
- /* Save the new size */
td->cols = cols;
td->rows = rows;
-
- /* Activate */
Term_activate(&td->t);
-
- /* Resize the term */
Term_resize(td->cols, td->rows);
-
- /* Activate */
Term_activate(old_term);
-
- /* Redraw later */
InvalidateRect(td->w, NULL, TRUE);
-
- /* HACK - Redraw all windows */
p_ptr->window = 0xFFFFFFFF;
handle_stuff(p_ptr);
}
return 0;
}
-
case WM_PAINT:
{
BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
return 0;
}
-
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
{
return 0;
break;
}
-
case WM_CHAR:
{
if (term_no_press) term_no_press = FALSE;
else Term_keypress(wParam);
return 0;
}
-
case WM_PALETTECHANGED:
{
- /* ignore if palette change caused by itself */
if ((HWND)wParam == hWnd) return FALSE;
- /* otherwise, fall through!!! */
}
-
case WM_QUERYNEWPALETTE:
{
if (!paletted) return 0;
hdc = GetDC(hWnd);
SelectPalette(hdc, hPal, FALSE);
- i = RealizePalette(hdc);
- /* if any palette entries changed, repaint the window. */
+ int i = RealizePalette(hdc);
if (i) InvalidateRect(hWnd, NULL, TRUE);
ReleaseDC(hWnd, hdc);
return 0;
}
-
case WM_NCLBUTTONDOWN:
{
-
#ifdef HTCLOSE
if (wParam == HTCLOSE) wParam = HTSYSMENU;
#endif /* HTCLOSE */
static WORD xMouse = 0;
static WORD yMouse = 0;
- int dx, dy;
-
-
- /* Process */
switch (uMsg)
{
case WM_NCCREATE:
SendMessage(hWnd, WM_CLOSE, 0, 0);
return 0;
}
-
case WM_MOUSEMOVE:
{
if (iMouse)
{
- dx = LOWORD(lParam) - xMouse;
- dy = HIWORD(lParam) - yMouse;
+ int dx = LOWORD(lParam) - xMouse;
+ int dy = HIWORD(lParam) - yMouse;
if (dx < 0) dx = -dx;
if (dy < 0) dy = -dy;
}
}
- /* Save last location */
iMouse = 1;
xMouse = LOWORD(lParam);
yMouse = HIWORD(lParam);
return 0;
}
-
case WM_CLOSE:
{
DestroyWindow(hwndSaver);
#endif /* USE_SAVER */
-
-
-
-/*** Temporary Hooks ***/
-
-
/*
* Display warning message (see "z-util.c")
*/
static void hack_plog(concptr str)
{
- /* Give a warning */
if (str)
{
#ifdef JP
*/
static void hack_quit(concptr str)
{
- /* Give a warning */
if (str)
{
#ifdef JP
}
- /* Unregister the classes */
UnregisterClass(AppName, hInstance);
-
- /* Destroy the icon */
if (hIcon) DestroyIcon(hIcon);
exit(0);
}
-
-/*** Various hooks ***/
-
-
/*
* Display warning message (see "z-util.c")
*/
static void hook_plog(concptr str)
{
- /* Warning */
if (str)
{
#ifdef JP
*/
static void hook_quit(concptr str)
{
- int i;
-
-
- /* Give a warning */
if (str)
{
#ifdef JP
MessageBox(data[0].w, str, "Error",
MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
#endif
-
}
-
- /* Save the preferences */
save_prefs();
-
- /* Destroy all windows */
- for (i = MAX_TERM_DATA - 1; i >= 0; --i)
+ for (int i = MAX_TERM_DATA - 1; i >= 0; --i)
{
term_force_font(&data[i], NULL);
if (data[i].font_want) string_free(data[i].font_want);
data[i].w = 0;
}
- /* Free the bitmap stuff */
if (infGraph.hPalette) DeleteObject(infGraph.hPalette);
if (infGraph.hBitmap) DeleteObject(infGraph.hBitmap);
-
if (infMask.hPalette) DeleteObject(infMask.hPalette);
if (infMask.hBitmap) DeleteObject(infMask.hBitmap);
- /*** Free some other stuff ***/
-
DeleteObject(hbrYellow);
-
- /* bg */
delete_bg();
if (hPal) DeleteObject(hPal);
UnregisterClass(AppName, hInstance);
-
if (hIcon) DestroyIcon(hIcon);
exit(0);
}
-
-/*** Initialize ***/
-
-
/*
* Init some stuff
*/
static void init_stuff(void)
{
- int i;
-
char path[1024];
-
-
- /* Get program name with full path */
GetModuleFileName(hInstance, path, 512);
-
- /* Save the "program name" */
argv0 = path;
-
- /* Get the name of the "*.ini" file */
strcpy(path + strlen(path) - 4, ".INI");
-
- /* Save the the name of the ini-file */
ini_file = string_make(path);
+ int i = strlen(path);
- /* Analyze the path */
- i = strlen(path);
-
- /* Get the path */
for (; i > 0; i--)
{
if (path[i] == '\\')
{
- /* End of path */
break;
}
}
- /* Add "lib" to the path */
strcpy(path + i + 1, "lib\\");
-
- /* Validate the path */
validate_dir(path, TRUE);
-
- /* Init the file paths */
init_file_paths(path);
-
- /* Hack -- Validate the paths */
validate_dir(ANGBAND_DIR_APEX, FALSE);
validate_dir(ANGBAND_DIR_BONE, FALSE);
-
- /* Allow missing 'edit' directory */
if (!check_dir(ANGBAND_DIR_EDIT))
{
- /* Must have 'data'! */
validate_dir(ANGBAND_DIR_DATA, TRUE);
}
else
{
- /* Don't need 'data' */
validate_dir(ANGBAND_DIR_DATA, FALSE);
}
validate_dir(ANGBAND_DIR_XTRA, TRUE);
path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
- /* Hack -- Validate the "news.txt" file */
validate_file(path);
-
- /* Build the "graf" path */
path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
-
- /* Allocate the path */
ANGBAND_DIR_XTRA_GRAF = string_make(path);
-
- /* Validate the "graf" directory */
validate_dir(ANGBAND_DIR_XTRA_GRAF, TRUE);
- /* Build the "sound" path */
path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
-
- /* Allocate the path */
ANGBAND_DIR_XTRA_SOUND = string_make(path);
-
- /* Validate the "sound" directory */
validate_dir(ANGBAND_DIR_XTRA_SOUND, FALSE);
- /* Build the "music" path */
path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
-
- /* Allocate the path */
ANGBAND_DIR_XTRA_MUSIC = string_make(path);
-
- /* Validate the "music" directory */
validate_dir(ANGBAND_DIR_XTRA_MUSIC, FALSE);
- /* Build the "help" path */
path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "help");
-
- /* Allocate the path */
ANGBAND_DIR_XTRA_HELP = string_make(path);
-
- /* Validate the "help" directory */
- /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
}
*/
static bool is_already_running(void)
{
- bool result = FALSE;
- HANDLE hMutex;
-
- hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
+ HANDLE hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
- result = TRUE;
+ return TRUE;
}
- return result;
+
+ return FALSE;
}
int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
LPSTR lpCmdLine, int nCmdShow)
{
- int i;
-
WNDCLASS wc;
HDC hdc;
MSG msg;
setlocale(LC_ALL, "ja_JP.utf8");
-
- /* Unused */
(void)nCmdShow;
-
- /* Save globally */
hInstance = hInst;
-
-
- /* Prevent multiple run */
if (is_already_running())
{
MessageBox(NULL,
wc.style = CS_CLASSDC;
wc.lpfnWndProc = AngbandWndProc;
wc.cbClsExtra = 0;
- wc.cbWndExtra = 4; /* one long pointer to term_data */
+ wc.cbWndExtra = 4;
wc.hInstance = hInst;
wc.hIcon = hIcon = LoadIcon(hInst, AppName);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
}
- /* Temporary hooks */
plog_aux = hack_plog;
quit_aux = hack_quit;
core_aux = hack_quit;
- /* Prepare the filepaths */
init_stuff();
-
- /* Initialize the keypress analyzer */
- for (i = 0; special_key_list[i]; ++i)
+ for (int i = 0; special_key_list[i]; ++i)
{
special_key[special_key_list[i]] = TRUE;
}
- /* Initialize the keypress analyzer */
- for (i = 0; ignore_key_list[i]; ++i)
+
+ for (int i = 0; ignore_key_list[i]; ++i)
{
ignore_key[ignore_key_list[i]] = TRUE;
}
- /* Determine if display is 16/256/true color */
hdc = GetDC(NULL);
colors16 = (GetDeviceCaps(hdc, BITSPIXEL) == 4);
paletted = ((GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ? TRUE : FALSE);
ReleaseDC(NULL, hdc);
- /* Initialize the colors */
- for (i = 0; i < 256; i++)
+ for (int i = 0; i < 256; i++)
{
- byte rv, gv, bv;
-
- /* Extract desired values */
- rv = angband_color_table[i][1];
- gv = angband_color_table[i][2];
- bv = angband_color_table[i][3];
-
- /* Extract the "complex" code */
+ byte rv = angband_color_table[i][1];
+ byte gv = angband_color_table[i][2];
+ byte bv = angband_color_table[i][3];
win_clr[i] = PALETTERGB(rv, gv, bv);
-
- /* Save the "simple" code */
angband_color_table[i][0] = win_pal[i];
}
- /* Prepare the windows */
init_windows();
-
- /* bg */
init_bg();
- /* Activate hooks */
plog_aux = hook_plog;
quit_aux = hook_quit;
core_aux = hook_quit;
- /* Set the system suffix */
ANGBAND_SYS = "win";
-
- /* Set the keyboard suffix */
if (7 != GetKeyboardType(0))
ANGBAND_KEYBOARD = "0";
else
{
- /* Japanese keyboard */
+ /* todo PC-98のサポートは打ち切ったので削除したい */
switch (GetKeyboardType(1))
{
case 0x0D01: case 0x0D02:
}
}
- /* Catch nasty signals */
signals_init();
-
Term_activate(term_screen);
init_angband(p_ptr);
-
- /* We are now initialized */
initialized = TRUE;
#ifdef CHUUKEI
if (lpCmdLine[0] == '-') {
#endif
#ifdef CHUUKEI
- /* Did the user double click on a save file? */
if (!chuukei_server) check_for_save_file(lpCmdLine);
#else
- /* Did the user double click on a save file? */
check_for_save_file(p_ptr, lpCmdLine);
#endif
- /* Prompt the user */
prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
-
Term_fresh();
-
- /* Process messages forever */
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
+
quit(NULL);
return 0;
}
-
-
#endif /* WINDOWS */