/*\r
* woptions.c -- Options dialog box routines for WinBoard\r
*\r
- * Copyright 2000, 2009, 2010 Free Software Foundation, Inc.\r
+ * Copyright 2000, 2009, 2010, 2011 Free Software Foundation, Inc.\r
*\r
* Enhancements Copyright 2005 Alessandro Scotti\r
*\r
VOID SetSaveOptionEnables(HWND hDlg);\r
VOID SetTimeControlEnables(HWND hDlg);\r
\r
+char *\r
+InterpretFileName(char *buf, char *homeDir)\r
+{ // [HGM] file name relative to homeDir. (Taken out of SafeOptionsDialog, because it is generally useful)\r
+ char *result = NULL;\r
+ if ((isalpha(buf[0]) && buf[1] == ':') ||\r
+ (buf[0] == '\\' && buf[1] == '\\')) {\r
+ return strdup(buf);\r
+ } else {\r
+ char buf2[MSG_SIZ], buf3[MSG_SIZ];\r
+ char *dummy;\r
+ GetCurrentDirectory(MSG_SIZ, buf3);\r
+ SetCurrentDirectory(homeDir);\r
+ if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {\r
+ result = strdup(buf2);\r
+ } else {\r
+ result = strdup(buf);\r
+ }\r
+ SetCurrentDirectory(buf3);\r
+ }\r
+ return result;\r
+}\r
+\r
/*---------------------------------------------------------------------------*\\r
*\r
* General Options Dialog functions\r
int i=0, j;\r
while((j = radioButton[i++]) != -2) {\r
if(j == -1) continue; // no menu button\r
- if(IsDlgButtonChecked(hDlg, j)) return (VariantClass) i-1;\r
+ if(IsDlgButtonChecked(hDlg, j) &&\r
+ (appData.noChessProgram || strstr(first.variants, VariantName(i-1)))) return (VariantClass) i-1;\r
}\r
return gameInfo.variant; // If no button checked, keep old\r
}\r
if (IsDlgButtonChecked(hDlg, OPT_Autosave)) {\r
appData.autoSaveGames = TRUE;\r
if (IsDlgButtonChecked(hDlg, OPT_AVPrompt)) {\r
- appData.saveGameFile = "";\r
+ ASSIGN(appData.saveGameFile, ""); // [HGM] make sure value is ALWAYS in allocated memory\r
} else /*if (IsDlgButtonChecked(hDlg, OPT_AVToFile))*/ {\r
GetDlgItemText(hDlg, OPT_AVFilename, buf, MSG_SIZ);\r
if (*buf == NULLCHAR) {\r
_("Option Error"), MB_OK|MB_ICONEXCLAMATION);\r
return FALSE;\r
}\r
- if ((isalpha(buf[0]) && buf[1] == ':') ||\r
- (buf[0] == '\\' && buf[1] == '\\')) {\r
- appData.saveGameFile = strdup(buf);\r
- } else {\r
- char buf2[MSG_SIZ], buf3[MSG_SIZ];\r
- char *dummy;\r
- GetCurrentDirectory(MSG_SIZ, buf3);\r
- SetCurrentDirectory(installDir);\r
- if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {\r
- appData.saveGameFile = strdup(buf2);\r
- } else {\r
- appData.saveGameFile = strdup(buf);\r
- }\r
- SetCurrentDirectory(buf3);\r
- }\r
+ FREE(appData.saveGameFile);\r
+ appData.saveGameFile = InterpretFileName(buf, homeDir);\r
}\r
} else {\r
appData.autoSaveGames = FALSE;\r
- appData.saveGameFile = "";\r
+ ASSIGN(appData.saveGameFile, "");\r
}\r
appData.oldSaveStyle = IsDlgButtonChecked(hDlg, OPT_Old);\r
appData.saveOutOfBookInfo = IsDlgButtonChecked( hDlg, OPT_OutOfBookInfo );\r
* UCI Options Dialog functions\r
*\r
\*---------------------------------------------------------------------------*/\r
-static BOOL BrowseForFolder( const char * title, char * path )\r
+BOOL BrowseForFolder( const char * title, char * path )\r
{\r
BOOL result = FALSE;\r
BROWSEINFO bi;\r