diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 830d1e3da..a7f6ddbfc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -28,7 +28,7 @@ import java.util.* import kotlin.math.ceil object MatteryGUI { - private val BARS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "player_bars"), 80f, 36f) + private val BARS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/player_bars.png"), 80f, 35f) val CHARGE = BARS.subElement(height = 9f) val CHARGE_BG = BARS.subElement(y = 9f, height = 9f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt index af06604b7..02435dc3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt @@ -2,13 +2,20 @@ package ru.dbotthepony.mc.otm.client.render import com.google.gson.JsonObject import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexConsumer +import com.mojang.blaze3d.vertex.VertexFormat +import net.minecraft.client.renderer.GameRenderer +import net.minecraft.client.renderer.RenderStateShard +import net.minecraft.client.renderer.RenderType import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation +import org.lwjgl.opengl.GL11.GL_ALWAYS import ru.dbotthepony.mc.otm.core.RGBAColor import ru.dbotthepony.mc.otm.core.linearInterpolation import java.lang.ref.WeakReference +import java.util.concurrent.ConcurrentHashMap sealed class AbstractMatterySprite { /** @@ -305,4 +312,84 @@ sealed class AbstractMatterySprite { fun toNetwork(buff: FriendlyByteBuf) { type.toActualNetwork(this, buff) } + + + val renderTypeNoDepth by lazy { + noDepthCache.computeIfAbsent(texture) { + val builder = RenderType.CompositeState.builder() + + builder.setTextureState(RenderStateShard.TextureStateShard(it, false, false)) + builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) + builder.setDepthTestState(RenderStateShard.DepthTestStateShard("always", GL_ALWAYS)) + builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() + }, { + RenderSystem.disableBlend() + })) + + @Suppress("INACCESSIBLE_TYPE") + RenderType.create("otm_gui_element_no_depth", + DefaultVertexFormat.POSITION_COLOR_TEX, + VertexFormat.Mode.QUADS, + 2048, + false, + false, + builder.createCompositeState(false)) as RenderType + } + } + + val renderTypeDepth by lazy { + depthCache.computeIfAbsent(texture) { + val builder = RenderType.CompositeState.builder() + + builder.setTextureState(RenderStateShard.TextureStateShard(it, false, false)) + builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) + builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() + }, { + RenderSystem.disableBlend() + })) + + @Suppress("INACCESSIBLE_TYPE") + RenderType.create("otm_gui_element_depth", + DefaultVertexFormat.POSITION_COLOR_TEX, + VertexFormat.Mode.QUADS, + 2048, + false, + false, + builder.createCompositeState(false)) as RenderType + } + } + + val renderTypeWorld by lazy { + worldCache.computeIfAbsent(texture) { + val builder = RenderType.CompositeState.builder() + + builder.setTextureState(RenderStateShard.TextureStateShard(it, false, false)) + builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) + builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() + }, { + RenderSystem.disableBlend() + })) + + @Suppress("INACCESSIBLE_TYPE") + RenderType.create("otm_gui_element_world", + DefaultVertexFormat.POSITION_COLOR_TEX, + VertexFormat.Mode.QUADS, + 8192, + false, + false, + builder.createCompositeState(false)) as RenderType + } + } + + companion object { + private val noDepthCache = ConcurrentHashMap() + private val depthCache = ConcurrentHashMap() + private val worldCache = ConcurrentHashMap() + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt index 29c5c343d..0e0cfcf88 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt @@ -143,9 +143,12 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit next = State(RenderType.waterMask(), ImmutableList.of(next.type), true, false) it.add(next) - it.add(State(AtlasMatterySprite.renderTypeDepth, ImmutableList.of(RenderType.waterMask()), true)) - it.add(State(AtlasMatterySprite.renderTypeNoDepth, ImmutableList.of(RenderType.waterMask()), true)) - it.add(State(AtlasMatterySprite.renderTypeWorld, ImmutableList.of(Sheets.signSheet()), true)) + // TODO + // it.add(State(AtlasMatterySprite.renderTypeDepth, ImmutableList.of(RenderType.waterMask()), true)) + // TODO + // it.add(State(AtlasMatterySprite.renderTypeNoDepth, ImmutableList.of(RenderType.waterMask()), true)) + // TODO + // it.add(State(AtlasMatterySprite.renderTypeWorld, ImmutableList.of(Sheets.signSheet()), true)) } private fun determineHeight(input: State, seen: MutableSet) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt new file mode 100644 index 000000000..4a9304fa8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt @@ -0,0 +1,24 @@ +package ru.dbotthepony.mc.otm.client.render + +import net.minecraft.resources.ResourceLocation + +data class MatteryAtlas( + val texture: ResourceLocation, + val width: Float, + val height: Float, + val winding: UVWindingOrder = UVWindingOrder.NORMAL, +) { + fun subElement( + x: Float = 0f, + y: Float = 0f, + width: Float = this.width, + height: Float = this.height, + winding: UVWindingOrder = this.winding, + ) = MatterySprite(texture, x = x, y = y, width = width, height = height, atlasHeight = this.height, atlasWidth = this.width, winding = winding) + + @Deprecated("Construct grid directly instead") + fun subGrid(rows: Int, columns: Int) = SkinGrid(texture, this.width / rows, this.height / columns, rows = rows, columns = columns) + + @Deprecated("Construct grid directly instead") + fun subGrid(width: Float, height: Float, rows: Int, columns: Int) = SkinGrid(texture, width, height, rows, columns) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt index afd08f149..352afb437 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt @@ -41,8 +41,8 @@ data class MatterySprite @JvmOverloads constructor( val y: Float, override val width: Float, override val height: Float, - val imageWidth: Float = 256f, - val imageHeight: Float = 256f, + val atlasWidth: Float = 256f, + val atlasHeight: Float = 256f, override val winding: UVWindingOrder = UVWindingOrder.NORMAL, ) : AbstractMatterySprite() { init { @@ -50,18 +50,19 @@ data class MatterySprite @JvmOverloads constructor( require(y >= 0f) { "Invalid y $y" } require(width > 0f) { "Invalid width $width" } require(height > 0f) { "Invalid height $height" } - require(imageWidth > 0f) { "Invalid image width $imageWidth" } - require(imageHeight > 0f) { "Invalid image height $imageHeight" } + require(atlasWidth > 0f) { "Invalid image width $atlasWidth" } + require(atlasHeight > 0f) { "Invalid image height $atlasHeight" } - require(width <= imageWidth) { "$width <= $imageWidth" } - require(height <= imageHeight) { "$height <= $imageHeight" } + require(width <= atlasWidth) { "$width <= $atlasWidth" } + require(height <= atlasHeight) { "$height <= $atlasHeight" } } - override val u0 = this.x / imageWidth - override val v0 = this.y / imageHeight - override val u1 = (this.x + width) / imageWidth - override val v1 = (this.y + height) / imageHeight + override val u0 = this.x / atlasWidth + override val v0 = this.y / atlasHeight + override val u1 = (this.x + width) / atlasWidth + override val v1 = (this.y + height) / atlasHeight override val type: SkinElementType get() = SkinElementType.SINGLE } + diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt index c80ea1ee3..8587d4197 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt @@ -34,7 +34,7 @@ object ResearchIcons { val KOT = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/block/ph_kitty.png").element(0f, 0f, 32f, 32f, 32f, 32f) init { - val grid = SubSkinGrid(AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_upgrades"), 126f, 126f), 18f, 18f, 7, 7) + val grid = SkinGrid(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/android_upgrades.png"), 18f, 18f, 7, 7) ICON_TRANSFER = grid.next() ICON_ATTACK_BOOST = grid.next() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt index 6a729cf7c..a672e32ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt @@ -18,8 +18,8 @@ enum class SkinElementType { it["y"] = JsonPrimitive(value.y) it["width"] = JsonPrimitive(value.width) it["height"] = JsonPrimitive(value.height) - it["imageWidth"] = JsonPrimitive(value.imageWidth) - it["imageHeight"] = JsonPrimitive(value.imageHeight) + it["imageWidth"] = JsonPrimitive(value.atlasWidth) + it["imageHeight"] = JsonPrimitive(value.atlasHeight) it["winding"] = JsonPrimitive(value.winding.name) } } @@ -32,8 +32,8 @@ enum class SkinElementType { buff.writeFloat(value.y) buff.writeFloat(value.width) buff.writeFloat(value.height) - buff.writeFloat(value.imageWidth) - buff.writeFloat(value.imageHeight) + buff.writeFloat(value.atlasWidth) + buff.writeFloat(value.atlasHeight) buff.writeEnum(value.winding) } @@ -63,41 +63,6 @@ enum class SkinElementType { return MatterySprite(ResourceLocation.tryParse(texture) ?: throw JsonSyntaxException("Invalid resource location: $texture"), x, y, width, height, imageWidth, imageHeight, UVWindingOrder.valueOf(winding)) } }, - ATLAS { - override fun toJson(value: AbstractMatterySprite): JsonObject { - require(value is AtlasMatterySprite) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } - - return JsonObject().also { - it["location"] = JsonPrimitive(value.location.toString()) - it["width"] = JsonPrimitive(value.width) - it["height"] = JsonPrimitive(value.height) - } - } - - override fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) { - require(value is AtlasMatterySprite) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } - - buff.writeResourceLocation(value.location) - buff.writeFloat(value.width) - buff.writeFloat(value.height) - } - - override fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite { - val location = ResourceLocation(buff.readUtf()) - val width = buff.readFloat() - val height = buff.readFloat() - - return AtlasMatterySprite(location, width, height) - } - - override fun fromJson(element: JsonObject): AbstractMatterySprite { - val location = element["location"]?.asString ?: throw JsonSyntaxException("Missing location element") - val width = element["width"]?.asFloat ?: throw JsonSyntaxException("Missing width element") - val height = element["height"]?.asFloat ?: throw JsonSyntaxException("Missing height element") - - return AtlasMatterySprite(ResourceLocation.tryParse(location) ?: throw JsonSyntaxException("Invalid resource location: $location"), width, height) - } - }, SUBELEMENT { override fun toJson(value: AbstractMatterySprite): JsonObject { require(value is SubMatterySprite) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt index 7861590dd..f83cb71df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt @@ -13,8 +13,8 @@ data class SkinGrid( var row = 0 var column = 0 - val imageWidth get() = width * columns - val imageHeight get() = height * rows + val atlasWidth get() = width * columns + val atlasHeight get() = height * rows val currentX: Float get() = column * width val currentY: Float get() = row * height @@ -36,7 +36,7 @@ data class SkinGrid( } fun next(): MatterySprite { - val element = MatterySprite(texture, currentX, currentY, width, height, imageWidth, imageHeight) + val element = MatterySprite(texture, currentX, currentY, width, height, atlasWidth, atlasHeight) skip() return element } @@ -54,5 +54,5 @@ data class SkinGrid( } operator fun get(column: Int, row: Int) = - MatterySprite(texture, column * width, row * height, width, height, imageWidth, imageHeight) + MatterySprite(texture, column * width, row * height, width, height, atlasWidth, atlasHeight) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt index 196317389..08b60e242 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt @@ -9,34 +9,11 @@ class SubMatterySprite( override val width: Float = parent.width, override val height: Float = parent.height, private val overrideWinding: UVWindingOrder? = null -) : AbstractMatterySprite.Mutable() { - override var u0: Float = 0f - private set - override var v0: Float = 0f - private set - override var u1: Float = 0f - private set - override var v1: Float = 0f - private set - - private fun calculateUVs() { - u0 = parent.u0 + (xOffset / parent.width) * (parent.u1 - parent.u0) - v0 = parent.v0 + (yOffset / parent.height) * (parent.v1 - parent.v0) - u1 = parent.u0 + ((xOffset + width) / parent.width) * (parent.u1 - parent.u0) - v1 = parent.v0 + ((yOffset + height) / parent.height) * (parent.v1 - parent.v0) - - notifyListeners() - } - - override fun parentChanges(parent: AbstractMatterySprite) = calculateUVs() - - init { - parent.addListener(this) - } - - init { - calculateUVs() - } +) : AbstractMatterySprite() { + override val u0 = parent.u0 + (xOffset / parent.width) * (parent.u1 - parent.u0) + override val v0 = parent.v0 + (yOffset / parent.height) * (parent.v1 - parent.v0) + override val u1 = parent.u0 + ((xOffset + width) / parent.width) * (parent.u1 - parent.u0) + override val v1 = parent.v0 + ((yOffset + height) / parent.height) * (parent.v1 - parent.v0) override val texture: ResourceLocation get() = parent.texture diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 813924b33..67431c658 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -6,11 +6,11 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters object WidgetLocation { val WIDGETS_18 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png") - val MISC = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/misc"), 64f, 64f) - val PATTERN_PANEL_TABS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/pattern_panel_tabs"), 64f, 32f) + val MISC = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc.png"), 64f, 64f) + val PATTERN_PANEL_TABS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/pattern_panel_tabs.png"), 64f, 32f) - val CHECKBOX = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/checkbox"), 32f, 64f) - val PROGRESS_ARROWS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/progress_arrows"), 32f, 32f) - val HORIZONTAL_GAUGES = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/horizontal_gauges"), 128f, 64f) - val VERTICAL_GAUGES = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/vertical_gauges"), 128f, 48f) + val CHECKBOX = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/checkbox.png"), 32f, 64f) + val PROGRESS_ARROWS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/progress_arrows.png"), 22f, 31f) + val HORIZONTAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/horizontal_gauges.png"), 96f, 54f) + val VERTICAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/vertical_gauges.png"), 90f, 48f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt index 0921111a3..3a23df616 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt @@ -8,8 +8,8 @@ object Widgets { val ARROW_UP_BUTTON_PRESSED = WidgetLocation.MISC.subElement(0f, 18f + 6f * 2f, 18f, 6f) val ARROW_UP_BUTTON_DISABLED = WidgetLocation.MISC.subElement(0f, 18f + 6f * 3f, 18f, 6f) - val ARROW_DOWN_BUTTON_IDLE = ARROW_UP_BUTTON_IDLE.copy(overrideWinding = UVWindingOrder.FLIP) - val ARROW_DOWN_BUTTON_HOVERED = ARROW_UP_BUTTON_HOVERED.copy(overrideWinding = UVWindingOrder.FLIP) - val ARROW_DOWN_BUTTON_PRESSED = ARROW_UP_BUTTON_PRESSED.copy(overrideWinding = UVWindingOrder.FLIP) - val ARROW_DOWN_BUTTON_DISABLED = ARROW_UP_BUTTON_DISABLED.copy(overrideWinding = UVWindingOrder.FLIP) + val ARROW_DOWN_BUTTON_IDLE = ARROW_UP_BUTTON_IDLE.copy(winding = UVWindingOrder.FLIP) + val ARROW_DOWN_BUTTON_HOVERED = ARROW_UP_BUTTON_HOVERED.copy(winding = UVWindingOrder.FLIP) + val ARROW_DOWN_BUTTON_PRESSED = ARROW_UP_BUTTON_PRESSED.copy(winding = UVWindingOrder.FLIP) + val ARROW_DOWN_BUTTON_DISABLED = ARROW_UP_BUTTON_DISABLED.copy(winding = UVWindingOrder.FLIP) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 34a812e8d..d49145350 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -5,15 +5,15 @@ private fun makeButton(grid: SkinGrid): StretchingRectangleElement { val y = grid.currentY return StretchingRectangleElement( - topLeft = WidgetLocation.WIDGETS_18.element(x, y, 2f, 2f, grid.imageWidth, grid.imageHeight), - topRight = WidgetLocation.WIDGETS_18.element(x + 16f, y, 2f, 2f, grid.imageWidth, grid.imageHeight), - bottomLeft = WidgetLocation.WIDGETS_18.element(x, y + 16f, 2f, 2f, grid.imageWidth, grid.imageHeight), - bottomRight = WidgetLocation.WIDGETS_18.element(x + 16f, y + 16f, 2f, 2f, grid.imageWidth, grid.imageHeight), - middle = WidgetLocation.WIDGETS_18.element(x + 2f, y + 2f, 14f, 14f, grid.imageWidth, grid.imageHeight), - top = WidgetLocation.WIDGETS_18.element(x + 2f, y, 14f, 2f, grid.imageWidth, grid.imageHeight), - left = WidgetLocation.WIDGETS_18.element(x, y + 2f, 2f, 14f, grid.imageWidth, grid.imageHeight), - right = WidgetLocation.WIDGETS_18.element(x + 16f, y + 2f, 2f, 14f, grid.imageWidth, grid.imageHeight), - bottom = WidgetLocation.WIDGETS_18.element(x + 2f, y + 16f, 14f, 2f, grid.imageWidth, grid.imageHeight), + topLeft = WidgetLocation.WIDGETS_18.element(x, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + topRight = WidgetLocation.WIDGETS_18.element(x + 16f, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + bottomLeft = WidgetLocation.WIDGETS_18.element(x, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + bottomRight = WidgetLocation.WIDGETS_18.element(x + 16f, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + middle = WidgetLocation.WIDGETS_18.element(x + 2f, y + 2f, 14f, 14f, grid.atlasWidth, grid.atlasHeight), + top = WidgetLocation.WIDGETS_18.element(x + 2f, y, 14f, 2f, grid.atlasWidth, grid.atlasHeight), + left = WidgetLocation.WIDGETS_18.element(x, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), + right = WidgetLocation.WIDGETS_18.element(x + 16f, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), + bottom = WidgetLocation.WIDGETS_18.element(x + 2f, y + 16f, 14f, 2f, grid.atlasWidth, grid.atlasHeight), ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt index 0a631c678..bd18562ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt @@ -4,7 +4,7 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters object Widgets8 { - val GRID = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets_8"), 64f, 32f).subGrid(8f, 8f, 64 / 8, 32 / 8) + val GRID = SkinGrid(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_8.png"), 8f, 8f, 64 / 8, 32 / 8) val BUTTON_IDLE = GRID[0, 0] val BUTTON_HOVERED = GRID[0, 1] diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index 716a5c5ce..ef8f5da50 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -52,7 +52,7 @@ abstract class BankRenderer(private val context: BlockEn val width = 9f val heightMax = 39.36f - val buffer = DynamicBufferSource.WORLD.getBuffer(AtlasMatterySprite.renderTypeWorld) + val buffer = DynamicBufferSource.WORLD.getBuffer(texture.renderTypeWorld) texture.uploadOntoPartialColor( stack, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt index 46242cf9c..f30839f85 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt @@ -2,30 +2,34 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.render.MatteryAtlas import ru.dbotthepony.mc.otm.client.render.subElement object ScrollBarConstants { const val WIDTH = 14f const val SLIM_WIDTH = 8f - val BACKGROUND = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/background"), 14f, 8f) - val BACKGROUND_SLIM = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/background"), 8f, 8f) + val NORMAL_ATLAS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/scrollbar.png"), 62f, 15f) + val SLIM_ATLAS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/scrollbar_slim.png"), 32f, 15f) + + val BACKGROUND = NORMAL_ATLAS.subElement(width = 14f, height = 8f) + val BACKGROUND_SLIM = SLIM_ATLAS.subElement(width = 8f, height = 8f) val TOP = BACKGROUND.subElement(height = 2f) val BODY = BACKGROUND.subElement(y = 2f, height = 5f) val BOTTOM = BACKGROUND.subElement(y = 6f, height = 2f) - val BUTTON = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/idle"), 12f, 15f) - val BUTTON_HOVER = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/hovered"), 12f, 15f) - val BUTTON_PRESS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/pressed"), 12f, 15f) - val BUTTON_DISABLED = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/disabled"), 12f, 15f) + val BUTTON = NORMAL_ATLAS.subElement(x = 15f, width = 12f) + val BUTTON_HOVER = NORMAL_ATLAS.subElement(x = 15f + 12f, width = 12f) + val BUTTON_PRESS = NORMAL_ATLAS.subElement(x = 15f + 12f * 2f, width = 12f) + val BUTTON_DISABLED = NORMAL_ATLAS.subElement(x = 15f + 12f * 3f, width = 12f) val SLIM_TOP = BACKGROUND_SLIM.subElement(height = 2f) val SLIM_BODY = BACKGROUND_SLIM.subElement(y = 2f, height = 5f) val SLIM_BOTTOM = BACKGROUND_SLIM.subElement(y = 6f, height = 2f) - val SLIM_BUTTON = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/idle"), 6f, 15f) - val SLIM_BUTTON_HOVER = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/hovered"), 6f, 15f) - val SLIM_BUTTON_PRESS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/pressed"), 6f, 15f) - val SLIM_BUTTON_DISABLED = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/disabled"), 6f, 15f) + val SLIM_BUTTON = SLIM_ATLAS.subElement(x = 9f, width = 6f) + val SLIM_BUTTON_HOVER = SLIM_ATLAS.subElement(x = 9f + 6f, width = 6f) + val SLIM_BUTTON_PRESS = SLIM_ATLAS.subElement(x = 9f + 6f * 2f, width = 6f) + val SLIM_BUTTON_DISABLED = SLIM_ATLAS.subElement(x = 9f + 6f * 3f, width = 6f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt index 6db631948..bbd0e6415 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt @@ -91,7 +91,7 @@ open class CheckBoxPanel @JvmOverloads constructor( val DISABLED_CHECKED: AbstractMatterySprite init { - val grid = WidgetLocation.CHECKBOX.subGrid(REGULAR_DIMENSIONS, REGULAR_DIMENSIONS, 2, 4) + val grid = WidgetLocation.CHECKBOX.subGrid(columns = 2, rows = 4) IDLE_UNCHECKED = grid.next() IDLE_CHECKED = grid.next() diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/android_upgrades.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/android_upgrades.png index 8deae1d89..ce32f5677 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/android_upgrades.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/android_upgrades.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png index 4c867588e..9b2f93567 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/checkbox.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/checkbox.png index 740496b5a..55b1deff2 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/checkbox.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/checkbox.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.png index 83caab387..699161318 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/pattern_panel_tabs.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/pattern_panel_tabs.png index 6988d0fc4..14b5b1ad1 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/pattern_panel_tabs.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/pattern_panel_tabs.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/progress_arrows.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/progress_arrows.png index 97e068022..dc0c2a9a8 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/progress_arrows.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/progress_arrows.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar.png new file mode 100644 index 000000000..e15e25c3d Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/background.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/background.png deleted file mode 100644 index 187422eb7..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/background.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/disabled.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/disabled.png deleted file mode 100644 index 767ab2867..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/disabled.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/hovered.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/hovered.png deleted file mode 100644 index 60457f250..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/hovered.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/idle.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/idle.png deleted file mode 100644 index d68f984a7..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/idle.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/pressed.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/pressed.png deleted file mode 100644 index d1b456e8a..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/pressed.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim.png new file mode 100644 index 000000000..f8539f3e6 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/background.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/background.png deleted file mode 100644 index b0a6eae96..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/background.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/disabled.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/disabled.png deleted file mode 100644 index d7cf35e98..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/disabled.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/hovered.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/hovered.png deleted file mode 100644 index 98f996d4d..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/hovered.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/idle.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/idle.png deleted file mode 100644 index 603961851..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/idle.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/pressed.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/pressed.png deleted file mode 100644 index 7b8b5dd0a..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/pressed.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.png index 677f59422..c981a8143 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.png differ