mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-22 16:32:13 -07:00
All the games in this collection have always defined their graphics
in terms of a constant TILE_SIZE (or equivalent). Here's a surprisingly small patch which switches this constant into a run-time variable. The only observable behaviour change should be on Windows, which physically does not permit the creation of windows larger than the screen; if you try to create a puzzle (Net makes this plausible) large enough to encounter this restriction, the Windows front end should automatically re-adjust the puzzle's tile size so that it does fit within the available space. On GTK, I haven't done this, on the grounds that X _does_ permit windows larger than the screen, and many X window managers already provide the means to navigate around such a window. Gareth said he'd rather navigate around a huge Net window than have it shrunk to fit on one screen. I'm uncertain that this makes sense for all puzzles - Pattern in particular strikes me as something that might be better off shrunk to fit - so I may have to change policy later or make it configurable. On OS X, I also haven't done automatic shrinkage to fit on one screen, largely because I didn't have the courage to address the question of multiple monitors and what that means for the entire concept :-) [originally from svn r5913]
This commit is contained in:
82
windows.c
82
windows.c
@ -19,6 +19,7 @@
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "puzzles.h"
|
||||
@ -406,11 +407,57 @@ static void find_help_file(frontend *fe)
|
||||
}
|
||||
}
|
||||
|
||||
static void check_window_size(frontend *fe, int *px, int *py)
|
||||
{
|
||||
RECT r;
|
||||
int x, y, sy;
|
||||
|
||||
if (fe->statusbar) {
|
||||
RECT sr;
|
||||
GetWindowRect(fe->statusbar, &sr);
|
||||
sy = sr.bottom - sr.top;
|
||||
} else {
|
||||
sy = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* See if we actually got the window size we wanted, and adjust
|
||||
* the puzzle size if not.
|
||||
*/
|
||||
GetClientRect(fe->hwnd, &r);
|
||||
x = r.right - r.left;
|
||||
y = r.bottom - r.top - sy;
|
||||
midend_size(fe->me, &x, &y, FALSE);
|
||||
if (x != r.right - r.left || y != r.bottom - r.top) {
|
||||
/*
|
||||
* Resize the window, now we know what size we _really_
|
||||
* want it to be.
|
||||
*/
|
||||
r.left = r.top = 0;
|
||||
r.right = x;
|
||||
r.bottom = y + sy;
|
||||
AdjustWindowRectEx(&r, WS_OVERLAPPEDWINDOW &~
|
||||
(WS_THICKFRAME | WS_MAXIMIZEBOX | WS_OVERLAPPED),
|
||||
TRUE, 0);
|
||||
SetWindowPos(fe->hwnd, NULL, 0, 0, r.right - r.left, r.bottom - r.top,
|
||||
SWP_NOMOVE | SWP_NOZORDER);
|
||||
}
|
||||
|
||||
if (fe->statusbar) {
|
||||
GetClientRect(fe->hwnd, &r);
|
||||
SetWindowPos(fe->statusbar, NULL, 0, r.bottom-r.top-sy, r.right-r.left,
|
||||
sy, SWP_NOZORDER);
|
||||
}
|
||||
|
||||
*px = x;
|
||||
*py = y;
|
||||
}
|
||||
|
||||
static frontend *new_window(HINSTANCE inst, char *game_id, char **error)
|
||||
{
|
||||
frontend *fe;
|
||||
int x, y;
|
||||
RECT r, sr;
|
||||
RECT r;
|
||||
HDC hdc;
|
||||
|
||||
fe = snew(frontend);
|
||||
@ -431,7 +478,6 @@ static frontend *new_window(HINSTANCE inst, char *game_id, char **error)
|
||||
|
||||
fe->inst = inst;
|
||||
midend_new_game(fe->me);
|
||||
midend_size(fe->me, &x, &y);
|
||||
|
||||
fe->timer = 0;
|
||||
|
||||
@ -459,6 +505,9 @@ static frontend *new_window(HINSTANCE inst, char *game_id, char **error)
|
||||
}
|
||||
}
|
||||
|
||||
x = y = INT_MAX; /* find puzzle's preferred size */
|
||||
midend_size(fe->me, &x, &y, FALSE);
|
||||
|
||||
r.left = r.top = 0;
|
||||
r.right = x;
|
||||
r.bottom = y;
|
||||
@ -473,6 +522,14 @@ static frontend *new_window(HINSTANCE inst, char *game_id, char **error)
|
||||
r.right - r.left, r.bottom - r.top,
|
||||
NULL, NULL, inst, NULL);
|
||||
|
||||
if (midend_wants_statusbar(fe->me))
|
||||
fe->statusbar = CreateWindowEx(0, STATUSCLASSNAME, "ooh",
|
||||
WS_CHILD | WS_VISIBLE,
|
||||
0, 0, 0, 0, /* status bar does these */
|
||||
fe->hwnd, NULL, inst, NULL);
|
||||
else
|
||||
fe->statusbar = NULL;
|
||||
|
||||
{
|
||||
HMENU bar = CreateMenu();
|
||||
HMENU menu = CreateMenu();
|
||||
@ -541,20 +598,7 @@ static frontend *new_window(HINSTANCE inst, char *game_id, char **error)
|
||||
SetMenu(fe->hwnd, bar);
|
||||
}
|
||||
|
||||
if (midend_wants_statusbar(fe->me)) {
|
||||
fe->statusbar = CreateWindowEx(0, STATUSCLASSNAME, "ooh",
|
||||
WS_CHILD | WS_VISIBLE,
|
||||
0, 0, 0, 0, /* status bar does these */
|
||||
fe->hwnd, NULL, inst, NULL);
|
||||
GetWindowRect(fe->statusbar, &sr);
|
||||
SetWindowPos(fe->hwnd, NULL, 0, 0,
|
||||
r.right - r.left, r.bottom - r.top + sr.bottom - sr.top,
|
||||
SWP_NOMOVE | SWP_NOZORDER);
|
||||
SetWindowPos(fe->statusbar, NULL, 0, y, x, sr.bottom - sr.top,
|
||||
SWP_NOZORDER);
|
||||
} else {
|
||||
fe->statusbar = NULL;
|
||||
}
|
||||
check_window_size(fe, &x, &y);
|
||||
|
||||
hdc = GetDC(fe->hwnd);
|
||||
fe->bitmap = CreateCompatibleBitmap(hdc, x, y);
|
||||
@ -1075,7 +1119,8 @@ static void new_game_type(frontend *fe)
|
||||
int x, y;
|
||||
|
||||
midend_new_game(fe->me);
|
||||
midend_size(fe->me, &x, &y);
|
||||
x = y = INT_MAX;
|
||||
midend_size(fe->me, &x, &y, FALSE);
|
||||
|
||||
r.left = r.top = 0;
|
||||
r.right = x;
|
||||
@ -1094,6 +1139,9 @@ static void new_game_type(frontend *fe)
|
||||
r.right - r.left,
|
||||
r.bottom - r.top + sr.bottom - sr.top,
|
||||
SWP_NOMOVE | SWP_NOZORDER);
|
||||
|
||||
check_window_size(fe, &x, &y);
|
||||
|
||||
if (fe->statusbar != NULL)
|
||||
SetWindowPos(fe->statusbar, NULL, 0, y, x,
|
||||
sr.bottom - sr.top, SWP_NOZORDER);
|
||||
|
Reference in New Issue
Block a user