Make EditablePanel be generic and upper-bound to Screen
This commit is contained in:
parent
7b478d485a
commit
a6a06fd4cd
@ -1,11 +1,13 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels;
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FlexGridPanel extends EditablePanel {
|
||||
public class FlexGridPanel<S extends Screen> extends EditablePanel<S> {
|
||||
public enum FlexAlign {
|
||||
TOP_LEFT,
|
||||
TOP_CENTER,
|
||||
@ -23,15 +25,15 @@ public class FlexGridPanel extends EditablePanel {
|
||||
protected FlexAlign align = FlexAlign.MIDDLE_CENTER;
|
||||
public int panels_per_row = 1;
|
||||
|
||||
public FlexGridPanel(@Nonnull MatteryScreen<?> screen, @Nullable EditablePanel parent, float x, float y, float width, float height) {
|
||||
public FlexGridPanel(@Nonnull S screen, @Nullable EditablePanel<?> parent, float x, float y, float width, float height) {
|
||||
super(screen, parent, x, y, width, height);
|
||||
}
|
||||
|
||||
public FlexGridPanel(@Nonnull MatteryScreen<?> screen, @Nullable EditablePanel parent, float x, float y) {
|
||||
public FlexGridPanel(@Nonnull S screen, @Nullable EditablePanel<?> parent, float x, float y) {
|
||||
super(screen, parent, x, y);
|
||||
}
|
||||
|
||||
public FlexGridPanel(@Nonnull MatteryScreen<?> screen, @Nullable EditablePanel parent) {
|
||||
public FlexGridPanel(@Nonnull S screen, @Nullable EditablePanel<?> parent) {
|
||||
super(screen, parent);
|
||||
}
|
||||
|
||||
@ -39,7 +41,7 @@ public class FlexGridPanel extends EditablePanel {
|
||||
return align;
|
||||
}
|
||||
|
||||
public FlexGridPanel setAlign(FlexAlign align) {
|
||||
public FlexGridPanel<S> setAlign(FlexAlign align) {
|
||||
this.align = align;
|
||||
return this;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ private class Tree(val node: AndroidResearchType<*>) : Iterable<Tree> {
|
||||
}
|
||||
|
||||
fun put(
|
||||
rows: Int2ObjectFunction<EditablePanel>,
|
||||
rows: Int2ObjectFunction<EditablePanel<AndroidStationScreen>>,
|
||||
left: Float,
|
||||
capability: MatteryPlayerCapability
|
||||
): Pair<AndroidResearchButton, Float> {
|
||||
@ -247,11 +247,11 @@ private class Tree(val node: AndroidResearchType<*>) : Iterable<Tree> {
|
||||
}
|
||||
|
||||
private class AndroidResearchButton(
|
||||
parent: EditablePanel,
|
||||
parent: EditablePanel<AndroidStationScreen>,
|
||||
private val node: AndroidResearch,
|
||||
private val lines: List<LinePos>,
|
||||
private val highlightLines: Map<AndroidResearchType<*>, List<LinePos>>
|
||||
) :EditablePanel(
|
||||
): EditablePanel<AndroidStationScreen>(
|
||||
parent.screen,
|
||||
parent,
|
||||
0f,
|
||||
@ -417,8 +417,8 @@ private class AndroidResearchButton(
|
||||
}
|
||||
|
||||
private enum class PreviewScrollers(
|
||||
val init: (EditablePanel, Random) -> Unit,
|
||||
val scroll: (EditablePanel, Random) -> Boolean
|
||||
val init: (EditablePanel<*>, Random) -> Unit,
|
||||
val scroll: (EditablePanel<*>, Random) -> Boolean
|
||||
) {
|
||||
LEFT_TO_RIGHT(
|
||||
init = { it, random ->
|
||||
@ -472,10 +472,10 @@ private enum class PreviewScrollers(
|
||||
class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: Inventory, p_97743_: Component) :
|
||||
MatteryScreen<AndroidStationMenu>(p_97741_, p_97742_, p_97743_) {
|
||||
|
||||
private fun makeCanvas(isPreview: Boolean): DraggableCanvasPanel {
|
||||
val rows = Int2ObjectAVLTreeMap<EditablePanel>()
|
||||
private fun makeCanvas(isPreview: Boolean): DraggableCanvasPanel<AndroidStationScreen> {
|
||||
val rows = Int2ObjectAVLTreeMap<EditablePanel<AndroidStationScreen>>()
|
||||
|
||||
val canvas = object : DraggableCanvasPanel(this@AndroidStationScreen, null) {
|
||||
val canvas = object : DraggableCanvasPanel<AndroidStationScreen>(this@AndroidStationScreen, null) {
|
||||
private val random = Random()
|
||||
private var scroller: PreviewScrollers = PreviewScrollers.values().let { it[random.nextInt(it.size)] }
|
||||
private var firstTick = false
|
||||
@ -522,7 +522,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
|
||||
for (i in 0 .. tree.height) {
|
||||
rows.computeIfAbsent(i, Int2ObjectFunction {
|
||||
object : EditablePanel(this@AndroidStationScreen, canvas, 0f, it * 24f, 10000f, 22f) {
|
||||
object : EditablePanel<AndroidStationScreen>(this@AndroidStationScreen, canvas, 0f, it * 24f, 10000f, 22f) {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int) = false
|
||||
override fun mouseReleasedInner(x: Double, y: Double, button: Int) = false
|
||||
override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double) = false
|
||||
@ -536,7 +536,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
|
||||
for (research in graph.second) {
|
||||
val row = rows.computeIfAbsent(research.researchTreeDepth, Int2ObjectFunction {
|
||||
object : EditablePanel(this@AndroidStationScreen, canvas, 0f, it * 24f, 10000f, 22f) {
|
||||
object : EditablePanel<AndroidStationScreen>(this@AndroidStationScreen, canvas, 0f, it * 24f, 10000f, 22f) {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int) = false
|
||||
override fun mouseReleasedInner(x: Double, y: Double, button: Int) = false
|
||||
override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double) = false
|
||||
@ -568,8 +568,8 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
return canvas
|
||||
}
|
||||
|
||||
private var research: FramePanel? = null
|
||||
private var playerStrip: EditablePanel by Delegates.notNull()
|
||||
private var research: FramePanel<AndroidStationScreen>? = null
|
||||
private var playerStrip: EditablePanel<AndroidStationScreen> by Delegates.notNull()
|
||||
var hoveredResearch: AndroidResearch? = null
|
||||
|
||||
private fun openResearchTree() {
|
||||
@ -614,10 +614,10 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
}
|
||||
}
|
||||
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<AndroidStationScreen> {
|
||||
val frame = FramePanel(this, 200f, 108f, title)
|
||||
|
||||
object : Label(this@AndroidStationScreen, frame, height = 11f, shadow = true) {
|
||||
object : Label<AndroidStationScreen>(this@AndroidStationScreen, frame, height = 11f, shadow = true) {
|
||||
init {
|
||||
dock = Dock.BOTTOM
|
||||
dockTop = 2f
|
||||
|
@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
|
||||
class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Component) :
|
||||
MatteryScreen<BatteryBankMenu>(menu, p_97742_, p_97743_) {
|
||||
|
||||
override fun makeMainFrame(): FramePanel{
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
WidePowerGaugePanel(this, frame, menu.powerLevel, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT)
|
||||
|
@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel
|
||||
import ru.dbotthepony.mc.otm.menu.CargoCrateMenu
|
||||
|
||||
class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen<CargoCrateMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = FramePanel(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, 22f + 4f + 6f * 18f, getTitle())
|
||||
val grid = GridPanel(this, frame, 8f, 18f, 9f * 18f, 6f * 18f, 9, 6)
|
||||
|
||||
|
@ -9,14 +9,14 @@ import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
|
||||
import ru.dbotthepony.mc.otm.menu.ChemicalGeneratorMenu
|
||||
|
||||
class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, title: Component) : MatteryScreen<ChemicalGeneratorMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
WidePowerGaugePanel(this, frame, menu.energy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE)
|
||||
|
||||
val self = this
|
||||
val progress = object : ProgressGaugePanel(self, frame, menu.progress, 78f, PROGRESS_ARROW_TOP) {
|
||||
val progress = object : ProgressGaugePanel<ChemicalGeneratorScreen>(self, frame, menu.progress, 78f, PROGRESS_ARROW_TOP) {
|
||||
override fun makeTooltip(): MutableList<Component> {
|
||||
val list = super.makeTooltip()
|
||||
|
||||
|
@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
|
||||
class DriveRackScreen(menu: DriveRackMenu, inventory: Inventory, title: Component) :
|
||||
MatteryScreen<DriveRackMenu>(menu, inventory, title) {
|
||||
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
|
@ -16,11 +16,11 @@ import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak
|
||||
class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Component) :
|
||||
MatteryScreen<DriveViewerMenu>(menu, inventory, title) {
|
||||
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = FramePanel(this, null, 0f, 0f, FRAME_WIDTH, FRAME_HEIGHT, getTitle())
|
||||
|
||||
val views = ArrayList<EditablePanel>()
|
||||
val settings = ArrayList<EditablePanel>()
|
||||
val views = ArrayList<EditablePanel<*>>()
|
||||
val settings = ArrayList<EditablePanel<*>>()
|
||||
|
||||
frame.Tab(onOpen = {
|
||||
for (panel in views) {
|
||||
@ -54,7 +54,7 @@ class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Comp
|
||||
views.add(scrollBar)
|
||||
|
||||
for (i in 0 until GRID_WIDTH * GRID_HEIGHT) {
|
||||
object : AbstractSlotPanel(this@DriveViewerScreen, grid, 0f, 0f) {
|
||||
object : AbstractSlotPanel<DriveViewerScreen>(this@DriveViewerScreen, grid, 0f, 0f) {
|
||||
override fun getItemStack(): ItemStack {
|
||||
val index = i + scrollBar.scroll * GRID_WIDTH
|
||||
return menu.networkedItemView.sortedView.getOrNull(index)?.stack?.item ?: ItemStack.EMPTY
|
||||
|
@ -8,10 +8,10 @@ import ru.dbotthepony.mc.otm.core.formatPower
|
||||
import ru.dbotthepony.mc.otm.menu.EnergyCounterMenu
|
||||
|
||||
class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: Component) : MatteryScreen<EnergyCounterMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
var label: Label = object : Label(this@EnergyCounterScreen, frame) {
|
||||
var label: Label<EnergyCounterScreen> = object : Label<EnergyCounterScreen>(this@EnergyCounterScreen, frame) {
|
||||
override fun tick() {
|
||||
super.tick()
|
||||
text = TranslatableComponent(
|
||||
@ -24,7 +24,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title:
|
||||
label.dock = Dock.TOP
|
||||
label.setDockMargin(4f, 0f, 0f, 0f)
|
||||
|
||||
label = object : Label(this@EnergyCounterScreen, frame) {
|
||||
label = object : Label<EnergyCounterScreen>(this@EnergyCounterScreen, frame) {
|
||||
override fun tick() {
|
||||
super.tick()
|
||||
text = TranslatableComponent(
|
||||
@ -37,7 +37,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title:
|
||||
label.dock = Dock.TOP
|
||||
label.setDockMargin(4f, 0f, 0f, 0f)
|
||||
|
||||
label = object : Label(this@EnergyCounterScreen, frame) {
|
||||
label = object : Label<EnergyCounterScreen>(this@EnergyCounterScreen, frame) {
|
||||
override fun tick() {
|
||||
super.tick()
|
||||
text = TranslatableComponent(
|
||||
@ -50,7 +50,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title:
|
||||
label.dock = Dock.TOP
|
||||
label.setDockMargin(4f, 0f, 0f, 0f)
|
||||
|
||||
label = object : Label(this@EnergyCounterScreen, frame) {
|
||||
label = object : Label<EnergyCounterScreen>(this@EnergyCounterScreen, frame) {
|
||||
override fun tick() {
|
||||
super.tick()
|
||||
text = TranslatableComponent(
|
||||
@ -63,7 +63,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title:
|
||||
label.dock = Dock.TOP
|
||||
label.setDockMargin(4f, 0f, 0f, 0f)
|
||||
|
||||
label = object : Label(this@EnergyCounterScreen, frame) {
|
||||
label = object : Label<EnergyCounterScreen>(this@EnergyCounterScreen, frame) {
|
||||
override fun tick() {
|
||||
super.tick()
|
||||
|
||||
|
@ -15,7 +15,7 @@ import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak
|
||||
|
||||
@MouseTweaksDisableWheelTweak
|
||||
class ExoSuitInventoryScreen(menu: ExoSuitInventoryMenu) : MatteryScreen<ExoSuitInventoryMenu>(menu, TranslatableComponent("otm.gui.exosuit")) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = FramePanel(this, width = 200f, height = 180f, title = this.title)
|
||||
|
||||
val toolbeltLine = EditablePanel(this, frame, height = 18f)
|
||||
@ -23,7 +23,7 @@ class ExoSuitInventoryScreen(menu: ExoSuitInventoryMenu) : MatteryScreen<ExoSuit
|
||||
|
||||
toolbeltLine.setDockMargin(top = 3f)
|
||||
|
||||
var mainInventoryLine: EditablePanel? = null
|
||||
var mainInventoryLine: EditablePanel<*>? = null
|
||||
|
||||
val scrollPanel = DiscreteScrollBarPanel(this, null, maxScroll = { ((menu.playerCombinedInventorySlots.size - 27) + 8) / 9 },
|
||||
scrollCallback = {
|
||||
@ -45,7 +45,7 @@ class ExoSuitInventoryScreen(menu: ExoSuitInventoryMenu) : MatteryScreen<ExoSuit
|
||||
|
||||
scrollPanel.scroll = menu.lastScroll
|
||||
|
||||
mainInventoryLine = object : EditablePanel(this@ExoSuitInventoryScreen, frame, height = 18f * 3f) {
|
||||
mainInventoryLine = object : EditablePanel<ExoSuitInventoryScreen>(this@ExoSuitInventoryScreen, frame, height = 18f * 3f) {
|
||||
override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean {
|
||||
return scrollPanel.mouseScrolledInner(x, y, scroll)
|
||||
}
|
||||
@ -113,7 +113,7 @@ class ExoSuitInventoryScreen(menu: ExoSuitInventoryMenu) : MatteryScreen<ExoSuit
|
||||
|
||||
val resultPanel = SlotPanel(this, craftingCanvas, menu.craftingResultSlot, x = craftingCanvas.width - 18f, y = topLine.height / 2f - 9f)
|
||||
|
||||
val arrowPanel = object : EditablePanel(
|
||||
val arrowPanel = object : EditablePanel<ExoSuitInventoryScreen>(
|
||||
this@ExoSuitInventoryScreen,
|
||||
craftingCanvas,
|
||||
x = craftingSlotsCanvas.width,
|
||||
|
@ -27,7 +27,7 @@ import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak
|
||||
class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Component) :
|
||||
MatteryScreen<ItemMonitorMenu>(menu, inventory, title) {
|
||||
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = FramePanel(this@ItemMonitorScreen, null, 0f, 0f, 1f, 1f, getTitle())
|
||||
|
||||
val topPanel = EditablePanel(this, frame)
|
||||
@ -54,7 +54,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
|
||||
gridPanel.dock = Dock.FILL
|
||||
|
||||
for (i in 0 until ITEM_GRID_WIDTH * ITEM_GRID_HEIGHT) {
|
||||
object : AbstractSlotPanel(this@ItemMonitorScreen, gridPanel) {
|
||||
object : AbstractSlotPanel<ItemMonitorScreen>(this@ItemMonitorScreen, gridPanel) {
|
||||
private val index get() = i + viewScrollBar.scroll * ITEM_GRID_WIDTH
|
||||
|
||||
override fun getItemStack(): ItemStack {
|
||||
@ -113,7 +113,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
|
||||
SlotPanel(this, craftingGrid, menu.craftingSlots[i])
|
||||
}
|
||||
|
||||
val arrowAndButtons = object : EditablePanel(this@ItemMonitorScreen, bottomPanel, width = ProgressGaugePanel.GAUGE_BACKGROUND.w) {
|
||||
val arrowAndButtons = object : EditablePanel<ItemMonitorScreen>(this@ItemMonitorScreen, bottomPanel, width = ProgressGaugePanel.GAUGE_BACKGROUND.w) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
ProgressGaugePanel.GAUGE_BACKGROUND.render(stack, y = height / 2f - ProgressGaugePanel.GAUGE_BACKGROUND.h / 2f)
|
||||
}
|
||||
@ -179,7 +179,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
|
||||
craftingHistoryScroll.setDockMargin(left = 2f)
|
||||
|
||||
for (i in 0 until 9) {
|
||||
object : AbstractSlotPanel(this@ItemMonitorScreen, craftingHistory) {
|
||||
object : AbstractSlotPanel<ItemMonitorScreen>(this@ItemMonitorScreen, craftingHistory) {
|
||||
override fun getItemStack(): ItemStack {
|
||||
return ItemStack(Items.ARROW, 42)
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ import ru.dbotthepony.mc.otm.menu.MatterBottlerMenu
|
||||
class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title: Component) :
|
||||
MatteryScreen<MatterBottlerMenu>(menu, inventory, title) {
|
||||
|
||||
private var progress: ProgressGaugePanel? = null
|
||||
private var progress: ProgressGaugePanel<MatterBottlerScreen>? = null
|
||||
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
val p = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
|
@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
|
||||
|
||||
class MatterCapacitorBankScreen(p_97741_: MatterCapacitorBankMenu, p_97742_: Inventory, p_97743_: Component) :
|
||||
MatteryScreen<MatterCapacitorBankMenu>(p_97741_, p_97742_, p_97743_) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
val m = MatterGaugePanel(this, frame, menu.matterGauge, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT)
|
||||
|
@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
class MatterDecomposerScreen(p_97741_: MatterDecomposerMenu, p_97742_: Inventory, p_97743_: Component) :
|
||||
MatteryScreen<MatterDecomposerMenu>(p_97741_, p_97742_, p_97743_) {
|
||||
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
|
@ -23,7 +23,7 @@ class MatterPanelScreen(
|
||||
inventory: Inventory,
|
||||
title: Component
|
||||
) : MatteryScreen<MatterPanelMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
var isPatternView = true
|
||||
|
||||
val frame = FramePanel.padded(this, null, GRID_WIDTH * AbstractSlotPanel.SIZE + ScrollBarConstants.WIDTH + 4f, GRID_HEIGHT * AbstractSlotPanel.SIZE, title)
|
||||
@ -46,7 +46,7 @@ class MatterPanelScreen(
|
||||
it.tooltip = TranslatableComponent("otm.container.matter_panel.tasks")
|
||||
}
|
||||
|
||||
val canvas = object : EditablePanel(this@MatterPanelScreen, frame, width = GRID_WIDTH * AbstractSlotPanel.SIZE) {
|
||||
val canvas = object : EditablePanel<MatterPanelScreen>(this@MatterPanelScreen, frame, width = GRID_WIDTH * AbstractSlotPanel.SIZE) {
|
||||
init {
|
||||
dock = Dock.LEFT
|
||||
}
|
||||
@ -57,7 +57,7 @@ class MatterPanelScreen(
|
||||
}
|
||||
|
||||
for (row in 0 until GRID_HEIGHT) {
|
||||
val rowCanvas = object : EditablePanel(this@MatterPanelScreen, canvas, height = AbstractSlotPanel.SIZE) {
|
||||
val rowCanvas = object : EditablePanel<MatterPanelScreen>(this@MatterPanelScreen, canvas, height = AbstractSlotPanel.SIZE) {
|
||||
init {
|
||||
dock = Dock.TOP
|
||||
}
|
||||
@ -68,7 +68,7 @@ class MatterPanelScreen(
|
||||
}
|
||||
|
||||
for (i in 0 until GRID_WIDTH) {
|
||||
object : AbstractSlotPanel(this@MatterPanelScreen, rowCanvas) {
|
||||
object : AbstractSlotPanel<MatterPanelScreen>(this@MatterPanelScreen, rowCanvas) {
|
||||
init {
|
||||
dock = Dock.LEFT
|
||||
}
|
||||
@ -127,7 +127,7 @@ class MatterPanelScreen(
|
||||
private fun openTask(task: IReplicationTask<*>) {
|
||||
val frame = FramePanel.padded(this, null, 170f, 20f, TranslatableComponent("otm.container.matter_panel.task"))
|
||||
|
||||
object : AbstractSlotPanel(this@MatterPanelScreen, frame) {
|
||||
object : AbstractSlotPanel<MatterPanelScreen>(this@MatterPanelScreen, frame) {
|
||||
init {
|
||||
dock = Dock.LEFT
|
||||
}
|
||||
@ -181,7 +181,7 @@ class MatterPanelScreen(
|
||||
rowControls.dock = Dock.TOP
|
||||
rowControls.dockTop = 3f
|
||||
|
||||
object : AbstractSlotPanel(this@MatterPanelScreen, rowInput) {
|
||||
object : AbstractSlotPanel<MatterPanelScreen>(this@MatterPanelScreen, rowInput) {
|
||||
init {
|
||||
dock = Dock.LEFT
|
||||
dockRight = 2f
|
||||
@ -209,7 +209,7 @@ class MatterPanelScreen(
|
||||
}
|
||||
}
|
||||
|
||||
val input = object : EditBoxPanel(this@MatterPanelScreen, rowInput) {
|
||||
val input = object : EditBoxPanel<MatterPanelScreen>(this@MatterPanelScreen, rowInput) {
|
||||
init {
|
||||
dock = Dock.FILL
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
import ru.dbotthepony.mc.otm.menu.MatterRecyclerMenu
|
||||
|
||||
class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title: Component) : MatteryScreen<MatterRecyclerMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
|
@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
|
||||
class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory, p_97743_: Component) :
|
||||
MatteryScreen<MatterReplicatorMenu>(p_97741_, p_97742_, p_97743_) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
|
@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
|
||||
class MatterScannerScreen(p_97741_: MatterScannerMenu, p_97742_: Inventory, p_97743_: Component) :
|
||||
MatteryScreen<MatterScannerMenu>(p_97741_, p_97742_, p_97743_) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
|
@ -32,10 +32,10 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||
abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, title: Component) : AbstractContainerScreen<T>(menu, inventory, title) {
|
||||
constructor(menu: T, title: Component) : this(menu, menu.inventory, title)
|
||||
|
||||
protected val panels = ArrayDeque<EditablePanel>()
|
||||
protected val panels = ArrayDeque<EditablePanel<*>>()
|
||||
|
||||
var inventoryFrame: FramePanel? = null
|
||||
var mainFrame: FramePanel? = null
|
||||
var inventoryFrame: FramePanel<out MatteryScreen<*>>? = null
|
||||
var mainFrame: FramePanel<out MatteryScreen<*>>? = null
|
||||
private var madeMainFrame = false
|
||||
|
||||
var itemRenderer: ItemRenderer
|
||||
@ -51,12 +51,12 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
val quickCraftingType get() = quickCraftingType
|
||||
val isQuickCrafting get() = isQuickCrafting
|
||||
|
||||
private val inventorySlotsRows = Int2ObjectAVLTreeMap<EditablePanel>()
|
||||
private val inventorySlotsRows = Int2ObjectAVLTreeMap<EditablePanel<MatteryScreen<*>>>()
|
||||
|
||||
init {
|
||||
if (menu.playerInventorySlots.isNotEmpty() && menu.autoCreateInventoryFrame) {
|
||||
if (menu.playerExoSuitSlots.isEmpty()) {
|
||||
inventoryFrame = FramePanel(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel)
|
||||
inventoryFrame = FramePanel<MatteryScreen<*>>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel)
|
||||
|
||||
val hotbarStrip = EditablePanel(this, inventoryFrame, height = AbstractSlotPanel.SIZE)
|
||||
hotbarStrip.dock = Dock.BOTTOM
|
||||
@ -77,9 +77,9 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inventoryFrame = FramePanel(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH_EXTENDED, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel)
|
||||
inventoryFrame = FramePanel<MatteryScreen<*>>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH_EXTENDED, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel)
|
||||
|
||||
var slotListCanvas: EditablePanel? = null
|
||||
var slotListCanvas: EditablePanel<MatteryScreen<*>>? = null
|
||||
|
||||
val scrollbar = DiscreteScrollBarPanel(this, inventoryFrame, { ((menu.playerCombinedInventorySlots.size - 27) + 8) / 9 }, {
|
||||
_, old, new ->
|
||||
@ -99,7 +99,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
menu.ply.matteryPlayer?.exoSuitMenu?.lastScroll = new
|
||||
})
|
||||
|
||||
slotListCanvas = object : EditablePanel(this@MatteryScreen, inventoryFrame, height = AbstractSlotPanel.SIZE * 3f) {
|
||||
slotListCanvas = object : EditablePanel<MatteryScreen<*>>(this@MatteryScreen, inventoryFrame, height = AbstractSlotPanel.SIZE * 3f) {
|
||||
override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean {
|
||||
scrollbar.mouseScrolledInner(x, y, scroll)
|
||||
return true
|
||||
@ -130,9 +130,9 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
}
|
||||
}
|
||||
|
||||
protected fun getInventorySlotsRow(index: Int): EditablePanel {
|
||||
protected fun getInventorySlotsRow(index: Int): EditablePanel<MatteryScreen<*>> {
|
||||
return inventorySlotsRows.computeIfAbsent(index, Int2ObjectFunction {
|
||||
val canvas = object : EditablePanel(this@MatteryScreen, null, width = AbstractSlotPanel.SIZE * 9f, height = AbstractSlotPanel.SIZE) {
|
||||
val canvas = object : EditablePanel<MatteryScreen<*>>(this@MatteryScreen, null, width = AbstractSlotPanel.SIZE * 9f, height = AbstractSlotPanel.SIZE) {
|
||||
override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean {
|
||||
return false
|
||||
}
|
||||
@ -145,7 +145,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
}
|
||||
|
||||
for (i in 0 .. (8).coerceAtMost(menu.playerCombinedInventorySlots.size - offset - 1)) {
|
||||
val slot = object : SlotPanel<Slot>(this@MatteryScreen, canvas, menu.playerCombinedInventorySlots[offset + i]) {
|
||||
val slot = object : SlotPanel<MatteryScreen<*>, Slot>(this@MatteryScreen, canvas, menu.playerCombinedInventorySlots[offset + i]) {
|
||||
override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean {
|
||||
return false
|
||||
}
|
||||
@ -170,7 +170,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
movePanels()
|
||||
}
|
||||
|
||||
fun addPanel(panel: EditablePanel): Boolean {
|
||||
fun addPanel(panel: EditablePanel<out MatteryScreen<*>>): Boolean {
|
||||
if (!panels.contains(panel)) {
|
||||
panels.addFirst(panel)
|
||||
return true
|
||||
@ -179,7 +179,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
return false
|
||||
}
|
||||
|
||||
fun removePanel(panel: EditablePanel): Boolean {
|
||||
fun removePanel(panel: EditablePanel<out MatteryScreen<*>>): Boolean {
|
||||
val indexOf = panels.indexOf(panel)
|
||||
|
||||
if (indexOf != -1) {
|
||||
@ -195,7 +195,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
*
|
||||
* @param panel panel to be pushed up
|
||||
*/
|
||||
fun popup(panel: EditablePanel) {
|
||||
fun popup(panel: EditablePanel<out MatteryScreen<*>>) {
|
||||
val indexOf = panels.indexOf(panel)
|
||||
|
||||
require(indexOf != -1) { "No such panel $panel" }
|
||||
@ -215,7 +215,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
*
|
||||
* @return FramePanel created, or null
|
||||
*/
|
||||
protected open fun makeMainFrame(): FramePanel? {
|
||||
protected open fun makeMainFrame(): FramePanel<out MatteryScreen<*>>? {
|
||||
return FramePanel(this, null, 0f, 0f, DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT, getTitle())
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel
|
||||
|
||||
class PatternStorageScreen(p_97741_: PatternStorageMenu, p_97742_: Inventory, p_97743_: Component) :
|
||||
MatteryScreen<PatternStorageMenu>(p_97741_, p_97742_, p_97743_) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
val m = PatternGaugePanel(this, frame, menu.storedThis, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT)
|
||||
|
@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.menu.PlatePressMenu
|
||||
|
||||
class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Component) :
|
||||
MatteryScreen<PlatePressMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
|
@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.menu.StorageBusMenu
|
||||
|
||||
class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Component) :
|
||||
MatteryScreen<StorageBusMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
|
@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.menu.StorageExporterMenu
|
||||
|
||||
class StorageExporterScreen(menu: StorageExporterMenu, inventory: Inventory, title: Component) :
|
||||
MatteryScreen<StorageExporterMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
|
@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.menu.StorageImporterMenu
|
||||
|
||||
class StorageImporterScreen(menu: StorageImporterMenu, inventory: Inventory, title: Component) :
|
||||
MatteryScreen<StorageImporterMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = super.makeMainFrame()!!
|
||||
|
||||
WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
|
@ -11,7 +11,7 @@ import ru.dbotthepony.mc.otm.menu.StoragePowerSupplierMenu
|
||||
|
||||
class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inventory, title: Component) :
|
||||
MatteryScreen<StoragePowerSupplierMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
|
||||
val frame = FramePanel(this, width = 200f, height = 60f, title)
|
||||
|
||||
HorizontalPowerGaugePanel(this, frame, menu.powerWidget).also {
|
||||
@ -33,7 +33,7 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve
|
||||
|
||||
labels.dock = Dock.FILL
|
||||
|
||||
object : Label(this@StoragePowerSupplierScreen, labels) {
|
||||
object : Label<StoragePowerSupplierScreen>(this@StoragePowerSupplierScreen, labels) {
|
||||
init {
|
||||
dock = Dock.TOP
|
||||
}
|
||||
@ -48,7 +48,7 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve
|
||||
}
|
||||
}
|
||||
|
||||
object : Label(this@StoragePowerSupplierScreen, labels) {
|
||||
object : Label<StoragePowerSupplierScreen>(this@StoragePowerSupplierScreen, labels) {
|
||||
init {
|
||||
dock = Dock.TOP
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import net.minecraft.client.renderer.GameRenderer
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.ItemStack
|
||||
@ -12,17 +14,15 @@ import ru.dbotthepony.mc.otm.client.render.*
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.core.RGBAColor
|
||||
|
||||
abstract class AbstractSlotPanel @JvmOverloads constructor(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
abstract class AbstractSlotPanel<out S : MatteryScreen<*>> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
height: Float = SIZE,
|
||||
open val noItemIcon: SkinElement? = null
|
||||
) : EditablePanel(
|
||||
screen, parent, x, y, width, height
|
||||
) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
protected open fun renderSlotBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
SLOT_BACKGROUND.render(stack, width = width, height = height)
|
||||
}
|
||||
|
@ -1,19 +1,21 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import ru.dbotthepony.mc.otm.client.render.StretchingRectangleElement
|
||||
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
||||
import ru.dbotthepony.mc.otm.client.render.element
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
|
||||
open class BackgroundPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class BackgroundPanel<out S : Screen>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = 10f,
|
||||
height: Float = 10f,
|
||||
) : EditablePanel(screen, parent, x, y, width, height) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
init {
|
||||
dockPadding = DockProperty(3f, 3f, 3f, 3f)
|
||||
}
|
||||
@ -23,18 +25,18 @@ open class BackgroundPanel(
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun padded(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
fun <S : Screen> padded(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = 10f,
|
||||
height: Float = 10f,
|
||||
) = BackgroundPanel(screen, parent, x, y, width + 6f, height + 6f)
|
||||
|
||||
fun paddedCenter(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
fun <S : Screen> paddedCenter(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = 10f,
|
||||
|
@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.client.gui.components.Button
|
||||
import net.minecraft.client.gui.components.Button.OnPress
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import net.minecraft.network.chat.Component
|
||||
import ru.dbotthepony.mc.otm.client.playGuiClickSound
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
@ -16,19 +17,19 @@ import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.reflect.KMutableProperty0
|
||||
|
||||
open class ButtonPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class ButtonPanel<out S : AbstractContainerScreen<*>>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = 40f,
|
||||
height: Float = HEIGHT,
|
||||
label: Component
|
||||
) : MinecraftWidgetPanel<Button>(screen, parent, x, y, width, height) {
|
||||
constructor(screen: MatteryScreen<*>, parent: EditablePanel?, label: Component) : this(screen, parent, x = 0f, label = label)
|
||||
) : MinecraftWidgetPanel<S, Button>(screen, parent, x, y, width, height) {
|
||||
constructor(screen: S, parent: EditablePanel<*>?, label: Component) : this(screen, parent, x = 0f, label = label)
|
||||
constructor(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = 40f,
|
||||
@ -72,16 +73,16 @@ open class ButtonPanel(
|
||||
}
|
||||
|
||||
@Suppress("PropertyName")
|
||||
abstract class SquareButtonPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
abstract class SquareButtonPanel<out S : AbstractContainerScreen<*>>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float,
|
||||
height: Float,
|
||||
val skinElement: (() -> SkinElement)? = null,
|
||||
val onPress: ((clickButton: Int) -> Unit)? = null,
|
||||
) : EditablePanel(screen, parent, x, y, width, height) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
protected var pressed = false
|
||||
|
||||
protected open fun click(clickButton: Int) {
|
||||
@ -144,9 +145,9 @@ abstract class SquareButtonPanel(
|
||||
}
|
||||
}
|
||||
|
||||
abstract class EnumSquareButtonPanel<T : Enum<T>>(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
abstract class EnumSquareButtonPanel<out S : AbstractContainerScreen<*>, T : Enum<T>>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float,
|
||||
@ -155,13 +156,13 @@ abstract class EnumSquareButtonPanel<T : Enum<T>>(
|
||||
val prop: KMutableProperty0<T>,
|
||||
val defaultValue: T,
|
||||
val onChange: ((newValue: T) -> Unit)? = null,
|
||||
) : SquareButtonPanel(screen, parent, x, y, width, height, null, null) {
|
||||
) : SquareButtonPanel<S>(screen, parent, x, y, width, height, null, null) {
|
||||
private var building = true
|
||||
|
||||
protected val enumMapping = EnumMap<T, Pair<SkinElement, UVWindingOrder>>(enum)
|
||||
protected val tooltipMapping = EnumMap<T, Component>(enum)
|
||||
|
||||
fun addTooltip(value: T, component: Component): EnumSquareButtonPanel<T> {
|
||||
fun addTooltip(value: T, component: Component): EnumSquareButtonPanel<S, T> {
|
||||
check(tooltipMapping.put(value, component) == null) { "Already has mapping for $value" }
|
||||
return this
|
||||
}
|
||||
@ -197,19 +198,19 @@ abstract class EnumSquareButtonPanel<T : Enum<T>>(
|
||||
return missing
|
||||
}
|
||||
|
||||
fun add(value: T, skinElement: SkinElement, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumSquareButtonPanel<T> {
|
||||
fun add(value: T, skinElement: SkinElement, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumSquareButtonPanel<S, T> {
|
||||
return add(value, skinElement to winding)
|
||||
}
|
||||
|
||||
fun add(value: T, skinElement: SkinElement, component: Component, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumSquareButtonPanel<T> {
|
||||
fun add(value: T, skinElement: SkinElement, component: Component, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumSquareButtonPanel<S, T> {
|
||||
return add(value, component, skinElement to winding)
|
||||
}
|
||||
|
||||
fun add(value: T, component: Component, skinElement: SkinElement, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumSquareButtonPanel<T> {
|
||||
fun add(value: T, component: Component, skinElement: SkinElement, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumSquareButtonPanel<S, T> {
|
||||
return add(value, component, skinElement to winding)
|
||||
}
|
||||
|
||||
fun add(value: T, pair: Pair<SkinElement, UVWindingOrder>): EnumSquareButtonPanel<T> {
|
||||
fun add(value: T, pair: Pair<SkinElement, UVWindingOrder>): EnumSquareButtonPanel<S, T> {
|
||||
check(building) { "Not building" }
|
||||
check(enumMapping.put(value, pair) == null) { "Already has mapping for $value" }
|
||||
|
||||
@ -220,12 +221,12 @@ abstract class EnumSquareButtonPanel<T : Enum<T>>(
|
||||
return this
|
||||
}
|
||||
|
||||
fun add(value: T, component: Component, pair: Pair<SkinElement, UVWindingOrder>): EnumSquareButtonPanel<T> {
|
||||
fun add(value: T, component: Component, pair: Pair<SkinElement, UVWindingOrder>): EnumSquareButtonPanel<S, T> {
|
||||
addTooltip(value, component)
|
||||
return add(value, pair)
|
||||
}
|
||||
|
||||
fun finish(): EnumSquareButtonPanel<T> {
|
||||
fun finish(): EnumSquareButtonPanel<S, T> {
|
||||
check(building) { "Not building" }
|
||||
check(isFullyDefined()) {
|
||||
"Not all enums having their mapping defined, missing are: ${missingValues.joinToString(", ")}"
|
||||
@ -313,19 +314,19 @@ abstract class EnumSquareButtonPanel<T : Enum<T>>(
|
||||
}
|
||||
}
|
||||
|
||||
open class LargeSquareButtonPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class LargeSquareButtonPanel<out S : AbstractContainerScreen<*>>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
height: Float = SIZE,
|
||||
skinElement: (() -> SkinElement)? = null,
|
||||
onPress: ((clickButton: Int) -> Unit)? = null,
|
||||
) : SquareButtonPanel(screen, parent, x, y, width, height, skinElement, onPress) {
|
||||
) : SquareButtonPanel<S>(screen, parent, x, y, width, height, skinElement, onPress) {
|
||||
constructor(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
@ -342,9 +343,10 @@ open class LargeSquareButtonPanel(
|
||||
const val SIZE = 18f
|
||||
}
|
||||
}
|
||||
open class LargeEnumSquareButtonPanel<T : Enum<T>>(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
|
||||
open class LargeEnumSquareButtonPanel<out S : AbstractContainerScreen<*>, T : Enum<T>>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
@ -353,7 +355,7 @@ open class LargeEnumSquareButtonPanel<T : Enum<T>>(
|
||||
prop: KMutableProperty0<T>,
|
||||
defaultValue: T,
|
||||
onChange: ((newValue: T) -> Unit)? = null,
|
||||
) : EnumSquareButtonPanel<T>(screen, parent, x, y, width, height, enum, prop, defaultValue, onChange) {
|
||||
) : EnumSquareButtonPanel<S, T>(screen, parent, x, y, width, height, enum, prop, defaultValue, onChange) {
|
||||
final override val IDLE = Widgets18.BUTTON_IDLE
|
||||
final override val HOVERED = Widgets18.BUTTON_HOVERED
|
||||
final override val PRESSED = Widgets18.BUTTON_PRESSED
|
||||
@ -363,16 +365,16 @@ open class LargeEnumSquareButtonPanel<T : Enum<T>>(
|
||||
}
|
||||
}
|
||||
|
||||
open class SmallSquareButtonPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class SmallSquareButtonPanel<out S : AbstractContainerScreen<*>>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
height: Float = SIZE,
|
||||
skinElement: (() -> SkinElement)? = null,
|
||||
lambdaOnPress: ((clickButton: Int) -> Unit)? = null,
|
||||
) : SquareButtonPanel(screen, parent, x, y, width, height, skinElement, lambdaOnPress) {
|
||||
) : SquareButtonPanel<S>(screen, parent, x, y, width, height, skinElement, lambdaOnPress) {
|
||||
final override val IDLE = Widgets8.BUTTON_IDLE
|
||||
final override val HOVERED = Widgets8.BUTTON_HOVERED
|
||||
final override val PRESSED = Widgets8.BUTTON_PRESSED
|
||||
@ -382,9 +384,9 @@ open class SmallSquareButtonPanel(
|
||||
}
|
||||
}
|
||||
|
||||
open class SmallEnumSquareButtonPanel<T : Enum<T>>(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class SmallEnumSquareButtonPanel<out S : AbstractContainerScreen<*>, T : Enum<T>>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
@ -393,7 +395,7 @@ open class SmallEnumSquareButtonPanel<T : Enum<T>>(
|
||||
prop: KMutableProperty0<T>,
|
||||
defaultValue: T,
|
||||
lambdaOnChange: ((newValue: T) -> Unit)? = null,
|
||||
) : EnumSquareButtonPanel<T>(screen, parent, x, y, width, height, enum, prop, defaultValue, lambdaOnChange) {
|
||||
) : EnumSquareButtonPanel<S, T>(screen, parent, x, y, width, height, enum, prop, defaultValue, lambdaOnChange) {
|
||||
final override val IDLE = Widgets8.BUTTON_IDLE
|
||||
final override val HOVERED = Widgets8.BUTTON_HOVERED
|
||||
final override val PRESSED = Widgets8.BUTTON_PRESSED
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.network.chat.Component
|
||||
import ru.dbotthepony.mc.otm.client.playGuiClickSound
|
||||
import ru.dbotthepony.mc.otm.client.render.SkinElement
|
||||
@ -9,16 +10,14 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.CheckBoxPanel.Companion.REGULAR_DIMENSIONS
|
||||
import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget
|
||||
|
||||
open class CheckBoxPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class CheckBoxPanel<out S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = REGULAR_DIMENSIONS,
|
||||
height: Float = REGULAR_DIMENSIONS
|
||||
) : EditablePanel(
|
||||
screen, parent, x, y, width, height
|
||||
) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
open var checked = false
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
@ -56,15 +55,15 @@ open class CheckBoxPanel(
|
||||
}
|
||||
}
|
||||
|
||||
open class CheckBoxInputPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class CheckBoxInputPanel<out S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
val widget: BooleanPlayerInputWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = REGULAR_DIMENSIONS + 120f,
|
||||
height: Float = REGULAR_DIMENSIONS
|
||||
) : CheckBoxPanel(screen, parent, x, y, width, height) {
|
||||
) : CheckBoxPanel<S>(screen, parent, x, y, width, height) {
|
||||
override var checked: Boolean
|
||||
get() = widget.value
|
||||
set(value) {}
|
||||
@ -76,29 +75,29 @@ open class CheckBoxInputPanel(
|
||||
}
|
||||
}
|
||||
|
||||
open class CheckBoxLabelPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class CheckBoxLabelPanel<out S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
text: Component,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = REGULAR_DIMENSIONS + 120f,
|
||||
height: Float = REGULAR_DIMENSIONS
|
||||
) : EditablePanel(screen, parent, x, y, width, height) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
val checkbox = CheckBoxPanel(screen, this, 0f, 0f, REGULAR_DIMENSIONS, REGULAR_DIMENSIONS)
|
||||
val label = Label(screen, this, REGULAR_DIMENSIONS + 4f, 4f, text = text)
|
||||
}
|
||||
|
||||
open class CheckBoxLabelInputPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class CheckBoxLabelInputPanel<out S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
widget: BooleanPlayerInputWidget,
|
||||
text: Component,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = REGULAR_DIMENSIONS + 120f,
|
||||
height: Float = REGULAR_DIMENSIONS
|
||||
) : EditablePanel(screen, parent, x, y, width, height) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
val widget get() = checkbox.widget
|
||||
val checkbox = CheckBoxInputPanel(screen, this, widget, 0f, 0f, REGULAR_DIMENSIONS, REGULAR_DIMENSIONS)
|
||||
val label = Label(screen, this, REGULAR_DIMENSIONS + 4f, 4f, text = text)
|
||||
|
@ -2,19 +2,20 @@ package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
open class DiscreteScrollBarPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
val maxScroll: (panel: DiscreteScrollBarPanel) -> Int,
|
||||
val scrollCallback: (panel: DiscreteScrollBarPanel, oldScroll: Int, newScroll: Int) -> Unit,
|
||||
open class DiscreteScrollBarPanel<S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
val maxScroll: (panel: DiscreteScrollBarPanel<S>) -> Int,
|
||||
val scrollCallback: (panel: DiscreteScrollBarPanel<S>, oldScroll: Int, newScroll: Int) -> Unit,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
height: Float = 20f
|
||||
) : EditablePanel(screen, parent, x, y, width = ScrollBarConstants.WIDTH, height = height) {
|
||||
open inner class Button : EditablePanel(screen, this@DiscreteScrollBarPanel, 1f, 1f, 12f, 15f) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width = ScrollBarConstants.WIDTH, height = height) {
|
||||
open inner class Button : EditablePanel<S>(screen, this@DiscreteScrollBarPanel, 1f, 1f, 12f, 15f) {
|
||||
var isScrolling = false
|
||||
protected set
|
||||
|
||||
|
@ -1,17 +1,16 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
|
||||
open class DraggableCanvasPanel @JvmOverloads constructor(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class DraggableCanvasPanel<out S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = 10f,
|
||||
height: Float = 10f
|
||||
) : EditablePanel(
|
||||
screen, parent, x, y, width, height
|
||||
) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
protected var dragging = false
|
||||
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
|
@ -1,19 +1,19 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import net.minecraft.client.gui.components.EditBox
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.network.chat.Component
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
|
||||
open class EditBoxPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class EditBoxPanel<out S : Screen>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = 0f,
|
||||
height: Float = 20f,
|
||||
val defaultText: Component = TextComponent("")
|
||||
) : MinecraftWidgetPanel<EditBox>(screen, parent, x, y, width, height) {
|
||||
) : MinecraftWidgetPanel<S, EditBox>(screen, parent, x, y, width, height) {
|
||||
override fun makeNew(): EditBox {
|
||||
return object : EditBox(font, 0, 0, width.toInt(), height.toInt().coerceAtMost(20), defaultText) {
|
||||
override fun isHoveredOrFocused(): Boolean {
|
||||
@ -47,8 +47,8 @@ open class EditBoxPanel(
|
||||
widget?.setFocus(new)
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(x: Double, y: Double, flag: Int): Boolean {
|
||||
super.mouseClickedInner(x, y, flag)
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
super.mouseClickedInner(x, y, button)
|
||||
requestFocus()
|
||||
return true
|
||||
}
|
||||
|
@ -6,9 +6,12 @@ import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.Font
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.render.popScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.render.pushScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
@ -40,9 +43,9 @@ interface ISlotPanel<S : Slot> {
|
||||
val slot: S
|
||||
}
|
||||
|
||||
open class EditablePanel @JvmOverloads constructor(
|
||||
val screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
val screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
|
||||
// относительно родителя
|
||||
x: Float = 0f,
|
||||
@ -51,7 +54,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
width: Float = 10f,
|
||||
height: Float = 10f,
|
||||
) : GuiEventListener {
|
||||
var parent: EditablePanel? = null
|
||||
var parent: EditablePanel<*>? = null
|
||||
set(value) {
|
||||
if (field === value)
|
||||
return
|
||||
@ -126,9 +129,8 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
var dockedHeight: Float = 0f
|
||||
private set
|
||||
|
||||
@JvmField
|
||||
protected val children = ArrayList<EditablePanel>()
|
||||
val childrenView: List<EditablePanel> = Collections.unmodifiableList(children)
|
||||
protected val children = ArrayList<EditablePanel<*>>()
|
||||
val childrenView: List<EditablePanel<*>> = Collections.unmodifiableList(children)
|
||||
|
||||
var layoutInvalidated = true
|
||||
private set
|
||||
@ -324,7 +326,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
accumulatedDepth += value
|
||||
}
|
||||
|
||||
val font: Font get() = screen.font
|
||||
val font: Font get() = if (screen is MatteryScreen<*>) screen.font else minecraft.font
|
||||
|
||||
fun invalidateLayout() {
|
||||
layoutInvalidated = true
|
||||
@ -348,14 +350,14 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
this.parent = parent
|
||||
}
|
||||
|
||||
private fun onParent(child: EditablePanel) {
|
||||
private fun onParent(child: EditablePanel<*>) {
|
||||
if (children.contains(child)) throw IllegalStateException("Already containing $child")
|
||||
children.add(child)
|
||||
layoutInvalidated = true
|
||||
updateVisible()
|
||||
}
|
||||
|
||||
private fun onUnParent(child: EditablePanel) {
|
||||
private fun onUnParent(child: EditablePanel<*>) {
|
||||
val indexOf = children.indexOf(child)
|
||||
if (indexOf == -1) throw IllegalStateException("Already not containing $child")
|
||||
children.removeAt(indexOf)
|
||||
@ -526,7 +528,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
listOf(tooltip),
|
||||
mouse_x.toInt(),
|
||||
mouse_y.toInt(),
|
||||
screen.font
|
||||
font
|
||||
)
|
||||
|
||||
return true
|
||||
@ -536,7 +538,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
tooltipList,
|
||||
mouse_x.toInt(),
|
||||
mouse_y.toInt(),
|
||||
screen.font
|
||||
font
|
||||
)
|
||||
|
||||
return true
|
||||
@ -572,8 +574,8 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
return ScreenPos((_x - pos.x).toFloat(), (_y - pos.y).toFloat())
|
||||
}
|
||||
|
||||
fun findRoot(): EditablePanel? {
|
||||
var parent: EditablePanel? = this.parent ?: return null
|
||||
fun findRoot(): EditablePanel<*>? {
|
||||
var parent: EditablePanel<*>? = this.parent ?: return null
|
||||
|
||||
while (true) {
|
||||
val parent2 = parent!!.parent
|
||||
@ -586,7 +588,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun findAbsoluteRoot(): EditablePanel {
|
||||
fun findAbsoluteRoot(): EditablePanel<*> {
|
||||
return findRoot() ?: this
|
||||
}
|
||||
|
||||
@ -779,7 +781,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun findHierarchicalFocus(): EditablePanel? {
|
||||
fun findHierarchicalFocus(): EditablePanel<*>? {
|
||||
if (isFocused) {
|
||||
return this
|
||||
}
|
||||
@ -876,20 +878,12 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
setSize(w, h)
|
||||
}
|
||||
|
||||
fun fetchChildren(): List<EditablePanel> {
|
||||
fun fetchChildren(): List<EditablePanel<*>> {
|
||||
return ImmutableList.copyOf(children)
|
||||
}
|
||||
|
||||
fun getUndockedChildren(): List<EditablePanel> {
|
||||
var count = 0
|
||||
|
||||
for (child in children) {
|
||||
if (child.dock == Dock.NONE) {
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
||||
val list = ArrayList<EditablePanel>(count)
|
||||
fun getUndockedChildren(): List<EditablePanel<*>> {
|
||||
val list = LinkedList<EditablePanel<*>>()
|
||||
|
||||
for (child in children) {
|
||||
if (child.dock == Dock.NONE) {
|
||||
@ -900,7 +894,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
return list
|
||||
}
|
||||
|
||||
operator fun get(index: Int): EditablePanel? {
|
||||
operator fun get(index: Int): EditablePanel<*>? {
|
||||
if (index < 0 || index >= children.size) return null
|
||||
return children[index]
|
||||
}
|
||||
@ -937,7 +931,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
return pos.x <= x && pos.x + boundingWidth > x && pos.y <= y && pos.y + boundingHeight > y
|
||||
}
|
||||
|
||||
fun killFocusForEverythingExcept(except: EditablePanel) {
|
||||
fun killFocusForEverythingExcept(except: EditablePanel<*>) {
|
||||
for (child in children) {
|
||||
if (child !== except) {
|
||||
child.killFocusForEverythingExceptInner()
|
||||
@ -974,7 +968,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (isTrappingMouseInput() || withinBounds(x, y)) {
|
||||
if (acceptMouseInput && parent == null) screen.popup(this)
|
||||
if (acceptMouseInput && parent == null) popup()
|
||||
return mouseClicked(x, y, button)
|
||||
} else if (withinExtendedBounds(x, y)) {
|
||||
for (child in children) {
|
||||
@ -1181,12 +1175,12 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
protected open fun onRemoved() {}
|
||||
|
||||
fun remove() {
|
||||
if (isRemoved) {
|
||||
if (isRemoved || screen !is MatteryScreen<*>) {
|
||||
return
|
||||
}
|
||||
|
||||
killFocus()
|
||||
screen.removePanel(this)
|
||||
screen.removePanel(this as EditablePanel<MatteryScreen<*>>)
|
||||
|
||||
for (child in children) {
|
||||
child.remove()
|
||||
@ -1196,7 +1190,13 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
isRemoved = true
|
||||
}
|
||||
|
||||
fun asGrid(): FlexGridPanel {
|
||||
fun popup() {
|
||||
if (screen is MatteryScreen<*>) {
|
||||
screen.popup(this as EditablePanel<MatteryScreen<*>>)
|
||||
}
|
||||
}
|
||||
|
||||
fun asGrid(): FlexGridPanel<*> {
|
||||
val grid = FlexGridPanel(screen, parent, x, y, width, height)
|
||||
parent = grid
|
||||
grid.dock = dock
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
@ -22,16 +23,16 @@ private fun calculateScale(width: Float, height: Float): Int {
|
||||
}
|
||||
}
|
||||
|
||||
class EntityRendererPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
val entity: LivingEntity,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = ENTITY_RECTANGLE.w,
|
||||
height: Float = ENTITY_RECTANGLE.h,
|
||||
var renderScale: Int = calculateScale(width, height)
|
||||
) : EditablePanel(screen, parent, x, y, width, height) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
ExoSuitInventoryScreen.ENTITY_RECTANGLE.render(stack)
|
||||
|
||||
|
@ -1,20 +1,21 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot
|
||||
import ru.dbotthepony.mc.otm.container.ItemFilterSlotPacket
|
||||
import ru.dbotthepony.mc.otm.network.MenuNetworkChannel
|
||||
|
||||
open class FilterSlotPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class FilterSlotPanel<out S : MatteryScreen<*>> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
val slot: ItemFilterNetworkSlot,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
height: Float = SIZE
|
||||
) : AbstractSlotPanel(screen, parent, x, y, width, height) {
|
||||
) : AbstractSlotPanel<S>(screen, parent, x, y, width, height) {
|
||||
override fun getItemStack(): ItemStack {
|
||||
return slot.get()
|
||||
}
|
||||
|
@ -5,29 +5,31 @@ import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.narration.NarratableEntry
|
||||
import net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import net.minecraft.network.chat.Component
|
||||
import org.lwjgl.opengl.GL30
|
||||
import ru.dbotthepony.mc.otm.client.playGuiClickSound
|
||||
import ru.dbotthepony.mc.otm.client.render.*
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
|
||||
open class FramePanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class FramePanel<out S : Screen>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float,
|
||||
y: Float,
|
||||
width: Float,
|
||||
height: Float,
|
||||
protected var title: Component
|
||||
) : EditablePanel(screen, parent, x, y, width, height), NarratableEntry {
|
||||
constructor(screen: MatteryScreen<*>, width: Float, height: Float, title: Component) : this(screen, null, 0f, 0f, width, height, title)
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height), NarratableEntry {
|
||||
constructor(screen: S, width: Float, height: Float, title: Component) : this(screen, null, 0f, 0f, width, height, title)
|
||||
|
||||
open inner class Tab(
|
||||
var onOpen: Runnable? = null,
|
||||
var onClose: Runnable? = null,
|
||||
var activeIcon: SkinElement? = null,
|
||||
var inactiveIcon: SkinElement? = null,
|
||||
) : EditablePanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) {
|
||||
) : EditablePanel<S>(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) {
|
||||
var isActive = tabs.isEmpty()
|
||||
var initial = false
|
||||
|
||||
@ -35,7 +37,7 @@ open class FramePanel(
|
||||
tabs.add(this)
|
||||
}
|
||||
|
||||
fun showHidePanels(input: List<EditablePanel>) {
|
||||
fun showHidePanels(input: List<EditablePanel<*>>) {
|
||||
onOpen = Runnable {
|
||||
for (child in input) {
|
||||
child.visible = true
|
||||
@ -120,7 +122,7 @@ open class FramePanel(
|
||||
}
|
||||
}
|
||||
|
||||
protected val tabs = ArrayList<Tab>()
|
||||
protected val tabs: java.util.ArrayList<Tab> = ArrayList()
|
||||
|
||||
override fun performLayout() {
|
||||
for ((i, tab) in tabs.withIndex()) {
|
||||
@ -173,7 +175,7 @@ open class FramePanel(
|
||||
|
||||
// title
|
||||
RenderSystem.depthFunc(GL30.GL_ALWAYS)
|
||||
screen.font.draw(stack, title, 8f, 5f, 4210752)
|
||||
font.draw(stack, title, 8f, 5f, 4210752)
|
||||
RenderSystem.depthFunc(GL30.GL_ALWAYS)
|
||||
}
|
||||
|
||||
@ -188,9 +190,9 @@ open class FramePanel(
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun padded(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
fun <S : Screen> padded(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float,
|
||||
y: Float,
|
||||
width: Float,
|
||||
@ -198,9 +200,9 @@ open class FramePanel(
|
||||
title: Component
|
||||
) = FramePanel(screen, parent, x, y, width + PADDING * 2, height + PADDING_TOP + PADDING, title)
|
||||
|
||||
fun padded(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
fun <S : Screen> padded(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
width: Float,
|
||||
height: Float,
|
||||
title: Component
|
||||
|
@ -1,17 +1,18 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
|
||||
open class GridPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class GridPanel<out S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float,
|
||||
height: Float,
|
||||
protected var columns: Int,
|
||||
protected var rows: Int
|
||||
) : EditablePanel(screen, parent, x, y, width, height) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
override fun performLayout() {
|
||||
var currentX = 0f
|
||||
var currentY = 0f
|
||||
|
@ -1,22 +1,23 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.network.chat.Component
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.core.RGBAColor
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
|
||||
open class Label @JvmOverloads constructor(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class Label<out S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = 100f,
|
||||
height: Float = 10f,
|
||||
var text: Component = TextComponent("Label"),
|
||||
var shadow: Boolean = false
|
||||
) : EditablePanel(screen, parent, x, y, width, height) {
|
||||
constructor(screen: MatteryScreen<*>, parent: EditablePanel?, text: Component, shadow: Boolean = false) : this(screen, parent, x = 0f, text = text, shadow = shadow)
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
constructor(screen: S, parent: EditablePanel<*>?, text: Component, shadow: Boolean = false) : this(screen, parent, x = 0f, text = text, shadow = shadow)
|
||||
|
||||
var shadowX = 0.75f
|
||||
var shadowY = 0.75f
|
||||
|
@ -3,17 +3,19 @@ package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.components.AbstractWidget
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import org.lwjgl.opengl.GL11
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
|
||||
abstract class MinecraftWidgetPanel<T : AbstractWidget>(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
abstract class MinecraftWidgetPanel<out S : Screen, T : AbstractWidget>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
x: Float,
|
||||
y: Float,
|
||||
width: Float,
|
||||
height: Float
|
||||
) : EditablePanel(screen, parent, x, y, width, height) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
var widget: T? = null
|
||||
protected set
|
||||
|
||||
|
@ -1,21 +1,22 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.network.chat.Component
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.menu.widget.NumberPlayerInputWidget
|
||||
import java.math.BigDecimal
|
||||
|
||||
open class NumberInputPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class NumberInputPanel<out S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
val inputWidget: NumberPlayerInputWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = 0f,
|
||||
height: Float = 20f,
|
||||
defaultText: Component = TextComponent("")
|
||||
) : EditBoxPanel(screen, parent, x, y, width, height, defaultText) {
|
||||
) : EditBoxPanel<S>(screen, parent, x, y, width, height, defaultText) {
|
||||
protected var nextUpdateFromServer = 0L
|
||||
protected var inputStr = ""
|
||||
|
||||
|
@ -6,6 +6,7 @@ import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.client.gui.GuiComponent
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import net.minecraft.client.renderer.GameRenderer
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu
|
||||
import net.minecraft.world.inventory.Slot
|
||||
@ -18,16 +19,16 @@ import ru.dbotthepony.mc.otm.client.render.setDrawColor
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import javax.annotation.Nonnull
|
||||
|
||||
open class SlotPanel<T : Slot>(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
open class SlotPanel<out S : MatteryScreen<*>, T : Slot> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
final override val slot: T,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = AbstractSlotPanel.SIZE,
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
width: Float = SIZE,
|
||||
height: Float = SIZE,
|
||||
noItemIcon: SkinElement? = null
|
||||
) : AbstractSlotPanel(screen, parent, x, y, width, height, noItemIcon), ISlotPanel<T> {
|
||||
) : AbstractSlotPanel<S>(screen, parent, x, y, width, height, noItemIcon), ISlotPanel<T> {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
screen.returnSlot = slot
|
||||
return true
|
||||
@ -114,9 +115,9 @@ open class SlotPanel<T : Slot>(
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Slot> BatterySlotPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
fun <S : MatteryScreen<*>, T : Slot> BatterySlotPanel(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
slot: T,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
@ -124,9 +125,9 @@ fun <T : Slot> BatterySlotPanel(
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.BATTERY_SLOT_BACKGROUND)
|
||||
|
||||
fun <T : Slot> EquipmentBatterySlotPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
fun <S : MatteryScreen<*>, T : Slot> EquipmentBatterySlotPanel(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
slot: T,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
@ -134,9 +135,9 @@ fun <T : Slot> EquipmentBatterySlotPanel(
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.EQUIPMENT_BATTERY_SLOT_BACKGROUND)
|
||||
|
||||
fun <T : Slot> PatternSlotPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
fun <S : MatteryScreen<*>, T : Slot> PatternSlotPanel(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
slot: T,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
@ -144,9 +145,9 @@ fun <T : Slot> PatternSlotPanel(
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.PATTERN_SLOT_BACKGROUND)
|
||||
|
||||
fun <T : Slot> MatterCapacitorSlotPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel?,
|
||||
fun <S : MatteryScreen<*>, T : Slot> MatterCapacitorSlotPanel(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
slot: T,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.widget
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
||||
import ru.dbotthepony.mc.otm.client.render.element
|
||||
@ -8,15 +9,15 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
|
||||
open class HorizontalPowerGaugePanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
open class HorizontalPowerGaugePanel<out S : Screen>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>? = null,
|
||||
widget: LevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = GAUGE_BACKGROUND.w,
|
||||
height: Float = GAUGE_BACKGROUND.h
|
||||
) : PowerGaugePanel(screen, parent, widget, x, y, width, height) {
|
||||
) : PowerGaugePanel<S>(screen, parent, widget, x, y, width, height) {
|
||||
var flop = false
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
@ -55,9 +56,9 @@ open class HorizontalPowerGaugePanel(
|
||||
/**
|
||||
* Shortcut to [HorizontalPowerGaugePanel] with doubled height
|
||||
*/
|
||||
fun TallHorizontalPowerGaugePanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
fun <S : Screen> TallHorizontalPowerGaugePanel(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>? = null,
|
||||
widget: LevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
|
@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.BufferUploader
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.blaze3d.vertex.VertexFormat
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.renderer.GameRenderer
|
||||
import net.minecraft.network.chat.Component
|
||||
import org.lwjgl.opengl.GL11
|
||||
@ -19,13 +20,13 @@ import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
open class MatterGaugePanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
open class MatterGaugePanel<S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>? = null,
|
||||
val widget: LevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f
|
||||
): EditablePanel(screen, parent, x, y, width = GAUGE_BACKGROUND.w, height = GAUGE_BACKGROUND.h) {
|
||||
): EditablePanel<S>(screen, parent, x, y, width = GAUGE_BACKGROUND.w, height = GAUGE_BACKGROUND.h) {
|
||||
init {
|
||||
scissor = true
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.widget
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.network.chat.Component
|
||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
||||
@ -10,13 +11,13 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
|
||||
open class PatternGaugePanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
open class PatternGaugePanel<S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>? = null,
|
||||
val widget: LevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f
|
||||
): EditablePanel(screen, parent, x, y, width = GAUGE_BACKGROUND.w, height = GAUGE_BACKGROUND.h) {
|
||||
): EditablePanel<S>(screen, parent, x, y, width = GAUGE_BACKGROUND.w, height = GAUGE_BACKGROUND.h) {
|
||||
init {
|
||||
scissor = true
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.widget
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.network.chat.Component
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.client.render.*
|
||||
@ -9,15 +10,15 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import ru.dbotthepony.mc.otm.core.formatPowerLevel
|
||||
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
|
||||
open class PowerGaugePanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
open class PowerGaugePanel<out S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>? = null,
|
||||
val widget: LevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = GAUGE_BACKGROUND.w,
|
||||
height: Float = GAUGE_BACKGROUND.h
|
||||
) : EditablePanel(screen, parent, x, y, width, height) {
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
init {
|
||||
scissor = true
|
||||
}
|
||||
@ -72,9 +73,9 @@ open class PowerGaugePanel(
|
||||
/**
|
||||
* Shortcut to [PowerGaugePanel] with doubled width
|
||||
*/
|
||||
fun WidePowerGaugePanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
fun <S : Screen> WidePowerGaugePanel(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>? = null,
|
||||
widget: LevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
|
@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.widget
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.network.chat.Component
|
||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
||||
@ -12,13 +13,13 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
||||
|
||||
open class ProgressGaugePanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
open class ProgressGaugePanel<S : Screen> @JvmOverloads constructor(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>? = null,
|
||||
val widget: ProgressGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f
|
||||
): EditablePanel(screen, parent, x, y, width = GAUGE_BACKGROUND.w, height = GAUGE_BACKGROUND.h) {
|
||||
): EditablePanel<S>(screen, parent, x, y, width = GAUGE_BACKGROUND.w, height = GAUGE_BACKGROUND.h) {
|
||||
init {
|
||||
scissor = true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user