Rename Skin Element to Mattery Sprite
This commit is contained in:
parent
c439665871
commit
68b68c4219
@ -9,27 +9,20 @@ import net.minecraft.network.chat.Component
|
|||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.server.level.ServerPlayer
|
||||||
import net.minecraft.world.entity.player.Player
|
import net.minecraft.world.entity.player.Player
|
||||||
import net.minecraft.world.item.ItemStack
|
|
||||||
import net.minecraftforge.common.util.INBTSerializable
|
import net.minecraftforge.common.util.INBTSerializable
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||||
import ru.dbotthepony.mc.otm.capability.awareItemsStream
|
import ru.dbotthepony.mc.otm.capability.awareItemsStream
|
||||||
import ru.dbotthepony.mc.otm.capability.itemsStream
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.SkinElement
|
|
||||||
import ru.dbotthepony.mc.otm.container.iterator
|
|
||||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
import ru.dbotthepony.mc.otm.core.addAll
|
import ru.dbotthepony.mc.otm.core.addAll
|
||||||
import ru.dbotthepony.mc.otm.core.getCompoundList
|
import ru.dbotthepony.mc.otm.core.getCompoundList
|
||||||
import ru.dbotthepony.mc.otm.core.nonEmpty
|
|
||||||
import ru.dbotthepony.mc.otm.core.registryName
|
import ru.dbotthepony.mc.otm.core.registryName
|
||||||
import ru.dbotthepony.mc.otm.core.set
|
import ru.dbotthepony.mc.otm.core.set
|
||||||
import ru.dbotthepony.mc.otm.milliTime
|
import ru.dbotthepony.mc.otm.milliTime
|
||||||
import ru.dbotthepony.mc.otm.nanoTime
|
|
||||||
import ru.dbotthepony.mc.otm.network.FieldSynchronizer
|
import ru.dbotthepony.mc.otm.network.FieldSynchronizer
|
||||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||||
import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger
|
import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger
|
||||||
import java.io.DataInputStream
|
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
|
||||||
|
@ -21,8 +21,7 @@ import net.minecraft.world.item.Items
|
|||||||
import net.minecraft.world.item.crafting.Ingredient
|
import net.minecraft.world.item.crafting.Ingredient
|
||||||
import net.minecraft.world.level.ItemLike
|
import net.minecraft.world.level.ItemLike
|
||||||
import net.minecraftforge.registries.ForgeRegistries
|
import net.minecraftforge.registries.ForgeRegistries
|
||||||
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.SkinElement
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.SkinElementType
|
import ru.dbotthepony.mc.otm.client.render.SkinElementType
|
||||||
import ru.dbotthepony.mc.otm.core.ListSet
|
import ru.dbotthepony.mc.otm.core.ListSet
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
@ -625,7 +624,7 @@ class AndroidResearchType(
|
|||||||
var description: MutableList<Component>? = null,
|
var description: MutableList<Component>? = null,
|
||||||
var descriptionSuppliers: MutableList<ComponentSupplier>? = null,
|
var descriptionSuppliers: MutableList<ComponentSupplier>? = null,
|
||||||
var itemIcon: Item? = null,
|
var itemIcon: Item? = null,
|
||||||
var skinIcon: AbstractSkinElement? = null,
|
var skinIcon: AbstractMatterySprite? = null,
|
||||||
var iconText: Component? = null,
|
var iconText: Component? = null,
|
||||||
) {
|
) {
|
||||||
private val items = ArrayList<Pair<Ingredient, Int>>()
|
private val items = ArrayList<Pair<Ingredient, Int>>()
|
||||||
@ -639,7 +638,7 @@ class AndroidResearchType(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun withIcon(icon: AbstractSkinElement? = null): Builder {
|
fun withIcon(icon: AbstractMatterySprite? = null): Builder {
|
||||||
this.skinIcon = icon
|
this.skinIcon = icon
|
||||||
this.itemIcon = null
|
this.itemIcon = null
|
||||||
return this
|
return this
|
||||||
|
@ -12,8 +12,6 @@ import net.minecraft.world.entity.LivingEntity
|
|||||||
import net.minecraft.world.entity.player.Player
|
import net.minecraft.world.entity.player.Player
|
||||||
import net.minecraftforge.client.event.RenderGuiEvent
|
import net.minecraftforge.client.event.RenderGuiEvent
|
||||||
import net.minecraftforge.client.event.RenderGuiOverlayEvent
|
import net.minecraftforge.client.event.RenderGuiOverlayEvent
|
||||||
import net.minecraftforge.client.event.RenderLevelLastEvent
|
|
||||||
import net.minecraftforge.client.event.RenderLevelStageEvent
|
|
||||||
import net.minecraftforge.client.event.ScreenEvent
|
import net.minecraftforge.client.event.ScreenEvent
|
||||||
import net.minecraftforge.client.gui.overlay.ForgeGui
|
import net.minecraftforge.client.gui.overlay.ForgeGui
|
||||||
import net.minecraftforge.client.gui.overlay.GuiOverlayManager
|
import net.minecraftforge.client.gui.overlay.GuiOverlayManager
|
||||||
@ -30,7 +28,7 @@ import java.util.*
|
|||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
|
|
||||||
object MatteryGUI {
|
object MatteryGUI {
|
||||||
private val BARS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "player_bars"), 80f, 36f)
|
private val BARS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "player_bars"), 80f, 36f)
|
||||||
val CHARGE = BARS.subElement(height = 9f)
|
val CHARGE = BARS.subElement(height = 9f)
|
||||||
val CHARGE_BG = BARS.subElement(y = 9f, height = 9f)
|
val CHARGE_BG = BARS.subElement(y = 9f, height = 9f)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.core.RGBAColor
|
|||||||
import ru.dbotthepony.mc.otm.core.linearInterpolation
|
import ru.dbotthepony.mc.otm.core.linearInterpolation
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
|
|
||||||
sealed class AbstractSkinElement {
|
sealed class AbstractMatterySprite {
|
||||||
/**
|
/**
|
||||||
* Expected image width in pixels, used in calculations
|
* Expected image width in pixels, used in calculations
|
||||||
* and as default width argument in render methods
|
* and as default width argument in render methods
|
||||||
@ -28,14 +28,6 @@ sealed class AbstractSkinElement {
|
|||||||
abstract val u1: Float
|
abstract val u1: Float
|
||||||
abstract val v1: Float
|
abstract val v1: Float
|
||||||
|
|
||||||
internal open fun addListener(listener: AbstractSkinElement) {
|
|
||||||
// no-op by default
|
|
||||||
}
|
|
||||||
|
|
||||||
internal open fun parentChanges(parent: AbstractSkinElement) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun partialU(offset: Float): Float {
|
fun partialU(offset: Float): Float {
|
||||||
return u0 + (offset / width) * (u1 - u0)
|
return u0 + (offset / width) * (u1 - u0)
|
||||||
}
|
}
|
||||||
@ -313,40 +305,4 @@ sealed class AbstractSkinElement {
|
|||||||
fun toNetwork(buff: FriendlyByteBuf) {
|
fun toNetwork(buff: FriendlyByteBuf) {
|
||||||
type.toActualNetwork(this, buff)
|
type.toActualNetwork(this, buff)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class Mutable : AbstractSkinElement() {
|
|
||||||
private val listeners = ArrayList<WeakReference<AbstractSkinElement>>(0)
|
|
||||||
|
|
||||||
override fun addListener(listener: AbstractSkinElement) {
|
|
||||||
synchronized(listeners) {
|
|
||||||
val iterator = listeners.listIterator()
|
|
||||||
|
|
||||||
for (ref in iterator) {
|
|
||||||
if (ref.get() == null) {
|
|
||||||
iterator.remove()
|
|
||||||
} else if (ref.get() === listener) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
listeners.add(WeakReference(listener))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fun notifyListeners() {
|
|
||||||
synchronized(listeners) {
|
|
||||||
val iterator = listeners.listIterator()
|
|
||||||
|
|
||||||
for (ref in iterator) {
|
|
||||||
val value = ref.get()
|
|
||||||
|
|
||||||
if (value == null) {
|
|
||||||
iterator.remove()
|
|
||||||
} else {
|
|
||||||
value.parentChanges(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,215 +0,0 @@
|
|||||||
package ru.dbotthepony.mc.otm.client.render
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem
|
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat
|
|
||||||
import net.minecraft.client.renderer.GameRenderer
|
|
||||||
import net.minecraft.client.renderer.RenderStateShard
|
|
||||||
import net.minecraft.client.renderer.RenderStateShard.TextureStateShard
|
|
||||||
import net.minecraft.client.renderer.RenderType
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
|
||||||
import net.minecraft.util.Mth
|
|
||||||
import org.lwjgl.opengl.GL11.GL_ALWAYS
|
|
||||||
import ru.dbotthepony.mc.otm.isClient
|
|
||||||
import java.lang.ref.WeakReference
|
|
||||||
import java.util.stream.Stream
|
|
||||||
|
|
||||||
class AtlasSkinElement(
|
|
||||||
val location: ResourceLocation,
|
|
||||||
override val width: Float,
|
|
||||||
override val height: Float,
|
|
||||||
val spriteWidth: Float = Mth.smallestEncompassingPowerOfTwo(width.toInt()).toFloat(),
|
|
||||||
val spriteHeight: Float = Mth.smallestEncompassingPowerOfTwo(height.toInt()).toFloat(),
|
|
||||||
override val winding: UVWindingOrder = UVWindingOrder.NORMAL,
|
|
||||||
) : AbstractSkinElement.Mutable() {
|
|
||||||
init {
|
|
||||||
synchronized(keys) {
|
|
||||||
if (keys.add(location)) {
|
|
||||||
if (isWidgetAtlasAvailable) {
|
|
||||||
queueRebuild()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// optimistic: we should not create a lot of instances of this class
|
|
||||||
synchronized(atlasListeners) {
|
|
||||||
atlasListeners.add(WeakReference(this))
|
|
||||||
val iterator = atlasListeners.listIterator()
|
|
||||||
|
|
||||||
for (ref in iterator) {
|
|
||||||
val value = ref.get()
|
|
||||||
|
|
||||||
if (value == null) {
|
|
||||||
iterator.remove()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isWidgetAtlasAvailable) {
|
|
||||||
earlyBindingImpl()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun earlyBindingImpl() {
|
|
||||||
if (WidgetAtlasHolder.INSTANCE.once) {
|
|
||||||
textureAtlasSpriteImpl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private var changeset = -1
|
|
||||||
private var _textureAtlasSprite: TextureAtlasSprite? = null
|
|
||||||
|
|
||||||
private val textureAtlasSpriteImpl: TextureAtlasSprite get(): TextureAtlasSprite {
|
|
||||||
check(isClient) { "Invalid realm" }
|
|
||||||
val _textureAtlasSprite = _textureAtlasSprite
|
|
||||||
|
|
||||||
if (
|
|
||||||
_textureAtlasSprite == null ||
|
|
||||||
_textureAtlasSprite.contents().name().let { it.namespace == "minecraft" && it.path == "missingno" } ||
|
|
||||||
changeset != WidgetAtlasHolder.INSTANCE.changeset
|
|
||||||
) {
|
|
||||||
val get = WidgetAtlasHolder.INSTANCE.getSprite(location)
|
|
||||||
this._textureAtlasSprite = get
|
|
||||||
changeset = WidgetAtlasHolder.INSTANCE.changeset
|
|
||||||
|
|
||||||
u0 = get.u0
|
|
||||||
v0 = get.v0
|
|
||||||
u1 = get.u1 - (get.u1 - get.u0) * (1f - width / spriteWidth)
|
|
||||||
v1 = get.v1 - (get.v1 - get.v0) * (1f - height / spriteHeight)
|
|
||||||
|
|
||||||
notifyListeners()
|
|
||||||
|
|
||||||
return get
|
|
||||||
}
|
|
||||||
|
|
||||||
return _textureAtlasSprite
|
|
||||||
}
|
|
||||||
|
|
||||||
val textureAtlasSprite: TextureAtlasSprite get(): TextureAtlasSprite {
|
|
||||||
check(isWidgetAtlasAvailable) { "Atlas is not available; either we are not a client, or we are running datagen" }
|
|
||||||
return textureAtlasSpriteImpl
|
|
||||||
}
|
|
||||||
|
|
||||||
override var u0 = 0f
|
|
||||||
private set
|
|
||||||
override var v0 = 0f
|
|
||||||
private set
|
|
||||||
override var u1 = 0f
|
|
||||||
private set
|
|
||||||
override var v1 = 0f
|
|
||||||
private set
|
|
||||||
|
|
||||||
override val texture: ResourceLocation get() = WidgetAtlasHolder.LOCATION
|
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
if (other is AtlasSkinElement)
|
|
||||||
return location == other.location
|
|
||||||
|
|
||||||
return super.equals(other)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
return WidgetAtlasHolder.INSTANCE.hashCode() xor location.hashCode()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String {
|
|
||||||
return "AtlasSkinElement[$location]"
|
|
||||||
}
|
|
||||||
|
|
||||||
override val type: SkinElementType
|
|
||||||
get() = SkinElementType.ATLAS
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val keys = HashSet<ResourceLocation>()
|
|
||||||
private val atlasListeners = ArrayList<WeakReference<AtlasSkinElement>>()
|
|
||||||
val keysStream: Stream<ResourceLocation> get() = keys.stream()
|
|
||||||
|
|
||||||
fun notifyListeners() {
|
|
||||||
synchronized(atlasListeners) {
|
|
||||||
val iterator = atlasListeners.listIterator()
|
|
||||||
|
|
||||||
for (ref in iterator) {
|
|
||||||
val value = ref.get()
|
|
||||||
|
|
||||||
if (value == null) {
|
|
||||||
iterator.remove()
|
|
||||||
} else {
|
|
||||||
value.textureAtlasSpriteImpl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun queueRebuild() {
|
|
||||||
WidgetAtlasHolder.INSTANCE.queueRebuild()
|
|
||||||
}
|
|
||||||
|
|
||||||
val renderTypeNoDepth by lazy {
|
|
||||||
val builder = RenderType.CompositeState.builder()
|
|
||||||
|
|
||||||
builder.setTextureState(TextureStateShard(WidgetAtlasHolder.LOCATION, 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 {
|
|
||||||
val builder = RenderType.CompositeState.builder()
|
|
||||||
|
|
||||||
builder.setTextureState(TextureStateShard(WidgetAtlasHolder.LOCATION, 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 {
|
|
||||||
val builder = RenderType.CompositeState.builder()
|
|
||||||
|
|
||||||
builder.setTextureState(TextureStateShard(WidgetAtlasHolder.LOCATION, 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -143,9 +143,9 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit
|
|||||||
next = State(RenderType.waterMask(), ImmutableList.of(next.type), true, false)
|
next = State(RenderType.waterMask(), ImmutableList.of(next.type), true, false)
|
||||||
it.add(next)
|
it.add(next)
|
||||||
|
|
||||||
it.add(State(AtlasSkinElement.renderTypeDepth, ImmutableList.of(RenderType.waterMask()), true))
|
it.add(State(AtlasMatterySprite.renderTypeDepth, ImmutableList.of(RenderType.waterMask()), true))
|
||||||
it.add(State(AtlasSkinElement.renderTypeNoDepth, ImmutableList.of(RenderType.waterMask()), true))
|
it.add(State(AtlasMatterySprite.renderTypeNoDepth, ImmutableList.of(RenderType.waterMask()), true))
|
||||||
it.add(State(AtlasSkinElement.renderTypeWorld, ImmutableList.of(Sheets.signSheet()), true))
|
it.add(State(AtlasMatterySprite.renderTypeWorld, ImmutableList.of(Sheets.signSheet()), true))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun determineHeight(input: State, seen: MutableSet<State>) {
|
private fun determineHeight(input: State, seen: MutableSet<State>) {
|
||||||
|
@ -1,21 +1,6 @@
|
|||||||
package ru.dbotthepony.mc.otm.client.render
|
package ru.dbotthepony.mc.otm.client.render
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext
|
|
||||||
import com.google.gson.JsonDeserializer
|
|
||||||
import com.google.gson.JsonElement
|
|
||||||
import com.google.gson.JsonObject
|
|
||||||
import com.google.gson.JsonPrimitive
|
|
||||||
import com.google.gson.JsonSerializationContext
|
|
||||||
import com.google.gson.JsonSerializer
|
|
||||||
import com.google.gson.JsonSyntaxException
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.internal.bind.TypeAdapters
|
|
||||||
import com.google.gson.stream.JsonReader
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import net.minecraft.network.FriendlyByteBuf
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
import ru.dbotthepony.mc.otm.core.set
|
|
||||||
import java.lang.reflect.Type
|
|
||||||
|
|
||||||
fun ResourceLocation.element(
|
fun ResourceLocation.element(
|
||||||
x: Float,
|
x: Float,
|
||||||
@ -24,14 +9,14 @@ fun ResourceLocation.element(
|
|||||||
height: Float,
|
height: Float,
|
||||||
textureWidth: Float = 256f,
|
textureWidth: Float = 256f,
|
||||||
textureHeight: Float = 256f
|
textureHeight: Float = 256f
|
||||||
) = SkinElement(this, x, y, width, height, textureWidth, textureHeight)
|
) = MatterySprite(this, x, y, width, height, textureWidth, textureHeight)
|
||||||
|
|
||||||
fun ResourceLocation.pixel(
|
fun ResourceLocation.pixel(
|
||||||
x: Float,
|
x: Float,
|
||||||
y: Float,
|
y: Float,
|
||||||
textureWidth: Float = 256f,
|
textureWidth: Float = 256f,
|
||||||
textureHeight: Float = 256f
|
textureHeight: Float = 256f
|
||||||
) = SkinElement(this, x, y, 1f, 1f, textureWidth, textureHeight)
|
) = MatterySprite(this, x, y, 1f, 1f, textureWidth, textureHeight)
|
||||||
|
|
||||||
fun ResourceLocation.hLine(
|
fun ResourceLocation.hLine(
|
||||||
x: Float,
|
x: Float,
|
||||||
@ -39,7 +24,7 @@ fun ResourceLocation.hLine(
|
|||||||
width: Float,
|
width: Float,
|
||||||
textureWidth: Float = 256f,
|
textureWidth: Float = 256f,
|
||||||
textureHeight: Float = 256f
|
textureHeight: Float = 256f
|
||||||
) = SkinElement(this, x, y, width, 1f, textureWidth, textureHeight)
|
) = MatterySprite(this, x, y, width, 1f, textureWidth, textureHeight)
|
||||||
|
|
||||||
fun ResourceLocation.vLine(
|
fun ResourceLocation.vLine(
|
||||||
x: Float,
|
x: Float,
|
||||||
@ -47,10 +32,10 @@ fun ResourceLocation.vLine(
|
|||||||
height: Float,
|
height: Float,
|
||||||
textureWidth: Float = 256f,
|
textureWidth: Float = 256f,
|
||||||
textureHeight: Float = 256f
|
textureHeight: Float = 256f
|
||||||
) = SkinElement(this, x, y, 1f, height, textureWidth, textureHeight)
|
) = MatterySprite(this, x, y, 1f, height, textureWidth, textureHeight)
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
data class SkinElement @JvmOverloads constructor(
|
data class MatterySprite @JvmOverloads constructor(
|
||||||
override val texture: ResourceLocation,
|
override val texture: ResourceLocation,
|
||||||
val x: Float,
|
val x: Float,
|
||||||
val y: Float,
|
val y: Float,
|
||||||
@ -59,7 +44,7 @@ data class SkinElement @JvmOverloads constructor(
|
|||||||
val imageWidth: Float = 256f,
|
val imageWidth: Float = 256f,
|
||||||
val imageHeight: Float = 256f,
|
val imageHeight: Float = 256f,
|
||||||
override val winding: UVWindingOrder = UVWindingOrder.NORMAL,
|
override val winding: UVWindingOrder = UVWindingOrder.NORMAL,
|
||||||
) : AbstractSkinElement() {
|
) : AbstractMatterySprite() {
|
||||||
init {
|
init {
|
||||||
require(x >= 0f) { "Invalid x $x" }
|
require(x >= 0f) { "Invalid x $x" }
|
||||||
require(y >= 0f) { "Invalid y $y" }
|
require(y >= 0f) { "Invalid y $y" }
|
||||||
@ -67,6 +52,9 @@ data class SkinElement @JvmOverloads constructor(
|
|||||||
require(height > 0f) { "Invalid height $height" }
|
require(height > 0f) { "Invalid height $height" }
|
||||||
require(imageWidth > 0f) { "Invalid image width $imageWidth" }
|
require(imageWidth > 0f) { "Invalid image width $imageWidth" }
|
||||||
require(imageHeight > 0f) { "Invalid image height $imageHeight" }
|
require(imageHeight > 0f) { "Invalid image height $imageHeight" }
|
||||||
|
|
||||||
|
require(width <= imageWidth) { "$width <= $imageWidth" }
|
||||||
|
require(height <= imageHeight) { "$height <= $imageHeight" }
|
||||||
}
|
}
|
||||||
|
|
||||||
override val u0 = this.x / imageWidth
|
override val u0 = this.x / imageWidth
|
@ -4,37 +4,37 @@ import net.minecraft.resources.ResourceLocation
|
|||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
|
|
||||||
object ResearchIcons {
|
object ResearchIcons {
|
||||||
val ICON_TRANSFER: AbstractSkinElement
|
val ICON_TRANSFER: AbstractMatterySprite
|
||||||
val ICON_ATTACK_BOOST: AbstractSkinElement
|
val ICON_ATTACK_BOOST: AbstractMatterySprite
|
||||||
val ICON_PLASMA_SHIELD_BOOST: AbstractSkinElement
|
val ICON_PLASMA_SHIELD_BOOST: AbstractMatterySprite
|
||||||
val ICON_CLOAK: AbstractSkinElement
|
val ICON_CLOAK: AbstractMatterySprite
|
||||||
val ICON_GRAVITATIONAL_STABILIZER: AbstractSkinElement
|
val ICON_GRAVITATIONAL_STABILIZER: AbstractMatterySprite
|
||||||
val ICON_AIR_BAGS: AbstractSkinElement
|
val ICON_AIR_BAGS: AbstractMatterySprite
|
||||||
val ICON_JUMP_BOOST: AbstractSkinElement
|
val ICON_JUMP_BOOST: AbstractMatterySprite
|
||||||
|
|
||||||
val ICON_FEATHER_FALLING: AbstractSkinElement
|
val ICON_FEATHER_FALLING: AbstractMatterySprite
|
||||||
val ICON_ITEM_MAGNET: AbstractSkinElement
|
val ICON_ITEM_MAGNET: AbstractMatterySprite
|
||||||
val ICON_ARROW: AbstractSkinElement
|
val ICON_ARROW: AbstractMatterySprite
|
||||||
val ICON_ARMOR: AbstractSkinElement
|
val ICON_ARMOR: AbstractMatterySprite
|
||||||
val ICON_NANOBOTS: AbstractSkinElement
|
val ICON_NANOBOTS: AbstractMatterySprite
|
||||||
val ICON_NIGHT_VISION: AbstractSkinElement
|
val ICON_NIGHT_VISION: AbstractMatterySprite
|
||||||
val ICON_OXYGEN_SUPPLY: AbstractSkinElement
|
val ICON_OXYGEN_SUPPLY: AbstractMatterySprite
|
||||||
|
|
||||||
val ICON_PLASMA_SHIELD: AbstractSkinElement
|
val ICON_PLASMA_SHIELD: AbstractMatterySprite
|
||||||
val ICON_SHOCKWAVE: AbstractSkinElement
|
val ICON_SHOCKWAVE: AbstractMatterySprite
|
||||||
val ICON_LIMB_OVERCLOCKING: AbstractSkinElement
|
val ICON_LIMB_OVERCLOCKING: AbstractMatterySprite
|
||||||
val ICON_STEP_ASSIST: AbstractSkinElement
|
val ICON_STEP_ASSIST: AbstractMatterySprite
|
||||||
val ICON_ENDER_TELEPORT: AbstractSkinElement
|
val ICON_ENDER_TELEPORT: AbstractMatterySprite
|
||||||
val ICON_WIRELESS_CHARGING: AbstractSkinElement
|
val ICON_WIRELESS_CHARGING: AbstractMatterySprite
|
||||||
val ICON_UNKNOWN: AbstractSkinElement
|
val ICON_UNKNOWN: AbstractMatterySprite
|
||||||
|
|
||||||
val ICON_EXTENDED_REACH: AbstractSkinElement
|
val ICON_EXTENDED_REACH: AbstractMatterySprite
|
||||||
val ICON_PHANTOM_ATTRACTOR: AbstractSkinElement
|
val ICON_PHANTOM_ATTRACTOR: AbstractMatterySprite
|
||||||
|
|
||||||
val KOT = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/block/ph_kitty.png").element(0f, 0f, 32f, 32f, 32f, 32f)
|
val KOT = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/block/ph_kitty.png").element(0f, 0f, 32f, 32f, 32f, 32f)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val grid = SubSkinGrid(AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_upgrades"), 126f, 126f), 18f, 18f, 7, 7)
|
val grid = SubSkinGrid(AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_upgrades"), 126f, 126f), 18f, 18f, 7, 7)
|
||||||
|
|
||||||
ICON_TRANSFER = grid.next()
|
ICON_TRANSFER = grid.next()
|
||||||
ICON_ATTACK_BOOST = grid.next()
|
ICON_ATTACK_BOOST = grid.next()
|
||||||
|
@ -9,8 +9,8 @@ import ru.dbotthepony.mc.otm.core.set
|
|||||||
|
|
||||||
enum class SkinElementType {
|
enum class SkinElementType {
|
||||||
SINGLE {
|
SINGLE {
|
||||||
override fun toJson(value: AbstractSkinElement): JsonObject {
|
override fun toJson(value: AbstractMatterySprite): JsonObject {
|
||||||
require(value is SkinElement) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" }
|
require(value is MatterySprite) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" }
|
||||||
|
|
||||||
return JsonObject().also {
|
return JsonObject().also {
|
||||||
it["texture"] = JsonPrimitive(value.texture.toString())
|
it["texture"] = JsonPrimitive(value.texture.toString())
|
||||||
@ -24,8 +24,8 @@ enum class SkinElementType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) {
|
override fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) {
|
||||||
require(value is SkinElement) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" }
|
require(value is MatterySprite) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" }
|
||||||
|
|
||||||
buff.writeUtf(value.texture.toString())
|
buff.writeUtf(value.texture.toString())
|
||||||
buff.writeFloat(value.x)
|
buff.writeFloat(value.x)
|
||||||
@ -37,7 +37,7 @@ enum class SkinElementType {
|
|||||||
buff.writeEnum(value.winding)
|
buff.writeEnum(value.winding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement {
|
override fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite {
|
||||||
val texture = ResourceLocation(buff.readUtf())
|
val texture = ResourceLocation(buff.readUtf())
|
||||||
val x = buff.readFloat()
|
val x = buff.readFloat()
|
||||||
val y = buff.readFloat()
|
val y = buff.readFloat()
|
||||||
@ -47,10 +47,10 @@ enum class SkinElementType {
|
|||||||
val imageHeight = buff.readFloat()
|
val imageHeight = buff.readFloat()
|
||||||
val winding = buff.readEnum(UVWindingOrder::class.java)
|
val winding = buff.readEnum(UVWindingOrder::class.java)
|
||||||
|
|
||||||
return SkinElement(texture, x, y, width, height, imageWidth, imageHeight, winding)
|
return MatterySprite(texture, x, y, width, height, imageWidth, imageHeight, winding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fromJson(element: JsonObject): AbstractSkinElement {
|
override fun fromJson(element: JsonObject): AbstractMatterySprite {
|
||||||
val texture = element["texture"]?.asString ?: throw JsonSyntaxException("Missing texture element")
|
val texture = element["texture"]?.asString ?: throw JsonSyntaxException("Missing texture element")
|
||||||
val x = element["x"]?.asFloat ?: throw JsonSyntaxException("Missing x element")
|
val x = element["x"]?.asFloat ?: throw JsonSyntaxException("Missing x element")
|
||||||
val y = element["y"]?.asFloat ?: throw JsonSyntaxException("Missing y element")
|
val y = element["y"]?.asFloat ?: throw JsonSyntaxException("Missing y element")
|
||||||
@ -60,12 +60,12 @@ enum class SkinElementType {
|
|||||||
val imageHeight = element["imageHeight"]?.asFloat ?: throw JsonSyntaxException("Missing imageHeight element")
|
val imageHeight = element["imageHeight"]?.asFloat ?: throw JsonSyntaxException("Missing imageHeight element")
|
||||||
val winding = element["winding"]?.asString ?: throw JsonSyntaxException("Missing winding element")
|
val winding = element["winding"]?.asString ?: throw JsonSyntaxException("Missing winding element")
|
||||||
|
|
||||||
return SkinElement(ResourceLocation.tryParse(texture) ?: throw JsonSyntaxException("Invalid resource location: $texture"), x, y, width, height, imageWidth, imageHeight, UVWindingOrder.valueOf(winding))
|
return MatterySprite(ResourceLocation.tryParse(texture) ?: throw JsonSyntaxException("Invalid resource location: $texture"), x, y, width, height, imageWidth, imageHeight, UVWindingOrder.valueOf(winding))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ATLAS {
|
ATLAS {
|
||||||
override fun toJson(value: AbstractSkinElement): JsonObject {
|
override fun toJson(value: AbstractMatterySprite): JsonObject {
|
||||||
require(value is AtlasSkinElement) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" }
|
require(value is AtlasMatterySprite) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" }
|
||||||
|
|
||||||
return JsonObject().also {
|
return JsonObject().also {
|
||||||
it["location"] = JsonPrimitive(value.location.toString())
|
it["location"] = JsonPrimitive(value.location.toString())
|
||||||
@ -74,33 +74,33 @@ enum class SkinElementType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) {
|
override fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) {
|
||||||
require(value is AtlasSkinElement) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" }
|
require(value is AtlasMatterySprite) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" }
|
||||||
|
|
||||||
buff.writeResourceLocation(value.location)
|
buff.writeResourceLocation(value.location)
|
||||||
buff.writeFloat(value.width)
|
buff.writeFloat(value.width)
|
||||||
buff.writeFloat(value.height)
|
buff.writeFloat(value.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement {
|
override fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite {
|
||||||
val location = ResourceLocation(buff.readUtf())
|
val location = ResourceLocation(buff.readUtf())
|
||||||
val width = buff.readFloat()
|
val width = buff.readFloat()
|
||||||
val height = buff.readFloat()
|
val height = buff.readFloat()
|
||||||
|
|
||||||
return AtlasSkinElement(location, width, height)
|
return AtlasMatterySprite(location, width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fromJson(element: JsonObject): AbstractSkinElement {
|
override fun fromJson(element: JsonObject): AbstractMatterySprite {
|
||||||
val location = element["location"]?.asString ?: throw JsonSyntaxException("Missing location element")
|
val location = element["location"]?.asString ?: throw JsonSyntaxException("Missing location element")
|
||||||
val width = element["width"]?.asFloat ?: throw JsonSyntaxException("Missing width element")
|
val width = element["width"]?.asFloat ?: throw JsonSyntaxException("Missing width element")
|
||||||
val height = element["height"]?.asFloat ?: throw JsonSyntaxException("Missing height element")
|
val height = element["height"]?.asFloat ?: throw JsonSyntaxException("Missing height element")
|
||||||
|
|
||||||
return AtlasSkinElement(ResourceLocation.tryParse(location) ?: throw JsonSyntaxException("Invalid resource location: $location"), width, height)
|
return AtlasMatterySprite(ResourceLocation.tryParse(location) ?: throw JsonSyntaxException("Invalid resource location: $location"), width, height)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SUBELEMENT {
|
SUBELEMENT {
|
||||||
override fun toJson(value: AbstractSkinElement): JsonObject {
|
override fun toJson(value: AbstractMatterySprite): JsonObject {
|
||||||
require(value is SubSkinElement) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" }
|
require(value is SubMatterySprite) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" }
|
||||||
|
|
||||||
return JsonObject().also {
|
return JsonObject().also {
|
||||||
it["parent"] = value.parent.toJson()
|
it["parent"] = value.parent.toJson()
|
||||||
@ -111,8 +111,8 @@ enum class SkinElementType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) {
|
override fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) {
|
||||||
require(value is SubSkinElement) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" }
|
require(value is SubMatterySprite) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" }
|
||||||
|
|
||||||
value.parent.toNetwork(buff)
|
value.parent.toNetwork(buff)
|
||||||
buff.writeFloat(value.xOffset)
|
buff.writeFloat(value.xOffset)
|
||||||
@ -121,50 +121,50 @@ enum class SkinElementType {
|
|||||||
buff.writeFloat(value.height)
|
buff.writeFloat(value.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement {
|
override fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite {
|
||||||
val parent = Companion.fromNetwork(buff)
|
val parent = Companion.fromNetwork(buff)
|
||||||
val xOffset = buff.readFloat()
|
val xOffset = buff.readFloat()
|
||||||
val yOffset = buff.readFloat()
|
val yOffset = buff.readFloat()
|
||||||
val subWidth = buff.readFloat()
|
val subWidth = buff.readFloat()
|
||||||
val subHeight = buff.readFloat()
|
val subHeight = buff.readFloat()
|
||||||
|
|
||||||
return SubSkinElement(parent, xOffset, yOffset, subWidth, subHeight)
|
return SubMatterySprite(parent, xOffset, yOffset, subWidth, subHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fromJson(element: JsonObject): AbstractSkinElement {
|
override fun fromJson(element: JsonObject): AbstractMatterySprite {
|
||||||
val parent = element["parent"] as? JsonObject ?: throw JsonSyntaxException("Invalid parent")
|
val parent = element["parent"] as? JsonObject ?: throw JsonSyntaxException("Invalid parent")
|
||||||
val xOffset = element["xOffset"].asFloat
|
val xOffset = element["xOffset"].asFloat
|
||||||
val yOffset = element["yOffset"].asFloat
|
val yOffset = element["yOffset"].asFloat
|
||||||
val subWidth = element["subWidth"].asFloat
|
val subWidth = element["subWidth"].asFloat
|
||||||
val subHeight = element["subHeight"].asFloat
|
val subHeight = element["subHeight"].asFloat
|
||||||
|
|
||||||
return SubSkinElement(Companion.fromJson(parent), xOffset, yOffset, subWidth, subHeight)
|
return SubMatterySprite(Companion.fromJson(parent), xOffset, yOffset, subWidth, subHeight)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected abstract fun toJson(value: AbstractSkinElement): JsonObject
|
protected abstract fun toJson(value: AbstractMatterySprite): JsonObject
|
||||||
protected abstract fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf)
|
protected abstract fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf)
|
||||||
protected abstract fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement
|
protected abstract fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite
|
||||||
protected abstract fun fromJson(element: JsonObject): AbstractSkinElement
|
protected abstract fun fromJson(element: JsonObject): AbstractMatterySprite
|
||||||
|
|
||||||
fun toActualJson(value: AbstractSkinElement): JsonObject {
|
fun toActualJson(value: AbstractMatterySprite): JsonObject {
|
||||||
return toJson(value).also {
|
return toJson(value).also {
|
||||||
it["type"] = JsonPrimitive(name)
|
it["type"] = JsonPrimitive(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toActualNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) {
|
fun toActualNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) {
|
||||||
buff.writeEnum(this)
|
buff.writeEnum(this)
|
||||||
toNetwork(value, buff)
|
toNetwork(value, buff)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement {
|
fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite {
|
||||||
val type = buff.readEnum(SkinElementType::class.java)
|
val type = buff.readEnum(SkinElementType::class.java)
|
||||||
return type.fromNetwork(buff)
|
return type.fromNetwork(buff)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fromJson(element: JsonObject): AbstractSkinElement {
|
fun fromJson(element: JsonObject): AbstractMatterySprite {
|
||||||
val type = SkinElementType.valueOf(element["type"].asString)
|
val type = SkinElementType.valueOf(element["type"].asString)
|
||||||
return type.fromJson(element)
|
return type.fromJson(element)
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ data class SkinGrid(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun next(): SkinElement {
|
fun next(): MatterySprite {
|
||||||
val element = SkinElement(texture, currentX, currentY, width, height, imageWidth, imageHeight)
|
val element = MatterySprite(texture, currentX, currentY, width, height, imageWidth, imageHeight)
|
||||||
skip()
|
skip()
|
||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
@ -54,5 +54,5 @@ data class SkinGrid(
|
|||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(column: Int, row: Int) =
|
operator fun get(column: Int, row: Int) =
|
||||||
SkinElement(texture, column * width, row * height, width, height, imageWidth, imageHeight)
|
MatterySprite(texture, column * width, row * height, width, height, imageWidth, imageHeight)
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,15 @@ import net.minecraft.resources.ResourceLocation
|
|||||||
import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty
|
import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty
|
||||||
|
|
||||||
data class StretchingRectangleElement(
|
data class StretchingRectangleElement(
|
||||||
val topLeft: AbstractSkinElement,
|
val topLeft: AbstractMatterySprite,
|
||||||
val topRight: AbstractSkinElement,
|
val topRight: AbstractMatterySprite,
|
||||||
val bottomLeft: AbstractSkinElement,
|
val bottomLeft: AbstractMatterySprite,
|
||||||
val bottomRight: AbstractSkinElement,
|
val bottomRight: AbstractMatterySprite,
|
||||||
val left: AbstractSkinElement,
|
val left: AbstractMatterySprite,
|
||||||
val right: AbstractSkinElement,
|
val right: AbstractMatterySprite,
|
||||||
val top: AbstractSkinElement,
|
val top: AbstractMatterySprite,
|
||||||
val bottom: AbstractSkinElement,
|
val bottom: AbstractMatterySprite,
|
||||||
val middle: AbstractSkinElement,
|
val middle: AbstractMatterySprite,
|
||||||
val padding: DockProperty = DockProperty.EMPTY
|
val padding: DockProperty = DockProperty.EMPTY
|
||||||
) {
|
) {
|
||||||
fun render(
|
fun render(
|
||||||
|
@ -2,14 +2,14 @@ package ru.dbotthepony.mc.otm.client.render
|
|||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
|
|
||||||
class SubSkinElement(
|
class SubMatterySprite(
|
||||||
val parent: AbstractSkinElement,
|
val parent: AbstractMatterySprite,
|
||||||
val xOffset: Float = 0f,
|
val xOffset: Float = 0f,
|
||||||
val yOffset: Float = 0f,
|
val yOffset: Float = 0f,
|
||||||
override val width: Float = parent.width,
|
override val width: Float = parent.width,
|
||||||
override val height: Float = parent.height,
|
override val height: Float = parent.height,
|
||||||
private val overrideWinding: UVWindingOrder? = null
|
private val overrideWinding: UVWindingOrder? = null
|
||||||
) : AbstractSkinElement.Mutable() {
|
) : AbstractMatterySprite.Mutable() {
|
||||||
override var u0: Float = 0f
|
override var u0: Float = 0f
|
||||||
private set
|
private set
|
||||||
override var v0: Float = 0f
|
override var v0: Float = 0f
|
||||||
@ -28,7 +28,7 @@ class SubSkinElement(
|
|||||||
notifyListeners()
|
notifyListeners()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun parentChanges(parent: AbstractSkinElement) = calculateUVs()
|
override fun parentChanges(parent: AbstractMatterySprite) = calculateUVs()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
parent.addListener(this)
|
parent.addListener(this)
|
||||||
@ -53,12 +53,12 @@ class SubSkinElement(
|
|||||||
width: Float = this.width,
|
width: Float = this.width,
|
||||||
height: Float = this.height,
|
height: Float = this.height,
|
||||||
overrideWinding: UVWindingOrder? = this.overrideWinding
|
overrideWinding: UVWindingOrder? = this.overrideWinding
|
||||||
) = SubSkinElement(parent, xOffset, yOffset, width, height, overrideWinding)
|
) = SubMatterySprite(parent, xOffset, yOffset, width, height, overrideWinding)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AbstractSkinElement.subElement(
|
fun AbstractMatterySprite.subElement(
|
||||||
x: Float = 0f,
|
x: Float = 0f,
|
||||||
y: Float = 0f,
|
y: Float = 0f,
|
||||||
width: Float = this.width,
|
width: Float = this.width,
|
||||||
height: Float = this.height,
|
height: Float = this.height,
|
||||||
) = SubSkinElement(this, x, y, width, height)
|
) = SubMatterySprite(this, x, y, width, height)
|
@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.render
|
|||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
data class SubSkinGrid(
|
data class SubSkinGrid(
|
||||||
val parent: AbstractSkinElement,
|
val parent: AbstractMatterySprite,
|
||||||
val width: Float,
|
val width: Float,
|
||||||
val height: Float,
|
val height: Float,
|
||||||
val columns: Int = 16,
|
val columns: Int = 16,
|
||||||
@ -30,7 +30,7 @@ data class SubSkinGrid(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun next(): AbstractSkinElement {
|
fun next(): AbstractMatterySprite {
|
||||||
val element = parent.subElement(currentX, currentY, width, height)
|
val element = parent.subElement(currentX, currentY, width, height)
|
||||||
skip()
|
skip()
|
||||||
return element
|
return element
|
||||||
@ -52,7 +52,7 @@ data class SubSkinGrid(
|
|||||||
parent.subElement(column * width, row * height, width, height)
|
parent.subElement(column * width, row * height, width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AbstractSkinElement.subGrid(
|
fun AbstractMatterySprite.subGrid(
|
||||||
width: Float,
|
width: Float,
|
||||||
height: Float,
|
height: Float,
|
||||||
columns: Int = 16,
|
columns: Int = 16,
|
||||||
|
@ -1,99 +0,0 @@
|
|||||||
package ru.dbotthepony.mc.otm.client.render
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlas
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager
|
|
||||||
import net.minecraft.client.resources.TextureAtlasHolder
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
|
||||||
import net.minecraft.server.packs.resources.ResourceManager
|
|
||||||
import net.minecraft.util.profiling.ProfilerFiller
|
|
||||||
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent
|
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
|
||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
|
||||||
import ru.dbotthepony.mc.otm.isClientThread
|
|
||||||
import ru.dbotthepony.mc.otm.core.WriteOnce
|
|
||||||
import java.util.stream.Stream
|
|
||||||
import kotlin.properties.Delegates
|
|
||||||
|
|
||||||
var isWidgetAtlasAvailable: Boolean = false
|
|
||||||
private set
|
|
||||||
|
|
||||||
class WidgetAtlasHolder private constructor(manager: TextureManager) : TextureAtlasHolder(manager, LOCATION, INFO_LOCATION) {
|
|
||||||
var changeset = 0
|
|
||||||
private set
|
|
||||||
|
|
||||||
var once = false
|
|
||||||
private set
|
|
||||||
var demandsRebuild = false
|
|
||||||
private set
|
|
||||||
|
|
||||||
private var resourceManager by Delegates.notNull<ResourceManager>()
|
|
||||||
private var profileManager by Delegates.notNull<ProfilerFiller>()
|
|
||||||
|
|
||||||
override fun prepare(p_118891_: ResourceManager, p_118892_: ProfilerFiller): TextureAtlas.Preparations {
|
|
||||||
resourceManager = p_118891_
|
|
||||||
profileManager = p_118892_
|
|
||||||
changeset++
|
|
||||||
return super.prepare(p_118891_, p_118892_)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun apply(p_118894_: TextureAtlas.Preparations, p_118895_: ResourceManager, p_118896_: ProfilerFiller) {
|
|
||||||
once = true
|
|
||||||
resourceManager = p_118895_
|
|
||||||
profileManager = p_118896_
|
|
||||||
changeset++
|
|
||||||
super.apply(p_118894_, p_118895_, p_118896_)
|
|
||||||
AtlasSkinElement.notifyListeners()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun rebuildIfRequired(): Boolean {
|
|
||||||
if (once && demandsRebuild && isClientThread()) {
|
|
||||||
apply(prepare(resourceManager, profileManager), resourceManager, profileManager)
|
|
||||||
}
|
|
||||||
|
|
||||||
return demandsRebuild
|
|
||||||
}
|
|
||||||
|
|
||||||
public override fun getSprite(p_118902_: ResourceLocation): TextureAtlasSprite {
|
|
||||||
if (!once) {
|
|
||||||
throw IllegalStateException("Trying to get sprite too early")
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getSprite(p_118902_)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun queueRebuild() {
|
|
||||||
demandsRebuild = true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getResourcesToLoad(): Stream<ResourceLocation> {
|
|
||||||
demandsRebuild = false
|
|
||||||
return AtlasSkinElement.keysStream
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmStatic
|
|
||||||
val LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/atlas/gui.png")
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
val INFO_LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "fuck/you/mojang")
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
var INSTANCE: WidgetAtlasHolder by WriteOnce()
|
|
||||||
private set
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun register(event: RegisterClientReloadListenersEvent) {
|
|
||||||
INSTANCE = WidgetAtlasHolder(minecraft.textureManager)
|
|
||||||
event.registerReloadListener(INSTANCE)
|
|
||||||
isWidgetAtlasAvailable = true
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun renderGameHook() {
|
|
||||||
if (isWidgetAtlasAvailable) {
|
|
||||||
INSTANCE.rebuildIfRequired()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,11 +6,11 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
|||||||
object WidgetLocation {
|
object WidgetLocation {
|
||||||
val WIDGETS_18 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png")
|
val WIDGETS_18 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png")
|
||||||
|
|
||||||
val MISC = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/misc"), 64f, 64f)
|
val MISC = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/misc"), 64f, 64f)
|
||||||
val PATTERN_PANEL_TABS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/pattern_panel_tabs"), 64f, 32f)
|
val PATTERN_PANEL_TABS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/pattern_panel_tabs"), 64f, 32f)
|
||||||
|
|
||||||
val CHECKBOX = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/checkbox"), 32f, 64f)
|
val CHECKBOX = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/checkbox"), 32f, 64f)
|
||||||
val PROGRESS_ARROWS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/progress_arrows"), 32f, 32f)
|
val PROGRESS_ARROWS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/progress_arrows"), 32f, 32f)
|
||||||
val HORIZONTAL_GAUGES = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/horizontal_gauges"), 128f, 64f)
|
val HORIZONTAL_GAUGES = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/horizontal_gauges"), 128f, 64f)
|
||||||
val VERTICAL_GAUGES = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/vertical_gauges"), 128f, 48f)
|
val VERTICAL_GAUGES = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/vertical_gauges"), 128f, 48f)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import net.minecraft.resources.ResourceLocation
|
|||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
|
|
||||||
object Widgets8 {
|
object Widgets8 {
|
||||||
val GRID = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets_8"), 64f, 32f).subGrid(8f, 8f, 64 / 8, 32 / 8)
|
val GRID = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets_8"), 64f, 32f).subGrid(8f, 8f, 64 / 8, 32 / 8)
|
||||||
|
|
||||||
val BUTTON_IDLE = GRID[0, 0]
|
val BUTTON_IDLE = GRID[0, 0]
|
||||||
val BUTTON_HOVERED = GRID[0, 1]
|
val BUTTON_HOVERED = GRID[0, 1]
|
||||||
|
@ -9,8 +9,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
|||||||
import ru.dbotthepony.mc.otm.block.entity.BatteryBankBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.BatteryBankBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.AtlasSkinElement
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||||
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
|
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
|
||||||
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
|
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
|
||||||
@ -20,7 +19,7 @@ import kotlin.math.PI
|
|||||||
|
|
||||||
abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<T> {
|
abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<T> {
|
||||||
protected abstract fun gaugeLevel(entity: T): Float
|
protected abstract fun gaugeLevel(entity: T): Float
|
||||||
protected abstract val texture: AbstractSkinElement
|
protected abstract val texture: AbstractMatterySprite
|
||||||
|
|
||||||
override fun render(
|
override fun render(
|
||||||
blockEntity: T,
|
blockEntity: T,
|
||||||
@ -53,7 +52,7 @@ abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEn
|
|||||||
val width = 9f
|
val width = 9f
|
||||||
val heightMax = 39.36f
|
val heightMax = 39.36f
|
||||||
|
|
||||||
val buffer = DynamicBufferSource.WORLD.getBuffer(AtlasSkinElement.renderTypeWorld)
|
val buffer = DynamicBufferSource.WORLD.getBuffer(AtlasMatterySprite.renderTypeWorld)
|
||||||
|
|
||||||
texture.uploadOntoPartialColor(
|
texture.uploadOntoPartialColor(
|
||||||
stack,
|
stack,
|
||||||
@ -85,7 +84,7 @@ class BatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRe
|
|||||||
return entity.gaugeLevel
|
return entity.gaugeLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
override val texture: AbstractSkinElement
|
override val texture: AbstractMatterySprite
|
||||||
get() = PowerGaugePanel.GAUGE_FOREGROUND
|
get() = PowerGaugePanel.GAUGE_FOREGROUND
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +93,7 @@ class MatterBatteryBankRenderer(context: BlockEntityRendererProvider.Context) :
|
|||||||
return entity.gaugeLevel
|
return entity.gaugeLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
override val texture: AbstractSkinElement
|
override val texture: AbstractMatterySprite
|
||||||
get() = MatterGaugePanel.GAUGE_FOREGROUND
|
get() = MatterGaugePanel.GAUGE_FOREGROUND
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ abstract class AbstractSlotPanel<out S : MatteryScreen<*>> @JvmOverloads constru
|
|||||||
y: Float = 0f,
|
y: Float = 0f,
|
||||||
width: Float = SIZE,
|
width: Float = SIZE,
|
||||||
height: Float = SIZE,
|
height: Float = SIZE,
|
||||||
open val noItemIcon: SkinElement? = null
|
open val noItemIcon: MatterySprite? = null
|
||||||
) : EditablePanel<S>(screen, parent, x, y, width, height), IItemStackPanel {
|
) : EditablePanel<S>(screen, parent, x, y, width, height), IItemStackPanel {
|
||||||
protected open fun renderSlotBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
protected open fun renderSlotBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||||
SLOT_BACKGROUND.render(stack, width = width, height = height)
|
SLOT_BACKGROUND.render(stack, width = width, height = height)
|
||||||
|
@ -25,8 +25,8 @@ open class FramePanel<out S : Screen>(
|
|||||||
open inner class Tab(
|
open inner class Tab(
|
||||||
var onOpen: Runnable? = null,
|
var onOpen: Runnable? = null,
|
||||||
var onClose: Runnable? = null,
|
var onClose: Runnable? = null,
|
||||||
var activeIcon: AbstractSkinElement? = null,
|
var activeIcon: AbstractMatterySprite? = null,
|
||||||
var inactiveIcon: AbstractSkinElement? = null,
|
var inactiveIcon: AbstractMatterySprite? = null,
|
||||||
) : EditablePanel<S>(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) {
|
) : EditablePanel<S>(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) {
|
||||||
var isActive = tabs.isEmpty()
|
var isActive = tabs.isEmpty()
|
||||||
var initial = false
|
var initial = false
|
||||||
|
@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels
|
|||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants
|
import com.mojang.blaze3d.platform.InputConstants
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.Widgets
|
import ru.dbotthepony.mc.otm.client.render.Widgets
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel
|
||||||
|
|
||||||
@ -45,10 +45,10 @@ open class HeightControls<out S : Screen>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
open inner class Control(val isIncrease: Boolean) : RectangleButtonPanel<S>(screen, this@HeightControls, width = BUTTON_WIDTH, height = BUTTON_HEIGHT) {
|
open inner class Control(val isIncrease: Boolean) : RectangleButtonPanel<S>(screen, this@HeightControls, width = BUTTON_WIDTH, height = BUTTON_HEIGHT) {
|
||||||
override val PRESSED: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_PRESSED else Widgets.ARROW_UP_BUTTON_PRESSED
|
override val PRESSED: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_PRESSED else Widgets.ARROW_UP_BUTTON_PRESSED
|
||||||
override val HOVERED: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_HOVERED else Widgets.ARROW_UP_BUTTON_HOVERED
|
override val HOVERED: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_HOVERED else Widgets.ARROW_UP_BUTTON_HOVERED
|
||||||
override val IDLE: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_IDLE else Widgets.ARROW_UP_BUTTON_IDLE
|
override val IDLE: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_IDLE else Widgets.ARROW_UP_BUTTON_IDLE
|
||||||
override val DISABLED: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_DISABLED else Widgets.ARROW_UP_BUTTON_DISABLED
|
override val DISABLED: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_DISABLED else Widgets.ARROW_UP_BUTTON_DISABLED
|
||||||
|
|
||||||
init {
|
init {
|
||||||
dock = Dock.TOP
|
dock = Dock.TOP
|
||||||
|
@ -2,34 +2,30 @@ package ru.dbotthepony.mc.otm.client.screen.panels
|
|||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.AtlasSkinElement
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.element
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.subElement
|
import ru.dbotthepony.mc.otm.client.render.subElement
|
||||||
|
|
||||||
object ScrollBarConstants {
|
object ScrollBarConstants {
|
||||||
const val WIDTH = 14f
|
const val WIDTH = 14f
|
||||||
const val SLIM_WIDTH = 8f
|
const val SLIM_WIDTH = 8f
|
||||||
|
|
||||||
val BACKGROUND = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/background"), 14f, 8f)
|
val BACKGROUND = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/background"), 14f, 8f)
|
||||||
val BACKGROUND_SLIM = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/background"), 8f, 8f)
|
val BACKGROUND_SLIM = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/background"), 8f, 8f)
|
||||||
|
|
||||||
val TOP = BACKGROUND.subElement(height = 2f)
|
val TOP = BACKGROUND.subElement(height = 2f)
|
||||||
val BODY = BACKGROUND.subElement(y = 2f, height = 5f)
|
val BODY = BACKGROUND.subElement(y = 2f, height = 5f)
|
||||||
val BOTTOM = BACKGROUND.subElement(y = 6f, height = 2f)
|
val BOTTOM = BACKGROUND.subElement(y = 6f, height = 2f)
|
||||||
|
|
||||||
val BUTTON = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/idle"), 12f, 15f)
|
val BUTTON = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/idle"), 12f, 15f)
|
||||||
val BUTTON_HOVER = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/hovered"), 12f, 15f)
|
val BUTTON_HOVER = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/hovered"), 12f, 15f)
|
||||||
val BUTTON_PRESS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/pressed"), 12f, 15f)
|
val BUTTON_PRESS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/pressed"), 12f, 15f)
|
||||||
val BUTTON_DISABLED = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/disabled"), 12f, 15f)
|
val BUTTON_DISABLED = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/disabled"), 12f, 15f)
|
||||||
|
|
||||||
val SLIM_TOP = BACKGROUND_SLIM.subElement(height = 2f)
|
val SLIM_TOP = BACKGROUND_SLIM.subElement(height = 2f)
|
||||||
val SLIM_BODY = BACKGROUND_SLIM.subElement(y = 2f, height = 5f)
|
val SLIM_BODY = BACKGROUND_SLIM.subElement(y = 2f, height = 5f)
|
||||||
val SLIM_BOTTOM = BACKGROUND_SLIM.subElement(y = 6f, height = 2f)
|
val SLIM_BOTTOM = BACKGROUND_SLIM.subElement(y = 6f, height = 2f)
|
||||||
|
|
||||||
val SLIM_BUTTON = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/idle"), 6f, 15f)
|
val SLIM_BUTTON = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/idle"), 6f, 15f)
|
||||||
val SLIM_BUTTON_HOVER = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/hovered"), 6f, 15f)
|
val SLIM_BUTTON_HOVER = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/hovered"), 6f, 15f)
|
||||||
val SLIM_BUTTON_PRESS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/pressed"), 6f, 15f)
|
val SLIM_BUTTON_PRESS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/pressed"), 6f, 15f)
|
||||||
val SLIM_BUTTON_DISABLED = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/disabled"), 6f, 15f)
|
val SLIM_BUTTON_DISABLED = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/disabled"), 6f, 15f)
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,12 @@ import com.mojang.blaze3d.systems.RenderSystem
|
|||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import net.minecraft.ChatFormatting
|
import net.minecraft.ChatFormatting
|
||||||
import net.minecraft.client.gui.GuiComponent
|
import net.minecraft.client.gui.GuiComponent
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
|
||||||
import net.minecraft.client.renderer.GameRenderer
|
import net.minecraft.client.renderer.GameRenderer
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu
|
import net.minecraft.world.inventory.AbstractContainerMenu
|
||||||
import net.minecraft.world.inventory.Slot
|
import net.minecraft.world.inventory.Slot
|
||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.mc.otm.client.render.SkinElement
|
import ru.dbotthepony.mc.otm.client.render.MatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
||||||
import ru.dbotthepony.mc.otm.client.render.drawRect
|
import ru.dbotthepony.mc.otm.client.render.drawRect
|
||||||
import ru.dbotthepony.mc.otm.client.render.setDrawColor
|
import ru.dbotthepony.mc.otm.client.render.setDrawColor
|
||||||
@ -28,7 +27,7 @@ open class SlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads const
|
|||||||
y: Float = 0f,
|
y: Float = 0f,
|
||||||
width: Float = SIZE,
|
width: Float = SIZE,
|
||||||
height: Float = SIZE,
|
height: Float = SIZE,
|
||||||
noItemIcon: SkinElement? = null
|
noItemIcon: MatterySprite? = null
|
||||||
) : AbstractSlotPanel<S>(screen, parent, x, y, width, height, noItemIcon), ISlotPanel<T> {
|
) : AbstractSlotPanel<S>(screen, parent, x, y, width, height, noItemIcon), ISlotPanel<T> {
|
||||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||||
screen.returnSlot = slot
|
screen.returnSlot = slot
|
||||||
|
@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons
|
|||||||
import com.mojang.blaze3d.platform.InputConstants
|
import com.mojang.blaze3d.platform.InputConstants
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||||
import ru.dbotthepony.mc.otm.core.GetterSetter
|
import ru.dbotthepony.mc.otm.core.GetterSetter
|
||||||
import ru.dbotthepony.mc.otm.core.value
|
import ru.dbotthepony.mc.otm.core.value
|
||||||
@ -16,8 +16,8 @@ abstract class BooleanRectangleButtonPanel<out S : Screen>(
|
|||||||
width: Float,
|
width: Float,
|
||||||
height: Float,
|
height: Float,
|
||||||
val prop: GetterSetter<Boolean>,
|
val prop: GetterSetter<Boolean>,
|
||||||
val skinElementActive: AbstractSkinElement? = null,
|
val skinElementActive: AbstractMatterySprite? = null,
|
||||||
val skinElementInactive: AbstractSkinElement? = null,
|
val skinElementInactive: AbstractMatterySprite? = null,
|
||||||
val onChange: ((newValue: Boolean) -> Unit)? = null,
|
val onChange: ((newValue: Boolean) -> Unit)? = null,
|
||||||
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height, null) {
|
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height, null) {
|
||||||
override fun onClick(clickButton: Int) {
|
override fun onClick(clickButton: Int) {
|
||||||
|
@ -4,7 +4,7 @@ import com.mojang.blaze3d.platform.InputConstants
|
|||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import ru.dbotthepony.mc.otm.client.playGuiClickSound
|
import ru.dbotthepony.mc.otm.client.playGuiClickSound
|
||||||
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
||||||
import ru.dbotthepony.mc.otm.client.render.subGrid
|
import ru.dbotthepony.mc.otm.client.render.subGrid
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||||
@ -81,14 +81,14 @@ open class CheckBoxPanel<out S : Screen> @JvmOverloads constructor(
|
|||||||
companion object {
|
companion object {
|
||||||
const val REGULAR_DIMENSIONS = 15f
|
const val REGULAR_DIMENSIONS = 15f
|
||||||
|
|
||||||
val IDLE_UNCHECKED: AbstractSkinElement
|
val IDLE_UNCHECKED: AbstractMatterySprite
|
||||||
val IDLE_CHECKED: AbstractSkinElement
|
val IDLE_CHECKED: AbstractMatterySprite
|
||||||
val HOVERED_UNCHECKED: AbstractSkinElement
|
val HOVERED_UNCHECKED: AbstractMatterySprite
|
||||||
val HOVERED_CHECKED: AbstractSkinElement
|
val HOVERED_CHECKED: AbstractMatterySprite
|
||||||
val PRESSED_UNCHECKED: AbstractSkinElement
|
val PRESSED_UNCHECKED: AbstractMatterySprite
|
||||||
val PRESSED_CHECKED: AbstractSkinElement
|
val PRESSED_CHECKED: AbstractMatterySprite
|
||||||
val DISABLED_UNCHECKED: AbstractSkinElement
|
val DISABLED_UNCHECKED: AbstractMatterySprite
|
||||||
val DISABLED_CHECKED: AbstractSkinElement
|
val DISABLED_CHECKED: AbstractMatterySprite
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val grid = WidgetLocation.CHECKBOX.subGrid(REGULAR_DIMENSIONS, REGULAR_DIMENSIONS, 2, 4)
|
val grid = WidgetLocation.CHECKBOX.subGrid(REGULAR_DIMENSIONS, REGULAR_DIMENSIONS, 2, 4)
|
||||||
|
@ -5,7 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack
|
|||||||
import net.minecraft.ChatFormatting
|
import net.minecraft.ChatFormatting
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||||
import ru.dbotthepony.mc.otm.core.GetterSetter
|
import ru.dbotthepony.mc.otm.core.GetterSetter
|
||||||
@ -30,7 +30,7 @@ abstract class EnumRectangleButtonPanel<out S : Screen, T : Enum<T>>(
|
|||||||
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height, null) {
|
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height, null) {
|
||||||
private var building = true
|
private var building = true
|
||||||
|
|
||||||
protected val enumMapping = EnumMap<T, Pair<AbstractSkinElement, UVWindingOrder>>(enum)
|
protected val enumMapping = EnumMap<T, Pair<AbstractMatterySprite, UVWindingOrder>>(enum)
|
||||||
protected val tooltipMapping = EnumMap<T, Component>(enum)
|
protected val tooltipMapping = EnumMap<T, Component>(enum)
|
||||||
|
|
||||||
fun addTooltip(value: T, component: Component): EnumRectangleButtonPanel<S, T> {
|
fun addTooltip(value: T, component: Component): EnumRectangleButtonPanel<S, T> {
|
||||||
@ -69,19 +69,19 @@ abstract class EnumRectangleButtonPanel<out S : Screen, T : Enum<T>>(
|
|||||||
return missing
|
return missing
|
||||||
}
|
}
|
||||||
|
|
||||||
fun add(value: T, skinElement: AbstractSkinElement, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel<S, T> {
|
fun add(value: T, skinElement: AbstractMatterySprite, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel<S, T> {
|
||||||
return add(value, skinElement to winding)
|
return add(value, skinElement to winding)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun add(value: T, skinElement: AbstractSkinElement, component: Component, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel<S, T> {
|
fun add(value: T, skinElement: AbstractMatterySprite, component: Component, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel<S, T> {
|
||||||
return add(value, component, skinElement to winding)
|
return add(value, component, skinElement to winding)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun add(value: T, component: Component, skinElement: AbstractSkinElement, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel<S, T> {
|
fun add(value: T, component: Component, skinElement: AbstractMatterySprite, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel<S, T> {
|
||||||
return add(value, component, skinElement to winding)
|
return add(value, component, skinElement to winding)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun add(value: T, pair: Pair<AbstractSkinElement, UVWindingOrder>): EnumRectangleButtonPanel<S, T> {
|
fun add(value: T, pair: Pair<AbstractMatterySprite, UVWindingOrder>): EnumRectangleButtonPanel<S, T> {
|
||||||
check(building) { "Not building" }
|
check(building) { "Not building" }
|
||||||
check(enumMapping.put(value, pair) == null) { "Already has mapping for $value" }
|
check(enumMapping.put(value, pair) == null) { "Already has mapping for $value" }
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ abstract class EnumRectangleButtonPanel<out S : Screen, T : Enum<T>>(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun add(value: T, component: Component, pair: Pair<AbstractSkinElement, UVWindingOrder>): EnumRectangleButtonPanel<S, T> {
|
fun add(value: T, component: Component, pair: Pair<AbstractMatterySprite, UVWindingOrder>): EnumRectangleButtonPanel<S, T> {
|
||||||
addTooltip(value, component)
|
addTooltip(value, component)
|
||||||
return add(value, pair)
|
return add(value, pair)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package ru.dbotthepony.mc.otm.client.screen.panels.buttons
|
package ru.dbotthepony.mc.otm.client.screen.panels.buttons
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||||
import ru.dbotthepony.mc.otm.core.GetterSetter
|
import ru.dbotthepony.mc.otm.core.GetterSetter
|
||||||
@ -14,8 +14,8 @@ open class LargeBooleanRectangleButtonPanel<out S : Screen>(
|
|||||||
width: Float = SIZE,
|
width: Float = SIZE,
|
||||||
height: Float = SIZE,
|
height: Float = SIZE,
|
||||||
prop: GetterSetter<Boolean>,
|
prop: GetterSetter<Boolean>,
|
||||||
skinElementActive: AbstractSkinElement? = null,
|
skinElementActive: AbstractMatterySprite? = null,
|
||||||
skinElementInactive: AbstractSkinElement? = null,
|
skinElementInactive: AbstractMatterySprite? = null,
|
||||||
onChange: ((newValue: Boolean) -> Unit)? = null,
|
onChange: ((newValue: Boolean) -> Unit)? = null,
|
||||||
) : BooleanRectangleButtonPanel<S>(screen, parent, x, y, width, height, prop, skinElementActive, skinElementInactive, onChange) {
|
) : BooleanRectangleButtonPanel<S>(screen, parent, x, y, width, height, prop, skinElementActive, skinElementInactive, onChange) {
|
||||||
final override val IDLE = Widgets18.BUTTON_IDLE
|
final override val IDLE = Widgets18.BUTTON_IDLE
|
||||||
|
@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons
|
|||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||||
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||||
@ -15,7 +15,7 @@ open class LargeRectangleButtonPanel<out S : Screen>(
|
|||||||
width: Float = SIZE,
|
width: Float = SIZE,
|
||||||
height: Float = SIZE,
|
height: Float = SIZE,
|
||||||
onPress: ((clickButton: Int) -> Unit)? = null,
|
onPress: ((clickButton: Int) -> Unit)? = null,
|
||||||
val skinElement: AbstractSkinElement? = null,
|
val skinElement: AbstractMatterySprite? = null,
|
||||||
val skinElementWinding: UVWindingOrder? = null,
|
val skinElementWinding: UVWindingOrder? = null,
|
||||||
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height, onPress) {
|
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height, onPress) {
|
||||||
final override val IDLE = Widgets18.BUTTON_IDLE
|
final override val IDLE = Widgets18.BUTTON_IDLE
|
||||||
|
@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons
|
|||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import ru.dbotthepony.mc.otm.client.playGuiClickSound
|
import ru.dbotthepony.mc.otm.client.playGuiClickSound
|
||||||
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||||
|
|
||||||
@Suppress("PropertyName")
|
@Suppress("PropertyName")
|
||||||
@ -22,10 +22,10 @@ abstract class RectangleButtonPanel<out S : Screen>(
|
|||||||
onPress?.invoke(clickButton)
|
onPress?.invoke(clickButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract val PRESSED: AbstractSkinElement
|
abstract val PRESSED: AbstractMatterySprite
|
||||||
abstract val HOVERED: AbstractSkinElement
|
abstract val HOVERED: AbstractMatterySprite
|
||||||
abstract val IDLE: AbstractSkinElement
|
abstract val IDLE: AbstractMatterySprite
|
||||||
abstract val DISABLED: AbstractSkinElement
|
abstract val DISABLED: AbstractMatterySprite
|
||||||
|
|
||||||
var isDisabled = false
|
var isDisabled = false
|
||||||
set(value) {
|
set(value) {
|
||||||
|
@ -13,8 +13,8 @@ open class SmallBooleanRectangleButtonPanel<out S : Screen>(
|
|||||||
width: Float = SIZE,
|
width: Float = SIZE,
|
||||||
height: Float = SIZE,
|
height: Float = SIZE,
|
||||||
prop: GetterSetter<Boolean>,
|
prop: GetterSetter<Boolean>,
|
||||||
skinElementActive: AbstractSkinElement? = null,
|
skinElementActive: AbstractMatterySprite? = null,
|
||||||
skinElementInactive: AbstractSkinElement? = null,
|
skinElementInactive: AbstractMatterySprite? = null,
|
||||||
onChange: ((newValue: Boolean) -> Unit)? = null,
|
onChange: ((newValue: Boolean) -> Unit)? = null,
|
||||||
) : BooleanRectangleButtonPanel<S>(screen, parent, x, y, width, height, prop, skinElementActive, skinElementInactive, onChange) {
|
) : BooleanRectangleButtonPanel<S>(screen, parent, x, y, width, height, prop, skinElementActive, skinElementInactive, onChange) {
|
||||||
final override val IDLE = Widgets8.BUTTON_IDLE
|
final override val IDLE = Widgets8.BUTTON_IDLE
|
||||||
|
@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons
|
|||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import ru.dbotthepony.mc.otm.client.render.SkinElement
|
import ru.dbotthepony.mc.otm.client.render.MatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||||
import ru.dbotthepony.mc.otm.client.render.Widgets8
|
import ru.dbotthepony.mc.otm.client.render.Widgets8
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||||
@ -15,7 +15,7 @@ open class SmallRectangleButtonPanel<out S : Screen>(
|
|||||||
width: Float = SIZE,
|
width: Float = SIZE,
|
||||||
height: Float = SIZE,
|
height: Float = SIZE,
|
||||||
onPress: ((clickButton: Int) -> Unit)? = null,
|
onPress: ((clickButton: Int) -> Unit)? = null,
|
||||||
val skinElement: SkinElement? = null,
|
val skinElement: MatterySprite? = null,
|
||||||
val skinElementWinding: UVWindingOrder? = null,
|
val skinElementWinding: UVWindingOrder? = null,
|
||||||
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height, onPress) {
|
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height, onPress) {
|
||||||
final override val IDLE = Widgets8.BUTTON_IDLE
|
final override val IDLE = Widgets8.BUTTON_IDLE
|
||||||
|
@ -17,7 +17,7 @@ import net.minecraft.world.inventory.Slot
|
|||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
import net.minecraftforge.fml.ModList
|
import net.minecraftforge.fml.ModList
|
||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.mc.otm.client.render.SkinElement
|
import ru.dbotthepony.mc.otm.client.render.MatterySprite
|
||||||
import ru.dbotthepony.mc.otm.client.render.element
|
import ru.dbotthepony.mc.otm.client.render.element
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel
|
import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel
|
||||||
@ -149,13 +149,13 @@ class CosmeticToggleButton<out S : Screen>(
|
|||||||
width: Float = 5f,
|
width: Float = 5f,
|
||||||
height: Float = 5f
|
height: Float = 5f
|
||||||
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height) {
|
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height) {
|
||||||
override val PRESSED: SkinElement
|
override val PRESSED: MatterySprite
|
||||||
get() = BUTTON_ACTIVE
|
get() = BUTTON_ACTIVE
|
||||||
override val HOVERED: SkinElement
|
override val HOVERED: MatterySprite
|
||||||
get() = BUTTON_ACTIVE
|
get() = BUTTON_ACTIVE
|
||||||
override val IDLE: SkinElement
|
override val IDLE: MatterySprite
|
||||||
get() = BUTTON_INACTIVE
|
get() = BUTTON_INACTIVE
|
||||||
override val DISABLED: SkinElement
|
override val DISABLED: MatterySprite
|
||||||
get() = BUTTON_INACTIVE
|
get() = BUTTON_INACTIVE
|
||||||
|
|
||||||
private val index = when (index) {
|
private val index = when (index) {
|
||||||
@ -198,13 +198,13 @@ class CosmeticToggleRenderButton<out S : Screen>(
|
|||||||
width: Float = 5f,
|
width: Float = 5f,
|
||||||
height: Float = 5f
|
height: Float = 5f
|
||||||
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height) {
|
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height) {
|
||||||
override val PRESSED: SkinElement
|
override val PRESSED: MatterySprite
|
||||||
get() = BUTTON_ACTIVE
|
get() = BUTTON_ACTIVE
|
||||||
override val HOVERED: SkinElement
|
override val HOVERED: MatterySprite
|
||||||
get() = BUTTON_ACTIVE
|
get() = BUTTON_ACTIVE
|
||||||
override val IDLE: SkinElement
|
override val IDLE: MatterySprite
|
||||||
get() = BUTTON_INACTIVE
|
get() = BUTTON_INACTIVE
|
||||||
override val DISABLED: SkinElement
|
override val DISABLED: MatterySprite
|
||||||
get() = BUTTON_INACTIVE
|
get() = BUTTON_INACTIVE
|
||||||
|
|
||||||
override fun onClick(clickButton: Int) {
|
override fun onClick(clickButton: Int) {
|
||||||
|
@ -2,9 +2,9 @@ package ru.dbotthepony.mc.otm.compat.jei
|
|||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import mezz.jei.api.gui.drawable.IDrawable
|
import mezz.jei.api.gui.drawable.IDrawable
|
||||||
import ru.dbotthepony.mc.otm.client.render.SkinElement
|
import ru.dbotthepony.mc.otm.client.render.MatterySprite
|
||||||
|
|
||||||
class SkinDrawable(val element: SkinElement) : IDrawable {
|
class SkinDrawable(val element: MatterySprite) : IDrawable {
|
||||||
override fun getWidth(): Int {
|
override fun getWidth(): Int {
|
||||||
return element.width.toInt()
|
return element.width.toInt()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user