This commit is contained in:
2026-01-17 13:59:18 -06:00
parent c46afdac76
commit fbc4e070da
10 changed files with 145 additions and 52 deletions

View File

@@ -1,25 +1,40 @@
class_name ActionBox extends GridContainer
enum Action {
ATTACK,
MAGIC,
ITEM,
BACK
}
@export var btnAttack:Button
@export var btnMagic:Button
@export var btnItem:Button
@export var btnBack:Button
signal decisionMade(move:BattleDecision)
signal action(action:Action)
func _ready() -> void:
btnAttack.pressed.connect(onAttackPressed)
btnMagic.pressed.connect(onMagicPressed)
btnItem.pressed.connect(onItemPressed)
btnAttack.pressed.connect(func():
action.emit(Action.ATTACK)
)
btnMagic.pressed.connect(func():
action.emit(Action.MAGIC)
)
btnItem.pressed.connect(func():
action.emit(Action.ITEM)
)
btnBack.pressed.connect(func():
action.emit(Action.BACK)
)
self.visible = false
func onAttackPressed() -> void:
print("Attack button pressed")
decisionMade.emit(BattleDecision.new(BattleMove.MOVE_PUNCH, null, null))
func onMagicPressed() -> void:
print("Magic button pressed")
decisionMade.emit(BattleDecision.new(BattleMove.MOVE_FIRE1, null, null))
func getAction(fighter:BattleFighter) -> Action:
btnAttack.disabled = fighter.movePrimary == null || !fighter.movePrimary.canFighterUse(fighter)
btnMagic.disabled = fighter.movesMagical.size() == 0
btnItem.disabled = false # TODO: check if items available?
func onItemPressed() -> void:
print("Item button pressed")
decisionMade.emit(null)
# TODO: Update cursor position to first enabled button
var act = await action
return act