diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt index 454d3c515..e976385e3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt @@ -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 } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/CheckBox.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/CheckBox.kt new file mode 100644 index 000000000..6bbd5e6d8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/CheckBox.kt @@ -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) +} diff --git a/src/main/resources/assets/overdrive_that_matters/lang/en_us.json b/src/main/resources/assets/overdrive_that_matters/lang/en_us.json index 8a8da36ff..6a577c848 100644 --- a/src/main/resources/assets/overdrive_that_matters/lang/en_us.json +++ b/src/main/resources/assets/overdrive_that_matters/lang/en_us.json @@ -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%%", diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.png index f9eb592ea..86ed9c540 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.xcf index 53a067a3a..515415ca1 100644 --- a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.xcf +++ b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.xcf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0a5231c06b10616b3fd29a6a303539aa1007f120391df2783185cb74b979675e -size 27255 +oid sha256:289e6665dcc783a0b712a41470d3ae4a41e65a0e2b8c643f995415258cecdce8 +size 29982