#define IDM_REDO 0x0040
#define IDM_QUIT 0x0050
#define IDM_CONFIG 0x0060
+#define IDM_SEED 0x0070
#define IDM_PRESETS 0x0100
#ifdef DEBUG
HPEN *pens;
HRGN clip;
UINT timer;
+ DWORD timer_last_tickcount;
int npresets;
game_params **presets;
struct font *fonts;
int nfonts, fontsize;
config_item *cfg;
struct cfg_aux *cfgaux;
- int cfg_done;
+ int cfg_which, cfg_done;
HFONT cfgfont;
};
void activate_timer(frontend *fe)
{
- fe->timer = SetTimer(fe->hwnd, fe->timer, 20, NULL);
+ if (!fe->timer) {
+ fe->timer = SetTimer(fe->hwnd, fe->timer, 20, NULL);
+ fe->timer_last_tickcount = GetTickCount();
+ }
}
static frontend *new_window(HINSTANCE inst)
int x, y;
RECT r, sr;
HDC hdc;
+ time_t t;
fe = snew(frontend);
- fe->me = midend_new(fe);
+
+ time(&t);
+ fe->me = midend_new(fe, &t, sizeof(t));
+
fe->inst = inst;
- midend_new_game(fe->me, NULL);
+ midend_new_game(fe->me);
midend_size(fe->me, &x, &y);
fe->timer = 0;
+ fe->fonts = NULL;
+ fe->nfonts = fe->fontsize = 0;
+
{
int i, ncolours;
float *colours;
AppendMenu(bar, MF_ENABLED|MF_POPUP, (UINT)menu, "Game");
AppendMenu(menu, MF_ENABLED, IDM_NEW, "New");
AppendMenu(menu, MF_ENABLED, IDM_RESTART, "Restart");
+ AppendMenu(menu, MF_ENABLED, IDM_SEED, "Specific...");
if ((fe->npresets = midend_num_presets(fe->me)) > 0 ||
game_can_configure) {
HIWORD(wParam) == BN_DOUBLECLICKED) &&
(LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)) {
if (LOWORD(wParam) == IDOK) {
- char *err = midend_set_config(fe->me, fe->cfg);
+ char *err = midend_set_config(fe->me, fe->cfg_which, fe->cfg);
if (err) {
MessageBox(hwnd, err, "Validation error",
return ret;
}
-static int get_config(frontend *fe)
+static int get_config(frontend *fe, int which)
{
config_item *i;
struct cfg_aux *j;
+ char *title;
WNDCLASS wc;
MSG msg;
TEXTMETRIC tm;
height = width = 30;
}
- fe->cfg = midend_get_config(fe->me);
+ fe->cfg = midend_get_config(fe->me, which, &title);
+ fe->cfg_which = which;
/*
* Figure out the layout of the config box by measuring the
r.right += r.left;
r.bottom += r.top;
- fe->cfgbox = CreateWindowEx(0, wc.lpszClassName, "Configuration",
+ fe->cfgbox = CreateWindowEx(0, wc.lpszClassName, title,
DS_MODALFRAME | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU,
r.left, r.top,
r.right-r.left, r.bottom-r.top,
fe->hwnd, NULL, fe->inst, NULL);
+ sfree(title);
}
SendMessage(fe->cfgbox, WM_SETFONT, (WPARAM)fe->cfgfont, FALSE);
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));
y += height;
break;
HDC hdc;
int x, y;
- midend_new_game(fe->me, NULL);
+ midend_new_game(fe->me);
midend_size(fe->me, &x, &y);
r.left = r.top = 0;
PostQuitMessage(0);
break;
case IDM_CONFIG:
- if (get_config(fe))
+ if (get_config(fe, CFG_SETTINGS))
+ new_game_type(fe);
+ break;
+ case IDM_SEED:
+ if (get_config(fe, CFG_SEED))
new_game_type(fe);
break;
default:
PostQuitMessage(0);
return 0;
case WM_TIMER:
- if (fe->timer)
- midend_timer(fe->me, (float)0.02);
+ if (fe->timer) {
+ DWORD now = GetTickCount();
+ float elapsed = (float) (now - fe->timer_last_tickcount) * 0.001F;
+ midend_timer(fe->me, elapsed);
+ fe->timer_last_tickcount = now;
+ }
return 0;
}
{
MSG msg;
- srand(time(NULL));
-
InitCommonControls();
if (!prev) {