mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
inventory grid mode buttons working highlight
This commit is contained in:
Binary file not shown.
67
assets/modules/basegame/default.json
Normal file
67
assets/modules/basegame/default.json
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"displayfps": 0,
|
||||
"usevsync": true,
|
||||
|
||||
"imtooyoungtodie": false,
|
||||
"language": "enUS",
|
||||
"notificationshowuptime": 6500,
|
||||
"multithread": true,
|
||||
|
||||
|
||||
"joypadkeyn": 4,
|
||||
"joypadkeyw": 1,
|
||||
"joypadkeys": 2,
|
||||
"joypadkeye": 3,
|
||||
|
||||
"joypadlup": 4,
|
||||
"joypadrup": 5,
|
||||
"joypadldown": 6,
|
||||
"joypadrdown": 7,
|
||||
|
||||
"joypadlstickx": 0,
|
||||
"joypadlsticky": 1,
|
||||
"joypadrstickx": 2,
|
||||
"joypadrsticky": 3,
|
||||
|
||||
"joypadlabelstyle": "msxb360",
|
||||
|
||||
|
||||
"keyup": 33,
|
||||
"keyleft": 47,
|
||||
"keydown": 32,
|
||||
"keyright": 34,
|
||||
|
||||
"keymovementaux": 29,
|
||||
"keyinventory": 45,
|
||||
"keyinteract": 46,
|
||||
"keyclose": 31,
|
||||
|
||||
"keygamemenu": 61,
|
||||
"keyquicksel": 59,
|
||||
|
||||
"keyquickselalt": [4, 129, 73],
|
||||
|
||||
"keyjump": 62,
|
||||
|
||||
"keyquickbars": [145, 146, 147, 148, 149, 150, 151, 152, 153, 144],
|
||||
|
||||
"mouseprimary": 0,
|
||||
"mousesecondary": 1,
|
||||
|
||||
|
||||
"pcgamepadenv": "console",
|
||||
|
||||
"safetywarning": true,
|
||||
|
||||
|
||||
"maxparticles": 768,
|
||||
|
||||
|
||||
"fullframelightupdate": false,
|
||||
|
||||
"useamericanunit": false,
|
||||
|
||||
|
||||
"fxdither": true,
|
||||
"fx3dlut": false
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.utils.JsonFetcher
|
||||
import org.apache.commons.csv.CSVFormat
|
||||
import org.apache.commons.csv.CSVParser
|
||||
import java.io.File
|
||||
@@ -35,6 +36,8 @@ object ModMgr {
|
||||
val groovyEngine = ScriptEngineManager().getEngineByExtension("groovy")!!
|
||||
val groovyInvocable = groovyEngine as Invocable
|
||||
|
||||
val metaFilename = "metadata.properties"
|
||||
val defaultConfigFilename = "default.json"
|
||||
|
||||
data class ModuleMetadata(
|
||||
val order: Int,
|
||||
@@ -74,7 +77,16 @@ object ModMgr {
|
||||
|
||||
try {
|
||||
val modMetadata = Properties()
|
||||
modMetadata.load(FileInputStream("$modDir/$moduleName/metadata.properties"))
|
||||
modMetadata.load(FileInputStream("$modDir/$moduleName/$metaFilename"))
|
||||
|
||||
if (File("$modDir/$moduleName/$defaultConfigFilename").exists()) {
|
||||
val defaultConfig = JsonFetcher("$modDir/$moduleName/$defaultConfigFilename")
|
||||
// read config and store it to the game
|
||||
|
||||
// write to user's config file
|
||||
}
|
||||
|
||||
|
||||
|
||||
val properName = modMetadata.getProperty("propername")
|
||||
val description = modMetadata.getProperty("description")
|
||||
|
||||
@@ -106,15 +106,58 @@ class UIItemInventoryDynamicList(
|
||||
}
|
||||
)
|
||||
|
||||
private val items: Array<UIItemInventoryCellBase>
|
||||
get() = if (catArrangement[selection] in compactViewCat) itemGrid else itemList
|
||||
private var items: Array<UIItemInventoryCellBase>
|
||||
= if (catArrangement[selection] in compactViewCat) itemGrid else itemList // this is INIT code
|
||||
|
||||
var isCompactView = (catArrangement[selection] in compactViewCat) // this is INIT code
|
||||
set(value) {
|
||||
items = if (value) itemGrid else itemList
|
||||
|
||||
rebuild()
|
||||
|
||||
field = value
|
||||
}
|
||||
|
||||
private val gridModeButtons = Array<UIItemImageButton>(2, { index ->
|
||||
val iconPosX = posX - 12 - parentUI.catIcons.tileW + 2
|
||||
val iconPosY = posY - 2 + (4 + UIItemInventoryElem.height - parentUI.catIcons.tileH) * index
|
||||
|
||||
UIItemImageButton(
|
||||
parentUI,
|
||||
parentUI.catIcons.get(index + 14, 0),
|
||||
activeBackCol = Color(0),
|
||||
activeBackBlendMode = BlendMode.NORMAL,
|
||||
posX = iconPosX,
|
||||
posY = iconPosY,
|
||||
highlightable = true
|
||||
)
|
||||
})
|
||||
|
||||
init {
|
||||
// initially highlight grid mode buttons
|
||||
gridModeButtons[if (isCompactView) 1 else 0].highlighted = true
|
||||
|
||||
|
||||
gridModeButtons[0].touchDownListener = { _, _, _, _ ->
|
||||
isCompactView = false
|
||||
gridModeButtons[0].highlighted = true
|
||||
gridModeButtons[1].highlighted = false
|
||||
}
|
||||
gridModeButtons[1].touchDownListener = { _, _, _, _ ->
|
||||
isCompactView = true
|
||||
gridModeButtons[0].highlighted = false
|
||||
gridModeButtons[1].highlighted = true
|
||||
}
|
||||
|
||||
// if (is.mouseUp) handled by this.touchDown()
|
||||
}
|
||||
|
||||
|
||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||
|
||||
items.forEach { it.render(batch, camera) }
|
||||
|
||||
gridModeButtons.forEach { it.render(batch, camera) }
|
||||
|
||||
super.render(batch, camera)
|
||||
}
|
||||
@@ -124,6 +167,8 @@ class UIItemInventoryDynamicList(
|
||||
super.update(delta)
|
||||
|
||||
items.forEach { it.update(delta) }
|
||||
|
||||
gridModeButtons.forEach { it.update(delta) }
|
||||
}
|
||||
|
||||
|
||||
@@ -190,12 +235,14 @@ class UIItemInventoryDynamicList(
|
||||
override fun dispose() {
|
||||
itemList.forEach { it.dispose() }
|
||||
itemGrid.forEach { it.dispose() }
|
||||
gridModeButtons.forEach { it.dispose() }
|
||||
}
|
||||
|
||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||
super.touchDown(screenX, screenY, pointer, button)
|
||||
|
||||
items.forEach { if (it.mouseUp) it.touchDown(screenX, screenY, pointer, button) }
|
||||
gridModeButtons.forEach { if (it.mouseUp) it.touchDown(screenX, screenY, pointer, button) }
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user