Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Discord RPC dynamic off-by-one #2279

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -226,25 +226,30 @@ enum class DiscordStatus(private val displayMessageSupplier: (() -> String?)) {
DiscordRPCManager.config.customText.get() // custom field in the config
}),

AUTO({
var autoReturn = ""
for (statusID in DiscordRPCManager.config.autoPriority) { // for every dynamic that the user wants to see...
// TODO, change functionality to use enum rather than ordinals
val autoStatus = AutoStatus.entries[statusID.ordinal]
val result =
autoStatus.correspondingDiscordStatus.getDisplayString() // get what would happen if we were to display it
if (result != autoStatus.placeholderText) { // if that value is useful, display it
autoReturn = result
break
AUTO(
{
var autoReturn = ""
for (statusID in DiscordRPCManager.config.autoPriority) { // for every dynamic that the user wants to see...
// TODO, change functionality to use enum rather than ordinals
val autoStatus = AutoStatus.entries[statusID.ordinal]
val result =
autoStatus.correspondingDiscordStatus.getDisplayString() // get what would happen if we were to display it
if (result != autoStatus.placeholderText) { // if that value is useful, display it
autoReturn = result
break
}
}
}
if (autoReturn == "") { // if we didn't find any useful information, display the fallback
val statusNoAuto = DiscordStatus.entries.toMutableList()
statusNoAuto.remove(AUTO)
autoReturn = statusNoAuto[DiscordRPCManager.config.auto.get().ordinal].getDisplayString()
}
autoReturn
}),
if (autoReturn == "") { // if we didn't find any useful information, display the fallback
val fallbackID = DiscordRPCManager.config.auto.get().ordinal
autoReturn = if (fallbackID == 10) {
NONE.getDisplayString() // 10 is this (DiscordStatus.AUTO); prevents an infinite loop
} else {
DiscordStatus.entries[fallbackID].getDisplayString()
}
}
autoReturn
},
),

CROP_MILESTONES({ getCropMilestoneDisplay() }),

Expand Down
Loading