diff --git a/src/main/resources/assets/opencomputers/textures/gui/robot_selection.png b/src/main/resources/assets/opencomputers/textures/gui/sprites/robot_selection.png similarity index 100% rename from src/main/resources/assets/opencomputers/textures/gui/robot_selection.png rename to src/main/resources/assets/opencomputers/textures/gui/sprites/robot_selection.png diff --git a/src/main/resources/assets/opencomputers/textures/gui/sprites/robot_selection.png.mcmeta b/src/main/resources/assets/opencomputers/textures/gui/sprites/robot_selection.png.mcmeta new file mode 100644 index 0000000000..a76de3a0a4 --- /dev/null +++ b/src/main/resources/assets/opencomputers/textures/gui/sprites/robot_selection.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {"frametime": 1} +} diff --git a/src/main/scala/li/cil/oc/client/Textures.scala b/src/main/scala/li/cil/oc/client/Textures.scala index e863fd610a..665dbc673d 100644 --- a/src/main/scala/li/cil/oc/client/Textures.scala +++ b/src/main/scala/li/cil/oc/client/Textures.scala @@ -45,7 +45,6 @@ object Textures { val Robot = L("robot") val RobotAssembler = L("robot_assembler") val RobotNoScreen = L("robot_noscreen") - val RobotSelection = L("robot_selection") val Server = L("server") val Slot = L("slot") val Waypoint = L("waypoint") @@ -58,11 +57,12 @@ object Textures { val Bar: ResourceLocation = L("bar") val KeyboardMissing: ResourceLocation = L("keyboard_missing") + val ManualMissingItem = L("manual_missing_item") val PrinterInk: ResourceLocation = L("printer_ink") val PrinterMaterial: ResourceLocation = L("printer_material") val PrinterProgress: ResourceLocation = L("printer_progress") + val RobotSelection: ResourceLocation = L("robot_selection") val UpgradeTab: ResourceLocation = L("upgrade_tab") - val ManualMissingItem = L("manual_missing_item") val ButtonDriveMode: WidgetSprites = new WidgetSprites(L("button_drive_mode"), L("button_drive_mode_disabled"), L("button_drive_mode_highlight")) val ButtonPower: WidgetSprites = new WidgetSprites( diff --git a/src/main/scala/li/cil/oc/client/gui/Drone.scala b/src/main/scala/li/cil/oc/client/gui/Drone.scala index cf99f6e485..639fc392f4 100644 --- a/src/main/scala/li/cil/oc/client/gui/Drone.scala +++ b/src/main/scala/li/cil/oc/client/gui/Drone.scala @@ -1,7 +1,6 @@ package li.cil.oc.client.gui import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.{BufferUploader, DefaultVertexFormat, Tesselator, VertexFormat} import li.cil.oc.Localization import li.cil.oc.client.{Textures, PacketSender => ClientPacketSender} import li.cil.oc.client.gui.widget.ProgressBar @@ -47,8 +46,6 @@ class Drone(state: menu.Drone, playerInventory: Inventory, name: Component) private var power: ProgressBar = _ private val selectionSize = 20 - private val selectionsStates = 17 - private val selectionStepV = 1 / selectionsStates.toFloat override protected def init(): Unit = { super.init() @@ -109,22 +106,13 @@ class Drone(state: menu.Drone, playerInventory: Inventory, name: Component) override protected def drawSlotBackground(graphics: GuiGraphics, x: Int, y: Int): Unit = {} private def drawSelection(graphics: GuiGraphics): Unit = { - val stack = graphics.pose() val slot = inventoryContainer.selectedSlot if (slot >= 0 && slot < 16) { - Textures.bind(Textures.GUI.RobotSelection) - val now = System.currentTimeMillis() % 1000 / 1000.0f - val offsetV = (now * selectionsStates).toInt * selectionStepV val x = leftPos + inventoryX - 1 + (slot % 4) * (selectionSize - 2) val y = topPos + inventoryY - 1 + (slot / 4) * (selectionSize - 2) - - val t = Tesselator.getInstance - val r = t.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX) - r.addVertex(stack.last.pose(), x.toFloat, y.toFloat, 0f).setUv(0f, offsetV) - r.addVertex(stack.last.pose(), x.toFloat, (y + selectionSize).toFloat, 0f).setUv(0f, offsetV + selectionStepV) - r.addVertex(stack.last.pose(), (x + selectionSize).toFloat, (y + selectionSize).toFloat, 0f).setUv(1f, offsetV + selectionStepV) - r.addVertex(stack.last.pose(), (x + selectionSize).toFloat, y.toFloat, 0f).setUv(1f, offsetV) - BufferUploader.drawWithShader(r.buildOrThrow()) + RenderSystem.enableBlend() + graphics.blitSprite(Textures.GUISprites.RobotSelection, x, y, selectionSize, selectionSize) + RenderSystem.disableBlend() } } } diff --git a/src/main/scala/li/cil/oc/client/gui/Robot.scala b/src/main/scala/li/cil/oc/client/gui/Robot.scala index f6a44644aa..42db8e6bfa 100644 --- a/src/main/scala/li/cil/oc/client/gui/Robot.scala +++ b/src/main/scala/li/cil/oc/client/gui/Robot.scala @@ -1,7 +1,7 @@ package li.cil.oc.client.gui import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.{BufferUploader, DefaultVertexFormat, PoseStack, Tesselator, VertexFormat} +import com.mojang.blaze3d.vertex.PoseStack import li.cil.oc.{Localization, Settings} import li.cil.oc.api.internal.TextBuffer import li.cil.oc.client.{ComponentTracker, Textures, PacketSender => ClientPacketSender} @@ -77,8 +77,6 @@ class Robot(state: menu.Robot, playerInventory: Inventory, name: Component) private var power: ProgressBar = _ private val selectionSize = 20 - private val selectionsStates = 17 - private val selectionStepV = 1 / selectionsStates.toFloat override protected def init(): Unit = { super.init() @@ -156,7 +154,7 @@ class Robot(state: menu.Robot, playerInventory: Inventory, name: Component) graphics.blit(if (buffer != null) Textures.GUI.Robot else Textures.GUI.RobotNoScreen, leftPos, topPos, 0, 0, imageWidth, imageHeight) if (inventoryContainer.info.mainInvSize > 0) { - drawSelection(graphics.pose) + drawSelection(graphics) } drawInventorySlots(graphics) @@ -239,22 +237,14 @@ class Robot(state: menu.Robot, playerInventory: Inventory, name: Component) math.min(scaleX, scaleY) } - private def drawSelection(stack: PoseStack): Unit = { + private def drawSelection(graphics: GuiGraphics): Unit = { val slot = inventoryContainer.selectedSlot - inventoryOffset * 4 if (slot >= 0 && slot < 16) { - Textures.bind(Textures.GUI.RobotSelection) - val now = System.currentTimeMillis() % 1000 / 1000.0f - val offsetV = (now * selectionsStates).toInt * selectionStepV val x = leftPos + inventoryX - 1 + (slot % 4) * (selectionSize - 2) val y = topPos + inventoryY - 1 + (slot / 4) * (selectionSize - 2) - - val t = Tesselator.getInstance - val r = t.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX) - r.addVertex(stack.last.pose(), x.toFloat, y.toFloat, 0f).setUv(0f, offsetV) - r.addVertex(stack.last.pose(), x.toFloat, (y + selectionSize).toFloat, 0f).setUv(0f, offsetV + selectionStepV) - r.addVertex(stack.last.pose(), (x + selectionSize).toFloat, (y + selectionSize).toFloat, 0f).setUv(1f, offsetV + selectionStepV) - r.addVertex(stack.last.pose(), (x + selectionSize).toFloat, y.toFloat, 0f).setUv(1f, offsetV) - BufferUploader.drawWithShader(r.buildOrThrow()) + RenderSystem.enableBlend() + graphics.blitSprite(Textures.GUISprites.RobotSelection, x, y, selectionSize, selectionSize) + RenderSystem.disableBlend() } } }