X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=menus.c;h=23e09ea66e0d777c42c9f404b16dce86b0e56dc0;hb=7e0222e64da6706bf0dc2468f459b98e4346206b;hp=560e8af414a0d6532cce09fccfcfe68ba0745cdf;hpb=2aaf542114d8131c9fccc4e1ebffd45cb950d1d1;p=xboard.git diff --git a/menus.c b/menus.c index 560e8af..23e09ea 100644 --- a/menus.c +++ b/menus.c @@ -87,9 +87,6 @@ extern char *getenv(); #include "frontend.h" #include "backend.h" -#include "backendz.h" -#include "moves.h" -#include "xgamelist.h" #include "xhistory.h" #include "xedittags.h" #include "menus.h" @@ -103,85 +100,559 @@ extern char *getenv(); # define N_(s) s #endif +/* + * Button/menu procedures + */ + +char *gameCopyFilename, *gamePasteFilename; +Boolean saveSettingsOnExit; +char *settingsFileName; + +static int +LoadGamePopUp (FILE *f, int gameNumber, char *title) +{ + cmailMsgLoaded = FALSE; + if (gameNumber == 0) { + int error = GameListBuild(f); + if (error) { + DisplayError(_("Cannot build game list"), error); + } else if (!ListEmpty(&gameList) && + ((ListGame *) gameList.tailPred)->number > 1) { + GameListPopUp(f, title); + return TRUE; + } + GameListDestroy(); + gameNumber = 1; + } + return LoadGame(f, gameNumber, title, FALSE); +} + +void +LoadGameProc () +{ + if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { + Reset(FALSE, TRUE); + } + FileNamePopUp(_("Load game file name?"), "", ".pgn .game", LoadGamePopUp, "rb"); +} + +void +LoadNextGameProc () +{ + ReloadGame(1); +} + +void +LoadPrevGameProc () +{ + ReloadGame(-1); +} + +void +ReloadGameProc () +{ + ReloadGame(0); +} + +void +LoadNextPositionProc () +{ + ReloadPosition(1); +} + +void +LoadPrevPositionProc () +{ + ReloadPosition(-1); +} + +void +ReloadPositionProc () +{ + ReloadPosition(0); +} + +void +LoadPositionProc() +{ + if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { + Reset(FALSE, TRUE); + } + FileNamePopUp(_("Load position file name?"), "", ".fen .epd .pos", LoadPosition, "rb"); +} + +void +SaveGameProc () +{ + FileNamePopUp(_("Save game file name?"), + DefaultFileName(appData.oldSaveStyle ? "game" : "pgn"), + appData.oldSaveStyle ? ".game" : ".pgn", + SaveGame, "a"); +} + +void +SavePositionProc () +{ + FileNamePopUp(_("Save position file name?"), + DefaultFileName(appData.oldSaveStyle ? "pos" : "fen"), + appData.oldSaveStyle ? ".pos" : ".fen", + SavePosition, "a"); +} + +void +ReloadCmailMsgProc () +{ + ReloadCmailMsgEvent(FALSE); +} + +void +CopyFENToClipboard () +{ // wrapper to make call from back-end possible + CopyPositionProc(); +} + +void +CopyPositionProc () +{ + static char *selected_fen_position=NULL; + if(gameMode == EditPosition) EditPositionDone(TRUE); + if (selected_fen_position) free(selected_fen_position); + selected_fen_position = (char *)PositionToFEN(currentMove, NULL); + if (!selected_fen_position) return; + CopySomething(selected_fen_position); +} + +void +CopyGameProc () +{ + int ret; + + ret = SaveGameToFile(gameCopyFilename, FALSE); + if (!ret) return; + + CopySomething(NULL); +} + +void +CopyGameListProc () +{ + if(!SaveGameListAsText(fopen(gameCopyFilename, "w"))) return; + CopySomething(NULL); +} + +void +AutoSaveGame () +{ + SaveGameProc(); +} + + +void +QuitProc () +{ + ExitEvent(0); +} + +void +MatchProc () +{ + MatchEvent(2); +} + +void +AdjuWhiteProc () +{ + UserAdjudicationEvent(+1); +} + +void +AdjuBlackProc () +{ + UserAdjudicationEvent(-1); +} + +void +AdjuDrawProc () +{ + UserAdjudicationEvent(0); +} + +void +RevertProc () +{ + RevertEvent(False); +} + +void +AnnotateProc () +{ + RevertEvent(True); +} + +void +FlipViewProc () +{ + if(twoBoards) { partnerUp = 1; DrawPosition(True, NULL); partnerUp = 0; } + flipView = !flipView; + DrawPosition(True, NULL); +} + +void +SaveOnExitProc () +{ + saveSettingsOnExit = !saveSettingsOnExit; + + MarkMenuItem("Options.SaveSettingsonExit", saveSettingsOnExit); +} + +void +SaveSettingsProc () +{ + SaveSettings(settingsFileName); +} + +void +InfoProc () +{ + char buf[MSG_SIZ]; + snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &", + INFODIR, INFOFILE); + system(buf); +} + +void +BugReportProc () +{ + char buf[MSG_SIZ]; + snprintf(buf, MSG_SIZ, "%s mailto:bug-xboard@gnu.org", appData.sysOpen); + system(buf); +} + +void +GuideProc () +{ + char buf[MSG_SIZ]; + snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/user_guide/UserGuide.html", appData.sysOpen); + system(buf); +} + +void +HomePageProc () +{ + char buf[MSG_SIZ]; + snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/", appData.sysOpen); + system(buf); +} + +void +NewsPageProc () +{ + char buf[MSG_SIZ]; + snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/whats_new/portal.html", appData.sysOpen); + system(buf); +} + +void +AboutProc () +{ + char buf[2 * MSG_SIZ]; +#if ZIPPY + char *zippy = _(" (with Zippy code)"); +#else + char *zippy = ""; +#endif + snprintf(buf, sizeof(buf), +_("%s%s\n\n" +"Copyright 1991 Digital Equipment Corporation\n" +"Enhancements Copyright 1992-2012 Free Software Foundation\n" +"Enhancements Copyright 2005 Alessandro Scotti\n\n" +"%s is free software and carries NO WARRANTY;" +"see the file COPYING for more information.\n\n" +"Visit XBoard on the web at: http://www.gnu.org/software/xboard/\n" +"Check out the newest features at: http://www.gnu.org/software/xboard/whats_new.html\n\n" +"Report bugs via email at: \n\n" + ), + programVersion, zippy, PACKAGE); + ErrorPopUp(_("About XBoard"), buf, FALSE); +} + +void +DebugProc () +{ + appData.debugMode = !appData.debugMode; + if(!strcmp(appData.nameOfDebugFile, "stderr")) return; // stderr is already open, and should never be closed + if(!appData.debugMode) fclose(debugFP); + else { + debugFP = fopen(appData.nameOfDebugFile, "w"); + if(debugFP == NULL) debugFP = stderr; + else setbuf(debugFP, NULL); + } +} + +void +NothingProc () +{ + return; +} + +#ifdef OPTIONSDIALOG +# define MARK_MENU_ITEM(X,Y) +#else +# define MARK_MENU_ITEM(X,Y) MarkMenuItem(X, Y) +#endif + +void +PonderNextMoveProc () +{ + PonderNextMoveEvent(!appData.ponderNextMove); + MARK_MENU_ITEM("Options.PonderNextMove", appData.ponderNextMove); +} + +void +AlwaysQueenProc () +{ + appData.alwaysPromoteToQueen = !appData.alwaysPromoteToQueen; + MARK_MENU_ITEM("Options.AlwaysQueen", appData.alwaysPromoteToQueen); +} + +void +AnimateDraggingProc () +{ + appData.animateDragging = !appData.animateDragging; + + if (appData.animateDragging) CreateAnimVars(); + MARK_MENU_ITEM("Options.AnimateDragging", appData.animateDragging); +} + +void +AnimateMovingProc () +{ + appData.animate = !appData.animate; + if (appData.animate) CreateAnimVars(); + MARK_MENU_ITEM("Options.AnimateMoving", appData.animate); +} + +void +AutoflagProc () +{ + appData.autoCallFlag = !appData.autoCallFlag; + MARK_MENU_ITEM("Options.AutoFlag", appData.autoCallFlag); +} + +void +AutoflipProc () +{ + appData.autoFlipView = !appData.autoFlipView; + MARK_MENU_ITEM("Options.AutoFlipView", appData.autoFlipView); +} + +void +BlindfoldProc () +{ + appData.blindfold = !appData.blindfold; + MARK_MENU_ITEM("Options.Blindfold", appData.blindfold); + DrawPosition(True, NULL); +} + +void +TestLegalityProc () +{ + appData.testLegality = !appData.testLegality; + MARK_MENU_ITEM("Options.TestLegality", appData.testLegality); +} + + +void +FlashMovesProc () +{ + if (appData.flashCount == 0) { + appData.flashCount = 3; + } else { + appData.flashCount = -appData.flashCount; + } + MARK_MENU_ITEM("Options.FlashMoves", appData.flashCount > 0); +} + +#if HIGHDRAG +void +HighlightDraggingProc () +{ + appData.highlightDragging = !appData.highlightDragging; + MARK_MENU_ITEM("Options.HighlightDragging", appData.highlightDragging); +} +#endif + +void +HighlightLastMoveProc () +{ + appData.highlightLastMove = !appData.highlightLastMove; + MARK_MENU_ITEM("Options.HighlightLastMove", appData.highlightLastMove); +} + +void +HighlightArrowProc () +{ + appData.highlightMoveWithArrow = !appData.highlightMoveWithArrow; + MARK_MENU_ITEM("Options.HighlightWithArrow", appData.highlightMoveWithArrow); +} + +void +IcsAlarmProc () +{ + appData.icsAlarm = !appData.icsAlarm; +// MARK_MENU_ITEM("Options.ICSAlarm", appData.icsAlarm); +} + +void +MoveSoundProc () +{ + appData.ringBellAfterMoves = !appData.ringBellAfterMoves; + MARK_MENU_ITEM("Options.MoveSound", appData.ringBellAfterMoves); +} + +void +OneClickProc () +{ + appData.oneClick = !appData.oneClick; + MARK_MENU_ITEM("Options.OneClickMoving", appData.oneClick); +} + +void +PeriodicUpdatesProc () +{ + PeriodicUpdatesEvent(!appData.periodicUpdates); + MARK_MENU_ITEM("Options.PeriodicUpdates", appData.periodicUpdates); +} + +void +PopupExitMessageProc () +{ + appData.popupExitMessage = !appData.popupExitMessage; + MARK_MENU_ITEM("Options.PopupExitMessage", appData.popupExitMessage); +} + +void +PopupMoveErrorsProc () +{ + appData.popupMoveErrors = !appData.popupMoveErrors; + MARK_MENU_ITEM("Options.PopupMoveErrors", appData.popupMoveErrors); +} + +void +PremoveProc () +{ + appData.premove = !appData.premove; +// MARK_MENU_ITEM("Options.Premove", appData.premove); +} + +void +ShowCoordsProc () +{ + appData.showCoords = !appData.showCoords; + MARK_MENU_ITEM("Options.ShowCoords", appData.showCoords); + DrawPosition(True, NULL); +} + +void +ShowThinkingProc () +{ + appData.showThinking = !appData.showThinking; // [HGM] thinking: taken out of ShowThinkingEvent + ShowThinkingEvent(); +} + +void +HideThinkingProc () +{ + appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; // [HGM] thinking: taken out of ShowThinkingEvent + ShowThinkingEvent(); + + MARK_MENU_ITEM("Options.HideThinking", appData.hideThinkingFromHuman); +} + +/* + * Menu definition tables + */ + MenuItem fileMenu[] = { - {N_("New Game Ctrl+N"), "New Game", ResetGameEvent}, - {N_("New Shuffle Game ..."), "New Shuffle Game", ShuffleMenuProc}, - {N_("New Variant ... Alt+Shift+V"), "New Variant", NewVariantProc}, // [HGM] variant: not functional yet + {N_("New Game Ctrl+N"), "NewGame", ResetGameEvent}, + {N_("New Shuffle Game ..."), "NewShuffleGame", ShuffleMenuProc}, + {N_("New Variant ... Alt+Shift+V"), "NewVariant", NewVariantProc}, // [HGM] variant: not functional yet {"----", NULL, NothingProc}, - {N_("Load Game Ctrl+O"), "Load Game", LoadGameProc}, - {N_("Load Position Ctrl+Shift+O"), "Load Position", LoadPositionProc}, -// {N_("Load Next Game"), "Load Next Game", LoadNextGameProc}, -// {N_("Load Previous Game"), "Load Previous Game", LoadPrevGameProc}, -// {N_("Reload Same Game"), "Reload Same Game", ReloadGameProc}, - {N_("Next Position Shift+PgDn"), "Load Next Position", LoadNextPositionProc}, - {N_("Prev Position Shift+PgUp"), "Load Previous Position", LoadPrevPositionProc}, + {N_("Load Game Ctrl+O"), "LoadGame", LoadGameProc}, + {N_("Load Position Ctrl+Shift+O"), "LoadPosition", LoadPositionProc}, +// {N_("Load Next Game"), "LoadNextGame", LoadNextGameProc}, +// {N_("Load Previous Game"), "LoadPreviousGame", LoadPrevGameProc}, +// {N_("Reload Same Game"), "ReloadSameGame", ReloadGameProc}, + {N_("Next Position Shift+PgDn"), "LoadNextPosition", LoadNextPositionProc}, + {N_("Prev Position Shift+PgUp"), "LoadPreviousPosition", LoadPrevPositionProc}, {"----", NULL, NothingProc}, // {N_("Reload Same Position"), "Reload Same Position", ReloadPositionProc}, - {N_("Save Game Ctrl+S"), "Save Game", SaveGameProc}, - {N_("Save Position Ctrl+Shift+S"), "Save Position", SavePositionProc}, + {N_("Save Game Ctrl+S"), "SaveGame", SaveGameProc}, + {N_("Save Position Ctrl+Shift+S"), "SavePosition", SavePositionProc}, {"----", NULL, NothingProc}, - {N_("Mail Move"), "Mail Move", MailMoveEvent}, - {N_("Reload CMail Message"), "Reload CMail Message", ReloadCmailMsgProc}, + {N_("Mail Move"), "MailMove", MailMoveEvent}, + {N_("Reload CMail Message"), "ReloadCMailMessage", ReloadCmailMsgProc}, {"----", NULL, NothingProc}, - {N_("Quit Ctr+Q"), "Exit", QuitProc}, + {N_("Quit Ctr+Q"), "Quit", QuitProc}, {NULL, NULL, NULL} }; MenuItem editMenu[] = { - {N_("Copy Game Ctrl+C"), "Copy Game", CopyGameProc}, - {N_("Copy Position Ctrl+Shift+C"), "Copy Position", CopyPositionProc}, - {N_("Copy Game List"), "Copy Game List", CopyGameListProc}, + {N_("Copy Game Ctrl+C"), "CopyGame", CopyGameProc}, + {N_("Copy Position Ctrl+Shift+C"), "CopyPosition", CopyPositionProc}, + {N_("Copy Game List"), "CopyGameList", CopyGameListProc}, {"----", NULL, NothingProc}, - {N_("Paste Game Ctrl+V"), "Paste Game", PasteGameProc}, - {N_("Paste Position Ctrl+Shift+V"), "Paste Position", PastePositionProc}, + {N_("Paste Game Ctrl+V"), "PasteGame", PasteGameProc}, + {N_("Paste Position Ctrl+Shift+V"), "PastePosition", PastePositionProc}, {"----", NULL, NothingProc}, - {N_("Edit Game Ctrl+E"), "Edit Game 2", EditGameEvent}, - {N_("Edit Position Ctrl+Shift+E"), "Edit Position 2", EditPositionEvent}, - {N_("Edit Tags"), "Edit Tags", EditTagsProc}, - {N_("Edit Comment"), "Edit Comment", EditCommentProc}, - {N_("Edit Book"), "Edit Book", EditBookEvent}, + {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent}, + {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent}, + {N_("Edit Tags"), "EditTags", EditTagsProc}, + {N_("Edit Comment"), "EditComment", EditCommentProc}, + {N_("Edit Book"), "EditBook", EditBookEvent}, {"----", NULL, NothingProc}, {N_("Revert Home"), "Revert", RevertProc}, {N_("Annotate"), "Annotate", AnnotateProc}, - {N_("Truncate Game End"), "Truncate Game", TruncateGameEvent}, + {N_("Truncate Game End"), "TruncateGame", TruncateGameEvent}, {"----", NULL, NothingProc}, {N_("Backward Alt+Left"), "Backward", BackwardEvent}, {N_("Forward Alt+Right"), "Forward", ForwardEvent}, - {N_("Back to Start Alt+Home"), "Back to Start", ToStartEvent}, - {N_("Forward to End Alt+End"), "Forward to End", ToEndEvent}, + {N_("Back to Start Alt+Home"), "BacktoStart", ToStartEvent}, + {N_("Forward to End Alt+End"), "ForwardtoEnd", ToEndEvent}, {NULL, NULL, NULL} }; MenuItem viewMenu[] = { - {N_("Flip View F2"), "Flip View", FlipViewProc}, + {N_("Flip View F2"), "FlipView", FlipViewProc}, {"----", NULL, NothingProc}, - {N_("Engine Output Alt+Shift+O"), "Show Engine Output", EngineOutputProc}, - {N_("Move History Alt+Shift+H"), "Show Move History", HistoryShowProc}, // [HGM] hist: activate 4.2.7 code - {N_("Evaluation Graph Alt+Shift+E"), "Show Evaluation Graph", EvalGraphProc}, - {N_("Game List Alt+Shift+G"), "Show Game List", ShowGameListProc}, - {N_("ICS text menu"), "ICStex", IcsTextProc}, + {N_("Engine Output Alt+Shift+O"), "EngineOutput", EngineOutputProc}, + {N_("Move History Alt+Shift+H"), "MoveHistory", HistoryShowProc}, // [HGM] hist: activate 4.2.7 code + {N_("Evaluation Graph Alt+Shift+E"), "EvaluationGraph", EvalGraphProc}, + {N_("Game List Alt+Shift+G"), "GameList", ShowGameListProc}, + {N_("ICS text menu"), "ICStextmenu", IcsTextProc}, {"----", NULL, NothingProc}, - {N_("Tags"), "Show Tags", EditTagsProc}, - {N_("Comments"), "Show Comments", EditCommentProc}, - {N_("ICS Input Box"), "ICS Input Box", IcsInputBoxProc}, + {N_("Tags"), "Tags", EditTagsProc}, + {N_("Comments"), "Comments", EditCommentProc}, + {N_("ICS Input Box"), "ICSInputBox", IcsInputBoxProc}, + {N_("Open Chat Window"), "OpenChatWindow", ChatProc}, {"----", NULL, NothingProc}, - {N_("Board..."), "Board Options", BoardOptionsProc}, - {N_("Game List Tags..."), "Game List", GameListOptionsPopUp}, + {N_("Board..."), "Board", BoardOptionsProc}, + {N_("Game List Tags..."), "GameListTags", GameListOptionsProc}, {NULL, NULL, NULL} }; MenuItem modeMenu[] = { - {N_("Machine White Ctrl+W"), "Machine White", MachineWhiteEvent}, - {N_("Machine Black Ctrl+B"), "Machine Black", MachineBlackEvent}, - {N_("Two Machines Ctrl+T"), "Two Machines", TwoMachinesEvent}, - {N_("Analysis Mode Ctrl+A"), "Analysis Mode", AnalyzeModeProc}, - {N_("Analyze Game Ctrl+G"), "Analyze File", AnalyzeFileProc }, - {N_("Edit Game Ctrl+E"), "Edit Game", EditGameEvent}, - {N_("Edit Position Ctrl+Shift+E"), "Edit Position", EditPositionEvent}, + {N_("Machine White Ctrl+W"), "MachineWhite", MachineWhiteEvent}, + {N_("Machine Black Ctrl+B"), "MachineBlack", MachineBlackEvent}, + {N_("Two Machines Ctrl+T"), "TwoMachines", TwoMachinesEvent}, + {N_("Analysis Mode Ctrl+A"), "AnalysisMode", (MenuProc*) AnalyzeModeEvent}, + {N_("Analyze Game Ctrl+G"), "AnalyzeFile", AnalyzeFileEvent }, + {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent}, + {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent}, {N_("Training"), "Training", TrainingEvent}, - {N_("ICS Client"), "ICS Client", IcsClientEvent}, + {N_("ICS Client"), "ICSClient", IcsClientEvent}, {"----", NULL, NothingProc}, - {N_("Machine Match"), "Machine Match", MatchProc}, + {N_("Machine Match"), "MachineMatch", MatchProc}, {N_("Pause Pause"), "Pause", PauseEvent}, {NULL, NULL, NULL} }; @@ -191,33 +662,34 @@ MenuItem actionMenu[] = { {N_("Decline F4"), "Decline", DeclineEvent}, {N_("Rematch F12"), "Rematch", RematchEvent}, {"----", NULL, NothingProc}, - {N_("Call Flag F5"), "Call Flag", CallFlagEvent}, + {N_("Call Flag F5"), "CallFlag", CallFlagEvent}, {N_("Draw F6"), "Draw", DrawEvent}, {N_("Adjourn F7"), "Adjourn", AdjournEvent}, {N_("Abort F8"),"Abort", AbortEvent}, {N_("Resign F9"), "Resign", ResignEvent}, {"----", NULL, NothingProc}, - {N_("Stop Observing F10"), "Stop Observing", StopObservingEvent}, - {N_("Stop Examining F11"), "Stop Examining", StopExaminingEvent}, - {N_("Upload to Examine"), "Upload to Examine", UploadGameEvent}, + {N_("Stop Observing F10"), "StopObserving", StopObservingEvent}, + {N_("Stop Examining F11"), "StopExamining", StopExaminingEvent}, + {N_("Upload to Examine"), "UploadtoExamine", UploadGameEvent}, {"----", NULL, NothingProc}, - {N_("Adjudicate to White"), "Adjudicate to White", AdjuWhiteProc}, - {N_("Adjudicate to Black"), "Adjudicate to Black", AdjuBlackProc}, - {N_("Adjudicate Draw"), "Adjudicate Draw", AdjuDrawProc}, + {N_("Adjudicate to White"), "AdjudicatetoWhite", AdjuWhiteProc}, + {N_("Adjudicate to Black"), "AdjudicatetoBlack", AdjuBlackProc}, + {N_("Adjudicate Draw"), "AdjudicateDraw", AdjuDrawProc}, {NULL, NULL, NULL} }; MenuItem engineMenu[] = { - {N_("Load New Engine ..."), "Load Engine", LoadEngineProc}, + {N_("Load New 1st Engine ..."), "LoadNew1stEngine", LoadEngine1Proc}, + {N_("Load New 2nd Engine ..."), "LoadNew2ndEngine", LoadEngine2Proc}, {"----", NULL, NothingProc}, - {N_("Engine #1 Settings ..."), "Engine #1 Settings", FirstSettingsProc}, - {N_("Engine #2 Settings ..."), "Engine #2 Settings", SecondSettingsProc}, + {N_("Engine #1 Settings ..."), "Engine#1Settings", FirstSettingsProc}, + {N_("Engine #2 Settings ..."), "Engine#2Settings", SecondSettingsProc}, {"----", NULL, NothingProc}, {N_("Hint"), "Hint", HintEvent}, {N_("Book"), "Book", BookEvent}, {"----", NULL, NothingProc}, - {N_("Move Now Ctrl+M"), "Move Now", MoveNowEvent}, - {N_("Retract Move Ctrl+X"), "Retract Move", RetractMoveEvent}, + {N_("Move Now Ctrl+M"), "MoveNow", MoveNowEvent}, + {N_("Retract Move Ctrl+X"), "RetractMove", RetractMoveEvent}, {NULL, NULL, NULL} }; @@ -225,58 +697,92 @@ MenuItem optionsMenu[] = { #ifdef OPTIONSDIALOG {N_("General ..."), "General", OptionsProc}, #endif - {N_("Time Control ... Alt+Shift+T"), "Time Control", TimeControlProc}, - {N_("Common Engine ... Alt+Shift+U"), "Common Engine", UciMenuProc}, + {N_("Time Control ... Alt+Shift+T"), "TimeControl", TimeControlProc}, + {N_("Common Engine ... Alt+Shift+U"), "CommonEngine", 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_("Load Game ..."), "LoadGame", LoadOptionsProc}, + {N_("Save Game ..."), "SaveGame", SaveOptionsProc}, // {N_(" ..."), "", OptionsProc}, - {N_("Game List ..."), "Game List", GameListOptionsPopUp}, + {N_("Game List ..."), "GameList", GameListOptionsProc}, {N_("Sounds ..."), "Sounds", SoundOptionsProc}, {"----", NULL, NothingProc}, #ifndef OPTIONSDIALOG - {N_("Always Queen Ctrl+Shift+Q"), "Always Queen", AlwaysQueenProc}, - {N_("Animate Dragging"), "Animate Dragging", AnimateDraggingProc}, - {N_("Animate Moving Ctrl+Shift+A"), "Animate Moving", AnimateMovingProc}, - {N_("Auto Flag Ctrl+Shift+F"), "Auto Flag", AutoflagProc}, - {N_("Auto Flip View"), "Auto Flip View", AutoflipProc}, + {N_("Always Queen Ctrl+Shift+Q"), "AlwaysQueen", AlwaysQueenProc}, + {N_("Animate Dragging"), "AnimateDragging", AnimateDraggingProc}, + {N_("Animate Moving Ctrl+Shift+A"), "AnimateMoving", AnimateMovingProc}, + {N_("Auto Flag Ctrl+Shift+F"), "AutoFlag", AutoflagProc}, + {N_("Auto Flip View"), "AutoFlipView", AutoflipProc}, {N_("Blindfold"), "Blindfold", BlindfoldProc}, - {N_("Flash Moves"), "Flash Moves", FlashMovesProc}, + {N_("Flash Moves"), "FlashMoves", FlashMovesProc}, #if HIGHDRAG - {N_("Highlight Dragging"), "Highlight Dragging", HighlightDraggingProc}, + {N_("Highlight Dragging"), "HighlightDragging", HighlightDraggingProc}, #endif - {N_("Highlight Last Move"), "Highlight Last Move", HighlightLastMoveProc}, - {N_("Highlight With Arrow"), "Arrow", HighlightArrowProc}, - {N_("Move Sound"), "Move Sound", MoveSoundProc}, -// {N_("ICS Alarm"), "ICS Alarm", IcsAlarmProc}, - {N_("One-Click Moving"), "OneClick", OneClickProc}, - {N_("Periodic Updates"), "Periodic Updates", PeriodicUpdatesProc}, - {N_("Ponder Next Move Ctrl+Shift+P"), "Ponder Next Move", PonderNextMoveProc}, - {N_("Popup Exit Message"), "Popup Exit Message", PopupExitMessageProc}, - {N_("Popup Move Errors"), "Popup Move Errors", PopupMoveErrorsProc}, + {N_("Highlight Last Move"), "HighlightLastMove", HighlightLastMoveProc}, + {N_("Highlight With Arrow"), "HighlightWithArrow", HighlightArrowProc}, + {N_("Move Sound"), "MoveSound", MoveSoundProc}, +// {N_("ICS Alarm"), "ICSAlarm", IcsAlarmProc}, + {N_("One-Click Moving"), "OneClickMoving", OneClickProc}, + {N_("Periodic Updates"), "PeriodicUpdates", PeriodicUpdatesProc}, + {N_("Ponder Next Move Ctrl+Shift+P"), "PonderNextMove", PonderNextMoveProc}, + {N_("Popup Exit Message"), "PopupExitMessage", PopupExitMessageProc}, + {N_("Popup Move Errors"), "PopupMoveErrors", PopupMoveErrorsProc}, // {N_("Premove"), "Premove", PremoveProc}, - {N_("Show Coords"), "Show Coords", ShowCoordsProc}, - {N_("Hide Thinking Ctrl+Shift+H"), "Hide Thinking", HideThinkingProc}, - {N_("Test Legality Ctrl+Shift+L"), "Test Legality", TestLegalityProc}, + {N_("Show Coords"), "ShowCoords", ShowCoordsProc}, + {N_("Hide Thinking Ctrl+Shift+H"), "HideThinking", HideThinkingProc}, + {N_("Test Legality Ctrl+Shift+L"), "TestLegality", TestLegalityProc}, {"----", NULL, NothingProc}, #endif - {N_("Save Settings Now"), "Save Settings Now", SaveSettingsProc}, - {N_("Save Settings on Exit"), "Save Settings on Exit", SaveOnExitProc}, + {N_("Save Settings Now"), "SaveSettingsNow", SaveSettingsProc}, + {N_("Save Settings on Exit"), "SaveSettingsonExit", SaveOnExitProc}, {NULL, NULL, NULL} }; MenuItem helpMenu[] = { - {N_("Info XBoard"), "Info XBoard", InfoProc}, - {N_("Man XBoard F1"), "Man XBoard", ManProc}, + {N_("Info XBoard"), "InfoXBoard", InfoProc}, + {N_("Man XBoard F1"), "ManXBoard", ManProc}, {"----", NULL, NothingProc}, - {N_("XBoard Home Page"), "Home Page", HomePageProc}, - {N_("On-line User Guide"), "User Guide", GuideProc}, - {N_("Development News"), "News Page", NewsPageProc}, - {N_("e-Mail Bug Report"), "Bug Report", BugReportProc}, + {N_("XBoard Home Page"), "XBoardHomePage", HomePageProc}, + {N_("On-line User Guide"), "On-lineUserGuide", GuideProc}, + {N_("Development News"), "DevelopmentNews", NewsPageProc}, + {N_("e-Mail Bug Report"), "e-MailBugReport", BugReportProc}, {"----", NULL, NothingProc}, - {N_("About XBoard"), "About XBoard", AboutProc}, + {N_("About XBoard"), "AboutXBoard", AboutProc}, + {NULL, NULL, NULL} +}; + +MenuItem noMenu[] = { + { "", "LoadNextGame", LoadNextGameProc }, + { "", "LoadPrevGame", LoadPrevGameProc }, + { "", "ReloadGame", ReloadGameProc }, + { "", "ReloadPosition", ReloadPositionProc }, +#ifndef OPTIONSDIALOG + { "", "AlwaysQueen", AlwaysQueenProc }, + { "", "AnimateDragging", AnimateDraggingProc }, + { "", "AnimateMoving", AnimateMovingProc }, + { "", "Autoflag", AutoflagProc }, + { "", "Autoflip", AutoflipProc }, + { "", "Blindfold", BlindfoldProc }, + { "", "FlashMoves", FlashMovesProc }, +#if HIGHDRAG + { "", "HighlightDragging", HighlightDraggingProc }, +#endif + { "", "HighlightLastMove", HighlightLastMoveProc }, +// { "", "IcsAlarm", IcsAlarmProc }, + { "", "MoveSound", MoveSoundProc }, + { "", "PeriodicUpdates", PeriodicUpdatesProc }, + { "", "PopupExitMessage", PopupExitMessageProc }, + { "", "PopupMoveErrors", PopupMoveErrorsProc }, +// { "", "Premove", PremoveProc }, + { "", "ShowCoords", ShowCoordsProc }, + { "", "ShowThinking", ShowThinkingProc }, + { "", "HideThinking", HideThinkingProc }, + { "", "TestLegality", TestLegalityProc }, +#endif + { "", "AboutGame", AboutGameEvent }, + { "", "DebugProc", DebugProc }, + { "", "Nothing", NothingProc }, {NULL, NULL, NULL} }; @@ -292,13 +798,27 @@ Menu menuBar[] = { {NULL, NULL, NULL} }; -int -MenuToNumber(char *menuName) +MenuItem * +MenuNameToItem (char *menuName) { - int i; - for(i=0; imi; - while (mi->string != NULL) { - AppendMenuItem(mi->string, mi->ref, mi->proc); - menuItemList[nrOfMenuItems].name = mi->ref; - menuItemList[nrOfMenuItems].proc = mi->proc; - if(strcmp(mi->string, "----")) nrOfMenuItems++; - mi++; - } +void +SetNCPMode () +{ + SetMenuEnables(ncpEnables); +} - if(!strcmp(mb->name, "Engine")) AppendEnginesToMenu(appData.recentEngineList); +void +SetGNUMode () +{ + SetMenuEnables(gnuEnables); } void -CreateMainMenus (Menu *mb) +SetCmailMode () { - char menuName[MSG_SIZ]; + SetMenuEnables(cmailEnables); +} - while(menuItemList[nrOfMenuItems].name) nrOfMenuItems++; // skip any predefined items +void +SetTrainingModeOn () +{ + SetMenuEnables(trainingOnEnables); + if (appData.showButtonBar) { + EnableButtonBar(False); + } + CommentPopDown(); +} - while (mb->name != NULL) { - safeStrCpy(menuName, "menu", sizeof(menuName)/sizeof(menuName[0]) ); - strncat(menuName, mb->ref, MSG_SIZ - strlen(menuName) - 1); - AddPullDownMenu(menuName, mb++); +void +SetTrainingModeOff () +{ + SetMenuEnables(trainingOffEnables); + if (appData.showButtonBar) { + EnableButtonBar(True); + } +} + +void +SetUserThinkingEnables () +{ + if (appData.noChessProgram) return; + SetMenuEnables(userThinkingEnables); +} + +void +SetMachineThinkingEnables () +{ + if (appData.noChessProgram) return; + SetMenuEnables(machineThinkingEnables); + switch (gameMode) { + case MachinePlaysBlack: + case MachinePlaysWhite: + case TwoMachinesPlay: + EnableNamedMenuItem(ModeToWidgetName(gameMode), True); + break; + default: + break; + } +} + +void +GreyRevert (Boolean grey) +{ + MarkMenuItem("Edit.Revert", !grey); + MarkMenuItem("Edit.Annotate", !grey); +} + +char * +ModeToWidgetName (GameMode mode) +{ + switch (mode) { + case BeginningOfGame: + if (appData.icsActive) + return "Mode.ICSClient"; + else if (appData.noChessProgram || + *appData.cmailGameName != NULLCHAR) + return "Mode.EditGame"; + else + return "Mode.MachineBlack"; + case MachinePlaysBlack: + return "Mode.MachineBlack"; + case MachinePlaysWhite: + return "Mode.MachineWhite"; + case AnalyzeMode: + return "Mode.AnalysisMode"; + case AnalyzeFile: + return "Mode.AnalyzeFile"; + case TwoMachinesPlay: + return "Mode.TwoMachines"; + case EditGame: + return "Mode.EditGame"; + case PlayFromGameFile: + return "File.LoadGame"; + case EditPosition: + return "Mode.EditPosition"; + case Training: + return "Mode.Training"; + case IcsPlayingWhite: + case IcsPlayingBlack: + case IcsObserving: + case IcsIdle: + case IcsExamining: + return "Mode.ICSClient"; + default: + case EndOfGame: + return NULL; + } +} + +void +InitMenuMarkers() +{ +#ifndef OPTIONSDIALOG + if (appData.alwaysPromoteToQueen) { + MarkMenuItem("Options.Always Queen", True); + } + if (appData.animateDragging) { + MarkMenuItem("Options.Animate Dragging", True); + } + if (appData.animate) { + MarkMenuItem("Options.Animate Moving", True); + } + if (appData.autoCallFlag) { + MarkMenuItem("Options.Auto Flag", True); + } + if (appData.autoFlipView) { + XtSetValues(XtNameToWidget(menuBarWidget,"Options.Auto Flip View", True); + } + if (appData.blindfold) { + MarkMenuItem("Options.Blindfold", True); + } + if (appData.flashCount > 0) { + MarkMenuItem("Options.Flash Moves", True); + } +#if HIGHDRAG + if (appData.highlightDragging) { + MarkMenuItem("Options.Highlight Dragging", True); + } +#endif + if (appData.highlightLastMove) { + MarkMenuItem("Options.Highlight Last Move", True); + } + if (appData.highlightMoveWithArrow) { + MarkMenuItem("Options.Arrow", True); + } +// if (appData.icsAlarm) { +// MarkMenuItem("Options.ICS Alarm", True); +// } + if (appData.ringBellAfterMoves) { + MarkMenuItem("Options.Move Sound", True); + } + if (appData.oneClick) { + MarkMenuItem("Options.OneClick", True); + } + if (appData.periodicUpdates) { + MarkMenuItem("Options.Periodic Updates", True); + } + if (appData.ponderNextMove) { + MarkMenuItem("Options.Ponder Next Move", True); + } + if (appData.popupExitMessage) { + MarkMenuItem("Options.Popup Exit Message", True); + } + if (appData.popupMoveErrors) { + MarkMenuItem("Options.Popup Move Errors", True); + } +// if (appData.premove) { +// MarkMenuItem("Options.Premove", True); +// } + if (appData.showCoords) { + MarkMenuItem("Options.Show Coords", True); + } + if (appData.hideThinkingFromHuman) { + MarkMenuItem("Options.Hide Thinking", True); + } + if (appData.testLegality) { + MarkMenuItem("Options.Test Legality", True); + } +#endif + if (saveSettingsOnExit) { + MarkMenuItem("Options.SaveSettingsonExit", True); } }