From 62cdf2b04aa8d0162da8e024d9901ba5743bf5e3 Mon Sep 17 00:00:00 2001 From: oroborus Date: Mon, 30 Jun 2008 20:25:53 +0000 Subject: - hrac moze sucastne chodit aj strielat - na indexovanie poloziek v list_t sa pouizva index.c ( postaveny na list_t ) - oprava chyby, porgram sa zrutil ak nebolo inicializovane audio - zexxov patch git-svn-id: http://opensvn.csie.org/tuxanci_ng@80 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/widget/widget_textfield.c | 74 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 13 deletions(-) (limited to 'src/widget/widget_textfield.c') diff --git a/src/widget/widget_textfield.c b/src/widget/widget_textfield.c index f9186c9..2e4a9ec 100644 --- a/src/widget/widget_textfield.c +++ b/src/widget/widget_textfield.c @@ -87,17 +87,14 @@ static void readKey(widget_textfield_t *p) int len; int i; - if( p->time > 0 ) - { - p->time--; - return; - } - if( p->active == FALSE ) { return; } + if (p->atime < 100) + p->atime ++; + mapa = SDL_GetKeyState(NULL); len = strlen(p->text); @@ -106,7 +103,7 @@ static void readKey(widget_textfield_t *p) { if( len > 0 ) { - p->time = WIDGET_TEXTFIELD_TIME_READ_KEY; + p->time = 0; p->text[len-1]='\0'; getTextSize(p->text, &p->w, &p->h); } @@ -125,9 +122,30 @@ static void readKey(widget_textfield_t *p) //if(widthtime = WIDGET_TEXTFIELD_TIME_READ_KEY; + if (i == SDLK_SPACE) + { + strcat( p->text, " " ); + getTextSize(p->text, &p->w, &p->h); + return; + } + + const char *c = (const char *) SDL_GetKeyName(i); - strcat( p->text, SDL_GetKeyName(i) ); + if (len) { + if (p->text[len-1] == *c) { + p->time ++; + + if (p->time < WIDGET_TEXTFIELD_TIME_MULTIPLE) { + if (p->atime < 3) + return; + } + } else + p->time = 0; + } + + p->atime = 0; + + strcat( p->text, c ); getTextSize(p->text, &p->w, &p->h); if( mapa[SDLK_LSHIFT] == SDL_PRESSED || @@ -145,8 +163,23 @@ static void readKey(widget_textfield_t *p) { if( mapa[i] == SDL_PRESSED && len < STR_SIZE ) { - p->time = WIDGET_TEXTFIELD_TIME_READ_KEY; - strcat( p->text, SDL_GetKeyName(i) ); + const char *c = (const char *) SDL_GetKeyName(i); + + if (len) { + if (p->text[len-1] == *c) { + p->time ++; + + if (p->time < WIDGET_TEXTFIELD_TIME_MULTIPLE) { + if (p->atime < 3) + return; + } + } else + p->time = 0; + } + + p->atime = 0; + + strcat( p->text, c ); getTextSize(p->text, &p->w, &p->h); return; } @@ -157,8 +190,23 @@ static void readKey(widget_textfield_t *p) { if( mapa[i] == SDL_PRESSED && len < STR_SIZE ) { - p->time = WIDGET_TEXTFIELD_TIME_READ_KEY; - strncat( p->text, SDL_GetKeyName(i)+1, 1 ); // napr. "[4]" + const char *c = (const char *) SDL_GetKeyName(i)+1; + + if (len) { + if (p->text[len-1] == *c) { + p->time ++; + + if (p->time < WIDGET_TEXTFIELD_TIME_MULTIPLE) { + if (p->atime < 3) + return; + } + } else + p->time = 0; + } + + p->atime = 0; + + strncat( p->text, c, 1 ); // napr. "[4]" getTextSize(p->text, &p->w, &p->h); return; } -- cgit v1.2.3