This code was still duplicated between WB and XB in the front-ends.
Because of its incorporation in AnalyzeModeEvent the 'middle-end'
function AnalyzeModeProc could be eliminated. AnalyzeModeEvent was made
to return an int to flag its success, and keep the JAWS code based
on it out of XBoard.
The AnalyzeGame code is now incorporated in AnalyzeFileEvent().
}
}
+/* Toggle ShowThinking */
void
+ToggleShowThinking()
+{
+ appData.showThinking = !appData.showThinking;
+ ShowThinkingEvent();
+}
+
+int
AnalyzeModeEvent ()
{
- if (gameMode == AnalyzeMode) { ToggleSecond(); return; }
+ char buf[MSG_SIZ];
+
+ if (!first.analysisSupport) {
+ snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
+ DisplayError(buf, 0);
+ return 0;
+ }
+ /* [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 0;
+ }
+ /* if enable, user wants to disable icsEngineAnalyze */
+ if (appData.icsEngineAnalyze) {
+ ExitAnalyzeMode();
+ ModeHighlight();
+ return 0;
+ }
+ appData.icsEngineAnalyze = TRUE;
+ if (appData.debugMode)
+ fprintf(debugFP, _("ICS engine analyze starting... \n"));
+ }
+
+ if (gameMode == AnalyzeMode) { ToggleSecond(); return 0; }
if (appData.noChessProgram || gameMode == AnalyzeMode)
- return;
+ return 0;
if (gameMode != AnalyzeFile) {
if (!appData.icsEngineAnalyze) {
EditGameEvent();
- if (gameMode != EditGame) return;
+ if (gameMode != EditGame) return 0;
}
+ if (!appData.showThinking) ToggleShowThinking();
ResurrectChessProgram();
SendToProgram("analyze\n", &first);
first.analyzing = TRUE;
StartAnalysisClock();
GetTimeMark(&lastNodeCountTime);
lastNodeCount = 0;
+ return 1;
}
void
if (appData.noChessProgram || gameMode == AnalyzeFile)
return;
+ if (!first.analysisSupport) {
+ char buf[MSG_SIZ];
+ snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
+ DisplayError(buf, 0);
+ return;
+ }
+
if (gameMode != AnalyzeMode) {
EditGameEvent();
if (gameMode != EditGame) return;
+ if (!appData.showThinking) ToggleShowThinking();
ResurrectChessProgram();
SendToProgram("analyze\n", &first);
first.analyzing = TRUE;
GetTimeMark(&lastNodeCountTime);
lastNodeCount = 0;
if(appData.timeDelay > 0) StartLoadGameTimer((long)(1000.0f * appData.timeDelay));
+ AnalysisPeriodicEvent(1);
}
void
void EditTagsEvent P((void));
void GetMoveListEvent P((void));
void ExitAnalyzeMode P((void));
-void AnalyzeModeEvent P((void));
+int AnalyzeModeEvent P((void));
void AnalyzeFileEvent P((void));
void MatchEvent P((int mode));
void RecentEngineEvent P((int nr));
}
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);
{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_("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},
PromotionPopup(hwndMain);\r
}\r
\r
-/* Toggle ShowThinking */\r
-VOID\r
-ToggleShowThinking()\r
-{\r
- appData.showThinking = !appData.showThinking;\r
- ShowThinkingEvent();\r
-}\r
-\r
VOID\r
LoadGameDialog(HWND hwnd, char* title)\r
{\r
break;\r
\r
case IDM_AnalysisMode:\r
- if (!first.analysisSupport) {\r
- snprintf(buf, MSG_SIZ, _("%s does not support analysis"), first.tidy);\r
- DisplayError(buf, 0);\r
- } else {\r
+ if(AnalyzeModeEvent()) {\r
SAY("analyzing current position");\r
- /* [DM] icsEngineAnlyze [HGM] Why is this front-end??? */\r
- if (appData.icsActive) {\r
- if (gameMode != IcsObserving) {\r
- snprintf(buf, MSG_SIZ, "You are not observing a game");\r
- DisplayError(buf, 0);\r
- /* secure check */\r
- if (appData.icsEngineAnalyze) {\r
- if (appData.debugMode) \r
- fprintf(debugFP, "Found unexpected active ICS engine analyze \n");\r
- ExitAnalyzeMode();\r
- ModeHighlight();\r
- break;\r
- }\r
- break;\r
- } else {\r
- /* if enable, user want disable icsEngineAnalyze */\r
- if (appData.icsEngineAnalyze) {\r
- ExitAnalyzeMode();\r
- ModeHighlight();\r
- break;\r
- }\r
- appData.icsEngineAnalyze = TRUE;\r
- if (appData.debugMode) fprintf(debugFP, "ICS engine analyze starting...\n");\r
- }\r
- } \r
- if (!appData.showThinking) ToggleShowThinking();\r
- AnalyzeModeEvent();\r
}\r
break;\r
\r
case IDM_AnalyzeFile:\r
- if (!first.analysisSupport) {\r
- char buf[MSG_SIZ];\r
- snprintf(buf, MSG_SIZ, _("%s does not support analysis"), first.tidy);\r
- DisplayError(buf, 0);\r
- } else {\r
- if (!appData.showThinking) ToggleShowThinking();\r
- AnalyzeFileEvent();\r
-// LoadGameDialog(hwnd, _("Analyze Game from File"));\r
- AnalysisPeriodicEvent(1);\r
- }\r
+ AnalyzeFileEvent();\r
break;\r
\r
case IDM_IcsClient:\r