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

Improvement: Compact Farming Fortune Display #3119

Open
wants to merge 9 commits into
base: beta
Choose a base branch
from
3 changes: 3 additions & 0 deletions .devauth/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ defaultAccount = "main"
[accounts.main]
type = "microsoft"

[accounts.alt]
Chissl marked this conversation as resolved.
Show resolved Hide resolved
type = "microsoft"

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ public class FarmingFortuneConfig {
@FeatureToggle
public boolean display = false;

@Expose
@ConfigOption(name = "Compact Format", desc = "Compact the farming fortune display")
Chissl marked this conversation as resolved.
Show resolved Hide resolved
@ConfigEditorBoolean
public boolean compactFormat = false;

@Expose
@ConfigOption(name = "Hide Missing Fortune Warnings", desc = "Hide missing fortune warnings from the display")
Chissl marked this conversation as resolved.
Show resolved Hide resolved
@ConfigEditorBoolean
public boolean hideMissingFortuneWarnings = false;

@ConfigOption(name = "Farming Fortune Guide", desc = "Open a guide that breaks down your Farming Fortune.\n§eCommand: /ff")
@ConfigEditorButton(buttonText = "Open")
public Runnable open = FFGuideGUI::onCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ object FarmingFortuneDisplay {

var recentlySwitchedTool = lastToolSwitch.passedSince() < 1.5.seconds
val wrongTabCrop = GardenAPI.cropInHand != null && GardenAPI.cropInHand != currentCrop
val ffReduction = getPestFFReduction()

val farmingFortune = if (wrongTabCrop) {
(displayCrop.getLatestTrueFarmingFortune() ?: -1.0).also {
Expand All @@ -172,28 +173,42 @@ object FarmingFortuneDisplay {

list.add(
Renderable.string(
"§6Farming Fortune§7: §e" + if (!recentlySwitchedTool && farmingFortune != -1.0) {
farmingFortune.roundTo(0).addSeparators()
} else "§7" + (displayCrop.getLatestTrueFarmingFortune()?.addSeparators() ?: "?"),
(if (config.compactFormat) "§6FF§7: " else "§6Farming Fortune§7: ") + (if (ffReduction > 0) "§c" else "§e") +
Chissl marked this conversation as resolved.
Show resolved Hide resolved
if (!recentlySwitchedTool && farmingFortune != -1.0) {
farmingFortune.roundTo(0).addSeparators()
} else "§7" + (displayCrop.getLatestTrueFarmingFortune()?.addSeparators() ?: "?"),
),
)
add(Renderable.horizontalContainer(list))

val ffReduction = getPestFFReduction()
if (ffReduction > 0) {
add(Renderable.string("§cPests are reducing your fortune by §e$ffReduction%§c!"))
add(
Renderable.string(
if (config.compactFormat) "§cPests: §7-§e$ffReduction%"
else "§cPests are reducing your fortune by §e$ffReduction%§c!"
)
)
}

if (wrongTabCrop) {
var text = "§cBreak §e${GardenAPI.cropInHand?.cropName}§c to see"
if (farmingFortune != -1.0) text += " latest"
text += " fortune!"

if (wrongTabCrop && !config.hideMissingFortuneWarnings) {
var text = ""
Chissl marked this conversation as resolved.
Show resolved Hide resolved
if (config.compactFormat) {
text = "§cInaccurate!"
} else {
text = "§cBreak §e${GardenAPI.cropInHand?.cropName}§c to see"
if (farmingFortune != -1.0) text += " latest"
text += " fortune!"
}
add(Renderable.string(text))
}
}

private fun drawMissingFortuneDisplay(cropFortune: Boolean) = buildList {
if (config.hideMissingFortuneWarnings) return@buildList
if (config.compactFormat) {
add(Renderable.string("§cInaccurate!"))
return@buildList
}
if (cropFortune) {
add(
Renderable.clickAndHover(
Expand Down
Loading