Checkboxes!
This commit is contained in:
parent
aa6f28977b
commit
813a6f0ceb
@ -1,7 +1,9 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen
|
||||
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.CheckBoxLabelInputPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.FilterSlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel
|
||||
@ -23,6 +25,8 @@ class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Compon
|
||||
}
|
||||
}
|
||||
|
||||
CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f)
|
||||
|
||||
return frame
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,104 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.sounds.SoundEvents
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.render.SkinElement
|
||||
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?,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = REGULAR_DIMENSIONS,
|
||||
height: Float = REGULAR_DIMENSIONS
|
||||
) : EditablePanel(
|
||||
screen, parent, x, y, width, height
|
||||
) {
|
||||
open var checked = false
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
if (checked) {
|
||||
CHECKBOX_CHECKED.render(stack)
|
||||
} else {
|
||||
CHECKBOX_UNCHECKED.render(stack)
|
||||
}
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
checked = !checked
|
||||
minecraft.soundManager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0f))
|
||||
return true
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val REGULAR_DIMENSIONS = 15f
|
||||
|
||||
val CHECKBOX_UNCHECKED = SkinElement(
|
||||
image_x = 18f,
|
||||
image_y = 65f,
|
||||
rect_w = REGULAR_DIMENSIONS,
|
||||
rect_h = REGULAR_DIMENSIONS,
|
||||
)
|
||||
|
||||
val CHECKBOX_CHECKED = SkinElement(
|
||||
image_x = 18f,
|
||||
image_y = 80f,
|
||||
rect_w = REGULAR_DIMENSIONS,
|
||||
rect_h = REGULAR_DIMENSIONS,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
open class CheckBoxInputPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
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) {
|
||||
override var checked: Boolean
|
||||
get() = widget.value
|
||||
set(value) {}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
super.mouseClickedInner(mouse_x, mouse_y, mouse_click_type)
|
||||
widget.userInput(!checked)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
open class CheckBoxLabelPanel(
|
||||
screen: MatteryScreen<*>,
|
||||
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) {
|
||||
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?,
|
||||
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) {
|
||||
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)
|
||||
}
|
@ -31,6 +31,8 @@
|
||||
"otm.gui.matter.format_and_complexity": "%s / Complexity: %s",
|
||||
"otm.gui.matter.name": "MtU",
|
||||
|
||||
"otm.gui.filter.is_whitelist": "Is Whitelist",
|
||||
|
||||
"otm.gui.android_research": "Research Tree",
|
||||
|
||||
"otm.gui.pattern.percentage_level": "Fill level: %s%%",
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.7 KiB |
BIN
src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.xcf
(Stored with Git LFS)
BIN
src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.xcf
(Stored with Git LFS)
Binary file not shown.
Loading…
Reference in New Issue
Block a user