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 34a356892..5ab2a9764 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 @@ -56,6 +56,11 @@ class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryB var textBlue by syncher.float(85f / 255f, setter = ::colorSetter).delegate var textAlpha by syncher.float(1f).delegate + var textAutoScale by syncher.boolean(true, setter = { access, value -> + setChanged() + access.accept(value) + }).delegate + var isLocked = false init { @@ -67,6 +72,8 @@ class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryB savetables.float(::textGreen) savetables.float(::textBlue) savetables.float(::textAlpha) + + savetables.bool(::textAutoScale) } override fun createMenu(p_39954_: Int, p_39955_: Inventory, p_39956_: Player): AbstractContainerMenu { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 4454efe37..d8ef39b0a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -176,4 +176,8 @@ object Widgets18 { } val UPGRADES = controlsGrid.next() + + val COLOR_PALETTE = controlsGrid.next() + val TEXT_SCALE_DISABLED = controlsGrid.next() + val TEXT_SCALE_ENABLED = controlsGrid.next() } 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 ed719fb84..45ca54dd4 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 @@ -35,10 +35,12 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) val totalHeight = lines.size * font.lineHeight + (lines.size - 1) * 2f var y = -totalHeight / 2f - val totalWidth = lines.maxOf { font.width(it) }.toFloat() - val highest = totalWidth.coerceAtLeast(totalHeight) - val mul = if (highest > 64f) 1f / (highest / 64f) else 64f / highest - poseStack.scale(mul, mul, mul) + if (tile.textAutoScale) { + val totalWidth = lines.maxOf { font.width(it) }.toFloat() + val highest = totalWidth.coerceAtLeast(totalHeight) + val mul = if (highest > 64f) 1f / (highest / 64f) else 64f / highest + poseStack.scale(mul, mul, mul) + } 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)) 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 f291876b3..20524cf57 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 @@ -2,8 +2,6 @@ package ru.dbotthepony.mc.otm.client.screen.decorative import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.ColorPickerPanel import ru.dbotthepony.mc.otm.client.screen.panels.Dock @@ -15,8 +13,9 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkedStringInputPanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.kommons.math.RGBAColor +import ru.dbotthepony.mc.otm.client.render.Widgets18 +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeBooleanRectangleButtonPanel import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu -import ru.dbotthepony.mc.otm.registry.MItems class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, title) { override fun makeMainFrame(): FramePanel> { @@ -51,10 +50,18 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) }) { init { tooltips.add(TranslatableComponent("otm.gui.change_color")) - icon = ItemStackIcon(ItemStack(MItems.PAINTER)).fixed() + icon = Widgets18.COLOR_PALETTE } }) + controls.addButton(LargeBooleanRectangleButtonPanel( + this@HoloSignScreen, + frame, + prop = menu.textAutoScale, + iconActive = Widgets18.TEXT_SCALE_ENABLED, + iconInactive = Widgets18.TEXT_SCALE_DISABLED, + )) + 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 87c55378e..2dd7ffa7c 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 textGreen = FloatInputWithFeedback(this) val textBlue = FloatInputWithFeedback(this) val textAlpha = FloatInputWithFeedback(this) + val textAutoScale = BooleanInputWithFeedback(this) init { text.filter { it.isCreative || !locked.value } @@ -35,6 +36,8 @@ class HoloSignMenu( textBlue.filter { it.isCreative || !locked.value } textAlpha.filter { it.isCreative || !locked.value } + textAutoScale.filter { it.isCreative || !locked.value } + if (tile != null) { text.withConsumer { if (tile.isLocked) tile.signText = it else tile.signText = HoloSignBlockEntity.truncate(it) }.withSupplier(tile::signText) textRed.withConsumer { tile.textRed = it.coerceIn(0f, 1f) }.withSupplier(tile::textRed) @@ -43,6 +46,7 @@ class HoloSignMenu( textAlpha.withConsumer { tile.textAlpha = it.coerceIn(0f, 1f) }.withSupplier(tile::textAlpha) locked.with(tile::isLocked) redstone.with(tile.redstoneControl::redstoneSetting) + textAutoScale.with(tile::textAutoScale) } } } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png index 41171ed83..9806ad55a 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf index cbd6a7acf..928c66053 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf differ