Move widget stuff around

This commit is contained in:
DBotThePony 2022-08-23 22:32:10 +07:00
parent 7b45fe3903
commit c8e67aece2
Signed by: DBot
GPG Key ID: DCC23B5715498507
7 changed files with 83 additions and 51 deletions

View File

@ -4,12 +4,9 @@ import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.*
import com.mojang.math.Matrix4f
import net.minecraft.client.renderer.GameRenderer
import net.minecraft.resources.ResourceLocation
import org.lwjgl.opengl.GL11
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.RGBAColor
import java.lang.Math.pow
import kotlin.math.acos
import kotlin.math.cos
import kotlin.math.pow
@ -17,13 +14,6 @@ import kotlin.math.sin
private val identity = Matrix4f().also { it.setIdentity() }
object WidgetLocation {
val WIDGETS = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets.png")
val WIDGETS_18 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png")
val WIDGETS_8 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_8.png")
val SCROLL = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/scroll.png")
}
var zLevel = 0f
var drawColor = RGBAColor(255, 255, 255, 255)

View File

@ -52,11 +52,6 @@ class SkinGrid(
}
operator fun get(column: Int, row: Int) = SkinElement(texture, column * width, row * height, width, height, imageWidth, imageHeight)
companion object {
val WIDGETS_18 = SkinGrid(WidgetLocation.WIDGETS_18, 18f, 18f)
val WIDGETS_8 = SkinGrid(WidgetLocation.WIDGETS_8, 8f, 8f)
}
}
fun ResourceLocation.element(

View File

@ -0,0 +1,11 @@
package ru.dbotthepony.mc.otm.client.render
import net.minecraft.resources.ResourceLocation
import ru.dbotthepony.mc.otm.OverdriveThatMatters
object WidgetLocation {
val WIDGETS = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets.png")
val WIDGETS_18 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png")
val WIDGETS_8 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_8.png")
val SCROLL = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/scroll.png")
}

View File

@ -0,0 +1,15 @@
package ru.dbotthepony.mc.otm.client.render
object Widgets18 {
val GRID = SkinGrid(WidgetLocation.WIDGETS_18, 18f, 18f)
val BUTTON_IDLE = GRID.next()
val BUTTON_HOVERED = GRID.next()
val BUTTON_PRESSED = GRID.next()
val ARROW_DOWN = GRID.next()
val AZ = GRID.next()
val COUNT = GRID.next()
val COLON = GRID.next()
val C = GRID.next()
val RED_CROSS = GRID.next()
}

View File

@ -0,0 +1,32 @@
package ru.dbotthepony.mc.otm.client.render
object Widgets8 {
val GRID = SkinGrid(WidgetLocation.WIDGETS_8, 8f, 8f)
val BUTTON_IDLE = GRID.next()
val WHITE_ARROW_DOWN = GRID.next()
val S = GRID.next()
val F = GRID.next()
val E = GRID.next()
val ONE = GRID.next()
init {
GRID.jump()
}
val BUTTON_HOVERED = GRID.next()
val ARROW_SIDEWAYS = GRID.next()
init {
GRID.jump()
}
val BUTTON_PRESSED = GRID.next()
val ARROW_PAINTED_UP = GRID.next()
init {
GRID.jump().skip()
}
val MINUS = GRID.next()
}

View File

@ -12,6 +12,7 @@ import ru.dbotthepony.mc.otm.TranslatableComponent
import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings
import ru.dbotthepony.mc.otm.client.render.SkinGrid
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.render.Widgets8
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.core.equalDownDivision
@ -127,11 +128,11 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
lambdaOnChange = { menu.sendSettingsToServer() })
refillPriority.mainTooltip = TranslatableComponent("otm.gui.item_monitor.refill_source.desc")
refillPriority.add(ItemMonitorPlayerSettings.RefillSource.SYSTEM, ItemMonitorPlayerSettings.RefillSource.SYSTEM.component, ARROW, UVWindingOrder.FLIP)
refillPriority.add(ItemMonitorPlayerSettings.RefillSource.INVENTORY, ItemMonitorPlayerSettings.RefillSource.INVENTORY.component, ARROW)
refillPriority.add(ItemMonitorPlayerSettings.RefillSource.INVENTORY_FIRST, ItemMonitorPlayerSettings.RefillSource.INVENTORY_FIRST.component, ARROW_UD, UVWindingOrder.FLIP)
refillPriority.add(ItemMonitorPlayerSettings.RefillSource.SYSTEM_FIRST, ItemMonitorPlayerSettings.RefillSource.SYSTEM_FIRST.component, ARROW_UD)
refillPriority.add(ItemMonitorPlayerSettings.RefillSource.DO_NOT, ItemMonitorPlayerSettings.RefillSource.DO_NOT.component, MINUS)
refillPriority.add(ItemMonitorPlayerSettings.RefillSource.SYSTEM, ItemMonitorPlayerSettings.RefillSource.SYSTEM.component, Widgets8.WHITE_ARROW_DOWN, UVWindingOrder.FLIP)
refillPriority.add(ItemMonitorPlayerSettings.RefillSource.INVENTORY, ItemMonitorPlayerSettings.RefillSource.INVENTORY.component, Widgets8.WHITE_ARROW_DOWN)
refillPriority.add(ItemMonitorPlayerSettings.RefillSource.INVENTORY_FIRST, ItemMonitorPlayerSettings.RefillSource.INVENTORY_FIRST.component, Widgets8.ARROW_SIDEWAYS, UVWindingOrder.FLIP)
refillPriority.add(ItemMonitorPlayerSettings.RefillSource.SYSTEM_FIRST, ItemMonitorPlayerSettings.RefillSource.SYSTEM_FIRST.component, Widgets8.ARROW_SIDEWAYS)
refillPriority.add(ItemMonitorPlayerSettings.RefillSource.DO_NOT, ItemMonitorPlayerSettings.RefillSource.DO_NOT.component, Widgets8.MINUS)
refillPriority.dock = Dock.LEFT
@ -149,9 +150,9 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
lambdaOnChange = { menu.sendSettingsToServer() })
resultTarget.mainTooltip = TranslatableComponent("otm.gui.item_monitor.result_target.desc")
resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.MIXED, ItemMonitorPlayerSettings.ResultTarget.MIXED.component, ARROW_UD)
resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY, ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY.component, ARROW_UU, UVWindingOrder.FLIP)
resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM, ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM.component, ARROW_UU)
resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.MIXED, ItemMonitorPlayerSettings.ResultTarget.MIXED.component, Widgets8.ARROW_SIDEWAYS)
resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY, ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY.component, Widgets8.ARROW_PAINTED_UP, UVWindingOrder.FLIP)
resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM, ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM.component, Widgets8.ARROW_PAINTED_UP)
val craftingAmount = SmallEnumSquareButtonPanel(this, resultAndButtons, x = 10f, y = 38f,
enum = ItemMonitorPlayerSettings.Amount::class.java,
@ -160,9 +161,9 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
lambdaOnChange = { menu.sendSettingsToServer() })
craftingAmount.mainTooltip = TranslatableComponent("otm.gui.item_monitor.amount.desc")
craftingAmount.add(ItemMonitorPlayerSettings.Amount.ONE, ItemMonitorPlayerSettings.Amount.ONE.component, ONE)
craftingAmount.add(ItemMonitorPlayerSettings.Amount.STACK, ItemMonitorPlayerSettings.Amount.STACK.component, S)
craftingAmount.add(ItemMonitorPlayerSettings.Amount.FULL, ItemMonitorPlayerSettings.Amount.FULL.component, F)
craftingAmount.add(ItemMonitorPlayerSettings.Amount.ONE, ItemMonitorPlayerSettings.Amount.ONE.component, Widgets8.ONE)
craftingAmount.add(ItemMonitorPlayerSettings.Amount.STACK, ItemMonitorPlayerSettings.Amount.STACK.component, Widgets8.S)
craftingAmount.add(ItemMonitorPlayerSettings.Amount.FULL, ItemMonitorPlayerSettings.Amount.FULL.component, Widgets8.F)
val craftingHistory = GridPanel(this, bottomPanel, width = 3 * 18f, height = 3 * 18f, columns = 3, rows = 3)
craftingHistory.dock = Dock.LEFT
@ -195,15 +196,5 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
const val ITEM_GRID_HEIGHT = 5
const val FONT_SCALE = 0.6f
val ARROW = SkinGrid.WIDGETS_8[1, 0]
val ARROW_UD = SkinGrid.WIDGETS_8[1, 1]
val ARROW_UU = SkinGrid.WIDGETS_8[1, 2]
val MINUS = SkinGrid.WIDGETS_8[1, 3]
val S = SkinGrid.WIDGETS_8[2, 0]
val F = SkinGrid.WIDGETS_8[3, 0]
val E = SkinGrid.WIDGETS_8[4, 0]
val ONE = SkinGrid.WIDGETS_8[5, 0]
}
}

View File

@ -10,9 +10,7 @@ import net.minecraft.network.chat.Component
import net.minecraft.sounds.SoundEvents
import ru.dbotthepony.mc.otm.TextComponent
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.SkinElement
import ru.dbotthepony.mc.otm.client.render.SkinGrid
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.render.*
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.next
import ru.dbotthepony.mc.otm.prev
@ -311,9 +309,9 @@ open class LargeSquareButtonPanel(
skinElement: (() -> SkinElement)? = null,
lambdaOnPress: ((clickButton: Int) -> Unit)? = null,
) : SquareButtonPanel(screen, parent, x, y, width, height, skinElement, lambdaOnPress) {
final override val IDLE = SkinGrid.WIDGETS_18[0, 0]
final override val HOVERED = SkinGrid.WIDGETS_18[1, 0]
final override val PRESSED = SkinGrid.WIDGETS_18[2, 0]
final override val IDLE = Widgets18.BUTTON_IDLE
final override val HOVERED = Widgets18.BUTTON_HOVERED
final override val PRESSED = Widgets18.BUTTON_PRESSED
companion object {
const val SIZE = 18f
@ -331,9 +329,9 @@ open class LargeEnumSquareButtonPanel<T : Enum<T>>(
defaultValue: T,
lambdaOnChange: ((newValue: T) -> Unit)? = null,
) : EnumSquareButtonPanel<T>(screen, parent, x, y, width, height, enum, prop, defaultValue, lambdaOnChange) {
final override val IDLE = SkinGrid.WIDGETS_18[0, 0]
final override val HOVERED = SkinGrid.WIDGETS_18[1, 0]
final override val PRESSED = SkinGrid.WIDGETS_18[2, 0]
final override val IDLE = Widgets18.BUTTON_IDLE
final override val HOVERED = Widgets18.BUTTON_HOVERED
final override val PRESSED = Widgets18.BUTTON_PRESSED
companion object {
const val SIZE = 18f
@ -350,9 +348,9 @@ open class SmallSquareButtonPanel(
skinElement: (() -> SkinElement)? = null,
lambdaOnPress: ((clickButton: Int) -> Unit)? = null,
) : SquareButtonPanel(screen, parent, x, y, width, height, skinElement, lambdaOnPress) {
final override val IDLE = SkinGrid.WIDGETS_8[0, 0]
final override val HOVERED = SkinGrid.WIDGETS_8[0, 1]
final override val PRESSED = SkinGrid.WIDGETS_8[0, 2]
final override val IDLE = Widgets8.BUTTON_IDLE
final override val HOVERED = Widgets8.BUTTON_HOVERED
final override val PRESSED = Widgets8.BUTTON_PRESSED
companion object {
const val SIZE = 8f
@ -371,9 +369,9 @@ open class SmallEnumSquareButtonPanel<T : Enum<T>>(
defaultValue: T,
lambdaOnChange: ((newValue: T) -> Unit)? = null,
) : EnumSquareButtonPanel<T>(screen, parent, x, y, width, height, enum, prop, defaultValue, lambdaOnChange) {
final override val IDLE = SkinGrid.WIDGETS_8[0, 0]
final override val HOVERED = SkinGrid.WIDGETS_8[0, 1]
final override val PRESSED = SkinGrid.WIDGETS_8[0, 2]
final override val IDLE = Widgets8.BUTTON_IDLE
final override val HOVERED = Widgets8.BUTTON_HOVERED
final override val PRESSED = Widgets8.BUTTON_PRESSED
companion object {
const val SIZE = 8f