diff options
| author | scarab <scarab@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-07-07 18:46:52 +0000 |
|---|---|---|
| committer | scarab <scarab@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-07-07 18:46:52 +0000 |
| commit | 6ca82a3f9841941caef20380fe014a8d4ac5349b (patch) | |
| tree | 9bc2d67bef704a193ed470a243d896a5ea2a2006 | |
| parent | 7344a044d40bf9329a5f2a8960c1c75fec448c19 (diff) | |
"Prepsano credits aby se zobrazovalo trochu jinak a predelana detekce na existenci souboru (hra nespadne)"
git-svn-id: http://opensvn.csie.org/tuxanci_ng@122 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
| -rw-r--r-- | config.h | 2 | ||||
| -rw-r--r-- | src/base/main.c | 8 | ||||
| -rw-r--r-- | src/screen/screen_credits.c | 45 |
3 files changed, 41 insertions, 14 deletions
@@ -1 +1 @@ -#define TUXANCI_NG_VERSION "svn121" +#define TUXANCI_NG_VERSION "svn122" diff --git a/src/base/main.c b/src/base/main.c index 5fb3d4e..ebc2018 100644 --- a/src/base/main.c +++ b/src/base/main.c @@ -101,6 +101,14 @@ void accessExistFile(const char *s) } } +int tryExistFile (const char *s) +{ + if (access(s, F_OK) !=0) + return 1; + else + return 0; +} + int main(int argc, char *argv[]) { listHelp = newList(); diff --git a/src/screen/screen_credits.c b/src/screen/screen_credits.c index 6104efb..39859cd 100644 --- a/src/screen/screen_credits.c +++ b/src/screen/screen_credits.c @@ -26,7 +26,7 @@ static widget_button_t *button_back; static list_t *listWidgetLabel; static textFile_t *textFile; static int offset; - +static int creditExists; void startScreenCredits() { #ifndef NO_SOUND @@ -104,21 +104,37 @@ void initScreenCredits() button_back = newWidgetButton(getMyText("BACK"), WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, WINDOW_SIZE_Y-80, eventWidget); listWidgetLabel = newList(); - accessExistFile(PATH_DATA SCREEN_CREDITS_FILE); - textFile = loadTextFile(PATH_DATA SCREEN_CREDITS_FILE); - for( i = 0 ; i < textFile->text->count ; i++ ) + if( tryExistFile(PATH_DATA SCREEN_CREDITS_FILE) == 0 ) { - widget_label_t *label; - char *line; - - line = (char *)textFile->text->list[i]; - label = newWidgetLabel(line, WINDOW_SIZE_X/2, (WINDOW_SIZE_Y-100)+i*20, - WIDGET_LABEL_CENTER); + creditExists=1; + textFile = loadTextFile(PATH_DATA SCREEN_CREDITS_FILE); + for( i = 0 ; i < textFile->text->count ; i++ ) + { + widget_label_t *label; + char *line; + line = (char *)textFile->text->list[i]; + label = newWidgetLabel(line, WINDOW_SIZE_X/2-WINDOW_SIZE_X/4, + (WINDOW_SIZE_Y-100)+i*20, WIDGET_LABEL_LEFT); - addList(listWidgetLabel, label); + addList(listWidgetLabel, label); + } } - + else + { + for( i = 0 ; i < 5 ; i++ ) + { + creditExists=0; + widget_label_t *label; + char *line; + line = "Credit file not found..."; + label = newWidgetLabel(line, WINDOW_SIZE_X/2, (WINDOW_SIZE_Y-100)+i*20, + WIDGET_LABEL_CENTER); + + addList(listWidgetLabel, label); + } + } + registerScreen( newScreen("credits", startScreenCredits, eventScreenCredits, drawScreenCredits, stopScreenCredits) ); } @@ -129,6 +145,9 @@ void quitScreenCredits() destroyWidgetButton(button_back); destroyListItem(listWidgetLabel, destroyWidgetLabel); - destroyTextFile(textFile); + if( creditExists ) + { + destroyTextFile(textFile); + } } |