MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / onScrollMouseDown

Function onScrollMouseDown

src/OpenLoco/src/Ui/Windows/MusicSelection.cpp:312–338  ·  view source on GitHub ↗

0x004C1799

Source from the content-addressed store, hash-verified

310
311 // 0x004C1799
312 static void onScrollMouseDown(Ui::Window& window, [[maybe_unused]] int16_t x, int16_t y, [[maybe_unused]] uint8_t scroll_index)
313 {
314 const uint16_t currentRow = y / kRowHeight;
315 if (currentRow > window.rowCount)
316 {
317 return;
318 }
319 const Jukebox::MusicId currentTrack = playlist[currentRow];
320
321 auto& config = Config::get().audio;
322
323 // Toggle the track in question.
324 config.customJukebox[currentTrack] ^= true;
325
326 // Do not allow there being 0 tracks enabled
327 uint16_t numTracksSelected = std::ranges::count(config.customJukebox, true);
328 if (numTracksSelected == 0)
329 {
330 config.customJukebox[currentTrack] = true;
331 numTracksSelected = 1;
332 }
333
334 updateStatusBar(window, numTracksSelected);
335 Config::write();
336 Audio::revalidateCurrentTrack();
337 window.invalidate();
338 }
339
340 // 0x004C1771
341 static void onScrollMouseOver(Ui::Window& window, [[maybe_unused]] int16_t x, int16_t y, [[maybe_unused]] uint8_t scroll_index)

Callers

nothing calls this directly

Calls 6

countFunction · 0.85
updateStatusBarFunction · 0.85
writeFunction · 0.85
revalidateCurrentTrackFunction · 0.85
getFunction · 0.50
invalidateMethod · 0.45

Tested by

no test coverage detected