Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"animation": {"frametime": 1}
}
4 changes: 2 additions & 2 deletions src/main/scala/li/cil/oc/client/Textures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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(
Expand Down
18 changes: 3 additions & 15 deletions src/main/scala/li/cil/oc/client/gui/Drone.scala
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
}
}
}
22 changes: 6 additions & 16 deletions src/main/scala/li/cil/oc/client/gui/Robot.scala
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
}
}
}
Loading