<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39667 >
> [dmarks - Mi 05. Sep 2007, 09:03:16]: > > > [EMAIL PROTECTED] - Tue Sep 04 13:09:46 2007]: > > > > SDL interface has some very annoying usability issues to address. > > > > (...) > > > > Auto-scrolling is annoying. It is especially annoying when playing in > > windowed mode when you are often moving the mouse cursor in and out of > > the game window. It would be better to scroll when pressing the > > right-mouse-button since the RMB is already used for manual movement. > > > > > > Could an option be made to turn this off in the Game Options dialog? > The attached patch disables auto-scrolling in windowed mode and reduces the sensible area in fullscreen mode to make accidental scrolling less likely. If that's still too problematic, an option can be added in a later release (would add a new translatable string). Pressing the right mouse button for a longer time already counts as middle-click in the current design (for two-button mice).
Index: client/gui-sdl/gui_main.c =================================================================== --- client/gui-sdl/gui_main.c (revision 13803) +++ client/gui-sdl/gui_main.c (working copy) @@ -359,14 +359,16 @@ button_behavior.counting = FALSE; button_behavior.button_down_ticks = 0; -#ifdef UNDER_CE is_map_scrolling = FALSE; -#endif return ID_ERROR; } -#define SCROLL_MAP_AREA 8 +#ifdef UNDER_CE + #define SCROLL_MAP_AREA 8 +#else + #define SCROLL_MAP_AREA 1 +#endif /************************************************************************** ... @@ -389,7 +391,13 @@ if(draw_goto_patrol_lines) { update_line(pMotionEvent->x, pMotionEvent->y); } - + +#ifndef UNDER_CE + if (gui_sdl_fullscreen) { + check_scroll_area(pMotionEvent->x, pMotionEvent->y); + } +#endif + if ((pWidget = MainWidgetListScaner(pMotionEvent->x, pMotionEvent->y)) != NULL) { update_mouse_cursor(CURSOR_DEFAULT); widget_sellected_action(pWidget); @@ -402,10 +410,6 @@ handle_mouse_cursor(ptile); hover_tile = ptile; - -#ifndef UNDER_CE - check_scroll_area(pMotionEvent->x, pMotionEvent->y); -#endif } } } @@ -446,45 +450,38 @@ } static int check_scroll_area(int x, int y) { - static SDL_Rect rect; - - rect.x = rect.y = 0; - rect.w = SCROLL_MAP_AREA; - rect.h = Main.map->h; - - if (is_in_rect_area(x, y, rect)) { + + SDL_Rect rect_north = {0, 0, Main.map->w, SCROLL_MAP_AREA}; + SDL_Rect rect_east = {Main.map->w - SCROLL_MAP_AREA, 0, SCROLL_MAP_AREA, Main.map->h}; + SDL_Rect rect_south = {0, Main.map->h - SCROLL_MAP_AREA, Main.map->w, SCROLL_MAP_AREA}; + SDL_Rect rect_west = {0, 0, SCROLL_MAP_AREA, Main.map->h}; + + if (is_in_rect_area(x, y, rect_north)) { is_map_scrolling = TRUE; - if (scroll_dir != DIR8_WEST) { - scroll_dir = DIR8_WEST; + if (is_in_rect_area(x, y, rect_west)) { + scroll_dir = DIR8_NORTHWEST; + } else if (is_in_rect_area(x, y, rect_east)) { + scroll_dir = DIR8_NORTHEAST; + } else { + scroll_dir = DIR8_NORTH; } - } else { - rect.x = Main.map->w - SCROLL_MAP_AREA; - if (is_in_rect_area(x, y, rect)) { - is_map_scrolling = TRUE; - if (scroll_dir != DIR8_EAST) { - scroll_dir = DIR8_EAST; - } + } else if (is_in_rect_area(x, y, rect_south)) { + is_map_scrolling = TRUE; + if (is_in_rect_area(x, y, rect_west)) { + scroll_dir = DIR8_SOUTHWEST; + } else if (is_in_rect_area(x, y, rect_east)) { + scroll_dir = DIR8_SOUTHEAST; } else { - rect.x = rect.y = 0; - rect.w = Main.map->w; - rect.h = SCROLL_MAP_AREA; - if (is_in_rect_area(x, y, rect)) { - is_map_scrolling = TRUE; - if (scroll_dir != DIR8_NORTH) { - scroll_dir = DIR8_NORTH; - } - } else { - rect.y = Main.map->h - SCROLL_MAP_AREA; - if (is_in_rect_area(x, y, rect)) { - is_map_scrolling = TRUE; - if (scroll_dir != DIR8_SOUTH) { - scroll_dir = DIR8_SOUTH; - } - } else { - is_map_scrolling = FALSE; - } - } + scroll_dir = DIR8_SOUTH; } + } else if (is_in_rect_area(x, y, rect_east)) { + is_map_scrolling = TRUE; + scroll_dir = DIR8_EAST; + } else if (is_in_rect_area(x, y, rect_west)) { + is_map_scrolling = TRUE; + scroll_dir = DIR8_WEST; + } else { + is_map_scrolling = FALSE; } return is_map_scrolling; @@ -539,13 +536,13 @@ Uint16 ID; static struct timeval tv; static fd_set civfdset; - Uint32 t1, t2, t3; + Uint32 t_current, t_last_unit_anim, t_last_map_scrolling; Uint32 real_timer_next_call; static int result, schot_nr = 0; static char schot[32]; ID = ID_ERROR; - t3 = t1 = real_timer_next_call = SDL_GetTicks(); + t_last_map_scrolling = t_last_unit_anim = real_timer_next_call = SDL_GetTicks(); while (ID == ID_ERROR) { /* ========================================= */ /* net check with 10ms delay event loop */ @@ -584,13 +581,13 @@ } /* ========================================= */ - t2 = SDL_GetTicks(); + t_current = SDL_GetTicks(); - if (t2 > real_timer_next_call) { - real_timer_next_call = t2 + (real_timer_callback() * 1000); + if (t_current > real_timer_next_call) { + real_timer_next_call = t_current + (real_timer_callback() * 1000); } - if ((t2 - t1) > UNITS_TIMER_INTERVAL) { + if ((t_current - t_last_unit_anim) > UNITS_TIMER_INTERVAL) { if (autoconnect) { widget_info_counter++; SDL_PushEvent(pAnim_User_Event); @@ -598,14 +595,18 @@ SDL_PushEvent(pAnim_User_Event); } - if (is_map_scrolling && (t2 - t3) > MAP_SCROLL_TIMER_INTERVAL) { - SDL_PushEvent(pMap_Scroll_User_Event); - t3 = SDL_GetTicks(); + t_last_unit_anim = SDL_GetTicks(); + } + + if (is_map_scrolling) { + if ((t_current - t_last_map_scrolling) > MAP_SCROLL_TIMER_INTERVAL) { + SDL_PushEvent(pMap_Scroll_User_Event); + t_last_map_scrolling = SDL_GetTicks(); } - - t1 = SDL_GetTicks(); + } else { + t_last_map_scrolling = SDL_GetTicks(); } - + if (widget_info_counter > 0) { SDL_PushEvent(pInfo_User_Event); widget_info_counter = 0;
Index: client/gui-sdl/gui_main.c =================================================================== --- client/gui-sdl/gui_main.c (revision 13783) +++ client/gui-sdl/gui_main.c (working copy) @@ -359,14 +359,16 @@ button_behavior.counting = FALSE; button_behavior.button_down_ticks = 0; -#ifdef UNDER_CE is_map_scrolling = FALSE; -#endif return ID_ERROR; } -#define SCROLL_MAP_AREA 8 +#ifdef UNDER_CE + #define SCROLL_MAP_AREA 8 +#else + #define SCROLL_MAP_AREA 1 +#endif /************************************************************************** ... @@ -389,7 +391,13 @@ if(draw_goto_patrol_lines) { update_line(pMotionEvent->x, pMotionEvent->y); } - + +#ifndef UNDER_CE + if (gui_sdl_fullscreen) { + check_scroll_area(pMotionEvent->x, pMotionEvent->y); + } +#endif + if ((pWidget = MainWidgetListScaner(pMotionEvent->x, pMotionEvent->y)) != NULL) { update_mouse_cursor(CURSOR_DEFAULT); widget_sellected_action(pWidget); @@ -399,9 +407,6 @@ } else { if (get_client_state() == CLIENT_GAME_RUNNING_STATE) { handle_mouse_cursor(canvas_pos_to_tile(pMotionEvent->x, pMotionEvent->y)); -#ifndef UNDER_CE - check_scroll_area(pMotionEvent->x, pMotionEvent->y); -#endif } } } @@ -442,45 +447,38 @@ } static int check_scroll_area(int x, int y) { - static SDL_Rect rect; - - rect.x = rect.y = 0; - rect.w = SCROLL_MAP_AREA; - rect.h = Main.map->h; - - if (is_in_rect_area(x, y, rect)) { + + SDL_Rect rect_north = {0, 0, Main.map->w, SCROLL_MAP_AREA}; + SDL_Rect rect_east = {Main.map->w - SCROLL_MAP_AREA, 0, SCROLL_MAP_AREA, Main.map->h}; + SDL_Rect rect_south = {0, Main.map->h - SCROLL_MAP_AREA, Main.map->w, SCROLL_MAP_AREA}; + SDL_Rect rect_west = {0, 0, SCROLL_MAP_AREA, Main.map->h}; + + if (is_in_rect_area(x, y, rect_north)) { is_map_scrolling = TRUE; - if (scroll_dir != DIR8_WEST) { - scroll_dir = DIR8_WEST; + if (is_in_rect_area(x, y, rect_west)) { + scroll_dir = DIR8_NORTHWEST; + } else if (is_in_rect_area(x, y, rect_east)) { + scroll_dir = DIR8_NORTHEAST; + } else { + scroll_dir = DIR8_NORTH; } - } else { - rect.x = Main.map->w - SCROLL_MAP_AREA; - if (is_in_rect_area(x, y, rect)) { - is_map_scrolling = TRUE; - if (scroll_dir != DIR8_EAST) { - scroll_dir = DIR8_EAST; - } + } else if (is_in_rect_area(x, y, rect_south)) { + is_map_scrolling = TRUE; + if (is_in_rect_area(x, y, rect_west)) { + scroll_dir = DIR8_SOUTHWEST; + } else if (is_in_rect_area(x, y, rect_east)) { + scroll_dir = DIR8_SOUTHEAST; } else { - rect.x = rect.y = 0; - rect.w = Main.map->w; - rect.h = SCROLL_MAP_AREA; - if (is_in_rect_area(x, y, rect)) { - is_map_scrolling = TRUE; - if (scroll_dir != DIR8_NORTH) { - scroll_dir = DIR8_NORTH; - } - } else { - rect.y = Main.map->h - SCROLL_MAP_AREA; - if (is_in_rect_area(x, y, rect)) { - is_map_scrolling = TRUE; - if (scroll_dir != DIR8_SOUTH) { - scroll_dir = DIR8_SOUTH; - } - } else { - is_map_scrolling = FALSE; - } - } + scroll_dir = DIR8_SOUTH; } + } else if (is_in_rect_area(x, y, rect_east)) { + is_map_scrolling = TRUE; + scroll_dir = DIR8_EAST; + } else if (is_in_rect_area(x, y, rect_west)) { + is_map_scrolling = TRUE; + scroll_dir = DIR8_WEST; + } else { + is_map_scrolling = FALSE; } return is_map_scrolling; @@ -535,13 +533,13 @@ Uint16 ID; static struct timeval tv; static fd_set civfdset; - Uint32 t1, t2, t3; + Uint32 t_current, t_last_unit_anim, t_last_map_scrolling; Uint32 real_timer_next_call; static int result, schot_nr = 0; static char schot[32]; ID = ID_ERROR; - t3 = t1 = real_timer_next_call = SDL_GetTicks(); + t_last_map_scrolling = t_last_unit_anim = real_timer_next_call = SDL_GetTicks(); while (ID == ID_ERROR) { /* ========================================= */ /* net check with 10ms delay event loop */ @@ -580,13 +578,13 @@ } /* ========================================= */ - t2 = SDL_GetTicks(); + t_current = SDL_GetTicks(); - if (t2 > real_timer_next_call) { - real_timer_next_call = t2 + (real_timer_callback() * 1000); + if (t_current > real_timer_next_call) { + real_timer_next_call = t_current + (real_timer_callback() * 1000); } - if ((t2 - t1) > UNITS_TIMER_INTERVAL) { + if ((t_current - t_last_unit_anim) > UNITS_TIMER_INTERVAL) { if (autoconnect) { widget_info_counter++; SDL_PushEvent(pAnim_User_Event); @@ -594,14 +592,18 @@ SDL_PushEvent(pAnim_User_Event); } - if (is_map_scrolling && (t2 - t3) > MAP_SCROLL_TIMER_INTERVAL) { - SDL_PushEvent(pMap_Scroll_User_Event); - t3 = SDL_GetTicks(); + t_last_unit_anim = SDL_GetTicks(); + } + + if (is_map_scrolling) { + if ((t_current - t_last_map_scrolling) > MAP_SCROLL_TIMER_INTERVAL) { + SDL_PushEvent(pMap_Scroll_User_Event); + t_last_map_scrolling = SDL_GetTicks(); } - - t1 = SDL_GetTicks(); + } else { + t_last_map_scrolling = SDL_GetTicks(); } - + if (widget_info_counter > 0) { SDL_PushEvent(pInfo_User_Event); widget_info_counter = 0;
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev