Pass a game_ui to compute_size, print_size and print.

I'm about to move some of the bodgy getenv-based options so that they
become fields in game_ui. So these functions, which could previously
access those options directly via getenv, will now need to be given a
game_ui where they can look them up.
This commit is contained in:
Simon Tatham
2023-04-21 15:30:41 +01:00
parent ec2e2f3770
commit a4fca3286f
49 changed files with 214 additions and 144 deletions

View File

@ -303,7 +303,7 @@ static void midend_size_new_drawstate(midend *me)
* anyway yet.
*/
if (me->tilesize > 0) {
me->ourgame->compute_size(me->params, me->tilesize,
me->ourgame->compute_size(me->params, me->tilesize, me->ui,
&me->winwidth, &me->winheight);
me->ourgame->set_size(me->drawing, me->drawstate,
me->params, me->tilesize);
@ -328,19 +328,19 @@ static int convert_tilesize(midend *me, int old_tilesize,
defaults = me->ourgame->default_params();
me->ourgame->compute_size(defaults, old_tilesize, &x, &y);
me->ourgame->compute_size(defaults, old_tilesize, me->ui, &x, &y);
x *= new_dpr / old_dpr;
y *= new_dpr / old_dpr;
min = max = 1;
do {
max *= 2;
me->ourgame->compute_size(defaults, max, &rx, &ry);
me->ourgame->compute_size(defaults, max, me->ui, &rx, &ry);
} while (rx <= x && ry <= y);
while (max - min > 1) {
int mid = (max + min) / 2;
me->ourgame->compute_size(defaults, mid, &rx, &ry);
me->ourgame->compute_size(defaults, mid, me->ui, &rx, &ry);
if (rx <= x && ry <= y)
min = mid;
else
@ -382,7 +382,7 @@ void midend_size(midend *me, int *x, int *y, bool user_size,
max = 1;
do {
max *= 2;
me->ourgame->compute_size(me->params, max, &rx, &ry);
me->ourgame->compute_size(me->params, max, me->ui, &rx, &ry);
} while (rx <= *x && ry <= *y);
} else
max = convert_tilesize(me, me->preferred_tilesize,
@ -398,7 +398,7 @@ void midend_size(midend *me, int *x, int *y, bool user_size,
*/
while (max - min > 1) {
int mid = (max + min) / 2;
me->ourgame->compute_size(me->params, mid, &rx, &ry);
me->ourgame->compute_size(me->params, mid, me->ui, &rx, &ry);
if (rx <= *x && ry <= *y)
min = mid;
else