From: H.G. Muller Date: Thu, 19 Jan 2012 16:18:25 +0000 (+0100) Subject: Implement Clone Tourney button XBoard X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=b0589092225d890ae15ca64677a4b0dbbb370877;p=xboard.git Implement Clone Tourney button XBoard This makes use of the new GenericUpdate(). --- diff --git a/xboard.texi b/xboard.texi index 022034f..ca00599 100644 --- a/xboard.texi +++ b/xboard.texi @@ -1365,7 +1365,7 @@ XBoard’s intrinsic tournament manager support round-robins (type = 0), where each participant plays every other participant, and (multi-)gauntlets, where one (or a few) so-called ‘gauntlet engines’ play an independent set of opponents. In the latter case, you specify the number of gauntlet engines. -E.g. if you specified 10 engine, and tourney type = 2, +E.g. if you specified 10 engines, and tourney type = 2, the first 2 engines each play the remaining 8. A value of -1 instructs XBoard to play Swiss; for this to work an external pairing engine must be specified through the @code{pairingEngine} option. @@ -1395,9 +1395,9 @@ File where the tournament games are saved @itemx Rewind Index after @cindex Game File with Opening Lines, Menu Item @cindex File with Start Positions, Menu Item -@itemx Game Number, Menu Item -@itemx Position Number, Menu Item -@itemx Rewind Index after, Menu Item +@cindex Game Number, Menu Item +@cindex Position Number, Menu Item +@cindex Rewind Index after, Menu Item These items optionally specify the file with move sequences or board positions the tourney games should start from. The corresponding numbers specify the number of the game or position in the file. @@ -1416,7 +1416,7 @@ Default: No game or position file will be used. The default index if such a file @cindex Replace Engine, Menu Item @cindex Upgrade Engine, Menu Item With these two buttons you can alter the participants of an already running tournament. -After opening the Match Options dialog on an XBoard that iw playing fo the tourney, +After opening the Match Options dialog on an XBoard that is playing for the tourney, you will see all the tourney parameters in the dialog fields. You can then replace the name of one engine by that of another by editing the @samp{participants} field. @@ -1428,6 +1428,14 @@ be invalidated, and they will be replayed with the substitute engine. In this latter case the engine must not be playing when you do this, but otherwise there is no need to pause the tournament play for making a substitution. +@itemx Clone Tourney +@cindex CloneTourney, Menu Item +Pressing this button after you have specified an existing tournament file +will copy the contents of the latter to the dialog, +and then puts the originally proposed name for the tourney file back. +You can then run a tourney with the same parameters +(possibly after changing the proposed name of the tourney file for the new tourney) +by pressing 'OK'. @item Load Game Options @cindex Load Game Options, Menu Item diff --git a/xoptions.c b/xoptions.c index 114215b..0ace8b6 100644 --- a/xoptions.c +++ b/xoptions.c @@ -253,6 +253,7 @@ int MakeColors P((void)); void CreateGCs P((int redo)); void CreateAnyPieces P((void)); int GenericReadout P((int selected)); +void GenericUpdate P((int selected)); Widget shells[10]; Widget marked[10]; Boolean shellUp[10]; @@ -362,6 +363,21 @@ UpgradeParticipant () Substitute(strdup(engineName), False); } +void +CloneTourney () +{ + FILE *f; + char *name; + GetWidgetText(currentOption, &name); + if(name && name[0] && (f = fopen(name, "r")) ) { + char *saveSaveFile; + saveSaveFile = appData.saveGameFile; appData.saveGameFile = NULL; // this is a persistent option, protect from change + ParseArgsFromFile(f); + engineName = appData.participants; GenericUpdate(-1); + FREE(appData.saveGameFile); appData.saveGameFile = saveSaveFile; + } else DisplayError(_("First you must specify an existing tourney file to clone"), 0); +} + Option matchOptions[] = { { 0, 0, 0, NULL, (void*) &tfName, ".trn", NULL, FileName, N_("Tournament file:") }, { 0, 0, 0, NULL, (void*) &appData.roundSync, "", NULL, CheckBox, N_("Sync after round (for concurrent playing of a single") }, @@ -382,6 +398,7 @@ Option matchOptions[] = { { 0, 0, 0, NULL, (void*) &appData.defNoBook, "", NULL, CheckBox, N_("Disable own engine books by default") }, { 0, 0, 0, NULL, (void*) &ReplaceParticipant, NULL, NULL, Button, N_("Replace Engine") }, { 0, 1, 0, NULL, (void*) &UpgradeParticipant, NULL, NULL, Button, N_("Upgrade Engine") }, +{ 0, 1, 0, NULL, (void*) &CloneTourney, NULL, NULL, Button, N_("Clone Tourney") }, { 0, 1, 0, NULL, (void*) &MatchOK, "", NULL, EndMark , "" } };