new advanced preference to choose whether middle-click scrolls...

...or warps (default=scrolls)
This commit is contained in:
Patrick Parker 2009-01-05 04:47:48 +00:00
parent b6f8870d1d
commit c81ae6895b
7 changed files with 38 additions and 5 deletions

View file

@ -1,12 +1,14 @@
Version 1.5.7+svn:
* Graphics:
* new portrait for Royal Guard, Heavy Infantry
* Fixed drawing glitches in the listboxes.
* Fixed several glitches with the new portrait dialog.
* User interface:
* new advanced preference to choose whether middle-click scrolls or warps
* Fixed a glitch which closed a new dialog on the mouse up event of the old
dialog (the effect is percieved as the new dialog not showing up).
* Spacebar closes the dialogs without a scrollbar again.
* Pressing escape in a new dialog, behaves like in the old dialogs again.
* new portrait for Royal Guard, Heavy Infantry
* Fixed several glitches in with the listboxes and new portrait dialog.
* Language and i18n:
* updated translations: German, Hungarian, Italian, Japanese, Slovak,
Spanish

View file

@ -54,6 +54,13 @@
default=yes
[/advanced_preference]
[advanced_preference]
field=middle_click_scrolls
name=_"Middle-click Scrolling"
type=boolean
default=yes
[/advanced_preference]
[advanced_preference]
field=animate_map
name=_"Animate Map"

View file

@ -153,7 +153,7 @@ bool controller_base::handle_scroll(CKey& key, int mousex, int mousey, int mouse
get_display().scroll(preferences::scroll_speed(),0);
scrolling = true;
}
if ((mouse_flags & SDL_BUTTON_MMASK) != 0) { //middle mouse button pressed
if ((mouse_flags & SDL_BUTTON_MMASK) != 0 && preferences::middle_click_scrolls()) {
const SDL_Rect& rect = get_display().map_outside_area();
if (point_in_rect(mousex, mousey,rect)) {
// relative distance from the center to the border

View file

@ -46,6 +46,7 @@ static bool command_active()
}
mouse_handler_base::mouse_handler_base() :
simple_warp_(false),
minimap_scrolling_(false),
dragging_left_(false),
dragging_started_(false),
@ -77,6 +78,10 @@ void mouse_handler_base::mouse_update(const bool browse)
bool mouse_handler_base::mouse_motion_default(int x, int y, bool& /*update*/)
{
if(simple_warp_) {
return true;
}
if(minimap_scrolling_) {
//if the game is run in a window, we could miss a LMB/MMB up event
// if it occurs outside our window.
@ -116,6 +121,9 @@ bool mouse_handler_base::mouse_motion_default(int x, int y, bool& /*update*/)
void mouse_handler_base::mouse_press(const SDL_MouseButtonEvent& event, const bool browse)
{
if(is_middle_click(event) && !preferences::middle_click_scrolls()) {
simple_warp_ = true;
}
show_menu_ = false;
mouse_update(browse);
int scrollx = 0;
@ -149,16 +157,24 @@ void mouse_handler_base::mouse_press(const SDL_MouseButtonEvent& event, const bo
}
} else if (is_middle_click(event)) {
if (event.state == SDL_PRESSED) {
// clicked on a hex on the minimap? then initiate minimap scrolling
const map_location& loc = gui().minimap_location_on(event.x,event.y);
map_location loc = gui().minimap_location_on(event.x,event.y);
minimap_scrolling_ = false;
if(loc.valid()) {
simple_warp_ = false;
minimap_scrolling_ = true;
last_hex_ = loc;
gui().scroll_to_tile(loc,display::WARP,false);
} else if(simple_warp_) {
// middle click not on minimap, check gamemap instead
loc = gui().hex_clicked_on(event.x,event.y);
if(loc.valid()) {
last_hex_ = loc;
gui().scroll_to_tile(loc,display::WARP,false);
}
}
} else if (event.state == SDL_RELEASED) {
minimap_scrolling_ = false;
simple_warp_ = false;
}
} else if (allow_mouse_wheel_scroll(event.x, event.y)) {
if (event.button == SDL_BUTTON_WHEELUP) {

View file

@ -132,6 +132,8 @@ protected:
void clear_dragging(const SDL_MouseButtonEvent& event, bool browse);
void init_dragging(bool& dragging_flag);
/** MMB click (on game map) state flag */
bool simple_warp_;
/** minimap scrolling (scroll-drag) state flag */
bool minimap_scrolling_;
/** LMB drag init flag */

View file

@ -514,6 +514,11 @@ void set_scroll_speed(const int new_speed)
scroll = new_speed / 100.0;
}
bool middle_click_scrolls()
{
return utils::string_bool(get("middle_click_scrolls"), true);
}
bool mouse_scroll_enabled()
{
return utils::string_bool(get("mouse_scrolling"), true);

View file

@ -127,6 +127,7 @@ namespace preferences {
int scroll_speed();
void set_scroll_speed(const int scroll);
bool middle_click_scrolls();
bool mouse_scroll_enabled();
void enable_mouse_scroll(bool value);