not so good attempt at improving clarity of configuration menu

This commit is contained in:
DBotThePony 2023-02-21 16:10:58 +07:00
parent 3b53d65b29
commit 504033b65e
Signed by: DBot
GPG Key ID: DCC23B5715498507
5 changed files with 74 additions and 39 deletions

View File

@ -17,5 +17,5 @@ object WidgetLocation {
val HORIZONTAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/horizontal_gauges.png"), 96f, 54f)
val VERTICAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/vertical_gauges.png"), 90f, 48f)
val REDSTONE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/redstone.png"), 54f, 18f)
val SIDE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/side_controls.png"), 72f, 72f)
val SIDE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/side_controls.png"), 144f, 72f)
}

View File

@ -1,5 +1,10 @@
package ru.dbotthepony.mc.otm.client.render
import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity
import ru.dbotthepony.mc.otm.capability.FlowDirection
import ru.dbotthepony.mc.otm.core.immutableMap
import ru.dbotthepony.mc.otm.core.math.RelativeSide
private fun makeButton(grid: GridAtlas): StretchingRectangleElement {
val x = grid.currentX
val y = grid.currentY
@ -56,17 +61,61 @@ object Widgets18 {
val REDSTONE_LOW = redstoneGrid.next()
val REDSTONE_HIGH = redstoneGrid.next()
private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 4, columns = 4)
private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 4, columns = 8)
val PULL = controlsGrid.next()
val PUSH = controlsGrid.next()
val PULL_DISABLED = controlsGrid.next()
val PUSH_DISABLED = controlsGrid.next()
val DISABLED = controlsGrid.next()
val INPUT_ONLY = controlsGrid.next()
val OUTPUT_ONLY = controlsGrid.next()
val INPUT_OUTPUT = controlsGrid.next()
private fun controls() = immutableMap {
put(FlowDirection.NONE, controlsGrid.next())
put(FlowDirection.INPUT, controlsGrid.next())
put(FlowDirection.OUTPUT, controlsGrid.next())
put(FlowDirection.BI_DIRECTIONAL, controlsGrid.next())
}
private fun controls2(input: Map<FlowDirection, MatterySprite>) = immutableMap {
put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, input[FlowDirection.NONE]!!)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, input[FlowDirection.INPUT]!!)
put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, input[FlowDirection.OUTPUT]!!)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, input[FlowDirection.BI_DIRECTIONAL]!!)
put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY)
}
val LEFT_CONTROLS = controls()
val RIGHT_CONTROLS = controls()
val TOP_CONTROLS = controls()
val BOTTOM_CONTROLS = controls()
val FRONT_CONTROLS = controls()
val BACK_CONTROLS = controls()
val CONTROLS = immutableMap {
put(RelativeSide.BOTTOM, BOTTOM_CONTROLS)
put(RelativeSide.TOP, TOP_CONTROLS)
put(RelativeSide.LEFT, LEFT_CONTROLS)
put(RelativeSide.RIGHT, RIGHT_CONTROLS)
put(RelativeSide.FRONT, FRONT_CONTROLS)
put(RelativeSide.BACK, BACK_CONTROLS)
}
val BATTERY_ONLY = controlsGrid.next()
val ITEMS_CONFIGURATION = controlsGrid.next()
val ENERGY_CONFIGURATION = controlsGrid.next()
val LEFT_CONTROLS_ITEMS = controls2(LEFT_CONTROLS)
val RIGHT_CONTROLS_ITEMS = controls2(RIGHT_CONTROLS)
val TOP_CONTROLS_ITEMS = controls2(TOP_CONTROLS)
val BOTTOM_CONTROLS_ITEMS = controls2(BOTTOM_CONTROLS)
val FRONT_CONTROLS_ITEMS = controls2(FRONT_CONTROLS)
val BACK_CONTROLS_ITEMS = controls2(BACK_CONTROLS)
val ITEMS_CONTROLS = immutableMap {
put(RelativeSide.BOTTOM, BOTTOM_CONTROLS_ITEMS)
put(RelativeSide.TOP, TOP_CONTROLS_ITEMS)
put(RelativeSide.LEFT, LEFT_CONTROLS_ITEMS)
put(RelativeSide.RIGHT, RIGHT_CONTROLS_ITEMS)
put(RelativeSide.FRONT, FRONT_CONTROLS_ITEMS)
put(RelativeSide.BACK, BACK_CONTROLS_ITEMS)
}
}

View File

@ -5,6 +5,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.capability.FlowDirection
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.render.Widgets18
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
@ -41,19 +42,11 @@ private fun <S : MatteryScreen<*>> makeRedstoneSettingButton(
}
}
private fun <S : MatteryScreen<*>> makeItemModeButton(screen: S, parent: FramePanel<S>, input: ItemHandlerPlayerInput.Piece): LargeEnumRectangleButtonPanel<S, MatteryDeviceBlockEntity.ItemHandlerMode> {
private fun <S : MatteryScreen<*>> makeItemModeButton(screen: S, parent: FramePanel<S>, input: ItemHandlerPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel<S, MatteryDeviceBlockEntity.ItemHandlerMode> {
val button = LargeEnumRectangleButtonPanel(screen, parent, enum = MatteryDeviceBlockEntity.ItemHandlerMode::class.java, prop = input.input, defaultValue = input.default)
val values = listOf(
MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED to Widgets18.DISABLED,
MatteryDeviceBlockEntity.ItemHandlerMode.INPUT to Widgets18.INPUT_ONLY,
MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT to Widgets18.OUTPUT_ONLY,
MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT to Widgets18.INPUT_OUTPUT,
MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY to Widgets18.BATTERY_ONLY,
)
for ((k, v) in values) {
button.add(k, skinElement = v, tooltip = TranslatableComponent(k.translationKey))
for (v in MatteryDeviceBlockEntity.ItemHandlerMode.values()) {
button.add(v, skinElement = Widgets18.ITEMS_CONTROLS[side]!![v]!!, tooltip = TranslatableComponent(v.translationKey))
}
button.finish()
@ -62,18 +55,11 @@ private fun <S : MatteryScreen<*>> makeItemModeButton(screen: S, parent: FramePa
return button
}
private fun <S : MatteryScreen<*>> makeEnergyModeButton(screen: S, parent: FramePanel<S>, input: EnergyPlayerInput.Piece): LargeEnumRectangleButtonPanel<S, FlowDirection> {
private fun <S : MatteryScreen<*>> makeEnergyModeButton(screen: S, parent: FramePanel<S>, input: EnergyPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel<S, FlowDirection> {
val button = LargeEnumRectangleButtonPanel(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default)
val values = listOf(
FlowDirection.NONE to Widgets18.DISABLED,
FlowDirection.INPUT to Widgets18.INPUT_ONLY,
FlowDirection.OUTPUT to Widgets18.OUTPUT_ONLY,
FlowDirection.BI_DIRECTIONAL to Widgets18.INPUT_OUTPUT,
)
for ((k, v) in values) {
button.add(k, skinElement = v, tooltip = TranslatableComponent(k.translationKey))
for (v in FlowDirection.values()) {
button.add(v, skinElement = Widgets18.CONTROLS[side]!![v]!!, tooltip = TranslatableComponent(v.translationKey))
}
button.finish()
@ -162,12 +148,12 @@ private fun <S : MatteryScreen<*>> makeItemHandlerControlPanel(
}
}
val front = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!)
val back = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!)
val left = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!)
val right = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!)
val top = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!)
val bottom = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!)
val front = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!, RelativeSide.FRONT)
val back = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!, RelativeSide.BACK)
val left = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!, RelativeSide.LEFT)
val right = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!, RelativeSide.RIGHT)
val top = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP)
val bottom = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM)
pullPush(frame, inputs.pull, inputs.push)
moveButtons(front, back, left, right, top, bottom)
@ -191,12 +177,12 @@ private fun <S : MatteryScreen<*>> makeEnergyConfigPanel(
}
}
val front = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val back = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val left = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val right = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val top = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val bottom = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val front = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!, RelativeSide.FRONT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val back = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!, RelativeSide.BACK).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val left = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!, RelativeSide.LEFT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val right = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!, RelativeSide.RIGHT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val top = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val bottom = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
pullPush(frame, inputs.pull, inputs.push)
moveButtons(front, back, left, right, top, bottom)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB