# Conflicts:
#	src/main/kotlin/org/neoflock/neocomputers/gui/screen/CaseScreen.kt
This commit is contained in:
2026-04-21 20:53:45 +02:00
7 changed files with 57 additions and 37 deletions

View File

@@ -24,15 +24,19 @@ import kotlin.math.ceil
// #66CC66
object ProgressBar { // TODO: variable length
object ProgressBar {
val BAR: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/bar.png")
// NOTE: OC never uses a different width and height, changing height is not recommended
// NOTE: OC never uses a different width and height
fun render(guiGraphics: GuiGraphics, x: Int, y: Int, value: Long, max: Long, mouseX: Int, mouseY: Int, width: Int=142, height: Int=14, tooltipfunc: (Int) -> String?) {
guiGraphics.blit(BAR, x, y, 1, height, 0F, 0F, 1, 14, 3, 14)
guiGraphics.blit(BAR, x+1, y, width-2, height, 1F, 0F, 1, 14, 3, 14)
guiGraphics.blit(BAR, x+width-1, y, 1, height, 2F, 0F, 1, 14, 3, 14)
RenderSystem.disableBlend()
guiGraphics.fill(x, y, x+width-1, y+1, 0xFF373737.toInt()) // top left corner + top edge
guiGraphics.fill(x, y+1, x+1, y+height-1, 0xFF373737.toInt()) // left edge
guiGraphics.fill(x, y+height-1, x+1, y+height, 0xFF8B8B8B.toInt()) // bottom left corner
guiGraphics.fill(x+width-1, y, x+width, y+1, 0xFF8B8B8B.toInt()) // top right corner
guiGraphics.fill(x+1, y+height-1, x+width, y+height, 0xFFFFFFFF.toInt()) // bottom right corner + bottom edge
guiGraphics.fill(x+width-1, y+height-1, x+width, y+1, 0xFFFFFFFF.toInt()) // right edge
val frac = if(max == 0L) 0.0f else value.toFloat() / max.toFloat()
val linew = ceil(frac*(width-2).toFloat())

View File

@@ -7,7 +7,6 @@ import com.mojang.blaze3d.vertex.VertexFormat
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.components.ImageButton
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
import net.minecraft.network.FriendlyByteBuf
import net.minecraft.network.chat.Component
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.entity.player.Inventory
@@ -19,28 +18,8 @@ import org.neoflock.neocomputers.utils.GenericContainerScreen
class CaseScreen : GenericContainerScreen<CaseMenu> {
private val PCB: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/computer.png")
private val POWER_ATLAS: ResourceLocation = ResourceLocation.fromNamespaceAndPath(NeoComputers.MODID, "textures/gui/button_power.png")
private val BTN_SIZE = 18
override fun shouldCenterTitle(): Boolean = false
var isOn = false
var energy = 0L
var energyTotal = 0L
var memUsed = 0L
var memTotal = 0L
var compUsed = 0L
var compTotal = 0L
override fun processScreenStatePacket(buf: FriendlyByteBuf) {
isOn = buf.readBoolean()
energy = buf.readLong()
energyTotal = buf.readLong()
memUsed = buf.readLong()
memTotal = buf.readLong()
compUsed = buf.readLong()
compTotal = buf.readLong()
}
constructor(abstractContainerMenu: CaseMenu, inventory: Inventory, component: Component) : super(abstractContainerMenu, inventory, component)
override fun renderBg(guiGraphics: GuiGraphics, f: Float, i: Int, j: Int) {
@@ -54,14 +33,6 @@ class CaseScreen : GenericContainerScreen<CaseMenu> {
}
override fun renderCustomOverlay(graphics: GuiGraphics, mouseX: Int, mouseY: Int, blend: Float) {
super.renderCustomOverlay(graphics, mouseX, mouseY, blend)
val relX = (this.width - this.imageWidth) / 2
val relY = (this.height - this.imageHeight) / 2
graphics.blit(POWER_ATLAS, relX, relY, BTN_SIZE, BTN_SIZE, 0.5f, 0.5f, BTN_SIZE, BTN_SIZE, BTN_SIZE*2, BTN_SIZE*2)
}
// private fun renderSlots(relX: Int, relY: Int) { // TODO: put this in some generic screen class
// for (slot in menu.slots) {
// if (slot is DynamicSlot) {

View File

@@ -0,0 +1,27 @@
package org.neoflock.neocomputers.gui.widget
import net.minecraft.client.gui.Gui
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.components.Button
import net.minecraft.network.chat.Component
import net.minecraft.resources.ResourceLocation
import org.neoflock.neocomputers.NeoComputers
data class ButtonSprites(val sheet: ResourceLocation, val spriteWidth: Int, val spriteHeight: Int, val texWidth: Int, val texHeight: Int)
// minecraft sux
class ImagerButton(x: Int, y: Int, width: Int, height: Int, val sprites: ButtonSprites, onPress: Button.OnPress) : Button(x, y, width, height, Component.literal(""), onPress, DEFAULT_NARRATION) {
// public void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) {
// ResourceLocation resourceLocation = this.sprites.get(this.isActive(), this.isHoveredOrFocused());
// guiGraphics.blitSprite(resourceLocation, this.getX(), this.getY(), this.width, this.height);
// }
var pressed = false
override fun renderWidget(graphics: GuiGraphics, mouseX: Int, mouseY: Int, delta: Float) {
val u = if (pressed) 18F else 0F // no clue why it's swapped? prob cooked the coordinates, we gotta get parchment so bad
val v = if (this.isHoveredOrFocused) 18F else 0F
graphics.blit(sprites.sheet, x, y, width, height, u, v, sprites.spriteWidth, sprites.spriteHeight, sprites.texWidth, sprites.texHeight)
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB