diff --git a/assets/mods/basegame/crafting/fixtures.json b/assets/mods/basegame/crafting/fixtures.json index 26b2ef6c5..7fd5a7199 100644 --- a/assets/mods/basegame/crafting/fixtures.json +++ b/assets/mods/basegame/crafting/fixtures.json @@ -2,7 +2,8 @@ "basegame:176": { /* torch */ "workbench": "", "ingredients": [ - [5, 1, "item@basegame:18", 1, "item@basegame:130"] /* 5 torches = 1 stick, 1 coal */ + [5, 1, "item@basegame:18", 1, "item@basegame:130"], /* 5 torches = 1 stick, 1 coal */ + [5, 1, "item@basegame:18", 1, "item@basegame:29"] /* 5 torches = 1 stick, 1 charcoal */ ] }, "item@basegame:5": { /* tiki torch */ diff --git a/assets/mods/basegame/items/itemid.csv b/assets/mods/basegame/items/itemid.csv index fb20ab3e7..a9b919b2d 100644 --- a/assets/mods/basegame/items/itemid.csv +++ b/assets/mods/basegame/items/itemid.csv @@ -26,12 +26,13 @@ id;classname;tags 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 +29;net.torvald.terrarum.modulebasegame.gameitems.ItemCharcoal;COMBUSTIBLE # ingots 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,COMBUSTIBLE +114;net.torvald.terrarum.modulebasegame.gameitems.ItemCoalCoke;COMBUSTIBLE 115;net.torvald.terrarum.modulebasegame.gameitems.IngotZinc;INGOT 116;net.torvald.terrarum.modulebasegame.gameitems.IngotTin;INGOT 117;net.torvald.terrarum.modulebasegame.gameitems.IngotGold;INGOT @@ -59,10 +60,10 @@ id;classname;tags 163;net.torvald.terrarum.modulebasegame.gameitems.ItemSeedRosewood;SEEDLING # tree logs -168;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsOak;COMBUSTIBLE -169;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsEbony;COMBUSTIBLE -170;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsBirch;COMBUSTIBLE -171;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsRosewood;COMBUSTIBLE +168;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsOak;COMBUSTIBLE,SMELTABLE +169;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsEbony;COMBUSTIBLE,SMELTABLE +170;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsBirch;COMBUSTIBLE,SMELTABLE +171;net.torvald.terrarum.modulebasegame.gameitems.ItemLogsRosewood;COMBUSTIBLE,SMELTABLE 256;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorOak;FIXTURE diff --git a/assets/mods/basegame/items/items.tga b/assets/mods/basegame/items/items.tga index 82f5a061d..d9bf79018 100644 --- a/assets/mods/basegame/items/items.tga +++ b/assets/mods/basegame/items/items.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dca7861ad7eaf241e2e0276233c1e8adbe64ffbb69e591295763b70e54e277f8 +oid sha256:6edde9fa72a97f57e35ad52aceb677edade79f9af6b6ef53c0747f4600cdb694 size 2408466 diff --git a/assets/mods/basegame/locales/en/items.json b/assets/mods/basegame/locales/en/items.json index d5b7dc7d7..49673b61b 100644 --- a/assets/mods/basegame/locales/en/items.json +++ b/assets/mods/basegame/locales/en/items.json @@ -1,5 +1,6 @@ { "ITEM_CALENDAR": "Calendar", + "ITEM_CHARCOAL": "Charcoal", "ITEM_COAL_COKE": "Coal Coke", "ITEM_DOOR_OAK": "Oak Door", "ITEM_DOOR_EBONY": "Ebony Door", diff --git a/assets/mods/basegame/locales/koKR/items.json b/assets/mods/basegame/locales/koKR/items.json index 456659c8b..99fe6522c 100644 --- a/assets/mods/basegame/locales/koKR/items.json +++ b/assets/mods/basegame/locales/koKR/items.json @@ -1,5 +1,6 @@ { "ITEM_CALENDAR": "달력", + "ITEM_CHARCOAL": "목탄", "ITEM_COAL_COKE": "코크스", "ITEM_DOOR_OAK": "나무 문", "ITEM_DOOR_EBONY": "흑단 문", diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/ItemFurnaceAndAnvil.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemFurnaceAndAnvil.kt index 56e8f2f9b..0082c4aa4 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameitems/ItemFurnaceAndAnvil.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemFurnaceAndAnvil.kt @@ -1,6 +1,7 @@ package net.torvald.terrarum.modulebasegame.gameitems import com.badlogic.gdx.graphics.g2d.TextureRegion +import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.gameitems.ItemID /** @@ -13,9 +14,7 @@ class ItemFurnaceAndAnvil(originalID: ItemID) : FixtureItemBase(originalID, "net override val isDynamic = false override val materialId = "" override val itemImage: TextureRegion - get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/metalworking_furnace_and_anvil.tga") - override val itemImageEmissive: TextureRegion - get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/metalworking_furnace_and_anvil_emsv.tga") + get() = CommonResourcePool.getAsItemSheet("basegame.items").get(5,3) override var baseToolSize: Double? = baseMass override var originalName = "ITEM_FURNACE_AND_ANVIL" diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/ItemSmelterBasic.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemSmelterBasic.kt index 435f842e7..a8371a43a 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameitems/ItemSmelterBasic.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemSmelterBasic.kt @@ -10,26 +10,12 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack * Created by minjaesong on 2023-12-04. */ class ItemSmelterBasic(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureSmelterBasic") { - - init { - CommonResourcePool.addToLoadingList("basegame/sprites/fixtures/smelter_tall.tga") { - TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/smelter_tall.tga"), 48, 64) - } - CommonResourcePool.addToLoadingList("basegame/sprites/fixtures/smelter_tall_emsv.tga") { - TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/smelter_tall_emsv.tga"), 48, 64) - } - CommonResourcePool.loadAll() - } - override var baseMass = 100.0 override val isDynamic = false override val materialId = "" override val itemImage: TextureRegion - get() = CommonResourcePool.getAsTextureRegionPack("basegame/sprites/fixtures/smelter_tall.tga").get(1, 0) - override val itemImageEmissive: TextureRegion - get() = CommonResourcePool.getAsTextureRegionPack("basegame/sprites/fixtures/smelter_tall_emsv.tga").get(1, 0) + get() = CommonResourcePool.getAsItemSheet("basegame.items").get(4,3) override var baseToolSize: Double? = baseMass override var originalName = "ITEM_SMELTER_SMALL" - } \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/OreItemBase.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/OreItemBase.kt index d5bed8f1b..db9df2342 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameitems/OreItemBase.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/OreItemBase.kt @@ -35,6 +35,7 @@ class ItemLogsOak(originalID: ItemID) : OreItemBase(originalID) { override val materialId = "WOOD" override var calories = 1920.0 override var smokiness = 0.2f + override var smeltingProduct: ItemID? = "item@basegame:29" override val itemImage: TextureRegion get() = CommonResourcePool.getAsItemSheet("basegame.items").get(0,10) @@ -48,6 +49,7 @@ class ItemLogsEbony(originalID: ItemID) : OreItemBase(originalID) { override val materialId = "WOOD" override var calories = 1920.0 override var smokiness = 0.2f + override var smeltingProduct: ItemID? = "item@basegame:29" override val itemImage: TextureRegion get() = CommonResourcePool.getAsItemSheet("basegame.items").get(1,10) @@ -61,6 +63,7 @@ class ItemLogsBirch(originalID: ItemID) : OreItemBase(originalID) { override val materialId = "WOOD" override var calories = 1920.0 override var smokiness = 0.2f + override var smeltingProduct: ItemID? = "item@basegame:29" override val itemImage: TextureRegion get() = CommonResourcePool.getAsItemSheet("basegame.items").get(2,10) @@ -74,6 +77,7 @@ class ItemLogsRosewood(originalID: ItemID) : OreItemBase(originalID) { override val materialId = "WOOD" override var calories = 1920.0 override var smokiness = 0.2f + override var smeltingProduct: ItemID? = "item@basegame:29" override val itemImage: TextureRegion get() = CommonResourcePool.getAsItemSheet("basegame.items").get(3,10) @@ -180,6 +184,13 @@ class ItemCoalCoke(originalID: ItemID) : OreItemBase(originalID) { override val itemImage: TextureRegion get() = CommonResourcePool.getAsItemSheet("basegame.items").get(9,6) } +class ItemCharcoal(originalID: ItemID) : OreItemBase(originalID) { + override var originalName = "ITEM_CHARCOAL" + override var calories = 4800.0 + override var smokiness = 0.3f + override val itemImage: TextureRegion + get() = CommonResourcePool.getAsItemSheet("basegame.items").get(12,6) +} class IngotCopper(originalID: ItemID) : OreItemBase(originalID) { override var originalName = "ITEM_INGOT_COPPER" override val itemImage: TextureRegion diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UICrafting.kt b/src/net/torvald/terrarum/modulebasegame/ui/UICrafting.kt index 055727b24..0d92fb15d 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UICrafting.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UICrafting.kt @@ -120,7 +120,7 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas( val buttonWidth = (UIItemInventoryElemWide.height + listGap) * 3 - listGap - 2 // ingredient list - itemListIngredients = UIItemInventoryItemGrid( + itemListIngredients = UIItemInventoryItemGrid( this, { ingredients }, thisOffsetX, @@ -135,7 +135,8 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas( keyDownFun = { _, _, _, _, _ -> }, wheelFun = { _, _, _, _, _, _ -> }, touchDownFun = { gameItem, amount, _, _, _ -> gameItem?.let { gameItem -> - // if the item is craftable one, load its recipe instead + // if the clicked item is craftable one, present its recipe to the player // + CraftingRecipeCodex.getRecipesFor(gameItem.originalID)?.let { recipes -> // select most viable recipe (completely greedy search) val player = getPlayerInventory() @@ -150,7 +151,7 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas( listOf(score, items, recipe) }.maxByOrNull { it[0] as Long }?.let { (_, items, recipe) -> - val items = items as List> + val items = items as List val recipe = recipe as CraftingCodex.CraftingRecipe // change selected recipe to mostViableRecipe then update the UIs accordingly @@ -167,8 +168,8 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas( recipeClicked = recipe items.forEach { - val itm = it[0] as ItemID - val qty = it[2] as Long + val itm = it.selectedItem + val qty = it.howManyRecipeWants selectedItems.add(itm) ingredients.add(itm, qty) @@ -176,30 +177,14 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas( _getItemListPlayer().let { it.removeFromForceHighlightList(oldSelectedItems) - filterPlayerListUsing(recipeClicked) + //filterPlayerListUsing(recipeClicked) // ??? it.addToForceHighlightList(selectedItems) - it.rebuild(FILTER_CAT_ALL) + filterPlayerListUsing(recipeClicked) } + _getItemListIngredients().rebuild(FILTER_CAT_ALL) - // highlighting CraftingCandidateButton by searching for the buttons that has the recipe - _getItemListCraftables().let { - // turn the highlights off - it.items.forEach { it.forceHighlighted = false } - - // search for the recipe - // also need to find what "page" the recipe might be in - // use it.isCompactMode to find out the current mode - var ord = 0 - while (ord < it.craftingRecipes.indices.last) { - if (recipeClicked == it.craftingRecipes[ord]) break - ord += 1 - } - val itemSize = it.items.size - - it.itemPage = ord / itemSize - it.items[ord % itemSize].forceHighlighted = true - } + _getItemListCraftables().highlightRecipe(recipeClicked, true) oldSelectedItems.clear() oldSelectedItems.addAll(selectedItems) diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIItemCraftingCandidateGrid.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIItemCraftingCandidateGrid.kt index 160bc89fd..8df1b6063 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIItemCraftingCandidateGrid.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIItemCraftingCandidateGrid.kt @@ -40,14 +40,34 @@ class UIItemCraftingCandidateGrid( private var highlightedRecipe: CraftingCodex.CraftingRecipe? = null - fun highlightRecipe(recipe: CraftingCodex.CraftingRecipe?) { + fun highlightRecipe(recipe: CraftingCodex.CraftingRecipe?, changePage: Boolean = false) { items.forEach { it.forceHighlighted = false } highlightedRecipe = recipe - recipe?.let { - items.find { it.extraInfo == recipe }?.let { buttonFound -> - buttonFound.forceHighlighted = true + // search for the recipe + // also need to find what "page" the recipe might be in + // use it.isCompactMode to find out the current mode + var ord = 0 + var found = false + while (ord < craftingRecipes.indices.last) { + if (recipe == craftingRecipes[ord]) { + found = true + break + } + ord += 1 + } + val itemSize = items.size + val newPage = ord / itemSize + + if (found) { + if (changePage) { + itemPage = newPage + items[ord % itemSize].forceHighlighted = true + } + // if we are on the same page, highlight the cell; otherwise, do nothing + else if (itemPage == newPage) { + items[ord % itemSize].forceHighlighted = true } } } diff --git a/src/net/torvald/terrarum/ui/UIItemInventoryElemSimple.kt b/src/net/torvald/terrarum/ui/UIItemInventoryElemSimple.kt index 4e79fb668..168fbfbd5 100644 --- a/src/net/torvald/terrarum/ui/UIItemInventoryElemSimple.kt +++ b/src/net/torvald/terrarum/ui/UIItemInventoryElemSimple.kt @@ -76,8 +76,8 @@ class UIItemInventoryElemSimple( } // cell border batch.color = if (highlightToMainCol) colourTheme.cellHighlightMainCol - else if (highlightToSubCol) colourTheme.cellHighlightSubCol else if (mouseUp && (item != null || updateOnNull)) colourTheme.cellHighlightMouseUpCol + else if (highlightToSubCol) colourTheme.cellHighlightSubCol else colourTheme.cellHighlightNormalCol Toolkit.drawBoxBorder(batch, posX, posY, width, height) diff --git a/src/shaders/crt.frag b/src/shaders/crt.frag index cee836810..3f73433b8 100644 --- a/src/shaders/crt.frag +++ b/src/shaders/crt.frag @@ -40,6 +40,6 @@ void main(void) { out_color = out_color * scanline_darkening; } - fragColor = vec4(out_color, 1); + fragColor = vec4(out_color, color.a); //fragColor = texture(u_texture, v_texCoords); } \ No newline at end of file diff --git a/work_files/graphics/items/basegame_items.kra b/work_files/graphics/items/basegame_items.kra index 5088bc257..c96ce0ad1 100644 --- a/work_files/graphics/items/basegame_items.kra +++ b/work_files/graphics/items/basegame_items.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ecf154ac8bf8425d18852c7319a053d276ad5be7ce8501102be1c101ea0ece6b -size 938272 +oid sha256:7fb0c8a957aec6e9d87e42cfa7c2ffa2a2f530951369c23d8ff86689001446c2 +size 1602279 diff --git a/work_files/graphics/sprites/fixtures/metalworking_furnace_and_anvil.kra b/work_files/graphics/sprites/fixtures/metalworking_furnace_and_anvil.kra index 8c798958a..69b66ad44 100644 --- a/work_files/graphics/sprites/fixtures/metalworking_furnace_and_anvil.kra +++ b/work_files/graphics/sprites/fixtures/metalworking_furnace_and_anvil.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:04ae5555b9646db77f3bbcb378ce985c1c8afa99a70d3808735c1714016814f0 -size 170805 +oid sha256:46e9d7af4118b10ccb6be557866ac12dea5d51bef9f6c38826253cf0a823345e +size 186237