Skip to content

Commit

Permalink
feat: show kitchentools in inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
kth1888 committed Mar 4, 2024
1 parent 1728fde commit 1238866
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 9 deletions.
1 change: 1 addition & 0 deletions frontend/Savor-22b/scenes/farm.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,5 @@ anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0

[connection signal="button_down" from="MC/HC/VBoxContainer/MarginContainer/VBoxContainer/HomeButton" to="." method="_on_home_button_button_down"]
[connection signal="button_down" from="MC/HC/VBoxContainer/MarginContainer/VBoxContainer/RefreshButton" to="." method="_on_refresh_button_button_down"]
2 changes: 2 additions & 0 deletions frontend/Savor-22b/scenes/house/house.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ size_flags_vertical = 3
theme_override_constants/margin_left = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20

[connection signal="button_down" from="M/V/menus/V/InventoryButton" to="." method="_on_inventory_button_button_down"]
11 changes: 11 additions & 0 deletions frontend/Savor-22b/scenes/house/house_inventory.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends Control

const KITCHEN_TOOLS = preload("res://scenes/house/kitchentools.tscn")

@onready var panel = $M/V/Panel/C

func _ready():
var kitchens = KITCHEN_TOOLS.instantiate()

panel.add_child(kitchens)

7 changes: 5 additions & 2 deletions frontend/Savor-22b/scenes/house/house_inventory.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://dupiw5pjpvulw"]
[gd_scene load_steps=4 format=3 uid="uid://dupiw5pjpvulw"]

[ext_resource type="Script" path="res://scenes/house/house_inventory.gd" id="1_7w8e6"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dth2p"]
bg_color = Color(0, 0, 0, 1)
Expand All @@ -13,6 +15,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_7w8e6")

[node name="M" type="MarginContainer" parent="."]
layout_mode = 1
Expand Down Expand Up @@ -42,7 +45,7 @@ layout_mode = 2
size_flags_vertical = 3
theme_override_styles/panel = SubResource("StyleBoxFlat_50occ")

[node name="M" type="MarginContainer" parent="M/V/Panel"]
[node name="C" type="CenterContainer" parent="M/V/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
Expand Down
16 changes: 16 additions & 0 deletions frontend/Savor-22b/scenes/house/kitchentools.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends Control

const TOOL = preload("res://scenes/house/tool.tscn")

@onready var grid = $M/V/Items/G

var tools

func _ready():
tools = SceneContext.user_state.inventoryState["kitchenEquipmentStateList"]

for tool in tools:
var toolpanel = TOOL.instantiate()
toolpanel.set_info(tool)
grid.add_child(toolpanel)

16 changes: 15 additions & 1 deletion frontend/Savor-22b/scenes/house/kitchentools.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cwqquis7w31g7"]
[gd_scene load_steps=3 format=3 uid="uid://cwqquis7w31g7"]

[ext_resource type="Script" path="res://scenes/house/kitchentools.gd" id="1_bkji1"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_rk6tx"]
bg_color = Color(1, 0.541176, 0, 1)
Expand All @@ -8,8 +10,10 @@ layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_bottom = -357.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_bkji1")

[node name="M" type="MarginContainer" parent="."]
layout_mode = 1
Expand All @@ -21,12 +25,22 @@ grow_vertical = 2

[node name="V" type="VBoxContainer" parent="M"]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 8

[node name="Items" type="MarginContainer" parent="M/V"]
layout_mode = 2
theme_override_constants/margin_left = 50
theme_override_constants/margin_top = 50
theme_override_constants/margin_right = 50
theme_override_constants/margin_bottom = 50

[node name="G" type="GridContainer" parent="M/V/Items"]
custom_minimum_size = Vector2(1780, 500)
layout_mode = 2
theme_override_constants/h_separation = 50
theme_override_constants/v_separation = 50
columns = 5

[node name="Button" type="MarginContainer" parent="M/V"]
layout_mode = 2
Expand Down
21 changes: 21 additions & 0 deletions frontend/Savor-22b/scenes/house/tool.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extends Panel

@onready var toolname = $M/V/Name
@onready var tooldesc = $M/V/Desc

var info

func _ready():
_update_info()


func _update_info():
if toolname == null:
return

toolname.text = info.equipmentName
tooldesc.text = info.stateId

func set_info(info: Dictionary):
self.info = info

24 changes: 18 additions & 6 deletions frontend/Savor-22b/scenes/house/tool.tscn
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
[gd_scene load_steps=2 format=3 uid="uid://cjlj4mej5h001"]
[gd_scene load_steps=3 format=3 uid="uid://cjlj4mej5h001"]

[ext_resource type="Script" path="res://scenes/house/tool.gd" id="1_fsq81"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_x6mfd"]
bg_color = Color(1, 0.541176, 0, 1)

[node name="Tool" type="Panel"]
custom_minimum_size = Vector2(300, 200)
offset_right = 40.0
offset_bottom = 40.0
offset_right = 300.0
offset_bottom = 200.0
size_flags_horizontal = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_x6mfd")
script = ExtResource("1_fsq81")

[node name="M" type="MarginContainer" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -18.5
offset_bottom = 18.5
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 20
Expand All @@ -29,7 +38,10 @@ theme_override_font_sizes/font_size = 40
text = "조리도구 이름"

[node name="Desc" type="Label" parent="M/V"]
custom_minimum_size = Vector2(260, 132)
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 30
text = "조리도구 설명"
autowrap_mode = 1
max_lines_visible = 3
4 changes: 4 additions & 0 deletions frontend/Savor-22b/scripts/scenes/farm.gd
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,7 @@ func fetch_new():
func _on_refresh_button_button_down():
fetch_new()



func _on_home_button_button_down():
get_tree().change_scene_to_file("res://scenes/house/house.tscn")
10 changes: 10 additions & 0 deletions frontend/Savor-22b/scripts/scenes/house.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
extends Control

const HOUSE_INVENTORY = preload("res://scenes/house/house_inventory.tscn")

@onready var subscene = $M/V/subscene

func _ready():
pass # Replace with function body.




func _on_inventory_button_button_down():
var inventory = HOUSE_INVENTORY.instantiate()

subscene.add_child(inventory)

0 comments on commit 1238866

Please sign in to comment.