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;
/*
* 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
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);
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);
+ }
}
/* 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);
}
}
/*
* 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
/* 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);
+ }
}
{
int i;
- char buf[1024];
-
/* Extract the "arg_graphics" flag */
arg_graphics = GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
/* 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);
}
}
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);
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);
case WM_ACTIVATEAPP:
{
+ if (IsIconic(td->w)) break;
+
for (i = 1; i < MAX_TERM_DATA; i++)
{
if(data[i].visible)