}
void
+SettingsMenuIfReady()
+{
+ if (second.lastPing != second.lastPong) {
+ DisplayMessage("", _("Waiting for second chess program"));
+ ScheduleDelayedEvent(SettingsMenuIfReady, 10); // [HGM] fast: lowered from 1000
+ return;
+ }
+ ThawUI();
+ DisplayMessage("", "");
+ SettingsPopUp(&second);
+}
+
+int
+WaitForSecond(DelayedEventCallback retry)
+{
+ if (second.pr == NULL) {
+ StartChessProgram(&second);
+ if (second.protocolVersion == 1) {
+ retry();
+ } else {
+ /* kludge: allow timeout for initial "feature" command */
+ FreezeUI();
+ DisplayMessage("", _("Starting second chess program"));
+ ScheduleDelayedEvent(retry, FEATURE_TIMEOUT);
+ }
+ return 1;
+ }
+ return 0;
+}
+
+void
TwoMachinesEvent P((void))
{
int i;
TruncateGame(); // [HGM] vari: MachineWhite and MachineBlack do this...
ResurrectChessProgram(); /* in case first program isn't running */
- if (second.pr == NULL) {
- StartChessProgram(&second);
- if (second.protocolVersion == 1) {
- TwoMachinesEventIfReady();
- } else {
- /* kludge: allow timeout for initial "feature" command */
- FreezeUI();
- DisplayMessage("", _("Starting second chess program"));
- ScheduleDelayedEvent(TwoMachinesEventIfReady, FEATURE_TIMEOUT);
- }
- return;
- }
+ if(WaitForSecond(TwoMachinesEventIfReady)) return;
DisplayMessage("", "");
InitChessProgram(&second, FALSE);
SendToProgram("force\n", &second);
{
DelayedEventCallback cb = GetDelayedEvent();
if ((cb == InitBackEnd3 && cps == &first) ||
+ (cb == SettingsMenuIfReady && cps == &second) ||
(cb == TwoMachinesEventIfReady && cps == &second)) {
CancelDelayedEvent();
ScheduleDelayedEvent(cb, val ? 1 : 3600000);
void AnalyzeFileEvent P((void));
void InitPosition P((int redraw));
void NewSettingEvent P((int option, int *feature, char *command, int value));
+int WaitForSecond P((DelayedEventCallback x));
+void SettingsMenuIfReady P((void));
void DoEcho P((void));
void DontEcho P((void));
void TidyProgramName P((char *prog, char *host, char *buf));
extern ChessProgramStats programStats;
extern int opponentKibitzes; // used by wengineo.c
extern int errorExitStatus;\r
+void SettingsPopUp P((ChessProgramState *cps)); // [HGM] really in front-end, but CPS not known in frontend.h
#endif /* _BACKEND */
HPALETTE hPal;\r
ColorClass currentColorClass;\r
\r
+static HWND savedHwnd;\r
HWND hCommPort = NULL; /* currently open comm port */\r
static HWND hwndPause; /* pause button */\r
static HBITMAP pieceBitmap[3][(int) BlackPawn]; /* [HGM] nr of bitmaps referred to bP in stead of wK */\r
break;\r
\r
case IDM_Engine2Options:\r
+ savedHwnd = hwnd;\r
+ if(WaitForSecond(SettingsMenuIfReady)) break;\r
EngineOptionsPopup(hwnd, &second);\r
break;\r
\r
\r
EvalGraphSet( first, last, current, pvInfoList );\r
}\r
+\r
+void\r
+SettingsPopUp(ChessProgramState *cps)\r
+{ // [HGM] wrapper needed because handles must not be passed through back-end\r
+ EngineOptionsPopup(savedHwnd, cps);\r
+}\r