Commit 5fa6881a authored by Matthew Trey's avatar Matthew Trey

word lists can now be loaded from user_settings_path/words (editor and games)

git-svn-id: svn://svn.debian.org/svn/tux4kids/tuxtype/trunk@1651 47d30e19-490b-0410-9d18-e851f4e465b3
parent 906743c1
......@@ -59,23 +59,31 @@ void ChooseListToEdit(void)
SDL_Surface *max_title_size = NULL; //using this to figure out size of wordlist name
//Temporary holders and ptrs used while scanning list directory:
char wordsDir[FNLEN];
char fn[FNLEN];
FILE* fp = NULL;
DIR* lists_dir = NULL;
struct dirent* list_dirent = NULL;
DEBUGCODE { fprintf(stderr , "%s/words", settings.var_data_path); }
/* First part - scan through our word list directory and create lists */
/* of the filenames and titles (first lines in files). */
/* NOTE we could use scandir() to do almost all of this as we do */
/* in tuxmath. */
//Try to open directory for modifiable word lists:
sprintf(fn , "%s/words" , settings.var_data_path);
lists_dir = opendir(fn);
//Try to open a directory for modifiable word lists:
sprintf(wordsDir, "%s/words", settings.user_settings_path);
if (CheckFile(wordsDir))
{
DEBUGCODE { fprintf(stderr, "User specific wordlist path found: %s\n", wordsDir); }
}
else
{
DEBUGCODE { fprintf(stderr , "Editor: checking directory: %s/words", settings.var_data_path); }
sprintf(wordsDir , "%s/words" , settings.var_data_path);
}
lists_dir = opendir(wordsDir);
if (!lists_dir)
{
......@@ -105,7 +113,7 @@ void ChooseListToEdit(void)
if (strcmp(&list_dirent->d_name[strlen(list_dirent->d_name) -4 ],".txt"))
continue;
snprintf(fn, FNLEN, "%s/words/%s" , settings.var_data_path, list_dirent->d_name);
snprintf(fn, FNLEN, "%s/%s" , wordsDir, list_dirent->d_name);
/* CheckFile() returns 2 if dir, 1 if file, 0 if neither: */
if (CheckFile(fn) == 1)
......@@ -322,7 +330,7 @@ void ChooseListToEdit(void)
{
num_lists = 0;
//Try to open directory for modifiable word lists:
sprintf(fn , "%s/words" , settings.var_data_path);
sprintf(fn , "%s" , wordsDir);
lists_dir = opendir(fn);
if (!lists_dir)
......@@ -345,7 +353,7 @@ void ChooseListToEdit(void)
if (strcmp("CVS", list_dirent->d_name) == 0)
continue;
snprintf(fn, FNLEN, "%s/words/%s" , settings.var_data_path, list_dirent->d_name);
snprintf(fn, FNLEN, "%s/%s" , wordsDir, list_dirent->d_name);
/* CheckFile() returns 2 if dir, 1 if file, 0 if neither: */
if (CheckFile(fn) == 1)
......
......@@ -1213,23 +1213,32 @@ static int chooseWordlist(void)
/* find the directory to load wordlists from */
/* Check under theme directory first, if theme selected: */
if (!settings.use_english) /* Using theme: */
/* First Check the user's personal settings */
sprintf(wordPath, "%s/words", settings.user_settings_path);
if (CheckFile(wordPath))
{
sprintf(wordPath,"%s/words", settings.theme_data_path);
if (!CheckFile(wordPath))
{
fprintf(stderr, "chooseWordList() - theme contains no wordlist dir \n");
return 0;
}
DEBUGCODE { fprintf(stderr, "User specific wordlist path found: %s\n", wordPath); }
}
else /* No theme selected - using English: */
/* If nothing found, check under theme directory, if theme selected: */
else
{
sprintf(wordPath,"%s/words", settings.default_data_path);
if (!CheckFile(wordPath))
if (!settings.use_english) /* Using theme: */
{
fprintf(stderr, "chooseWordList() - data path contains no wordlist dir \n");
return 0;
sprintf(wordPath,"%s/words", settings.theme_data_path);
if (!CheckFile(wordPath))
{
fprintf(stderr, "chooseWordList() - theme contains no wordlist dir \n");
return 0;
}
}
else /* No user settings or theme selected - using English: */
{
sprintf(wordPath,"%s/words", settings.default_data_path);
if (!CheckFile(wordPath))
{
fprintf(stderr, "chooseWordList() - data path contains no wordlist dir \n");
return 0;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment