Skip to content

Commit

Permalink
add compact fortune display
Browse files Browse the repository at this point in the history
  • Loading branch information
Chissl committed Dec 24, 2024
1 parent e1e0deb commit 8b698e0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
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]
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")
@ConfigEditorBoolean
public boolean compactFormat = false;

@Expose
@ConfigOption(name = "Hide Missing Fortune Warnings", desc = "Hide missing fortune warnings from the display")
@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,38 @@ object FarmingFortuneDisplay {

list.add(
Renderable.string(
"§6Farming Fortune§7: §e" + if (!recentlySwitchedTool && farmingFortune != -1.0) {
(if (config.compactFormat) "§6FF§7: " else "§6Farming Fortune§7: ") + (if (ffReduction > 0) "§c" else "§e") +
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 = ""
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

0 comments on commit 8b698e0

Please sign in to comment.