Fix multi-leg promotions
[xboard.git] / menus.c
diff --git a/menus.c b/menus.c
index 4934a3c..50968c1 100644 (file)
--- a/menus.c
+++ b/menus.c
@@ -5,7 +5,8 @@
  * Massachusetts.
  *
  * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
- * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+ * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free
+ * Software Foundation, Inc.
  *
  * The following terms apply to Digital Equipment Corporation's copyright
  * interest in XBoard:
@@ -105,6 +106,7 @@ extern char *getenv();
 char  *gameCopyFilename, *gamePasteFilename;
 Boolean saveSettingsOnExit;
 char *settingsFileName;
+char gamesDir[MSG_SIZ], positionsDir[MSG_SIZ], textureDir[MSG_SIZ], bookDir[MSG_SIZ], piecesDir[MSG_SIZ];
 
 static int
 LoadGamePopUp (FILE *f, int gameNumber, char *title)
@@ -173,10 +175,12 @@ ReloadPositionProc ()
 void
 LoadPositionProc()
 {
+    static char buf[MSG_SIZ];
     if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
        Reset(FALSE, TRUE);
     }
-    FileNamePopUp(_("Load position file name?"), "", ".fen .epd .pos", LoadPosition, "rb");
+    snprintf(buf, MSG_SIZ, "%s/", appData.positionDir);
+    FileNamePopUp(_("Load position file name?"), buf, ".fen .epd .pos", LoadPosition, "rb");
 }
 
 void
@@ -254,6 +258,8 @@ QuitProc ()
 void
 MatchProc ()
 {
+    static Enables matchOff[] = { { "Mode.MachineMatch", False }, { NULL, False } };
+    if(matchMode) SetMenuEnables(matchOff);
     MatchEvent(2);
 }
 
@@ -310,19 +316,6 @@ SaveSettingsProc ()
 }
 
 void
-InfoProc ()
-{
-    char buf[MSG_SIZ];
-#ifdef __APPLE__
-    snprintf(buf, MSG_SIZ, "%s ./info.command", appData.sysOpen);
-#else
-    snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
-           INFODIR, INFOFILE);
-#endif
-    system(buf);
-}
-
-void
 BugReportProc ()
 {
     char buf[MSG_SIZ];
@@ -366,11 +359,10 @@ AboutProc ()
     snprintf(buf, sizeof(buf),
 _("%s%s\n\n"
 "Copyright 1991 Digital Equipment Corporation\n"
-"Enhancements Copyright 1992-2014 Free Software Foundation\n"
+"Enhancements Copyright 1992-2016 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"
-"The GTK build of this version is experimental and unstable\n\n"
+"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: <bug-xboard@gnu.org>\n\n"
@@ -395,7 +387,19 @@ DebugProc ()
 void
 EditEngineProc ()
 {
-    EditTagsPopUp(firstChessProgramNames, &firstChessProgramNames);
+    EditAnyPopUp(firstChessProgramNames, &firstChessProgramNames, _("Registered Engines"));
+}
+
+void
+EditThemesProc ()
+{
+    EditAnyPopUp(appData.themeNames, &appData.themeNames, _("Predefined Themes"));
+}
+
+void
+EditMenuProc ()
+{
+    EditAnyPopUp(icsTextMenuString, &icsTextMenuString, _("ICS Text-Menu Definition"));
 }
 
 void
@@ -651,14 +655,17 @@ MenuItem viewMenu[] = {
   {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"),      NULL,           "ICStextmenu",     IcsTextProc,            CHECK},
   {"----",                   NULL,            NULL,             NothingProc},
   {N_("Tags"),               NULL,           "Tags",            EditTagsProc,           CHECK},
   {N_("Comments"),           NULL,           "Comments",        EditCommentProc,        CHECK},
   {N_("ICS Input Box"),      NULL,           "ICSInputBox",     IcsInputBoxProc,        CHECK},
   {N_("ICS/Chat Console"),   NULL,           "OpenChatWindow",  ChatProc,               CHECK},
+  {N_("ICS text menu"),      NULL,           "ICStextmenu",     IcsTextProc,            CHECK},
+  {N_("Edit ICS menu..."),   NULL,           "EditTextMenu",    EditMenuProc},
   {"----",                   NULL,            NULL,             NothingProc},
+  {N_("Edit Theme List..."), NULL,           "EditThemeList",   EditThemesProc},
   {N_("Board..."),           NULL,           "Board",           BoardOptionsProc},
+  {N_("Fonts..."),           NULL,           "Fonts",           FontsProc},
   {N_("Game List Tags..."),  NULL,           "GameListTags",    GameListOptionsProc},
   {NULL,                     NULL,            NULL,             NULL}
 };
@@ -708,6 +715,7 @@ MenuItem engineMenu[100] = {
   {"----",                         NULL,      NULL,              NothingProc},
   {N_("Engine #1 Settings..."),    NULL,     "Engine#1Settings", FirstSettingsProc},
   {N_("Engine #2 Settings..."),    NULL,     "Engine#2Settings", SecondSettingsProc},
+  {N_("Common Settings..."), "<Alt><Shift>u","CommonEngine",     UciMenuProc},
   {"----",                         NULL,      NULL,              NothingProc},
   {N_("Hint"),                     NULL,     "Hint",             HintEvent},
   {N_("Book"),                     NULL,     "Book",             BookEvent},
@@ -722,7 +730,6 @@ MenuItem optionsMenu[] = {
   {N_("General..."),              NULL,             "General",             OptionsProc},
 #endif
   {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..."),                  NULL,             "ICS",                 IcsOptionsProc},
   {N_("Tournament..."),           NULL,             "Match",               MatchOptionsProc},
@@ -1176,6 +1183,7 @@ InstallNewEngine (char *command, char *dir, char *variants, char *protocol)
        snprintf(buf + strlen(buf), MSG_SIZ - strlen(buf), " -fd %s", dir);
     if(!strcmp(protocol, "uci"))
        snprintf(buf + strlen(buf), MSG_SIZ - strlen(buf), " -fUCI");
+    if(strstr(firstChessProgramNames, buf)) return; // avoid duplicats
     // append line
     quote = malloc(strlen(firstChessProgramNames) + strlen(buf) + 2);
     sprintf(quote, "%s%s\n", firstChessProgramNames, buf);