diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-08 15:08:39 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-08-08 15:08:39 +0000 |
| commit | 54d61c622ba721b4ea57852e0ba6c87acfa66a2b (patch) | |
| tree | 5240311b5ab0aca967089b60df22034457fe515c /src/client/term.c | |
| parent | 8a49909114b3590d48d808b664db8b804bfe2ff7 (diff) | |
- schopnost autodetekce jazyka systému → v případě neznámého jazyka se zvolí default (angličtina)
- pamatovat posledně hranou arénu → vybrat ji a dostatečně zvýraznit
- pauza klevsa [P]
- seznam hráčů pod klávesou TAB – skóre, ping
git-svn-id: http://opensvn.csie.org/tuxanci_ng@193 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/client/term.c')
| -rw-r--r-- | src/client/term.c | 148 |
1 files changed, 99 insertions, 49 deletions
diff --git a/src/client/term.c b/src/client/term.c index fc1824d..6cad4d4 100644 --- a/src/client/term.c +++ b/src/client/term.c @@ -5,102 +5,152 @@ #include "main.h" #include "list.h" #include "myTimer.h" +#include "tux.h" +#include "space.h" +#include "arena.h" #include "interface.h" #include "term.h" #include "font.h" -typedef struct struct_term_t -{ - char *text; - my_time_t delTime; -} term_t; - static list_t *listText; +static bool_t activeTerm; +static my_time_t lastActive; +static my_time_t lastRefresh; -static term_t* newTermItem(char *s) +void initTerm() { - term_t *new; - char *line; - int len; + listText = newList(); - assert( s != NULL ); - - line = strdup(s); - len = strlen(line); - line[len-1] = '\0'; + activeTerm = FALSE; + lastActive = getMyTime(); + lastRefresh = lastActive; +} - new = malloc( sizeof(term_t) ); - memset(new, 0, sizeof(term_t)); +static char* getStrGun(int gun) +{ + switch( gun ) + { + case GUN_SIMPLE : return "revolver"; + case GUN_DUAL_SIMPLE : return "dual revolver"; + case GUN_SCATTER : return "scatter"; + case GUN_TOMMY : return "tommy"; + case GUN_LASSER : return "lasser"; + case GUN_MINE : return "mine"; + case GUN_BOMBBALL : return "bombball"; + default : return "none"; + } - new->text = line; - new->delTime = getMyTime() + TERM_DEL_TEXT_TIMEOUT; + return "gun_unknow"; +} - return new; +static char* getStrBonus(int bonus) +{ + switch( bonus ) + { + case BONUS_SPEED : return "speed"; + case BONUS_SHOT : return "shot"; + case BONUS_TELEPORT : return "teleport"; + case BONUS_GHOST : return "ghost"; + case BONUS_4X : return "4X"; + case BONUS_HIDDEN : return "hidden"; + default : return "none"; + } + + return "bonus_unknow"; } -static void destroyTermItem(term_t *p) +static void action_refreshTerm(space_t *space, tux_t *tux, void *p) { - assert( p != NULL ); - - free(p->text); - free(p); + char str[STR_SIZE]; + + sprintf(str, + "name: %s " + "score: %d " + "gun: %s " + "shot: %d " + "bonus: %s", + + tux->name, tux->score, + getStrGun(tux->gun), + tux->shot[tux->gun], + getStrBonus(tux->bonus) + ); + + addList(listText, strdup(str) ); } -void initTerm() +static void refreshTerm() { + arena_t *arena; + + arena = getCurrentArena(); + + destroyListItem(listText, free); listText = newList(); + + actionSpace(arena->spaceTux, action_refreshTerm, NULL); + + //printf("refresh term..\n"); } void drawTerm() { int i; + if( activeTerm == FALSE ) + { + return; + } + for( i = 0 ; i < listText->count ; i++ ) { char *line; - line = (char *)( (term_t *)listText->list[i] )->text; + line = (char *) listText->list[i]; drawFont(line, 10, 10 + i*20, COLOR_WHITE); } } +static void switchTerm() +{ + if( activeTerm == TRUE ) + { + activeTerm = FALSE; + } + else + { + activeTerm = TRUE; + } +} + void eventTerm() { my_time_t currentTime; - int i; + Uint8 *mapa; - currentTime = getMyTime(); + mapa = SDL_GetKeyState(NULL); + currentTime = getMyTime(); - for( i = 0 ; i < listText->count ; i++ ) + if( currentTime - lastRefresh > TERM_REFRESH_TIME_INTERVAL ) { - my_time_t thisTime; - - thisTime = ( (term_t *)listText->list[i] )->delTime; - - if( currentTime > thisTime ) - { - delListItem(listText, i, destroyTermItem); - i--; - } + lastRefresh = currentTime; + refreshTerm(); } -} - -void appendTextInTerm(char *s) -{ - - addList(listText, newTermItem(s) ); - - if( listText->count > TERM_MAX_LINES ) + if( mapa[SDLK_TAB] == SDL_PRESSED ) { - delListItem(listText, 0, destroyTermItem); + if( currentTime - lastActive > TERM_ACTIVE_TIME_INTERVAL ) + { + lastActive = currentTime; + switchTerm(); + } } } void quitTerm() { assert( listText != NULL ); - destroyListItem(listText, destroyTermItem); + destroyListItem(listText, free); } |