switch(evenement.type) {
case SDL_KEYDOWN:
if(evenement.key.keysym.sym == SDLK_ESCAPE) {
- for(i=0;i<255;i++){
- str[i]=' ';
- }
+ for(i=0;i<255;i++)
+ str[i]=0;
*nb_chars=0;
*charselected=0;
waiting=false;
} else if(evenement.key.keysym.sym==SDLK_BACKSPACE){
if((*charselected)!=0) {
- for(i=(*charselected)-1;i<255;i++){
+ for(i=(*charselected)-1;i<255;i++)
str[i]=str[i+1];
- }
- str[255]=' ';
+ str[255]=0;
(*charselected)--;
(*nb_chars)--;
}
} else if(evenement.key.keysym.sym==SDLK_DELETE){
- for(i=(*charselected);i<255;i++){
- str[i]=str[i+1];
- }
- str[255]=' ';
- (*nb_chars)--;
+ if((*charselected)<(*nb_chars)){
+ for(i=(*charselected);i<255;i++)
+ str[i]=str[i+1];
+ str[255]=0;
+ (*nb_chars)--;
+ }
+ } else if(evenement.key.keysym.sym==SDLK_HOME){
+ (*charselected)=0;
+ } else if(evenement.key.keysym.sym==SDLK_END){
+ (*charselected)=(*nb_chars);
} else if(evenement.key.keysym.sym==SDLK_LEFT){
if((*charselected)!=0)
(*charselected)--;
(*charselected)++;
} else if(evenement.key.keysym.sym==SDLK_RETURN) {
waiting=false;
- } else if((evenement.key.keysym.unicode<127)&&((*nb_chars)<60)&&(evenement.key.keysym.sym!=SDLK_LSHIFT)&&(evenement.key.keysym.sym!=SDLK_RSHIFT)) {
- for(i=255;i>=(*charselected)+1;i--){
+ } else if(evenement.key.keysym.unicode>=32&&evenement.key.keysym.unicode<127&&(*nb_chars)<60){
+ for(i=255;i>=(*charselected)+1;i--)
str[i]=str[i-1];
- }
str[*charselected]=evenement.key.keysym.unicode;
(*charselected)++;
(*nb_chars)++;
mainmenu=1;
for(int j=0;j<255;j++){
- displaytext[0][j]=' ';
+ displaytext[0][j]=0;
}
displaychars[0]=0;
displayselected=0;
fireSound(firestartsound);
for(int i=0;i<255;i++){
- displaytext[0][i]=' ';
+ displaytext[0][i]=0;
}
displaychars[0]=0;
if(!winfreeze)leveltime+=multiplier;
//keys
- if(Input::isKeyDown(SDLK_ESCAPE)){
- chatting=0;
- console=0;
- freeze=0;
- displaychars[0]=0;
- }
-
if(Input::isKeyPressed(SDLK_v)&&debugmode){
freeze=1-freeze;
if(freeze){
inputText(displaytext[0],&displayselected,&displaychars[0]);
if(!waiting) {
if(displaychars[0]){
- for(int j=0;j<255;j++){
- displaytext[0][j]=' ';
- }
+ for(int j=0;j<255;j++)
+ displaytext[0][j]=0;
displaychars[0]=0;
displayselected=0;
}
inputText(consoletext[0],&consoleselected,&consolechars[0]);
if(!waiting) {
archiveselected=0;
- cmd_dispatch(this, consoletext[0]);
if(consolechars[0]>0){
-
+ consoletext[0][consolechars[0]]=' ';
+ cmd_dispatch(this, consoletext[0]);
for(int k=14;k>=1;k--){
- for(int j=0;j<255;j++){
+ for(int j=0;j<255;j++)
consoletext[k][j]=consoletext[k-1][j];
- }
consolechars[k]=consolechars[k-1];
}
- for(int j=0;j<255;j++){
- consoletext[0][j]=' ';
- }
+ for(int j=0;j<255;j++)
+ consoletext[0][j]=0;
consolechars[0]=0;
consoleselected=0;
}
if((Input::isKeyPressed(jumpkey)||Input::isKeyPressed(SDLK_SPACE))&&!campaign)
if(winfreeze)
winfreeze=0;
- if((Input::isKeyDown(SDLK_ESCAPE))&&!campaign&&gameon)
- if(winfreeze){
+ if((Input::isKeyDown(SDLK_ESCAPE))&&!campaign&&gameon){
+ if(console){
+ console=0;
+ freeze=0;
+ }else if(winfreeze){
mainmenu=9;
gameon=0;
}
+ }