From 8b698e0a5eb590ee43b3eb7421563da7ce733300 Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Tue, 24 Dec 2024 15:19:58 -0600 Subject: [PATCH 1/7] add compact fortune display --- .devauth/config.toml | 3 +++ .../features/garden/FarmingFortuneConfig.java | 10 +++++++ .../features/garden/FarmingFortuneDisplay.kt | 27 +++++++++++++------ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.devauth/config.toml b/.devauth/config.toml index 1cb744bd4464..4bca64127f9d 100644 --- a/.devauth/config.toml +++ b/.devauth/config.toml @@ -4,3 +4,6 @@ defaultAccount = "main" [accounts.main] type = "microsoft" +[accounts.alt] +type = "microsoft" + diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java index a1cb92be0269..3242837b7fd4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java @@ -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; diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index 0dc6ce28cf15..b9745306068a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -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 { @@ -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( From cf7b2f460bb72177099b5d535abe2379a1389598 Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Tue, 24 Dec 2024 15:30:56 -0600 Subject: [PATCH 2/7] detekt --- .../features/garden/FarmingFortuneDisplay.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index b9745306068a..b4937a6a5059 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -174,16 +174,20 @@ object FarmingFortuneDisplay { list.add( Renderable.string( (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() ?: "?"), + if (!recentlySwitchedTool && farmingFortune != -1.0) { + farmingFortune.roundTo(0).addSeparators() + } else "§7" + (displayCrop.getLatestTrueFarmingFortune()?.addSeparators() ?: "?"), ), ) add(Renderable.horizontalContainer(list)) if (ffReduction > 0) { - add(Renderable.string(if (config.compactFormat) "§cPests: §7-§e$ffReduction%" - else "§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 && !config.hideMissingFortuneWarnings) { From 889a5d9141d9c60aa0c143b515a9f02efe0d05eb Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Tue, 24 Dec 2024 15:54:15 -0600 Subject: [PATCH 3/7] revert accidental devauth commit --- .devauth/config.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.devauth/config.toml b/.devauth/config.toml index 4bca64127f9d..993f064ed1cb 100644 --- a/.devauth/config.toml +++ b/.devauth/config.toml @@ -3,7 +3,3 @@ defaultAccount = "main" [accounts.main] type = "microsoft" - -[accounts.alt] -type = "microsoft" - From 3422f633ba4e3a5d7a0261259a7e0296349e3a0f Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Tue, 24 Dec 2024 15:55:05 -0600 Subject: [PATCH 4/7] revert accidental devauth commit --- .devauth/config.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/.devauth/config.toml b/.devauth/config.toml index 993f064ed1cb..1cb744bd4464 100644 --- a/.devauth/config.toml +++ b/.devauth/config.toml @@ -3,3 +3,4 @@ defaultAccount = "main" [accounts.main] type = "microsoft" + From b41765b262085e20480e1551b8806c60f825faaa Mon Sep 17 00:00:00 2001 From: Chissl <78828070+Chissl@users.noreply.github.com> Date: Tue, 24 Dec 2024 16:19:25 -0600 Subject: [PATCH 5/7] Update src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- .../skyhanni/config/features/garden/FarmingFortuneConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java index 3242837b7fd4..1c2f41e19e89 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java @@ -20,7 +20,7 @@ public class FarmingFortuneConfig { public boolean display = false; @Expose - @ConfigOption(name = "Compact Format", desc = "Compact the farming fortune display") + @ConfigOption(name = "Compact Format", desc = "Compact the farming fortune display.") @ConfigEditorBoolean public boolean compactFormat = false; From f9df650ae2b52d9cbb85d072d42fba9a1f71f250 Mon Sep 17 00:00:00 2001 From: Chissl <78828070+Chissl@users.noreply.github.com> Date: Tue, 24 Dec 2024 16:19:43 -0600 Subject: [PATCH 6/7] Update src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- .../skyhanni/config/features/garden/FarmingFortuneConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java index 1c2f41e19e89..1a31b2a11ba6 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java @@ -25,7 +25,7 @@ public class FarmingFortuneConfig { public boolean compactFormat = false; @Expose - @ConfigOption(name = "Hide Missing Fortune Warnings", desc = "Hide missing fortune warnings from the display") + @ConfigOption(name = "Hide Missing Fortune Warnings", desc = "Hide missing fortune warnings from the display.") @ConfigEditorBoolean public boolean hideMissingFortuneWarnings = false; From bd97b494df1722c21a6284344267c4fe7d81aac8 Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Tue, 24 Dec 2024 17:03:56 -0600 Subject: [PATCH 7/7] improved readability --- .../features/garden/FarmingFortuneDisplay.kt | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index b4937a6a5059..68eccc6cf405 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -171,14 +171,14 @@ object FarmingFortuneDisplay { } } else getCurrentFarmingFortune() - list.add( - Renderable.string( - (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() ?: "?"), - ), - ) + val farmingFortuneText = if (config.compactFormat) "§6FF§7: " else "§6Farming Fortune§7: " + val fortuneColorCode = if (ffReduction > 0) "§c" else "§e" + val fortuneAmount = if (!recentlySwitchedTool && farmingFortune != -1.0) { + farmingFortune.roundTo(0).addSeparators() + } else "§7" + (displayCrop.getLatestTrueFarmingFortune()?.addSeparators() ?: "?") + + list.add(Renderable.string(farmingFortuneText + fortuneColorCode + fortuneAmount)) + add(Renderable.horizontalContainer(list)) if (ffReduction > 0) { @@ -191,13 +191,12 @@ object FarmingFortuneDisplay { } 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!" + val latest = if (farmingFortune != -1.0) " latest" else "" + val text = when { + config.compactFormat -> "§cInaccurate!" + else -> { + "§cBreak §e${GardenAPI.cropInHand?.cropName}§c to see" + latest + " fortune!" + } } add(Renderable.string(text)) }