[Tux4kids-commits] r1651 - tuxtype/trunk/src
Matthew Trey
treymd-guest at alioth.debian.org
Sat Nov 14 16:49:49 UTC 2009
Author: treymd-guest
Date: 2009-11-14 16:49:49 +0000 (Sat, 14 Nov 2009)
New Revision: 1651
Modified:
tuxtype/trunk/src/editor.c
tuxtype/trunk/src/titlescreen.c
Log:
word lists can now be loaded from user_settings_path/words (editor and games)
Modified: tuxtype/trunk/src/editor.c
===================================================================
--- tuxtype/trunk/src/editor.c 2009-11-14 15:17:19 UTC (rev 1650)
+++ tuxtype/trunk/src/editor.c 2009-11-14 16:49:49 UTC (rev 1651)
@@ -59,24 +59,32 @@
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)
{
fprintf(stderr, "ChooseListToEdit() - cannot open custom word list directory!\n");
@@ -105,7 +113,7 @@
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 @@
{
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 @@
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)
Modified: tuxtype/trunk/src/titlescreen.c
===================================================================
--- tuxtype/trunk/src/titlescreen.c 2009-11-14 15:17:19 UTC (rev 1650)
+++ tuxtype/trunk/src/titlescreen.c 2009-11-14 16:49:49 UTC (rev 1651)
@@ -1213,24 +1213,33 @@
/* 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;
+ }
+ }
}
/* If we get to here, we know there is at least a wordlist directory */
More information about the Tux4kids-commits
mailing list