2 * menus.c -- platform-indendent menu handling code for XBoard
4 * Copyright 1991 by Digital Equipment Corporation, Maynard,
7 * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
8 * 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
10 * The following terms apply to Digital Equipment Corporation's copyright
12 * ------------------------------------------------------------------------
15 * Permission to use, copy, modify, and distribute this software and its
16 * documentation for any purpose and without fee is hereby granted,
17 * provided that the above copyright notice appear in all copies and that
18 * both that copyright notice and this permission notice appear in
19 * supporting documentation, and that the name of Digital not be
20 * used in advertising or publicity pertaining to distribution of the
21 * software without specific, written prior permission.
23 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
24 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
25 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
26 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
27 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
28 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
30 * ------------------------------------------------------------------------
32 * The following terms apply to the enhanced version of XBoard
33 * distributed by the Free Software Foundation:
34 * ------------------------------------------------------------------------
36 * GNU XBoard is free software: you can redistribute it and/or modify
37 * it under the terms of the GNU General Public License as published by
38 * the Free Software Foundation, either version 3 of the License, or (at
39 * your option) any later version.
41 * GNU XBoard is distributed in the hope that it will be useful, but
42 * WITHOUT ANY WARRANTY; without even the implied warranty of
43 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44 * General Public License for more details.
46 * You should have received a copy of the GNU General Public License
47 * along with this program. If not, see http://www.gnu.org/licenses/. *
49 *------------------------------------------------------------------------
50 ** See the file ChangeLog for a revision history. */
60 #include <sys/types.h>
68 #else /* not STDC_HEADERS */
69 extern char *getenv();
72 # else /* not HAVE_STRING_H */
74 # endif /* not HAVE_STRING_H */
75 #endif /* not STDC_HEADERS */
85 // [HGM] bitmaps: put before incuding the bitmaps / pixmaps, to know how many piece types there are.
94 # define _(s) gettext (s)
95 # define N_(s) gettext_noop (s)
102 * Button/menu procedures
105 char *gameCopyFilename, *gamePasteFilename;
106 Boolean saveSettingsOnExit;
107 char *settingsFileName;
110 LoadGamePopUp (FILE *f, int gameNumber, char *title)
112 cmailMsgLoaded = FALSE;
113 if (gameNumber == 0) {
114 int error = GameListBuild(f);
116 DisplayError(_("Cannot build game list"), error);
117 } else if (!ListEmpty(&gameList) &&
118 ((ListGame *) gameList.tailPred)->number > 1) {
119 GameListPopUp(f, title);
125 return LoadGame(f, gameNumber, title, FALSE);
131 if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
134 FileNamePopUp(_("Load game file name?"), "", ".pgn .game", LoadGamePopUp, "rb");
156 LoadNextPositionProc ()
162 LoadPrevPositionProc ()
168 ReloadPositionProc ()
176 if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
179 FileNamePopUp(_("Load position file name?"), "", ".fen .epd .pos", LoadPosition, "rb");
185 FileNamePopUp(_("Save game file name?"),
186 DefaultFileName(appData.oldSaveStyle ? "game" : "pgn"),
187 appData.oldSaveStyle ? ".game" : ".pgn",
194 FileNamePopUp(_("Save position file name?"),
195 DefaultFileName(appData.oldSaveStyle ? "pos" : "fen"),
196 appData.oldSaveStyle ? ".pos" : ".fen",
201 ReloadCmailMsgProc ()
203 ReloadCmailMsgEvent(FALSE);
207 CopyFENToClipboard ()
208 { // wrapper to make call from back-end possible
215 static char *selected_fen_position=NULL;
216 if(gameMode == EditPosition) EditPositionDone(TRUE);
217 if (selected_fen_position) free(selected_fen_position);
218 selected_fen_position = (char *)PositionToFEN(currentMove, NULL);
219 if (!selected_fen_position) return;
220 CopySomething(selected_fen_position);
228 ret = SaveGameToFile(gameCopyFilename, FALSE);
237 if(!SaveGameListAsText(fopen(gameCopyFilename, "w"))) return;
263 UserAdjudicationEvent(+1);
269 UserAdjudicationEvent(-1);
275 UserAdjudicationEvent(0);
293 if(twoBoards) { partnerUp = 1; DrawPosition(True, NULL); partnerUp = 0; }
294 flipView = !flipView;
295 DrawPosition(True, NULL);
301 saveSettingsOnExit = !saveSettingsOnExit;
303 MarkMenuItem("Options.SaveSettingsonExit", saveSettingsOnExit);
309 SaveSettings(settingsFileName);
316 snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
325 snprintf(buf, MSG_SIZ, "%s mailto:bug-xboard@gnu.org", appData.sysOpen);
333 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/user_guide/UserGuide.html", appData.sysOpen);
341 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/", appData.sysOpen);
349 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/whats_new/portal.html", appData.sysOpen);
356 char buf[2 * MSG_SIZ];
358 char *zippy = _(" (with Zippy code)");
362 snprintf(buf, sizeof(buf),
364 "Copyright 1991 Digital Equipment Corporation\n"
365 "Enhancements Copyright 1992-2012 Free Software Foundation\n"
366 "Enhancements Copyright 2005 Alessandro Scotti\n\n"
367 "%s is free software and carries NO WARRANTY;"
368 "see the file COPYING for more information.\n\n"
369 "Visit XBoard on the web at: http://www.gnu.org/software/xboard/\n"
370 "Check out the newest features at: http://www.gnu.org/software/xboard/whats_new.html\n\n"
371 "Report bugs via email at: <bug-xboard@gnu.org>\n\n"
373 programVersion, zippy, PACKAGE);
374 ErrorPopUp(_("About XBoard"), buf, FALSE);
380 appData.debugMode = !appData.debugMode;
381 if(!strcmp(appData.nameOfDebugFile, "stderr")) return; // stderr is already open, and should never be closed
382 if(!appData.debugMode) fclose(debugFP);
384 debugFP = fopen(appData.nameOfDebugFile, "w");
385 if(debugFP == NULL) debugFP = stderr;
386 else setbuf(debugFP, NULL);
397 # define MARK_MENU_ITEM(X,Y)
399 # define MARK_MENU_ITEM(X,Y) MarkMenuItem(X, Y)
403 PonderNextMoveProc ()
405 PonderNextMoveEvent(!appData.ponderNextMove);
406 MARK_MENU_ITEM("Options.PonderNextMove", appData.ponderNextMove);
412 appData.alwaysPromoteToQueen = !appData.alwaysPromoteToQueen;
413 MARK_MENU_ITEM("Options.AlwaysQueen", appData.alwaysPromoteToQueen);
417 AnimateDraggingProc ()
419 appData.animateDragging = !appData.animateDragging;
421 if (appData.animateDragging) CreateAnimVars();
422 MARK_MENU_ITEM("Options.AnimateDragging", appData.animateDragging);
428 appData.animate = !appData.animate;
429 if (appData.animate) CreateAnimVars();
430 MARK_MENU_ITEM("Options.AnimateMoving", appData.animate);
436 appData.autoCallFlag = !appData.autoCallFlag;
437 MARK_MENU_ITEM("Options.AutoFlag", appData.autoCallFlag);
443 appData.autoFlipView = !appData.autoFlipView;
444 MARK_MENU_ITEM("Options.AutoFlipView", appData.autoFlipView);
450 appData.blindfold = !appData.blindfold;
451 MARK_MENU_ITEM("Options.Blindfold", appData.blindfold);
452 DrawPosition(True, NULL);
458 appData.testLegality = !appData.testLegality;
459 MARK_MENU_ITEM("Options.TestLegality", appData.testLegality);
466 if (appData.flashCount == 0) {
467 appData.flashCount = 3;
469 appData.flashCount = -appData.flashCount;
471 MARK_MENU_ITEM("Options.FlashMoves", appData.flashCount > 0);
476 HighlightDraggingProc ()
478 appData.highlightDragging = !appData.highlightDragging;
479 MARK_MENU_ITEM("Options.HighlightDragging", appData.highlightDragging);
484 HighlightLastMoveProc ()
486 appData.highlightLastMove = !appData.highlightLastMove;
487 MARK_MENU_ITEM("Options.HighlightLastMove", appData.highlightLastMove);
491 HighlightArrowProc ()
493 appData.highlightMoveWithArrow = !appData.highlightMoveWithArrow;
494 MARK_MENU_ITEM("Options.HighlightWithArrow", appData.highlightMoveWithArrow);
500 appData.icsAlarm = !appData.icsAlarm;
501 // MARK_MENU_ITEM("Options.ICSAlarm", appData.icsAlarm);
507 appData.ringBellAfterMoves = !appData.ringBellAfterMoves;
508 MARK_MENU_ITEM("Options.MoveSound", appData.ringBellAfterMoves);
514 appData.oneClick = !appData.oneClick;
515 MARK_MENU_ITEM("Options.OneClickMoving", appData.oneClick);
519 PeriodicUpdatesProc ()
521 PeriodicUpdatesEvent(!appData.periodicUpdates);
522 MARK_MENU_ITEM("Options.PeriodicUpdates", appData.periodicUpdates);
526 PopupExitMessageProc ()
528 appData.popupExitMessage = !appData.popupExitMessage;
529 MARK_MENU_ITEM("Options.PopupExitMessage", appData.popupExitMessage);
533 PopupMoveErrorsProc ()
535 appData.popupMoveErrors = !appData.popupMoveErrors;
536 MARK_MENU_ITEM("Options.PopupMoveErrors", appData.popupMoveErrors);
542 appData.premove = !appData.premove;
543 // MARK_MENU_ITEM("Options.Premove", appData.premove);
549 appData.showCoords = !appData.showCoords;
550 MARK_MENU_ITEM("Options.ShowCoords", appData.showCoords);
551 DrawPosition(True, NULL);
557 appData.showThinking = !appData.showThinking; // [HGM] thinking: taken out of ShowThinkingEvent
564 appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; // [HGM] thinking: taken out of ShowThinkingEvent
567 MARK_MENU_ITEM("Options.HideThinking", appData.hideThinkingFromHuman);
573 ScheduleDelayedEvent(CreateBookEvent, 50);
577 * Menu definition tables
580 MenuItem fileMenu[] = {
581 {N_("New Game Ctrl+N"), "NewGame", ResetGameEvent},
582 {N_("New Shuffle Game ..."), "NewShuffleGame", ShuffleMenuProc},
583 {N_("New Variant ... Alt+Shift+V"), "NewVariant", NewVariantProc}, // [HGM] variant: not functional yet
584 {"----", NULL, NothingProc},
585 {N_("Load Game Ctrl+O"), "LoadGame", LoadGameProc, CHECK},
586 {N_("Load Position Ctrl+Shift+O"), "LoadPosition", LoadPositionProc},
587 // {N_("Load Next Game"), "LoadNextGame", LoadNextGameProc},
588 // {N_("Load Previous Game"), "LoadPreviousGame", LoadPrevGameProc},
589 // {N_("Reload Same Game"), "ReloadSameGame", ReloadGameProc},
590 {N_("Next Position Shift+PgDn"), "LoadNextPosition", LoadNextPositionProc},
591 {N_("Prev Position Shift+PgUp"), "LoadPreviousPosition", LoadPrevPositionProc},
592 {"----", NULL, NothingProc},
593 // {N_("Reload Same Position"), "Reload Same Position", ReloadPositionProc},
594 {N_("Save Game Ctrl+S"), "SaveGame", SaveGameProc},
595 {N_("Save Position Ctrl+Shift+S"), "SavePosition", SavePositionProc},
596 {N_("Save Games as Book"), "CreateBook", CreateBookDelayed},
597 {"----", NULL, NothingProc},
598 {N_("Mail Move"), "MailMove", MailMoveEvent},
599 {N_("Reload CMail Message"), "ReloadCMailMessage", ReloadCmailMsgProc},
600 {"----", NULL, NothingProc},
601 {N_("Quit Ctr+Q"), "Quit", QuitProc},
605 MenuItem editMenu[] = {
606 {N_("Copy Game Ctrl+C"), "CopyGame", CopyGameProc},
607 {N_("Copy Position Ctrl+Shift+C"), "CopyPosition", CopyPositionProc},
608 {N_("Copy Game List"), "CopyGameList", CopyGameListProc},
609 {"----", NULL, NothingProc},
610 {N_("Paste Game Ctrl+V"), "PasteGame", PasteGameProc},
611 {N_("Paste Position Ctrl+Shift+V"), "PastePosition", PastePositionProc},
612 {"----", NULL, NothingProc},
613 {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent},
614 {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent},
615 {N_("Edit Tags"), "EditTags", EditTagsProc},
616 {N_("Edit Comment"), "EditComment", EditCommentProc},
617 {N_("Edit Book"), "EditBook", EditBookEvent},
618 {"----", NULL, NothingProc},
619 {N_("Revert Home"), "Revert", RevertProc},
620 {N_("Annotate"), "Annotate", AnnotateProc},
621 {N_("Truncate Game End"), "TruncateGame", TruncateGameEvent},
622 {"----", NULL, NothingProc},
623 {N_("Backward Alt+Left"), "Backward", BackwardEvent},
624 {N_("Forward Alt+Right"), "Forward", ForwardEvent},
625 {N_("Back to Start Alt+Home"), "BacktoStart", ToStartEvent},
626 {N_("Forward to End Alt+End"), "ForwardtoEnd", ToEndEvent},
630 MenuItem viewMenu[] = {
631 {N_("Flip View F2"), "FlipView", FlipViewProc, CHECK},
632 {"----", NULL, NothingProc},
633 {N_("Engine Output Alt+Shift+O"), "EngineOutput", EngineOutputProc, CHECK},
634 {N_("Move History Alt+Shift+H"), "MoveHistory", HistoryShowProc, CHECK}, // [HGM] hist: activate 4.2.7 code
635 {N_("Evaluation Graph Alt+Shift+E"), "EvaluationGraph", EvalGraphProc, CHECK},
636 {N_("Game List Alt+Shift+G"), "GameList", ShowGameListProc, CHECK},
637 {N_("ICS text menu"), "ICStextmenu", IcsTextProc, CHECK},
638 {"----", NULL, NothingProc},
639 {N_("Tags"), "Tags", EditTagsProc, CHECK},
640 {N_("Comments"), "Comments", EditCommentProc, CHECK},
641 {N_("ICS Input Box"), "ICSInputBox", IcsInputBoxProc, CHECK},
642 {N_("Open Chat Window"), "OpenChatWindow", ChatProc, CHECK},
643 {"----", NULL, NothingProc},
644 {N_("Board..."), "Board", BoardOptionsProc},
645 {N_("Game List Tags..."), "GameListTags", GameListOptionsProc},
649 MenuItem modeMenu[] = {
650 {N_("Machine White Ctrl+W"), "MachineWhite", MachineWhiteEvent, RADIO },
651 {N_("Machine Black Ctrl+B"), "MachineBlack", MachineBlackEvent, RADIO },
652 {N_("Two Machines Ctrl+T"), "TwoMachines", TwoMachinesEvent, RADIO },
653 {N_("Analysis Mode Ctrl+A"), "AnalysisMode", (MenuProc*) AnalyzeModeEvent, RADIO},
654 {N_("Analyze Game Ctrl+G"), "AnalyzeFile", AnalyzeFileEvent, RADIO },
655 {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent, RADIO },
656 {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent, RADIO },
657 {N_("Training"), "Training", TrainingEvent, RADIO },
658 {N_("ICS Client"), "ICSClient", IcsClientEvent, RADIO },
659 {"----", NULL, NothingProc},
660 {N_("Machine Match"), "MachineMatch", MatchProc, CHECK },
661 {N_("Pause Pause"), "Pause", PauseEvent, CHECK },
665 MenuItem actionMenu[] = {
666 {N_("Accept F3"), "Accept", AcceptEvent},
667 {N_("Decline F4"), "Decline", DeclineEvent},
668 {N_("Rematch F12"), "Rematch", RematchEvent},
669 {"----", NULL, NothingProc},
670 {N_("Call Flag F5"), "CallFlag", CallFlagEvent},
671 {N_("Draw F6"), "Draw", DrawEvent},
672 {N_("Adjourn F7"), "Adjourn", AdjournEvent},
673 {N_("Abort F8"),"Abort", AbortEvent},
674 {N_("Resign F9"), "Resign", ResignEvent},
675 {"----", NULL, NothingProc},
676 {N_("Stop Observing F10"), "StopObserving", StopObservingEvent},
677 {N_("Stop Examining F11"), "StopExamining", StopExaminingEvent},
678 {N_("Upload to Examine"), "UploadtoExamine", UploadGameEvent},
679 {"----", NULL, NothingProc},
680 {N_("Adjudicate to White"), "AdjudicatetoWhite", AdjuWhiteProc},
681 {N_("Adjudicate to Black"), "AdjudicatetoBlack", AdjuBlackProc},
682 {N_("Adjudicate Draw"), "AdjudicateDraw", AdjuDrawProc},
686 MenuItem engineMenu[100] = {
687 {N_("Load New 1st Engine ..."), "LoadNew1stEngine", LoadEngine1Proc},
688 {N_("Load New 2nd Engine ..."), "LoadNew2ndEngine", LoadEngine2Proc},
689 {"----", NULL, NothingProc},
690 {N_("Engine #1 Settings ..."), "Engine#1Settings", FirstSettingsProc},
691 {N_("Engine #2 Settings ..."), "Engine#2Settings", SecondSettingsProc},
692 {"----", NULL, NothingProc},
693 {N_("Hint"), "Hint", HintEvent},
694 {N_("Book"), "Book", BookEvent},
695 {"----", NULL, NothingProc},
696 {N_("Move Now Ctrl+M"), "MoveNow", MoveNowEvent},
697 {N_("Retract Move Ctrl+X"), "RetractMove", RetractMoveEvent},
701 MenuItem optionsMenu[] = {
703 {N_("General ..."), "General", OptionsProc},
705 {N_("Time Control ... Alt+Shift+T"), "TimeControl", TimeControlProc},
706 {N_("Common Engine ... Alt+Shift+U"), "CommonEngine", UciMenuProc},
707 {N_("Adjudications ... Alt+Shift+J"), "Adjudications", EngineMenuProc},
708 {N_("ICS ..."), "ICS", IcsOptionsProc},
709 {N_("Match ..."), "Match", MatchOptionsProc},
710 {N_("Load Game ..."), "LoadGame", LoadOptionsProc},
711 {N_("Save Game ..."), "SaveGame", SaveOptionsProc},
712 // {N_(" ..."), "", OptionsProc},
713 {N_("Game List ..."), "GameList", GameListOptionsProc},
714 {N_("Sounds ..."), "Sounds", SoundOptionsProc},
715 {"----", NULL, NothingProc},
716 #ifndef OPTIONSDIALOG
717 {N_("Always Queen Ctrl+Shift+Q"), "AlwaysQueen", AlwaysQueenProc},
718 {N_("Animate Dragging"), "AnimateDragging", AnimateDraggingProc},
719 {N_("Animate Moving Ctrl+Shift+A"), "AnimateMoving", AnimateMovingProc},
720 {N_("Auto Flag Ctrl+Shift+F"), "AutoFlag", AutoflagProc},
721 {N_("Auto Flip View"), "AutoFlipView", AutoflipProc},
722 {N_("Blindfold"), "Blindfold", BlindfoldProc},
723 {N_("Flash Moves"), "FlashMoves", FlashMovesProc},
725 {N_("Highlight Dragging"), "HighlightDragging", HighlightDraggingProc},
727 {N_("Highlight Last Move"), "HighlightLastMove", HighlightLastMoveProc},
728 {N_("Highlight With Arrow"), "HighlightWithArrow", HighlightArrowProc},
729 {N_("Move Sound"), "MoveSound", MoveSoundProc},
730 // {N_("ICS Alarm"), "ICSAlarm", IcsAlarmProc},
731 {N_("One-Click Moving"), "OneClickMoving", OneClickProc},
732 {N_("Periodic Updates"), "PeriodicUpdates", PeriodicUpdatesProc},
733 {N_("Ponder Next Move Ctrl+Shift+P"), "PonderNextMove", PonderNextMoveProc},
734 {N_("Popup Exit Message"), "PopupExitMessage", PopupExitMessageProc},
735 {N_("Popup Move Errors"), "PopupMoveErrors", PopupMoveErrorsProc},
736 // {N_("Premove"), "Premove", PremoveProc},
737 {N_("Show Coords"), "ShowCoords", ShowCoordsProc},
738 {N_("Hide Thinking Ctrl+Shift+H"), "HideThinking", HideThinkingProc},
739 {N_("Test Legality Ctrl+Shift+L"), "TestLegality", TestLegalityProc},
740 {"----", NULL, NothingProc},
742 {N_("Save Settings Now"), "SaveSettingsNow", SaveSettingsProc},
743 {N_("Save Settings on Exit"), "SaveSettingsonExit", SaveOnExitProc, CHECK },
747 MenuItem helpMenu[] = {
748 {N_("Info XBoard"), "InfoXBoard", InfoProc},
749 {N_("Man XBoard F1"), "ManXBoard", ManProc},
750 {"----", NULL, NothingProc},
751 {N_("XBoard Home Page"), "XBoardHomePage", HomePageProc},
752 {N_("On-line User Guide"), "On-lineUserGuide", GuideProc},
753 {N_("Development News"), "DevelopmentNews", NewsPageProc},
754 {N_("e-Mail Bug Report"), "e-MailBugReport", BugReportProc},
755 {"----", NULL, NothingProc},
756 {N_("About XBoard"), "AboutXBoard", AboutProc},
760 MenuItem noMenu[] = {
761 { "", "LoadNextGame", LoadNextGameProc },
762 { "", "LoadPrevGame", LoadPrevGameProc },
763 { "", "ReloadGame", ReloadGameProc },
764 { "", "ReloadPosition", ReloadPositionProc },
765 #ifndef OPTIONSDIALOG
766 { "", "AlwaysQueen", AlwaysQueenProc },
767 { "", "AnimateDragging", AnimateDraggingProc },
768 { "", "AnimateMoving", AnimateMovingProc },
769 { "", "Autoflag", AutoflagProc },
770 { "", "Autoflip", AutoflipProc },
771 { "", "Blindfold", BlindfoldProc },
772 { "", "FlashMoves", FlashMovesProc },
774 { "", "HighlightDragging", HighlightDraggingProc },
776 { "", "HighlightLastMove", HighlightLastMoveProc },
777 // { "", "IcsAlarm", IcsAlarmProc },
778 { "", "MoveSound", MoveSoundProc },
779 { "", "PeriodicUpdates", PeriodicUpdatesProc },
780 { "", "PopupExitMessage", PopupExitMessageProc },
781 { "", "PopupMoveErrors", PopupMoveErrorsProc },
782 // { "", "Premove", PremoveProc },
783 { "", "ShowCoords", ShowCoordsProc },
784 { "", "ShowThinking", ShowThinkingProc },
785 { "", "HideThinking", HideThinkingProc },
786 { "", "TestLegality", TestLegalityProc },
788 { "", "AboutGame", AboutGameEvent },
789 { "", "DebugProc", DebugProc },
790 { "", "Nothing", NothingProc },
795 {N_("File"), "File", fileMenu},
796 {N_("Edit"), "Edit", editMenu},
797 {N_("View"), "View", viewMenu},
798 {N_("Mode"), "Mode", modeMenu},
799 {N_("Action"), "Action", actionMenu},
800 {N_("Engine"), "Engine", engineMenu},
801 {N_("Options"), "Options", optionsMenu},
802 {N_("Help"), "Help", helpMenu},
807 MenuNameToItem (char *menuName)
810 char buf[MSG_SIZ], *p;
812 static MenuItem a = { NULL, NULL, NothingProc };
813 extern Option mainOptions[];
814 safeStrCpy(buf, menuName, MSG_SIZ);
815 p = strchr(buf, '.');
816 if(!p) menuTab = noMenu, p = menuName; else {
818 for(i=0; menuBar[i].name; i++)
819 if(!strcmp(buf, menuBar[i].name)) break;
820 if(!menuBar[i].name) return NULL; // main menu not found
821 menuTab = menuBar[i].mi;
823 if(*p == NULLCHAR) { a.handle = mainOptions[i+1].handle; return &a; } // main menu bar
824 for(i=0; menuTab[i].string; i++)
825 if(menuTab[i].ref && !strcmp(p, menuTab[i].ref)) return menuTab + i;
826 return NULL; // item not found
832 AppendEnginesToMenu (char *list)
836 if(appData.icsActive || appData.recentEngines <= 0) return;
837 for(firstEngineItem=0; engineMenu[firstEngineItem].string; firstEngineItem++);
838 recentEngines = strdup(list);
840 p = strchr(list, '\n'); if(p == NULL) break;
841 if(i == 0) engineMenu[firstEngineItem++].string = "----"; // at least one valid item to add
843 if(firstEngineItem + i < 99)
844 engineMenu[firstEngineItem+i].string = strdup(list); // just set name; MenuProc stays NULL
845 i++; *p = '\n'; list = p + 1;
849 Enables icsEnables[] = {
850 { "File.MailMove", False },
851 { "File.ReloadCMailMessage", False },
852 { "Mode.MachineBlack", False },
853 { "Mode.MachineWhite", False },
854 { "Mode.AnalysisMode", False },
855 { "Mode.AnalyzeFile", False },
856 { "Mode.TwoMachines", False },
857 { "Mode.MachineMatch", False },
859 { "Engine.Hint", False },
860 { "Engine.Book", False },
861 { "Engine.MoveNow", False },
862 #ifndef OPTIONSDIALOG
863 { "PeriodicUpdates", False },
864 { "HideThinking", False },
865 { "PonderNextMove", False },
868 { "Engine.Engine#1Settings", False },
869 { "Engine.Engine#2Settings", False },
870 { "Engine.Load1stEngine", False },
871 { "Engine.Load2ndEngine", False },
872 { "Edit.Annotate", False },
873 { "Options.Match", False },
877 Enables ncpEnables[] = {
878 { "File.MailMove", False },
879 { "File.ReloadCMailMessage", False },
880 { "Mode.MachineWhite", False },
881 { "Mode.MachineBlack", False },
882 { "Mode.AnalysisMode", False },
883 { "Mode.AnalyzeFile", False },
884 { "Mode.TwoMachines", False },
885 { "Mode.MachineMatch", False },
886 { "Mode.ICSClient", False },
887 { "View.ICStextmenu", False },
888 { "View.ICSInputBox", False },
889 { "View.OpenChatWindow", False },
890 { "Action.", False },
891 { "Edit.Revert", False },
892 { "Edit.Annotate", False },
893 { "Engine.Engine#1Settings", False },
894 { "Engine.Engine#2Settings", False },
895 { "Engine.MoveNow", False },
896 { "Engine.RetractMove", False },
897 { "Options.ICS", False },
898 #ifndef OPTIONSDIALOG
899 { "Options.AutoFlag", False },
900 { "Options.AutoFlip View", False },
901 // { "Options.ICSAlarm", False },
902 { "Options.MoveSound", False },
903 { "Options.HideThinking", False },
904 { "Options.PeriodicUpdates", False },
905 { "Options.PonderNextMove", False },
907 { "Engine.Hint", False },
908 { "Engine.Book", False },
912 Enables gnuEnables[] = {
913 { "Mode.ICSClient", False },
914 { "View.ICStextmenu", False },
915 { "View.ICSInputBox", False },
916 { "View.OpenChatWindow", False },
917 { "Action.Accept", False },
918 { "Action.Decline", False },
919 { "Action.Rematch", False },
920 { "Action.Adjourn", False },
921 { "Action.StopExamining", False },
922 { "Action.StopObserving", False },
923 { "Action.UploadtoExamine", False },
924 { "Edit.Revert", False },
925 { "Edit.Annotate", False },
926 { "Options.ICS", False },
928 /* The next two options rely on SetCmailMode being called *after* */
929 /* SetGNUMode so that when GNU is being used to give hints these */
930 /* menu options are still available */
932 { "File.MailMove", False },
933 { "File.ReloadCMailMessage", False },
934 // [HGM] The following have been added to make a switch from ncp to GNU mode possible
935 { "Mode.MachineWhite", True },
936 { "Mode.MachineBlack", True },
937 { "Mode.AnalysisMode", True },
938 { "Mode.AnalyzeFile", True },
939 { "Mode.TwoMachines", True },
940 { "Mode.MachineMatch", True },
941 { "Engine.Engine#1Settings", True },
942 { "Engine.Engine#2Settings", True },
943 { "Engine.Hint", True },
944 { "Engine.Book", True },
945 { "Engine.MoveNow", True },
946 { "Engine.RetractMove", True },
951 Enables cmailEnables[] = {
953 { "Action.CallFlag", False },
954 { "Action.Draw", True },
955 { "Action.Adjourn", False },
956 { "Action.Abort", False },
957 { "Action.StopObserving", False },
958 { "Action.StopExamining", False },
959 { "File.MailMove", True },
960 { "File.ReloadCMailMessage", True },
964 Enables trainingOnEnables[] = {
965 { "Edit.EditComment", False },
966 { "Mode.Pause", False },
967 { "Edit.Forward", False },
968 { "Edit.Backward", False },
969 { "Edit.ForwardtoEnd", False },
970 { "Edit.BacktoStart", False },
971 { "Engine.MoveNow", False },
972 { "Edit.TruncateGame", False },
976 Enables trainingOffEnables[] = {
977 { "Edit.EditComment", True },
978 { "Mode.Pause", True },
979 { "Edit.Forward", True },
980 { "Edit.Backward", True },
981 { "Edit.ForwardtoEnd", True },
982 { "Edit.BacktoStart", True },
983 { "Engine.MoveNow", True },
984 { "Engine.TruncateGame", True },
988 Enables machineThinkingEnables[] = {
989 { "File.LoadGame", False },
990 // { "LoadNextGame", False },
991 // { "LoadPreviousGame", False },
992 // { "ReloadSameGame", False },
993 { "Edit.PasteGame", False },
994 { "File.LoadPosition", False },
995 // { "LoadNextPosition", False },
996 // { "LoadPreviousPosition", False },
997 // { "ReloadSamePosition", False },
998 { "Edit.PastePosition", False },
999 { "Mode.MachineWhite", False },
1000 { "Mode.MachineBlack", False },
1001 { "Mode.TwoMachines", False },
1002 // { "MachineMatch", False },
1003 { "Engine.RetractMove", False },
1007 Enables userThinkingEnables[] = {
1008 { "File.LoadGame", True },
1009 // { "LoadNextGame", True },
1010 // { "LoadPreviousGame", True },
1011 // { "ReloadSameGame", True },
1012 { "Edit.PasteGame", True },
1013 { "File.LoadPosition", True },
1014 // { "LoadNextPosition", True },
1015 // { "LoadPreviousPosition", True },
1016 // { "ReloadSamePosition", True },
1017 { "Edit.PastePosition", True },
1018 { "Mode.MachineWhite", True },
1019 { "Mode.MachineBlack", True },
1020 { "Mode.TwoMachines", True },
1021 // { "MachineMatch", True },
1022 { "Engine.RetractMove", True },
1029 SetMenuEnables(icsEnables);
1032 if (appData.zippyPlay && !appData.noChessProgram) { /* [DM] icsEngineAnalyze */
1033 EnableNamedMenuItem("Mode.AnalysisMode", True);
1034 EnableNamedMenuItem("Engine.Engine#1Settings", True);
1042 SetMenuEnables(ncpEnables);
1048 SetMenuEnables(gnuEnables);
1054 SetMenuEnables(cmailEnables);
1058 SetTrainingModeOn ()
1060 SetMenuEnables(trainingOnEnables);
1061 if (appData.showButtonBar) {
1062 EnableButtonBar(False);
1068 SetTrainingModeOff ()
1070 SetMenuEnables(trainingOffEnables);
1071 if (appData.showButtonBar) {
1072 EnableButtonBar(True);
1077 SetUserThinkingEnables ()
1079 if (appData.noChessProgram) return;
1080 SetMenuEnables(userThinkingEnables);
1084 SetMachineThinkingEnables ()
1086 if (appData.noChessProgram) return;
1087 SetMenuEnables(machineThinkingEnables);
1089 case MachinePlaysBlack:
1090 case MachinePlaysWhite:
1091 case TwoMachinesPlay:
1092 EnableNamedMenuItem(ModeToWidgetName(gameMode), True);
1100 GreyRevert (Boolean grey)
1102 MarkMenuItem("Edit.Revert", !grey);
1103 MarkMenuItem("Edit.Annotate", !grey);
1107 ModeToWidgetName (GameMode mode)
1110 case BeginningOfGame:
1111 if (appData.icsActive)
1112 return "Mode.ICSClient";
1113 else if (appData.noChessProgram ||
1114 *appData.cmailGameName != NULLCHAR)
1115 return "Mode.EditGame";
1117 return "Mode.MachineBlack";
1118 case MachinePlaysBlack:
1119 return "Mode.MachineBlack";
1120 case MachinePlaysWhite:
1121 return "Mode.MachineWhite";
1123 return "Mode.AnalysisMode";
1125 return "Mode.AnalyzeFile";
1126 case TwoMachinesPlay:
1127 return "Mode.TwoMachines";
1129 return "Mode.EditGame";
1130 case PlayFromGameFile:
1131 return "File.LoadGame";
1133 return "Mode.EditPosition";
1135 return "Mode.Training";
1136 case IcsPlayingWhite:
1137 case IcsPlayingBlack:
1141 return "Mode.ICSClient";
1151 #ifndef OPTIONSDIALOG
1152 if (appData.alwaysPromoteToQueen) {
1153 MarkMenuItem("Options.Always Queen", True);
1155 if (appData.animateDragging) {
1156 MarkMenuItem("Options.Animate Dragging", True);
1158 if (appData.animate) {
1159 MarkMenuItem("Options.Animate Moving", True);
1161 if (appData.autoCallFlag) {
1162 MarkMenuItem("Options.Auto Flag", True);
1164 if (appData.autoFlipView) {
1165 XtSetValues(XtNameToWidget(menuBarWidget,"Options.Auto Flip View", True);
1167 if (appData.blindfold) {
1168 MarkMenuItem("Options.Blindfold", True);
1170 if (appData.flashCount > 0) {
1171 MarkMenuItem("Options.Flash Moves", True);
1174 if (appData.highlightDragging) {
1175 MarkMenuItem("Options.Highlight Dragging", True);
1178 if (appData.highlightLastMove) {
1179 MarkMenuItem("Options.Highlight Last Move", True);
1181 if (appData.highlightMoveWithArrow) {
1182 MarkMenuItem("Options.Arrow", True);
1184 // if (appData.icsAlarm) {
1185 // MarkMenuItem("Options.ICS Alarm", True);
1187 if (appData.ringBellAfterMoves) {
1188 MarkMenuItem("Options.Move Sound", True);
1190 if (appData.oneClick) {
1191 MarkMenuItem("Options.OneClick", True);
1193 if (appData.periodicUpdates) {
1194 MarkMenuItem("Options.Periodic Updates", True);
1196 if (appData.ponderNextMove) {
1197 MarkMenuItem("Options.Ponder Next Move", True);
1199 if (appData.popupExitMessage) {
1200 MarkMenuItem("Options.Popup Exit Message", True);
1202 if (appData.popupMoveErrors) {
1203 MarkMenuItem("Options.Popup Move Errors", True);
1205 // if (appData.premove) {
1206 // MarkMenuItem("Options.Premove", True);
1208 if (appData.showCoords) {
1209 MarkMenuItem("Options.Show Coords", True);
1211 if (appData.hideThinkingFromHuman) {
1212 MarkMenuItem("Options.Hide Thinking", True);
1214 if (appData.testLegality) {
1215 MarkMenuItem("Options.Test Legality", True);
1218 if (saveSettingsOnExit) {
1219 MarkMenuItem("Options.SaveSettingsonExit", True);