From ff83f12b31674b7787ac2e59714c427438de21e7 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 12 May 2009 19:05:33 +0000 Subject: [PATCH] Fixed all sdl_delays to wait for 20ms, not 1. Avoid problems for low-latency guys. Also, made the splash screen stay as long as you don't click or key. Mouse moves are discarded. Sorry! git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@800 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- buttons.c | 2 +- engine.c | 18 +++++++++--------- help.c | 2 +- misc.c | 4 ++-- readline.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/buttons.c b/buttons.c index 4b9346d6..90105156 100644 --- a/buttons.c +++ b/buttons.c @@ -135,7 +135,7 @@ void Button_Message_initial(void) Display_cursor(); - while(!Get_input()) SDL_Delay(1); + while(!Get_input() && !Mouse_K && !Key) SDL_Delay(20); if (Mouse_K) Wait_end_of_click(); diff --git a/engine.c b/engine.c index 5c843363..c8f54883 100644 --- a/engine.c +++ b/engine.c @@ -448,7 +448,7 @@ void Move_separator(void) Display_cursor(); } } - if(!Get_input())SDL_Delay(1); + if(!Get_input())SDL_Delay(20); } // Effacer la barre en XOR @@ -895,7 +895,7 @@ void Main_handler(void) } } } - else SDL_Delay(1); // S'il n'y a pas d'évènement, on ne gère pas tout ça et on attend un peu. La partie en dessous doit être exécutée quand + else SDL_Delay(20); // S'il n'y a pas d'évènement, on ne gère pas tout ça et on attend un peu. La partie en dessous doit être exécutée quand // même pour les trucs asynchrones, par exemple le spray. // Gestion de la souris @@ -1772,7 +1772,7 @@ short Wait_click_in_palette(T_Palette_button * button) for (;;) { - while(!Get_input())SDL_Delay(1); + while(!Get_input())SDL_Delay(20); if (Mouse_K==LEFT_SIDE) { @@ -1858,7 +1858,7 @@ void Get_color_behind_window(byte * color, byte * click) do { - if(!Get_input())SDL_Delay(1); + if(!Get_input())SDL_Delay(20); if ((Mouse_X!=old_x) || (Mouse_Y!=old_y)) { @@ -1953,7 +1953,7 @@ void Move_window(short dx, short dy) old_x=new_x; old_y=new_y; - while(!Get_input() && new_x==Mouse_X-dx && new_y==Mouse_Y-dy) SDL_Delay(1); + while(!Get_input() && new_x==Mouse_X-dx && new_y==Mouse_Y-dy) SDL_Delay(20); new_x=Mouse_X-dx; @@ -2151,7 +2151,7 @@ short Window_dropdown_on_click(T_Dropdown_button *Button) do { // Attente - if(!Get_input()) SDL_Delay(1); + if(!Get_input()) SDL_Delay(20); // Mise à jour du survol selected_index=Window_click_in_rectangle(2,2,Button->Dropdown_width-2,box_height-1)? (((Mouse_Y-Window_pos_Y)/Menu_factor_Y-2)>>3) : -1; @@ -2197,7 +2197,7 @@ short Window_normal_button_onclick(word x_pos, word y_pos, word width, word heig Display_cursor(); while (Window_click_in_rectangle(x_pos,y_pos,x_pos+width-1,y_pos+height-1)) { - if(!Get_input()) SDL_Delay(1); + if(!Get_input()) SDL_Delay(20); if (!Mouse_K) { Hide_cursor(); @@ -2211,7 +2211,7 @@ short Window_normal_button_onclick(word x_pos, word y_pos, word width, word heig Display_cursor(); while (!(Window_click_in_rectangle(x_pos,y_pos,x_pos+width-1,y_pos+height-1))) { - if(!Get_input()) SDL_Delay(1); + if(!Get_input()) SDL_Delay(20); if (!Mouse_K) return 0; } @@ -2445,7 +2445,7 @@ short Window_clicked_button(void) { short Button; - if(!Get_input())SDL_Delay(1); + if(!Get_input())SDL_Delay(20); // Gestion des clicks if (Mouse_K) diff --git a/help.c b/help.c index 9443792a..ba9e3394 100644 --- a/help.c +++ b/help.c @@ -88,7 +88,7 @@ void Redefine_control(word *shortcut, int x_pos, int y_pos) Display_cursor(); while (1) { - while(!Get_input())SDL_Delay(1); + while(!Get_input())SDL_Delay(20); if (Key==KEY_ESC) return; if (Key!=0) diff --git a/misc.c b/misc.c index f70959ee..d951fc7e 100644 --- a/misc.c +++ b/misc.c @@ -125,7 +125,7 @@ void Wait_end_of_click(void) { // On désactive tous les raccourcis clavier - while(Mouse_K) if(!Get_input()) SDL_Delay(1); + while(Mouse_K) if(!Get_input()) SDL_Delay(20); } void Hide_current_image_with_stencil(byte color, byte * stencil) @@ -626,7 +626,7 @@ void Slider_timer(byte speed) end = SDL_GetTicks() + speed*10; do { - if (!Get_input()) SDL_Delay(1); + if (!Get_input()) SDL_Delay(20); } while (Mouse_K == original_mouse_k && SDL_GetTicks()