From 2260b927ef09142f000676b4e63d2a3b735dde52 Mon Sep 17 00:00:00 2001 From: iks Date: Sat, 7 Mar 2009 21:24:35 +0000 Subject: [PATCH] =?utf8?q?windows=E7=89=88=E3=81=A7=E3=80=81windows?= =?utf8?q?=E3=82=92=E6=9C=80=E5=A4=A7=E5=8C=96=E3=81=97=E3=81=9F=E3=81=A8?= =?utf8?q?=E3=81=8D=E3=81=AB=E5=85=83=E3=81=AE=E3=82=A6=E3=82=A3=E3=83=B3?= =?utf8?q?=E3=83=89=E3=82=A6=E3=82=B5=E3=82=A4=E3=82=BA=E3=82=92=E4=BF=9D?= =?utf8?q?=E6=8C=81=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89?= =?utf8?q?=E6=9B=B4=E3=80=82=E5=85=83=E3=81=AE=E3=82=A6=E3=82=A3=E3=83=B3?= =?utf8?q?=E3=83=89=E3=82=A6=E3=81=AE=E4=BD=8D=E7=BD=AE=E3=81=AB=E3=81=A4?= =?utf8?q?=E3=81=84=E3=81=A6=E3=81=AF=E5=AF=BE=E5=BF=9C=E3=81=A7=E3=81=8D?= =?utf8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E3=80=82(from=20XAngband)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main-win.c | 106 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 23 deletions(-) diff --git a/src/main-win.c b/src/main-win.c index bfa243bf1..2fddbbf9f 100644 --- a/src/main-win.c +++ b/src/main-win.c @@ -434,6 +434,16 @@ static term_data data[MAX_TERM_DATA]; static term_data *my_td; /* + * Remember normal size of main window when maxmized + */ +POINT normsize; + +/* + * was main window maximized on previous playing + */ +bool win_maximized = FALSE; + +/* * game in progress */ bool game_in_progress = FALSE; @@ -1067,18 +1077,27 @@ static void term_getsize(term_data *td) /* * Write the "prefs" for a single term */ -static void save_prefs_aux(term_data *td, cptr sec_name) +static void save_prefs_aux(int i) { + term_data *td = &data[i]; + char sec_name[128]; char buf[1024]; RECT rc; + WINDOWPLACEMENT lpwndpl; /* Paranoia */ if (!td->w) return; + /* Make section name */ + sprintf(sec_name, "Term-%d", i); + /* Visible */ - strcpy(buf, td->visible ? "1" : "0"); - WritePrivateProfileString(sec_name, "Visible", buf, ini_file); + if (i > 0) + { + strcpy(buf, td->visible ? "1" : "0"); + WritePrivateProfileString(sec_name, "Visible", buf, ini_file); + } /* Font */ #ifdef JP @@ -1113,14 +1132,30 @@ static void save_prefs_aux(term_data *td, cptr sec_name) wsprintf(buf, "%d", td->tile_hgt); WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file); + /* Get window placement and dimensions */ + lpwndpl.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(td->w, &lpwndpl); + + /* Acquire position in *normal* mode (not minimized) */ + rc = lpwndpl.rcNormalPosition; + /* Window size (x) */ - wsprintf(buf, "%d", td->cols); + if (i == 0) wsprintf(buf, "%d", normsize.x); + else wsprintf(buf, "%d", td->cols); WritePrivateProfileString(sec_name, "NumCols", buf, ini_file); /* Window size (y) */ - wsprintf(buf, "%d", td->rows); + if (i == 0) wsprintf(buf, "%d", normsize.y); + else wsprintf(buf, "%d", td->rows); WritePrivateProfileString(sec_name, "NumRows", buf, ini_file); + /* Maxmized (only main window) */ + if (i == 0) + { + strcpy(buf, IsZoomed(td->w) ? "1" : "0"); + WritePrivateProfileString(sec_name, "Maximized", buf, ini_file); + } + /* Acquire position */ GetWindowRect(td->w, &rc); @@ -1133,8 +1168,11 @@ static void save_prefs_aux(term_data *td, cptr sec_name) WritePrivateProfileString(sec_name, "PositionY", buf, ini_file); /* Window Z position */ - strcpy(buf, td->posfix ? "1" : "0"); - WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file); + if (i > 0) + { + strcpy(buf, td->posfix ? "1" : "0"); + WritePrivateProfileString(sec_name, "PositionFix", buf, ini_file); + } } @@ -1170,11 +1208,7 @@ static void save_prefs(void) /* Save window prefs */ for (i = 0; i < MAX_TERM_DATA; ++i) { - term_data *td = &data[i]; - - sprintf(buf, "Term-%d", i); - - save_prefs_aux(td, buf); + save_prefs_aux(i); } } @@ -1182,14 +1216,25 @@ static void save_prefs(void) /* * Load the "prefs" for a single term */ -static void load_prefs_aux(term_data *td, cptr sec_name) +static void load_prefs_aux(int i) { + term_data *td = &data[i]; + char sec_name[128]; char tmp[1024]; int wid, hgt; + /* Make section name */ + sprintf(sec_name, "Term-%d", i); + + /* Make section name */ + sprintf(sec_name, "Term-%d", i); + /* Visible */ - td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0); + if (i > 0) + { + td->visible = (GetPrivateProfileInt(sec_name, "Visible", td->visible, ini_file) != 0); + } /* Desired font, with default */ #ifdef JP @@ -1231,13 +1276,23 @@ static void load_prefs_aux(term_data *td, cptr sec_name) /* Window size */ td->cols = GetPrivateProfileInt(sec_name, "NumCols", td->cols, ini_file); td->rows = GetPrivateProfileInt(sec_name, "NumRows", td->rows, ini_file); + normsize.x = td->cols; normsize.y = td->rows; + + /* Window size */ + if (i == 0) + { + win_maximized = GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file); + } /* Window position */ td->pos_x = GetPrivateProfileInt(sec_name, "PositionX", td->pos_x, ini_file); td->pos_y = GetPrivateProfileInt(sec_name, "PositionY", td->pos_y, ini_file); /* Window Z position */ - td->posfix = GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file); + if (i > 0) + { + td->posfix = GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file); + } } @@ -1248,8 +1303,6 @@ static void load_prefs(void) { int i; - char buf[1024]; - /* Extract the "arg_graphics" flag */ arg_graphics = GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file); @@ -1267,11 +1320,7 @@ static void load_prefs(void) /* Load window prefs */ for (i = 0; i < MAX_TERM_DATA; ++i) { - term_data *td = &data[i]; - - sprintf(buf, "Term-%d", i); - - load_prefs_aux(td, buf); + load_prefs_aux(i); } } @@ -3093,9 +3142,12 @@ static void init_windows(void) term_data_link(td); angband_term[0] = &td->t; + normsize.x = td->cols; + normsize.y = td->rows; /* Activate the main window */ - SetActiveWindow(td->w); + if (win_maximized) ShowWindow(td->w, SW_SHOWMAXIMIZED); + else ShowWindow(td->w, SW_SHOW); /* Bring main window back to top */ SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); @@ -4415,6 +4467,12 @@ LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, 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); @@ -4488,6 +4546,8 @@ LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, case WM_ACTIVATEAPP: { + if (IsIconic(td->w)) break; + for (i = 1; i < MAX_TERM_DATA; i++) { if(data[i].visible) -- 2.11.0