| 200 | } |
| 201 | |
| 202 | DFhackCExport command_result plugin_onupdate(color_ostream &out) { |
| 203 | // Apply a cooldown to any potential edgescrolls |
| 204 | auto& core = Core::getInstance(); |
| 205 | static uint32_t last_action = 0; |
| 206 | uint32_t now = core.p->getTickCount(); |
| 207 | if (now < last_action + cooldown_ms) |
| 208 | return CR_OK; |
| 209 | |
| 210 | // Update mouse_x/y from values read in render thread callback |
| 211 | if (!update_mouse_pos()) |
| 212 | return CR_OK; // No new input to process |
| 213 | |
| 214 | if (state.xdiff == 0 && state.ydiff == 0) |
| 215 | return CR_OK; // No work to do |
| 216 | |
| 217 | // Ensure either a map viewscreen or the main viewport are visible |
| 218 | auto worldmap = get_map(); |
| 219 | if (!worldmap.has_value() && (!gps->main_viewport || !gps->main_viewport->flag.bits.active)) |
| 220 | return CR_OK; |
| 221 | |
| 222 | // Dispatch scrolling to active scrollables |
| 223 | if (worldmap.has_value()) |
| 224 | scroll_world(worldmap.value(), state.xdiff, state.ydiff); |
| 225 | else if (gps->main_viewport->flag.bits.active) |
| 226 | scroll_dwarfmode(state.xdiff, state.ydiff); |
| 227 | |
| 228 | // Update cooldown |
| 229 | last_action = now; |
| 230 | |
| 231 | return CR_OK; |
| 232 | } |
nothing calls this directly
no test coverage detected