Skip to content

Commit 2213dc3

Browse files
committed
new setting
1 parent 03d7b77 commit 2213dc3

File tree

6 files changed

+44
-7
lines changed

6 files changed

+44
-7
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*<c-aaaaaa>Friendly reminder that</c> <cl>some</c> <cj>features</c> <c-aaaaaa>of this mod (including features from this update and features related to bugfixes in this update) require [Better Touch Prio](mod:alk.better-touch-prio) to be installed. These decisions are still here to stay.</c>*
44
- <cg>Added</c> playback increment/decrement controls.
55
- You can toggle this option off in the mod settings.
6+
- You can also adjust how many milliseconds to increment/decrement by in the mod settings.
67
- [Better Touch Prio](mod:alk.better-touch-prio) is <cl>requ</c><cj>ired</c> for this feature.
78
- <co>Fixed</c> an issue where menu loop positions wouldn't be restored when leaving a level whose most recently played song was also the most recently selected menu loop.
89
## v1.11.3, v1.11.4, and v1.11.5

mod.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,24 @@
301301
"default": true,
302302
"enable-if": "loaded:alk.better-touch-prio"
303303
},
304+
"incrementDecrementByMilliseconds": {
305+
"name": "Control Panel: Playback Progress Controls Forward/Backward Amount (MS)",
306+
"description": "<c-ff0000>***__IF THE \"BETTER TOUCH PRIO\" MOD BY UNDEFINED0 + ALK1M123 IS NOT INSTALLED, THIS SETTING IS IGNORED.__***</c>\n\nChoose how many milliseconds to go forward/backward in when using the playback progress controls in the Control Panel.\n\n<cy>If</c> <cl>Constant Shuffle Mode</c> <c-aaaaaa>(formerly known as Playlist Mode)</c> <cy>is enabled, going past the end of the current song will shuffle a new song, and going backwards will be capped to the very start of the song.</c>\n\nOtherwise, going too far past the end or the beginning of the current song will wrap around from the opposite end of the song.",
307+
"type": "int",
308+
"default": 5000,
309+
"min": 100,
310+
"max": 30000,
311+
"control": {
312+
"input": true,
313+
"slider": true,
314+
"arrows": true,
315+
"big-arrows": true,
316+
"arrow-step": 500,
317+
"big-arrow-step": 1000,
318+
"slider-step": 100
319+
},
320+
"enable-if": "loaded:alk.better-touch-prio"
321+
},
304322
"specificSongOverride": {
305323
"name": "Specific Menu Loop File Override",
306324
"description": "In case you *hate* the randomizer elements from this mod.\n\n<cy>Leave this as blank to disable this option.</c>",

src/SongManager.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,12 @@ void SongManager::setFinishedCalculatingSongLengths(const bool value) {
323323

324324
bool SongManager::getFinishedCalculatingSongLengths() const {
325325
return m_finishedCalculatingSongLengths;
326+
}
327+
328+
void SongManager::setIncrementDecrementByMilliseconds(const int value) {
329+
m_incrementDecrementByMilliseconds = std::clamp<int>(value, 100, 30000);
330+
}
331+
332+
int SongManager::getIncrementDecrementByMilliseconds() const {
333+
return m_incrementDecrementByMilliseconds;
326334
}

src/SongManager.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class SongManager {
9898
bool getShowPlaybackProgressAndControls() const;
9999
void setFinishedCalculatingSongLengths(const bool);
100100
bool getFinishedCalculatingSongLengths() const;
101+
void setIncrementDecrementByMilliseconds(const int);
102+
int getIncrementDecrementByMilliseconds() const;
101103

102104
private:
103105
SongManager();
@@ -124,9 +126,10 @@ class SongManager {
124126
bool m_comingFromGJBGL = false;
125127
bool m_showPlaybackProgressAndControls = false;
126128
int m_lastPosition = 0;
129+
int m_towerRepeatCount = 0;
130+
int m_incrementDecrementByMilliseconds = 0;
127131
std::vector<std::string> m_blacklist {};
128132
std::vector<std::string> m_favorites {};
129-
int m_towerRepeatCount = 0;
130133
geode::Mod* m_colonMenuLoopStartTime {};
131134
SongToSongData m_songToSongDataMap {};
132135
bool m_finishedCalculatingSongLengths = false;

src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ bool originalOverrideWasEmpty = false;
2222
songManager.setFinishedCalculatingSongLengths(false);
2323
songManager.setAdvancedLogs(Mod::get()->getSettingValue<bool>("advancedLogs"));
2424
songManager.setShowPlaybackProgressAndControls(Mod::get()->getSettingValue<bool>("showPlaybackProgressAndControls"));
25+
songManager.setIncrementDecrementByMilliseconds(Mod::get()->getSettingValue<int64_t>("incrementDecrementByMilliseconds"));
2526
songManager.setVibecodedVentilla(VIBECODED_RADIO && (VIBECODED_RADIO->isEnabled() || VIBECODED_RADIO->shouldLoad()));
2627
songManager.setUndefined0Alk1m123TouchPrio(BTP && (BTP->isEnabled() || BTP->shouldLoad()) && !BTP->hasUnresolvedDependencies() && !BTP->hasUnresolvedIncompatibilities());
2728
if (!std::filesystem::exists(configDir / "playlistOne.txt")) Utils::writeToFile("# This file was generated automatically as it hadn't existed previously.", configDir / "playlistOne.txt");
@@ -200,6 +201,11 @@ bool originalOverrideWasEmpty = false;
200201
if (SongManager::get().getUndefined0Alk1m123TouchPrio() || !showPlaybackProgressAndControls) return;
201202
Utils::showMDPopup("Control Panel Playback Progress Controls", USE_BETTER_TOUCH_PRIO_DAMMIT, 20260105, "show-playback-progress-controls");
202203
});
204+
listenForSettingChanges<int64_t>("incrementDecrementByMilliseconds", [](const int64_t incrementDecrementByMilliseconds) {
205+
SongManager::get().setIncrementDecrementByMilliseconds(incrementDecrementByMilliseconds);
206+
if (SongManager::get().getUndefined0Alk1m123TouchPrio()) return;
207+
Utils::showMDPopup("Control Panel Playback Progress Controls", USE_BETTER_TOUCH_PRIO_DAMMIT, 20260105, "playback-progress-incrdecr-amt");
208+
});
203209
listenForSettingChanges<bool>("advancedLogs", [](const bool newAdvancedLogs) {
204210
SongManager::get().setAdvancedLogs(newAdvancedLogs);
205211
});

src/ui/SongControlMenu.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define REST_OF_THE_OWL this->m_songControlsMenu, this
88
#define DEFAULT_FOOTER_TEXT fmt::format("Hi! Menu Loop Randomizer will never resemble Spotify or its distant cousin EditorMusic. Please respect that. :) [Platform: {}]", Utils::getPlatform())
99
#define CAN_USE_PLAYBACK_CONTROLS (songManager.getFinishedCalculatingSongLengths() && songManager.getUndefined0Alk1m123TouchPrio() && songManager.getShowPlaybackProgressAndControls())
10+
#define INCREMENT_DECREMENT_AMOUNT songManager.getIncrementDecrementByMilliseconds()
1011

1112
bool SongControlMenu::setup() {
1213
this->setTitle("Menu Loop Randomizer - Control Panel");
@@ -357,18 +358,18 @@ void SongControlMenu::onSkipBkwdButton(CCObject*) {
357358
const int fullLength = songManager.getSongToSongDataEntries().find(songManager.getCurrentSong())->second.songLength;
358359
const int lastPosition = songManager.getLastMenuLoopPosition();
359360

360-
if ((lastPosition - 5000) < 0) {
361+
if ((lastPosition - INCREMENT_DECREMENT_AMOUNT) < 0) {
361362
if (songManager.getConstantShuffleMode()) {
362363
fmod->getActiveMusicChannel(0)->setPosition(0, FMOD_TIMEUNIT_MS);
363364
} else if (fullLength > 0 && fullLength < std::numeric_limits<unsigned int>::max()) {
364-
const int newPosition = ((((lastPosition % fullLength) + fullLength) % fullLength) - (5000 % fullLength) + fullLength) % fullLength;
365+
const int newPosition = ((((lastPosition % fullLength) + fullLength) % fullLength) - (INCREMENT_DECREMENT_AMOUNT % fullLength) + fullLength) % fullLength;
365366
songManager.setPauseSongPositionTracking(true);
366367
fmod->getActiveMusicChannel(0)->setPosition(newPosition, FMOD_TIMEUNIT_MS);
367368
songManager.setLastMenuLoopPosition(newPosition);
368369
songManager.setPauseSongPositionTracking(false);
369370
}
370371
} else {
371-
fmod->getActiveMusicChannel(0)->setPosition(lastPosition - 5000, FMOD_TIMEUNIT_MS);
372+
fmod->getActiveMusicChannel(0)->setPosition(lastPosition - INCREMENT_DECREMENT_AMOUNT, FMOD_TIMEUNIT_MS);
372373
}
373374
}
374375

@@ -383,19 +384,19 @@ void SongControlMenu::onSkipFwrdButton(CCObject*) {
383384
const int fullLength = songManager.getSongToSongDataEntries().find(songManager.getCurrentSong())->second.songLength;
384385
const int lastPosition = songManager.getLastMenuLoopPosition();
385386

386-
if ((lastPosition + 5000) > fullLength) {
387+
if ((lastPosition + INCREMENT_DECREMENT_AMOUNT) > fullLength) {
387388
if (songManager.getConstantShuffleMode()) {
388389
SongControl::shuffleSong();
389390
SongControlMenu::updateCurrentLabel();
390391
} else if (fullLength > 0 && fullLength < std::numeric_limits<unsigned int>::max()) {
391-
const int newPosition = ((((lastPosition % fullLength) + fullLength) % fullLength) + (5000 % fullLength)) % fullLength;
392+
const int newPosition = ((((lastPosition % fullLength) + fullLength) % fullLength) + (INCREMENT_DECREMENT_AMOUNT % fullLength)) % fullLength;
392393
songManager.setPauseSongPositionTracking(true);
393394
fmod->getActiveMusicChannel(0)->setPosition(newPosition, FMOD_TIMEUNIT_MS);
394395
songManager.setLastMenuLoopPosition(newPosition);
395396
songManager.setPauseSongPositionTracking(false);
396397
}
397398
} else {
398-
fmod->getActiveMusicChannel(0)->setPosition(lastPosition + 5000, FMOD_TIMEUNIT_MS);
399+
fmod->getActiveMusicChannel(0)->setPosition(lastPosition + INCREMENT_DECREMENT_AMOUNT, FMOD_TIMEUNIT_MS);
399400
}
400401
}
401402

0 commit comments

Comments
 (0)