The loot window is now also a module.

This commit is contained in:
Relintai 2020-09-24 16:54:10 +02:00
parent 91656e1060
commit ed417cf2c1
11 changed files with 56 additions and 42 deletions

View File

@ -1,19 +1,22 @@
extends GameModule
class_name UIWindowModule
export(PackedScene) var character_scene : PackedScene
export(PackedScene) var scene : PackedScene
export(Texture) var opener_button_texture : Texture
export(int) var index : int = -1
export(bool) var add_button : bool = true
func on_request_instance(what : int, node : Node) -> void:
if what == DataManager.PLAYER_UI_INSTANCE:
var sc = character_scene.instance()
var sc = scene.instance()
node.windows.add_child(sc)
var b = node.buttons.add_image_button(opener_button_texture, 0)
b.connect("toggled", sc, "_on_button_toggled")
sc.opener_button = b
if add_button:
var b = node.buttons.add_image_button(opener_button_texture, 0)
b.connect("toggled", sc, "_on_button_toggled")
sc.opener_button = b
sc.hide()

View File

@ -7,6 +7,7 @@
[resource]
script = ExtResource( 2 )
enabled = true
character_scene = ExtResource( 3 )
scene = ExtResource( 3 )
opener_button_texture = ExtResource( 1 )
index = 3
add_button = true

View File

@ -7,6 +7,7 @@
[resource]
script = ExtResource( 1 )
enabled = true
character_scene = ExtResource( 2 )
scene = ExtResource( 2 )
opener_button_texture = ExtResource( 3 )
index = 0
add_button = true

View File

@ -7,6 +7,7 @@
[resource]
script = ExtResource( 2 )
enabled = true
character_scene = ExtResource( 3 )
scene = ExtResource( 3 )
opener_button_texture = ExtResource( 1 )
index = 4
add_button = true

View File

@ -29,6 +29,8 @@ var player : Entity
var target_bag : Bag
func _ready():
get_node("../../../").loot_window = self
container = get_node(container_path)
connect("visibility_changed", self, "on_visibility_changed")

View File

@ -4,7 +4,7 @@
[ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=2]
[ext_resource path="res://ui/loot_window/LootEntry.tscn" type="PackedScene" id=3]
[node name="LootWindow" type="PanelContainer"]
[node name="LootWindow" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
@ -14,37 +14,43 @@ __meta__ = {
"_edit_use_anchors_": false
}
entry_scene = ExtResource( 3 )
container_path = NodePath("VBoxContainer/ScrollContainer/container")
container_path = NodePath("PanelContainer/VBoxContainer/ScrollContainer/container")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
[node name="PanelContainer" type="PanelContainer" parent="."]
margin_left = 82.0
margin_top = 83.0
margin_right = 299.0
margin_bottom = 359.0
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
margin_left = 4.0
margin_top = 4.0
margin_right = 1020.0
margin_bottom = 596.0
margin_right = 213.0
margin_bottom = 272.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Label" type="Label" parent="VBoxContainer"]
margin_right = 1016.0
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer"]
margin_right = 209.0
margin_bottom = 15.0
text = "Loot"
align = 1
valign = 1
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/VBoxContainer"]
margin_top = 23.0
margin_right = 1016.0
margin_bottom = 558.0
margin_right = 209.0
margin_bottom = 234.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="container" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
margin_right = 1016.0
[node name="container" type="VBoxContainer" parent="PanelContainer/VBoxContainer/ScrollContainer"]
margin_right = 209.0
size_flags_horizontal = 3
[node name="Button" type="Button" parent="VBoxContainer"]
margin_top = 566.0
margin_right = 1016.0
margin_bottom = 592.57
[node name="Button" type="Button" parent="PanelContainer/VBoxContainer"]
margin_top = 242.0
margin_right = 209.0
margin_bottom = 268.57
text = "close"
[connection signal="pressed" from="VBoxContainer/Button" to="." method="hide"]
[connection signal="pressed" from="PanelContainer/VBoxContainer/Button" to="." method="hide"]

View File

@ -0,0 +1,11 @@
[gd_resource type="Resource" load_steps=3 format=2]
[ext_resource path="res://scripts/game_modules/ui_window_module.gd" type="Script" id=2]
[ext_resource path="res://ui/loot_window/LootWindow.tscn" type="PackedScene" id=3]
[resource]
script = ExtResource( 2 )
enabled = true
scene = ExtResource( 3 )
index = -1
add_button = false

View File

@ -31,7 +31,6 @@ var gui_base : Node
var buttons : Node
var windows : Node
export(NodePath) var loot_window_path : NodePath
var loot_window : Control
func _ready():
@ -52,8 +51,7 @@ func initialize():
gui_base = get_node(gui_base_path)
buttons = get_node(buttons_path)
windows = get_node(windows_path)
loot_window = get_node(loot_window_path) as Control
func _on_Player_onc_open_loot_winow_request() -> void:
if loot_window != null:

View File

@ -1,11 +1,10 @@
[gd_scene load_steps=13 format=2]
[gd_scene load_steps=12 format=2]
[ext_resource path="res://player/GUI.gd" type="Script" id=1]
[ext_resource path="res://ui/ingame_menu/IngameMenu.tscn" type="PackedScene" id=2]
[ext_resource path="res://ui/theme/menu_icon.tres" type="Texture" id=6]
[ext_resource path="res://ui/buttons/Buttons.gd" type="Script" id=9]
[ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=10]
[ext_resource path="res://ui/loot_window/LootWindow.tscn" type="PackedScene" id=19]
[ext_resource path="res://ui/theme/locked_icon.tres" type="Texture" id=25]
[ext_resource path="res://ui/theme/unlocked_icon.tres" type="Texture" id=26]
[ext_resource path="res://ui/player_ui/player_ui.gd" type="Script" id=28]
@ -18,7 +17,6 @@ script = ExtResource( 28 )
gui_base_path = NodePath("GUI")
buttons_path = NodePath("GUI/Buttons")
windows_path = NodePath("GUI/Windows")
loot_window_path = NodePath("GUI/Windows/LootWindow")
[node name="GUI" type="Control" parent="."]
anchor_right = 1.0
@ -98,15 +96,6 @@ __meta__ = {
[node name="Windows" type="CanvasLayer" parent="GUI"]
layer = 2
[node name="LootWindow" parent="GUI/Windows" instance=ExtResource( 19 )]
visible = false
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 39.0
margin_top = 85.0
margin_right = 242.0
margin_bottom = 315.0
[node name="TrainerWindow" parent="GUI/Windows" instance=ExtResource( 31 )]
visible = false
anchor_right = 0.0

View File

@ -7,6 +7,7 @@
[resource]
script = ExtResource( 3 )
enabled = true
character_scene = ExtResource( 2 )
scene = ExtResource( 2 )
opener_button_texture = ExtResource( 1 )
index = 1
add_button = true

View File

@ -7,6 +7,7 @@
[resource]
script = ExtResource( 2 )
enabled = true
character_scene = ExtResource( 3 )
scene = ExtResource( 3 )
opener_button_texture = ExtResource( 1 )
index = 2
add_button = true