From 35185452d7546ab56aa0040d7c2d68795c3f813f Mon Sep 17 00:00:00 2001 From: oroborus Date: Sun, 6 Apr 2008 17:25:52 +0000 Subject: - synchronizuju sa aj veci - preklady obsahuju aj font a velkost pismen - upravy aby to slo ( po stahnut tejto verzii sa hra musi odinstalovat a znova naonstalovat ) git-svn-id: http://opensvn.csie.org/tuxanci_ng@43 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/language.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 4 deletions(-) (limited to 'src/language.c') diff --git a/src/language.c b/src/language.c index 51a7d5b..5291f44 100644 --- a/src/language.c +++ b/src/language.c @@ -8,15 +8,38 @@ #include "list.h" #include "homeDirector.h" #include "textFile.h" +#include "configFile.h" #include "language.h" static textFile_t *languageFile; +static char fontFile[STR_FILE_NAME_SIZE]; +static int fontSize; -void initLanguage() +char* getHead(textFile_t *ts) +{ + int i; + + for( i = 0 ; i < ts->text->count ; i++ ) + { + char *line; + line = (char *) (ts->text->list[i]); + + if( strncmp(line, "HEAD", 4) == 0 ) + { + return line; + } + } + + return NULL; +} + + +int initLanguage() { textFile_t *languageTypeFile; char path[STR_PATH_SIZE]; char *lang; + char *head; sprintf(path, "%s/lang.conf", getHomeDirector()); languageTypeFile = loadTextFile(path); @@ -34,25 +57,60 @@ void initLanguage() if( languageTypeFile == NULL ) { fprintf(stderr, "Don't create %s\n", path); - return; + return -1; } if( languageTypeFile->text->count == 0 ) { fprintf(stderr, "File %s empty\n", path); - return; + return -1; } lang = ((char *)languageTypeFile->text->list[0]); printf("select lang %s\n", lang); - sprintf(path, PATH_DATA "lang.%s", lang); + sprintf(path, PATH_LANG "%s.lang", lang); languageFile = loadTextFile(path); if( languageFile == NULL ) { fprintf(stderr, "Don't load %s\n", path); + return -1; + } + + head = getHead(languageFile); + + if( head != NULL ) + { + char val[STR_SIZE]; + + if( getValue(head, "fontfile", val, STR_SIZE) == 0 ) + { + strcpy(fontFile, val); + } + else + { + fprintf(stderr, "fontfile in lang file %s not found\n", path); + return -1; + } + + if( getValue(head, "fontsize", val, STR_SIZE) == 0 ) + { + fontSize = atoi(val); + } + else + { + fprintf(stderr, "fontsize in lang file %s not found\n", path); + return -1; + } } + else + { + fprintf(stderr, "head in lang file %s not found\n", path); + return -1; + } + + return 0; } char* getMyText(char *key) @@ -76,6 +134,16 @@ char* getMyText(char *key) return NULL; } +char* getLanguageFont() +{ + return fontFile; +} + +int getLanguageSize() +{ + return fontSize; +} + void quitLanguage() { destroyTextFile(languageFile); -- cgit v1.2.3