mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
crafting recipe is at least successfully read and parsed by the modloader
This commit is contained in:
@@ -4,5 +4,12 @@
|
||||
"ingredients": [ /* Multiple ingredients denotes alternative recipes */
|
||||
[2, 1, "$WOOD", 1, "$ROCK"] /* This recipe only requires one Wooden Plank */
|
||||
]
|
||||
},
|
||||
|
||||
"basegame:176": { /* alternative recipes can be added like this */
|
||||
"workbench": "SOME_WORKBENCH",
|
||||
"ingredients": [
|
||||
[5, 1, "$ROCKWOOD"]
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ object ColorLimiterTest : ApplicationAdapter() {
|
||||
batch = SpriteBatch()
|
||||
shapeRenderer = ShapeRenderer()
|
||||
|
||||
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap", flipY = false)
|
||||
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap")
|
||||
|
||||
|
||||
if (!shader4096.isCompiled) {
|
||||
|
||||
@@ -50,7 +50,7 @@ object GlslTilingTest : ApplicationAdapter() {
|
||||
shader = ShaderProgram(Gdx.files.internal("assets/shaders/default.vert"), Gdx.files.internal("assets/shaders/tiling.frag"))
|
||||
|
||||
|
||||
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap", flipY = false)
|
||||
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap")
|
||||
|
||||
|
||||
if (!shader.isCompiled) {
|
||||
|
||||
@@ -564,7 +564,7 @@ object ModMgr {
|
||||
|
||||
@JvmStatic operator fun invoke(module: String) {
|
||||
getFile(module, recipePath).listFiles { it: File -> it.name.lowercase().endsWith(".json") }?.forEach { jsonFile ->
|
||||
Terrarum.craftingCodex.addFromJson(JsonFetcher(jsonFile), module)
|
||||
Terrarum.craftingCodex.addFromJson(JsonFetcher(jsonFile), module, jsonFile.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ object ShitOnGlsl : ApplicationAdapter() {
|
||||
shader = ShaderProgram(Gdx.files.internal("assets/shaders/default.vert"), Gdx.files.internal("assets/shaders/crt.frag"))
|
||||
|
||||
|
||||
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap", flipY = false)
|
||||
font = TerrarumSansBitmap("assets/graphics/fonts/terrarum-sans-bitmap")
|
||||
|
||||
|
||||
if (!shader.isCompiled) {
|
||||
|
||||
@@ -106,7 +106,7 @@ object IME {
|
||||
}
|
||||
|
||||
|
||||
val iconSheet = TextureRegionPack("assets/graphics/gui/ime_icons_by_language.tga", 20, 20, flipY = false)
|
||||
val iconSheet = TextureRegionPack("assets/graphics/gui/ime_icons_by_language.tga", 20, 20)
|
||||
val iconPixmap = Pixmap(Gdx.files.internal("assets/graphics/gui/ime_icons_by_language.tga"))
|
||||
for (k in 0 until iconPixmap.height step 20) {
|
||||
val langCode = StringBuilder()
|
||||
|
||||
@@ -10,9 +10,9 @@ import net.torvald.terrarum.utils.forEachSiblingsIndexed
|
||||
*/
|
||||
class CraftingCodex {
|
||||
|
||||
@Transient private val props = HashMap<ItemID, ArrayList<CraftingRecipe>>()
|
||||
@Transient internal val props = HashMap<ItemID, ArrayList<CraftingRecipe>>()
|
||||
|
||||
fun addFromJson(json: JsonValue, moduleName: String) {
|
||||
fun addFromJson(json: JsonValue, moduleName: String, fileName:String) {
|
||||
|
||||
if (moduleName.filter { it.code in 33..127 } .length < 5)
|
||||
throw IllegalStateException("Invalid module name: ${moduleName}")
|
||||
@@ -38,8 +38,8 @@ class CraftingCodex {
|
||||
}
|
||||
|
||||
// sanity check
|
||||
if (moq < 1)
|
||||
throw IllegalStateException("Recipe #${ingredientIndex+1} for item '$itemName' has moq of ${moq}")
|
||||
if (moq !in 1..1000)
|
||||
throw IllegalStateException("Recipe #${ingredientIndex+1} for item '$itemName' has invalid moq of ${moq}")
|
||||
else if (qtys.size != itemsStr.size)
|
||||
throw IllegalStateException("Mismatched item name and count for recipe #${ingredientIndex+1} for item '$itemName'")
|
||||
|
||||
@@ -59,7 +59,7 @@ class CraftingCodex {
|
||||
qtys[i]
|
||||
))
|
||||
}
|
||||
recipes.add(CraftingRecipe(workbenchStr, ingredients.toTypedArray(), moq, moduleName))
|
||||
recipes.add(CraftingRecipe(workbenchStr, ingredients.toTypedArray(), moq, "$moduleName/$fileName"))
|
||||
}
|
||||
|
||||
// register to the main props
|
||||
|
||||
@@ -29,13 +29,13 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
|
||||
// load common resources to the AssetsManager
|
||||
CommonResourcePool.addToLoadingList("$moduleName.items16") {
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items.tga"), 16, 16, flipY = false)
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items.tga"), 16, 16)
|
||||
}
|
||||
CommonResourcePool.addToLoadingList("$moduleName.items24") {
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items24.tga"), 24, 24, flipY = false)
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items24.tga"), 24, 24)
|
||||
}
|
||||
CommonResourcePool.addToLoadingList("$moduleName.items48") {
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items48.tga"), 48, 48, flipY = false)
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items48.tga"), 48, 48)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
|
||||
@@ -45,6 +45,16 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
ModMgr.GameItemLoader.invoke(moduleName)
|
||||
ModMgr.GameBlockLoader.invoke(moduleName)
|
||||
ModMgr.GameLanguageLoader.invoke(moduleName)
|
||||
ModMgr.GameCraftingRecipeLoader.invoke(moduleName)
|
||||
|
||||
println("Crafting Recipes: ")
|
||||
Terrarum.craftingCodex.props.forEach { item, recipes ->
|
||||
println("$item ->")
|
||||
recipes.forEach {
|
||||
print(" ")
|
||||
println(it)
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// load customised item loader //
|
||||
|
||||
@@ -236,7 +236,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
fun getSpritesheet(module: String, path: String, tileW: Int, tileH: Int): TextureRegionPack {
|
||||
val id = "$module/${path.replace('\\','/')}"
|
||||
return (CommonResourcePool.getOrPut(id) {
|
||||
TextureRegionPack(ModMgr.getGdxFile(module, path), tileW, tileH, flipY = false)
|
||||
TextureRegionPack(ModMgr.getGdxFile(module, path), tileW, tileH)
|
||||
} as TextureRegionPack)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
|
||||
fun getItemImageFromSheet(module: String, path: String, tileW: Int, tileH: Int): TextureRegion {
|
||||
val id = "$module/${path.replace('\\','/')}"
|
||||
return (CommonResourcePool.getOrPut(id) {
|
||||
TextureRegionPack(ModMgr.getGdxFile(module, path), tileW, tileH, flipY = false)
|
||||
TextureRegionPack(ModMgr.getGdxFile(module, path), tileW, tileH)
|
||||
} as TextureRegionPack).get(0,0)
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : UICanvas() {
|
||||
t.flip(false, false); t
|
||||
}
|
||||
CommonResourcePool.addToLoadingList("savegame_status_icon") {
|
||||
TextureRegionPack("assets/graphics/gui/savegame_status_icon.tga", 24, 24, flipY = false)
|
||||
TextureRegionPack("assets/graphics/gui/savegame_status_icon.tga", 24, 24)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ object Toolkit : Disposable {
|
||||
private lateinit var blurWriteQuad2: Mesh
|
||||
private lateinit var blurWriteQuad4: Mesh
|
||||
|
||||
val baloonTile = TextureRegionPack("assets/graphics/gui/message_black_tileable.tga", 36, 36, flipY = false)
|
||||
val baloonTile = TextureRegionPack("assets/graphics/gui/message_black_tileable.tga", 36, 36)
|
||||
|
||||
val textureWhiteSquare = Texture(Gdx.files.internal("assets/graphics/ortho_line_tex_2px.tga"))
|
||||
val textureWhiteCircle = Texture(Gdx.files.internal("assets/graphics/circle_512.tga"))
|
||||
|
||||
Reference in New Issue
Block a user