-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: create food implment * feat: refrigerator in inventory ui * fix: main tool food appears in sub tool food area
- Loading branch information
Showing
43 changed files
with
1,237 additions
and
768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
extends Control | ||
|
||
signal closeall | ||
signal reload_signal | ||
signal cook_started | ||
|
||
const RECIPE = preload("res://scenes/house/Cook/recipe_available.tscn") | ||
|
||
@onready var grid = $background/M/V/S/G | ||
@onready var installed_tool = $background/M/V/Description/ToolList | ||
|
||
const Gql_query = preload("res://gql/query.gd") | ||
|
||
var recipe_list = SceneContext.recipe["recipe"] | ||
var installed_list = SceneContext.installed_tool_name | ||
var available_tool_list : Array | ||
var available_recipe_list : Array | ||
|
||
func _ready(): | ||
var format_string = "[%s]" | ||
var unique_list = remove_duplicates(installed_list) | ||
installed_tool.text = format_string % [", ".join(unique_list)] | ||
|
||
filter_recipe() | ||
|
||
for recipe_data in recipe_list: | ||
print("recipe") | ||
print(recipe_data) | ||
for name in available_tool_list: | ||
for tool in recipe_data["requiredKitchenEquipmentCategoryList"]: | ||
if name == tool.name: | ||
available_recipe_list.append(recipe_data) | ||
var recipe = RECIPE.instantiate() | ||
recipe.set_info(recipe_data) | ||
recipe.select_signal.connect(recipe_selected) | ||
grid.add_child(recipe) | ||
|
||
func filter_recipe(): | ||
# 작은 조리도구 이름 추출 | ||
var small_tool_name : Array | ||
var all_equipment_list = SceneContext.shop["kitchenEquipments"] | ||
for equipment in all_equipment_list: | ||
if equipment["categoryType"] == "sub": | ||
small_tool_name.append(equipment["name"]) | ||
|
||
available_tool_list.append_array(small_tool_name) | ||
available_tool_list.append_array(installed_list) | ||
|
||
|
||
func remove_duplicates(array): | ||
var unique_elements = [] | ||
for item in array: | ||
if not unique_elements.has(item): | ||
unique_elements.append(item) | ||
|
||
return unique_elements | ||
|
||
|
||
func recipe_selected(recipe_index): | ||
SceneContext.selected_recipe_index = recipe_index | ||
|
||
# Visual toggle | ||
for recipe in grid.get_children(): | ||
if(recipe.get_index() != recipe_index): | ||
recipe.disable_button_selected() | ||
|
||
|
||
|
||
|
||
|
||
func _on_close_button_down(): | ||
queue_free() | ||
closeall.emit() | ||
|
||
|
||
func _on_cook_button_down(): | ||
var ingarr = SceneContext.selected_ingredients | ||
var toolarr = SceneContext.selected_tools | ||
var ingstr | ||
var toolstr | ||
|
||
if ingarr.size() > 1 : | ||
ingstr = "\", \"".join(ingarr) | ||
else: | ||
ingstr = ingarr[0] | ||
if toolarr.size() > 1 : | ||
toolstr = "\", \"".join(toolarr) | ||
else: | ||
toolstr = toolarr[0] | ||
print(ingstr) | ||
print(toolstr) | ||
|
||
var gql_query = Gql_query.new() | ||
var query_string = gql_query.create_food_query_format.format([ | ||
"\"%s\"" % GlobalSigner.signer.GetPublicKey(), | ||
SceneContext.selected_recipe_index, | ||
#need to be fixed | ||
"[\"%s\"]" % ingstr, | ||
"[\"%s\"]" % toolstr], "{}") | ||
print(query_string) | ||
|
||
var query_executor = SvrGqlClient.raw(query_string) | ||
query_executor.graphql_response.connect(func(data): | ||
print("gql response: ", data) | ||
var unsigned_tx = data["data"]["createAction_CreateFood"] | ||
print("unsigned tx: ", unsigned_tx) | ||
var signature = GlobalSigner.sign(unsigned_tx) | ||
print("signed tx: ", signature) | ||
var mutation_executor = SvrGqlClient.raw_mutation(gql_query.stage_tx_query_format % [unsigned_tx, signature]) | ||
mutation_executor.graphql_response.connect(func(data): | ||
print("mutation res: ", data) | ||
) | ||
add_child(mutation_executor) | ||
mutation_executor.run({}) | ||
) | ||
add_child(query_executor) | ||
query_executor.run({}) | ||
|
||
# Init past selected infos | ||
SceneContext.selected_ingredients = [] | ||
SceneContext.selected_tools = [] | ||
|
||
cook_started.emit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
frontend/Savor-22b/scenes/house/Cook/cook_started_popup.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
extends Control | ||
|
||
signal close_book | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
pass # Replace with function body. | ||
|
||
|
||
|
||
|
||
func _on_button_pressed(): | ||
close_book.emit() |
58 changes: 58 additions & 0 deletions
58
frontend/Savor-22b/scenes/house/Cook/cook_started_popup.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://dyxrqvghkcb0x"] | ||
|
||
[ext_resource type="Script" path="res://scenes/house/Cook/cook_started_popup.gd" id="1_4u6i2"] | ||
|
||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e6j35"] | ||
bg_color = Color(0.313726, 0.313726, 0.313726, 1) | ||
corner_radius_top_left = 40 | ||
corner_radius_top_right = 40 | ||
corner_radius_bottom_right = 40 | ||
corner_radius_bottom_left = 40 | ||
|
||
[node name="cook_started_popup" type="Control"] | ||
custom_minimum_size = Vector2(500, 250) | ||
layout_mode = 3 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
script = ExtResource("1_4u6i2") | ||
|
||
[node name="Panel" type="Panel" parent="."] | ||
custom_minimum_size = Vector2(500, 250) | ||
layout_mode = 0 | ||
offset_left = 600.0 | ||
offset_top = 400.0 | ||
offset_right = 1100.0 | ||
offset_bottom = 650.0 | ||
theme_override_styles/panel = SubResource("StyleBoxFlat_e6j35") | ||
|
||
[node name="M" type="MarginContainer" parent="Panel"] | ||
layout_mode = 1 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
theme_override_constants/margin_top = 50 | ||
|
||
[node name="V" type="VBoxContainer" parent="Panel/M"] | ||
layout_mode = 2 | ||
theme_override_constants/separation = 30 | ||
|
||
[node name="Label" type="Label" parent="Panel/M/V"] | ||
layout_mode = 2 | ||
theme_override_font_sizes/font_size = 40 | ||
text = "조리를 시작합니다." | ||
horizontal_alignment = 1 | ||
vertical_alignment = 1 | ||
|
||
[node name="Button" type="Button" parent="Panel/M/V"] | ||
layout_mode = 2 | ||
size_flags_horizontal = 4 | ||
size_flags_vertical = 4 | ||
theme_override_font_sizes/font_size = 40 | ||
text = " 확인 " | ||
|
||
[connection signal="pressed" from="Panel/M/V/Button" to="." method="_on_button_pressed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
extends Control | ||
|
||
signal select_ingredient(name : String) | ||
signal select_tool(name : String) | ||
|
||
@onready var button = $Ing | ||
@onready var empty = $Empty | ||
|
||
var ingname | ||
var format_string = "[%s] | ||
사용 가능" | ||
var isTool = false | ||
|
||
func _ready(): | ||
update_info() | ||
|
||
|
||
|
||
|
||
func set_ingname(name: String): | ||
ingname = name | ||
|
||
func get_ingname(): | ||
return ingname | ||
|
||
func disable_button(): | ||
button.disabled = true | ||
empty.set_visible(true) | ||
button.text = "[%s] | ||
" % [ingname] | ||
|
||
func update_info(): | ||
button.text = format_string % [ingname] | ||
|
||
func set_toggled(state: bool): | ||
button.set_toggle_mode(state) | ||
|
||
func change_state_text(): | ||
button.text = "[%s] | ||
선택됨" % [ingname] | ||
|
||
func button_is_tool(): | ||
isTool = true | ||
|
||
func _on_ing_button_down(): | ||
if (isTool): | ||
select_tool.emit(ingname) | ||
else: | ||
select_ingredient.emit(ingname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
[gd_scene load_steps=6 format=3 uid="uid://c0ui8bu7d5c3c"] | ||
|
||
[ext_resource type="Script" path="res://scenes/house/Cook/ingredient.gd" id="1_0odus"] | ||
|
||
[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 | ||
|
||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8gche"] | ||
corner_radius_top_left = 20 | ||
corner_radius_top_right = 20 | ||
corner_radius_bottom_right = 20 | ||
corner_radius_bottom_left = 20 | ||
|
||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_snsw5"] | ||
bg_color = Color(0.94902, 0.596078, 0.0784314, 1) | ||
border_width_left = 10 | ||
border_width_top = 10 | ||
border_width_right = 10 | ||
border_width_bottom = 10 | ||
border_color = Color(1, 1, 1, 1) | ||
corner_radius_top_left = 20 | ||
corner_radius_top_right = 20 | ||
corner_radius_bottom_right = 20 | ||
corner_radius_bottom_left = 20 | ||
|
||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_76ikv"] | ||
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_0odus") | ||
|
||
[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") | ||
theme_override_styles/hover = SubResource("StyleBoxFlat_8gche") | ||
theme_override_styles/pressed = SubResource("StyleBoxFlat_snsw5") | ||
theme_override_styles/disabled = SubResource("StyleBoxFlat_76ikv") | ||
toggle_mode = true | ||
text = "[춘장] | ||
" | ||
|
||
[node name="Empty" type="Label" parent="."] | ||
visible = false | ||
layout_mode = 1 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
theme_override_colors/font_color = Color(1, 0, 0, 1) | ||
theme_override_font_sizes/font_size = 25 | ||
text = " | ||
없음 | ||
" | ||
horizontal_alignment = 1 | ||
vertical_alignment = 1 | ||
|
||
[connection signal="button_down" from="Ing" to="." method="_on_ing_button_down"] |
Oops, something went wrong.