diff options
author | HiZe_ <superhize@hotmail.com> | 2023-10-11 10:24:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-11 10:24:32 +0200 |
commit | 3fd0e2bf09c5de630df610786e2e4c58f8cccd24 (patch) | |
tree | 80ed7f268ba3ed5510a5806fd9f01e74897b5769 /src | |
parent | 2ed7f674d61e52f1bffddd5a99a630104fd29030 (diff) | |
download | skyhanni-3fd0e2bf09c5de630df610786e2e4c58f8cccd24.tar.gz skyhanni-3fd0e2bf09c5de630df610786e2e4c58f8cccd24.tar.bz2 skyhanni-3fd0e2bf09c5de630df610786e2e4c58f8cccd24.zip |
Update: Sack Display (#550)
Added button to change Price and Number format #550
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt | 6 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt | 34 |
2 files changed, 34 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 6ba933e40..64bebee7e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -84,8 +84,8 @@ object SackAPI { else null } - private fun NEUInternalName.sackPrice(stored: String): Long = when (sackDisplayConfig.priceFrom) { - 0 -> (getPrice(true) * stored.formatNumber()).toLong().let { if (it < 0) 0 else it } + private fun NEUInternalName.sackPrice(stored: String) = when (sackDisplayConfig.priceFrom) { + 0 -> (getPrice(true) * stored.formatNumber()).toLong().let { if (it < 0) 0L else it } 1 -> try { val npcPrice = getNpcPriceOrNull() ?: 0.0 @@ -94,7 +94,7 @@ object SackAPI { 0L } - else -> 0 + else -> 0L } fun getSacksData(savingSacks: Boolean) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt index 92c60bad5..0b8231879 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.LorenzUtils.addButton import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.getItemStack @@ -98,9 +99,15 @@ object SackDisplay { config.sortingType = it.ordinal update(false) }) - + newDisplay.addButton( + prefix = "§7Number format: ", + getName = NumberFormat.entries[config.numberFormat].DisplayName, + onChange = { + config.numberFormat = (config.numberFormat + 1) % 3 + update(false) + } + ) if (config.showPrice) { - newDisplay.addAsSingletonList("§cTotal price: §6${format(totalPrice)}") newDisplay.addSelector<PriceFrom>(" ", getName = { type -> type.displayName }, isCurrent = { it.ordinal == config.priceFrom }, @@ -108,6 +115,15 @@ object SackDisplay { config.priceFrom = it.ordinal update(false) }) + newDisplay.addButton( + prefix = "§7Price Format: ", + getName = PriceFormat.entries[config.priceFormat].displayName, + onChange = { + config.priceFormat = (config.priceFormat + 1) % 2 + update(false) + } + ) + newDisplay.addAsSingletonList("§cTotal price: §6${format(totalPrice)}") } } @@ -135,7 +151,7 @@ object SackDisplay { BazaarApi.searchForBazaarItem(name.dropLast(1)) }) { !NEUItems.neuHasFocus() }) add(" ($rough-§a$flawed-§9$fine-§5$flawless)") - val price = (roughprice + flawedprice + fineprice + flawlessprice) + val price = roughprice + flawedprice + fineprice + flawlessprice totalPrice += price if (config.showPrice && price != 0L) add(" §7(§6${format(price)}§7)") }) @@ -162,4 +178,16 @@ object SackDisplay { NPC("Npc Price"), ; } + + enum class PriceFormat(val displayName: String) { + FORMATED("Formatted"), + UNFORMATED("Unformatted") + ; + } + + enum class NumberFormat(val DisplayName: String) { + DEFAULT("Default"), + FORMATTED("Formatted"), + UNFORMATTED("Unformatted") + } }
\ No newline at end of file |