diff --git a/Systems/Combat/Scripts/Combatant.gd b/Systems/Combat/Scripts/Combatant.gd index 4d30861..8f4a916 100644 --- a/Systems/Combat/Scripts/Combatant.gd +++ b/Systems/Combat/Scripts/Combatant.gd @@ -3,13 +3,13 @@ class_name Combatant # @export var Behavior: -@export var Menu: BattleMenu @export var Stats: CombatStats @export var Actions: Array[Action] = [] var is_init = false func _ready(): + pass # var idx = 0 # for node in get_children(): # if node.name == "Actions": @@ -18,8 +18,8 @@ func _ready(): # Menu.add_action(action) # Actions.append(action) # idx += 1 - for action in Actions: - Menu.add_action(action) +# for action in Actions: +# Menu.add_action(action) func execute_action(index: int): diff --git a/Systems/UI/Menu System/Scripts/battle_menu.gd b/Systems/UI/Menu System/Scripts/battle_menu.gd new file mode 100644 index 0000000..a8c12f6 --- /dev/null +++ b/Systems/UI/Menu System/Scripts/battle_menu.gd @@ -0,0 +1,25 @@ +extends Control +class_name BattleMenu + +var items: Array[MenuItem] = [] +var top_margin = 100 +var item_padding = 10 +var next_y_pos = 0 + +func _ready(): + next_y_pos = top_margin + +func add_action(action: Action): + var item = preload("res://Systems/UI/Menu System/menu_item.tscn").instantiate() + items.push_back(item) + item.label = action.ActionName + item.action = action + + var button = item.get_node("Button") + button.position.y = next_y_pos + next_y_pos += button.size.y + item_padding + + var panel = $Panel + # var button = item.get_node("Button") + panel.add_child(item) + diff --git a/Systems/UI/Menu System/Scripts/menu_item.gd b/Systems/UI/Menu System/Scripts/menu_item.gd new file mode 100644 index 0000000..f5b2217 --- /dev/null +++ b/Systems/UI/Menu System/Scripts/menu_item.gd @@ -0,0 +1,17 @@ +extends Control +class_name MenuItem + +@export var label = "" +@export var action: Action + +@onready var button = $Button + +signal action_selected(action) + +# Called when the node enters the scene tree for the first time. +func _ready(): + button.text = label + + +func _on_button_pressed(): + emit_signal("action_selected", action) diff --git a/Systems/UI/Menu System/battle_menu.tscn b/Systems/UI/Menu System/battle_menu.tscn new file mode 100644 index 0000000..88848ec --- /dev/null +++ b/Systems/UI/Menu System/battle_menu.tscn @@ -0,0 +1,39 @@ +[gd_scene load_steps=2 format=3 uid="uid://cl5d768roh8ir"] + +[ext_resource type="Script" path="res://Systems/UI/Menu System/Scripts/battle_menu.gd" id="1_fije1"] + +[node name="battle_menu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_fije1") + +[node name="Panel" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -100.0 +offset_top = -86.0 +offset_right = 108.0 +offset_bottom = 184.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Label" type="Label" parent="Panel"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -60.0 +offset_top = 16.0 +offset_right = 53.0 +offset_bottom = 45.0 +grow_horizontal = 2 +text = "Battle Menu" +horizontal_alignment = 1 diff --git a/Systems/UI/Menu System/menu_item.tscn b/Systems/UI/Menu System/menu_item.tscn new file mode 100644 index 0000000..e929919 --- /dev/null +++ b/Systems/UI/Menu System/menu_item.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=2 format=3 uid="uid://l1bdgx07seai"] + +[ext_resource type="Script" path="res://Systems/UI/Menu System/Scripts/menu_item.gd" id="1_paamu"] + +[node name="MenuItem" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_paamu") + +[node name="Button" type="Button" parent="."] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -36.0 +offset_right = 36.0 +offset_bottom = 34.0 +grow_horizontal = 2 +text = "TEST" + +[connection signal="pressed" from="Button" to="." method="_on_button_pressed"] diff --git a/Systems/UI/Scripts/battle_menu.gd b/Systems/UI/Scripts/battle_menu.gd deleted file mode 100644 index de1ae0a..0000000 --- a/Systems/UI/Scripts/battle_menu.gd +++ /dev/null @@ -1,7 +0,0 @@ -extends Control -class_name BattleMenu - -@onready var text = $Text - -func add_action(action: Action): - text.text += "\n%d) %s" % [action.ActionIndex + 1, action.ActionName] diff --git a/Systems/UI/battle_menu.tscn b/Systems/UI/battle_menu.tscn deleted file mode 100644 index ab7fc09..0000000 --- a/Systems/UI/battle_menu.tscn +++ /dev/null @@ -1,18 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://cl5d768roh8ir"] - -[ext_resource type="Script" path="res://Systems/UI/Scripts/battle_menu.gd" id="1_ng8au"] - -[node name="battle_menu" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_ng8au") - -[node name="Text" type="Label" parent="."] -layout_mode = 0 -offset_right = 299.0 -offset_bottom = 142.0 -text = "Battle Menu:" diff --git a/Test Scenes/Player.gd b/Test Scenes/Player.gd new file mode 100644 index 0000000..ae837d3 --- /dev/null +++ b/Test Scenes/Player.gd @@ -0,0 +1,7 @@ +extends Sprite2D + + +func _ready(): + var menu = $battle_menu + menu.add_action($Combatant/Actions/attack) + menu.add_action($Combatant/Actions/spin_attack) diff --git a/Test Scenes/sandbox.tscn b/Test Scenes/sandbox.tscn index c7ef23a..7c8ae16 100644 --- a/Test Scenes/sandbox.tscn +++ b/Test Scenes/sandbox.tscn @@ -1,10 +1,15 @@ -[gd_scene load_steps=11 format=3 uid="uid://dnmtnb7kvhmkp"] +[gd_scene load_steps=16 format=3 uid="uid://dnmtnb7kvhmkp"] -[ext_resource type="PackedScene" uid="uid://cnnvxd4gefp4o" path="res://Test Scenes/test_player.tscn" id="1_ff72w"] [ext_resource type="Texture2D" uid="uid://dxqymswxvgfax" path="res://assets/binary files/tile sets/RPGW_GrassLand_v2.01/MainLev2.0.png" id="2_mrneo"] [ext_resource type="Texture2D" uid="uid://iuymh60ilu1r" path="res://assets/binary files/tile sets/RPGW_GrassLand_v2.01/decorative.png" id="3_ylcjg"] [ext_resource type="Texture2D" uid="uid://cu7troaoq4own" path="res://assets/binary files/tile sets/RPGW_GrassLand_v2.01/anim/tree1B_ss.png" id="4_e2cmm"] +[ext_resource type="PackedScene" uid="uid://cl5d768roh8ir" path="res://Systems/UI/Menu System/battle_menu.tscn" id="5_5qms1"] +[ext_resource type="Texture2D" uid="uid://dedauf4ntkthu" path="res://icon.svg" id="5_b4su3"] [ext_resource type="Texture2D" uid="uid://qje1ncupgnd" path="res://assets/binary files/tile sets/RPGW_GrassLand_v2.01/anim/tree1D_ss.png" id="5_ewkk6"] +[ext_resource type="Script" path="res://Test Scenes/Player.gd" id="6_wrfj3"] +[ext_resource type="PackedScene" uid="uid://ch1sc85jxy1r7" path="res://Systems/Combat/Combatant.tscn" id="8_81l0u"] +[ext_resource type="PackedScene" uid="uid://bbbyup8pp6uam" path="res://Test Scenes/Test Player Actions/attack.tscn" id="9_1kqn5"] +[ext_resource type="PackedScene" uid="uid://bmot4y61f1r8f" path="res://Test Scenes/Test Player Actions/spin_attack.tscn" id="10_nrdne"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_6ttut"] texture = ExtResource("2_mrneo") @@ -12572,7 +12577,7 @@ sources/3 = SubResource("TileSetAtlasSource_mt186") [node name="Sandbox" type="Node2D"] -[node name="Battle Platform" type="TileMap" parent="."] +[node name="Battle Map" type="TileMap" parent="."] y_sort_enabled = true tile_set = SubResource("TileSet_tqlf2") format = 2 @@ -12594,4 +12599,26 @@ layer_2/y_sort_origin = 0 layer_2/z_index = 0 layer_2/tile_data = PackedInt32Array(983087, 3, 2, 1048623, 3, 3, 983088, 65539, 2, 1048624, 65539, 3, 1114160, 65539, 4, 852017, 131075, 0, 917553, 131075, 1, 983089, 131075, 2, 1048625, 131075, 3, 1114161, 131075, 4, 1376305, 131075, 8, 1441841, 131075, 9, 852018, 196611, 0, 917554, 196611, 1, 983090, 196611, 2, 1048626, 196611, 3, 1114162, 196611, 4, 1179698, 196611, 5, 1245234, 196611, 6, 1310770, 196611, 7, 1376306, 196611, 8, 1441842, 196611, 9, 852019, 262147, 0, 917555, 262147, 1, 983091, 262147, 2, 1048627, 262147, 3, 1114163, 262147, 4, 1179699, 262147, 5, 1245235, 262147, 6, 1310771, 262147, 7, 1376307, 262147, 8, 1441843, 262147, 9, 852020, 327683, 0, 917556, 327683, 1, 983092, 327683, 2, 1048628, 327683, 3, 1114164, 327683, 4, 1179700, 327683, 5, 1245236, 327683, 6, 1310772, 327683, 7, 1376308, 327683, 8, 1441844, 327683, 9, 852021, 393219, 0, 917557, 393219, 1, 983093, 393219, 2, 1048629, 393219, 3, 1114165, 393219, 4, 1179701, 393219, 5, 1245237, 393219, 6, 1310773, 393219, 7, 1376309, 393219, 8, 1441845, 393219, 9, 852022, 458755, 0, 917558, 458755, 1, 983094, 458755, 2, 1048630, 458755, 3, 1114166, 458755, 4, 1179702, 458755, 5, 1245238, 458755, 6, 1310774, 458755, 7, 1376310, 458755, 8, 1441846, 458755, 9, 852023, 524291, 0, 917559, 524291, 1, 983095, 524291, 2, 1048631, 524291, 3, 1114167, 524291, 4, 524325, 3, 2, 589861, 3, 3, 524326, 65539, 2, 589862, 65539, 3, 655398, 65539, 4, 393255, 131075, 0, 458791, 131075, 1, 524327, 131075, 2, 589863, 131075, 3, 655399, 131075, 4, 917543, 131075, 8, 983079, 131075, 9, 393256, 196611, 0, 458792, 196611, 1, 524328, 196611, 2, 589864, 196611, 3, 655400, 196611, 4, 720936, 196611, 5, 786472, 196611, 6, 852008, 196611, 7, 917544, 196611, 8, 983080, 196611, 9, 393257, 262147, 0, 458793, 262147, 1, 524329, 262147, 2, 589865, 262147, 3, 655401, 262147, 4, 720937, 262147, 5, 786473, 262147, 6, 852009, 262147, 7, 917545, 262147, 8, 983081, 262147, 9, 393258, 327683, 0, 458794, 327683, 1, 524330, 327683, 2, 589866, 327683, 3, 655402, 327683, 4, 720938, 327683, 5, 786474, 327683, 6, 852010, 327683, 7, 917546, 327683, 8, 983082, 327683, 9, 393259, 393219, 0, 458795, 393219, 1, 524331, 393219, 2, 589867, 393219, 3, 655403, 393219, 4, 720939, 393219, 5, 786475, 393219, 6, 852011, 393219, 7, 917547, 393219, 8, 983083, 393219, 9, 393260, 458755, 0, 458796, 458755, 1, 524332, 458755, 2, 589868, 458755, 3, 655404, 458755, 4, 720940, 458755, 5, 786476, 458755, 6, 852012, 458755, 7, 917548, 458755, 8, 983084, 458755, 9, 393261, 524291, 0, 458797, 524291, 1, 524333, 524291, 2, 589869, 524291, 3, 655405, 524291, 4, 851974, 3, 2, 917510, 3, 3, 851975, 65539, 2, 917511, 65539, 3, 983047, 65539, 4, 720904, 131075, 0, 786440, 131075, 1, 851976, 131075, 2, 917512, 131075, 3, 983048, 131075, 4, 1245192, 131075, 8, 1310728, 131075, 9, 720905, 196611, 0, 786441, 196611, 1, 851977, 196611, 2, 917513, 196611, 3, 983049, 196611, 4, 1048585, 196611, 5, 1114121, 196611, 6, 1179657, 196611, 7, 1245193, 196611, 8, 1310729, 196611, 9, 720906, 262147, 0, 786442, 262147, 1, 851978, 262147, 2, 917514, 262147, 3, 983050, 262147, 4, 1048586, 262147, 5, 1114122, 262147, 6, 1179658, 262147, 7, 1245194, 262147, 8, 1310730, 262147, 9, 720907, 327683, 0, 786443, 327683, 1, 851979, 327683, 2, 917515, 327683, 3, 983051, 327683, 4, 1048587, 327683, 5, 1114123, 327683, 6, 1179659, 327683, 7, 1245195, 327683, 8, 1310731, 327683, 9, 720908, 393219, 0, 786444, 393219, 1, 851980, 393219, 2, 917516, 393219, 3, 983052, 393219, 4, 1048588, 393219, 5, 1114124, 393219, 6, 1179660, 393219, 7, 1245196, 393219, 8, 1310732, 393219, 9, 720909, 458755, 0, 786445, 458755, 1, 851981, 458755, 2, 917517, 458755, 3, 983053, 458755, 4, 1048589, 458755, 5, 1114125, 458755, 6, 1179661, 458755, 7, 1245197, 458755, 8, 1310733, 458755, 9, 720910, 524291, 0, 786446, 524291, 1, 851982, 524291, 2, 917518, 524291, 3, 983054, 524291, 4, 524309, 2, 2, 589845, 2, 3, 524310, 65538, 2, 589846, 65538, 3, 655382, 65538, 4, 393239, 131074, 0, 458775, 131074, 1, 524311, 131074, 2, 589847, 131074, 3, 655383, 131074, 4, 917527, 131074, 8, 983063, 131074, 9, 393240, 196610, 0, 458776, 196610, 1, 524312, 196610, 2, 589848, 196610, 3, 655384, 196610, 4, 720920, 196610, 5, 786456, 196610, 6, 851992, 196610, 7, 917528, 196610, 8, 983064, 196610, 9, 393241, 262146, 0, 458777, 262146, 1, 524313, 262146, 2, 589849, 262146, 3, 655385, 262146, 4, 720921, 262146, 5, 786457, 262146, 6, 851993, 262146, 7, 917529, 262146, 8, 983065, 262146, 9, 393242, 327682, 0, 458778, 327682, 1, 524314, 327682, 2, 589850, 327682, 3, 655386, 327682, 4, 720922, 327682, 5, 786458, 327682, 6, 851994, 327682, 7, 917530, 327682, 8, 983066, 327682, 9, 393243, 393218, 0, 458779, 393218, 1, 524315, 393218, 2, 589851, 393218, 3, 655387, 393218, 4, 720923, 393218, 5, 786459, 393218, 6, 851995, 393218, 7, 917531, 393218, 8, 983067, 393218, 9, 393244, 458754, 0, 458780, 458754, 1, 524316, 458754, 2, 589852, 458754, 3, 655388, 458754, 4, 720924, 458754, 5, 786460, 458754, 6, 851996, 458754, 7, 917532, 458754, 8, 983068, 458754, 9, 393245, 524290, 0, 458781, 524290, 1, 524317, 524290, 2, 589853, 524290, 3, 655389, 524290, 4, 524318, 589826, 2, 1507340, 2, 2, 1572876, 2, 3, 1507341, 65538, 2, 1572877, 65538, 3, 1638413, 65538, 4, 1376270, 131074, 0, 1441806, 131074, 1, 1507342, 131074, 2, 1572878, 131074, 3, 1638414, 131074, 4, 1900558, 131074, 8, 1966094, 131074, 9, 1376271, 196610, 0, 1441807, 196610, 1, 1507343, 196610, 2, 1572879, 196610, 3, 1638415, 196610, 4, 1703951, 196610, 5, 1769487, 196610, 6, 1835023, 196610, 7, 1900559, 196610, 8, 1966095, 196610, 9, 1376272, 262146, 0, 1441808, 262146, 1, 1507344, 262146, 2, 1572880, 262146, 3, 1638416, 262146, 4, 1703952, 262146, 5, 1769488, 262146, 6, 1835024, 262146, 7, 1900560, 262146, 8, 1966096, 262146, 9, 1376273, 327682, 0, 1441809, 327682, 1, 1507345, 327682, 2, 1572881, 327682, 3, 1638417, 327682, 4, 1703953, 327682, 5, 1769489, 327682, 6, 1835025, 327682, 7, 1900561, 327682, 8, 1966097, 327682, 9, 1376274, 393218, 0, 1441810, 393218, 1, 1507346, 393218, 2, 1572882, 393218, 3, 1638418, 393218, 4, 1703954, 393218, 5, 1769490, 393218, 6, 1835026, 393218, 7, 1900562, 393218, 8, 1966098, 393218, 9, 1376275, 458754, 0, 1441811, 458754, 1, 1507347, 458754, 2, 1572883, 458754, 3, 1638419, 458754, 4, 1703955, 458754, 5, 1769491, 458754, 6, 1835027, 458754, 7, 1900563, 458754, 8, 1966099, 458754, 9, 1376276, 524290, 0, 1441812, 524290, 1, 1507348, 524290, 2, 1572884, 524290, 3, 1638420, 524290, 4, 1507349, 589826, 2, 1441829, 2, 2, 1507365, 2, 3, 1441830, 65538, 2, 1507366, 65538, 3, 1572902, 65538, 4, 1310759, 131074, 0, 1376295, 131074, 1, 1441831, 131074, 2, 1507367, 131074, 3, 1572903, 131074, 4, 1835047, 131074, 8, 1900583, 131074, 9, 1310760, 196610, 0, 1376296, 196610, 1, 1441832, 196610, 2, 1507368, 196610, 3, 1572904, 196610, 4, 1638440, 196610, 5, 1703976, 196610, 6, 1769512, 196610, 7, 1835048, 196610, 8, 1900584, 196610, 9, 1310761, 262146, 0, 1376297, 262146, 1, 1441833, 262146, 2, 1507369, 262146, 3, 1572905, 262146, 4, 1638441, 262146, 5, 1703977, 262146, 6, 1769513, 262146, 7, 1835049, 262146, 8, 1900585, 262146, 9, 1310762, 327682, 0, 1376298, 327682, 1, 1441834, 327682, 2, 1507370, 327682, 3, 1572906, 327682, 4, 1638442, 327682, 5, 1703978, 327682, 6, 1769514, 327682, 7, 1835050, 327682, 8, 1900586, 327682, 9, 1310763, 393218, 0, 1376299, 393218, 1, 1441835, 393218, 2, 1507371, 393218, 3, 1572907, 393218, 4, 1638443, 393218, 5, 1703979, 393218, 6, 1769515, 393218, 7, 1835051, 393218, 8, 1900587, 393218, 9, 1310764, 458754, 0, 1376300, 458754, 1, 1441836, 458754, 2, 1507372, 458754, 3, 1572908, 458754, 4, 1638444, 458754, 5, 1703980, 458754, 6, 1769516, 458754, 7, 1835052, 458754, 8, 1900588, 458754, 9, 1310765, 524290, 0, 1376301, 524290, 1, 1441837, 524290, 2, 1507373, 524290, 3, 1572909, 524290, 4, 1441838, 589826, 2) -[node name="test_player" parent="." instance=ExtResource("1_ff72w")] +[node name="Player" type="Sprite2D" parent="."] +position = Vector2(451, 276) +texture = ExtResource("5_b4su3") +script = ExtResource("6_wrfj3") + +[node name="battle_menu" parent="Player" instance=ExtResource("5_5qms1")] +offset_left = -64.0 +offset_top = 127.0 +offset_right = -64.0 +offset_bottom = 127.0 + +[node name="Combatant" parent="Player" node_paths=PackedStringArray("Actions") instance=ExtResource("8_81l0u")] +Actions = [NodePath("Actions/attack"), NodePath("Actions/spin_attack")] + +[node name="Actions" type="Node" parent="Player/Combatant"] + +[node name="attack" parent="Player/Combatant/Actions" instance=ExtResource("9_1kqn5")] +ActionName = "Attack" +ActionText = "Attack" + +[node name="spin_attack" parent="Player/Combatant/Actions" instance=ExtResource("10_nrdne")] +ActionName = "Spin Attack" +ActionText = "Spin Attack" diff --git a/Test Scenes/test_player.tscn b/Test Scenes/test_player.tscn deleted file mode 100644 index a9c78eb..0000000 --- a/Test Scenes/test_player.tscn +++ /dev/null @@ -1,41 +0,0 @@ -[gd_scene load_steps=8 format=3 uid="uid://cnnvxd4gefp4o"] - -[ext_resource type="PackedScene" uid="uid://ch1sc85jxy1r7" path="res://Systems/Combat/Combatant.tscn" id="1_701ur"] -[ext_resource type="Script" path="res://Test Scenes/test_player.gd" id="1_fstsi"] -[ext_resource type="Script" path="res://Systems/Combat/Scripts/combat_stats.gd" id="3_axh6y"] -[ext_resource type="PackedScene" uid="uid://bbbyup8pp6uam" path="res://Test Scenes/Test Player Actions/attack.tscn" id="3_ywlre"] -[ext_resource type="PackedScene" uid="uid://bmot4y61f1r8f" path="res://Test Scenes/Test Player Actions/spin_attack.tscn" id="4_sr4bi"] -[ext_resource type="PackedScene" uid="uid://cl5d768roh8ir" path="res://Systems/UI/battle_menu.tscn" id="5_2vin1"] - -[sub_resource type="Resource" id="Resource_l1ix6"] -script = ExtResource("3_axh6y") -MaxHP = 10 -MaxPhysicalStamina = 10 -MaxMentalStamina = 10 -Strength = 1 -Wisdom = 1 -Constitution = 1 -Willpower = 1 -Speed = 1 -Focus = 1 -Accuracy = 1 -Agility = 1 - -[node name="test_player" type="Node2D"] -script = ExtResource("1_fstsi") - -[node name="battle_menu" parent="." instance=ExtResource("5_2vin1")] - -[node name="Combatant" parent="." node_paths=PackedStringArray("Menu", "Actions") instance=ExtResource("1_701ur")] -Menu = NodePath("../battle_menu") -Stats = SubResource("Resource_l1ix6") -Actions = [NodePath("Actions/attack"), NodePath("Actions/spin_attack")] - -[node name="Actions" type="Node" parent="Combatant"] - -[node name="attack" parent="Combatant/Actions" instance=ExtResource("3_ywlre")] -ActionName = "Attack" -ActionText = "Attack" - -[node name="spin_attack" parent="Combatant/Actions" instance=ExtResource("4_sr4bi")] -ActionName = "Spin Attack"