diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-03-21 14:03:35 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-03-21 14:03:35 +0000 |
| commit | 114131bf71d7d4ec48c92a7bde8183442995940f (patch) | |
| tree | 84a3e5ba788d3a6bf76f5067b861fbce8b2f239b /src/term.c | |
| parent | 1e1d106a545a9cadc517de1a0ad931f1a8fcc2fa (diff) | |
- vypisovanie sprav do hry
- oprava chyby odhlaelenj pomocou valgrindu
- zena rychlosti zbrani
- drobne upravy
git-svn-id: http://opensvn.csie.org/tuxanci_ng@31 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/src/term.c b/src/term.c new file mode 100644 index 0000000..62dcd8f --- /dev/null +++ b/src/term.c @@ -0,0 +1,105 @@ + +#include <stdlib.h> +#include <assert.h> + +#include "main.h" +#include "list.h" +#include "interface.h" +#include "font.h" +#include "term.h" +#include "myTimer.h" + +typedef struct struct_term_t +{ + char *text; + my_time_t delTime; +} term_t; + +static list_t *listText; + +static term_t* newTermItem(char *s) +{ + term_t *new; + char *line; + int len; + + assert( s != NULL ); + + line = strdup(s); + len = strlen(line); + line[len-1] = '\0'; + + new = malloc( sizeof(term_t) ); + memset(new, 0, sizeof(term_t)); + + new->text = line; + new->delTime = getMyTime() + TERM_DEL_TEXT_TIMEOUT; + + return new; +} + +static void destroyTermItem(term_t *p) +{ + assert( p != NULL ); + + free(p->text); + free(p); +} + +void initTerm() +{ + listText = newList(); +} + +void drawTerm() +{ + int i; + + for( i = 0 ; i < listText->count ; i++ ) + { + char *line; + + line = (char *)( (term_t *)listText->list[i] )->text; + drawFont(line, 10, 10 + i*20, COLOR_WHITE); + } +} + +void eventTerm() +{ + my_time_t currentTime; + int i; + + currentTime = getMyTime(); + + + for( i = 0 ; i < listText->count ; i++ ) + { + my_time_t thisTime; + + thisTime = ( (term_t *)listText->list[i] )->delTime; + + if( currentTime > thisTime ) + { + delListItem(listText, i, destroyTermItem); + i--; + } + } + +} + +void appendTextInTerm(char *s) +{ + + addList(listText, newTermItem(s) ); + + if( listText->count > TERM_MAX_LINES ) + { + delListItem(listText, 0, destroyTermItem); + } +} + +void quitTerm() +{ + assert( listText != NULL ); + destroyListItem(listText, destroyTermItem); +} |