X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=menus.c;h=0cbaa7738b4c9f815f281d936ce2a200da3db05d;hb=a009a27e8c1e0bfa818f12fdcae675d0babc510a;hp=304d3c419999af0ff3fbd2ddf7e374212030c736;hpb=45bea0f2fdd5d1e938b0b8c0c2044e4d7bd2e0d2;p=xboard.git diff --git a/menus.c b/menus.c index 304d3c4..0cbaa77 100644 --- a/menus.c +++ b/menus.c @@ -5,7 +5,7 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. * * The following terms apply to Digital Equipment Corporation's copyright * interest in XBoard: @@ -87,10 +87,6 @@ extern char *getenv(); #include "frontend.h" #include "backend.h" -#include "backendz.h" -#include "moves.h" -#include "xhistory.h" -#include "xedittags.h" #include "menus.h" #include "gettext.h" @@ -256,67 +252,6 @@ QuitProc () } void -AnalyzeModeProc () -{ - char buf[MSG_SIZ]; - - if (!first.analysisSupport) { - snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy); - DisplayError(buf, 0); - return; - } - /* [DM] icsEngineAnalyze [HGM] This is horrible code; reverse the gameMode and isEngineAnalyze tests! */ - if (appData.icsActive) { - if (gameMode != IcsObserving) { - snprintf(buf, MSG_SIZ, _("You are not observing a game")); - DisplayError(buf, 0); - /* secure check */ - if (appData.icsEngineAnalyze) { - if (appData.debugMode) - fprintf(debugFP, _("Found unexpected active ICS engine analyze \n")); - ExitAnalyzeMode(); - ModeHighlight(); - } - return; - } - /* if enable, use want disable icsEngineAnalyze */ - if (appData.icsEngineAnalyze) { - ExitAnalyzeMode(); - ModeHighlight(); - return; - } - appData.icsEngineAnalyze = TRUE; - if (appData.debugMode) - fprintf(debugFP, _("ICS engine analyze starting... \n")); - } -#ifndef OPTIONSDIALOG - if (!appData.showThinking) - ShowThinkingProc(); -#endif - - AnalyzeModeEvent(); -} - -void -AnalyzeFileProc () -{ - if (!first.analysisSupport) { - char buf[MSG_SIZ]; - snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy); - DisplayError(buf, 0); - return; - } -// Reset(FALSE, TRUE); -#ifndef OPTIONSDIALOG - if (!appData.showThinking) - ShowThinkingProc(); -#endif - AnalyzeFileEvent(); -// FileNamePopUp(_("File to analyze"), "", ".pgn .game", LoadGamePopUp, "rb"); - AnalysisPeriodicEvent(1); -} - -void MatchProc () { MatchEvent(2); @@ -632,6 +567,12 @@ HideThinkingProc () MARK_MENU_ITEM("Options.HideThinking", appData.hideThinkingFromHuman); } +void +CreateBookDelayed () +{ + ScheduleDelayedEvent(CreateBookEvent, 50); +} + /* * Menu definition tables */ @@ -641,7 +582,7 @@ MenuItem fileMenu[] = { {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"), "LoadGame", LoadGameProc}, + {N_("Load Game Ctrl+O"), "LoadGame", LoadGameProc, CHECK}, {N_("Load Position Ctrl+Shift+O"), "LoadPosition", LoadPositionProc}, // {N_("Load Next Game"), "LoadNextGame", LoadNextGameProc}, // {N_("Load Previous Game"), "LoadPreviousGame", LoadPrevGameProc}, @@ -652,6 +593,7 @@ MenuItem fileMenu[] = { // {N_("Reload Same Position"), "Reload Same Position", ReloadPositionProc}, {N_("Save Game Ctrl+S"), "SaveGame", SaveGameProc}, {N_("Save Position Ctrl+Shift+S"), "SavePosition", SavePositionProc}, + {N_("Save Games as Book"), "CreateBook", CreateBookDelayed}, {"----", NULL, NothingProc}, {N_("Mail Move"), "MailMove", MailMoveEvent}, {N_("Reload CMail Message"), "ReloadCMailMessage", ReloadCmailMsgProc}, @@ -686,17 +628,18 @@ MenuItem editMenu[] = { }; MenuItem viewMenu[] = { - {N_("Flip View F2"), "FlipView", FlipViewProc}, + {N_("Flip View F2"), "FlipView", FlipViewProc, CHECK}, {"----", NULL, NothingProc}, - {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}, + {N_("Engine Output Alt+Shift+O"), "EngineOutput", EngineOutputProc, CHECK}, + {N_("Move History Alt+Shift+H"), "MoveHistory", HistoryShowProc, CHECK}, // [HGM] hist: activate 4.2.7 code + {N_("Evaluation Graph Alt+Shift+E"), "EvaluationGraph", EvalGraphProc, CHECK}, + {N_("Game List Alt+Shift+G"), "GameList", ShowGameListProc, CHECK}, + {N_("ICS text menu"), "ICStextmenu", IcsTextProc, CHECK}, {"----", NULL, NothingProc}, - {N_("Tags"), "Tags", EditTagsProc}, - {N_("Comments"), "Comments", EditCommentProc}, - {N_("ICS Input Box"), "ICSInputBox", IcsInputBoxProc}, + {N_("Tags"), "Tags", EditTagsProc, CHECK}, + {N_("Comments"), "Comments", EditCommentProc, CHECK}, + {N_("ICS Input Box"), "ICSInputBox", IcsInputBoxProc, CHECK}, + {N_("Open Chat Window"), "OpenChatWindow", ChatProc, CHECK}, {"----", NULL, NothingProc}, {N_("Board..."), "Board", BoardOptionsProc}, {N_("Game List Tags..."), "GameListTags", GameListOptionsProc}, @@ -704,18 +647,18 @@ MenuItem viewMenu[] = { }; MenuItem modeMenu[] = { - {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", AnalyzeModeProc}, - {N_("Analyze Game Ctrl+G"), "AnalyzeFile", AnalyzeFileProc }, - {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent}, - {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent}, - {N_("Training"), "Training", TrainingEvent}, - {N_("ICS Client"), "ICSClient", IcsClientEvent}, + {N_("Machine White Ctrl+W"), "MachineWhite", MachineWhiteEvent, RADIO }, + {N_("Machine Black Ctrl+B"), "MachineBlack", MachineBlackEvent, RADIO }, + {N_("Two Machines Ctrl+T"), "TwoMachines", TwoMachinesEvent, RADIO }, + {N_("Analysis Mode Ctrl+A"), "AnalysisMode", (MenuProc*) AnalyzeModeEvent, RADIO}, + {N_("Analyze Game Ctrl+G"), "AnalyzeFile", AnalyzeFileEvent, RADIO }, + {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent, RADIO }, + {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent, RADIO }, + {N_("Training"), "Training", TrainingEvent, RADIO }, + {N_("ICS Client"), "ICSClient", IcsClientEvent, RADIO }, {"----", NULL, NothingProc}, - {N_("Machine Match"), "MachineMatch", MatchProc}, - {N_("Pause Pause"), "Pause", PauseEvent}, + {N_("Machine Match"), "MachineMatch", MatchProc, CHECK }, + {N_("Pause Pause"), "Pause", PauseEvent, CHECK }, {NULL, NULL, NULL} }; @@ -740,9 +683,9 @@ MenuItem actionMenu[] = { {NULL, NULL, NULL} }; -MenuItem engineMenu[] = { - {N_("Load New 1st Engine ..."), "LoadEngine", LoadEngine1Proc}, - {N_("Load New 2nd Engine ..."), "LoadEngine", LoadEngine2Proc}, +MenuItem engineMenu[100] = { + {N_("Load New 1st Engine ..."), "LoadNew1stEngine", LoadEngine1Proc}, + {N_("Load New 2nd Engine ..."), "LoadNew2ndEngine", LoadEngine2Proc}, {"----", NULL, NothingProc}, {N_("Engine #1 Settings ..."), "Engine#1Settings", FirstSettingsProc}, {N_("Engine #2 Settings ..."), "Engine#2Settings", SecondSettingsProc}, @@ -797,7 +740,7 @@ MenuItem optionsMenu[] = { {"----", NULL, NothingProc}, #endif {N_("Save Settings Now"), "SaveSettingsNow", SaveSettingsProc}, - {N_("Save Settings on Exit"), "SaveSettingsonExit", SaveOnExitProc}, + {N_("Save Settings on Exit"), "SaveSettingsonExit", SaveOnExitProc, CHECK }, {NULL, NULL, NULL} }; @@ -843,7 +786,7 @@ MenuItem noMenu[] = { { "", "TestLegality", TestLegalityProc }, #endif { "", "AboutGame", AboutGameEvent }, - { "", "Debug", DebugProc }, + { "", "DebugProc", DebugProc }, { "", "Nothing", NothingProc }, {NULL, NULL, NULL} }; @@ -883,18 +826,22 @@ MenuNameToItem (char *menuName) return NULL; // item not found } +int firstEngineItem; + void AppendEnginesToMenu (char *list) { int i=0; char *p; if(appData.icsActive || appData.recentEngines <= 0) return; + for(firstEngineItem=0; engineMenu[firstEngineItem].string; firstEngineItem++); recentEngines = strdup(list); while (*list) { p = strchr(list, '\n'); if(p == NULL) break; - if(i == 0) AppendMenuItem("----", 0); // at least one valid item to add + if(i == 0) engineMenu[firstEngineItem++].string = "----"; // at least one valid item to add *p = 0; - AppendMenuItem(list, i); + if(firstEngineItem + i < 99) + engineMenu[firstEngineItem+i].string = strdup(list); // just set name; MenuProc stays NULL i++; *p = '\n'; list = p + 1; } } @@ -908,7 +855,7 @@ Enables icsEnables[] = { { "Mode.AnalyzeFile", False }, { "Mode.TwoMachines", False }, { "Mode.MachineMatch", False }, -#ifndef ZIPPY +#if !ZIPPY { "Engine.Hint", False }, { "Engine.Book", False }, { "Engine.MoveNow", False }, @@ -920,7 +867,8 @@ Enables icsEnables[] = { #endif { "Engine.Engine#1Settings", False }, { "Engine.Engine#2Settings", False }, - { "Engine.LoadEngine", False }, + { "Engine.Load1stEngine", False }, + { "Engine.Load2ndEngine", False }, { "Edit.Annotate", False }, { "Options.Match", False }, { NULL, False } @@ -938,6 +886,7 @@ Enables ncpEnables[] = { { "Mode.ICSClient", False }, { "View.ICStextmenu", False }, { "View.ICSInputBox", False }, + { "View.OpenChatWindow", False }, { "Action.", False }, { "Edit.Revert", False }, { "Edit.Annotate", False }, @@ -964,6 +913,7 @@ Enables gnuEnables[] = { { "Mode.ICSClient", False }, { "View.ICStextmenu", False }, { "View.ICSInputBox", False }, + { "View.OpenChatWindow", False }, { "Action.Accept", False }, { "Action.Decline", False }, { "Action.Rematch", False }, @@ -1080,8 +1030,8 @@ SetICSMode () #if ZIPPY if (appData.zippyPlay && !appData.noChessProgram) { /* [DM] icsEngineAnalyze */ - EnableMenuItem("Analysis Mode", True); - EnableMenuItem("Engine #1 Settings", True); + EnableNamedMenuItem("Mode.AnalysisMode", True); + EnableNamedMenuItem("Engine.Engine#1Settings", True); } #endif } @@ -1139,7 +1089,7 @@ SetMachineThinkingEnables () case MachinePlaysBlack: case MachinePlaysWhite: case TwoMachinesPlay: - EnableMenuItem(ModeToWidgetName(gameMode), True); + EnableNamedMenuItem(ModeToWidgetName(gameMode), True); break; default: break;