Now closing windows will properly reset their opener toggles.

This commit is contained in:
Relintai 2020-07-27 22:52:58 +02:00
parent 58ce8bb9d6
commit a3bfaf9e2a
6 changed files with 88 additions and 28 deletions

View File

@ -20,6 +20,9 @@ extends PanelContainer
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
export(NodePath) var opener_button_path : NodePath
var opener_button : BaseButton
export(PackedScene) var inventory_item_scene : PackedScene
export(NodePath) var inventory_item_container_path : NodePath
export(NodePath) var item_tooltip_path : NodePath
@ -33,6 +36,8 @@ var _player : Entity = null
var _bag : Bag = null
func _ready() -> void:
opener_button = get_node_or_null(opener_button_path) as BaseButton
_inventory_item_container = get_node(inventory_item_container_path)
_tooltip = get_node(item_tooltip_path)
@ -122,12 +127,21 @@ func item_removed(bag: Bag, item: ItemInstance, slot_id: int) -> void:
func item_swapped(bag: Bag, item1_slot : int, item2_slot: int) -> void:
refresh_bags()
func on_visibility_changed() -> void:
func on_visibility_changed():
refresh_bags()
if opener_button:
if visible && !opener_button.pressed:
opener_button.pressed = true
return
if !visible && opener_button.pressed:
opener_button.pressed = false
func _on_BagButton_toggled(button_pressed):
if button_pressed:
show()
if !visible:
show()
else:
hide()
if visible:
hide()

View File

@ -275,7 +275,6 @@ keep_pressed_outside = true
text = "Talent"
[node name="CraftingButton" type="Button" parent="GUI/Buttons/HBoxContainer"]
visible = false
margin_left = 181.0
margin_right = 226.0
margin_bottom = 45.0
@ -288,8 +287,8 @@ keep_pressed_outside = true
text = "Craft"
[node name="LockButton" type="Button" parent="GUI/Buttons/HBoxContainer"]
margin_left = 181.0
margin_right = 226.0
margin_left = 226.0
margin_right = 271.0
margin_bottom = 45.0
rect_min_size = Vector2( 45, 45 )
focus_mode = 0
@ -331,8 +330,8 @@ __meta__ = {
}
[node name="Menu" type="Button" parent="GUI/Buttons/HBoxContainer"]
margin_left = 226.0
margin_right = 271.0
margin_left = 271.0
margin_right = 316.0
margin_bottom = 45.0
rect_min_size = Vector2( 45, 45 )
focus_mode = 0
@ -365,12 +364,14 @@ margin_left = 66.0
margin_top = 44.0
margin_right = 681.0
margin_bottom = 474.0
opener_button_path = NodePath("../../Buttons/HBoxContainer/CharacterButton")
[node name="SpellBookWindow" parent="GUI/Windows" instance=ExtResource( 17 )]
visible = false
margin_left = 60.0
margin_top = 50.0
margin_right = 561.0
opener_button_path = NodePath("../../Buttons/HBoxContainer/SpellBookButton")
[node name="TalentWindow" parent="GUI/Windows" instance=ExtResource( 11 )]
visible = false
@ -380,6 +381,7 @@ margin_left = 62.0
margin_top = 54.0
margin_right = 656.0
margin_bottom = 513.0
opener_button_path = NodePath("../../Buttons/HBoxContainer/TalentButton")
[node name="CraftingWindow" parent="GUI/Windows" instance=ExtResource( 20 )]
visible = false
@ -387,6 +389,7 @@ margin_left = 31.0
margin_top = 23.0
margin_right = -345.0
margin_bottom = -67.0
opener_button_path = NodePath("../../Buttons/HBoxContainer/CraftingButton")
[node name="Inventory" parent="GUI/Windows" instance=ExtResource( 15 )]
visible = false
@ -394,6 +397,7 @@ margin_left = 56.0
margin_top = 69.0
margin_right = -422.0
margin_bottom = -109.0
opener_button_path = NodePath("../../Buttons/HBoxContainer/BagButton")
inventory_item_container_path = NodePath("../Inventory/VBoxContainer/HBoxContainer3/PanelContainer2/VBoxContainer/ScrollContainer/GridContainer")
[node name="LootWindow" parent="GUI/Windows" instance=ExtResource( 19 )]

View File

@ -1,19 +1,10 @@
extends PanelContainer
export(NodePath) var opener_button_path : NodePath
var opener_button : BaseButton
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
opener_button = get_node_or_null(opener_button_path) as BaseButton
func _on_CharacterButton_toggled(button_pressed):
@ -24,4 +15,7 @@ func _on_CharacterButton_toggled(button_pressed):
func _on_Button_pressed():
if opener_button:
opener_button.pressed = false
hide()

View File

@ -20,6 +20,9 @@ extends PanelContainer
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
export(NodePath) var opener_button_path : NodePath
var opener_button : BaseButton
export(PackedScene) var item_entry_scene : PackedScene
export(PackedScene) var recipe_selector_scene : PackedScene
@ -48,6 +51,9 @@ var _materials_container_main_on : Node
var _materials_container_main_off : Node
func _ready():
opener_button = get_node_or_null(opener_button_path) as BaseButton
connect("visibility_changed", self, "on_visibility_changed")
_item_container = get_node(item_container_path)
_tools_container = get_node(tools_container_path)
_materials_container = get_node(materials_container_path)
@ -140,8 +146,19 @@ func select_recipe(recipe : CraftRecipe) -> void:
ie.set_item(_player, ih)
func on_visibility_changed():
if opener_button:
if visible && !opener_button.pressed:
opener_button.pressed = true
return
if !visible && opener_button.pressed:
opener_button.pressed = false
func _on_CraftingButton_toggled(button_pressed):
if button_pressed:
show()
if !visible:
show()
else:
hide()
if visible:
hide()

View File

@ -20,6 +20,9 @@ extends Control
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
export(NodePath) var opener_button_path : NodePath
var opener_button : BaseButton
export(NodePath) var spell_entry_container_path : NodePath
export(NodePath) var prev_button_path : NodePath
export(NodePath) var next_button_path : NodePath
@ -45,6 +48,9 @@ var _character_class : EntityClassData
var _spells : Array
func _ready() -> void:
opener_button = get_node_or_null(opener_button_path) as BaseButton
connect("visibility_changed", self, "on_visibility_changed")
_spell_entries.clear()
_spell_entry_container = get_node(spell_entry_container_path)
@ -191,9 +197,19 @@ class CustomSpellSorter:
return true
func on_visibility_changed():
if opener_button:
if visible && !opener_button.pressed:
opener_button.pressed = true
return
if !visible && opener_button.pressed:
opener_button.pressed = false
func _on_SpellBookButton_toggled(button_pressed):
if button_pressed:
show()
if !visible:
show()
else:
hide()
if visible:
hide()

View File

@ -20,6 +20,9 @@ extends PanelContainer
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
export(NodePath) var opener_button_path : NodePath
var opener_button : BaseButton
export(PackedScene) var spec_scene : PackedScene
export(PackedScene) var spec_switcher_scene : PackedScene
export(NodePath) var spec_container_path : NodePath
@ -32,6 +35,9 @@ var _data : EntityData
var _player : Entity
func _ready():
opener_button = get_node_or_null(opener_button_path) as BaseButton
connect("visibility_changed", self, "on_visibility_changed")
_spec_container = get_node(spec_container_path)
_spec_switcher_container = get_node(spec_switcher_path)
@ -96,10 +102,19 @@ func centity_data_changed(data: EntityData) -> void:
s.set_spec(_player, spec, i)
func on_visibility_changed():
if opener_button:
if visible && !opener_button.pressed:
opener_button.pressed = true
return
if !visible && opener_button.pressed:
opener_button.pressed = false
func _on_TalentButton_toggled(button_pressed):
if button_pressed:
show()
if !visible:
show()
else:
hide()
if visible:
hide()