mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-11 06:11:50 +09:00
charcoal; smelter item sprite;
crafting-fixed navigate-ingredients-crafting-recipe behav
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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<List<*>>
|
||||
val items = items as List<RecipeIngredientRecord>
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user