From 18b89b4031a70dedbed51f86d301b3ed8151b2b1 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 4 Mar 2025 22:31:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=95=D0=A2=20=D0=9D=D0=A3=20=D0=95?= =?UTF-8?q?=D0=A1=D0=9B=D0=98=20=D0=A2=D0=95=D0=9F=D0=95=D0=A0=D0=AC=20?= =?UTF-8?q?=D0=A3=20=D0=9D=D0=90=D0=A1=20=D0=95=D0=A1=D0=A2=D0=AC=20=D0=A2?= =?UTF-8?q?=D0=90=D0=9A=D0=9E=D0=99=20=D0=A8=D0=A0=D0=98=D0=A4=D0=A2=20?= =?UTF-8?q?=D0=A2=D0=9E=20=D0=AF=20=D0=91=D0=A3=D0=94=D0=A3=20=D0=95=D0=93?= =?UTF-8?q?=D0=9E=20=D0=90=D0=91=D0=A3=D0=97=D0=98=D0=A2=D0=AC=20=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=8B=20=D0=BC=D0=BD=D0=B5=20=D0=BD=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=BD=D0=B5=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=D0=B5=20=D0=BF=D0=BE=D0=BD=D1=8F=D1=82=D0=BD=D0=BE?= =?UTF-8?q?=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/dbotthepony/mc/otm/datagen/lang/English.kt | 4 ++++ .../ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 4 ++++ .../block/entity/decorative/HoloSignBlockEntity.kt | 6 ++++++ .../ru/dbotthepony/mc/otm/client/MatteryGUI.kt | 9 +++++---- .../client/render/blockentity/HoloSignRenderer.kt | 6 +++++- .../otm/client/screen/decorative/HoloSignScreen.kt | 12 ++++++++++++ .../mc/otm/menu/decorative/HoloSignMenu.kt | 3 +++ 7 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index d06fb62f0..b7797fb52 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -192,6 +192,10 @@ private fun misc(provider: MatteryLanguageProvider) { gui("holo_screen.resize_text", "Resize text automatically") gui("holo_screen.do_not_resize_text", "Do not resize text") + gui("abc", "ABC") + gui("use_standard_font", "Use standard font") + gui("use_small_font", "Use small font") + gui("ticks", "Ticks") gui("power_cost_per_use", "Power cost per use: %s") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 77d971421..0efb16145 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -202,6 +202,10 @@ private fun misc(provider: MatteryLanguageProvider) { gui("holo_screen.resize_text", "Изменять размер текста автоматически") gui("holo_screen.do_not_resize_text", "Не менять размер текста") + gui("abc", "АБВ") + gui("use_standard_font", "Использовать стандартный шрифт") + gui("use_small_font", "Использовать уменьшенный шрифт") + gui("ticks", "Тиков") gui("power_cost_per_use", "Энергии на операцию: %s") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index 02062bea9..748ec5811 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -61,6 +61,11 @@ class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryB access.accept(value) }).delegate + var smallerFont by syncher.boolean(false, setter = { access, value -> + setChanged() + access.accept(value) + }).delegate + var isLocked = false init { @@ -74,6 +79,7 @@ class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryB savetablesConfig.float(::textAlpha) savetablesConfig.bool(::textAutoScale) + savetablesConfig.bool(::smallerFont) } override fun createMenu(p_39954_: Int, p_39955_: Inventory, p_39956_: Player): AbstractContainerMenu { 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 b7f561691..ddc917ee3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -113,8 +113,9 @@ object MatteryGUI { event.registerAbove(VanillaGuiLayers.CAMERA_OVERLAYS, loc("android_low_power"), AndroidLowPowerLayer()) } - private val SMALL_FONT = loc("small") - private val SMALL_FONT_STYLE = Style.EMPTY.withFont(SMALL_FONT) + val SMALL_FONT = loc("small") + val SMALL_FONT_STYLE: Style = Style.EMPTY.withFont(SMALL_FONT) + val STANDARD_FONT_STYLE: Style = Style.EMPTY class AndroidEnergyBarLayer : LayeredDraw.Layer { override fun render( @@ -168,7 +169,7 @@ object MatteryGUI { val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() val scale = if (ClientConfig.HUD.USE_SMALL_FONT) 1f else ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() - guiGraphics.draw(formattedPower.withStyle(if (ClientConfig.HUD.USE_SMALL_FONT) SMALL_FONT_STYLE else Style.EMPTY), left + CHARGE_BG.width + 2f + scale, top + CHARGE_BG.height / 2f + scale, font = gui.font, scale = scale, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.FULL_POWER, drawOutline = true) + guiGraphics.draw(formattedPower.withStyle(if (ClientConfig.HUD.USE_SMALL_FONT) SMALL_FONT_STYLE else STANDARD_FONT_STYLE), left + CHARGE_BG.width + 2f + scale, top + CHARGE_BG.height / 2f + scale, font = gui.font, scale = scale, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.FULL_POWER, drawOutline = true) RenderSystem.disableBlend() RenderSystem.enableDepthTest() @@ -234,7 +235,7 @@ object MatteryGUI { formattedHealth = TextComponent("%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt())) val scale = if (ClientConfig.HUD.USE_SMALL_FONT) 1f else ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() - guiGraphics.draw(formattedHealth.withStyle(if (ClientConfig.HUD.USE_SMALL_FONT) SMALL_FONT_STYLE else Style.EMPTY), left - 2f, top + HEALTH_BG.height / 2f + 1f * scale, scale = scale, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) + guiGraphics.draw(formattedHealth.withStyle(if (ClientConfig.HUD.USE_SMALL_FONT) SMALL_FONT_STYLE else STANDARD_FONT_STYLE), left - 2f, top + HEALTH_BG.height / 2f + 1f * scale, scale = scale, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) RenderSystem.disableBlend() RenderSystem.enableDepthTest() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt index 7f343934b..9a242dac8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt @@ -12,6 +12,9 @@ import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.kommons.math.RGBAColor +import ru.dbotthepony.mc.otm.client.MatteryGUI.SMALL_FONT_STYLE +import ru.dbotthepony.mc.otm.client.MatteryGUI.STANDARD_FONT_STYLE +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.rotateWithBlockFacing class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { @@ -42,8 +45,9 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) poseStack.scale(mul, mul, mul) } + val style = if (tile.smallerFont) SMALL_FONT_STYLE else STANDARD_FONT_STYLE for (line in lines) { - font.draw(poseStack = poseStack, buffer = bufferSource, text = line, gravity = RenderGravity.TOP_CENTER, y = y, color = RGBAColor(tile.textRed, tile.textGreen, tile.textBlue, tile.textAlpha)) + font.draw(poseStack = poseStack, buffer = bufferSource, text = TextComponent(line).withStyle(style), gravity = RenderGravity.TOP_CENTER, y = y, color = RGBAColor(tile.textRed, tile.textGreen, tile.textBlue, tile.textAlpha)) y += font.lineHeight + 2f } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index 95d1b597c..f82987077 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -11,6 +11,8 @@ import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkedStringInputPane import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.kommons.math.RGBAColor import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity +import ru.dbotthepony.mc.otm.client.MatteryGUI.SMALL_FONT_STYLE +import ru.dbotthepony.mc.otm.client.render.TextIcon import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.button.BooleanButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel @@ -84,6 +86,16 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) tooltipInactive = TranslatableComponent("otm.gui.lock_holo_screen.unlocked") )) + controls.addButton(BooleanButtonPanel.square18( + this@HoloSignScreen, + frame, + prop = menu.smallerFont, + iconActive = TextIcon(font = font, text = TranslatableComponent("otm.gui.abc").withStyle(SMALL_FONT_STYLE)), + iconInactive = TextIcon(font = font, text = TranslatableComponent("otm.gui.abc")), + tooltipActive = TranslatableComponent("otm.gui.use_small_font"), + tooltipInactive = TranslatableComponent("otm.gui.use_standard_font") + )) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt index d2c598c48..d31698c3b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt @@ -24,6 +24,7 @@ class HoloSignMenu( val textBlue = FloatInputWithFeedback(this) val textAlpha = FloatInputWithFeedback(this) val textAutoScale = BooleanInputWithFeedback(this) + val smallerFont = BooleanInputWithFeedback(this) init { text.filter { it.isCreative || !locked.value } @@ -36,6 +37,7 @@ class HoloSignMenu( textAlpha.filter { it.isCreative || !locked.value } textAutoScale.filter { it.isCreative || !locked.value } + smallerFont.filter { it.isCreative || !locked.value } if (tile != null) { text.withConsumer { tile.signText = HoloSignBlockEntity.truncate(it, tile.isLocked) }.withSupplier(tile::signText) @@ -46,6 +48,7 @@ class HoloSignMenu( locked.with(tile::isLocked) redstone.with(tile.redstoneControl::redstoneSetting) textAutoScale.with(tile::textAutoScale) + smallerFont.with(tile::smallerFont) } } }