Merge branch 'master' into jgrpp
# Conflicts: # src/autoreplace_cmd.cpp # src/company_base.h # src/company_gui.cpp # src/cpu.cpp # src/debug.h # src/group.h # src/group_cmd.cpp # src/house.h # src/industry.h # src/newgrf_house.cpp # src/news_type.h # src/openttd.cpp # src/saveload/company_sl.cpp # src/settings_type.h # src/sl/oldloader_sl.cpp # src/story.cpp # src/table/town_land.h # src/viewport.cpp
This commit is contained in:
@@ -4315,9 +4315,20 @@ void UpdateNextViewportPosition(Window *w)
|
||||
if (delta_x != 0 || delta_y != 0) {
|
||||
if (_settings_client.gui.smooth_scroll) {
|
||||
int max_scroll = ScaleByMapSize1D(512 * ZOOM_LVL_BASE);
|
||||
/* Not at our desired position yet... */
|
||||
w->viewport->next_scrollpos_x += Clamp(DivAwayFromZero(delta_x, 4), -max_scroll, max_scroll);
|
||||
w->viewport->next_scrollpos_y += Clamp(DivAwayFromZero(delta_y, 4), -max_scroll, max_scroll);
|
||||
|
||||
int delta_x_clamped;
|
||||
int delta_y_clamped;
|
||||
|
||||
if (abs(delta_x) > abs(delta_y)) {
|
||||
delta_x_clamped = Clamp(DivAwayFromZero(delta_x, 4), -max_scroll, max_scroll);
|
||||
delta_y_clamped = delta_y * delta_x_clamped / delta_x;
|
||||
} else {
|
||||
delta_y_clamped = Clamp(DivAwayFromZero(delta_y, 4), -max_scroll, max_scroll);
|
||||
delta_x_clamped = delta_x * delta_y_clamped / delta_y;
|
||||
}
|
||||
|
||||
w->viewport->next_scrollpos_x += delta_x_clamped;
|
||||
w->viewport->next_scrollpos_y += delta_y_clamped;
|
||||
} else {
|
||||
w->viewport->next_scrollpos_x = w->viewport->dest_scrollpos_x;
|
||||
w->viewport->next_scrollpos_y = w->viewport->dest_scrollpos_y;
|
||||
|
Reference in New Issue
Block a user