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..999062414 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 @@ -4,6 +4,7 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider +import net.minecraft.network.chat.MutableComponent import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.client.font import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource @@ -12,6 +13,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 { @@ -31,7 +35,8 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) poseStack.translate(0.5f, 0.5f, 0.75f) poseStack.scale(0.01f, 0.01f, 0.01f) - val lines = tile.signText.split('\n') + val style = if (tile.smallerFont) SMALL_FONT_STYLE else STANDARD_FONT_STYLE + val lines: List = tile.signText.split('\n').map { TextComponent(it).withStyle(style) } val totalHeight = lines.size * font.lineHeight + (lines.size - 1) * 2f var y = -totalHeight / 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) } } } diff --git a/src/main/resources/assets/overdrive_that_matters/font/small.json b/src/main/resources/assets/overdrive_that_matters/font/small.json index 612ba26a3..30391944b 100644 --- a/src/main/resources/assets/overdrive_that_matters/font/small.json +++ b/src/main/resources/assets/overdrive_that_matters/font/small.json @@ -15,7 +15,7 @@ "\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u004a\u004b\u004c\u004d\u004e\u004f", "\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005a\u005b\u005c\u005d\u005e\u005f", "\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u006a\u006b\u006c\u006d\u006e\u006f", - "\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007a\u007b\u007c\u007d\u007e\u0000", + "\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007a\u007b\u007c\u007d\u007e\u221E", "\u0410\u0411\u0412\u0413\u0414\u0415\u0401\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E", "\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E", "\u042F\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000", diff --git a/src/main/resources/assets/overdrive_that_matters/textures/font/small.pdn b/src/main/resources/assets/overdrive_that_matters/textures/font/small.pdn index 60ffb2a2e..25f26b09c 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/font/small.pdn and b/src/main/resources/assets/overdrive_that_matters/textures/font/small.pdn differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/font/small.png b/src/main/resources/assets/overdrive_that_matters/textures/font/small.png index 911701955..09171906e 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/font/small.png and b/src/main/resources/assets/overdrive_that_matters/textures/font/small.png differ