From: H.G. Muller Date: Fri, 25 Feb 2011 11:14:25 +0000 (+0100) Subject: Implement Machine Match menu item and options dialog X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=a90c45ee54a358b17fa4d006417bab8c6cf8657e;p=xboard.git Implement Machine Match menu item and options dialog An item to start a match from the menu is added, similar to what WinBoard has. (The code is duplicated, so I guess it should be moved to the back-end now, as MachineMatchEvent(), but it was tiny.) A dialog in the Options menu was added with the aid of the generic popup, and allows the user to set the load Game / Position File and Index. --- diff --git a/xboard.c b/xboard.c index d45cd74..7d277f7 100644 --- a/xboard.c +++ b/xboard.c @@ -346,6 +346,8 @@ void AnalyzeFileProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void TwoMachinesProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void MatchProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void MatchOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void IcsClientProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void EditGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); @@ -665,6 +667,7 @@ MenuItem modeMenu[] = { {N_("Training"), "Training", TrainingProc}, {N_("ICS Client"), "ICS Client", IcsClientProc}, {"----", NULL, NothingProc}, + {N_("Machine Match"), "Machine Match", MatchProc}, {N_("Pause Pause"), "Pause", PauseProc}, {NULL, NULL, NULL} }; @@ -711,6 +714,7 @@ MenuItem optionsMenu[] = { {N_("Common Engine ... Alt+Shift+U"), "Common Engine", UciMenuProc}, {N_("Adjudications ... Alt+Shift+J"), "Adjudications", EngineMenuProc}, {N_("ICS ..."), "ICS", IcsOptionsProc}, + {N_("Match ..."), "Match", MatchOptionsProc}, {N_("Load Game ..."), "Load Game", LoadOptionsProc}, {N_("Save Game ..."), "Save Game", SaveOptionsProc}, // {N_(" ..."), "", OptionsProc}, @@ -2762,6 +2766,7 @@ Enables icsEnables[] = { { "menuMode.Analysis Mode", False }, { "menuMode.Analyze File", False }, { "menuMode.Two Machines", False }, + { "menuMode.Machine Match", False }, #ifndef ZIPPY { "menuEngine.Hint", False }, { "menuEngine.Book", False }, @@ -2786,6 +2791,7 @@ Enables ncpEnables[] = { { "menuMode.Analysis Mode", False }, { "menuMode.Analyze File", False }, { "menuMode.Two Machines", False }, + { "menuMode.Machine Match", False }, { "menuMode.ICS Client", False }, { "menuView.ICS Input Box", False }, { "Action", False }, @@ -2884,6 +2890,7 @@ Enables machineThinkingEnables[] = { { "menuMode.Machine White", False }, { "menuMode.Machine Black", False }, { "menuMode.Two Machines", False }, + { "menuMode.Machine Match", False }, { "menuEngine.Retract Move", False }, { NULL, False } }; @@ -2902,6 +2909,7 @@ Enables userThinkingEnables[] = { { "menuMode.Machine White", True }, { "menuMode.Machine Black", True }, { "menuMode.Two Machines", True }, + { "menuMode.Machine Match", True }, { "menuEngine.Retract Move", True }, { NULL, False } }; @@ -6191,6 +6199,20 @@ void TwoMachinesProc(w, event, prms, nprms) TwoMachinesEvent(); } +void MatchProc(w, event, prms, nprms) + Widget w; + XEvent *event; + String *prms; + Cardinal *nprms; +{ + if(gameMode != BeginningOfGame) { DisplayError(_("You can only start a match from the initial position."), 0); return; } + matchMode = 2; // This is back-end, really + appData.matchGames = appData.defaultMatchGames; + matchGame = 1; + first.matchWins = second.matchWins = 0; + TwoMachinesEvent(); +} + void IcsClientProc(w, event, prms, nprms) Widget w; XEvent *event; diff --git a/xoptions.c b/xoptions.c index 286ef8b..ffb1da4 100644 --- a/xoptions.c +++ b/xoptions.c @@ -1017,8 +1017,6 @@ void SecondSettingsProc(w, event, prms, nprms) // cloned from Engine Settings dialog -#define CURR -2000000000 /* indicates control should start at actual value of target */ - typedef void ButtonCallback(int n); char *trialSound; @@ -1030,6 +1028,17 @@ void CreateXPMBoard P((char *s, int kind)); void CreateXPMPieces P((void)); void GenericReadout(); +Option matchOptions[] = { +{ 0, 2, 1000000000, NULL, (void*) &appData.defaultMatchGames, "", NULL, Spin, _("Default Number of Games in Match:") }, +{ 0, 0, 1000000000, NULL, (void*) &appData.matchPause, "", NULL, Spin, _("Pause between Match Games (msec):") }, +{ 0, 0, 0, NULL, (void*) &appData.loadGameFile, "", NULL, FileName, _("Game File with Opening Lines:") }, +{ 0, -2, 1000000000, NULL, (void*) &appData.loadGameIndex, "", NULL, Spin, _("Game Number (-1 or -2 = Auto-Increment):") }, +{ 0, 0, 0, NULL, (void*) &appData.loadPositionFile, "", NULL, FileName, _("File with Start Positions:") }, +{ 0, -2, 1000000000, NULL, (void*) &appData.loadPositionIndex, "", NULL, Spin, _("Position Number (-1 or -2 = Auto-Increment):") }, +{ 0, 0, 1000000000, NULL, (void*) &appData.rewindIndex, "", NULL, Spin, _("Rewind Index after this many Games (0 = never):") }, +{ 0, 0, 0, NULL, NULL, "", NULL, EndMark , "" } +}; + void GeneralOptionsOK(int n) { int newPonder = appData.ponderNextMove; @@ -1850,6 +1859,15 @@ void OptionsProc(w, event, prms, nprms) GenericPopUp(generalOptions, _("General Options")); } +void MatchOptionsProc(w, event, prms, nprms) + Widget w; + XEvent *event; + String *prms; + Cardinal *nprms; +{ + GenericPopUp(matchOptions, _("Match Options")); +} + //---------------------------- Chat Windows ---------------------------------------------- void OutputChatMessage(int partner, char *mess)