From 586c43fd6c0f785fbeb41439f5b20682f06b0779 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 4 Nov 2023 13:39:08 +0300 Subject: [PATCH] hud text scale + reorganize client config --- .../mc/otm/client/ClientEventHandler.kt | 4 +- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 8 +- .../mc/otm/client/screen/MatteryScreen.kt | 2 +- .../client/screen/panels/button/Buttons.kt | 6 +- .../dbotthepony/mc/otm/config/ClientConfig.kt | 81 ++++++++++++++----- .../mc/otm/matter/MatterManager.kt | 4 +- 6 files changed, 73 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index b6d324cfa..66b76fa4a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -229,7 +229,7 @@ fun onMouseScrolled(event: MouseScrolled.Pre) { return } - if (ClientConfig.EXOPACK_FREE_SCROLL && widget.panel is InventoryScrollbarPanel) { + if (ClientConfig.GUI.EXOPACK_FREE_SCROLL && widget.panel is InventoryScrollbarPanel) { val slot = screen.slotUnderMouse if (slot != null && (slot.container == minecraft.player?.inventory && slot.containerSlot in 9 .. 35 || slot.container == minecraft.player?.matteryPlayer?.exopackContainer)) { @@ -266,7 +266,7 @@ private val TOOLTIP_TAG_DISPLAY_ITEM_TITLE = TranslatableComponent("otm.gui.debu private val TOOLTIP_TAG_DISPLAY_BLOCK_TITLE = TranslatableComponent("otm.gui.debug.tags.block.title").withStyle(ChatFormatting.DARK_GRAY) fun tooltipEvent(event: ItemTooltipEvent) { - if (event.flags.isAdvanced && ClientConfig.TOOLTIP_DISPLAY_TAGS && !event.itemStack.isEmpty) { + if (event.flags.isAdvanced && ClientConfig.Tooltip.DISPLAY_TAGS && !event.itemStack.isEmpty) { val itemTags = ArrayList>() if (event.itemStack.tags.count() > 0) { itemTags.addAll(event.itemStack.tags) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index fae1fea3f..16d14743d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -262,7 +262,8 @@ object MatteryGUI { val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() - event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 1f, top + CHARGE_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) + val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() + event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 2f + scale, top + CHARGE_BG.height / 2f + scale, scale = scale, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) } } @@ -291,7 +292,7 @@ object MatteryGUI { } // можно вынести в конфиг, но для этого нужен селектор цвета private fun renderPlayerHealth(event: RenderGuiOverlayEvent.Pre, gui: ForgeGui) { - if (!ClientConfig.ANDROID_HEALTH_HUD) return + if (!ClientConfig.HUD.ANDROID_HEALTH_BAR) return val ply: LocalPlayer = minecraft.player ?: return var mattery = ply.matteryPlayer @@ -338,7 +339,8 @@ object MatteryGUI { if (ply.absorptionAmount > 0) formattedHealth = TextComponent("%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt())) - event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) + val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() + event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f + 1f * scale, scale = scale, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt index 3105d5426..67f24f1b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt @@ -747,6 +747,6 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit const val MAX_ROWS = 6 var lastScroll = 0 - var lastRows by ClientConfig::EXOPACK_INVENTORY_ROWS + var lastRows by ClientConfig.GUI::EXOPACK_INVENTORY_ROWS } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt index 298603b00..69b871904 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt @@ -65,9 +65,9 @@ private fun > makeRedstoneSettingButton( set(value) {} init { - add(RedstoneSetting.IGNORED, tooltip = RedstoneSetting.IGNORED.description, skinElement = if (ClientConfig.REDSTONE_CONTROLS_ITEM_ICONS) gunpowder else Widgets18.REDSTONE_IGNORED) - add(RedstoneSetting.LOW, tooltip = RedstoneSetting.LOW.description, skinElement = if (ClientConfig.REDSTONE_CONTROLS_ITEM_ICONS) redstoneUnderBarrier else Widgets18.REDSTONE_LOW) - add(RedstoneSetting.HIGH, tooltip = RedstoneSetting.HIGH.description, skinElement = if (ClientConfig.REDSTONE_CONTROLS_ITEM_ICONS) redstone else Widgets18.REDSTONE_HIGH) + add(RedstoneSetting.IGNORED, tooltip = RedstoneSetting.IGNORED.description, skinElement = if (ClientConfig.GUI.REDSTONE_CONTROLS_ITEM_ICONS) gunpowder else Widgets18.REDSTONE_IGNORED) + add(RedstoneSetting.LOW, tooltip = RedstoneSetting.LOW.description, skinElement = if (ClientConfig.GUI.REDSTONE_CONTROLS_ITEM_ICONS) redstoneUnderBarrier else Widgets18.REDSTONE_LOW) + add(RedstoneSetting.HIGH, tooltip = RedstoneSetting.HIGH.description, skinElement = if (ClientConfig.GUI.REDSTONE_CONTROLS_ITEM_ICONS) redstone else Widgets18.REDSTONE_HIGH) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt index 64b1f5e91..d4ce32b41 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt @@ -1,35 +1,74 @@ package ru.dbotthepony.mc.otm.config -import net.minecraftforge.common.ForgeConfigSpec -import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.config.ModConfig object ClientConfig : AbstractConfig("client", ModConfig.Type.CLIENT) { - var ALWAYS_DISPLAY_MATTER_VALUE: Boolean by builder - .define("ALWAYS_DISPLAY_MATTER_VALUE", false) - - var EXOPACK_INVENTORY_ROWS: Int by builder - .comment("Amount of inventory rows to show when wearing Exosuit") - .defineInRange("EXOPACK_INVENTORY_ROWS", 3, 3, 6) var JUMP_BOOST_LOOK_ANGLE: Double by builder .comment("If looking below this angle (actually, looking 'above' as you see in game, but not as you expect it, check with debug screen), Crouch + Jump will trigger jump boost android ability") .defineInRange("JUMP_BOOST_LOOK_ANGLE", 30.0, -180.0, 180.0) - var EXOPACK_FREE_SCROLL: Boolean by builder - .comment("Allow to scroll Exopack inventory in non OTM inventories when hovering just over inventory slots, not only scrollbar") - .define("EXOPACK_FREE_SCROLL", true) + object Tooltip { + init { + builder.push("Tooltip") + } - var ANDROID_HEALTH_HUD: Boolean by builder - .comment("Replace hearts with health bar on HUD when you are an android") - .define("ANDROID_HEALTH_HUD", true) + var ALWAYS_DISPLAY_MATTER_VALUE: Boolean by builder + .comment("Always display matter value in tooltips without requiring holding Shift key") + .define("ALWAYS_DISPLAY_MATTER_VALUE", false) - var REDSTONE_CONTROLS_ITEM_ICONS: Boolean by builder - .comment("Display redstone control button using items instead of custom sprites") - .comment("For those who want it.") - .define("REDSTONE_CONTROLS_ITEM_ICONS", false) + var DISPLAY_TAGS: Boolean by builder + .comment("Display block/item tags in advanced item tooltips") + .define("DISPLAY_TAGS", false) - var TOOLTIP_DISPLAY_TAGS: Boolean by builder - .comment("Display block/item tags in advanced item tooltips") - .define("TOOLTIP_DISPLAY_TAGS", false) + init { + builder.pop() + } + } + + object GUI { + init { + builder.comment("Inventory/GUI options").push("Gui") + } + + var EXOPACK_INVENTORY_ROWS: Int by builder + .comment("Amount of inventory rows to show when wearing Exosuit") + .defineInRange("EXOPACK_INVENTORY_ROWS", 3, 3, 6) + + var EXOPACK_FREE_SCROLL: Boolean by builder + .comment("Allow to scroll Exopack inventory in non OTM inventories when hovering just over inventory slots, not only scrollbar") + .define("EXOPACK_FREE_SCROLL", true) + + var REDSTONE_CONTROLS_ITEM_ICONS: Boolean by builder + .comment("Display redstone control button using items instead of custom sprites") + .comment("For those who want it.") + .define("REDSTONE_CONTROLS_ITEM_ICONS", false) + + init { + builder.pop() + } + } + + object HUD { + init { + builder.push("HUD") + } + + var ANDROID_HEALTH_BAR: Boolean by builder + .comment("Replace hearts with health bar on HUD when you are an android") + .define("ANDROID_HEALTH_BAR", true) + + var BAR_TEXT_SCALE: Double by builder + .defineInRange("BAR_TEXT_SCALE", 0.5, 0.5, 1.0) + + init { + builder.pop() + } + } + + init { + Tooltip + GUI + HUD + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 1c55d6324..097f8d008 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -1345,10 +1345,10 @@ object MatterManager { return getResearchAdvance(this@MatterManager.get(stack.asItem()).complexity) } - private val formatMatterAsReadable = BooleanSupplier { if (ClientConfig.ALWAYS_DISPLAY_MATTER_VALUE) minecraft.window.isShiftDown else minecraft.window.isShiftDown && milliTime % 2_000L > 1_000L } + private val formatMatterAsReadable = BooleanSupplier { if (ClientConfig.Tooltip.ALWAYS_DISPLAY_MATTER_VALUE) minecraft.window.isShiftDown else minecraft.window.isShiftDown && milliTime % 2_000L > 1_000L } fun tooltipEvent(event: ItemTooltipEvent) { - if (ClientConfig.ALWAYS_DISPLAY_MATTER_VALUE || minecraft.window.isShiftDown) { + if (ClientConfig.Tooltip.ALWAYS_DISPLAY_MATTER_VALUE || minecraft.window.isShiftDown) { val matter = get(event.itemStack, accountForStackSize = false) if (matter.hasMatterValue) {