OutputDebugString(buf);
}
-void debug_printf(char *fmt, ...)
+void debug_printf(const char *fmt, ...)
{
char buf[4096];
va_list ap;
static void update_type_menu_tick(frontend *fe);
static void update_copy_menu_greying(frontend *fe);
-void fatal(char *fmt, ...)
+void fatal(const char *fmt, ...)
{
char buf[2048];
va_list ap;
*randseedsize = sizeof(SYSTEMTIME);
}
-static void win_status_bar(void *handle, char *text)
+static void win_status_bar(void *handle, const char *text)
{
#ifdef _WIN32_WCE
TCHAR wText[255];
}
static void win_draw_text(void *handle, int x, int y, int fonttype,
- int fontsize, int align, int colour, char *text)
+ int fontsize, int align, int colour,
+ const char *text)
{
frontend *fe = (frontend *)handle;
POINT xy;
document *doc;
midend *nme = NULL; /* non-interactive midend for bulk puzzle generation */
int i;
- char *err = NULL;
+ const char *err = NULL;
/*
* Create our document structure and fill it up with puzzles.
midend_new_game(me);
} else {
FILE *fp;
- char *err_param, *err_load;
+ const char *err_param, *err_load;
/*
* See if arg is a valid filename of a save game file.
ret[i].name = "Number of puzzles to print";
ret[i].type = C_STRING;
- ret[i].sval = dupstr("1");
- ret[i].ival = 0;
+ ret[i].u.string.sval = dupstr("1");
i++;
ret[i].name = "Number of puzzles across the page";
ret[i].type = C_STRING;
- ret[i].sval = dupstr("1");
- ret[i].ival = 0;
+ ret[i].u.string.sval = dupstr("1");
i++;
ret[i].name = "Number of puzzles down the page";
ret[i].type = C_STRING;
- ret[i].sval = dupstr("1");
- ret[i].ival = 0;
+ ret[i].u.string.sval = dupstr("1");
i++;
ret[i].name = "Percentage of standard size";
ret[i].type = C_STRING;
- ret[i].sval = dupstr("100.0");
- ret[i].ival = 0;
+ ret[i].u.string.sval = dupstr("100.0");
i++;
ret[i].name = "Include currently shown puzzle";
ret[i].type = C_BOOLEAN;
- ret[i].sval = NULL;
- ret[i].ival = TRUE;
+ ret[i].u.boolean.bval = TRUE;
i++;
ret[i].name = "Print solutions";
ret[i].type = C_BOOLEAN;
- ret[i].sval = NULL;
- ret[i].ival = FALSE;
+ ret[i].u.boolean.bval = FALSE;
i++;
if (fe->game->can_print_in_colour) {
ret[i].name = "Print in colour";
ret[i].type = C_BOOLEAN;
- ret[i].sval = NULL;
- ret[i].ival = FALSE;
+ ret[i].u.boolean.bval = FALSE;
i++;
}
ret[i].name = NULL;
ret[i].type = C_END;
- ret[i].sval = NULL;
- ret[i].ival = 0;
i++;
return ret;
}
}
-static char *frontend_set_config(frontend *fe, int which, config_item *cfg)
+static const char *frontend_set_config(
+ frontend *fe, int which, config_item *cfg)
{
if (which < CFG_FRONTEND_SPECIFIC) {
return midend_set_config(fe->me, which, cfg);
} else if (which == CFG_PRINT) {
- if ((fe->printcount = atoi(cfg[0].sval)) <= 0)
+ if ((fe->printcount = atoi(cfg[0].u.string.sval)) <= 0)
return "Number of puzzles to print should be at least one";
- if ((fe->printw = atoi(cfg[1].sval)) <= 0)
+ if ((fe->printw = atoi(cfg[1].u.string.sval)) <= 0)
return "Number of puzzles across the page should be at least one";
- if ((fe->printh = atoi(cfg[2].sval)) <= 0)
+ if ((fe->printh = atoi(cfg[2].u.string.sval)) <= 0)
return "Number of puzzles down the page should be at least one";
- if ((fe->printscale = (float)atof(cfg[3].sval)) <= 0)
+ if ((fe->printscale = (float)atof(cfg[3].u.string.sval)) <= 0)
return "Print size should be positive";
- fe->printcurr = cfg[4].ival;
- fe->printsolns = cfg[5].ival;
- fe->printcolour = fe->game->can_print_in_colour && cfg[6].ival;
+ fe->printcurr = cfg[4].u.boolean.bval;
+ fe->printsolns = cfg[5].u.boolean.bval;
+ fe->printcolour = fe->game->can_print_in_colour &&
+ cfg[6].u.boolean.bval;
return NULL;
} else {
assert(!"We should never get here");
/* Control coordinates should be specified in dialog units. */
HWND mkctrl(frontend *fe, int x1, int x2, int y1, int y2,
LPCTSTR wclass, int wstyle,
- int exstyle, const char *wtext, int wid)
+ int exstyle, const char *wtext, INT_PTR wid)
{
RECT rc;
TCHAR wwtext[256];
mkctrl(fe, col2l, col2r, y, y + 12,
TEXT("EDIT"), WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL,
0, "", (j->ctlid = id++));
- SetDlgItemTextA(fe->cfgbox, j->ctlid, i->sval);
+ SetDlgItemTextA(fe->cfgbox, j->ctlid, i->u.string.sval);
break;
case C_BOOLEAN:
mkctrl(fe, col1l, col2r, y + 1, y + 11, TEXT("BUTTON"),
BS_NOTIFY | BS_AUTOCHECKBOX | WS_TABSTOP,
0, i->name, (j->ctlid = id++));
- CheckDlgButton(fe->cfgbox, j->ctlid, (i->ival != 0));
+ CheckDlgButton(fe->cfgbox, j->ctlid, (i->u.boolean.bval != 0));
break;
case C_CHOICES:
CBS_DROPDOWNLIST | CBS_HASSTRINGS,
0, "", (j->ctlid = id++));
{
- char c, *p, *q, *str;
+ char c;
+ const char *p, *q;
+ char *str;
- p = i->sval;
+ p = i->u.choices.choicenames;
c = *p++;
while (*p) {
q = p;
p = q;
}
}
- SendMessage(ctl, CB_SETCURSEL, i->ival, 0);
+ SendMessage(ctl, CB_SETCURSEL, i->u.choices.selected, 0);
break;
}
*/
if ((LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)) {
if (LOWORD(wParam) == IDOK) {
- char *err = frontend_set_config(fe, fe->cfg_which, fe->cfg);
+ const char *err = frontend_set_config(
+ fe, fe->cfg_which, fe->cfg);
if (err) {
MessageBox(hwnd, err, "Validation error",
GetDlgItemText(fe->cfgbox, j->ctlid, buffer, lenof(buffer));
#endif
buffer[lenof(buffer)-1] = '\0';
- sfree(i->sval);
- i->sval = dupstr(buffer);
+ sfree(i->u.string.sval);
+ i->u.string.sval = dupstr(buffer);
} else if (i->type == C_BOOLEAN &&
(HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DBLCLK)) {
- i->ival = IsDlgButtonChecked(fe->cfgbox, j->ctlid);
+ i->u.boolean.bval = IsDlgButtonChecked(fe->cfgbox, j->ctlid);
} else if (i->type == C_CHOICES &&
HIWORD(wParam) == CBN_SELCHANGE) {
- i->ival = SendDlgItemMessage(fe->cfgbox, j->ctlid,
- CB_GETCURSEL, 0, 0);
+ i->u.choices.selected = SendDlgItemMessage(fe->cfgbox, j->ctlid,
+ CB_GETCURSEL, 0, 0);
}
return 0;
#ifndef _WIN32_WCE
HWND mkctrl(frontend *fe, int x1, int x2, int y1, int y2,
char *wclass, int wstyle,
- int exstyle, const char *wtext, int wid)
+ int exstyle, const char *wtext, INT_PTR wid)
{
HWND ret;
ret = CreateWindowEx(exstyle, wclass, wtext,
ctl = mkctrl(fe, col2l, col2r, y, y+height*3/2,
"EDIT", WS_TABSTOP | ES_AUTOHSCROLL,
WS_EX_CLIENTEDGE, "", (j->ctlid = id++));
- SetWindowText(ctl, i->sval);
+ SetWindowText(ctl, i->u.string.sval);
y += height*3/2;
break;
mkctrl(fe, col1l, col2r, y, y+height, "BUTTON",
BS_NOTIFY | BS_AUTOCHECKBOX | WS_TABSTOP,
0, i->name, (j->ctlid = id++));
- CheckDlgButton(fe->cfgbox, j->ctlid, (i->ival != 0));
+ CheckDlgButton(fe->cfgbox, j->ctlid, (i->u.boolean.bval != 0));
y += height;
break;
CBS_DROPDOWNLIST | CBS_HASSTRINGS,
WS_EX_CLIENTEDGE, "", (j->ctlid = id++));
{
- char c, *p, *q, *str;
+ char c;
+ const char *p, *q;
+ char *str;
SendMessage(ctl, CB_RESETCONTENT, 0, 0);
- p = i->sval;
+ p = i->u.choices.choicenames;
c = *p++;
while (*p) {
q = p;
}
}
- SendMessage(ctl, CB_SETCURSEL, i->ival, 0);
+ SendMessage(ctl, CB_SETCURSEL, i->u.choices.selected, 0);
y += height*3/2;
break;
break;
case IDM_SOLVE:
{
- char *msg = midend_solve(fe->me);
+ const char *msg = midend_solve(fe->me);
if (msg)
MessageBox(hwnd, msg, "Unable to solve",
MB_ICONERROR | MB_OK);
fclose(fp);
} else {
FILE *fp = fopen(filename, "r");
- char *err = NULL;
+ const char *err = NULL;
+ char *err_w = NULL;
midend *me = fe->me;
#ifdef COMBINED
char *id_name;
"supported by this program";
} else {
me = midend_for_new_game(fe, gamelist[i], NULL,
- FALSE, FALSE, &err);
+ FALSE, FALSE, &err_w);
+ err = err_w;
rewind(fp); /* for the actual load */
}
sfree(id_name);
if (err) {
MessageBox(hwnd, err, "Error", MB_ICONERROR|MB_OK);
+ sfree(err_w);
break;
}