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

View File

@@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://27274005hbgh" path="res://battle/ui/ActionBox.gd" id="1_w5s71"]
[node name="ActionBox" type="GridContainer" node_paths=PackedStringArray("btnAttack", "btnMagic", "btnItem")]
[node name="ActionBox" type="GridContainer" node_paths=PackedStringArray("btnAttack", "btnMagic", "btnItem", "btnBack")]
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
@@ -17,6 +17,7 @@ script = ExtResource("1_w5s71")
btnAttack = NodePath("Attack")
btnMagic = NodePath("Magic")
btnItem = NodePath("Items")
btnBack = NodePath("Back")
metadata/_custom_type_script = "uid://27274005hbgh"
[node name="Attack" type="Button" parent="."]
@@ -31,6 +32,6 @@ text = "Magic"
layout_mode = 2
text = "Items"
[node name="idk" type="Button" parent="."]
[node name="Back" type="Button" parent="."]
layout_mode = 2
text = "idk"
text = "Back"