MCPcopy Create free account
hub / github.com/DFHack/dfhack / scroll_dwarfmode

Function scroll_dwarfmode

plugins/edgescroll.cpp:123–143  ·  view source on GitHub ↗

Scroll main fortress/adventure world views

Source from the content-addressed store, hash-verified

121
122// Scroll main fortress/adventure world views
123static void scroll_dwarfmode(int xdiff, int ydiff) {
124 using df::global::window_x;
125 using df::global::window_y;
126 using df::global::game;
127 // Scale the movement by pixels, to keep scroll speeds visually consistent
128 int tilesize = gps->viewport_zoom_factor / 4;
129 int width = gps->main_viewport->dim_x;
130 int height = gps->main_viewport->dim_y;
131
132 // Ensure the map doesn't go fully off-screen
133 int min_x = -width / 2;
134 int min_y = -height / 2;
135 int max_x = world->map.x_count - (width / 2);
136 int max_y = world->map.y_count - (height / 2);
137 apply_scroll(window_x, xdiff * std::max(1, map_scroll_pixels / tilesize), min_x, max_x);
138 apply_scroll(window_y, ydiff * std::max(1, map_scroll_pixels / tilesize), min_y, max_y);
139
140 // Force a minimap update
141 game->minimap.update = 1;
142 game->minimap.mustmake = 1;
143}
144
145template<typename T>
146static void scroll_world_internal(T* screen, int xdiff, int ydiff) {

Callers 1

Calls 1

apply_scrollFunction · 0.85

Tested by

no test coverage detected