Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SVR-165] [부엌] 부엌 화면 & 식재료와 조리도구 조회 #150

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/Savor-22b/gql/svr_gql_client.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ extends GQLClient

func _ready():
print("client ready")
set_endpoint(false, "1.230.253.103", 38080, "/graphql")
#set_endpoint(false, "1.230.253.103", 38080, "/graphql")

#set_endpoint(false, "localhost", 38080, "/graphql")
set_endpoint(false, "localhost", 38080, "/graphql")


func raw_mutation(query:String):
Expand Down
11 changes: 11 additions & 0 deletions frontend/Savor-22b/gql/svr_gql_client_2.gd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아무래도 이름이 client2는 좀 그렇죠..
용도에 따라 이름을 바꾸면 좋겠네요

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends GQLClient2

func _ready():
print("client 2 ready")
#set_endpoint(false, "1.230.253.103", 38080, "/graphql")

set_endpoint_2(false, "localhost", 38080, "/graphql/explorer")


func raw_mutation(query:String):
return GQLQueryExecuter2.new(endpoint, use_ssl, Mutation.new(query))
1 change: 1 addition & 0 deletions frontend/Savor-22b/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ config/icon="res://icon.svg"

GlobalSigner="*res://scripts/sign/Signer.gd"
SvrGqlClient="*res://gql/svr_gql_client.gd"
SvrGqlClient2="*res://gql/svr_gql_client_2.gd"
SceneContext="*res://scripts/global/scene_context.gd"
GlobalInventory="*res://scripts/global/inventory.gd"
Intro="*res://scripts/scenes/intro.gd"
Expand Down
67 changes: 67 additions & 0 deletions frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
extends Control

const SLOT_EMPTY = preload("res://scenes/house/Kitchen/tool_slot_empty.tscn")
const SLOT_NOT_USED = preload("res://scenes/house/Kitchen/tool_not_used.tscn")
const SLOT_USED = preload("res://scenes/house/Kitchen/tool_is_used.tscn")

@onready var slot = $P/M/V/Slot

var largeslots: Dictionary
var largetools: Array

func _ready():

load_data()

#slot 1
var slot1 = largeslots["firstApplianceSpace"]
if (slot1.installedKitchenEquipment == null): # not installed
var bigslot = SLOT_EMPTY.instantiate()
slot.add_child(bigslot)
else: # installed but not used
if (!slot1["installedKitchenEquipment"]["isCooking"]):
var bigslot = SLOT_NOT_USED.instantiate()
bigslot.set_data(slot1)
slot.add_child(bigslot)
else: # cooking
var bigslot = SLOT_USED.instantiate()
bigslot.set_data(slot1)
slot.add_child(bigslot)
#slot 2
var slot2 = largeslots["secondApplianceSpace"]
if (slot2.installedKitchenEquipment == null):
var bigslot = SLOT_EMPTY.instantiate()
slot.add_child(bigslot)
else:
if (!slot2["installedKitchenEquipment"]["isCooking"]):
var bigslot = SLOT_NOT_USED.instantiate()
bigslot.set_data(slot2)
slot.add_child(bigslot)
else:
var bigslot = SLOT_USED.instantiate()
bigslot.set_data(slot2)
slot.add_child(bigslot)
#slot 3
var slot3 = largeslots["thirdApplianceSpace"]
if (slot3.installedKitchenEquipment == null):
var bigslot = SLOT_EMPTY.instantiate()
slot.add_child(bigslot)
else:
if (!slot3["installedKitchenEquipment"]["isCooking"]):
var bigslot = SLOT_NOT_USED.instantiate()
bigslot.set_data(slot3)
slot.add_child(bigslot)
else:
var bigslot = SLOT_USED.instantiate()
bigslot.set_data(slot3)
slot.add_child(bigslot)
Comment on lines +16 to +57
Copy link
Member

@upa-r-upa upa-r-upa Apr 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분은 사실 값만 다르고 행위는 다 똑같은 것 같은데
함수로 묶거나, 아니면 반복문으로 해도 되고.. 중복 코드를 없애면 좋을 것 같아요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확실히 그렇군요 한번 함수로 묶어서 정리해보겠습니다 !



func load_data():
largeslots = SceneContext.user_kitchen_state["villageState"]["houseState"]["kitchenState"]

var tools = SceneContext.user_state["inventoryState"]["kitchenEquipmentStateList"]
for tool in tools:
if(tool.equipmentCategoryType == "main"):
largetools.append(tool)

50 changes: 50 additions & 0 deletions frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[gd_scene load_steps=3 format=3 uid="uid://bo1s5xygod4cl"]

[ext_resource type="Script" path="res://scenes/house/Kitchen/big_tool_slot.gd" id="1_4yu3x"]

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

[node name="BigToolSlot" type="Control"]
custom_minimum_size = Vector2(1400, 550)
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -520.0
offset_bottom = -530.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
script = ExtResource("1_4yu3x")

[node name="P" type="Panel" parent="."]
layout_mode = 0
offset_right = 1400.0
offset_bottom = 550.0
theme_override_styles/panel = SubResource("StyleBoxFlat_mt11v")

[node name="M" type="MarginContainer" parent="P"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 30
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 30
theme_override_constants/margin_bottom = 15

[node name="V" type="VBoxContainer" parent="P/M"]
layout_mode = 2

[node name="Title" type="Label" parent="P/M/V"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_font_sizes/font_size = 50
text = "큰 조리도구 사용 슬롯"

[node name="Slot" type="HBoxContainer" parent="P/M/V"]
layout_mode = 2
theme_override_constants/separation = 20
31 changes: 31 additions & 0 deletions frontend/Savor-22b/scenes/house/Kitchen/cook_menu.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
extends Control

@onready var Desc = $P/Desc

var data
var requiredtime
var foodname

var format_string = "[%s] 요리 조리중
[%s 블록 남음]"

func _ready():
update_label()



func update_label():
if Desc == null:
return

Desc.text = format_string % [foodname, requiredtime]

func set_data(info: Dictionary):
data = info

# set end times
var endtime = data["cookingEndBlockIndex"]
var currenttime = SceneContext.block_index["blockQuery"]["blocks"][0]["index"]
requiredtime = endtime - currenttime

foodname = data["cookingFood"]["name"]
42 changes: 42 additions & 0 deletions frontend/Savor-22b/scenes/house/Kitchen/cook_menu.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[gd_scene load_steps=3 format=3 uid="uid://cs43iommrj00v"]

[ext_resource type="Script" path="res://scenes/house/Kitchen/cook_menu.gd" id="1_tn6pc"]

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

[node name="CookMenu" type="Control"]
custom_minimum_size = Vector2(400, 250)
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -1520.0
offset_bottom = -830.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_tn6pc")

[node name="P" type="Panel" parent="."]
layout_mode = 0
offset_right = 400.0
offset_bottom = 250.0
theme_override_styles/panel = SubResource("StyleBoxFlat_6jp5j")

[node name="Desc" type="Label" parent="P"]
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(0, 0, 0, 1)
theme_override_font_sizes/font_size = 40
text = "[-- -] 요리 조리중
[N 블록 남음]"
horizontal_alignment = 1
vertical_alignment = 1
55 changes: 55 additions & 0 deletions frontend/Savor-22b/scenes/house/Kitchen/cook_slot.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
extends Control

const MENU = preload("res://scenes/house/Kitchen/cook_menu.tscn")

@onready var slot = $P/M/V/S/Slot

var menus: Array
var largeslots: Dictionary
var largearr: Array #큰 조리도구의 메뉴

func _ready():
load_data();

for menu in menus:
var singlemenu = MENU.instantiate()
singlemenu.set_data(menu)
slot.add_child(singlemenu)


func load_data():
var refrigerator = SceneContext.user_state["inventoryState"]["kitchenEquipmentStateList"]
for items in refrigerator:
if(items.isCooking):
menus.append(items)

refine_data()



# 큰 조리도구의 메뉴를 제외시킨다
func refine_data():
largeslots = SceneContext.user_kitchen_state["villageState"]["houseState"]["kitchenState"]
#print(largeslots)

var slot1 = largeslots["firstApplianceSpace"]
var slot2 = largeslots["secondApplianceSpace"]
var slot3 = largeslots["thirdApplianceSpace"]

if (slot1["installedKitchenEquipment"]!= null):
var obj1 = slot1["installedKitchenEquipment"]["stateId"]
largearr.append(obj1)
if (slot2["installedKitchenEquipment"] != null):
var obj2 = slot2["installedKitchenEquipment"]["stateId"]
largearr.append(obj2)
if (slot3["installedKitchenEquipment"] != null):
var obj3 = slot3["installedKitchenEquipment"]["stateId"]
largearr.append(obj3)

print(largearr)

for menu in menus:
for data in largearr:
if data == menu["stateId"]:
menus.erase(menu)

52 changes: 52 additions & 0 deletions frontend/Savor-22b/scenes/house/Kitchen/cook_slot.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[gd_scene load_steps=3 format=3 uid="uid://dea1yl6pikg0n"]

[ext_resource type="Script" path="res://scenes/house/Kitchen/cook_slot.gd" id="1_kouyr"]

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

[node name="CookSlot" type="Control"]
custom_minimum_size = Vector2(1920, 400)
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_bottom = -680.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_kouyr")

[node name="P" type="Panel" parent="."]
layout_mode = 0
offset_right = 1920.0
offset_bottom = 400.0
theme_override_styles/panel = SubResource("StyleBoxFlat_q2usp")

[node name="M" type="MarginContainer" parent="P"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 30
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 30
theme_override_constants/margin_bottom = 15

[node name="V" type="VBoxContainer" parent="P/M"]
layout_mode = 2

[node name="Title" type="Label" parent="P/M/V"]
layout_mode = 2
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_font_sizes/font_size = 50
text = "일반 음식 조리 슬롯"

[node name="S" type="ScrollContainer" parent="P/M/V"]
layout_mode = 2
vertical_scroll_mode = 0

[node name="Slot" type="HBoxContainer" parent="P/M/V/S"]
layout_mode = 2
theme_override_constants/separation = 50
41 changes: 41 additions & 0 deletions frontend/Savor-22b/scenes/house/Kitchen/tool_is_used.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
extends Control

@onready var button = $Button

var data: Dictionary
var requiredtime
var menuname

var format_string = "현재 [%s] 조리 중

남은 조리 블록 %s 블록"

func _ready():
update_text()


func update_text():
if button == null:
return

print(SceneContext.block_index)
var endtime = data["installedKitchenEquipment"]["cookingEndBlockIndex"]
var currenttime = SceneContext.block_index["blockQuery"]["blocks"][0]["index"]
var timeleft = endtime - currenttime
button.text = format_string % [menuname, timeleft]


func set_data(info: Dictionary):
data = info
menuname = data["installedKitchenEquipment"]["cookingFood"]["name"]
time_info()

func time_info():
var recipe = SceneContext.recipe["recipe"]

for singlerecipe in recipe:
var rcpname = singlerecipe["resultFood"]["name"]
if(rcpname == menuname):
requiredtime = singlerecipe["requiredBlockCount"]

print(requiredtime)
Loading
Loading