Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
feat: recipebook feature
Browse files Browse the repository at this point in the history
  • Loading branch information
kth1888 committed Mar 21, 2024
1 parent 84a4894 commit c5c94d3
Show file tree
Hide file tree
Showing 19 changed files with 878 additions and 119 deletions.
18 changes: 18 additions & 0 deletions frontend/Savor-22b/scenes/house/recipebook/ingredient.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
extends Control

@onready var button = $Ing
var ingname
var format_string = "[%s]"


func _ready():
update_info()




func set_ingname(name: String):
ingname = name

func update_info():
button.text = format_string % [ingname]
27 changes: 27 additions & 0 deletions frontend/Savor-22b/scenes/house/recipebook/ingredient.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[gd_scene load_steps=3 format=3 uid="uid://me2nvitswvki"]

[ext_resource type="Script" path="res://scenes/house/recipebook/ingredient.gd" id="1_g877k"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jup0i"]
bg_color = Color(0.94902, 0.596078, 0.0784314, 1)
corner_radius_top_left = 20
corner_radius_top_right = 20
corner_radius_bottom_right = 20
corner_radius_bottom_left = 20

[node name="ingredient" type="Control"]
custom_minimum_size = Vector2(180, 110)
layout_mode = 3
anchors_preset = 0
offset_right = 180.0
offset_bottom = 110.0
script = ExtResource("1_g877k")

[node name="Ing" type="Button" parent="."]
custom_minimum_size = Vector2(180, 110)
layout_mode = 0
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 25
theme_override_styles/normal = SubResource("StyleBoxFlat_jup0i")
text = "[춘장]
보유중"
54 changes: 20 additions & 34 deletions frontend/Savor-22b/scenes/house/recipebook/recipe.gd
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
extends Control

const ING_YES = preload("res://scenes/house/recipebook/ingredient_yes.tscn")
const ING_NO = preload("res://scenes/house/recipebook/ingredient_no.tscn")
const ING = preload("res://scenes/house/recipebook/ingredient.tscn")

@onready var ingredients = $panel/M/V/Description/Ingredients/list
@onready var tools = $panel/M/V/Description/Tools
@onready var reqblock = $panel/M/V/Blockreq

var info
var inventorylist

var name_format = "[%s] 레시피"

var name_format = "[%s] 레시피";
var block_format = "소요 블록 %s 블록"

func _ready():
update_info()
Expand All @@ -19,7 +21,6 @@ func set_info(recipe: Dictionary):
info = recipe

func update_info():
inventorylist = SceneContext.user_state["inventoryState"]

# Setting names in UI
var name = info.name
Expand All @@ -28,36 +29,21 @@ func update_info():

# Getting exist
for ing in info["ingredientIDList"]:
var created = false
for inving in inventorylist.refrigeratorStateList:
if ing["name"] == inving["name"]:
var ing_y = ING_YES.instantiate()
ing_y.set_ingname(ing["name"])
ingredients.add_child(ing_y)
created = true
break
var ing_ins = ING.instantiate()
ing_ins.set_ingname(ing["name"])
ingredients.add_child(ing_ins)

if(!created):
var ing_n = ING_NO.instantiate()
ing_n.set_ingname(ing["name"])
ingredients.add_child(ing_n)

for ing in info["foodIDList"]:
var created = false
# refrigeratorstatelist에 만들어진 음식이 없는 경우 수정 필요
for inving in inventorylist.refrigeratorStateList:
if ing["name"] == inving["name"]:
var ing_y = ING_YES.instantiate()
ing_y.set_ingname(ing["name"])
ingredients.add_child(ing_y)
created = true
break
var ing_ins = ING.instantiate()
ing_ins.set_ingname(ing["name"])
ingredients.add_child(ing_ins)

if(!created):
var ing_n = ING_NO.instantiate()
ing_n.set_ingname(ing["name"])
ingredients.add_child(ing_n)

for tool in info["requiredKitchenEquipmentCategoryList"]:
var tool_ins = ING.instantiate()
tool_ins.set_ingname(tool["name"])
tools.add_child(tool_ins)

set_block_req()

func insufficient():
$panel/M/V/Title/insufficient.visible = true
func set_block_req():
reqblock.text = block_format % [ info["requiredBlockCount"] ]
33 changes: 1 addition & 32 deletions frontend/Savor-22b/scenes/house/recipebook/recipe.tscn
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://bam215608gpdl"]
[gd_scene load_steps=3 format=3 uid="uid://bam215608gpdl"]

[ext_resource type="StyleBox" uid="uid://b2nqsuwp80vsg" path="res://scenes/house/recipebook/recipe_style_box_flat.tres" id="1_8ipq3"]
[ext_resource type="Script" path="res://scenes/house/recipebook/recipe.gd" id="2_jlc81"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jup0i"]
bg_color = Color(0.94902, 0.596078, 0.0784314, 1)
corner_radius_top_left = 20
corner_radius_top_right = 20
corner_radius_bottom_right = 20
corner_radius_bottom_left = 20

[node name="Recipe" type="Control"]
custom_minimum_size = Vector2(700, 550)
layout_direction = 1
Expand Down Expand Up @@ -48,12 +41,6 @@ layout_mode = 2
theme_override_font_sizes/font_size = 40
text = "[트러플 짜장면] 레시피"

[node name="insufficient" type="Label" parent="panel/M/V/Title"]
visible = false
layout_mode = 2
theme_override_font_sizes/font_size = 40
text = "(재료부족)"

[node name="Blockreq" type="Label" parent="panel/M/V"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 0.541176, 0, 1)
Expand All @@ -77,24 +64,6 @@ text = "[조리도구]"
layout_mode = 2
theme_override_constants/separation = 20

[node name="Availabletools" type="Button" parent="panel/M/V/Description/Tools"]
custom_minimum_size = Vector2(180, 110)
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 25
theme_override_styles/normal = SubResource("StyleBoxFlat_jup0i")
text = "[-- -]
사용 가능"

[node name="Availabletools2" type="Button" parent="panel/M/V/Description/Tools"]
custom_minimum_size = Vector2(180, 110)
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 25
theme_override_styles/normal = SubResource("StyleBoxFlat_jup0i")
text = "[-- -]
사용 가능"

[node name="T2" type="Label" parent="panel/M/V/Description"]
layout_mode = 2
theme_override_font_sizes/font_size = 35
Expand Down
50 changes: 5 additions & 45 deletions frontend/Savor-22b/scenes/house/recipebook/recipebook.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://cpx04yry0xj16"]
[gd_scene load_steps=4 format=3 uid="uid://cpx04yry0xj16"]

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

Expand All @@ -15,25 +15,13 @@ corner_radius_bottom_right = 50
corner_radius_bottom_left = 50
shadow_size = 5

[sub_resource type="FontVariation" id="FontVariation_eybux"]
variation_embolden = -0.3

[sub_resource type="SystemFont" id="SystemFont_ardk6"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ym4cf"]
bg_color = Color(0, 0, 0, 1)
corner_radius_top_left = 30
corner_radius_top_right = 30
corner_radius_bottom_right = 30
corner_radius_bottom_left = 30

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_rle7u"]
bg_color = Color(0, 0, 0, 1)
corner_radius_top_left = 15
corner_radius_top_right = 15
corner_radius_bottom_right = 15
corner_radius_bottom_left = 15

[node name="Recipebook" type="Control"]
custom_minimum_size = Vector2(1600, 900)
layout_mode = 3
Expand Down Expand Up @@ -72,31 +60,10 @@ layout_mode = 2
size_flags_horizontal = 4
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 70
text = "조리 가능한 레시피"

[node name="Description" type="HBoxContainer" parent="background/M/V"]
layout_mode = 2
size_flags_vertical = 4
alignment = 1

[node name="Desc" type="Label" parent="background/M/V/Description"]
layout_mode = 2
size_flags_horizontal = 4
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = SubResource("FontVariation_eybux")
theme_override_font_sizes/font_size = 45
text = "현재 설치된 조리도구"

[node name="ription" type="Label" parent="background/M/V/Description"]
layout_mode = 2
size_flags_horizontal = 4
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = SubResource("SystemFont_ardk6")
theme_override_font_sizes/font_size = 45
text = "[ 중화 웍, 후라이팬, ... ]"
text = "레시피"

[node name="S" type="ScrollContainer" parent="background/M/V"]
custom_minimum_size = Vector2(2.08165e-12, 580)
custom_minimum_size = Vector2(2.08165e-12, 660)
layout_mode = 2

[node name="G" type="GridContainer" parent="background/M/V/S"]
Expand All @@ -107,22 +74,15 @@ columns = 2
[node name="BottomMenu" type="HBoxContainer" parent="background/M/V"]
layout_mode = 2
theme_override_constants/separation = 850
alignment = 2

[node name="Close" type="Button" parent="background/M/V/BottomMenu"]
custom_minimum_size = Vector2(150, 60)
layout_mode = 2
size_flags_horizontal = 8
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_font_sizes/font_size = 35
theme_override_styles/normal = SubResource("StyleBoxFlat_ym4cf")
text = "닫기"

[node name="Cook" type="Button" parent="background/M/V/BottomMenu"]
custom_minimum_size = Vector2(450, 60)
layout_mode = 2
size_flags_horizontal = 8
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_font_sizes/font_size = 35
theme_override_styles/normal = SubResource("StyleBoxFlat_rle7u")
text = "선택한 레시피로 조리하기"

[connection signal="button_down" from="background/M/V/BottomMenu/Close" to="." method="_on_close_button_down"]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=3 uid="uid://cte67bdw48cd6"]
[gd_scene load_steps=4 format=3 uid="uid://bsege78bb6kh3"]

[ext_resource type="Script" path="res://scenes/house/recipebook/ingredient_no.gd" id="1_8dhac"]
[ext_resource type="Script" path="res://scenes/house/recipebook/ingredient_no.gd" id="1_dc1oa"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jup0i"]
bg_color = Color(0.94902, 0.596078, 0.0784314, 1)
Expand All @@ -18,7 +18,7 @@ layout_mode = 3
anchors_preset = 0
offset_right = 180.0
offset_bottom = 110.0
script = ExtResource("1_8dhac")
script = ExtResource("1_dc1oa")

[node name="NoIng" type="Button" parent="."]
custom_minimum_size = Vector2(180, 110)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://me2nvitswvki"]
[gd_scene load_steps=3 format=3 uid="uid://cvackndy25dlm"]

[ext_resource type="Script" path="res://scenes/house/recipebook/ingredient_yes.gd" id="1_ictny"]
[ext_resource type="Script" path="res://scenes/house/recipebook/ingredient_yes.gd" id="1_7fepo"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jup0i"]
bg_color = Color(0.94902, 0.596078, 0.0784314, 1)
Expand All @@ -15,7 +15,7 @@ layout_mode = 3
anchors_preset = 0
offset_right = 180.0
offset_bottom = 110.0
script = ExtResource("1_ictny")
script = ExtResource("1_7fepo")

[node name="Ing" type="Button" parent="."]
custom_minimum_size = Vector2(180, 110)
Expand Down
63 changes: 63 additions & 0 deletions frontend/Savor-22b/scenes/house/recipebook_old/recipe.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
extends Control

const ING_YES = preload("res://scenes/house/recipebook/ingredient_yes.tscn")
const ING_NO = preload("res://scenes/house/recipebook/ingredient_no.tscn")

@onready var ingredients = $panel/M/V/Description/Ingredients/list

var info
var inventorylist

var name_format = "[%s] 레시피"

func _ready():
update_info()



func set_info(recipe: Dictionary):
info = recipe

func update_info():
inventorylist = SceneContext.user_state["inventoryState"]

# Setting names in UI
var name = info.name
name = name.left(name.length() -4)
$panel/M/V/Title/Name.text = name_format % [name]

# Getting exist
for ing in info["ingredientIDList"]:
var created = false
for inving in inventorylist.refrigeratorStateList:
if ing["name"] == inving["name"]:
var ing_y = ING_YES.instantiate()
ing_y.set_ingname(ing["name"])
ingredients.add_child(ing_y)
created = true
break

if(!created):
var ing_n = ING_NO.instantiate()
ing_n.set_ingname(ing["name"])
ingredients.add_child(ing_n)

for ing in info["foodIDList"]:
var created = false
# refrigeratorstatelist에 만들어진 음식이 없는 경우 수정 필요
for inving in inventorylist.refrigeratorStateList:
if ing["name"] == inving["name"]:
var ing_y = ING_YES.instantiate()
ing_y.set_ingname(ing["name"])
ingredients.add_child(ing_y)
created = true
break

if(!created):
var ing_n = ING_NO.instantiate()
ing_n.set_ingname(ing["name"])
ingredients.add_child(ing_n)


func insufficient():
$panel/M/V/Title/insufficient.visible = true
Loading

0 comments on commit c5c94d3

Please sign in to comment.