-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdialogs.c
3055 lines (2748 loc) · 114 KB
/
dialogs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* dialogs.c -- platform-independent code for dialogs of XBoard
*
* Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
* ------------------------------------------------------------------------
*
* GNU XBoard is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* GNU XBoard is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/. *
*
*------------------------------------------------------------------------
** See the file ChangeLog for a revision history. */
// [HGM] this file is the counterpart of woptions.c, containing xboard popup menus
// similar to those of WinBoard, to set the most common options interactively.
#include "config.h"
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <sys/types.h>
#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else /* not STDC_HEADERS */
extern char *getenv();
# if HAVE_STRING_H
# include <string.h>
# else /* not HAVE_STRING_H */
# include <strings.h>
# endif /* not HAVE_STRING_H */
#endif /* not STDC_HEADERS */
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdint.h>
#include "common.h"
#include "frontend.h"
#include "backend.h"
#include "xboard2.h"
#include "menus.h"
#include "dialogs.h"
#include "gettext.h"
#ifdef ENABLE_NLS
# define _(s) gettext (s)
# define N_(s) gettext_noop (s)
#else
# define _(s) (s)
# define N_(s) s
#endif
int values[MAX_OPTIONS];
ChessProgramState *currentCps;
//----------------------------Generic dialog --------------------------------------------
// cloned from Engine Settings dialog (and later merged with it)
char *marked[NrOfDialogs];
Boolean shellUp[NrOfDialogs];
void
MarkMenu (char *item, int dlgNr)
{
MarkMenuItem(marked[dlgNr] = item, True);
}
void
AddLine (Option *opt, char *s)
{
AppendText(opt, s);
AppendText(opt, "\n");
}
//---------------------------------------------- Update dialog controls ------------------------------------
int
SetCurrentComboSelection (Option *opt)
{
int j;
if(!opt->textValue) opt->value = *(int*)opt->target; /* numeric */else {
for(j=0; opt->choice[j]; j++) // look up actual value in list of possible values, to get selection nr
if(*(char**)opt->target && !strcmp(*(char**)opt->target, ((char**)opt->textValue)[j])) break;
opt->value = j + (opt->choice[j] == NULL);
}
return opt->value;
}
void
GenericUpdate (Option *opts, int selected)
{
int i;
char buf[MSG_SIZ];
for(i=0; ; i++)
{
if(selected >= 0) { if(i < selected) continue; else if(i > selected) break; }
switch(opts[i].type)
{
case TextBox:
case FileName:
case PathName:
SetWidgetText(&opts[i], *(char**) opts[i].target, -1);
break;
case Spin:
sprintf(buf, "%d", *(int*) opts[i].target);
SetWidgetText(&opts[i], buf, -1);
break;
case Fractional:
sprintf(buf, "%4.2f", *(float*) opts[i].target);
SetWidgetText(&opts[i], buf, -1);
break;
case CheckBox:
SetWidgetState(&opts[i], *(Boolean*) opts[i].target);
break;
case ComboBox:
if(opts[i].min & COMBO_CALLBACK) break;
SetCurrentComboSelection(opts+i);
// TODO: actually display this (but it is never used that way...)
break;
case EndMark:
return;
default:
printf("GenericUpdate: unexpected case in switch.\n");
case ListBox:
case Button:
case SaveButton:
case Label:
case Break:
break;
}
}
}
//------------------------------------------- Read out dialog controls ------------------------------------
int
GenericReadout (Option *opts, int selected)
{
int i, j, res=1;
char *val;
char buf[MSG_SIZ], **dest;
float x;
for(i=0; ; i++) { // send all options that had to be OK-ed to engine
if(selected >= 0) { if(i < selected) continue; else if(i > selected) break; }
switch(opts[i].type) {
case TextBox:
case FileName:
case PathName:
GetWidgetText(&opts[i], &val);
dest = currentCps ? &(opts[i].textValue) : (char**) opts[i].target;
if(*dest == NULL || strcmp(*dest, val)) {
if(currentCps) {
snprintf(buf, MSG_SIZ, "option %s=%s\n", opts[i].name, val);
SendToProgram(buf, currentCps);
} else {
if(*dest) free(*dest);
*dest = malloc(strlen(val)+1);
}
safeStrCpy(*dest, val, MSG_SIZ - (*dest - opts[i].name)); // copy text there
}
break;
case Spin:
case Fractional:
GetWidgetText(&opts[i], &val);
x = 0.0; // Initialise because sscanf() will fail if non-numeric text is entered
sscanf(val, "%f", &x);
if(x > opts[i].max) x = opts[i].max;
if(x < opts[i].min) x = opts[i].min;
if(opts[i].type == Fractional)
*(float*) opts[i].target = x; // engines never have float options!
else {
if(currentCps) {
if(opts[i].value != x) { // only to engine if changed
snprintf(buf, MSG_SIZ, "option %s=%.0f\n", opts[i].name, x);
SendToProgram(buf, currentCps);
}
} else *(int*) opts[i].target = x;
opts[i].value = x;
}
break;
case CheckBox:
j = 0;
GetWidgetState(&opts[i], &j);
if(opts[i].value != j) {
opts[i].value = j;
if(currentCps) {
snprintf(buf, MSG_SIZ, "option %s=%d\n", opts[i].name, j);
SendToProgram(buf, currentCps);
} else *(Boolean*) opts[i].target = j;
}
break;
case ComboBox:
if(opts[i].min & COMBO_CALLBACK) break;
if(!opts[i].textValue) { *(int*)opts[i].target = values[i]; break; } // numeric
val = ((char**)opts[i].textValue)[values[i]];
if(currentCps) {
if(opts[i].value == values[i]) break; // not changed
opts[i].value = values[i];
snprintf(buf, MSG_SIZ, "option %s=%s\n", opts[i].name, opts[i].choice[values[i]]);
SendToProgram(buf, currentCps);
} else if(val && (*(char**) opts[i].target == NULL || strcmp(*(char**) opts[i].target, val))) {
if(*(char**) opts[i].target) free(*(char**) opts[i].target);
*(char**) opts[i].target = strdup(val);
}
break;
case EndMark:
if(opts[i].target && selected != -2) // callback for implementing necessary actions on OK (like redraw)
res = ((OKCallback*) opts[i].target)(i);
break;
default:
printf("GenericReadout: unexpected case in switch.\n");
case ListBox:
case Button:
case SaveButton:
case Label:
case Break:
case Skip:
break;
}
if(opts[i].type == EndMark) break;
}
return res;
}
//------------------------------------------- Match Options ------------------------------------------------------
char *engineName, *engineChoice, *tfName;
char *engineList[MAXENGINES] = {" "}, *engineMnemonic[MAXENGINES];
static void AddToTourney P((int n, int sel));
static void CloneTourney P((void));
static void ReplaceParticipant P((void));
static void UpgradeParticipant P((void));
static void PseudoOK P((void));
static int
MatchOK (int n)
{
ASSIGN(appData.participants, engineName);
if(!CreateTourney(tfName) || matchMode) return matchMode || !appData.participants[0];
PopDown(MasterDlg); // early popdown to prevent FreezeUI called through MatchEvent from causing XtGrab warning
MatchEvent(2); // start tourney
return FALSE; // no double PopDown!
}
static void
DoTimeControl(int n)
{
TimeControlProc();
}
static void
DoCommonEngine(int n)
{
UciMenuProc();
}
static void
DoGeneral(int n)
{
OptionsProc();
}
#define PARTICIPANTS 6 /* This MUST be the number of the Option for &engineName!*/
static Option matchOptions[] = {
{ 0, 0, 0, NULL, (void*) &tfName, ".trn", NULL, FileName, N_("Tournament file: ") },
{ 0, 0, 0, NULL, NULL, NULL, NULL, Label, N_("For concurrent playing of tourney with multiple XBoards:") },
{ 0, 0, 0, NULL, (void*) &appData.roundSync, "", NULL, CheckBox, N_("Sync after round") },
{ 0, 0, 0, NULL, (void*) &appData.cycleSync, "", NULL, CheckBox, N_("Sync after cycle") },
{ 0, LR, 175, NULL, NULL, NULL, NULL, Label, N_("Tourney participants:") },
{ 0, SAME_ROW|RR, 175, NULL, NULL, NULL, NULL, Label, N_("Select Engine:") },
{ 200, T_VSCRL | T_FILL | T_WRAP,
175, NULL, (void*) &engineName, NULL, NULL, TextBox, "" },
{ 200, SAME_ROW|RR,
175, NULL, (void*) engineMnemonic, (char*) &AddToTourney, NULL, ListBox, "" },
{ 0, SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, "" }, // to decouple alignment above and below boxes
//{ 0, COMBO_CALLBACK | NO_GETTEXT,
// 0, NULL, (void*) &AddToTourney, (char*) (engineMnemonic+1), (engineMnemonic+1), ComboBox, N_("Select Engine:") },
{ 0, 0, 10, NULL, (void*) &appData.tourneyType, "", NULL, Spin, N_("Tourney type (0 = round-robin, 1 = gauntlet):") },
{ 0, 1, 1000000000, NULL, (void*) &appData.tourneyCycles, "", NULL, Spin, N_("Number of tourney cycles (or Swiss rounds):") },
{ 0, 1, 1000000000, NULL, (void*) &appData.defaultMatchGames, "", NULL, Spin, N_("Default Number of Games in Match (or Pairing):") },
{ 0, 0, 1000000000, NULL, (void*) &appData.matchPause, "", NULL, Spin, N_("Pause between Match Games (msec):") },
{ 0, 0, 0, NULL, (void*) &appData.saveGameFile, ".pgn .game", NULL, FileName, N_("Save Tourney Games on:") },
{ 0, 0, 0, NULL, (void*) &appData.loadGameFile, ".pgn .game", NULL, FileName, N_("Game File with Opening Lines:") },
{ 0, -2, 1000000000, NULL, (void*) &appData.loadGameIndex, "", NULL, Spin, N_("Game Number (-1 or -2 = Auto-Increment):") },
{ 0, 0, 0, NULL, (void*) &appData.loadPositionFile, ".fen .epd .pos", NULL, FileName, N_("File with Start Positions:") },
{ 0, -2, 1000000000, NULL, (void*) &appData.loadPositionIndex, "", NULL, Spin, N_("Position Number (-1 or -2 = Auto-Increment):") },
{ 0, 0, 1000000000, NULL, (void*) &appData.rewindIndex, "", NULL, Spin, N_("Rewind Index after this many Games (0 = never):") },
{ 0, 0, 0, NULL, (void*) &appData.defNoBook, "", NULL, CheckBox, N_("Disable own engine books by default") },
{ 0, 0, 0, NULL, (void*) &DoTimeControl, NULL, NULL, Button, N_("Time Control") },
{ 0, SAME_ROW, 0, NULL, (void*) &DoCommonEngine, NULL, NULL, Button, N_("Common Engine") },
{ 0, SAME_ROW, 0, NULL, (void*) &DoGeneral, NULL, NULL, Button, N_("General Options") },
{ 0, SAME_ROW, 0, NULL, (void*) &PseudoOK, NULL, NULL, Button, N_("Continue Later") },
{ 0, 0, 0, NULL, (void*) &ReplaceParticipant, NULL, NULL, Button, N_("Replace Engine") },
{ 0, SAME_ROW, 0, NULL, (void*) &UpgradeParticipant, NULL, NULL, Button, N_("Upgrade Engine") },
{ 0, SAME_ROW, 0, NULL, (void*) &CloneTourney, NULL, NULL, Button, N_("Clone Tourney") },
{ 0, SAME_ROW, 0, NULL, (void*) &MatchOK, "", NULL, EndMark , "" }
};
static void
ReplaceParticipant ()
{
GenericReadout(matchOptions, PARTICIPANTS);
Substitute(strdup(engineName), True);
}
static void
UpgradeParticipant ()
{
GenericReadout(matchOptions, PARTICIPANTS);
Substitute(strdup(engineName), False);
}
static void
PseudoOK ()
{
GenericReadout(matchOptions, -2); // read all, but suppress calling of MatchOK
ASSIGN(appData.participants, engineName);
PopDown(MasterDlg); // early popdown to prevent FreezeUI called through MatchEvent from causing XtGrab warning
}
static void
CloneTourney ()
{
FILE *f;
char *name;
GetWidgetText(matchOptions, &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(matchOptions, -1);
FREE(appData.saveGameFile); appData.saveGameFile = saveSaveFile;
} else DisplayError(_("First you must specify an existing tourney file to clone"), 0);
}
static void
AddToTourney (int n, int sel)
{
int nr;
char buf[MSG_SIZ];
if(sel < 1) buf[0] = NULLCHAR; // back to top level
else if(engineList[sel][0] == '#') safeStrCpy(buf, engineList[sel], MSG_SIZ); // group header, open group
else { // normal line, select engine
AddLine(&matchOptions[PARTICIPANTS], engineMnemonic[sel]);
return;
}
nr = NamesToList(firstChessProgramNames, engineList, engineMnemonic, buf); // replace list by only the group contents
ASSIGN(engineMnemonic[0], buf);
LoadListBox(&matchOptions[PARTICIPANTS+1], _("# no engines are installed"), -1, -1);
HighlightWithScroll(&matchOptions[PARTICIPANTS+1], 0, nr);
}
void
MatchOptionsProc ()
{
if(matchOptions[PARTICIPANTS+1].type != ListBox) {
DisplayError(_("Internal error: PARTICIPANTS set wrong"), 0);
return;
}
NamesToList(firstChessProgramNames, engineList, engineMnemonic, "");
matchOptions[9].min = -(appData.pairingEngine[0] != NULLCHAR); // with pairing engine, allow Swiss
ASSIGN(tfName, appData.tourneyFile[0] ? appData.tourneyFile : MakeName(appData.defName));
ASSIGN(engineName, appData.participants);
ASSIGN(engineMnemonic[0], "");
GenericPopUp(matchOptions, _("Tournament Options"), MasterDlg, BoardWindow, MODAL, 0);
}
// ------------------------------------------- General Options --------------------------------------------------
static int oldShow, oldBlind, oldPonder;
static int
GeneralOptionsOK (int n)
{
int newPonder = appData.ponderNextMove;
appData.ponderNextMove = oldPonder;
PonderNextMoveEvent(newPonder);
if(!appData.highlightLastMove) ClearHighlights(), ClearPremoveHighlights();
if(oldShow != appData.showCoords || oldBlind != appData.blindfold) DrawPosition(TRUE, NULL);
return 1;
}
static Option generalOptions[] = {
{ 0, 0, 0, NULL, (void*) &appData.whitePOV, "", NULL, CheckBox, N_("Absolute Analysis Scores") },
{ 0, 0, 0, NULL, (void*) &appData.sweepSelect, "", NULL, CheckBox, N_("Almost Always Queen (Detour Under-Promote)") },
{ 0, 0, 0, NULL, (void*) &appData.animateDragging, "", NULL, CheckBox, N_("Animate Dragging") },
{ 0, 0, 0, NULL, (void*) &appData.animate, "", NULL, CheckBox, N_("Animate Moving") },
{ 0, 0, 0, NULL, (void*) &appData.autoCallFlag, "", NULL, CheckBox, N_("Auto Flag") },
{ 0, 0, 0, NULL, (void*) &appData.autoFlipView, "", NULL, CheckBox, N_("Auto Flip View") },
{ 0, 0, 0, NULL, (void*) &appData.blindfold, "", NULL, CheckBox, N_("Blindfold") },
/* TRANSLATORS: the drop menu is used to drop a piece, e.g. during bughouse or editing a position */
{ 0, 0, 0, NULL, (void*) &appData.dropMenu, "", NULL, CheckBox, N_("Drop Menu") },
{ 0, 0, 0, NULL, (void*) &appData.variations, "", NULL, CheckBox, N_("Enable Variation Trees") },
{ 0, 0, 0, NULL, (void*) &appData.headers, "", NULL, CheckBox, N_("Headers in Engine Output Window") },
{ 0, 0, 0, NULL, (void*) &appData.hideThinkingFromHuman, "", NULL, CheckBox, N_("Hide Thinking from Human") },
{ 0, 0, 0, NULL, (void*) &appData.highlightLastMove, "", NULL, CheckBox, N_("Highlight Last Move") },
{ 0, 0, 0, NULL, (void*) &appData.highlightMoveWithArrow, "", NULL, CheckBox, N_("Highlight with Arrow") },
{ 0, 0, 0, NULL, (void*) &appData.oneClick, "", NULL, CheckBox, N_("One-Click Moving") },
{ 0, 0, 0, NULL, (void*) &appData.periodicUpdates, "", NULL, CheckBox, N_("Periodic Updates (in Analysis Mode)") },
{ 0, SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, "" },
{ 0, 0, 0, NULL, (void*) &appData.autoExtend, "", NULL, CheckBox, N_("Play Move(s) of Clicked PV (Analysis)") },
{ 0, 0, 0, NULL, (void*) &appData.ponderNextMove, "", NULL, CheckBox, N_("Ponder Next Move") },
{ 0, 0, 0, NULL, (void*) &appData.popupExitMessage, "", NULL, CheckBox, N_("Popup Exit Messages") },
{ 0, 0, 0, NULL, (void*) &appData.popupMoveErrors, "", NULL, CheckBox, N_("Popup Move Errors") },
{ 0, 0, 0, NULL, (void*) &appData.showEvalInMoveHistory, "", NULL, CheckBox, N_("Scores in Move List") },
{ 0, 0, 0, NULL, (void*) &appData.showCoords, "", NULL, CheckBox, N_("Show Coordinates") },
{ 0, 0, 0, NULL, (void*) &appData.markers, "", NULL, CheckBox, N_("Show Target Squares") },
{ 0, 0, 0, NULL, (void*) &appData.useStickyWindows, "", NULL, CheckBox, N_("Sticky Windows") },
{ 0, 0, 0, NULL, (void*) &appData.testLegality, "", NULL, CheckBox, N_("Test Legality") },
{ 0, 0, 0, NULL, (void*) &appData.topLevel, "", NULL, CheckBox, N_("Top-Level Dialogs") },
{ 0, 0,10, NULL, (void*) &appData.flashCount, "", NULL, Spin, N_("Flash Moves (0 = no flashing):") },
{ 0, 1,10, NULL, (void*) &appData.flashRate, "", NULL, Spin, N_("Flash Rate (high = fast):") },
{ 0, 5,100, NULL, (void*) &appData.animSpeed, "", NULL, Spin, N_("Animation Speed (high = slow):") },
{ 0, 1,5, NULL, (void*) &appData.zoom, "", NULL, Spin, N_("Zoom factor in Evaluation Graph:") },
{ 0, 0, 0, NULL, (void*) &GeneralOptionsOK, "", NULL, EndMark , "" }
};
void
OptionsProc ()
{
oldPonder = appData.ponderNextMove;
oldShow = appData.showCoords; oldBlind = appData.blindfold;
GenericPopUp(generalOptions, _("General Options"), TransientDlg, BoardWindow, MODAL, 0);
}
//---------------------------------------------- New Variant ------------------------------------------------
static void Pick P((int n));
static char warning[MSG_SIZ];
static int ranksTmp, filesTmp, sizeTmp;
static Option variantDescriptors[] = {
{ VariantNormal, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("Normal")},
{ VariantMakruk, SAME_ROW, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("Makruk")},
{ VariantFischeRandom, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("FRC")},
{ VariantShatranj,SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("Shatranj")},
{ VariantWildCastle, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("Wild castle")},
{ VariantKnightmate,SAME_ROW,135,NULL,(void*) &Pick, "#FFFFFF", NULL, Button, N_("Knightmate")},
{ VariantNoCastle, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("No castle")},
{ VariantCylinder,SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("Cylinder *")},
{ Variant3Check, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("3-checks")},
{ VariantBerolina,SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("berolina *")},
{ VariantAtomic, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("atomic")},
{ VariantTwoKings,SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("two kings")},
{ -1, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_(" ")}, // dummy, to have good alignment
{ VariantSpartan,SAME_ROW, 135, NULL, (void*) &Pick, "#FF0000", NULL, Button, N_("Spartan")},
{ 0, 0, 0, NULL, NULL, NULL, NULL, Label, N_("Board size ( -1 = default for selected variant):")},
{ 0, -1, BOARD_RANKS-1, NULL, (void*) &ranksTmp, "", NULL, Spin, N_("Number of Board Ranks:") },
{ 0, -1, BOARD_FILES, NULL, (void*) &filesTmp, "", NULL, Spin, N_("Number of Board Files:") },
{ 0, -1, BOARD_RANKS-1, NULL, (void*) &sizeTmp, "", NULL, Spin, N_("Holdings Size:") },
{ 0, 0, 275, NULL, NULL, NULL, NULL, Label, warning },
{ 0, 0, 275, NULL, NULL, NULL, NULL, Label, N_("Variants marked with * can only be played\nwith legality testing off.")},
{ 0, SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, ""},
{ VariantASEAN, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("ASEAN")},
{ VariantGreat, SAME_ROW, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Great Shatranj (10x8)")},
{ VariantSChess, 0, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("Seirawan")},
{ VariantFalcon, SAME_ROW, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Falcon (10x8)")},
{ VariantSuper, 0, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("Superchess")},
{ VariantCapablanca,SAME_ROW,135,NULL,(void*) &Pick, "#BFBFFF", NULL, Button, N_("Capablanca (10x8)")},
{ VariantCrazyhouse, 0, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("Crazyhouse")},
{ VariantGothic, SAME_ROW, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Gothic (10x8)")},
{ VariantBughouse, 0, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("Bughouse")},
{ VariantJanus, SAME_ROW, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Janus (10x8)")},
{ VariantSuicide, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("Suicide")},
{ VariantCapaRandom,SAME_ROW,135,NULL,(void*) &Pick, "#BFBFFF", NULL, Button, N_("CRC (10x8)")},
{ VariantGiveaway, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("give-away")},
{ VariantGrand, SAME_ROW, 135, NULL, (void*) &Pick, "#5070FF", NULL, Button, N_("grand (10x10)")},
{ VariantLosers, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("losers")},
{ VariantShogi, SAME_ROW, 135, NULL, (void*) &Pick, "#BFFFFF", NULL, Button, N_("shogi (9x9)")},
{ VariantFairy, 0, 135, NULL, (void*) &Pick, "#BFBFBF", NULL, Button, N_("fairy")},
{ VariantXiangqi, SAME_ROW,135, NULL, (void*) &Pick, "#BFFFFF", NULL, Button, N_("xiangqi (9x10)")},
{ VariantLion, 0, 135, NULL, (void*) &Pick, "#BFBFBF", NULL, Button, N_("mighty lion")},
{ VariantCourier, SAME_ROW,135, NULL, (void*) &Pick, "#BFFFBF", NULL, Button, N_("courier (12x8)")},
{ VariantChuChess, 0, 135, NULL, (void*) &Pick, "#BFBFBF", NULL, Button, N_("elven chess (10x10)")},
{ VariantChu, SAME_ROW, 135, NULL, (void*) &Pick, "#BFFFBF", NULL, Button, N_("chu shogi (12x12)")},
//{ -1, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_(" ")}, // dummy, to have good alignment
// optional buttons for engine-defined variants
{ 0, NO_OK, 0, NULL, NULL, "", NULL, EndMark , "" },
{ 0, SAME_ROW, 0, NULL, NULL, NULL, NULL, Skip, ""},
{ VariantUnknown, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
{ 0, NO_OK, 0, NULL, NULL, "", NULL, EndMark , "" }
};
static void
Pick (int n)
{
VariantClass v = variantDescriptors[n].value;
if(v == VariantUnknown) safeStrCpy(engineVariant, variantDescriptors[n].name, MSG_SIZ); else *engineVariant = NULLCHAR;
GenericReadout(variantDescriptors, -1); // read new ranks and file settings
if(!appData.noChessProgram) {
char buf[MSG_SIZ];
if (!SupportedVariant(first.variants, v, filesTmp, ranksTmp, sizeTmp, first.protocolVersion, first.tidy)) {
DisplayError(variantError, 0);
return; /* ignore OK if first engine does not support it */
} else
if (second.initDone &&
!SupportedVariant(second.variants, v, filesTmp, ranksTmp, sizeTmp, second.protocolVersion, second.tidy)) {
snprintf(buf, MSG_SIZ, _("Warning: second engine (%s) does not support this!"), second.tidy);
DisplayError(buf, 0); /* use of second engine is optional; only warn user */
}
}
gameInfo.variant = v;
appData.variant = VariantName(v);
shuffleOpenings = FALSE; /* [HGM] shuffle: possible shuffle reset when we switch */
startedFromPositionFile = FALSE; /* [HGM] loadPos: no longer valid in new variant */
appData.fischerCastling = FALSE; /* [HGM] fischer: no longer valid in new variant */
appData.NrRanks = ranksTmp;
appData.NrFiles = filesTmp;
appData.holdingsSize = sizeTmp;
appData.pieceToCharTable = NULL;
appData.pieceNickNames = "";
appData.colorNickNames = "";
PopDown(TransientDlg);
Reset(True, True);
return;
}
void
NewVariantProc ()
{
static int start;
int i, last;
ranksTmp = filesTmp = sizeTmp = -1; // prefer defaults over actual settings
if(appData.noChessProgram) sprintf(warning, _("Only bughouse is not available in viewer mode.")); else
sprintf(warning, _("All variants not supported by the first engine\n(currently %s) are disabled."), first.tidy);
if(!start) {
while(variantDescriptors[start].type != EndMark) start++; // locate spares
start += 2; // conditional EndMark and Break
}
last = -1;
for(i=0; variantDescriptors[start+i].type != EndMark; i++) { // create buttons for engine-defined variants
char *v = EngineDefinedVariant(&first, i);
if(v) {
last = i;
ASSIGN(variantDescriptors[start+i].name, v);
variantDescriptors[start+i].type = Button;
} else variantDescriptors[start+i].type = Skip;
}
if(!(last&1)) { // odd number, add filler
ASSIGN(variantDescriptors[start+last+1].name, " ");
variantDescriptors[start+last+1].type = Button;
variantDescriptors[start+last+1].value = Skip;
}
variantDescriptors[start-2].type = (last < 0 ? EndMark : Skip);
variantDescriptors[start-1].type = (last < 6 ? Skip : Break);
safeStrCpy(engineVariant+100, engineVariant, 100); *engineVariant = NULLCHAR; // yeghh...
GenericPopUp(variantDescriptors, _("New Variant"), TransientDlg, BoardWindow, MODAL, 0);
safeStrCpy(engineVariant, engineVariant+100, MSG_SIZ); // must temporarily clear to avoid enabling all variant buttons
}
//------------------------------------------- Common Engine Options -------------------------------------
static int oldCores;
static char *egtPath;
static int
CommonOptionsOK (int n)
{
int newPonder = appData.ponderNextMove;
if(*egtPath != '/' && strchr(egtPath, ':')) {
ASSIGN(appData.egtFormats, egtPath);
} else {
ASSIGN(appData.defaultPathEGTB, egtPath);
}
// make sure changes are sent to first engine by re-initializing it
// if it was already started pre-emptively at end of previous game
if(gameMode == BeginningOfGame) Reset(True, True); else {
// Some changed setting need immediate sending always.
if(oldCores != appData.smpCores)
NewSettingEvent(False, &(first.maxCores), "cores", appData.smpCores);
appData.ponderNextMove = oldPonder;
PonderNextMoveEvent(newPonder);
}
return 1;
}
static Option commonEngineOptions[] = {
{ 0, 0, 0, NULL, (void*) &appData.ponderNextMove, "", NULL, CheckBox, N_("Ponder Next Move") },
{ 0, 0, 1000, NULL, (void*) &appData.smpCores, "", NULL, Spin, N_("Maximum Number of CPUs per Engine:") },
{ 0, 0, 0, NULL, (void*) &appData.polyglotDir, "", NULL, PathName, N_("Polygot Directory:") },
{ 0, 0,16000, NULL, (void*) &appData.defaultHashSize, "", NULL, Spin, N_("Hash-Table Size (MB):") },
{ 0, 0, 0, NULL, (void*) &egtPath, "", NULL, PathName, N_("EGTB Path:") },
{ 0, 0, 1000, NULL, (void*) &appData.defaultCacheSizeEGTB, "", NULL, Spin, N_("EGTB Cache Size (MB):") },
{ 0, 0, 0, NULL, (void*) &appData.usePolyglotBook, "", NULL, CheckBox, N_("Use GUI Book") },
{ 0, 0, 0, NULL, (void*) &appData.polyglotBook, ".bin", NULL, FileName, N_("Opening-Book Filename:") },
{ 0, 0, 100, NULL, (void*) &appData.bookDepth, "", NULL, Spin, N_("Book Depth (moves):") },
{ 0, 0, 100, NULL, (void*) &appData.bookStrength, "", NULL, Spin, N_("Book Variety (0) vs. Strength (100):") },
{ 0, 0, 0, NULL, (void*) &appData.firstHasOwnBookUCI, "", NULL, CheckBox, N_("Engine #1 Has Own Book") },
{ 0, 0, 0, NULL, (void*) &appData.secondHasOwnBookUCI, "", NULL, CheckBox, N_("Engine #2 Has Own Book ") },
{ 0,SAME_ROW,0,NULL, (void*) &CommonOptionsOK, "", NULL, EndMark , "" }
};
void
UciMenuProc ()
{
oldCores = appData.smpCores;
oldPonder = appData.ponderNextMove;
if(appData.egtFormats && *appData.egtFormats) { ASSIGN(egtPath, appData.egtFormats); }
else { ASSIGN(egtPath, appData.defaultPathEGTB); }
GenericPopUp(commonEngineOptions, _("Common Engine Settings"), TransientDlg, BoardWindow, MODAL, 0);
}
//------------------------------------------ Adjudication Options --------------------------------------
static Option adjudicationOptions[] = {
{ 0, 0, 0, NULL, (void*) &appData.checkMates, "", NULL, CheckBox, N_("Detect all Mates") },
{ 0, 0, 0, NULL, (void*) &appData.testClaims, "", NULL, CheckBox, N_("Verify Engine Result Claims") },
{ 0, 0, 0, NULL, (void*) &appData.materialDraws, "", NULL, CheckBox, N_("Draw if Insufficient Mating Material") },
{ 0, 0, 0, NULL, (void*) &appData.trivialDraws, "", NULL, CheckBox, N_("Adjudicate Trivial Draws (3-Move Delay)") },
{ 0, 0,100, NULL, (void*) &appData.ruleMoves, "", NULL, Spin, N_("N-Move Rule:") },
{ 0, 0, 6, NULL, (void*) &appData.drawRepeats, "", NULL, Spin, N_("N-fold Repeats:") },
{ 0, 0,1000, NULL, (void*) &appData.adjudicateDrawMoves, "", NULL, Spin, N_("Draw after N Moves Total:") },
{ 0, -5000,0, NULL, (void*) &appData.adjudicateLossThreshold, "", NULL, Spin, N_("Win / Loss Threshold:") },
{ 0, 0, 0, NULL, (void*) &first.scoreIsAbsolute, "", NULL, CheckBox, N_("Negate Score of Engine #1") },
{ 0, 0, 0, NULL, (void*) &second.scoreIsAbsolute, "", NULL, CheckBox, N_("Negate Score of Engine #2") },
{ 0,SAME_ROW, 0, NULL, NULL, "", NULL, EndMark , "" }
};
void
EngineMenuProc ()
{
GenericPopUp(adjudicationOptions, _("Adjudicate non-ICS Games"), TransientDlg, BoardWindow, MODAL, 0);
}
//--------------------------------------------- ICS Options ---------------------------------------------
static int
IcsOptionsOK (int n)
{
ParseIcsTextColors();
return 1;
}
Option icsOptions[] = {
{ 0, 0, 0, NULL, (void*) &appData.autoKibitz, "", NULL, CheckBox, N_("Auto-Kibitz") },
{ 0, 0, 0, NULL, (void*) &appData.autoComment, "", NULL, CheckBox, N_("Auto-Comment") },
{ 0, 0, 0, NULL, (void*) &appData.autoObserve, "", NULL, CheckBox, N_("Auto-Observe") },
{ 0, 0, 0, NULL, (void*) &appData.autoRaiseBoard, "", NULL, CheckBox, N_("Auto-Raise Board") },
{ 0, 0, 0, NULL, (void*) &appData.autoCreateLogon, "", NULL, CheckBox, N_("Auto-Create Logon Script") },
{ 0, 0, 0, NULL, (void*) &appData.bgObserve, "", NULL, CheckBox, N_("Background Observe while Playing") },
{ 0, 0, 0, NULL, (void*) &appData.dualBoard, "", NULL, CheckBox, N_("Dual Board for Background-Observed Game") },
{ 0, 0, 0, NULL, (void*) &appData.getMoveList, "", NULL, CheckBox, N_("Get Move List") },
{ 0, 0, 0, NULL, (void*) &appData.quietPlay, "", NULL, CheckBox, N_("Quiet Play") },
{ 0, 0, 0, NULL, (void*) &appData.seekGraph, "", NULL, CheckBox, N_("Seek Graph") },
{ 0, 0, 0, NULL, (void*) &appData.autoRefresh, "", NULL, CheckBox, N_("Auto-Refresh Seek Graph") },
{ 0, 0, 0, NULL, (void*) &appData.autoBox, "", NULL, CheckBox, N_("Auto-InputBox PopUp") },
{ 0, 0, 0, NULL, (void*) &appData.quitNext, "", NULL, CheckBox, N_("Quit after game") },
{ 0, 0, 0, NULL, (void*) &appData.premove, "", NULL, CheckBox, N_("Premove") },
{ 0, 0, 0, NULL, (void*) &appData.premoveWhite, "", NULL, CheckBox, N_("Premove for White") },
{ 0, 0, 0, NULL, (void*) &appData.premoveWhiteText, "", NULL, TextBox, N_("First White Move:") },
{ 0, 0, 0, NULL, (void*) &appData.premoveBlack, "", NULL, CheckBox, N_("Premove for Black") },
{ 0, 0, 0, NULL, (void*) &appData.premoveBlackText, "", NULL, TextBox, N_("First Black Move:") },
{ 0, SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, "" },
{ 0, 0, 0, NULL, (void*) &appData.icsAlarm, "", NULL, CheckBox, N_("Alarm") },
{ 0, 0, 100000000, NULL, (void*) &appData.icsAlarmTime, "", NULL, Spin, N_("Alarm Time (msec):") },
//{ 0, 0, 0, NULL, (void*) &appData.chatBoxes, "", NULL, TextBox, N_("Startup Chat Boxes:") },
{ 0, 0, 0, NULL, (void*) &appData.colorize, "", NULL, CheckBox, N_("Colorize Messages") },
{ 0, 0, 0, NULL, (void*) &appData.colorShout, "", NULL, TextBox, N_("Shout Text Colors:") },
{ 0, 0, 0, NULL, (void*) &appData.colorSShout, "", NULL, TextBox, N_("S-Shout Text Colors:") },
{ 0, 0, 0, NULL, (void*) &appData.colorChannel1, "", NULL, TextBox, N_("Channel #1 Text Colors:") },
{ 0, 0, 0, NULL, (void*) &appData.colorChannel, "", NULL, TextBox, N_("Other Channel Text Colors:") },
{ 0, 0, 0, NULL, (void*) &appData.colorKibitz, "", NULL, TextBox, N_("Kibitz Text Colors:") },
{ 0, 0, 0, NULL, (void*) &appData.colorTell, "", NULL, TextBox, N_("Tell Text Colors:") },
{ 0, 0, 0, NULL, (void*) &appData.colorChallenge, "", NULL, TextBox, N_("Challenge Text Colors:") },
{ 0, 0, 0, NULL, (void*) &appData.colorRequest, "", NULL, TextBox, N_("Request Text Colors:") },
{ 0, 0, 0, NULL, (void*) &appData.colorSeek, "", NULL, TextBox, N_("Seek Text Colors:") },
{ 0, 0, 0, NULL, (void*) &appData.colorNormal, "", NULL, TextBox, N_("Other Text Colors:") },
{ 0, 0, 0, NULL, (void*) &IcsOptionsOK, "", NULL, EndMark , "" }
};
void
IcsOptionsProc ()
{
GenericPopUp(icsOptions, _("ICS Options"), TransientDlg, BoardWindow, MODAL, 0);
}
//-------------------------------------------- Load Game Options ---------------------------------
static char *modeNames[] = { N_("Exact position match"), N_("Shown position is subset"), N_("Same material with exactly same Pawn chain"),
N_("Same material"), N_("Material range (top board half optional)"), N_("Material difference (optional stuff balanced)"), NULL };
static char *modeValues[] = { "1", "2", "3", "4", "5", "6" };
static char *searchMode, *countRange;
static int
LoadOptionsOK ()
{
appData.minPieces = appData.maxPieces = 0;
sscanf(countRange, "%d-%d", &appData.minPieces, &appData.maxPieces);
if(appData.maxPieces < appData.minPieces) appData.maxPieces = appData.minPieces;
appData.searchMode = atoi(searchMode);
return 1;
}
static Option loadOptions[] = {
{ 0, 0, 0, NULL, (void*) &appData.autoDisplayTags, "", NULL, CheckBox, N_("Auto-Display Tags") },
{ 0, 0, 0, NULL, (void*) &appData.autoDisplayComment, "", NULL, CheckBox, N_("Auto-Display Comment") },
{ 0, LR, 0, NULL, NULL, NULL, NULL, Label, N_("Auto-Play speed of loaded games\n(0 = instant, -1 = off):") },
{ 0, -1,10000000, NULL, (void*) &appData.timeDelay, "", NULL, Fractional, N_("Seconds per Move:") },
{ 0, LR, 0, NULL, NULL, NULL, NULL, Label, N_("\noptions to use in game-viewer mode:") },
{ 0, 0,300, NULL, (void*) &appData.viewerOptions, "", NULL, TextBox, "" },
{ 0, LR, 0, NULL, NULL, NULL, NULL, Label, N_("\nThresholds for position filtering in game list:") },
{ 0, 0,5000, NULL, (void*) &appData.eloThreshold1, "", NULL, Spin, N_("Elo of strongest player at least:") },
{ 0, 0,5000, NULL, (void*) &appData.eloThreshold2, "", NULL, Spin, N_("Elo of weakest player at least:") },
{ 0, 0,5000, NULL, (void*) &appData.dateThreshold, "", NULL, Spin, N_("No games before year:") },
{ 0, 1,50, NULL, (void*) &appData.stretch, "", NULL, Spin, N_("Minimum nr consecutive positions:") },
{ 0, 0,197, NULL, (void*) &countRange, "", NULL, TextBox, "Final nr of pieces" },
{ 0, 0,205, NULL, (void*) &searchMode, (char*) modeValues, modeNames, ComboBox, N_("Search mode:") },
{ 0, 0, 0, NULL, (void*) &appData.ignoreColors, "", NULL, CheckBox, N_("Also match reversed colors") },
{ 0, 0, 0, NULL, (void*) &appData.findMirror, "", NULL, CheckBox, N_("Also match left-right flipped position") },
{ 0, 0, 0, NULL, (void*) &LoadOptionsOK, "", NULL, EndMark , "" }
};
void
LoadOptionsPopUp (DialogClass parent)
{
ASSIGN(countRange, "");
ASSIGN(searchMode, modeValues[appData.searchMode-1]);
GenericPopUp(loadOptions, _("Load Game Options"), TransientDlg, parent, MODAL, 0);
}
void
LoadOptionsProc ()
{ // called from menu
LoadOptionsPopUp(BoardWindow);
}
//------------------------------------------- Save Game Options --------------------------------------------
static Option saveOptions[] = {
{ 0, 0, 0, NULL, (void*) &appData.autoSaveGames, "", NULL, CheckBox, N_("Auto-Save Games") },
{ 0, 0, 0, NULL, (void*) &appData.onlyOwn, "", NULL, CheckBox, N_("Own Games Only") },
{ 0, 0, 0, NULL, (void*) &appData.saveGameFile, ".pgn", NULL, FileName, N_("Save Games on File:") },
{ 0, 0, 0, NULL, (void*) &appData.savePositionFile, ".fen", NULL, FileName, N_("Save Final Positions on File:") },
{ 0, 0, 0, NULL, (void*) &appData.pgnEventHeader, "", NULL, TextBox, N_("PGN Event Header:") },
{ 0, 0, 0, NULL, (void*) &appData.oldSaveStyle, "", NULL, CheckBox, N_("Old Save Style (as opposed to PGN)") },
{ 0, 0, 0, NULL, (void*) &appData.numberTag, "", NULL, CheckBox, N_("Include Number Tag in tourney PGN") },
{ 0, 0, 0, NULL, (void*) &appData.saveExtendedInfoInPGN, "", NULL, CheckBox, N_("Save Score/Depth Info in PGN") },
{ 0, 0, 0, NULL, (void*) &appData.saveOutOfBookInfo, "", NULL, CheckBox, N_("Save Out-of-Book Info in PGN ") },
{ 0, SAME_ROW, 0, NULL, NULL, "", NULL, EndMark , "" }
};
void
SaveOptionsProc ()
{
GenericPopUp(saveOptions, _("Save Game Options"), TransientDlg, BoardWindow, MODAL, 0);
}
//----------------------------------------------- Sound Options ---------------------------------------------
static void Test P((int n));
static char *trialSound;
static char *soundNames[] = {
N_("No Sound"),
N_("Default Beep"),
N_("Above WAV File"),
N_("Car Horn"),
N_("Cymbal"),
N_("Ding"),
N_("Gong"),
N_("Laser"),
N_("Penalty"),
N_("Phone"),
N_("Pop"),
N_("Roar"),
N_("Slap"),
N_("Wood Thunk"),
NULL,
N_("User File")
};
static char *soundFiles[] = { // sound files corresponding to above names
"",
"$",
NULL, // kludge alert: as first thing in the dialog readout this is replaced with the user-given .WAV filename
"honkhonk.wav",
"cymbal.wav",
"ding1.wav",
"gong.wav",
"laser.wav",
"penalty.wav",
"phone.wav",
"pop2.wav",
"roar.wav",
"slap.wav",
"woodthunk.wav",
NULL,
NULL
};
static Option soundOptions[] = {
{ 0, 0, 0, NULL, (void*) (soundFiles+2) /* kludge! */, ".wav", NULL, FileName, N_("User WAV File:") },
{ 0, 0, 0, NULL, (void*) &appData.soundProgram, "", NULL, TextBox, N_("Sound Program:") },
{ 0, 0, 0, NULL, (void*) &trialSound, (char*) soundFiles, soundNames, ComboBox, N_("Try-Out Sound:") },
{ 0, SAME_ROW, 0, NULL, (void*) &Test, NULL, NULL, Button, N_("Play") },
{ 0, 0, 0, NULL, (void*) &appData.soundMove, (char*) soundFiles, soundNames, ComboBox, N_("Move:") },
{ 0, 0, 0, NULL, (void*) &appData.soundIcsWin, (char*) soundFiles, soundNames, ComboBox, N_("Win:") },
{ 0, 0, 0, NULL, (void*) &appData.soundIcsLoss, (char*) soundFiles, soundNames, ComboBox, N_("Lose:") },
{ 0, 0, 0, NULL, (void*) &appData.soundIcsDraw, (char*) soundFiles, soundNames, ComboBox, N_("Draw:") },
{ 0, 0, 0, NULL, (void*) &appData.soundIcsUnfinished, (char*) soundFiles, soundNames, ComboBox, N_("Unfinished:") },
{ 0, 0, 0, NULL, (void*) &appData.soundIcsAlarm, (char*) soundFiles, soundNames, ComboBox, N_("Alarm:") },
{ 0, 0, 0, NULL, (void*) &appData.soundChallenge, (char*) soundFiles, soundNames, ComboBox, N_("Challenge:") },
{ 0, SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, "" },
{ 0, 0, 0, NULL, (void*) &appData.soundDirectory, "", NULL, PathName, N_("Sounds Directory:") },
{ 0, 0, 0, NULL, (void*) &appData.soundShout, (char*) soundFiles, soundNames, ComboBox, N_("Shout:") },
{ 0, 0, 0, NULL, (void*) &appData.soundSShout, (char*) soundFiles, soundNames, ComboBox, N_("S-Shout:") },
{ 0, 0, 0, NULL, (void*) &appData.soundChannel, (char*) soundFiles, soundNames, ComboBox, N_("Channel:") },
{ 0, 0, 0, NULL, (void*) &appData.soundChannel1, (char*) soundFiles, soundNames, ComboBox, N_("Channel 1:") },
{ 0, 0, 0, NULL, (void*) &appData.soundTell, (char*) soundFiles, soundNames, ComboBox, N_("Tell:") },
{ 0, 0, 0, NULL, (void*) &appData.soundKibitz, (char*) soundFiles, soundNames, ComboBox, N_("Kibitz:") },
{ 0, 0, 0, NULL, (void*) &appData.soundRequest, (char*) soundFiles, soundNames, ComboBox, N_("Request:") },
{ 0, 0, 0, NULL, (void*) &appData.soundRoar, (char*) soundFiles, soundNames, ComboBox, N_("Lion roar:") },
{ 0, 0, 0, NULL, (void*) &appData.soundSeek, (char*) soundFiles, soundNames, ComboBox, N_("Seek:") },
{ 0, SAME_ROW, 0, NULL, NULL, "", NULL, EndMark , "" }
};
static void
Test (int n)
{
GenericReadout(soundOptions, 1);
if(soundFiles[values[2]]) PlaySoundFile(soundFiles[values[2]]);
}
void
SoundOptionsProc ()
{
free(soundFiles[2]);
soundFiles[2] = strdup("*");
GenericPopUp(soundOptions, _("Sound Options"), TransientDlg, BoardWindow, MODAL, 0);
}
//--------------------------------------------- Board Options --------------------------------------
static void DefColor P((int n));
static void AdjustColor P((int i));
static void ThemeSel P((int n, int sel));
static int BoardOptionsOK P((int n));
static char oldPieceDir[MSG_SIZ];
extern char *engineLine, *nickName; // defined later on
#define THEMELIST 1
static Option boardOptions[] = {
{ 0,LR|T2T, 0, NULL, NULL, NULL, NULL, Label, N_("Selectable themes:") },
{ 300,LR|TB,200, NULL, (void*) engineMnemonic, (char*) &ThemeSel, NULL, ListBox, "" },
{ 0,LR|T2T, 0, NULL, NULL, NULL, NULL, Label, N_("New name for current theme:") },
{ 0, 0, 0, NULL, (void*) &nickName, "", NULL, TextBox, "" },
{ 0,SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, NULL },
{ 0, 0, 70, NULL, (void*) &appData.whitePieceColor, "", NULL, TextBox, N_("White Piece Color:") },
{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#FFFFCC", Button, " " },
/* TRANSLATORS: R = single letter for the color red */
{ 1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
/* TRANSLATORS: G = single letter for the color green */
{ 2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
/* TRANSLATORS: B = single letter for the color blue */
{ 3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
/* TRANSLATORS: D = single letter to make a color darker */
{ 4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
{ 0, 0, 70, NULL, (void*) &appData.blackPieceColor, "", NULL, TextBox, N_("Black Piece Color:") },
{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#202020", Button, " " },
{ 1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
{ 2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
{ 3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
{ 4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
{ 0, 0, 70, NULL, (void*) &appData.lightSquareColor, "", NULL, TextBox, N_("Light Square Color:") },
{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#C8C365", Button, " " },
{ 1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
{ 2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
{ 3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
{ 4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
{ 0, 0, 70, NULL, (void*) &appData.darkSquareColor, "", NULL, TextBox, N_("Dark Square Color:") },
{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#77A26D", Button, " " },
{ 1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
{ 2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
{ 3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
{ 4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
{ 0, 0, 70, NULL, (void*) &appData.highlightSquareColor, "", NULL, TextBox, N_("Highlight Color:") },
{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#FFFF00", Button, " " },
{ 1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
{ 2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
{ 3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
{ 4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
{ 0, 0, 70, NULL, (void*) &appData.premoveHighlightColor, "", NULL, TextBox, N_("Premove Highlight Color:") },
{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#FF0000", Button, " " },
{ 1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
{ 2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
{ 3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
{ 4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
{ 0, 0, 0, NULL, (void*) &appData.upsideDown, "", NULL, CheckBox, N_("Flip Pieces Shogi Style (Colored buttons restore default)") },
//{ 0, 0, 0, NULL, (void*) &appData.allWhite, "", NULL, CheckBox, N_("Use Outline Pieces for Black") },
{ 0, 0, 0, NULL, (void*) &appData.monoMode, "", NULL, CheckBox, N_("Mono Mode") },
{ 0, 0, 200, NULL, (void*) &appData.logoSize, "", NULL, Spin, N_("Logo Size (0=off, requires restart):") },
{ 0,-1, 5, NULL, (void*) &appData.overrideLineGap, "", NULL, Spin, N_("Line Gap (-1 = default for board size):") },
{ 0, 0, 0, NULL, (void*) &appData.useBitmaps, "", NULL, CheckBox, N_("Use Board Textures") },
{ 0, 0, 0, NULL, (void*) &appData.liteBackTextureFile, ".png", NULL, FileName, N_("Light-Squares Texture File:") },
{ 0, 0, 0, NULL, (void*) &appData.darkBackTextureFile, ".png", NULL, FileName, N_("Dark-Squares Texture File:") },
{ 0, 0, 0, NULL, (void*) &appData.trueColors, "", NULL, CheckBox, N_("Use external piece bitmaps with their own colors") },
{ 0, 0, 0, NULL, (void*) &appData.pieceDirectory, "", NULL, PathName, N_("Directory with Pieces Images:") },
{ 0, 0, 0, NULL, (void*) &BoardOptionsOK, "", NULL, EndMark , "" }
};
static int
BoardOptionsOK (int n)
{
if(n && (n = SelectedListBoxItem(&boardOptions[THEMELIST])) > 0 && *engineList[n] != '#') { // called by pressing OK, and theme selected
ASSIGN(engineLine, engineList[n]);
}
LoadTheme();
return 1;
}
static void
SetColorText (int n, char *buf)
{
SetWidgetText(&boardOptions[n-1], buf, TransientDlg);
SetColor(buf, &boardOptions[n]);
}
static void
DefColor (int n)
{
SetColorText(n, (char*) boardOptions[n].choice);
}
void
RefreshColor (int source, int n)
{
int col, j, r, g, b, step = 10;
char *s, buf[MSG_SIZ]; // color string
GetWidgetText(&boardOptions[source], &s);
if(sscanf(s, "#%x", &col) != 1) return; // malformed
b = col & 0xFF; g = col & 0xFF00; r = col & 0xFF0000;
switch(n) {
case 1: r += 0x10000*step;break;
case 2: g += 0x100*step; break;
case 3: b += step; break;
case 4: r -= 0x10000*step; g -= 0x100*step; b -= step; break;
}
if(r < 0) r = 0; if(g < 0) g = 0; if(b < 0) b = 0;
if(r > 0xFF0000) r = 0xFF0000; if(g > 0xFF00) g = 0xFF00; if(b > 0xFF) b = 0xFF;
col = r | g | b;
snprintf(buf, MSG_SIZ, "#%06x", col);
for(j=1; j<7; j++) if(buf[j] >= 'a') buf[j] -= 32; // capitalize
SetColorText(source+1, buf);
}
static void
AdjustColor (int i)
{
int n = boardOptions[i].value;
RefreshColor(i-n-1, n);
}
void
ThemeSel (int n, int sel)
{
int nr;