Now the crafting window will show some text instead of looking broken when nothing is selected / the player has no recipes in the selected category.

This commit is contained in:
Relintai 2019-11-29 09:18:01 +01:00
parent 96a645a2dd
commit 824fd02d0f
3 changed files with 135 additions and 48 deletions

View File

@ -46,6 +46,7 @@ transform = Transform( -1, 0, -3.25841e-07, 0, 1, 0, 3.25841e-07, 0, -1, 0, 0, 0
[node name="Model" type="Spatial" parent="Rotation_Helper"] [node name="Model" type="Spatial" parent="Rotation_Helper"]
[node name="character" parent="Rotation_Helper/Model" instance=ExtResource( 1 )] [node name="character" parent="Rotation_Helper/Model" instance=ExtResource( 1 )]
refresh_in_editor = false
[node name="GUILayer" parent="." instance=ExtResource( 3 )] [node name="GUILayer" parent="." instance=ExtResource( 3 )]
[connection signal="onc_open_loot_winow_request" from="." to="GUILayer" method="_on_Player_onc_open_loot_winow_request"] [connection signal="onc_open_loot_winow_request" from="." to="GUILayer" method="_on_Player_onc_open_loot_winow_request"]

View File

@ -12,6 +12,11 @@ export(NodePath) var tools_container_path : NodePath
export(NodePath) var materials_container_path : NodePath export(NodePath) var materials_container_path : NodePath
export(NodePath) var recipe_selector_container_path : NodePath export(NodePath) var recipe_selector_container_path : NodePath
export(NodePath) var recipe_selector_main_on : NodePath
export(NodePath) var recipe_selector_main_off : NodePath
export(NodePath) var materials_container_main_on : NodePath
export(NodePath) var materials_container_main_off : NodePath
var _item_container : Node var _item_container : Node
var _tools_container : Node var _tools_container : Node
var _materials_container : Node var _materials_container : Node
@ -21,11 +26,21 @@ var _selected_craft_recipe : CraftRecipe
var _player : Entity var _player : Entity
var _recipe_selector_main_on : Node
var _recipe_selector_main_off : Node
var _materials_container_main_on : Node
var _materials_container_main_off : Node
func _ready(): func _ready():
_item_container = get_node(item_container_path) _item_container = get_node(item_container_path)
_tools_container = get_node(tools_container_path) _tools_container = get_node(tools_container_path)
_materials_container = get_node(materials_container_path) _materials_container = get_node(materials_container_path)
_recipe_selector_container = get_node(recipe_selector_container_path) _recipe_selector_container = get_node(recipe_selector_container_path)
_recipe_selector_main_on = get_node(recipe_selector_main_on)
_recipe_selector_main_off = get_node(recipe_selector_main_off)
_materials_container_main_on = get_node(materials_container_main_on)
_materials_container_main_off = get_node(materials_container_main_off)
func set_player(entity: Entity) -> void: func set_player(entity: Entity) -> void:
_player = entity _player = entity
@ -36,6 +51,7 @@ func set_category(category: int) -> void:
for ch in _recipe_selector_container.get_children(): for ch in _recipe_selector_container.get_children():
ch.queue_free() ch.queue_free()
var count : int = 0
for i in range(_player.gets_craft_recipe_count()): for i in range(_player.gets_craft_recipe_count()):
var cr : CraftRecipe = _player.gets_craft_recipe(i) var cr : CraftRecipe = _player.gets_craft_recipe(i)
@ -46,6 +62,15 @@ func set_category(category: int) -> void:
rss.set_recipe(cr, self) rss.set_recipe(cr, self)
count += 1
if count == 0:
_recipe_selector_main_on.visible = false
_recipe_selector_main_off.visible = true
else:
_recipe_selector_main_on.visible = true
_recipe_selector_main_off.visible = false
func request_craft() -> void: func request_craft() -> void:
_player.crequest_craft(_selected_craft_recipe.id) _player.crequest_craft(_selected_craft_recipe.id)
@ -59,6 +84,15 @@ func request_craft() -> void:
func select_recipe(recipe : CraftRecipe) -> void: func select_recipe(recipe : CraftRecipe) -> void:
_selected_craft_recipe = recipe _selected_craft_recipe = recipe
if _selected_craft_recipe == null:
_materials_container_main_on.visible = false
_materials_container_main_off.visible = true
return
else:
_materials_container_main_on.visible = true
_materials_container_main_off.visible = false
_item_container.set_item(recipe.item) _item_container.set_item(recipe.item)
for ch in _tools_container.get_children(): for ch in _tools_container.get_children():

View File

@ -18,10 +18,14 @@ __meta__ = {
} }
item_entry_scene = ExtResource( 4 ) item_entry_scene = ExtResource( 4 )
recipe_selector_scene = ExtResource( 3 ) recipe_selector_scene = ExtResource( 3 )
item_container_path = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription") item_container_path = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription")
tools_container_path = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2/ToolsContainer") tools_container_path = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2/ToolsContainer")
materials_container_path = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2/MaterialContainer") materials_container_path = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2/MaterialContainer")
recipe_selector_container_path = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/Recipes/VBoxContainer") recipe_selector_container_path = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer2/Recipes/VBoxContainer")
recipe_selector_main_on = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer2/Recipes")
recipe_selector_main_off = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer2/CenterContainer2")
materials_container_main_on = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry")
materials_container_main_off = NodePath("VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CenterContainer")
[node name="VBoxContainer" type="VBoxContainer" parent="."] [node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_left = 4.0 margin_left = 4.0
@ -128,28 +132,37 @@ margin_bottom = 520.0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
[node name="CraftEntry" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer"] [node name="PanelContainer" type="PanelContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer"]
margin_right = 607.0 margin_right = 674.0
margin_bottom = 520.0 margin_bottom = 520.0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
[node name="CraftEntry" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer"]
visible = false
margin_left = 4.0
margin_top = 4.0
margin_right = 718.0
margin_bottom = 516.0
size_flags_horizontal = 3
size_flags_vertical = 3
size_flags_stretch_ratio = 0.6 size_flags_stretch_ratio = 0.6
custom_constants/separation = 10 custom_constants/separation = 10
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry"] [node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry"]
margin_right = 607.0 margin_right = 714.0
margin_bottom = 480.0 margin_bottom = 472.0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
scroll_horizontal_enabled = false scroll_horizontal_enabled = false
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer"] [node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer"]
margin_right = 607.0 margin_right = 714.0
margin_bottom = 122.0 margin_bottom = 122.0
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="CraftItemDescription" type="HBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2"] [node name="CraftItemDescription" type="HBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2"]
margin_right = 607.0 margin_right = 714.0
margin_bottom = 60.0 margin_bottom = 60.0
alignment = 1 alignment = 1
script = ExtResource( 5 ) script = ExtResource( 5 )
@ -157,40 +170,40 @@ icon_path = NodePath("VBoxContainer/PanelContainer/TextureRect")
name_label_path = NodePath("PanelContainer2/VBoxContainer/Label") name_label_path = NodePath("PanelContainer2/VBoxContainer/Label")
description_label_path = NodePath("PanelContainer2/VBoxContainer/RichTextLabel") description_label_path = NodePath("PanelContainer2/VBoxContainer/RichTextLabel")
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription"] [node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription"]
margin_left = 121.0 margin_left = 175.0
margin_right = 181.0 margin_right = 235.0
margin_bottom = 60.0 margin_bottom = 60.0
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription/VBoxContainer"] [node name="PanelContainer" type="PanelContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription/VBoxContainer"]
margin_right = 60.0 margin_right = 60.0
margin_bottom = 60.0 margin_bottom = 60.0
rect_min_size = Vector2( 60, 60 ) rect_min_size = Vector2( 60, 60 )
[node name="TextureRect" type="TextureRect" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription/VBoxContainer/PanelContainer"] [node name="TextureRect" type="TextureRect" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription/VBoxContainer/PanelContainer"]
margin_left = 4.0 margin_left = 4.0
margin_top = 4.0 margin_top = 4.0
margin_right = 56.0 margin_right = 56.0
margin_bottom = 56.0 margin_bottom = 56.0
expand = true expand = true
[node name="PanelContainer2" type="PanelContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription"] [node name="PanelContainer2" type="PanelContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription"]
margin_left = 185.0 margin_left = 239.0
margin_right = 485.0 margin_right = 539.0
margin_bottom = 60.0 margin_bottom = 60.0
rect_min_size = Vector2( 300, 0 ) rect_min_size = Vector2( 300, 0 )
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription/PanelContainer2"] [node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription/PanelContainer2"]
margin_left = 4.0 margin_left = 4.0
margin_top = 4.0 margin_top = 4.0
margin_right = 296.0 margin_right = 296.0
margin_bottom = 56.0 margin_bottom = 56.0
[node name="Label" type="Label" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription/PanelContainer2/VBoxContainer"] [node name="Label" type="Label" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription/PanelContainer2/VBoxContainer"]
margin_right = 292.0 margin_right = 292.0
margin_bottom = 15.0 margin_bottom = 15.0
[node name="RichTextLabel" type="RichTextLabel" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription/PanelContainer2/VBoxContainer"] [node name="RichTextLabel" type="RichTextLabel" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2/CraftItemDescription/PanelContainer2/VBoxContainer"]
margin_top = 23.0 margin_top = 23.0
margin_right = 292.0 margin_right = 292.0
margin_bottom = 52.0 margin_bottom = 52.0
@ -199,56 +212,95 @@ text = "
" "
scroll_active = false scroll_active = false
[node name="Label2" type="Label" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2"] [node name="Label2" type="Label" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2"]
margin_top = 68.0 margin_top = 68.0
margin_right = 607.0 margin_right = 714.0
margin_bottom = 83.0 margin_bottom = 83.0
text = "Tools" text = "Tools"
[node name="ToolsContainer" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2"] [node name="ToolsContainer" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2"]
margin_top = 91.0 margin_top = 91.0
margin_right = 607.0 margin_right = 714.0
margin_bottom = 91.0 margin_bottom = 91.0
[node name="Label" type="Label" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2"] [node name="Label" type="Label" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2"]
margin_top = 99.0 margin_top = 99.0
margin_right = 607.0 margin_right = 714.0
margin_bottom = 114.0 margin_bottom = 114.0
text = "Materials" text = "Materials"
[node name="MaterialContainer" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/ScrollContainer/VBoxContainer2"] [node name="MaterialContainer" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/ScrollContainer/VBoxContainer2"]
margin_top = 122.0 margin_top = 122.0
margin_right = 607.0 margin_right = 714.0
margin_bottom = 122.0 margin_bottom = 122.0
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry"] [node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry"]
margin_top = 490.0 margin_top = 482.0
margin_right = 607.0 margin_right = 714.0
margin_bottom = 520.0 margin_bottom = 512.0
alignment = 1 alignment = 1
[node name="CraftButton" type="Button" parent="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/HBoxContainer"] [node name="CraftButton" type="Button" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/HBoxContainer"]
margin_left = 253.0 margin_left = 307.0
margin_right = 353.0 margin_right = 407.0
margin_bottom = 30.0 margin_bottom = 30.0
rect_min_size = Vector2( 100, 30 ) rect_min_size = Vector2( 100, 30 )
text = "Craft" text = "Craft"
[node name="Recipes" type="ScrollContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer"] [node name="CenterContainer" type="CenterContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer"]
margin_left = 611.0 margin_left = 4.0
margin_top = 4.0
margin_right = 670.0
margin_bottom = 516.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Label" type="Label" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CenterContainer"]
margin_left = 288.0
margin_top = 248.0
margin_right = 378.0
margin_bottom = 263.0
text = "Select a recipe"
align = 1
valign = 1
[node name="PanelContainer2" type="PanelContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer"]
margin_left = 678.0
margin_right = 1016.0 margin_right = 1016.0
margin_bottom = 520.0 margin_bottom = 520.0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
size_flags_stretch_ratio = 0.4 size_flags_stretch_ratio = 0.5
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/Recipes"] [node name="Recipes" type="ScrollContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer2"]
margin_right = 405.0 visible = false
margin_bottom = 40.0 margin_left = 4.0
margin_top = 4.0
margin_right = 286.0
margin_bottom = 516.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer2/Recipes"]
margin_right = 282.0
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="Button" parent="VBoxContainer/VBoxContainer/HBoxContainer/Recipes/VBoxContainer" instance=ExtResource( 3 )] [node name="CenterContainer2" type="CenterContainer" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer2"]
margin_right = 405.0 margin_left = 4.0
margin_top = 4.0
margin_right = 334.0
margin_bottom = 516.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Label" type="Label" parent="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer2/CenterContainer2"]
margin_left = 135.0
margin_top = 248.0
margin_right = 195.0
margin_bottom = 263.0
text = "No recipes"
align = 1
valign = 1
[connection signal="pressed" from="VBoxContainer/Header/Button" to="." method="hide"] [connection signal="pressed" from="VBoxContainer/Header/Button" to="." method="hide"]
[connection signal="pressed" from="VBoxContainer/Categories/HBoxContainer2/Alchemy" to="." method="set_category" binds= [ 1 ]] [connection signal="pressed" from="VBoxContainer/Categories/HBoxContainer2/Alchemy" to="." method="set_category" binds= [ 1 ]]
[connection signal="pressed" from="VBoxContainer/Categories/HBoxContainer2/Smithing" to="." method="set_category" binds= [ 2 ]] [connection signal="pressed" from="VBoxContainer/Categories/HBoxContainer2/Smithing" to="." method="set_category" binds= [ 2 ]]
@ -256,4 +308,4 @@ margin_right = 405.0
[connection signal="pressed" from="VBoxContainer/Categories/HBoxContainer2/Engineering" to="." method="set_category" binds= [ 5 ]] [connection signal="pressed" from="VBoxContainer/Categories/HBoxContainer2/Engineering" to="." method="set_category" binds= [ 5 ]]
[connection signal="pressed" from="VBoxContainer/Categories/HBoxContainer2/Tailoring" to="." method="set_category" binds= [ 3 ]] [connection signal="pressed" from="VBoxContainer/Categories/HBoxContainer2/Tailoring" to="." method="set_category" binds= [ 3 ]]
[connection signal="pressed" from="VBoxContainer/Categories/HBoxContainer2/Other" to="." method="set_category" binds= [ 0 ]] [connection signal="pressed" from="VBoxContainer/Categories/HBoxContainer2/Other" to="." method="set_category" binds= [ 0 ]]
[connection signal="pressed" from="VBoxContainer/VBoxContainer/HBoxContainer/CraftEntry/HBoxContainer/CraftButton" to="." method="request_craft"] [connection signal="pressed" from="VBoxContainer/VBoxContainer/HBoxContainer/PanelContainer/CraftEntry/HBoxContainer/CraftButton" to="." method="request_craft"]