mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
smelter ui wip
This commit is contained in:
@@ -1,82 +1,82 @@
|
||||
id;classname
|
||||
1;net.torvald.terrarum.modulebasegame.gameitems.PickaxeCopper
|
||||
2;net.torvald.terrarum.modulebasegame.gameitems.PickaxeIron
|
||||
3;net.torvald.terrarum.modulebasegame.gameitems.PickaxeSteel
|
||||
4;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerIron
|
||||
5;net.torvald.terrarum.modulebasegame.gameitems.ItemTikiTorch
|
||||
6;net.torvald.terrarum.modulebasegame.gameitems.ItemStorageChest
|
||||
7;net.torvald.terrarum.modulebasegame.gameitems.WireGraphDebugger
|
||||
8;net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalEmitter
|
||||
9;net.torvald.terrarum.modulebasegame.gameitems.WireCutterAll
|
||||
10;net.torvald.terrarum.modulebasegame.gameitems.ItemTypewriter
|
||||
11;net.torvald.terrarum.modulebasegame.gameitems.ItemWallCalendar
|
||||
12;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerCopper
|
||||
13;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerSteel
|
||||
14;net.torvald.terrarum.modulebasegame.gameitems.PickaxeWood
|
||||
15;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerWood
|
||||
16;net.torvald.terrarum.modulebasegame.gameitems.ItemWorkbench
|
||||
17;net.torvald.terrarum.modulebasegame.gameitems.ItemSmelterBasic
|
||||
18;net.torvald.terrarum.modulebasegame.gameitems.OreStick
|
||||
19;net.torvald.terrarum.modulebasegame.gameitems.AxeCopper
|
||||
20;net.torvald.terrarum.modulebasegame.gameitems.AxeIron
|
||||
21;net.torvald.terrarum.modulebasegame.gameitems.AxeSteel
|
||||
#22;net.torvald.terrarum.modulebasegame.gameitems.AxeWood
|
||||
23;net.torvald.terrarum.modulebasegame.gameitems.PickaxeStone
|
||||
24;net.torvald.terrarum.modulebasegame.gameitems.AxeStone
|
||||
25;net.torvald.terrarum.modulebasegame.gameitems.ItemClayBall
|
||||
26;net.torvald.terrarum.modulebasegame.gameitems.IngotSteel
|
||||
27;net.torvald.terrarum.modulebasegame.gameitems.ItemFurnaceAndAnvil
|
||||
28;net.torvald.terrarum.modulebasegame.gameitems.ItemJukebox
|
||||
id;classname;tags
|
||||
1;net.torvald.terrarum.modulebasegame.gameitems.PickaxeCopper;TOOL,PICK
|
||||
2;net.torvald.terrarum.modulebasegame.gameitems.PickaxeIron;TOOL,PICK
|
||||
3;net.torvald.terrarum.modulebasegame.gameitems.PickaxeSteel;TOOL,PICK
|
||||
4;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerIron;TOOL,HAMMER
|
||||
5;net.torvald.terrarum.modulebasegame.gameitems.ItemTikiTorch;FIXTURE,LIGHT
|
||||
6;net.torvald.terrarum.modulebasegame.gameitems.ItemStorageChest;FIXTURE,STORAGE
|
||||
7;net.torvald.terrarum.modulebasegame.gameitems.WireGraphDebugger;TOOL,WIRE
|
||||
8;net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalEmitter;FIXTURE
|
||||
9;net.torvald.terrarum.modulebasegame.gameitems.WireCutterAll;TOOL,WIRE
|
||||
10;net.torvald.terrarum.modulebasegame.gameitems.ItemTypewriter;FIXTURE,PRINTING
|
||||
11;net.torvald.terrarum.modulebasegame.gameitems.ItemWallCalendar;FIXTURE
|
||||
12;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerCopper;TOOL,HAMMER
|
||||
13;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerSteel;TOOL,HAMMER
|
||||
14;net.torvald.terrarum.modulebasegame.gameitems.PickaxeWood;TOOL,PICK
|
||||
15;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerWood;TOOL,HAMMER
|
||||
16;net.torvald.terrarum.modulebasegame.gameitems.ItemWorkbench;FIXTURE,CRAFTING
|
||||
17;net.torvald.terrarum.modulebasegame.gameitems.ItemSmelterBasic;FIXTURE,STATION
|
||||
18;net.torvald.terrarum.modulebasegame.gameitems.OreStick;BURNABLE
|
||||
19;net.torvald.terrarum.modulebasegame.gameitems.AxeCopper;TOOL,AXE
|
||||
20;net.torvald.terrarum.modulebasegame.gameitems.AxeIron;TOOL,AXE
|
||||
21;net.torvald.terrarum.modulebasegame.gameitems.AxeSteel;TOOL,AXE
|
||||
#22;net.torvald.terrarum.modulebasegame.gameitems.AxeWood;TOOL,AXE
|
||||
23;net.torvald.terrarum.modulebasegame.gameitems.PickaxeStone;TOOL,PICK
|
||||
24;net.torvald.terrarum.modulebasegame.gameitems.AxeStone;TOOL,AXE
|
||||
25;net.torvald.terrarum.modulebasegame.gameitems.ItemClayBall;
|
||||
27;net.torvald.terrarum.modulebasegame.gameitems.ItemFurnaceAndAnvil;FIXTURE,CRAFTING
|
||||
28;net.torvald.terrarum.modulebasegame.gameitems.ItemJukebox;FIXTURE,MUSIC
|
||||
|
||||
# ingots
|
||||
112;net.torvald.terrarum.modulebasegame.gameitems.IngotCopper
|
||||
113;net.torvald.terrarum.modulebasegame.gameitems.IngotIron
|
||||
114;net.torvald.terrarum.modulebasegame.gameitems.ItemCoalCoke
|
||||
115;net.torvald.terrarum.modulebasegame.gameitems.IngotZinc
|
||||
116;net.torvald.terrarum.modulebasegame.gameitems.IngotTin
|
||||
117;net.torvald.terrarum.modulebasegame.gameitems.IngotGold
|
||||
118;net.torvald.terrarum.modulebasegame.gameitems.IngotSilver
|
||||
119;net.torvald.terrarum.modulebasegame.gameitems.IngotLead
|
||||
26;net.torvald.terrarum.modulebasegame.gameitems.IngotSteel;INGOT
|
||||
112;net.torvald.terrarum.modulebasegame.gameitems.IngotCopper;INGOT
|
||||
113;net.torvald.terrarum.modulebasegame.gameitems.IngotIron;INGOT
|
||||
114;net.torvald.terrarum.modulebasegame.gameitems.ItemCoalCoke;INGOT,BURNABLE
|
||||
115;net.torvald.terrarum.modulebasegame.gameitems.IngotZinc;INGOT
|
||||
116;net.torvald.terrarum.modulebasegame.gameitems.IngotTin;INGOT
|
||||
117;net.torvald.terrarum.modulebasegame.gameitems.IngotGold;INGOT
|
||||
118;net.torvald.terrarum.modulebasegame.gameitems.IngotSilver;INGOT
|
||||
119;net.torvald.terrarum.modulebasegame.gameitems.IngotLead;INGOT
|
||||
|
||||
# ores
|
||||
128;net.torvald.terrarum.modulebasegame.gameitems.OreCopper
|
||||
129;net.torvald.terrarum.modulebasegame.gameitems.OreIron
|
||||
130;net.torvald.terrarum.modulebasegame.gameitems.OreCoal
|
||||
131;net.torvald.terrarum.modulebasegame.gameitems.OreZinc
|
||||
132;net.torvald.terrarum.modulebasegame.gameitems.OreTin
|
||||
133;net.torvald.terrarum.modulebasegame.gameitems.OreGold
|
||||
134;net.torvald.terrarum.modulebasegame.gameitems.OreSilver
|
||||
135;net.torvald.terrarum.modulebasegame.gameitems.OreLead
|
||||
128;net.torvald.terrarum.modulebasegame.gameitems.OreCopper;SMELTABLE
|
||||
129;net.torvald.terrarum.modulebasegame.gameitems.OreIron;SMELTABLE
|
||||
130;net.torvald.terrarum.modulebasegame.gameitems.OreCoal;SMELTABLE,BURNABLE
|
||||
131;net.torvald.terrarum.modulebasegame.gameitems.OreZinc;SMELTABLE
|
||||
132;net.torvald.terrarum.modulebasegame.gameitems.OreTin;SMELTABLE
|
||||
133;net.torvald.terrarum.modulebasegame.gameitems.OreGold;SMELTABLE
|
||||
134;net.torvald.terrarum.modulebasegame.gameitems.OreSilver;SMELTABLE
|
||||
135;net.torvald.terrarum.modulebasegame.gameitems.OreLead;SMELTABLE
|
||||
|
||||
|
||||
# gemstones
|
||||
#144; gems
|
||||
|
||||
# tree seeds by tree species
|
||||
160;net.torvald.terrarum.modulebasegame.gameitems.ItemSeedOak
|
||||
161;net.torvald.terrarum.modulebasegame.gameitems.ItemSeedEbony
|
||||
162;net.torvald.terrarum.modulebasegame.gameitems.ItemSeedBirch
|
||||
163;net.torvald.terrarum.modulebasegame.gameitems.ItemSeedRosewood
|
||||
160;net.torvald.terrarum.modulebasegame.gameitems.ItemSeedOak;SEEDLING
|
||||
161;net.torvald.terrarum.modulebasegame.gameitems.ItemSeedEbony;SEEDLING
|
||||
162;net.torvald.terrarum.modulebasegame.gameitems.ItemSeedBirch;SEEDLING
|
||||
163;net.torvald.terrarum.modulebasegame.gameitems.ItemSeedRosewood;SEEDLING
|
||||
|
||||
# tree logs
|
||||
168;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsOak
|
||||
169;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsEbony
|
||||
170;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsBirch
|
||||
171;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsRosewood
|
||||
168;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsOak;
|
||||
169;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsEbony;
|
||||
170;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsBirch;
|
||||
171;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsRosewood;
|
||||
|
||||
|
||||
256;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorOak
|
||||
257;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorEbony
|
||||
258;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorBirch
|
||||
259;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorRosewood
|
||||
256;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorOak;FIXTURE
|
||||
257;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorEbony;FIXTURE
|
||||
258;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorBirch;FIXTURE
|
||||
259;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorRosewood;FIXTURE
|
||||
|
||||
320;net.torvald.terrarum.modulebasegame.gameitems.ItemWorldPortal
|
||||
320;net.torvald.terrarum.modulebasegame.gameitems.ItemWorldPortal;FIXTURE,STATION
|
||||
|
||||
65536;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc01
|
||||
65537;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc02
|
||||
65538;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc03
|
||||
65539;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc04
|
||||
65540;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc05
|
||||
65541;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc06
|
||||
65536;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc01;MUSIC
|
||||
65537;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc02;MUSIC
|
||||
65538;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc03;MUSIC
|
||||
65539;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc04;MUSIC
|
||||
65540;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc05;MUSIC
|
||||
65541;net.torvald.terrarum.modulebasegame.gameitems.MusicDisc06;MUSIC
|
||||
|
||||
999999;net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry
|
||||
999999;net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry;FIXTURE
|
||||
|
||||
|
46
assets/mods/basegame/sprites/test_sprite_emsv.properties
Normal file
46
assets/mods/basegame/sprites/test_sprite_emsv.properties
Normal file
@@ -0,0 +1,46 @@
|
||||
# complete file name is: SPRITESHEET + bodypart name + EXTENSION
|
||||
SPRITESHEET=mods/basegame/sprites/sprite_assembler_test_assets/testemsv_
|
||||
EXTENSION=.tga
|
||||
# defines frame size and origin point. Origin point is given as: (originx, 0)
|
||||
CONFIG=SIZE 48,56;ORIGINX 28
|
||||
|
||||
! A skeleton also defines what body parts (images) be used.
|
||||
! You can also write multiline text using reverse solidus; this is a feature of .properties
|
||||
! skeleton joints are ordered: foremost-drawn object comes first, which means lowermost object IN THIS LIST
|
||||
! are painted first, and any object that comes before it will paint over it. In other words, this list is
|
||||
! first reversed then being iterated.
|
||||
! Some keywords are considered special within the game, they are:
|
||||
! HEADGEAR, HELD_ITEM, BOOT_L, BOOT_R, GAUNTLET_L, GAUNTLET_R and ARMOUR_* (star means any number starting from zero)
|
||||
BODYPARTS=ARM_REST_RIGHT 3,8;\
|
||||
ARM_REST_LEFT 3,8;\
|
||||
FOOT_LEFT 4,2;\
|
||||
FOOT_RIGHT 4,2;\
|
||||
UPPER_TORSO 9,4;\
|
||||
LOWER_TORSO 7,4;\
|
||||
LEG_REST_RIGHT 3,7;\
|
||||
LEG_REST_LEFT 3,7;\
|
||||
HEAD 8,7;\
|
||||
HAND_REST_RIGHT 3,3;\
|
||||
HAND_REST_LEFT 3,3;\
|
||||
HAIR 20,12;\
|
||||
HAIR_FORE 20,12
|
||||
SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\
|
||||
ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\
|
||||
HAIR 0,32;HEAD 0,32;\
|
||||
UPPER_TORSO 0,23;LOWER_TORSO 0,15;\
|
||||
FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\
|
||||
FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\
|
||||
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\
|
||||
TAIL0 0,13
|
||||
|
||||
# skeleton_stand is used for testing purpose
|
||||
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND
|
||||
ANIM_RUN_1=LEG_REST_RIGHT 1,1;FOOT_RIGHT 1,1;LEG_REST_LEFT -1,0;FOOT_LEFT -1,0
|
||||
ANIM_RUN_2=ALL 0,1;LEG_REST_RIGHT 0,-1;FOOT_RIGHT 0,-1;LEG_REST_LEFT 0,1;FOOT_LEFT 0,1
|
||||
ANIM_RUN_3=LEG_REST_RIGHT -1,0;FOOT_RIGHT -1,0;LEG_REST_LEFT 1,1;FOOT_LEFT 1,1
|
||||
ANIM_RUN_4=ALL 0,1;LEG_REST_RIGHT 0,1;FOOT_RIGHT 0,1;LEG_REST_LEFT 0,-1;FOOT_LEFT 0,-1
|
||||
|
||||
ANIM_IDLE=DELAY 2;ROW 1;SKELETON SKELETON_STAND
|
||||
ANIM_IDLE_1=
|
||||
! ANIM_IDLE_1 will not make any transformation
|
||||
ANIM_IDLE_2=UPPER_TORSO 0,-1;HEAD 0,-1;HAIR 0,-1;HELD_ITEM 0,-1;ARM_REST_LEFT 0,-1;ARM_REST_RIGHT 0,-1;HAND_REST_LEFT 0,-1;HAND_REST_RIGHT 0,-1;HAIR_FORE 0,-1;HEADGEAR 0,-1
|
||||
@@ -659,6 +659,7 @@ object ModMgr {
|
||||
val className: String = it["classname"].toString()
|
||||
val internalID: Int = it["id"].toInt()
|
||||
val itemName: String = "item@$module:$internalID"
|
||||
val tags = it["tags"].split(',').map { it.trim().toUpperCase() }.toHashSet()
|
||||
|
||||
printdbg(this, "Reading item ${itemName} <<- internal #$internalID with className $className")
|
||||
|
||||
@@ -668,12 +669,14 @@ object ModMgr {
|
||||
val loadedClassConstructor = loadedClass.getConstructor(ItemID::class.java)
|
||||
val loadedClassInstance = loadedClassConstructor.newInstance(itemName)
|
||||
ItemCodex[itemName] = loadedClassInstance as GameItem
|
||||
ItemCodex.tags[itemName] = tags
|
||||
}
|
||||
else {
|
||||
val loadedClass = it.loadClass(className)
|
||||
val loadedClassConstructor = loadedClass.getConstructor(ItemID::class.java)
|
||||
val loadedClassInstance = loadedClassConstructor.newInstance(itemName)
|
||||
ItemCodex[itemName] = loadedClassInstance as GameItem
|
||||
ItemCodex.tags[itemName] = tags
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ fun main() {
|
||||
"Lkotlin/ranges/IntRange",
|
||||
"Lorg/dyn4j/geometry/Vector2",
|
||||
"Lcom/badlogic/gdx/graphics/Color",
|
||||
"Lnet/torvald/terrarum/modulebasegame/gameactors/InventoryPair",
|
||||
// subclasses
|
||||
"Lnet/torvald/terrarum/gameactors/BlockMarkerActor",
|
||||
"Lnet/torvald/terrarum/gameactors/Actor",
|
||||
|
||||
@@ -180,7 +180,7 @@ class BlockCodex {
|
||||
private fun setProp(modname: String, key: Int, record: CSVRecord) {
|
||||
val prop = BlockProp()
|
||||
prop.nameKey = record.get("name")
|
||||
prop.tags = record.get("tags").split(',').map { it.trim() }.toHashSet()
|
||||
prop.tags = record.get("tags").split(',').map { it.trim().toUpperCase() }.toHashSet()
|
||||
|
||||
prop.id = "$modname:$key"
|
||||
prop.numericID = key
|
||||
|
||||
@@ -111,7 +111,7 @@ class BlockProp {
|
||||
@Transient var rngBase1 = Math.random().toFloat() // flicker P0, etc
|
||||
@Transient var rngBase2 = Math.random().toFloat() // flicker P1, etc
|
||||
|
||||
var tags = HashSet<String>()
|
||||
@Transient var tags = HashSet<String>()
|
||||
|
||||
/**
|
||||
* Mainly intended to be used by third-party modules
|
||||
|
||||
@@ -32,6 +32,7 @@ class ItemCodex {
|
||||
* Will return corresponding Actor if ID >= ACTORID_MIN
|
||||
*/
|
||||
@Transient val itemCodex = ItemTable()
|
||||
@Transient var tags = HashMap<String, HashSet<String>>()
|
||||
val dynamicItemInventory = ItemTable()
|
||||
val dynamicToStaticTable = ItemRemapTable()
|
||||
|
||||
@@ -229,4 +230,15 @@ class ItemCodex {
|
||||
|
||||
fun hasItem(itemID: ItemID): Boolean = dynamicItemInventory.containsKey(itemID)
|
||||
fun isEmpty(): Boolean = itemCodex.isEmpty()
|
||||
|
||||
fun hasTag(itemID: ItemID, s: String) = tags[itemID]?.contains(s) == true
|
||||
fun hasAnyTagOf(itemID: ItemID, vararg s: String) = s.any { hasTag(itemID, it) }
|
||||
fun hasAnyTag(itemID: ItemID, s: Collection<String>) = s.any { hasTag(itemID, it) }
|
||||
fun hasAnyTag(itemID: ItemID, s: Array<String>) = s.any { hasTag(itemID, it) }
|
||||
fun hasAllTagOf(itemID: ItemID, vararg s: String) = s.all { hasTag(itemID, it) }
|
||||
fun hasAllTag(itemID: ItemID, s: Collection<String>) = s.all { hasTag(itemID, it) }
|
||||
fun hasAllTag(itemID: ItemID, s: Array<String>) = s.all { hasTag(itemID, it) }
|
||||
fun hasNoTagOf(itemID: ItemID, vararg s: String) = s.none { hasTag(itemID, it) }
|
||||
fun hasNoTag(itemID: ItemID, s: Collection<String>) = s.none { hasTag(itemID, it) }
|
||||
fun hasNoTag(itemID: ItemID, s: Array<String>) = s.none { hasTag(itemID, it) }
|
||||
}
|
||||
@@ -24,12 +24,23 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
|
||||
var fuelCaloriesNow = 0f
|
||||
var fuelCaloriesMax: Float? = null
|
||||
var temperature = 0f // 0f..1f
|
||||
var progress = 0f
|
||||
|
||||
var oreItem: InventoryPair? = null
|
||||
var fireboxItem: InventoryPair? = null
|
||||
var productItem: InventoryPair? = null
|
||||
|
||||
override val canBeDespawned: Boolean
|
||||
get() = oreItem == null && fireboxItem == null && productItem == null
|
||||
|
||||
@Transient override val tags = listOf("basicsmelter")
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.NO_COLLISION, 3, 4), // temporary value, will be overwritten by spawn()
|
||||
nameFun = { Lang["ITEM_SMELTER_SMALL"] },
|
||||
mainUI = UISmelterBasic()
|
||||
) {
|
||||
CommonResourcePool.addToLoadingList("particles-tiki_smoke.tga") {
|
||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "particles/bigger_smoke.tga"), 16, 16)
|
||||
@@ -51,6 +62,8 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
}
|
||||
|
||||
actorValue[AVKey.BASEMASS] = 100.0
|
||||
|
||||
this.mainUI = UISmelterBasic(this)
|
||||
}
|
||||
|
||||
@Transient override var lightBoxList = arrayListOf(Lightbox(Hitbox(0.0, 2*TILE_SIZED, TILE_SIZED * 2, TILE_SIZED * 2), Cvec(0.5f, 0.18f, 0f, 0f)))
|
||||
|
||||
@@ -7,42 +7,63 @@ import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureSmelterBasic
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||
import net.torvald.terrarum.ui.*
|
||||
import net.torvald.terrarum.ui.UIItemCatBar.Companion.FILTER_CAT_ALL
|
||||
import net.torvald.terrarum.ui.UIItemInventoryElemWide.Companion.UNIQUE_ITEM_HAS_NO_AMOUNT
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import net.torvald.unicode.getKeycapPC
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.math.roundToLong
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-01-29.
|
||||
*/
|
||||
class UISmelterBasic() : UICanvas(
|
||||
class UISmelterBasic(val smelter: FixtureSmelterBasic) : UICanvas(
|
||||
toggleKeyLiteral = "control_key_inventory",
|
||||
toggleButtonLiteral = "control_gamepad_start"
|
||||
), HasInventory {
|
||||
) {
|
||||
|
||||
override var width = Toolkit.drawWidth
|
||||
override var height = App.scr.height
|
||||
|
||||
private val playerThings = UITemplateHalfInventory(this, false).also {
|
||||
it.itemListTouchDownFun = { gameItem, _, _, _, _ ->
|
||||
it.itemListTouchDownFun = { gameItem, amount, button, _, _ ->
|
||||
val amount = if (button == App.getConfigInt("config_mouseprimary"))
|
||||
amount
|
||||
else if (button == App.getConfigInt("config_mousesecondary"))
|
||||
1
|
||||
else
|
||||
null
|
||||
|
||||
// oreslot
|
||||
if (amount != null && gameItem != null) {
|
||||
if (clickedOn == 1) {
|
||||
getPlayerInventory().remove(gameItem.dynamicID, amount)
|
||||
|
||||
if (smelter.oreItem == null)
|
||||
smelter.oreItem = InventoryPair(gameItem.dynamicID, amount)
|
||||
else
|
||||
smelter.oreItem!!.qty += amount
|
||||
}
|
||||
// firebox
|
||||
else if (clickedOn == 2) {
|
||||
getPlayerInventory().remove(gameItem.dynamicID, amount)
|
||||
|
||||
if (smelter.fireboxItem == null)
|
||||
smelter.fireboxItem = InventoryPair(gameItem.dynamicID, amount)
|
||||
else
|
||||
smelter.fireboxItem!!.qty += amount
|
||||
}
|
||||
}
|
||||
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
}
|
||||
}
|
||||
|
||||
private val negotiator = object : InventoryTransactionNegotiator() {
|
||||
override fun accept(player: FixtureInventory, fixture: FixtureInventory, item: GameItem, amount: Long) {
|
||||
// TODO()
|
||||
}
|
||||
|
||||
override fun refund(fixture: FixtureInventory, player: FixtureInventory, item: GameItem, amount: Long) {
|
||||
// TODO()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getNegotiator() = negotiator
|
||||
override fun getFixtureInventory(): FixtureInventory = TODO()
|
||||
override fun getPlayerInventory(): FixtureInventory = INGAME.actorNowPlaying!!.inventory
|
||||
fun getPlayerInventory(): FixtureInventory = INGAME.actorNowPlaying!!.inventory
|
||||
|
||||
init {
|
||||
CommonResourcePool.addToLoadingList("basegame_gui_smelter_icons") {
|
||||
@@ -56,19 +77,13 @@ class UISmelterBasic() : UICanvas(
|
||||
private var smelterBackdrop =
|
||||
FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/smelter_tall.tga")
|
||||
|
||||
private var fuelCaloriesNow = 0f
|
||||
private var fuelCaloriesMax: Float? = null
|
||||
|
||||
private var temperature = 0f // 0f..1f
|
||||
private var progress = 0f
|
||||
|
||||
|
||||
private val leftPanelWidth = playerThings.width
|
||||
private val leftPanelHeight = playerThings.height
|
||||
private val leftPanelX = playerThings.posX - leftPanelWidth - UIItemInventoryItemGrid.listGap - UIItemInventoryElemWide.height
|
||||
private val leftPanelY = playerThings.posY
|
||||
|
||||
private val backdropColour = Color(0x7f7f7fff)
|
||||
private val backdropColour = Color(0x999999_c8.toInt())
|
||||
private val backdropZoom = 6
|
||||
private val backdropX = (leftPanelX + (leftPanelWidth - smelterBackdrop.regionWidth * backdropZoom) / 2).toFloat()
|
||||
private val backdropY = (leftPanelY + (leftPanelHeight - smelterBackdrop.regionHeight * backdropZoom) / 2).toFloat()
|
||||
@@ -82,31 +97,137 @@ class UISmelterBasic() : UICanvas(
|
||||
private val productX = backdropX + 37 * backdropZoom + 3
|
||||
private val productY = backdropY + 39 * backdropZoom + 3
|
||||
|
||||
private val oreItemSlot = UIItemInventoryElemSimple(
|
||||
/*
|
||||
Click on the button when item is there:
|
||||
ButtonPrimary: take all the item
|
||||
ButtonSecondary: take only one item (or show radial menu?)
|
||||
|
||||
Click on the button when item is not there:
|
||||
ButtonPrimary: apply filter to the inventory
|
||||
|
||||
Click on the area that has no UIitem:
|
||||
ButtonPrimary: reset the inventory filter
|
||||
|
||||
Click on the inventory list:
|
||||
ButtonPrimary: use all the item
|
||||
ButtonSecondary: use only one item
|
||||
*/
|
||||
|
||||
private var clickedOn = 0 // Used to set inventory filter and its behaviour. 0: default, 1: oreslot, 2: firebox
|
||||
|
||||
private val oreItemSlot: UIItemInventoryElemSimple = UIItemInventoryElemSimple(
|
||||
this, oreX.toInt(), oreY.toInt(),
|
||||
updateOnNull = true,
|
||||
emptyCellIcon = smelterCellIcons.get(1, 1),
|
||||
keyDownFun = { _, _, _, _, _ -> },
|
||||
touchDownFun = { item, amount, _, _, _ -> }
|
||||
touchDownFun = { _, _, button, _, self ->
|
||||
if (clickedOn != 1) {
|
||||
clickedOn = 1
|
||||
self.forceHighlighted = true
|
||||
fireboxItemSlot.forceHighlighted = false
|
||||
itemListUpdate { ItemCodex.hasTag(it.itm, "SMELTABLE") }
|
||||
}
|
||||
else if (smelter.oreItem != null) {
|
||||
val removeCount = if (button == App.getConfigInt("config_mouseprimary"))
|
||||
smelter.oreItem!!.qty
|
||||
else if (button == App.getConfigInt("config_mousesecondary"))
|
||||
1L
|
||||
else
|
||||
null
|
||||
|
||||
if (removeCount != null) {
|
||||
getPlayerInventory().add(smelter.oreItem!!.itm, removeCount)
|
||||
smelter.oreItem!!.qty -= removeCount
|
||||
if (smelter.oreItem!!.qty == 0L) smelter.oreItem = null
|
||||
}
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
}
|
||||
else {
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
}
|
||||
}
|
||||
)
|
||||
private val fireboxItemSlot = UIItemInventoryElemSimple(
|
||||
private val fireboxItemSlot: UIItemInventoryElemSimple = UIItemInventoryElemSimple(
|
||||
this, fireboxX.toInt(), fireboxY.toInt(),
|
||||
emptyCellIcon = smelterCellIcons.get(0, 0),
|
||||
updateOnNull = true,
|
||||
keyDownFun = { _, _, _, _, _ -> },
|
||||
touchDownFun = { item, amount, _, _, _ -> }
|
||||
touchDownFun = { _, _, button, _, self ->
|
||||
if (clickedOn != 2) {
|
||||
clickedOn = 2
|
||||
self.forceHighlighted = true
|
||||
oreItemSlot.forceHighlighted = false
|
||||
itemListUpdate { ItemCodex.hasTag(it.itm, "BURNABLE") }
|
||||
}
|
||||
else if (smelter.fireboxItem != null) {
|
||||
val removeCount = if (button == App.getConfigInt("config_mouseprimary"))
|
||||
smelter.fireboxItem!!.qty
|
||||
else if (button == App.getConfigInt("config_mousesecondary"))
|
||||
1L
|
||||
else
|
||||
null
|
||||
|
||||
if (removeCount != null) {
|
||||
getPlayerInventory().add(smelter.fireboxItem!!.itm, removeCount)
|
||||
smelter.fireboxItem!!.qty -= removeCount
|
||||
if (smelter.fireboxItem!!.qty == 0L) smelter.fireboxItem = null
|
||||
}
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
}
|
||||
else {
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
}
|
||||
}
|
||||
)
|
||||
private val productItemslot = UIItemInventoryElemSimple(
|
||||
private val productItemslot: UIItemInventoryElemSimple = UIItemInventoryElemSimple(
|
||||
this, productX.toInt(), productY.toInt(),
|
||||
emptyCellIcon = smelterCellIcons.get(1, 0),
|
||||
updateOnNull = true,
|
||||
keyDownFun = { _, _, _, _, _ -> },
|
||||
touchDownFun = { item, amount, _, _, _ -> }
|
||||
touchDownFun = { _, _, button, _, self ->
|
||||
if (smelter.productItem != null) {
|
||||
val removeCount = if (button == App.getConfigInt("config_mouseprimary"))
|
||||
smelter.productItem!!.qty
|
||||
else if (button == App.getConfigInt("config_mousesecondary"))
|
||||
1L
|
||||
else
|
||||
null
|
||||
|
||||
if (removeCount != null) {
|
||||
getPlayerInventory().add(smelter.productItem!!.itm, removeCount)
|
||||
smelter.productItem!!.qty -= removeCount
|
||||
if (smelter.productItem!!.qty == 0L) smelter.productItem = null
|
||||
}
|
||||
itemListUpdateKeepCurrentFilter()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
private var encumbrancePerc = 0f
|
||||
|
||||
private fun itemListUpdate() {
|
||||
// let itemlists be sorted
|
||||
// itemListCraftable.rebuild(UIItemCatBar.FILTER_CAT_ALL)
|
||||
playerThings.rebuild(UIItemCatBar.FILTER_CAT_ALL)
|
||||
inventoryFilter = { _: InventoryPair -> true }
|
||||
playerThings.rebuild(FILTER_CAT_ALL)
|
||||
encumbrancePerc = getPlayerInventory().let {
|
||||
it.capacity.toFloat() / it.maxCapacity
|
||||
}
|
||||
}
|
||||
|
||||
private var inventoryFilter = { _: InventoryPair -> true }
|
||||
|
||||
private fun itemListUpdate(filter: (InventoryPair) -> Boolean) {
|
||||
// let itemlists be sorted
|
||||
inventoryFilter = filter
|
||||
playerThings.rebuild(filter)
|
||||
encumbrancePerc = getPlayerInventory().let {
|
||||
it.capacity.toFloat() / it.maxCapacity
|
||||
}
|
||||
}
|
||||
|
||||
private fun itemListUpdateKeepCurrentFilter() {
|
||||
// let itemlists be sorted
|
||||
playerThings.rebuild(inventoryFilter)
|
||||
encumbrancePerc = getPlayerInventory().let {
|
||||
it.capacity.toFloat() / it.maxCapacity
|
||||
}
|
||||
@@ -114,13 +235,18 @@ class UISmelterBasic() : UICanvas(
|
||||
|
||||
init {
|
||||
addUIitem(playerThings)
|
||||
addUIitem(fireboxItemSlot)
|
||||
addUIitem(oreItemSlot)
|
||||
addUIitem(fireboxItemSlot)
|
||||
addUIitem(productItemslot)
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
super.show()
|
||||
|
||||
clickedOn = 0
|
||||
oreItemSlot.forceHighlighted = false
|
||||
fireboxItemSlot.forceHighlighted = false
|
||||
|
||||
playerThings.setGetInventoryFun { INGAME.actorNowPlaying!!.inventory }
|
||||
itemListUpdate()
|
||||
|
||||
@@ -130,6 +256,31 @@ class UISmelterBasic() : UICanvas(
|
||||
|
||||
override fun updateUI(delta: Float) {
|
||||
uiItems.forEach { it.update(delta) }
|
||||
|
||||
oreItemSlot.item = ItemCodex[smelter.oreItem?.itm]
|
||||
oreItemSlot.itemImage = ItemCodex.getItemImage(smelter.oreItem?.itm)
|
||||
oreItemSlot.amount = smelter.oreItem?.qty ?: UNIQUE_ITEM_HAS_NO_AMOUNT
|
||||
|
||||
fireboxItemSlot.item = ItemCodex[smelter.fireboxItem?.itm]
|
||||
fireboxItemSlot.itemImage = ItemCodex.getItemImage(smelter.fireboxItem?.itm)
|
||||
fireboxItemSlot.amount = smelter.fireboxItem?.qty ?: UNIQUE_ITEM_HAS_NO_AMOUNT
|
||||
|
||||
productItemslot.item = ItemCodex[smelter.productItem?.itm]
|
||||
productItemslot.itemImage = ItemCodex.getItemImage(smelter.productItem?.itm)
|
||||
productItemslot.amount = smelter.productItem?.qty ?: UNIQUE_ITEM_HAS_NO_AMOUNT
|
||||
}
|
||||
|
||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||
super.touchDown(screenX, screenY, pointer, button)
|
||||
|
||||
if (!oreItemSlot.mouseUp && !fireboxItemSlot.mouseUp && !productItemslot.mouseUp && !playerThings.itemList.mouseUp) {
|
||||
clickedOn = 0
|
||||
oreItemSlot.forceHighlighted = false
|
||||
fireboxItemSlot.forceHighlighted = false
|
||||
itemListUpdate()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private val controlHelp: String
|
||||
|
||||
@@ -98,7 +98,14 @@ internal class UIStorageChest : UICanvas(
|
||||
itemListChest = UITemplateHalfInventory(this, true, { getFixtureInventory() }, { chestNameFun() }).also {
|
||||
it.itemListKeyDownFun = { _, _, _, _, _ -> Unit }
|
||||
it.itemListTouchDownFun = { gameItem, amount, button, _, _ ->
|
||||
if (button == App.getConfigInt("config_mouseprimary")) {
|
||||
val amount = if (button == App.getConfigInt("config_mouseprimary"))
|
||||
amount
|
||||
else if (button == App.getConfigInt("config_mousesecondary"))
|
||||
1
|
||||
else
|
||||
null
|
||||
|
||||
if (amount != null) {
|
||||
if (gameItem != null) {
|
||||
negotiator.refund(getFixtureInventory(), getPlayerInventory(), gameItem, amount)
|
||||
}
|
||||
@@ -114,7 +121,14 @@ internal class UIStorageChest : UICanvas(
|
||||
itemListPlayer = UITemplateHalfInventory(this, false).also {
|
||||
it.itemListKeyDownFun = { _, _, _, _, _ -> Unit }
|
||||
it.itemListTouchDownFun = { gameItem, amount, button, _, _ ->
|
||||
if (button == App.getConfigInt("config_mouseprimary")) {
|
||||
val amount = if (button == App.getConfigInt("config_mouseprimary"))
|
||||
amount
|
||||
else if (button == App.getConfigInt("config_mousesecondary"))
|
||||
1
|
||||
else
|
||||
null
|
||||
|
||||
if (amount != null) {
|
||||
if (gameItem != null) {
|
||||
negotiator.accept(getPlayerInventory(), getFixtureInventory(), gameItem, amount)
|
||||
}
|
||||
|
||||
@@ -66,23 +66,23 @@ class UITemplateHalfInventory(
|
||||
|
||||
}
|
||||
|
||||
inline fun rebuild(category: Array<String>) {
|
||||
fun rebuild(category: Array<String>) {
|
||||
itemList.rebuild(category)
|
||||
}
|
||||
|
||||
inline fun rebuild(noinline predicate: (InventoryPair) -> Boolean) {
|
||||
fun rebuild(predicate: (InventoryPair) -> Boolean) {
|
||||
itemList.rebuild(predicate)
|
||||
}
|
||||
|
||||
inline fun rebuild(noinline predicate: (InventoryPair) -> Boolean, appendix: ItemID) {
|
||||
fun rebuild(predicate: (InventoryPair) -> Boolean, appendix: ItemID) {
|
||||
itemList.rebuild(predicate, appendix)
|
||||
}
|
||||
|
||||
inline fun removeFromForceHighlightList(items: List<ItemID>) {
|
||||
fun removeFromForceHighlightList(items: List<ItemID>) {
|
||||
itemList.removeFromForceHighlightList(items)
|
||||
}
|
||||
|
||||
inline fun setGetInventoryFun(noinline getter: () -> ActorInventory) {
|
||||
fun setGetInventoryFun(getter: () -> ActorInventory) {
|
||||
itemList.getInventory = getter
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ class UIItemInventoryElemSimple(
|
||||
var showItemCount: Boolean = true,
|
||||
var emptyCellIcon: TextureRegion? = null, // icon to draw when the cell is empty
|
||||
var emptyCellIconColour: Color = Color(0xdddddd7f.toInt()),
|
||||
val updateOnNull: Boolean = false,
|
||||
) : UIItemInventoryCellBase(parentUI, initialX, initialY, item, amount, itemImage, quickslot, equippedSlot, keyDownFun, touchDownFun, extraInfo, highlightEquippedItem, colourTheme) {
|
||||
|
||||
companion object {
|
||||
@@ -78,7 +79,7 @@ class UIItemInventoryElemSimple(
|
||||
// cell border
|
||||
batch.color = if (highlightToMainCol) colourTheme.cellHighlightMainCol
|
||||
else if (highlightToSubCol) colourTheme.cellHighlightSubCol
|
||||
else if (mouseUp && item != null) colourTheme.cellHighlightMouseUpCol
|
||||
else if (mouseUp && (item != null || updateOnNull)) colourTheme.cellHighlightMouseUpCol
|
||||
else colourTheme.cellHighlightNormalCol
|
||||
Toolkit.drawBoxBorder(batch, posX, posY, width, height)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user