From cddda7d5e2b5a4205bf9b51b7c9cabc5de1be9c0 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 12 Sep 2020 23:23:54 +0200 Subject: [PATCH] Added interface options to the ingame menu. These are the character specific. Added an option to save a character's actionbars as the default. --- game/ui/ingame_menu/IngameMenu.tscn | 32 ++++++++++--- game/ui/interface/InterfaceOptions.gd | 6 +++ game/ui/interface/InterfaceOptions.tscn | 52 ++++++++++++++++++++++ game/ui/interface/SetActionbarAsDefault.gd | 16 +++++++ game/ui/options/Options.tscn | 1 + game/ui/player_ui/player_ui.tscn | 2 +- 6 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 game/ui/interface/InterfaceOptions.gd create mode 100644 game/ui/interface/InterfaceOptions.tscn create mode 100644 game/ui/interface/SetActionbarAsDefault.gd diff --git a/game/ui/ingame_menu/IngameMenu.tscn b/game/ui/ingame_menu/IngameMenu.tscn index 94067236..45ea6e43 100644 --- a/game/ui/ingame_menu/IngameMenu.tscn +++ b/game/ui/ingame_menu/IngameMenu.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=1] [ext_resource path="res://ui/options/Options.tscn" type="PackedScene" id=2] [ext_resource path="res://ui/ingame_menu/ExitButton.gd" type="Script" id=3] [ext_resource path="res://ui/keybinds/Keybinds.tscn" type="PackedScene" id=4] +[ext_resource path="res://ui/interface/InterfaceOptions.tscn" type="PackedScene" id=5] [node name="IngameMenu" type="Control"] anchor_right = 1.0 @@ -31,7 +32,7 @@ __meta__ = { margin_left = 4.0 margin_top = 4.0 margin_right = 151.0 -margin_bottom = 132.0 +margin_bottom = 166.0 [node name="Resume" type="Button" parent="Menu/VBoxContainer"] margin_right = 147.0 @@ -44,16 +45,25 @@ margin_right = 147.0 margin_bottom = 60.5702 text = "Keybinds" -[node name="Options" type="Button" parent="Menu/VBoxContainer"] +[node name="Interface" type="Button" parent="Menu/VBoxContainer"] margin_top = 68.0 margin_right = 147.0 margin_bottom = 94.5702 -text = "Options" +text = "Interface" +__meta__ = { +"_edit_use_anchors_": false +} -[node name="Exit" type="Button" parent="Menu/VBoxContainer"] +[node name="Options" type="Button" parent="Menu/VBoxContainer"] margin_top = 102.0 margin_right = 147.0 margin_bottom = 128.57 +text = "Options" + +[node name="Exit" type="Button" parent="Menu/VBoxContainer"] +margin_top = 136.0 +margin_right = 147.0 +margin_bottom = 162.57 text = "Exit" script = ExtResource( 3 ) @@ -78,6 +88,18 @@ margin_left = -426.0 margin_top = -270.0 margin_right = 426.0 margin_bottom = 270.0 + +[node name="InterfaceOptions" parent="." instance=ExtResource( 5 )] +visible = false +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -331.0 +margin_top = -224.5 +margin_right = 331.0 +margin_bottom = 224.5 [connection signal="pressed" from="Menu/VBoxContainer/Resume" to="." method="hide"] [connection signal="pressed" from="Menu/VBoxContainer/Keybinds" to="KeybindWindow" method="show"] +[connection signal="pressed" from="Menu/VBoxContainer/Interface" to="InterfaceOptions" method="show"] [connection signal="pressed" from="Menu/VBoxContainer/Options" to="Options" method="show"] diff --git a/game/ui/interface/InterfaceOptions.gd b/game/ui/interface/InterfaceOptions.gd new file mode 100644 index 00000000..1ecf6d1a --- /dev/null +++ b/game/ui/interface/InterfaceOptions.gd @@ -0,0 +1,6 @@ +extends PanelContainer + +export(NodePath) var actionbar_set_default_button_path : NodePath + +func set_player(p_player: Entity) -> void: + get_node(actionbar_set_default_button_path).set_player(p_player) diff --git a/game/ui/interface/InterfaceOptions.tscn b/game/ui/interface/InterfaceOptions.tscn new file mode 100644 index 00000000..e4a20f3b --- /dev/null +++ b/game/ui/interface/InterfaceOptions.tscn @@ -0,0 +1,52 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://ui/interface/SetActionbarAsDefault.gd" type="Script" id=1] +[ext_resource path="res://ui/interface/InterfaceOptions.gd" type="Script" id=2] + +[node name="InterfaceOptions" type="PanelContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} +actionbar_set_default_button_path = NodePath("VBoxContainer2/VBoxContainer/SetActionbarAsDefault") + +[node name="VBoxContainer2" type="VBoxContainer" parent="."] +margin_left = 7.0 +margin_top = 7.0 +margin_right = 1017.0 +margin_bottom = 593.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer2"] +margin_right = 1010.0 +margin_bottom = 30.0 +size_flags_horizontal = 3 + +[node name="Label" type="Label" parent="VBoxContainer2/HBoxContainer"] +margin_top = 8.0 +margin_right = 966.0 +margin_bottom = 22.0 +size_flags_horizontal = 3 +text = "Interface options" + +[node name="Button" type="Button" parent="VBoxContainer2/HBoxContainer"] +margin_left = 970.0 +margin_right = 1010.0 +margin_bottom = 30.0 +rect_min_size = Vector2( 40, 30 ) +text = "X" + +[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer2"] +margin_top = 34.0 +margin_right = 1010.0 +margin_bottom = 586.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="SetActionbarAsDefault" type="Button" parent="VBoxContainer2/VBoxContainer"] +margin_right = 1010.0 +margin_bottom = 20.0 +text = "Set current actionbar setup as default" +script = ExtResource( 1 ) +[connection signal="pressed" from="VBoxContainer2/HBoxContainer/Button" to="." method="hide"] diff --git a/game/ui/interface/SetActionbarAsDefault.gd b/game/ui/interface/SetActionbarAsDefault.gd new file mode 100644 index 00000000..c2cdd079 --- /dev/null +++ b/game/ui/interface/SetActionbarAsDefault.gd @@ -0,0 +1,16 @@ +extends Button + +var _player : Entity + +func set_player(p_player: Entity) -> void: + _player = p_player + +func _pressed(): + if _player && is_instance_valid(_player): + var abp : ActionBarProfile = _player.get_action_bar_profile() + + var cp : ClassProfile = ProfileManager.getc_player_profile().get_class_profile(_player.gets_entity_data().get_path()) + + cp.get_default_action_bar_profile().from_actionbar_profile(abp) + + ProfileManager.save() diff --git a/game/ui/options/Options.tscn b/game/ui/options/Options.tscn index 373add1c..dd5f5085 100644 --- a/game/ui/options/Options.tscn +++ b/game/ui/options/Options.tscn @@ -44,6 +44,7 @@ size_flags_vertical = 3 tab_align = 0 [node name="Video" type="VBoxContainer" parent="PanelContainer/VBoxContainer/TabContainer"] +visible = false anchor_right = 1.0 anchor_bottom = 1.0 margin_left = 4.0 diff --git a/game/ui/player_ui/player_ui.tscn b/game/ui/player_ui/player_ui.tscn index b2d494da..869034a8 100644 --- a/game/ui/player_ui/player_ui.tscn +++ b/game/ui/player_ui/player_ui.tscn @@ -45,7 +45,7 @@ script = ExtResource( 1 ) __meta__ = { "_edit_lock_": true } -child_controls = [ NodePath("Unitframes"), NodePath("Actionbars"), NodePath("Windows/SpellBookWindow"), NodePath("Buttons"), NodePath("Castbar"), NodePath("AuraFrame"), NodePath("Windows/Inventory"), NodePath("Windows/LootWindow"), NodePath("Windows/TalentWindow"), NodePath("Windows/CraftingWindow"), NodePath("IngameMenu/KeybindWindow"), NodePath("Windows/CharacterWindow"), NodePath("Windows/TrainerWindow") ] +child_controls = [ NodePath("Unitframes"), NodePath("Actionbars"), NodePath("Windows/SpellBookWindow"), NodePath("Buttons"), NodePath("Castbar"), NodePath("AuraFrame"), NodePath("Windows/Inventory"), NodePath("Windows/LootWindow"), NodePath("Windows/TalentWindow"), NodePath("Windows/CraftingWindow"), NodePath("IngameMenu/KeybindWindow"), NodePath("Windows/CharacterWindow"), NodePath("Windows/TrainerWindow"), NodePath("IngameMenu/InterfaceOptions") ] [node name="TouchTargetControls" type="MarginContainer" parent="GUI"] visible = false