quickslot works, new event for actor "actorValueChanged"

- "unpacking" fresh new tool would un-register quickslot desig.
- priority issue on "equipped by quickslot change" and "equipped by inventory UI"
This commit is contained in:
Song Minjae
2017-04-28 12:21:27 +09:00
parent 13e817e154
commit 996d578d3e
34 changed files with 215 additions and 61 deletions

View File

@@ -1,7 +1,6 @@
package net.torvald.terrarum.ui
import net.torvald.terrarum.*
import net.torvald.terrarum.Terrarum.QUICKSLOT_MAX
import net.torvald.terrarum.Terrarum.joypadLabelNinA
import net.torvald.terrarum.Terrarum.joypadLabelNinY
import net.torvald.terrarum.gameactors.*
@@ -257,7 +256,7 @@ class UIInventory(
items[k].itemImage = ItemCodex.getItemImage(sortListItem.item)
// set quickslot number
for (qs in 1..QUICKSLOT_MAX) {
for (qs in 1..UIQuickBar.SLOT_COUNT) {
if (sortListItem.item == actor?.inventory?.getQuickBar(qs - 1)?.item) {
items[k].quickslot = qs % 10 // 10 -> 0, 1..9 -> 1..9
break

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.ui
import net.torvald.terrarum.Millisec
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameworld.fmod
import net.torvald.terrarum.itemproperties.ItemCodex
import org.newdawn.slick.Color
import org.newdawn.slick.GameContainer
@@ -28,7 +29,7 @@ class UIQuickBar : UICanvas, MouseControlled {
private var selection: Int
get() = Terrarum.ingame!!.player?.actorValue?.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
set(value) { Terrarum.ingame!!.player?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, value) }
set(value) { Terrarum.ingame!!.player?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, value.fmod(SLOT_COUNT)) }
override fun update(gc: GameContainer, delta: Int) {
@@ -108,8 +109,7 @@ class UIQuickBar : UICanvas, MouseControlled {
}
override fun mouseWheelMoved(change: Int) {
selection = selection.plus(if (change > 1) 1 else if (change < -1) -1 else 0).rem(SLOT_COUNT)
if (selection < 0) selection += SLOT_COUNT
selection = selection.plus(if (change > 1) 1 else if (change < -1) -1 else 0).fmod(SLOT_COUNT)
}
companion object {