add simple inventory display
parent
9128d8ca49
commit
0a1dc86a26
Binary file not shown.
After Width: | Height: | Size: 267 KiB |
@ -0,0 +1,165 @@
|
||||
<TextureAtlas imagePath="sprites.png">
|
||||
<SubTexture name="genericItem_color_001.png" x="0" y="322" width="162" height="94"/>
|
||||
<SubTexture name="genericItem_color_002.png" x="136" y="1231" width="120" height="110"/>
|
||||
<SubTexture name="genericItem_color_003.png" x="130" y="1791" width="89" height="45"/>
|
||||
<SubTexture name="genericItem_color_004.png" x="623" y="1826" width="70" height="88"/>
|
||||
<SubTexture name="genericItem_color_005.png" x="626" y="135" width="66" height="105"/>
|
||||
<SubTexture name="genericItem_color_006.png" x="366" y="1095" width="96" height="84"/>
|
||||
<SubTexture name="genericItem_color_007.png" x="628" y="0" width="60" height="95"/>
|
||||
<SubTexture name="genericItem_color_008.png" x="623" y="1914" width="68" height="102"/>
|
||||
<SubTexture name="genericItem_color_009.png" x="551" y="1305" width="76" height="104"/>
|
||||
<SubTexture name="genericItem_color_010.png" x="553" y="1826" width="70" height="104"/>
|
||||
<SubTexture name="genericItem_color_011.png" x="551" y="1495" width="75" height="113"/>
|
||||
<SubTexture name="genericItem_color_012.png" x="261" y="993" width="106" height="102"/>
|
||||
<SubTexture name="genericItem_color_013.png" x="556" y="174" width="70" height="119"/>
|
||||
<SubTexture name="genericItem_color_014.png" x="380" y="88" width="94" height="144"/>
|
||||
<SubTexture name="genericItem_color_015.png" x="552" y="366" width="74" height="131"/>
|
||||
<SubTexture name="genericItem_color_016.png" x="276" y="90" width="104" height="188"/>
|
||||
<SubTexture name="genericItem_color_017.png" x="365" y="1459" width="98" height="152"/>
|
||||
<SubTexture name="genericItem_color_018.png" x="691" y="1001" width="48" height="62"/>
|
||||
<SubTexture name="genericItem_color_019.png" x="688" y="393" width="52" height="68"/>
|
||||
<SubTexture name="genericItem_color_020.png" x="376" y="278" width="94" height="128"/>
|
||||
<SubTexture name="genericItem_color_021.png" x="134" y="1360" width="123" height="154"/>
|
||||
<SubTexture name="genericItem_color_022.png" x="464" y="534" width="87" height="162"/>
|
||||
<SubTexture name="genericItem_color_023.png" x="269" y="456" width="104" height="176"/>
|
||||
<SubTexture name="genericItem_color_024.png" x="693" y="461" width="42" height="74"/>
|
||||
<SubTexture name="genericItem_color_025.png" x="691" y="836" width="50" height="74"/>
|
||||
<SubTexture name="genericItem_color_026.png" x="692" y="135" width="42" height="74"/>
|
||||
<SubTexture name="genericItem_color_027.png" x="691" y="910" width="49" height="91"/>
|
||||
<SubTexture name="genericItem_color_028.png" x="690" y="1469" width="50" height="89"/>
|
||||
<SubTexture name="genericItem_color_029.png" x="632" y="812" width="59" height="130"/>
|
||||
<SubTexture name="genericItem_color_030.png" x="367" y="784" width="57" height="56"/>
|
||||
<SubTexture name="genericItem_color_031.png" x="146" y="776" width="116" height="96"/>
|
||||
<SubTexture name="genericItem_color_032.png" x="152" y="649" width="116" height="112"/>
|
||||
<SubTexture name="genericItem_color_033.png" x="0" y="1879" width="128" height="114"/>
|
||||
<SubTexture name="genericItem_color_034.png" x="461" y="1314" width="90" height="128"/>
|
||||
<SubTexture name="genericItem_color_035.png" x="256" y="1514" width="109" height="125"/>
|
||||
<SubTexture name="genericItem_color_036.png" x="373" y="436" width="94" height="98"/>
|
||||
<SubTexture name="genericItem_color_037.png" x="463" y="1442" width="88" height="124"/>
|
||||
<SubTexture name="genericItem_color_038.png" x="363" y="840" width="98" height="124"/>
|
||||
<SubTexture name="genericItem_color_039.png" x="382" y="0" width="90" height="78"/>
|
||||
<SubTexture name="genericItem_color_040.png" x="0" y="1993" width="111" height="47"/>
|
||||
<SubTexture name="genericItem_color_041.png" x="367" y="1738" width="72" height="65"/>
|
||||
<SubTexture name="genericItem_color_042.png" x="551" y="613" width="72" height="65"/>
|
||||
<SubTexture name="genericItem_color_043.png" x="256" y="1639" width="54" height="37"/>
|
||||
<SubTexture name="genericItem_color_044.png" x="462" y="1057" width="88" height="75"/>
|
||||
<SubTexture name="genericItem_color_045.png" x="365" y="1611" width="96" height="70"/>
|
||||
<SubTexture name="genericItem_color_046.png" x="0" y="532" width="152" height="88"/>
|
||||
<SubTexture name="genericItem_color_047.png" x="134" y="1514" width="112" height="80"/>
|
||||
<SubTexture name="genericItem_color_048.png" x="460" y="1738" width="93" height="117"/>
|
||||
<SubTexture name="genericItem_color_049.png" x="0" y="0" width="174" height="99"/>
|
||||
<SubTexture name="genericItem_color_050.png" x="0" y="1027" width="143" height="136"/>
|
||||
<SubTexture name="genericItem_color_051.png" x="0" y="1231" width="136" height="129"/>
|
||||
<SubTexture name="genericItem_color_052.png" x="162" y="322" width="114" height="134"/>
|
||||
<SubTexture name="genericItem_color_053.png" x="0" y="191" width="163" height="131"/>
|
||||
<SubTexture name="genericItem_color_054.png" x="363" y="1331" width="98" height="128"/>
|
||||
<SubTexture name="genericItem_color_055.png" x="364" y="1804" width="96" height="135"/>
|
||||
<SubTexture name="genericItem_color_056.png" x="0" y="1839" width="129" height="40"/>
|
||||
<SubTexture name="genericItem_color_057.png" x="0" y="736" width="152" height="40"/>
|
||||
<SubTexture name="genericItem_color_058.png" x="310" y="1639" width="46" height="38"/>
|
||||
<SubTexture name="genericItem_color_059.png" x="261" y="1186" width="51" height="38"/>
|
||||
<SubTexture name="genericItem_color_060.png" x="0" y="1163" width="141" height="68"/>
|
||||
<SubTexture name="genericItem_color_061.png" x="132" y="1686" width="52" height="13"/>
|
||||
<SubTexture name="genericItem_color_062.png" x="626" y="1501" width="64" height="88"/>
|
||||
<SubTexture name="genericItem_color_063.png" x="692" y="590" width="44" height="96"/>
|
||||
<SubTexture name="genericItem_color_064.png" x="688" y="1068" width="58" height="110"/>
|
||||
<SubTexture name="genericItem_color_065.png" x="688" y="240" width="58" height="88"/>
|
||||
<SubTexture name="genericItem_color_066.png" x="627" y="1075" width="60" height="94"/>
|
||||
<SubTexture name="genericItem_color_067.png" x="625" y="1740" width="66" height="82"/>
|
||||
<SubTexture name="genericItem_color_068.png" x="550" y="696" width="82" height="96"/>
|
||||
<SubTexture name="genericItem_color_069.png" x="474" y="0" width="84" height="98"/>
|
||||
<SubTexture name="genericItem_color_070.png" x="424" y="784" width="24" height="44"/>
|
||||
<SubTexture name="genericItem_color_071.png" x="626" y="358" width="62" height="89"/>
|
||||
<SubTexture name="genericItem_color_072.png" x="553" y="1930" width="70" height="92"/>
|
||||
<SubTexture name="genericItem_color_073.png" x="688" y="1178" width="58" height="79"/>
|
||||
<SubTexture name="genericItem_color_074.png" x="261" y="1095" width="105" height="91"/>
|
||||
<SubTexture name="genericItem_color_075.png" x="0" y="1360" width="134" height="122"/>
|
||||
<SubTexture name="genericItem_color_076.png" x="155" y="456" width="112" height="76"/>
|
||||
<SubTexture name="genericItem_color_077.png" x="132" y="1600" width="124" height="86"/>
|
||||
<SubTexture name="genericItem_color_078.png" x="0" y="99" width="163" height="92"/>
|
||||
<SubTexture name="genericItem_color_079.png" x="626" y="1409" width="64" height="92"/>
|
||||
<SubTexture name="genericItem_color_080.png" x="627" y="1279" width="62" height="99"/>
|
||||
<SubTexture name="genericItem_color_081.png" x="367" y="1681" width="94" height="57"/>
|
||||
<SubTexture name="genericItem_color_082.png" x="257" y="1449" width="98" height="63"/>
|
||||
<SubTexture name="genericItem_color_083.png" x="632" y="696" width="59" height="116"/>
|
||||
<SubTexture name="genericItem_color_084.png" x="257" y="1331" width="106" height="118"/>
|
||||
<SubTexture name="genericItem_color_085.png" x="550" y="874" width="82" height="82"/>
|
||||
<SubTexture name="genericItem_color_086.png" x="367" y="1037" width="38" height="41"/>
|
||||
<SubTexture name="genericItem_color_087.png" x="219" y="1791" width="31" height="41"/>
|
||||
<SubTexture name="genericItem_color_088.png" x="550" y="792" width="82" height="82"/>
|
||||
<SubTexture name="genericItem_color_089.png" x="312" y="1186" width="40" height="40"/>
|
||||
<SubTexture name="genericItem_color_090.png" x="628" y="95" width="40" height="40"/>
|
||||
<SubTexture name="genericItem_color_091.png" x="688" y="328" width="57" height="65"/>
|
||||
<SubTexture name="genericItem_color_092.png" x="688" y="84" width="51" height="51"/>
|
||||
<SubTexture name="genericItem_color_093.png" x="690" y="1365" width="50" height="104"/>
|
||||
<SubTexture name="genericItem_color_094.png" x="625" y="590" width="67" height="106"/>
|
||||
<SubTexture name="genericItem_color_095.png" x="551" y="506" width="74" height="107"/>
|
||||
<SubTexture name="genericItem_color_096.png" x="416" y="232" width="36" height="36"/>
|
||||
<SubTexture name="genericItem_color_097.png" x="626" y="461" width="38" height="36"/>
|
||||
<SubTexture name="genericItem_color_098.png" x="551" y="1409" width="75" height="86"/>
|
||||
<SubTexture name="genericItem_color_099.png" x="256" y="1226" width="108" height="105"/>
|
||||
<SubTexture name="genericItem_color_100.png" x="461" y="1611" width="91" height="93"/>
|
||||
<SubTexture name="genericItem_color_101.png" x="550" y="956" width="81" height="119"/>
|
||||
<SubTexture name="genericItem_color_102.png" x="152" y="532" width="117" height="117"/>
|
||||
<SubTexture name="genericItem_color_103.png" x="689" y="1257" width="53" height="108"/>
|
||||
<SubTexture name="genericItem_color_104.png" x="735" y="461" width="35" height="110"/>
|
||||
<SubTexture name="genericItem_color_105.png" x="625" y="497" width="68" height="93"/>
|
||||
<SubTexture name="genericItem_color_106.png" x="693" y="1805" width="33" height="90"/>
|
||||
<SubTexture name="genericItem_color_107.png" x="553" y="1740" width="72" height="86"/>
|
||||
<SubTexture name="genericItem_color_108.png" x="631" y="956" width="60" height="112"/>
|
||||
<SubTexture name="genericItem_color_109.png" x="143" y="1027" width="118" height="89"/>
|
||||
<SubTexture name="genericItem_color_110.png" x="364" y="1186" width="98" height="128"/>
|
||||
<SubTexture name="genericItem_color_111.png" x="254" y="1804" width="110" height="138"/>
|
||||
<SubTexture name="genericItem_color_112.png" x="464" y="696" width="86" height="86"/>
|
||||
<SubTexture name="genericItem_color_113.png" x="129" y="1839" width="125" height="194"/>
|
||||
<SubTexture name="genericItem_color_114.png" x="0" y="776" width="146" height="104"/>
|
||||
<SubTexture name="genericItem_color_115.png" x="470" y="232" width="86" height="134"/>
|
||||
<SubTexture name="genericItem_color_116.png" x="369" y="632" width="95" height="152"/>
|
||||
<SubTexture name="genericItem_color_117.png" x="111" y="2033" width="90" height="14"/>
|
||||
<SubTexture name="genericItem_color_118.png" x="688" y="0" width="55" height="84"/>
|
||||
<SubTexture name="genericItem_color_119.png" x="626" y="1175" width="62" height="104"/>
|
||||
<SubTexture name="genericItem_color_120.png" x="688" y="1589" width="56" height="121"/>
|
||||
<SubTexture name="genericItem_color_121.png" x="556" y="293" width="69" height="72"/>
|
||||
<SubTexture name="genericItem_color_122.png" x="691" y="1914" width="46" height="95"/>
|
||||
<SubTexture name="genericItem_color_123.png" x="691" y="1710" width="47" height="95"/>
|
||||
<SubTexture name="genericItem_color_124.png" x="145" y="880" width="117" height="113"/>
|
||||
<SubTexture name="genericItem_color_125.png" x="0" y="620" width="152" height="116"/>
|
||||
<SubTexture name="genericItem_color_126.png" x="558" y="0" width="70" height="135"/>
|
||||
<SubTexture name="genericItem_color_127.png" x="691" y="696" width="50" height="140"/>
|
||||
<SubTexture name="genericItem_color_128.png" x="130" y="1709" width="124" height="82"/>
|
||||
<SubTexture name="genericItem_color_129.png" x="734" y="135" width="28" height="105"/>
|
||||
<SubTexture name="genericItem_color_130.png" x="726" y="1805" width="27" height="97"/>
|
||||
<SubTexture name="genericItem_color_131.png" x="736" y="571" width="20" height="106"/>
|
||||
<SubTexture name="genericItem_color_132.png" x="254" y="1686" width="113" height="118"/>
|
||||
<SubTexture name="genericItem_color_133.png" x="0" y="880" width="145" height="147"/>
|
||||
<SubTexture name="genericItem_color_134.png" x="461" y="1855" width="92" height="132"/>
|
||||
<SubTexture name="genericItem_color_135.png" x="462" y="1132" width="88" height="140"/>
|
||||
<SubTexture name="genericItem_color_136.png" x="626" y="1589" width="62" height="146"/>
|
||||
<SubTexture name="genericItem_color_137.png" x="461" y="921" width="89" height="136"/>
|
||||
<SubTexture name="genericItem_color_138.png" x="174" y="0" width="109" height="90"/>
|
||||
<SubTexture name="genericItem_color_139.png" x="0" y="1600" width="132" height="109"/>
|
||||
<SubTexture name="genericItem_color_140.png" x="276" y="278" width="100" height="158"/>
|
||||
<SubTexture name="genericItem_color_141.png" x="143" y="1116" width="118" height="110"/>
|
||||
<SubTexture name="genericItem_color_142.png" x="163" y="99" width="113" height="202"/>
|
||||
<SubTexture name="genericItem_color_143.png" x="254" y="1942" width="109" height="98"/>
|
||||
<SubTexture name="genericItem_color_144.png" x="461" y="784" width="89" height="137"/>
|
||||
<SubTexture name="genericItem_color_145.png" x="0" y="416" width="155" height="116"/>
|
||||
<SubTexture name="genericItem_color_146.png" x="0" y="1482" width="134" height="118"/>
|
||||
<SubTexture name="genericItem_color_147.png" x="0" y="1709" width="130" height="130"/>
|
||||
<SubTexture name="genericItem_color_148.png" x="262" y="840" width="101" height="135"/>
|
||||
<SubTexture name="genericItem_color_149.png" x="373" y="534" width="91" height="89"/>
|
||||
<SubTexture name="genericItem_color_150.png" x="283" y="0" width="99" height="88"/>
|
||||
<SubTexture name="genericItem_color_151.png" x="550" y="1175" width="76" height="130"/>
|
||||
<SubTexture name="genericItem_color_152.png" x="467" y="406" width="85" height="100"/>
|
||||
<SubTexture name="genericItem_color_153.png" x="553" y="1608" width="73" height="132"/>
|
||||
<SubTexture name="genericItem_color_154.png" x="367" y="964" width="94" height="73"/>
|
||||
<SubTexture name="genericItem_color_155.png" x="625" y="293" width="63" height="65"/>
|
||||
<SubTexture name="genericItem_color_156.png" x="550" y="1075" width="77" height="100"/>
|
||||
<SubTexture name="genericItem_color_157.png" x="363" y="1942" width="98" height="102"/>
|
||||
<SubTexture name="genericItem_color_158.png" x="268" y="649" width="101" height="106"/>
|
||||
<SubTexture name="genericItem_color_159.png" x="405" y="1057" width="36" height="36"/>
|
||||
<SubTexture name="genericItem_color_160.png" x="380" y="232" width="36" height="36"/>
|
||||
<SubTexture name="genericItem_color_161.png" x="145" y="993" width="24" height="24"/>
|
||||
<SubTexture name="genericItem_color_162.png" x="262" y="761" width="105" height="79"/>
|
||||
<SubTexture name="genericItem_color_163.png" x="474" y="98" width="83" height="76"/>
|
||||
</TextureAtlas>
|
@ -0,0 +1,15 @@
|
||||
package com.last.commit.inventory
|
||||
|
||||
class Inventory {
|
||||
|
||||
val items: MutableList<InventoryItem> = ArrayList()
|
||||
val textureLoader = InventoryItemTextureLoader()
|
||||
|
||||
init {
|
||||
textureLoader.parse()
|
||||
}
|
||||
|
||||
fun add(name: String) {
|
||||
items.add(InventoryItem(name, textureLoader.loadTexture(name)))
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.last.commit.inventory
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
|
||||
class InventoryItem(name: String, texture: TextureRegion) {
|
||||
val texture: TextureRegion
|
||||
val name: String
|
||||
|
||||
init {
|
||||
this.name = name
|
||||
this.texture = texture
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.last.commit.inventory
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.utils.Array
|
||||
import com.badlogic.gdx.utils.XmlReader
|
||||
|
||||
class InventoryItemTextureLoader {
|
||||
|
||||
private val itemsSpriteSheet = Texture("sprites/genericItems_spritesheet_colored.png")
|
||||
private lateinit var subTextures: Array<XmlReader.Element>
|
||||
|
||||
fun loadTexture(itemName: String): TextureRegion {
|
||||
var subtexture = subTextures.first { it.getAttribute("name") == itemName }
|
||||
val x = subtexture.getIntAttribute("x")
|
||||
val y = subtexture.getIntAttribute("y")
|
||||
val width = subtexture.getIntAttribute("width")
|
||||
val height = subtexture.getIntAttribute("height")
|
||||
return TextureRegion(itemsSpriteSheet, x, y, width, height)
|
||||
}
|
||||
|
||||
fun parse() {
|
||||
val xml = XmlReader()
|
||||
val textureAtlasElement = xml.parse(Gdx.files.local("sprites/genericItems_spritesheet_colored.xml"))
|
||||
this.subTextures = textureAtlasElement.getChildrenByName("SubTexture")
|
||||
println("Found ${subTextures.size} textures")
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.last.commit.stages
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
import com.last.commit.inventory.Inventory
|
||||
|
||||
class InventoryStage(inventory: Inventory) : Stage() {
|
||||
|
||||
var visible = false
|
||||
|
||||
init {
|
||||
for (item in inventory.items) {
|
||||
|
||||
val image = Image(item.texture)
|
||||
image.width = 32f
|
||||
image.height = 32f
|
||||
|
||||
addActor(image)
|
||||
}
|
||||
}
|
||||
|
||||
fun resize(width: Int, height: Int) {
|
||||
viewport.update(width, height, true)
|
||||
}
|
||||
|
||||
override fun draw() {
|
||||
if (visible) {
|
||||
super.draw()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue