mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
leak patched I guess
This commit is contained in:
@@ -5,7 +5,7 @@ import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.ui.UIVitalMetre
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-04-21.
|
||||
* Created by minjaesong on 2017-04-21.
|
||||
*/
|
||||
object AmmoMeterProxy {
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import net.torvald.terrarum.gameactors.ai.toInt
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
|
||||
@@ -15,90 +17,27 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
object ItemSlotImageBuilder {
|
||||
|
||||
// FIXME it leaks mem waaaaagh
|
||||
|
||||
val colourBlack = Color(0x404040_FF)
|
||||
val colourWhite = Color(0xC0C0C0_FF.toInt())
|
||||
|
||||
private val numberFont = TextureRegionPack(
|
||||
"./assets/graphics/fonts/numeric_small.tga", 5, 8
|
||||
)
|
||||
val slotImage = Pixmap(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slot.tga")) // must have same w/h as slotLarge
|
||||
val slotLarge = Pixmap(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slot_large.tga"))
|
||||
val slotImage = TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slot.tga"), 38, 38) // must have same w/h as slotLarge
|
||||
val slotLarge = TextureRegionPack(Gdx.files.internal("./assets/graphics/gui/quickbar/item_slot_large.tga"), 38, 38)
|
||||
|
||||
|
||||
private val imageDict = HashMap<ImageDesc, Texture>()
|
||||
private val imageDict = HashMap<Long, Texture>()
|
||||
|
||||
|
||||
fun produce(isBlack: Boolean, number: Int = -1): Texture {
|
||||
val pixmap = Pixmap(slotImage.width, slotImage.height, Pixmap.Format.RGBA8888)
|
||||
val color = if (isBlack) colourBlack else colourWhite
|
||||
|
||||
|
||||
val desc = ImageDesc(color, number, false)
|
||||
if (imageDict.containsKey(desc))
|
||||
return imageDict[desc]!!
|
||||
|
||||
|
||||
pixmap.setColor(color)
|
||||
pixmap.drawPixmap(slotImage, 0, 0)
|
||||
|
||||
|
||||
/*if (number >= 0) {
|
||||
if (isBlack)
|
||||
pixmap.setColor(colourWhite)
|
||||
else
|
||||
pixmap.setColor(colourBlack)
|
||||
|
||||
|
||||
pixmap.drawPixmap(fontPixmap,
|
||||
slotImage.width - 10,
|
||||
slotImage.height - 13
|
||||
)
|
||||
}*/
|
||||
|
||||
|
||||
val retTex = Texture(pixmap)
|
||||
pixmap.dispose()
|
||||
imageDict.put(desc, retTex)
|
||||
return retTex
|
||||
fun produce(isBlack: Boolean, number: Int = 10): TextureRegion {
|
||||
return slotImage.get(number, 0)
|
||||
}
|
||||
|
||||
fun produceLarge(isBlack: Boolean, number: Int = -1): Texture {
|
||||
val pixmap = Pixmap(slotLarge.width, slotLarge.height, Pixmap.Format.RGBA8888)
|
||||
val color = if (isBlack) colourBlack else colourWhite
|
||||
|
||||
|
||||
val desc = ImageDesc(color, number, false)
|
||||
if (imageDict.containsKey(desc))
|
||||
return imageDict[desc]!!
|
||||
|
||||
|
||||
pixmap.setColor(color)
|
||||
pixmap.drawPixmap(slotLarge, 0, 0)
|
||||
|
||||
|
||||
/*if (number >= 0) {
|
||||
if (isBlack)
|
||||
pixmap.setColor(colourWhite)
|
||||
else
|
||||
pixmap.setColor(colourBlack)
|
||||
|
||||
|
||||
pixmap.drawPixmap(fontPixmap,
|
||||
slotImage.width - 10,
|
||||
slotImage.height - 13
|
||||
)
|
||||
}*/
|
||||
|
||||
|
||||
val retTex = Texture(pixmap)
|
||||
pixmap.dispose()
|
||||
imageDict.put(desc, retTex)
|
||||
return retTex
|
||||
fun produceLarge(isBlack: Boolean, number: Int = 10): TextureRegion {
|
||||
return slotLarge.get(number, 0)
|
||||
}
|
||||
|
||||
|
||||
private data class ImageDesc(val color: Color, val number: Int, val isLarge: Boolean)
|
||||
|
||||
fun dispose() {
|
||||
slotImage.dispose()
|
||||
slotLarge.dispose()
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.ui
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-03-13.
|
||||
* Created by minjaesong on 2017-03-13.
|
||||
*/
|
||||
class NullUI : UICanvas() {
|
||||
override var width: Int = 0
|
||||
|
||||
@@ -17,7 +17,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-03-13.
|
||||
* Created by minjaesong on 2017-03-13.
|
||||
*/
|
||||
class UIInventory(
|
||||
var actor: Pocketed?,
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
/**
|
||||
* Text button. Height of hitbox is extended (double lineHeight, or 40 px) for better clicking
|
||||
*
|
||||
* Created by SKYHi14 on 2017-03-13.
|
||||
* Created by minjaesong on 2017-03-13.
|
||||
*/
|
||||
open class UIItemTextButton(
|
||||
parentUI: UICanvas,
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.torvald.terrarum.inUse
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-03-13.
|
||||
* Created by minjaesong on 2017-03-13.
|
||||
*/
|
||||
class UIItemTextButtonList(
|
||||
parentUI: UICanvas,
|
||||
|
||||
@@ -65,7 +65,7 @@ class UIPieMenu : UICanvas() {
|
||||
else
|
||||
ItemSlotImageBuilder.produce(true, i + 1)
|
||||
|
||||
val slotSize = image.width
|
||||
val slotSize = image.regionWidth
|
||||
|
||||
val slotX = slotCentrePoint.x.toFloat() - (slotSize / 2)
|
||||
val slotY = slotCentrePoint.y.toFloat() - (slotSize / 2)
|
||||
|
||||
@@ -14,15 +14,15 @@ import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
*/
|
||||
class UIQuickBar : UICanvas() {
|
||||
private val gutter = 8
|
||||
override var width: Int = (ItemSlotImageBuilder.slotImage.width + gutter) * SLOT_COUNT
|
||||
override var height: Int = ItemSlotImageBuilder.slotImage.height + 4 + Terrarum.fontGame.lineHeight.toInt()
|
||||
override var width: Int = (ItemSlotImageBuilder.slotImage.tileW + gutter) * SLOT_COUNT
|
||||
override var height: Int = ItemSlotImageBuilder.slotImage.tileH + 4 + Terrarum.fontGame.lineHeight.toInt()
|
||||
/**
|
||||
* In milliseconds
|
||||
*/
|
||||
override var openCloseTime: Second = 0.16f
|
||||
|
||||
private val startPointX = ItemSlotImageBuilder.slotLarge.width / 2
|
||||
private val startPointY = ItemSlotImageBuilder.slotLarge.height / 2
|
||||
private val startPointX = ItemSlotImageBuilder.slotLarge.tileW / 2
|
||||
private val startPointY = ItemSlotImageBuilder.slotLarge.tileH / 2
|
||||
|
||||
private var selection: Int
|
||||
get() = Terrarum.ingame!!.player.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.ui
|
||||
import net.torvald.terrarum.gameactors.sqr
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-03-14.
|
||||
* Created by minjaesong on 2017-03-14.
|
||||
*/
|
||||
object UIUtils {
|
||||
fun moveQuick(start: Double, end: Double, timer: Double, duration: Double) =
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-03-03.
|
||||
* Created by minjaesong on 2017-03-03.
|
||||
*/
|
||||
class UIVitalMetre(
|
||||
var player: ActorHumanoid,
|
||||
|
||||
Reference in New Issue
Block a user