diff --git a/frontend/Savor-22b/scripts/global/inventory.gd b/frontend/Savor-22b/global/inventory.gd similarity index 83% rename from frontend/Savor-22b/scripts/global/inventory.gd rename to frontend/Savor-22b/global/inventory.gd index 925eca88..a3da1dab 100644 --- a/frontend/Savor-22b/scripts/global/inventory.gd +++ b/frontend/Savor-22b/global/inventory.gd @@ -1,9 +1,9 @@ extends Node -const inventory_scene = preload("res://scenes/inventory/inventory.tscn"); +const inventory_scene = preload("res://scenes/inventory/inventory.tscn") func open_inventory(data: Dictionary): var inventory_instance := inventory_scene.instantiate() - inventory_instance.data = data; + inventory_instance.data = data get_tree().root.add_child(inventory_instance) diff --git a/frontend/Savor-22b/scripts/global/scene_context.gd b/frontend/Savor-22b/global/scene_context.gd similarity index 63% rename from frontend/Savor-22b/scripts/global/scene_context.gd rename to frontend/Savor-22b/global/scene_context.gd index 3c9a27b1..41405cc2 100644 --- a/frontend/Savor-22b/scripts/global/scene_context.gd +++ b/frontend/Savor-22b/global/scene_context.gd @@ -1,42 +1,5 @@ extends Node -#var villages_json_string := """{ - #"villages": [ - #{ - #"id": 1, - #"name": "평범한 도시 1", - #"width": 3, - #"height": 11, - #"worldX": 5, - #"worldY": 1, - #"houses": [ - #{ - #"x": 1, - #"y": 1, - #"owner": "0x53103C2D7875D2f5f02AeC3075155e268a6e3A94" - #} - #] - #}, - #{ - #"id": 2, - #"name": "외로운 섬", - #"width": 7, - #"height": 13, - #"worldX": -2, - #"worldY": 7, - #"houses": [] - #}, - #{ - #"id": 3, - #"name": "정글", - #"width": 3, - #"height": 5, - #"worldX": 1, - #"worldY": -3, - #"houses": [] - #} - #] - #}""" var villages: Array var selected_village_index := 0 var user_state: Dictionary @@ -56,7 +19,7 @@ var selected_field_index := 0 var selected_item_index := 0 var selected_item_name : String -var selected_recipe_index := 0 +var selected_recipe_index := 1 var selected_ingredients : Array var selected_tools : Array @@ -66,14 +29,6 @@ var installed_tool_info : Array var block_index : Dictionary -#func _ready(): - #var json = JSON.new() - #var error = json.parse(villages_json_string) - #if error != OK: - #print(error) - #else: - #villages = json.data.villages - func set_villages(query_data: Dictionary): villages = query_data.data.villages diff --git a/frontend/Savor-22b/scripts/sign/Signer.gd b/frontend/Savor-22b/global/signer.gd similarity index 97% rename from frontend/Savor-22b/scripts/sign/Signer.gd rename to frontend/Savor-22b/global/signer.gd index 9bae0a38..0368e316 100644 --- a/frontend/Savor-22b/scripts/sign/Signer.gd +++ b/frontend/Savor-22b/global/signer.gd @@ -1,4 +1,4 @@ -extends Node; +extends Node var signer var signer_address diff --git a/frontend/Savor-22b/gql/svr_gql_client_2.gd b/frontend/Savor-22b/global/svr_explorer_gql_client.gd similarity index 70% rename from frontend/Savor-22b/gql/svr_gql_client_2.gd rename to frontend/Savor-22b/global/svr_explorer_gql_client.gd index f9c98502..a1b193d8 100644 --- a/frontend/Savor-22b/gql/svr_gql_client_2.gd +++ b/frontend/Savor-22b/global/svr_explorer_gql_client.gd @@ -1,9 +1,7 @@ extends GQLClient func _ready(): - print("client 2 ready") - #set_endpoint(false, "1.230.253.103", 38080, "/graphql") - + set_endpoint(false, "localhost", 38080, "/graphql/explorer") diff --git a/frontend/Savor-22b/gql/svr_gql_client.gd b/frontend/Savor-22b/global/svr_gql_client.gd similarity index 70% rename from frontend/Savor-22b/gql/svr_gql_client.gd rename to frontend/Savor-22b/global/svr_gql_client.gd index ed3204f7..34e3ff72 100644 --- a/frontend/Savor-22b/gql/svr_gql_client.gd +++ b/frontend/Savor-22b/global/svr_gql_client.gd @@ -1,8 +1,6 @@ extends GQLClient func _ready(): - print("client ready") - #set_endpoint(false, "1.230.253.103", 38080, "/graphql") set_endpoint(false, "localhost", 38080, "/graphql") diff --git a/frontend/Savor-22b/gql/query.gd b/frontend/Savor-22b/gql/query.gd index e0ff1a8a..fdc388be 100644 --- a/frontend/Savor-22b/gql/query.gd +++ b/frontend/Savor-22b/gql/query.gd @@ -109,4 +109,4 @@ var calculate_relocation_cost_query = SvrGqlClient.query( "villageId": "Int!", "relocationVillageId": "Int!", }, - calculate_relocation_cost_query_template) \ No newline at end of file + calculate_relocation_cost_query_template) diff --git a/frontend/Savor-22b/project.godot b/frontend/Savor-22b/project.godot index 5c927a43..c9ab652e 100644 --- a/frontend/Savor-22b/project.godot +++ b/frontend/Savor-22b/project.godot @@ -11,20 +11,19 @@ config_version=5 [application] config/name="Savor-22b" -run/main_scene="res://scenes/intro.tscn" +run/main_scene="res://scenes/intro/intro.tscn" config/features=PackedStringArray("4.2", "C#", "GL Compatibility") boot_splash/bg_color=Color(0.141176, 0.141176, 0.141176, 1) config/icon="res://icon.svg" [autoload] -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" -TestPanel="*res://scenes/testpanel/test_panel.gd" +GlobalSigner="*res://global/signer.gd" +SvrGqlClient="*res://global/svr_gql_client.gd" +SvrExplorerGqlClient="*res://global/svr_explorer_gql_client.gd" +SceneContext="*res://global/scene_context.gd" +GlobalInventory="*res://global/inventory.gd" +Intro="*res://scenes/intro/intro.gd" [display] diff --git a/frontend/Savor-22b/Asset.gd b/frontend/Savor-22b/scenes/asset.gd similarity index 100% rename from frontend/Savor-22b/Asset.gd rename to frontend/Savor-22b/scenes/asset.gd diff --git a/frontend/Savor-22b/scenes/addressdisplay.gd b/frontend/Savor-22b/scenes/common/prefabs/address_display.gd similarity index 99% rename from frontend/Savor-22b/scenes/addressdisplay.gd rename to frontend/Savor-22b/scenes/common/prefabs/address_display.gd index dda7dbd6..b841d88f 100644 --- a/frontend/Savor-22b/scenes/addressdisplay.gd +++ b/frontend/Savor-22b/scenes/common/prefabs/address_display.gd @@ -1,6 +1,5 @@ extends LineEdit - # Called when the node enters the scene tree for the first time. func _ready(): self.text = str(GlobalSigner.signer_address) diff --git a/frontend/Savor-22b/ui/asset.tscn b/frontend/Savor-22b/scenes/common/prefabs/asset.tscn similarity index 83% rename from frontend/Savor-22b/ui/asset.tscn rename to frontend/Savor-22b/scenes/common/prefabs/asset.tscn index 3d2cb969..a2e2ea6d 100644 --- a/frontend/Savor-22b/ui/asset.tscn +++ b/frontend/Savor-22b/scenes/common/prefabs/asset.tscn @@ -1,13 +1,13 @@ [gd_scene load_steps=2 format=3 uid="uid://co4t4p5pawylr"] -[ext_resource type="Script" path="res://Asset.gd" id="1_dxu6y"] +[ext_resource type="Script" path="res://scenes/asset.gd" id="1_2uqhq"] [node name="Asset" type="ColorRect"] custom_minimum_size = Vector2(550, 77) offset_right = 400.0 offset_bottom = 100.0 color = Color(0.490196, 1, 1, 0) -script = ExtResource("1_dxu6y") +script = ExtResource("1_2uqhq") [node name="Text" type="Label" parent="."] layout_mode = 1 diff --git a/frontend/Savor-22b/ui/confirm_popup.gd b/frontend/Savor-22b/scenes/common/prefabs/confirm_popup.gd similarity index 100% rename from frontend/Savor-22b/ui/confirm_popup.gd rename to frontend/Savor-22b/scenes/common/prefabs/confirm_popup.gd diff --git a/frontend/Savor-22b/ui/confirm_popup.tscn b/frontend/Savor-22b/scenes/common/prefabs/confirm_popup.tscn similarity index 94% rename from frontend/Savor-22b/ui/confirm_popup.tscn rename to frontend/Savor-22b/scenes/common/prefabs/confirm_popup.tscn index 185a2b54..c7d84d3f 100644 --- a/frontend/Savor-22b/ui/confirm_popup.tscn +++ b/frontend/Savor-22b/scenes/common/prefabs/confirm_popup.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://dmgv25t8i3882"] -[ext_resource type="Script" path="res://ui/confirm_popup.gd" id="1_xg6hf"] +[ext_resource type="Script" path="res://scenes/common/prefabs/confirm_popup.gd" id="1_xg6hf"] [node name="NoticePopup" type="ColorRect"] offset_left = 5.0 diff --git a/frontend/Savor-22b/scenes/common/prefabs/done_notice_popup.gd b/frontend/Savor-22b/scenes/common/prefabs/done_notice_popup.gd new file mode 100644 index 00000000..340719cd --- /dev/null +++ b/frontend/Savor-22b/scenes/common/prefabs/done_notice_popup.gd @@ -0,0 +1,19 @@ +extends ColorRect + +@onready var info_text = $VBoxContainer/Label + +var format_string = "%s %s" +var seed_name: String + +func _ready(): + if info_text == null: + return + + info_text.text = format_string % [seed_name, "(이)가 수확되었습니다."] + +func set_seed_name(name: String): + seed_name = name + + +func _on_button_down(): + queue_free() diff --git a/frontend/Savor-22b/ui/done_notice_popup.tscn b/frontend/Savor-22b/scenes/common/prefabs/done_notice_popup.tscn similarity index 91% rename from frontend/Savor-22b/ui/done_notice_popup.tscn rename to frontend/Savor-22b/scenes/common/prefabs/done_notice_popup.tscn index d3746144..0a72ce36 100644 --- a/frontend/Savor-22b/ui/done_notice_popup.tscn +++ b/frontend/Savor-22b/scenes/common/prefabs/done_notice_popup.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://b0q2f8i3thy08"] -[ext_resource type="Script" path="res://ui/done_notice_popup.gd" id="1_4j1h2"] +[ext_resource type="Script" path="res://scenes/common/prefabs/done_notice_popup.gd" id="1_4j1h2"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ol5a4"] bg_color = Color(0, 0, 0, 1) @@ -47,4 +47,4 @@ text = " 확인 " layout_mode = 2 theme_override_constants/margin_top = 30 -[connection signal="button_down" from="VBoxContainer/Button" to="." method="_on_button_button_down"] +[connection signal="button_down" from="VBoxContainer/Button" to="." method="_on_button_down"] diff --git a/frontend/Savor-22b/ui/dungeon_button.tscn b/frontend/Savor-22b/scenes/common/prefabs/dungeon_button.tscn similarity index 100% rename from frontend/Savor-22b/ui/dungeon_button.tscn rename to frontend/Savor-22b/scenes/common/prefabs/dungeon_button.tscn diff --git a/frontend/Savor-22b/ui/notice_popup.gd b/frontend/Savor-22b/scenes/common/prefabs/notice_popup.gd similarity index 98% rename from frontend/Savor-22b/ui/notice_popup.gd rename to frontend/Savor-22b/scenes/common/prefabs/notice_popup.gd index 287dc378..afd67ac5 100644 --- a/frontend/Savor-22b/ui/notice_popup.gd +++ b/frontend/Savor-22b/scenes/common/prefabs/notice_popup.gd @@ -1,7 +1,5 @@ extends ColorRect - - func _on_button_pressed(): queue_free() diff --git a/frontend/Savor-22b/ui/notice_popup.tscn b/frontend/Savor-22b/scenes/common/prefabs/notice_popup.tscn similarity index 91% rename from frontend/Savor-22b/ui/notice_popup.tscn rename to frontend/Savor-22b/scenes/common/prefabs/notice_popup.tscn index c36fd194..def3b619 100644 --- a/frontend/Savor-22b/ui/notice_popup.tscn +++ b/frontend/Savor-22b/scenes/common/prefabs/notice_popup.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://fdq3w641k4h1"] -[ext_resource type="Script" path="res://ui/notice_popup.gd" id="1_ftdb6"] +[ext_resource type="Script" path="res://scenes/common/prefabs/notice_popup.gd" id="1_ftdb6"] [node name="NoticePopup" type="ColorRect"] offset_left = 5.0 diff --git a/frontend/Savor-22b/scenes/farm/farm.gd b/frontend/Savor-22b/scenes/farm/farm.gd new file mode 100644 index 00000000..624f1e8a --- /dev/null +++ b/frontend/Savor-22b/scenes/farm/farm.gd @@ -0,0 +1,259 @@ +extends Control + +const DoneNoticePopupScn = preload("res://scenes/common/prefabs/done_notice_popup.tscn") + +const FarmSlotEmptyScn = preload("res://scenes/farm/farm_slot_empty.tscn") +const FarmSlotButtonScn = preload("res://scenes/farm/farm_slot_button.tscn") +const FarmSlotDoneScn = preload("res://scenes/farm/farm_slot_done.tscn") +const FarmInstallPopupScn = preload("res://scenes/farm/farm_install_popup.tscn") +const FarmActionPopupScn = preload("res://scenes/farm/farm_action_popup.tscn") +const FarmAskRemovePopupScn = preload("res://scenes/farm/farm_ask_remove_popup.tscn") +const FarmRemoveDonePopupScn = preload("res://scenes/farm/farm_remove_done_popup.tscn") + +const GqlQuery = preload("res://gql/query.gd") + +@onready var left_farm = $MC/HC/CR/MC/HC/Left +@onready var right_farm = $MC/HC/CR/MC/HC/Right +@onready var popup_area = $Popups + +var farms = [] +var item_state_ids = [] +var item_state_Id_to_use +var harvested_name +var action_success = false + +func _ready(): + farms = SceneContext.user_state["villageState"]["houseFieldStates"] + + item_state_ids = SceneContext.user_state["inventoryState"]["itemStateList"] + + #create blank slots + # Left slot + for i in range(0,5): + var farm + if (farms[i] == null): + farm = FarmSlotEmptyScn.instantiate() + farm.im_left() + farm.button_down.connect(farm_selected) + else: + if(farms[i]["isHarvested"]): + farm = FarmSlotDoneScn.instantiate() + farm.im_left() + farm.set_farm_slot(farms[i]) + farm.button_down.connect(farm_selected) + farm.button_down_name.connect(set_harvested_name) + farm.button_down_harvest.connect(harvest_seed) + else: + farm = FarmSlotButtonScn.instantiate() + farm.im_left() + farm.button_down.connect(farm_selected) + farm.button_down_action.connect(control_seed) + farm.set_farm_slot(farms[i]) + + left_farm.add_child(farm) + + # Right slot + for i in range(5,10): + var farm + if (farms[i] == null): + farm = FarmSlotEmptyScn.instantiate() + farm.im_right() + farm.button_down.connect(farm_selected) + else: + if(farms[i]["isHarvested"]): + farm = FarmSlotDoneScn.instantiate() + farm.im_right() + farm.set_farm_slot(farms[i]) + farm.button_down.connect(farm_selected) + farm.button_down_name.connect(set_harvested_name) + farm.button_down_harvest.connect(harvest_seed) + else: + farm = FarmSlotButtonScn.instantiate() + farm.im_right() + farm.button_down.connect(farm_selected) + farm.button_down_action.connect(control_seed) + farm.set_farm_slot(farms[i]) + + right_farm.add_child(farm) + + +func farm_selected(farm_index): + var format_string = "farm selected: %s" + SceneContext.selected_field_index = farm_index + if (farms[farm_index] == null): + plant_popup() + #else: + #if(farms[farm_index]["isHarvested"]): + #done_popup() + #else: + #pass + +func plant_popup(): + if is_instance_valid(popup_area): + for child in popup_area.get_children(): + child.queue_free() + + var amount = item_state_ids.size() + var mouse_pos = get_local_mouse_position() + Vector2(0, -200) + var install_popup = FarmInstallPopupScn.instantiate() + install_popup.set_amount(amount) + popup_area.add_child(install_popup) + install_popup.set_position(mouse_pos) + install_popup.accept_button_down.connect(plant_seed) + + +func plant_seed(): + var gql_query = GqlQuery.new() + var query_string = gql_query.plant_seed_query_format.format([ + "\"%s\"" % GlobalSigner.signer.GetPublicKey(), + SceneContext.selected_field_index, + "\"%s\"" % item_state_ids[0]["stateID"]], "{}") + + var query_executor = SvrGqlClient.raw(query_string) + query_executor.graphql_response.connect( + func(data): + var unsigned_tx = data["data"]["createAction_PlantingSeed"] + var signature = GlobalSigner.sign(unsigned_tx) + var mutation_executor = SvrGqlClient.raw_mutation(gql_query.stage_tx_query_format % [unsigned_tx, signature]) + add_child(mutation_executor) + mutation_executor.run({}) + ) + add_child(query_executor) + query_executor.run({}) + +func set_harvested_name(seed_name): + harvested_name = seed_name + +func done_popup(): + if is_instance_valid(popup_area): + for child in popup_area.get_children(): + child.queue_free() + + var done_popup = DoneNoticePopupScn.instantiate() + done_popup.set_seed_name(harvested_name) + popup_area.add_child(done_popup) + # 팝업 위치는 설정이 필요할 듯 + done_popup.set_position(Vector2(700,500)) + +func harvest_seed(): + action_success = false + var gql_query = GqlQuery.new() + var query_string = gql_query.harvest_seed_query_format.format([ + "\"%s\"" % GlobalSigner.signer.GetPublicKey(), + SceneContext.selected_field_index], "{}") + + var query_executor = SvrGqlClient.raw(query_string) + query_executor.graphql_response.connect( + func(data): + var unsigned_tx = data["data"]["createAction_HarvestingSeed"] + var signature = GlobalSigner.sign(unsigned_tx) + var mutation_executor = SvrGqlClient.raw_mutation(gql_query.stage_tx_query_format % [unsigned_tx, signature]) + add_child(mutation_executor) + mutation_executor.run({}) + ) + add_child(query_executor) + query_executor.run({}) + action_success = true + fetch_new() + +func action_popup(weed : bool): + if is_instance_valid(popup_area): + for child in popup_area.get_children(): + child.queue_free() + + var action_popup = FarmActionPopupScn.instantiate() + action_popup.set_weed_button(weed) + popup_area.add_child(action_popup) + var mouse_pos = get_local_mouse_position() + Vector2(0, -200) + action_popup.set_position(mouse_pos) + action_popup.button_down_remove.connect(remove_popup) + action_popup.weed_action_signal.connect(remove_weed) + +func remove_popup(): + if is_instance_valid(popup_area): + for child in popup_area.get_children(): + child.queue_free() + + var remove_popup = FarmAskRemovePopupScn.instantiate() + popup_area.add_child(remove_popup) + remove_popup.set_position(Vector2(700,500)) + remove_popup.button_yes.connect(remove_done_popup) + +func remove_done_popup(): + remove_seed() + if is_instance_valid(popup_area): + for child in popup_area.get_children(): + child.queue_free() + + var done_popup = FarmRemoveDonePopupScn.instantiate() + popup_area.add_child(done_popup) + done_popup.set_position(Vector2(700,500)) + done_popup.refresh_me.connect(fetch_new) + +func control_seed(weed : bool): + #code here + action_popup(weed) + +func remove_seed(): + var gql_query = GqlQuery.new() + var query_string = gql_query.remove_seed_query_format.format([ + "\"%s\"" % GlobalSigner.signer.GetPublicKey(), + SceneContext.selected_field_index], "{}") + + var query_executor = SvrGqlClient.raw(query_string) + query_executor.graphql_response.connect( + func(data): + var unsigned_tx = data["data"]["createAction_RemovePlantedSeed"] + var signature = GlobalSigner.sign(unsigned_tx) + var mutation_executor = SvrGqlClient.raw_mutation(gql_query.stage_tx_query_format % [unsigned_tx, signature]) + add_child(mutation_executor) + mutation_executor.run({}) + ) + add_child(query_executor) + query_executor.run({}) + fetch_new() + +func fetch_new(): +# fetch datas + Intro._query_user_state() + Intro.get_current_block() + + # done popup + if(action_success): + done_popup() + action_success = false + +# delete old farm uis + if is_instance_valid(left_farm): + for child in left_farm.get_children(): + child.queue_free() + if is_instance_valid(right_farm): + for child in right_farm.get_children(): + child.queue_free() + + _ready() + +func remove_weed(): + var gql_query = GqlQuery.new() + var query_string = gql_query.remove_weed_query_format.format([ + "\"%s\"" % GlobalSigner.signer.GetPublicKey(), + SceneContext.selected_field_index], "{}") + + var query_executor = SvrGqlClient.raw(query_string) + query_executor.graphql_response.connect( + func(data): + var unsigned_tx = data["data"]["createAction_RemoveWeed"] + var signature = GlobalSigner.sign(unsigned_tx) + var mutation_executor = SvrGqlClient.raw_mutation(gql_query.stage_tx_query_format % [unsigned_tx, signature]) + add_child(mutation_executor) + mutation_executor.run({}) + ) + add_child(query_executor) + query_executor.run({}) + fetch_new() + +func _on_refresh_button_down(): + fetch_new() + +func _on_home_button_down(): + get_tree().change_scene_to_file("res://scenes/house/house.tscn") diff --git a/frontend/Savor-22b/scenes/farm.tscn b/frontend/Savor-22b/scenes/farm/farm.tscn similarity index 95% rename from frontend/Savor-22b/scenes/farm.tscn rename to frontend/Savor-22b/scenes/farm/farm.tscn index c76e1aec..838188d2 100644 --- a/frontend/Savor-22b/scenes/farm.tscn +++ b/frontend/Savor-22b/scenes/farm/farm.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://c10m1dv6u7ks7"] -[ext_resource type="Script" path="res://scripts/scenes/farm.gd" id="1_q2tum"] -[ext_resource type="PackedScene" uid="uid://co4t4p5pawylr" path="res://ui/asset.tscn" id="2_vkmuk"] +[ext_resource type="Script" path="res://scenes/farm/farm.gd" id="1_q2tum"] +[ext_resource type="PackedScene" uid="uid://co4t4p5pawylr" path="res://scenes/common/prefabs/asset.tscn" id="2_vkmuk"] [node name="Farm" type="Control"] layout_mode = 3 @@ -111,5 +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"] +[connection signal="button_down" from="MC/HC/VBoxContainer/MarginContainer/VBoxContainer/HomeButton" to="." method="_on_home_button_down"] +[connection signal="button_down" from="MC/HC/VBoxContainer/MarginContainer/VBoxContainer/RefreshButton" to="." method="_on_refresh_button_down"] diff --git a/frontend/Savor-22b/ui/farm_action_popup.gd b/frontend/Savor-22b/scenes/farm/farm_action_popup.gd similarity index 99% rename from frontend/Savor-22b/ui/farm_action_popup.gd rename to frontend/Savor-22b/scenes/farm/farm_action_popup.gd index 6562e6f6..10ac8b83 100644 --- a/frontend/Savor-22b/ui/farm_action_popup.gd +++ b/frontend/Savor-22b/scenes/farm/farm_action_popup.gd @@ -14,8 +14,6 @@ func set_weed_button(weed : bool): func _on_remove_button_down(): button_down_remove.emit() - - func _on_cancel_button_down(): queue_free() diff --git a/frontend/Savor-22b/ui/farm_action_popup.tscn b/frontend/Savor-22b/scenes/farm/farm_action_popup.tscn similarity index 95% rename from frontend/Savor-22b/ui/farm_action_popup.tscn rename to frontend/Savor-22b/scenes/farm/farm_action_popup.tscn index fe27684a..76764abc 100644 --- a/frontend/Savor-22b/ui/farm_action_popup.tscn +++ b/frontend/Savor-22b/scenes/farm/farm_action_popup.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://brn1piu848fxo"] -[ext_resource type="Script" path="res://ui/farm_action_popup.gd" id="1_ma8qk"] +[ext_resource type="Script" path="res://scenes/farm/farm_action_popup.gd" id="1_ma8qk"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yesvl"] bg_color = Color(0, 0, 0, 1) diff --git a/frontend/Savor-22b/ui/farm_ask_remove_popup.gd b/frontend/Savor-22b/scenes/farm/farm_ask_remove_popup.gd similarity index 97% rename from frontend/Savor-22b/ui/farm_ask_remove_popup.gd rename to frontend/Savor-22b/scenes/farm/farm_ask_remove_popup.gd index a490b851..59d82d88 100644 --- a/frontend/Savor-22b/ui/farm_ask_remove_popup.gd +++ b/frontend/Savor-22b/scenes/farm/farm_ask_remove_popup.gd @@ -2,16 +2,11 @@ extends ColorRect signal button_yes - - func _ready(): pass # Replace with function body. - - func _on_accept_button_down(): button_yes.emit() - func _on_cancel_button_down(): queue_free() diff --git a/frontend/Savor-22b/ui/farm_ask_remove_popup.tscn b/frontend/Savor-22b/scenes/farm/farm_ask_remove_popup.tscn similarity index 95% rename from frontend/Savor-22b/ui/farm_ask_remove_popup.tscn rename to frontend/Savor-22b/scenes/farm/farm_ask_remove_popup.tscn index d77b4f18..5e8953fc 100644 --- a/frontend/Savor-22b/ui/farm_ask_remove_popup.tscn +++ b/frontend/Savor-22b/scenes/farm/farm_ask_remove_popup.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://im1tn3x7uvfu"] -[ext_resource type="Script" path="res://ui/farm_ask_remove_popup.gd" id="1_nakgl"] +[ext_resource type="Script" path="res://scenes/farm/farm_ask_remove_popup.gd" id="1_nakgl"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5kg0i"] bg_color = Color(0, 0, 0, 1) diff --git a/frontend/Savor-22b/ui/farm_install_popup.gd b/frontend/Savor-22b/scenes/farm/farm_install_popup.gd similarity index 63% rename from frontend/Savor-22b/ui/farm_install_popup.gd rename to frontend/Savor-22b/scenes/farm/farm_install_popup.gd index 0c4326be..a345aec1 100644 --- a/frontend/Savor-22b/ui/farm_install_popup.gd +++ b/frontend/Savor-22b/scenes/farm/farm_install_popup.gd @@ -2,7 +2,7 @@ extends Panel signal accept_button_down -@onready var infotext = $VBoxContainer/MarginContainer/Text +@onready var info_text = $VBoxContainer/MarginContainer/Text var format_string = """%s %s (%d %s)""" @@ -14,12 +14,10 @@ func _ready(): func _update_text(): - if infotext == null: + if info_text == null: return - infotext.text = format_string % ["랜덤 종자 하나를 소모해서", "종자를 심기", amount, "개 남음"] - - + info_text.text = format_string % ["랜덤 종자 하나를 소모해서", "종자를 심기", amount, "개 남음"] func set_amount(amount: int): self.amount = amount @@ -30,7 +28,5 @@ func _on_accept_button_down(): queue_free() - - func _on_cancel_button_down(): queue_free() diff --git a/frontend/Savor-22b/ui/farm_install_popup.tscn b/frontend/Savor-22b/scenes/farm/farm_install_popup.tscn similarity index 96% rename from frontend/Savor-22b/ui/farm_install_popup.tscn rename to frontend/Savor-22b/scenes/farm/farm_install_popup.tscn index 49e0867e..6ea026be 100644 --- a/frontend/Savor-22b/ui/farm_install_popup.tscn +++ b/frontend/Savor-22b/scenes/farm/farm_install_popup.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://kttsr2bn7o31"] -[ext_resource type="Script" path="res://ui/farm_install_popup.gd" id="1_nl4pl"] +[ext_resource type="Script" path="res://scenes/farm/farm_install_popup.gd" id="1_nl4pl"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1w3ox"] bg_color = Color(0.866667, 0.498039, 0.215686, 1) diff --git a/frontend/Savor-22b/ui/farm_remove_done_popup.gd b/frontend/Savor-22b/scenes/farm/farm_remove_done_popup.gd similarity index 79% rename from frontend/Savor-22b/ui/farm_remove_done_popup.gd rename to frontend/Savor-22b/scenes/farm/farm_remove_done_popup.gd index 4e819215..55535249 100644 --- a/frontend/Savor-22b/ui/farm_remove_done_popup.gd +++ b/frontend/Savor-22b/scenes/farm/farm_remove_done_popup.gd @@ -5,7 +5,6 @@ signal refresh_me func _ready(): pass # Replace with function body. - -func _on_button_button_down(): +func _on_button_down(): refresh_me.emit() queue_free() diff --git a/frontend/Savor-22b/ui/farm_remove_done_popup.tscn b/frontend/Savor-22b/scenes/farm/farm_remove_done_popup.tscn similarity index 91% rename from frontend/Savor-22b/ui/farm_remove_done_popup.tscn rename to frontend/Savor-22b/scenes/farm/farm_remove_done_popup.tscn index 0cd60151..ce3f4c2d 100644 --- a/frontend/Savor-22b/ui/farm_remove_done_popup.tscn +++ b/frontend/Savor-22b/scenes/farm/farm_remove_done_popup.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://c48jlsophfki6"] -[ext_resource type="Script" path="res://ui/farm_remove_done_popup.gd" id="1_6dq0m"] +[ext_resource type="Script" path="res://scenes/farm/farm_remove_done_popup.gd" id="1_6dq0m"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_eamck"] bg_color = Color(0, 0, 0, 1) @@ -41,4 +41,4 @@ theme_override_font_sizes/font_size = 50 theme_override_styles/normal = SubResource("StyleBoxFlat_eamck") text = " 확인 " -[connection signal="button_down" from="M/V/Button" to="." method="_on_button_button_down"] +[connection signal="button_down" from="M/V/Button" to="." method="_on_button_down"] diff --git a/frontend/Savor-22b/ui/farm_slot_button.gd b/frontend/Savor-22b/scenes/farm/farm_slot_button.gd similarity index 69% rename from frontend/Savor-22b/ui/farm_slot_button.gd rename to frontend/Savor-22b/scenes/farm/farm_slot_button.gd index 8ff7a218..7339e7c8 100644 --- a/frontend/Savor-22b/ui/farm_slot_button.gd +++ b/frontend/Savor-22b/scenes/farm/farm_slot_button.gd @@ -3,7 +3,6 @@ extends ColorRect signal button_down(child_index: int) signal button_down_action - @onready var button = $V/Button var farm_slot: Dictionary @@ -11,7 +10,7 @@ var farm_slot: Dictionary var format_string = """%s %s (%d %s)""" -var isleft: bool +var is_left: bool func _ready(): _update_button() @@ -20,9 +19,9 @@ func _update_button(): if button == null: return - var currenttime = SceneContext.block_index["blockQuery"]["blocks"][0]["index"] - var timeleft = (farm_slot.installedBlock + farm_slot.totalBlock) - currenttime - button.text = format_string % [farm_slot.seedName, "자라는 중", timeleft, "블록 남음"] + var current_time = SceneContext.block_index["blockQuery"]["blocks"][0]["index"] + var time_left = (farm_slot.installedBlock + farm_slot.totalBlock) - current_time + button.text = format_string % [farm_slot.seedName, "자라는 중", time_left, "블록 남음"] if (farm_slot.weedRemovalAble): $Weed.visible = true @@ -31,8 +30,8 @@ func set_farm_slot(farm_slot: Dictionary): self.farm_slot = farm_slot _update_button() -func _on_button_button_down(): - if (isleft): +func _on_button_down(): + if (is_left): button_down.emit(get_index()) else: button_down.emit(get_index()+5) @@ -40,7 +39,7 @@ func _on_button_button_down(): func im_right(): - isleft = false + is_left = false func im_left(): - isleft = true + is_left = true diff --git a/frontend/Savor-22b/ui/farm_slot_button.tscn b/frontend/Savor-22b/scenes/farm/farm_slot_button.tscn similarity index 93% rename from frontend/Savor-22b/ui/farm_slot_button.tscn rename to frontend/Savor-22b/scenes/farm/farm_slot_button.tscn index 9d78b50f..3c27ed6d 100644 --- a/frontend/Savor-22b/ui/farm_slot_button.tscn +++ b/frontend/Savor-22b/scenes/farm/farm_slot_button.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://c0qm0ud7mwmwb"] -[ext_resource type="Script" path="res://ui/farm_slot_button.gd" id="1_vqq1f"] +[ext_resource type="Script" path="res://scenes/farm/farm_slot_button.gd" id="1_vqq1f"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b1e62"] bg_color = Color(0.6, 0.6, 0.6, 0) @@ -52,4 +52,4 @@ text = "[잡초 제거 필요]" horizontal_alignment = 2 vertical_alignment = 2 -[connection signal="button_down" from="V/Button" to="." method="_on_button_button_down"] +[connection signal="button_down" from="V/Button" to="." method="_on_button_down"] diff --git a/frontend/Savor-22b/ui/farm_slot_done.gd b/frontend/Savor-22b/scenes/farm/farm_slot_done.gd similarity index 74% rename from frontend/Savor-22b/ui/farm_slot_done.gd rename to frontend/Savor-22b/scenes/farm/farm_slot_done.gd index cac15890..afe656aa 100644 --- a/frontend/Savor-22b/ui/farm_slot_done.gd +++ b/frontend/Savor-22b/scenes/farm/farm_slot_done.gd @@ -1,14 +1,14 @@ extends ColorRect signal button_down(child_index: int) -signal button_down_name(seedName: String) +signal button_down_name(seed_name: String) signal button_down_harvest @onready var button = $V/Button var farm_slot: Dictionary -var isleft: bool +var is_left: bool var format_string = "[%s] %s" @@ -21,23 +21,21 @@ func _update_button(): button.text = format_string % [farm_slot.seedName, "수확하기"] - func set_farm_slot(farm_slot: Dictionary): self.farm_slot = farm_slot _update_button() -func _on_button_button_down(): +func _on_button_down(): button_down_name.emit(farm_slot.seedName) - if (isleft): + if (is_left): button_down.emit(get_index()) else: button_down.emit(get_index()+5) - print("done button signal") - button_down_harvest.emit() + button_down_harvest.emit() func im_right(): - isleft = false + is_left = false func im_left(): - isleft = true + is_left = true diff --git a/frontend/Savor-22b/ui/farm_slot_done.tscn b/frontend/Savor-22b/scenes/farm/farm_slot_done.tscn similarity index 91% rename from frontend/Savor-22b/ui/farm_slot_done.tscn rename to frontend/Savor-22b/scenes/farm/farm_slot_done.tscn index f342ba3d..91892d57 100644 --- a/frontend/Savor-22b/ui/farm_slot_done.tscn +++ b/frontend/Savor-22b/scenes/farm/farm_slot_done.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://bjcg2kocdfuua"] -[ext_resource type="Script" path="res://ui/farm_slot_done.gd" id="1_jh5h4"] +[ext_resource type="Script" path="res://scenes/farm/farm_slot_done.gd" id="1_jh5h4"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b1e62"] bg_color = Color(0, 0.372549, 1, 1) @@ -36,4 +36,4 @@ theme_override_styles/normal = SubResource("StyleBoxFlat_b1e62") theme_override_styles/pressed = SubResource("StyleBoxFlat_fgm2y") text = "[밀] 수확하기" -[connection signal="button_down" from="V/Button" to="." method="_on_button_button_down"] +[connection signal="button_down" from="V/Button" to="." method="_on_button_down"] diff --git a/frontend/Savor-22b/ui/farm_slot_empty.gd b/frontend/Savor-22b/scenes/farm/farm_slot_empty.gd similarity index 69% rename from frontend/Savor-22b/ui/farm_slot_empty.gd rename to frontend/Savor-22b/scenes/farm/farm_slot_empty.gd index dd8e47f2..3fad9d76 100644 --- a/frontend/Savor-22b/ui/farm_slot_empty.gd +++ b/frontend/Savor-22b/scenes/farm/farm_slot_empty.gd @@ -2,23 +2,21 @@ extends ColorRect signal button_down(child_index: int) -var isleft: bool +var is_left: bool func _ready(): pass -func _on_button_button_down(): +func _on_button_down(): # return index of selected slot - if (isleft): + if (is_left): button_down.emit(get_index()) else: button_down.emit(get_index()+5) - - func im_right(): - isleft = false + is_left = false func im_left(): - isleft = true + is_left = true diff --git a/frontend/Savor-22b/ui/farm_slot_empty.tscn b/frontend/Savor-22b/scenes/farm/farm_slot_empty.tscn similarity index 92% rename from frontend/Savor-22b/ui/farm_slot_empty.tscn rename to frontend/Savor-22b/scenes/farm/farm_slot_empty.tscn index 10b7d2e7..617fdc32 100644 --- a/frontend/Savor-22b/ui/farm_slot_empty.tscn +++ b/frontend/Savor-22b/scenes/farm/farm_slot_empty.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://bf6be56dhvlws"] -[ext_resource type="Script" path="res://ui/farm_slot_empty.gd" id="1_qsptk"] +[ext_resource type="Script" path="res://scenes/farm/farm_slot_empty.gd" id="1_qsptk"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b1e62"] bg_color = Color(0.243137, 1, 0.215686, 1) @@ -42,4 +42,4 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_esont") text = "[비어있음] 종자 심기" -[connection signal="button_down" from="V/Button" to="." method="_on_button_button_down"] +[connection signal="button_down" from="V/Button" to="." method="_on_button_down"] diff --git a/frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.gd b/frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.gd deleted file mode 100644 index 414a48f6..00000000 --- a/frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.gd +++ /dev/null @@ -1,79 +0,0 @@ -extends Control - -signal install_signal -signal uninstall_signal - -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 -var installedId: Array -var installedName: Array -var installedToolsInfo: Array - -var selectedSpace: int - -func _ready(): - - load_data() - -# Setting Slots - set_slot("first") - set_slot("second") - set_slot("third") - - SceneContext.installed_tool_id = installedId - SceneContext.installed_tool_name = installedName - SceneContext.installed_tool_info = installedToolsInfo - - -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) - -func set_slot(name : String): - var loc = "%s%s" % [name,"ApplianceSpace"] - var singleslot = largeslots[loc] - if (singleslot.installedKitchenEquipment == null): # not installed - var bigslot = SLOT_EMPTY.instantiate() - bigslot.install_tools.connect(on_signal_received) - bigslot.set_data(singleslot) - slot.add_child(bigslot) - else: # installed but not used - if (!singleslot["installedKitchenEquipment"]["isCooking"]): - var bigslot = SLOT_NOT_USED.instantiate() - bigslot.set_data(singleslot) - slot.add_child(bigslot) - bigslot.uninstall_big_tool_button_pressed.connect(on_uninstall_signal_recived) - installedId.append(singleslot["installedKitchenEquipment"]["stateId"]) - installedName.append(singleslot["installedKitchenEquipment"]["equipmentName"]) - var dict = { "name" : singleslot["installedKitchenEquipment"]["equipmentName"], - "stateId" : singleslot["installedKitchenEquipment"]["stateId"], - "isCooking" : singleslot["installedKitchenEquipment"]["isCooking"], - "foodId" : null} - - installedToolsInfo.append(dict) - else: # cooking - var bigslot = SLOT_USED.instantiate() - bigslot.set_data(singleslot) - slot.add_child(bigslot) - var dict = { "name" : singleslot["installedKitchenEquipment"]["equipmentName"], - "stateId" : singleslot["installedKitchenEquipment"]["stateId"], - "isCooking" : singleslot["installedKitchenEquipment"]["isCooking"], - "foodId" : singleslot["installedKitchenEquipment"]["cookingFood"]["stateId"]} - - installedToolsInfo.append(dict) - -func on_signal_received(spaceNumber : int): - install_signal.emit(spaceNumber) - -func on_uninstall_signal_recived(spaceNumber : int): - uninstall_signal.emit(spaceNumber) diff --git a/frontend/Savor-22b/scenes/house/Kitchen/cook_menu.gd b/frontend/Savor-22b/scenes/house/Kitchen/cook_menu.gd deleted file mode 100644 index 8b3e26a5..00000000 --- a/frontend/Savor-22b/scenes/house/Kitchen/cook_menu.gd +++ /dev/null @@ -1,31 +0,0 @@ -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"] diff --git a/frontend/Savor-22b/scenes/house/Kitchen/cook_slot.gd b/frontend/Savor-22b/scenes/house/Kitchen/cook_slot.gd deleted file mode 100644 index 01ace768..00000000 --- a/frontend/Savor-22b/scenes/house/Kitchen/cook_slot.gd +++ /dev/null @@ -1,34 +0,0 @@ -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 && items.equipmentCategoryType != "main"): - print(items) - menus.append(items) - - refine_data() - -func refine_data(): - for menu1 in menus: - for big in SceneContext.installed_tool_info: - print(big) - if menu1["cookingFood"].stateId == big.foodId: - menus.erase(menu1) diff --git a/frontend/Savor-22b/scenes/house/Kitchen/tool_is_used.gd b/frontend/Savor-22b/scenes/house/Kitchen/tool_is_used.gd deleted file mode 100644 index 868e60e2..00000000 --- a/frontend/Savor-22b/scenes/house/Kitchen/tool_is_used.gd +++ /dev/null @@ -1,44 +0,0 @@ -extends Control - -@onready var button = $Button - -var data: Dictionary -var requiredtime -var menuname -var stateid - -var format_string = "[%s] 조리 중 - -남은 조리 블록 %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, stateid] - - -func set_data(info: Dictionary): - data = info - menuname = data["installedKitchenEquipment"]["cookingFood"]["name"] - stateid = data["installedKitchenEquipment"]["cookingFood"]["stateId"] - 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) diff --git a/frontend/Savor-22b/scenes/house/bigtool.gd b/frontend/Savor-22b/scenes/house/big_tool.gd similarity index 88% rename from frontend/Savor-22b/scenes/house/bigtool.gd rename to frontend/Savor-22b/scenes/house/big_tool.gd index 8f5ff3b9..bce9646b 100644 --- a/frontend/Savor-22b/scenes/house/bigtool.gd +++ b/frontend/Savor-22b/scenes/house/big_tool.gd @@ -11,7 +11,6 @@ var format_string = "%s func _ready(): update_text() - func update_text(): if button == null: return @@ -20,8 +19,7 @@ func update_text(): func set_data(info: Dictionary): data = info - print(data) - + -func _on_button_button_down(): +func _on_button_down(): button_pressed.emit(data.stateId) diff --git a/frontend/Savor-22b/scenes/house/bigtool.tscn b/frontend/Savor-22b/scenes/house/big_tool.tscn similarity index 94% rename from frontend/Savor-22b/scenes/house/bigtool.tscn rename to frontend/Savor-22b/scenes/house/big_tool.tscn index f04dba30..c426bf9a 100644 --- a/frontend/Savor-22b/scenes/house/bigtool.tscn +++ b/frontend/Savor-22b/scenes/house/big_tool.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=5 format=3 uid="uid://c53b0e4ogji84"] -[ext_resource type="Script" path="res://scenes/house/bigtool.gd" id="1_wba4e"] +[ext_resource type="Script" path="res://scenes/house/big_tool.gd" id="1_wba4e"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nr860"] bg_color = Color(0, 0, 0, 1) @@ -55,4 +55,4 @@ theme_override_styles/focus = SubResource("StyleBoxFlat_aermx") text = "조리도구 이름" text_overrun_behavior = 1 -[connection signal="button_down" from="Button" to="." method="_on_button_button_down"] +[connection signal="button_down" from="Button" to="." method="_on_button_down"] diff --git a/frontend/Savor-22b/scenes/house/big_tool_install_popup.gd b/frontend/Savor-22b/scenes/house/big_tool_install_popup.gd new file mode 100644 index 00000000..8db9bc95 --- /dev/null +++ b/frontend/Savor-22b/scenes/house/big_tool_install_popup.gd @@ -0,0 +1,43 @@ +extends Control + +signal install_signal +signal reload_signal + +const BigToolScn = preload("res://scenes/house/big_tool.tscn") + +@onready var slot = $B/M/V/S/G + +var big_tools: Array +var selected_state_id + +func _ready(): + load_tools() + set_tools() + +func load_tools(): + var kitchen_tools = SceneContext.user_state["inventoryState"]["kitchenEquipmentStateList"] + for tool in kitchen_tools: + if (tool.equipmentCategoryType == "main"): + big_tools.append(tool) + for used in SceneContext.installed_tool_id: + if (tool.stateId == used): + big_tools.erase(tool) + +func set_tools(): + for tool in big_tools: + var single_tool = BigToolScn.instantiate() + single_tool.set_data(tool) + single_tool.button_pressed.connect(get_stateId) + slot.add_child(single_tool) + +func get_stateId(stateId: String): + selected_state_id = stateId + +func _on_install_button_down(): + install_signal.emit(selected_state_id) + reload_signal.emit() + queue_free() + +func _on_close_button_down(): + reload_signal.emit() + queue_free() diff --git a/frontend/Savor-22b/scenes/house/bigtool_install_popup.tscn b/frontend/Savor-22b/scenes/house/big_tool_install_popup.tscn similarity index 94% rename from frontend/Savor-22b/scenes/house/bigtool_install_popup.tscn rename to frontend/Savor-22b/scenes/house/big_tool_install_popup.tscn index 737afdf3..456a01a9 100644 --- a/frontend/Savor-22b/scenes/house/bigtool_install_popup.tscn +++ b/frontend/Savor-22b/scenes/house/big_tool_install_popup.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://78boqlki8lh7"] -[ext_resource type="Script" path="res://scenes/house/bigtool_install_popup.gd" id="1_hncgm"] +[ext_resource type="Script" path="res://scenes/house/big_tool_install_popup.gd" id="1_hncgm"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_lve77"] bg_color = Color(1, 0.541176, 0, 1) @@ -99,5 +99,5 @@ theme_override_font_sizes/font_size = 35 theme_override_styles/normal = SubResource("StyleBoxFlat_winqn") text = " 선택한 도구 설치하기 " -[connection signal="button_down" from="B/M/V/H/CloseButton" to="." method="_on_close_button_button_down"] -[connection signal="button_down" from="B/M/V/H/InstallButton" to="." method="_on_install_button_button_down"] +[connection signal="button_down" from="B/M/V/H/CloseButton" to="." method="_on_close_button_down"] +[connection signal="button_down" from="B/M/V/H/InstallButton" to="." method="_on_install_button_down"] diff --git a/frontend/Savor-22b/scenes/house/bigtool_install_popup.gd b/frontend/Savor-22b/scenes/house/bigtool_install_popup.gd deleted file mode 100644 index 5ca3dd1a..00000000 --- a/frontend/Savor-22b/scenes/house/bigtool_install_popup.gd +++ /dev/null @@ -1,47 +0,0 @@ -extends Control - -signal install_signal -signal reload_signal - -const BIGTOOL = preload("res://scenes/house/bigtool.tscn") - -@onready var slot = $B/M/V/S/G - -var bigtools: Array -var selectedStateId - -func _ready(): - load_tools() - set_tools() - - -func load_tools(): - var kitchentools = SceneContext.user_state["inventoryState"]["kitchenEquipmentStateList"] - for tool in kitchentools: - if (tool.equipmentCategoryType == "main"): - bigtools.append(tool) - for used in SceneContext.installed_tool_id: - if (tool.stateId == used): - bigtools.erase(tool) - -func set_tools(): - for tool in bigtools: - var singletool = BIGTOOL.instantiate() - singletool.set_data(tool) - singletool.button_pressed.connect(get_stateId) - slot.add_child(singletool) - - -func get_stateId(stateId: String): - selectedStateId = stateId - - -func _on_install_button_button_down(): - install_signal.emit(selectedStateId) - reload_signal.emit() - queue_free() - - -func _on_close_button_button_down(): - reload_signal.emit() - queue_free() diff --git a/frontend/Savor-22b/scenes/house/Cook/cook_book.gd b/frontend/Savor-22b/scenes/house/cook/cook_book.gd similarity index 72% rename from frontend/Savor-22b/scenes/house/Cook/cook_book.gd rename to frontend/Savor-22b/scenes/house/cook/cook_book.gd index f77c567b..866a3e32 100644 --- a/frontend/Savor-22b/scenes/house/Cook/cook_book.gd +++ b/frontend/Savor-22b/scenes/house/cook/cook_book.gd @@ -1,16 +1,15 @@ extends Control -signal closeall +signal close_all signal reload_signal signal cook_started -const RECIPE = preload("res://scenes/house/Cook/recipe_available.tscn") +const RecipeAvailableScn = preload("res://scenes/house/cook/recipe_available.tscn") +const GqlQuery = preload("res://gql/query.gd") @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 @@ -24,13 +23,11 @@ func _ready(): 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() + var recipe = RecipeAvailableScn.instantiate() recipe.set_info(recipe_data) recipe.select_signal.connect(recipe_selected) grid.add_child(recipe) @@ -46,7 +43,6 @@ func filter_recipe(): 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: @@ -55,61 +51,46 @@ func remove_duplicates(array): return unique_elements - func recipe_selected(recipe_index): - SceneContext.selected_recipe_index = recipe_index + SceneContext.selected_recipe_index = recipe_index + 1 # 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() - + close_all.emit() func _on_cook_button_down(): - var ingarr = SceneContext.selected_ingredients - var toolarr = SceneContext.selected_tools - var ingstr - var toolstr + var ingredient_arr = SceneContext.selected_ingredients + var tool_arr = SceneContext.selected_tools + var ingredient_str + var tool_str - if ingarr.size() > 1 : - ingstr = "\", \"".join(ingarr) + if ingredient_arr.size() > 1 : + ingredient_str = "\", \"".join(ingredient_arr) else: - ingstr = ingarr[0] - if toolarr.size() > 1 : - toolstr = "\", \"".join(toolarr) + ingredient_str = ingredient_arr[0] + if tool_arr.size() > 1 : + tool_str = "\", \"".join(tool_arr) else: - toolstr = toolarr[0] - print(ingstr) - print(toolstr) + tool_str = tool_arr[0] - var gql_query = Gql_query.new() + var gql_query = GqlQuery.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) + "[\"%s\"]" % ingredient_str, + "[\"%s\"]" % tool_str], "{}") 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({}) ) diff --git a/frontend/Savor-22b/scenes/house/Cook/cook_book.tscn b/frontend/Savor-22b/scenes/house/cook/cook_book.tscn similarity index 96% rename from frontend/Savor-22b/scenes/house/Cook/cook_book.tscn rename to frontend/Savor-22b/scenes/house/cook/cook_book.tscn index 222be25c..5e96b6c9 100644 --- a/frontend/Savor-22b/scenes/house/Cook/cook_book.tscn +++ b/frontend/Savor-22b/scenes/house/cook/cook_book.tscn @@ -1,6 +1,7 @@ [gd_scene load_steps=7 format=3 uid="uid://bb0hth2o7k30q"] -[ext_resource type="Script" path="res://scenes/house/Cook/cook_book.gd" id="1_q1ejr"] +[ext_resource type="Script" path="res://scenes/house/cook/cook_book.gd" id="1_q1ejr"] +[ext_resource type="Script" path="res://scenes/house/recipe_book/recipe_book.gd" id="1_2wc5e"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tvose"] bg_color = Color(0.94902, 0.694118, 0.0784314, 1) diff --git a/frontend/Savor-22b/scenes/house/Cook/cook_started_popup.gd b/frontend/Savor-22b/scenes/house/cook/cook_started_popup.gd similarity index 98% rename from frontend/Savor-22b/scenes/house/Cook/cook_started_popup.gd rename to frontend/Savor-22b/scenes/house/cook/cook_started_popup.gd index 4221e65e..19b2e728 100644 --- a/frontend/Savor-22b/scenes/house/Cook/cook_started_popup.gd +++ b/frontend/Savor-22b/scenes/house/cook/cook_started_popup.gd @@ -6,8 +6,5 @@ signal close_book func _ready(): pass # Replace with function body. - - - func _on_button_pressed(): close_book.emit() diff --git a/frontend/Savor-22b/scenes/house/Cook/cook_started_popup.tscn b/frontend/Savor-22b/scenes/house/cook/cook_started_popup.tscn similarity index 96% rename from frontend/Savor-22b/scenes/house/Cook/cook_started_popup.tscn rename to frontend/Savor-22b/scenes/house/cook/cook_started_popup.tscn index 557fd989..d25a1a26 100644 --- a/frontend/Savor-22b/scenes/house/Cook/cook_started_popup.tscn +++ b/frontend/Savor-22b/scenes/house/cook/cook_started_popup.tscn @@ -1,6 +1,6 @@ [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"] +[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) diff --git a/frontend/Savor-22b/scenes/house/Cook/ingredient.gd b/frontend/Savor-22b/scenes/house/cook/ingredient.gd similarity index 57% rename from frontend/Savor-22b/scenes/house/Cook/ingredient.gd rename to frontend/Savor-22b/scenes/house/cook/ingredient.gd index 1cd59631..c538ed08 100644 --- a/frontend/Savor-22b/scenes/house/Cook/ingredient.gd +++ b/frontend/Savor-22b/scenes/house/cook/ingredient.gd @@ -6,44 +6,41 @@ signal select_tool(name : String) @onready var button = $Ing @onready var empty = $Empty -var ingname +var ingredient_name var format_string = "[%s] 사용 가능" -var isTool = false +var is_tool = false func _ready(): update_info() +func set_ingredient_name(name: String): + ingredient_name = name - - -func set_ingname(name: String): - ingname = name - -func get_ingname(): - return ingname +func get_ingredient_name(): + return ingredient_name func disable_button(): button.disabled = true empty.set_visible(true) button.text = "[%s] - " % [ingname] + " % [ingredient_name] func update_info(): - button.text = format_string % [ingname] + button.text = format_string % [ingredient_name] func set_toggled(state: bool): button.set_toggle_mode(state) func change_state_text(): button.text = "[%s] - 선택됨" % [ingname] + 선택됨" % [ingredient_name] func button_is_tool(): - isTool = true + is_tool = true func _on_ing_button_down(): - if (isTool): - select_tool.emit(ingname) + if (is_tool): + select_tool.emit(ingredient_name) else: - select_ingredient.emit(ingname) + select_ingredient.emit(ingredient_name) diff --git a/frontend/Savor-22b/scenes/house/Cook/ingredient.tscn b/frontend/Savor-22b/scenes/house/cook/ingredient.tscn similarity index 97% rename from frontend/Savor-22b/scenes/house/Cook/ingredient.tscn rename to frontend/Savor-22b/scenes/house/cook/ingredient.tscn index 3a4c0227..936ed8cc 100644 --- a/frontend/Savor-22b/scenes/house/Cook/ingredient.tscn +++ b/frontend/Savor-22b/scenes/house/cook/ingredient.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=6 format=3 uid="uid://c0ui8bu7d5c3c"] -[ext_resource type="Script" path="res://scenes/house/Cook/ingredient.gd" id="1_0odus"] +[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) diff --git a/frontend/Savor-22b/scenes/house/Cook/ingredient_bigtool.gd b/frontend/Savor-22b/scenes/house/cook/ingredient_big_tool.gd similarity index 65% rename from frontend/Savor-22b/scenes/house/Cook/ingredient_bigtool.gd rename to frontend/Savor-22b/scenes/house/cook/ingredient_big_tool.gd index 4eabda67..30e3f576 100644 --- a/frontend/Savor-22b/scenes/house/Cook/ingredient_bigtool.gd +++ b/frontend/Savor-22b/scenes/house/cook/ingredient_big_tool.gd @@ -5,39 +5,32 @@ signal select_tool(name : String) @onready var button = $Ing @onready var empty = $Empty -var ingname +var ingredient_name var format_string = "[%s] 사용 가능" - func _ready(): update_info() +func set_ingredient_name(name: String): + ingredient_name = name - - -func set_ingname(name: String): - ingname = name - - - -func get_ingname(): - return ingname +func get_ingredient_name(): + return ingredient_name func disable_button(): button.disabled = true empty.set_visible(true) button.text = "[%s] - " % [ingname] + " % [ingredient_name] func update_info(): - button.text = format_string % [ingname] + button.text = format_string % [ingredient_name] func set_toggled(state: bool): button.set_toggle_mode(state) - func _on_ing_button_down(): for tool in SceneContext.installed_tool_info: - if tool.name == ingname && !tool.isCooking: + if tool.name == ingredient_name && !tool.isCooking: SceneContext.selected_tools.append(tool.stateId) diff --git a/frontend/Savor-22b/scenes/house/Cook/ingredient_bigtool.tscn b/frontend/Savor-22b/scenes/house/cook/ingredient_big_tool.tscn similarity index 93% rename from frontend/Savor-22b/scenes/house/Cook/ingredient_bigtool.tscn rename to frontend/Savor-22b/scenes/house/cook/ingredient_big_tool.tscn index bb95f6a4..e957c2d8 100644 --- a/frontend/Savor-22b/scenes/house/Cook/ingredient_bigtool.tscn +++ b/frontend/Savor-22b/scenes/house/cook/ingredient_big_tool.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=6 format=3 uid="uid://cyua25nh21x1d"] -[ext_resource type="Script" path="res://scenes/house/Cook/ingredient_bigtool.gd" id="1_mwbt6"] +[ext_resource type="Script" path="res://scenes/house/cook/ingredient_big_tool.gd" id="1_mwbt6"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jup0i"] bg_color = Color(0.94902, 0.596078, 0.0784314, 1) @@ -33,7 +33,7 @@ corner_radius_top_right = 20 corner_radius_bottom_right = 20 corner_radius_bottom_left = 20 -[node name="ingredient_bigtool" type="Control"] +[node name="ingredient_big_tool" type="Control"] custom_minimum_size = Vector2(180, 110) layout_mode = 3 anchors_preset = 0 diff --git a/frontend/Savor-22b/scenes/house/Cook/recipe_available.gd b/frontend/Savor-22b/scenes/house/cook/recipe_available.gd similarity index 58% rename from frontend/Savor-22b/scenes/house/Cook/recipe_available.gd rename to frontend/Savor-22b/scenes/house/cook/recipe_available.gd index cedc048e..4c381fdd 100644 --- a/frontend/Savor-22b/scenes/house/Cook/recipe_available.gd +++ b/frontend/Savor-22b/scenes/house/cook/recipe_available.gd @@ -2,43 +2,35 @@ extends Control signal select_signal(child_index: int) -const ING = preload("res://scenes/house/Cook/ingredient.tscn") -const ING_BT = preload("res://scenes/house/Cook/ingredient_bigtool.tscn") -const SELECT_POPUP = preload("res://scenes/house/Cook/select_popup.tscn") +const IngredientScn = preload("res://scenes/house/cook/ingredient.tscn") +const IngredientBigToolScn = preload("res://scenes/house/cook/ingredient_big_tool.tscn") +const SelectPopupScn = preload("res://scenes/house/cook/select_popup.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 +@onready var req_block = $panel/M/V/Blockreq @onready var button = $panel @onready var popup = $Popups - var info var refrigerator = SceneContext.user_state["inventoryState"]["refrigeratorStateList"] var toolbox = SceneContext.user_state["inventoryState"]["kitchenEquipmentStateList"] -var requiredIngredients = [] -var requiredTools = [] - -var availableIngredients = [] -var availableTools = [] - -var availableList = [] - - -var name_format = "[%s] 레시피"; +var required_ingredients = [] +var required_tools = [] +var available_ingredients = [] +var available_tools = [] +var available_list = [] +var name_format = "[%s] 레시피" var block_format = "소요 블록 %s 블록" func _ready(): button.add_to_group("RecipeGroup") update_info() - - func set_info(recipe: Dictionary): info = recipe func update_info(): - # Setting names in UI var name = info.name name = name.left(name.length() -4) @@ -46,78 +38,76 @@ func update_info(): # Getting exist ing/foods for ing in info["ingredientIDList"]: - var ing_ins = ING.instantiate() + var ing_ins = IngredientScn.instantiate() ing_ins.name = ing["name"] - ing_ins.set_ingname(ing["name"]) - requiredIngredients.append(ing["name"]) + ing_ins.set_ingredient_name(ing["name"]) + required_ingredients.append(ing["name"]) ing_ins.select_ingredient.connect(select_ingredients) ingredients.add_child(ing_ins) for ing in info["foodIDList"]: - var ing_ins = ING.instantiate() + var ing_ins = IngredientScn.instantiate() ing_ins.name = ing["name"] - ing_ins.set_ingname(ing["name"]) - requiredIngredients.append(ing["name"]) + ing_ins.set_ingredient_name(ing["name"]) + required_ingredients.append(ing["name"]) ing_ins.select_ingredient.connect(select_ingredients) ingredients.add_child(ing_ins) # Getting exist tools for tool in info["requiredKitchenEquipmentCategoryList"]: if tool["name"] in SceneContext.installed_tool_name: - var tool_ins = ING_BT.instantiate() + var tool_ins = IngredientBigToolScn.instantiate() tool_ins.name = tool["name"] - tool_ins.set_ingname(tool["name"]) - requiredTools.append(tool["name"]) + tool_ins.set_ingredient_name(tool["name"]) + required_tools.append(tool["name"]) tool_ins.select_tool.connect(select_tools) tools.add_child(tool_ins) else: - var tool_ins = ING.instantiate() + var tool_ins = IngredientScn.instantiate() tool_ins.name = tool["name"] - tool_ins.set_ingname(tool["name"]) - requiredTools.append(tool["name"]) + tool_ins.set_ingredient_name(tool["name"]) + required_tools.append(tool["name"]) tool_ins.button_is_tool() tool_ins.select_tool.connect(select_tools) tools.add_child(tool_ins) # Getting exist item infos // if not, disable button for ing in refrigerator: - for req in requiredIngredients: + for req in required_ingredients: if (ing["name"] == req): - availableIngredients.append(ing) - availableList.append(req) + available_ingredients.append(ing) + available_list.append(req) for tool in toolbox: - var full_toolname = tool["equipmentName"] - var toolname = full_toolname.split(" ") - var tooltype - if (full_toolname.contains("고급")): - tooltype = toolname[1] + var full_tool_name = tool["equipmentName"] + var tool_name = full_tool_name.split(" ") + var tool_type + if (full_tool_name.contains("고급")): + tool_type = tool_name[1] else: - tooltype = toolname[0] + tool_type = tool_name[0] - for req in requiredTools: - if(tooltype == req): - availableTools.append(tool) - availableList.append(req) + for req in required_tools: + if(tool_type == req): + available_tools.append(tool) + available_list.append(req) - remove_duplicates(availableList) + remove_duplicates(available_list) for ing in ingredients.get_children(): - var ing_name = ing.get_ingname() - if ing_name not in availableList: + var ingredient_name = ing.get_ingredient_name() + if ingredient_name not in available_list: ing.disable_button() - for tool in tools.get_children(): - var tool_name = tool.get_ingname() - if tool_name not in availableList: + var tool_name = tool.get_ingredient_name() + if tool_name not in available_list: tool.disable_button() - set_block_req() func set_block_req(): - reqblock.text = block_format % [ info["requiredBlockCount"] ] + req_block.text = block_format % [ info["requiredBlockCount"] ] func remove_duplicates(array): var unique_elements = [] @@ -135,35 +125,33 @@ func _on_panel_button_down(): select_signal.emit(info.id) func select_ingredients(name : String): - var proper_ings = [] - for ing in availableIngredients: + var proper_ingredients = [] + for ing in available_ingredients: if ing["name"] == name: - proper_ings.append(ing) - + proper_ingredients.append(ing) - var select_popup = SELECT_POPUP.instantiate() + var select_popup = SelectPopupScn.instantiate() popup.add_child(select_popup) - select_popup.set_info(proper_ings) - var mousepos = get_local_mouse_position() + Vector2(-200, -300) - select_popup.set_position(mousepos) + select_popup.set_info(proper_ingredients) + var mouse_pos = get_local_mouse_position() + Vector2(-200, -300) + select_popup.set_position(mouse_pos) select_popup.disable_toggled.connect(disable_toggle) select_popup.enable_toggled.connect(enable_toggle) func select_tools(name : String): var proper_tools = [] - for tool in availableTools: + for tool in available_tools: if tool["equipmentName"] == name: proper_tools.append(tool) if tool["equipmentName"] == "고급 " + name: proper_tools.append(tool) - - var select_popup = SELECT_POPUP.instantiate() - select_popup.is_tool() + var select_popup = SelectPopupScn.instantiate() + select_popup.set_is_tool() popup.add_child(select_popup) select_popup.set_info(proper_tools) - var mousepos = get_local_mouse_position() + Vector2(-200, -100) - select_popup.set_position(mousepos) + var mouse_pos = get_local_mouse_position() + Vector2(-200, -100) + select_popup.set_position(mouse_pos) select_popup.disable_toggled.connect(disable_toggle) select_popup.enable_toggled.connect(enable_toggle) diff --git a/frontend/Savor-22b/scenes/house/Cook/recipe_available.tscn b/frontend/Savor-22b/scenes/house/cook/recipe_available.tscn similarity index 98% rename from frontend/Savor-22b/scenes/house/Cook/recipe_available.tscn rename to frontend/Savor-22b/scenes/house/cook/recipe_available.tscn index f81f0d40..e4e34262 100644 --- a/frontend/Savor-22b/scenes/house/Cook/recipe_available.tscn +++ b/frontend/Savor-22b/scenes/house/cook/recipe_available.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=6 format=3 uid="uid://3in2bhd5bnpb"] -[ext_resource type="Script" path="res://scenes/house/Cook/recipe_available.gd" id="1_1f486"] +[ext_resource type="Script" path="res://scenes/house/cook/recipe_available.gd" id="1_1f486"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kmgu8"] bg_color = Color(0, 0, 0, 1) diff --git a/frontend/Savor-22b/scenes/house/Cook/select_button.gd b/frontend/Savor-22b/scenes/house/cook/select_button.gd similarity index 86% rename from frontend/Savor-22b/scenes/house/Cook/select_button.gd rename to frontend/Savor-22b/scenes/house/cook/select_button.gd index a19cf6c5..465737b3 100644 --- a/frontend/Savor-22b/scenes/house/Cook/select_button.gd +++ b/frontend/Savor-22b/scenes/house/cook/select_button.gd @@ -1,20 +1,17 @@ extends Button -signal selected_var(stateId : String) +signal selected_var(state_id : String) var format_string = "%s 등급 [%s개]" var info - func _ready(): pass - func set_ing_info(info : Array): self.info = info text = format_string % [info[0].grade, info.size()] - func _on_button_down(): selected_var.emit(info[0].stateId) diff --git a/frontend/Savor-22b/scenes/house/Cook/select_button.tscn b/frontend/Savor-22b/scenes/house/cook/select_button.tscn similarity index 90% rename from frontend/Savor-22b/scenes/house/Cook/select_button.tscn rename to frontend/Savor-22b/scenes/house/cook/select_button.tscn index e3363441..20dfe620 100644 --- a/frontend/Savor-22b/scenes/house/Cook/select_button.tscn +++ b/frontend/Savor-22b/scenes/house/cook/select_button.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://b30crxtayccx0"] -[ext_resource type="Script" path="res://scenes/house/Cook/select_button.gd" id="1_bebb3"] +[ext_resource type="Script" path="res://scenes/house/cook/select_button.gd" id="1_bebb3"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pvlfv"] bg_color = Color(0, 0, 0, 1) diff --git a/frontend/Savor-22b/scenes/house/Cook/select_popup.gd b/frontend/Savor-22b/scenes/house/cook/select_popup.gd similarity index 57% rename from frontend/Savor-22b/scenes/house/Cook/select_popup.gd rename to frontend/Savor-22b/scenes/house/cook/select_popup.gd index 759cd720..ab4f2901 100644 --- a/frontend/Savor-22b/scenes/house/Cook/select_popup.gd +++ b/frontend/Savor-22b/scenes/house/cook/select_popup.gd @@ -3,50 +3,49 @@ extends Control signal disable_toggled signal enable_toggled -const BUTTON = preload("res://scenes/house/Cook/select_button.tscn") -const TOOL_BUTTON = preload("res://scenes/house/Cook/select_tool_button.tscn") +const SelectButtonScn = preload("res://scenes/house/cook/select_button.tscn") +const SelectToolButtonScn = preload("res://scenes/house/cook/select_tool_button.tscn") @onready var panel = $Panel @onready var ingredient_slot = $Panel/M/V/S/Ingredients @onready var title = $Panel/M/V/Title -var ings -var ingname +var ingredients +var ingredient_name var ranks = [] -var isTool = false +var is_tool = false var selected func _ready(): pass - func search_rank(info : Array): for ing in info: ranks.append(ing["grade"]) func rank_info(rank : String): var result = [] - for ing in ings: + for ing in ingredients: if ing["grade"] == rank: result.append(ing) return result func create_button(info : Array): - var rank_button = BUTTON.instantiate() + var rank_button = SelectButtonScn.instantiate() rank_button.selected_var.connect(set_selected) rank_button.set_ing_info(info) ingredient_slot.add_child(rank_button) func create_tool_button(info : Array): - var tool_button = TOOL_BUTTON.instantiate() + var tool_button = SelectToolButtonScn.instantiate() tool_button.selected_var.connect(set_selected) tool_button.set_tool_info(info) ingredient_slot.add_child(tool_button) func set_info(info : Array): - if (!isTool): - ings = info - ingname = ings[0]["name"] + if (!is_tool): + ingredients = info + ingredient_name = ingredients[0]["name"] search_rank(info) ranks = remove_duplicates(ranks) @@ -54,20 +53,21 @@ func set_info(info : Array): var rank_ing = rank_info(rank) create_button(rank_ing) else: - ings = info + ingredients = info var rares = [] var normals = [] - for tool in ings: - ingname = ings[0]["equipmentName"] - if tool["equipmentName"] == ingname && !tool.isCooking: + for tool in ingredients: + ingredient_name = ingredients[0]["equipmentName"] + if tool["equipmentName"] == ingredient_name && !tool.isCooking: normals.append(tool) - if tool["equipmentName"] == "고급 " + ingname && !tool.isCooking: + if tool["equipmentName"] == "고급 " + ingredient_name && !tool.isCooking: rares.append(tool) - create_tool_button(rares) - create_tool_button(normals) + if (rares): + create_tool_button(rares) + if (normals): + create_tool_button(normals) - title.text = "현재 소유중인 [%s]" % [ingname] - + title.text = "현재 소유중인 [%s]" % [ingredient_name] func remove_duplicates(array): var unique_elements = [] @@ -78,22 +78,21 @@ func remove_duplicates(array): return unique_elements func stay_selected(): - enable_toggled.emit(ingname) + enable_toggled.emit(ingredient_name) queue_free() func _on_panel_pressed(): - disable_toggled.emit(ingname) + disable_toggled.emit(ingredient_name) queue_free() -func is_tool(): - isTool = true - -func set_selected(stateId : String): - selected = stateId +func set_is_tool(): + is_tool = true +func set_selected(state_id : String): + selected = state_id -func _on_button_button_down(): - if(isTool): +func _on_button_down(): + if(is_tool): SceneContext.selected_tools.append(selected) else: SceneContext.selected_ingredients.append(selected) diff --git a/frontend/Savor-22b/scenes/house/Cook/select_popup.tscn b/frontend/Savor-22b/scenes/house/cook/select_popup.tscn similarity index 96% rename from frontend/Savor-22b/scenes/house/Cook/select_popup.tscn rename to frontend/Savor-22b/scenes/house/cook/select_popup.tscn index 49df53a9..acba7bac 100644 --- a/frontend/Savor-22b/scenes/house/Cook/select_popup.tscn +++ b/frontend/Savor-22b/scenes/house/cook/select_popup.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://cdj3ppg7fw3ee"] -[ext_resource type="Script" path="res://scenes/house/Cook/select_popup.gd" id="1_g7ytm"] +[ext_resource type="Script" path="res://scenes/house/cook/select_popup.gd" id="1_g7ytm"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_p7oiq"] bg_color = Color(0.94902, 0.596078, 0.0784314, 1) @@ -82,4 +82,4 @@ theme_override_styles/normal = SubResource("StyleBoxFlat_61pm2") text = "선택한 등급으로 설정" [connection signal="pressed" from="Panel" to="." method="_on_panel_pressed"] -[connection signal="button_down" from="Panel/M/V/Button" to="." method="_on_button_button_down"] +[connection signal="button_down" from="Panel/M/V/Button" to="." method="_on_button_down"] diff --git a/frontend/Savor-22b/scenes/house/Cook/select_tool_button.gd b/frontend/Savor-22b/scenes/house/cook/select_tool_button.gd similarity index 86% rename from frontend/Savor-22b/scenes/house/Cook/select_tool_button.gd rename to frontend/Savor-22b/scenes/house/cook/select_tool_button.gd index f5e48240..2011e8a5 100644 --- a/frontend/Savor-22b/scenes/house/Cook/select_tool_button.gd +++ b/frontend/Savor-22b/scenes/house/cook/select_tool_button.gd @@ -1,20 +1,16 @@ extends Button -signal selected_var(stateId : String) +signal selected_var(state_id : String) var format_string = "%s 등급 [%s개]" var info - func _ready(): pass func set_tool_info(info : Array): - self.info = info text = "%s [%s개]" % [info[0].equipmentName, info.size()] func _on_button_down(): selected_var.emit(info[0].stateId) - - diff --git a/frontend/Savor-22b/scenes/house/Cook/select_tool_button.tscn b/frontend/Savor-22b/scenes/house/cook/select_tool_button.tscn similarity index 90% rename from frontend/Savor-22b/scenes/house/Cook/select_tool_button.tscn rename to frontend/Savor-22b/scenes/house/cook/select_tool_button.tscn index 2677e54e..15ef3342 100644 --- a/frontend/Savor-22b/scenes/house/Cook/select_tool_button.tscn +++ b/frontend/Savor-22b/scenes/house/cook/select_tool_button.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://cn67b2nj61lc1"] -[ext_resource type="Script" path="res://scenes/house/Cook/select_tool_button.gd" id="1_hw7e6"] +[ext_resource type="Script" path="res://scenes/house/cook/select_tool_button.gd" id="1_hw7e6"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pvlfv"] bg_color = Color(0, 0, 0, 1) diff --git a/frontend/Savor-22b/scenes/house/food.gd b/frontend/Savor-22b/scenes/house/food.gd index 8a6524b9..b77a9370 100644 --- a/frontend/Savor-22b/scenes/house/food.gd +++ b/frontend/Savor-22b/scenes/house/food.gd @@ -1,27 +1,21 @@ extends Panel -@onready var foodname = $M/V/Name -@onready var fooddesc = $M/V/Desc - +@onready var food_name = $M/V/Name +@onready var food_description = $M/V/Desc var info - - var desc_format_string = "%s : %s %s : %s %s" func _ready(): _update_info() - func _update_info(): - if foodname == null: + if food_name == null: return - foodname.text = info.name - fooddesc.text = info.stateId + food_name.text = info.name + food_description.text = info.stateId func set_info(info: Dictionary): self.info = info - - - + \ No newline at end of file diff --git a/frontend/Savor-22b/scenes/house/house.gd b/frontend/Savor-22b/scenes/house/house.gd new file mode 100644 index 00000000..bff681f9 --- /dev/null +++ b/frontend/Savor-22b/scenes/house/house.gd @@ -0,0 +1,207 @@ +extends Control + +const HouseInventoryScn = preload("res://scenes/house/house_inventory.tscn") +const AskPopupScn = preload("res://scenes/shop/ask_popup.tscn") +const DonePopupScn = preload("res://scenes/shop/done_popup.tscn") +const RecipeBookScn = preload("res://scenes/house/recipe_book/recipe_book.tscn") +const CookSlogScn = preload("res://scenes/house/kitchen/cook_slot.tscn") +const BigToolSlotScn = preload("res://scenes/house/kitchen/big_tool_slot.tscn") +const BigToolInstallPopupScn = preload("res://scenes/house/big_tool_install_popup.tscn") +const CookBookScn = preload("res://scenes/house/Cook/cook_book.tscn") +const CookStartedPopup = preload("res://scenes/house/Cook/cook_started_popup.tscn") +const ConfirmPopupScn = preload("res://scenes/common/prefabs/confirm_popup.tscn") +const GqlQuery = preload("res://gql/query.gd") + +@onready var sub_scene = $M/V/sub_scene +@onready var popup = $Popups +@onready var confirmPopup = $ConfirmPopup + +var selected_space +var cook_book + +func _ready(): + load_kitchen() + +func _on_inventory_button_down(): + clear_popup() + reload_sub_scene() + + var inventory = HouseInventoryScn.instantiate() + inventory.buy_signal.connect(buy_popup) + inventory.close_all.connect(clear_popup) + sub_scene.add_child(inventory) + +func buy_popup(): + var ask_popup = AskPopupScn.instantiate() + ask_popup.set_item_name(SceneContext.selected_item_name) + ask_popup.buy_button_down.connect(buy_action) + ask_popup.set_position(Vector2(900,600)) + popup.add_child(ask_popup) + +func buy_action(): + clear_popup() + buy_tool() + + var done_popup = DonePopupScn.instantiate() + done_popup.set_position(Vector2(900,600)) + popup.add_child(done_popup) + +func buy_tool(): + var item_num = SceneContext.selected_item_index + var gql_query = GqlQuery.new() + var query_string = gql_query.buy_kitchen_equipment_query_format.format([ + "\"%s\"" % GlobalSigner.signer.GetPublicKey(), + item_num], "{}") + + var query_executor = SvrGqlClient.raw(query_string) + query_executor.graphql_response.connect( + func(data): + var unsigned_tx = data["data"]["createAction_BuyKitchenEquipment"] + var signature = GlobalSigner.sign(unsigned_tx) + var mutation_executor = SvrGqlClient.raw_mutation(gql_query.stage_tx_query_format % [unsigned_tx, signature]) + add_child(mutation_executor) + mutation_executor.run({}) + ) + add_child(query_executor) + query_executor.run({}) + +func clear_popup(): + if is_instance_valid(popup): + for pop in popup.get_children(): + pop.queue_free() + load_kitchen() + +func reload_sub_scene(): + if is_instance_valid(sub_scene): + for scene in sub_scene.get_children(): + scene.queue_free() + Intro._query_user_state() + Intro._query_kitchen_slot_state() + +func _on_recipe_button_down(): + clear_popup() + reload_sub_scene() + var recipe_book_area = MarginContainer.new() + #setting margincontainer constants + recipe_book_area.add_theme_constant_override("margin_top", 20) + recipe_book_area.add_theme_constant_override("margin_bottom", 20) + recipe_book_area.add_theme_constant_override("margin_left", 140) + recipe_book_area.add_theme_constant_override("margin_right", 140) + sub_scene.add_child(recipe_book_area) + + var recipe_book = RecipeBookScn.instantiate() + recipe_book.close_all.connect(clear_popup) + + recipe_book_area.add_child(recipe_book) + +func _on_farm_button_down(): + get_tree().change_scene_to_file("res://scenes/farm/farm.tscn") + +func _on_village_button_down(): + get_tree().change_scene_to_file("res://scenes/village/village_view.tscn") + +func _on_refresh_button_down(): + clear_popup() + reload_sub_scene() + load_kitchen() + +func load_kitchen(): + reload_sub_scene() + + var kitchen_area = VBoxContainer.new() + kitchen_area.add_theme_constant_override("separation", 20) + sub_scene.add_child(kitchen_area) + + var small_slot = CookSlogScn.instantiate() + kitchen_area.add_child(small_slot) + + var large_slot = BigToolSlotScn.instantiate() + large_slot.install_signal.connect(on_empty_slot_pressed) + large_slot.uninstall_signal.connect(on_uninstall_slot_pressed) + kitchen_area.add_child(large_slot) + +func on_empty_slot_pressed(spaceNumber : int): + var large_installer = BigToolInstallPopupScn.instantiate() + + var installer_area = MarginContainer.new() + + installer_area.add_theme_constant_override("margin_top", 20) + installer_area.add_theme_constant_override("margin_bottom", 320) + installer_area.add_theme_constant_override("margin_left", 150) + installer_area.add_theme_constant_override("margin_right", 150) + sub_scene.add_child(installer_area) + installer_area.add_child(large_installer) + large_installer.install_signal.connect(install_tool) + large_installer.reload_signal.connect(load_kitchen) + + selected_space = spaceNumber + +func install_tool(stateId : String): + var gql_query = GqlQuery.new() + var query_string = gql_query.install_kitchen_equipment_query_format.format([ + "\"%s\"" % GlobalSigner.signer.GetPublicKey(), + "\"%s\"" % stateId, selected_space], "{}") + + var query_executor = SvrGqlClient.raw(query_string) + query_executor.graphql_response.connect( + func(data): + var unsigned_tx = data["data"]["createAction_InstallKitchenEquipmentAction"] + var signature = GlobalSigner.sign(unsigned_tx) + var mutation_executor = SvrGqlClient.raw_mutation(gql_query.stage_tx_query_format % [unsigned_tx, signature]) + add_child(mutation_executor) + mutation_executor.run({}) + ) + add_child(query_executor) + query_executor.run({}) + +func _on_cook_button_down(): + var cook_book_area = MarginContainer.new() + #setting margincontainer constants + cook_book_area.add_theme_constant_override("margin_top", 20) + cook_book_area.add_theme_constant_override("margin_bottom", 20) + cook_book_area.add_theme_constant_override("margin_left", 140) + cook_book_area.add_theme_constant_override("margin_right", 140) + sub_scene.add_child(cook_book_area) + + cook_book = CookBookScn.instantiate() + cook_book.close_all.connect(clear_popup) + cook_book.reload_signal.connect(reload_cookbook) + cook_book.cook_started.connect(cook_started_popup) + + cook_book_area.add_child(cook_book) + +func reload_cookbook(): + clear_popup() + _on_cook_button_down() + +func cook_started_popup(): + var start_popup = CookStartedPopup.instantiate() + start_popup.close_book.connect(_on_refresh_button_down) + start_popup.set_position(Vector2(900,600)) + sub_scene.add_child(start_popup) + +func on_uninstall_slot_pressed(spaceNumber: int): + var confirmPopupResource = ConfirmPopupScn.instantiate() + + confirmPopupResource.set_label("설치된 조리도구를 제거하시겠습니까?") + confirmPopupResource.ok_button_clicked_signal.connect(uninsatll_big_tool.bind(spaceNumber)) + confirmPopup.add_child(confirmPopupResource) + +func uninsatll_big_tool(spaceNumber: int): + var gql_query = GqlQuery.new() + var query_string = gql_query.uninstall_kitchen_equipment_query_format.format([ + "\"%s\"" % GlobalSigner.signer.GetPublicKey(), + "%s" % spaceNumber], "{}") + + var query_executor = SvrGqlClient.raw(query_string) + query_executor.graphql_response.connect( + func(data): + var unsigned_tx = data["data"]["createAction_UninstallKitchenEquipmentActionQuery"] + var signature = GlobalSigner.sign(unsigned_tx) + var mutation_executor = SvrGqlClient.raw_mutation(gql_query.stage_tx_query_format % [unsigned_tx, signature]) + add_child(mutation_executor) + mutation_executor.run({}) + ) + add_child(query_executor) + query_executor.run({}) + diff --git a/frontend/Savor-22b/scenes/house/house.tscn b/frontend/Savor-22b/scenes/house/house.tscn index 374d3bab..283d27df 100644 --- a/frontend/Savor-22b/scenes/house/house.tscn +++ b/frontend/Savor-22b/scenes/house/house.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://bpobpaan3tquv"] -[ext_resource type="Script" path="res://scripts/scenes/house.gd" id="1_suicg"] +[ext_resource type="Script" path="res://scenes/house/house.gd" id="1_suicg"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n3yrr"] bg_color = Color(0.32549, 1, 0.290196, 1) @@ -107,14 +107,14 @@ theme_override_font_sizes/font_size = 45 theme_override_styles/normal = SubResource("StyleBoxFlat_n3yrr") text = "+ 음식 조리하기" -[node name="subscene" type="MarginContainer" parent="M/V"] +[node name="sub_scene" type="MarginContainer" parent="M/V"] layout_mode = 2 size_flags_vertical = 3 theme_override_constants/margin_left = 20 theme_override_constants/margin_right = 20 theme_override_constants/margin_bottom = 20 -[node name="VBoxContainer" type="VBoxContainer" parent="M/V/subscene"] +[node name="VBoxContainer" type="VBoxContainer" parent="M/V/sub_scene"] layout_mode = 2 [node name="Popups" type="Control" parent="."] @@ -130,9 +130,9 @@ offset_top = 300.0 offset_right = 640.0 offset_bottom = 340.0 -[connection signal="button_down" from="M/V/menus/V/FarmButton" to="." method="_on_farm_button_button_down"] -[connection signal="button_down" from="M/V/menus/V/VillageButton" to="." method="_on_village_button_button_down"] -[connection signal="button_down" from="M/V/menus/V/RecipeButton" to="." method="_on_recipe_button_button_down"] -[connection signal="button_down" from="M/V/menus/V/InventoryButton" to="." method="_on_inventory_button_button_down"] -[connection signal="button_down" from="M/V/menus/V/RefreshButton" to="." method="_on_refresh_button_button_down"] -[connection signal="button_down" from="M/V/menus/M/CookButton" to="." method="_on_cook_button_button_down"] +[connection signal="button_down" from="M/V/menus/V/FarmButton" to="." method="_on_farm_button_down"] +[connection signal="button_down" from="M/V/menus/V/VillageButton" to="." method="_on_village_button_down"] +[connection signal="button_down" from="M/V/menus/V/RecipeButton" to="." method="_on_recipe_button_down"] +[connection signal="button_down" from="M/V/menus/V/InventoryButton" to="." method="_on_inventory_button_down"] +[connection signal="button_down" from="M/V/menus/V/RefreshButton" to="." method="_on_refresh_button_down"] +[connection signal="button_down" from="M/V/menus/M/CookButton" to="." method="_on_cook_button_down"] diff --git a/frontend/Savor-22b/scenes/house/house_inventory.gd b/frontend/Savor-22b/scenes/house/house_inventory.gd index 9d6c7304..968a66d9 100644 --- a/frontend/Savor-22b/scenes/house/house_inventory.gd +++ b/frontend/Savor-22b/scenes/house/house_inventory.gd @@ -1,31 +1,28 @@ extends Control -const KITCHEN_TOOLS = preload("res://scenes/house/kitchentools.tscn") -const KITCHEN_SHOP = preload("res://scenes/house/kitchenshop.tscn") -const REFRIGERATOR = preload("res://scenes/house/refrigerator.tscn") +const KitchenToolsScn = preload("res://scenes/house/kitchen_tools.tscn") +const KitchenShopScn = preload("res://scenes/house/kitchen_shop.tscn") +const Refrigerator = preload("res://scenes/house/refrigerator.tscn") @onready var panel = $M/V/Panel/C -signal buysignal -signal closeall +signal buy_signal +signal close_all func _ready(): _on_tools_button_down() - - - func _on_tools_button_down(): clear_popup() - var kitchens = KITCHEN_TOOLS.instantiate() - kitchens.closetab.connect(closetab) + var kitchens = KitchenToolsScn.instantiate() + kitchens.close_tab.connect(close_tab) panel.add_child(kitchens) func _on_shop_button_down(): clear_popup() - var kitchens = KITCHEN_SHOP.instantiate() - kitchens.closetab.connect(closetab) - kitchens.buysignal.connect(popup) + var kitchens = KitchenShopScn.instantiate() + kitchens.close_tab.connect(close_tab) + kitchens.buy_signal.connect(popup) panel.add_child(kitchens) func clear_popup(): @@ -33,16 +30,15 @@ func clear_popup(): for pop in panel.get_children(): pop.queue_free() -func closetab(): - closeall.emit() +func close_tab(): + close_all.emit() queue_free() func popup(): - buysignal.emit() - + buy_signal.emit() -func _on_ings_button_down(): +func _on_ingredients_button_down(): clear_popup() - var refrigerator = REFRIGERATOR.instantiate() - refrigerator.closetab.connect(closetab) + var refrigerator = Refrigerator.instantiate() + refrigerator.close_tab.connect(close_tab) panel.add_child(refrigerator) diff --git a/frontend/Savor-22b/scenes/house/house_inventory.tscn b/frontend/Savor-22b/scenes/house/house_inventory.tscn index 826e159a..46fbf5ff 100644 --- a/frontend/Savor-22b/scenes/house/house_inventory.tscn +++ b/frontend/Savor-22b/scenes/house/house_inventory.tscn @@ -87,5 +87,5 @@ grow_horizontal = 2 grow_vertical = 2 [connection signal="button_down" from="M/V/submenu/H/tools" to="." method="_on_tools_button_down"] -[connection signal="button_down" from="M/V/submenu/H/ings" to="." method="_on_ings_button_down"] +[connection signal="button_down" from="M/V/submenu/H/ings" to="." method="_on_ingredients_button_down"] [connection signal="button_down" from="M/V/submenu/H/shop" to="." method="_on_shop_button_down"] diff --git a/frontend/Savor-22b/scenes/install_kitchen_equipment.tscn b/frontend/Savor-22b/scenes/house/install_kitchen_equipment.tscn similarity index 100% rename from frontend/Savor-22b/scenes/install_kitchen_equipment.tscn rename to frontend/Savor-22b/scenes/house/install_kitchen_equipment.tscn diff --git a/frontend/Savor-22b/scenes/house/kitchen/big_tool_slot.gd b/frontend/Savor-22b/scenes/house/kitchen/big_tool_slot.gd new file mode 100644 index 00000000..928feaf9 --- /dev/null +++ b/frontend/Savor-22b/scenes/house/kitchen/big_tool_slot.gd @@ -0,0 +1,76 @@ +extends Control + +signal install_signal +signal uninstall_signal + +const ToolSlotEmptyScn = preload("res://scenes/house/kitchen/tool_slot_empty.tscn") +const ToolNotUsedScn = preload("res://scenes/house/kitchen/tool_not_used.tscn") +const ToolIsUsedScn = preload("res://scenes/house/kitchen/tool_is_used.tscn") + +@onready var slot = $P/M/V/Slot + +var large_slots: Dictionary +var large_tools: Array +var installed_id: Array +var installed_name: Array +var installed_tools_info: Array +var selected_space: int + +func _ready(): + load_data() + +# Setting Slots + set_slot("first") + set_slot("second") + set_slot("third") + + SceneContext.installed_tool_id = installed_id + SceneContext.installed_tool_name = installed_name + SceneContext.installed_tool_info = installed_tools_info + +func load_data(): + large_slots = SceneContext.user_kitchen_state["villageState"]["houseState"]["kitchenState"] + + var tools = SceneContext.user_state["inventoryState"]["kitchenEquipmentStateList"] + for tool in tools: + if(tool.equipmentCategoryType == "main"): + large_tools.append(tool) + +func set_slot(name : String): + var loc = "%s%s" % [name,"ApplianceSpace"] + var single_slot = large_slots[loc] + if (single_slot.installedKitchenEquipment == null): # not installed + var big_slot = ToolSlotEmptyScn.instantiate() + big_slot.install_tools.connect(on_signal_received) + big_slot.set_data(single_slot) + slot.add_child(big_slot) + else: # installed but not used + if (!single_slot["installedKitchenEquipment"]["isCooking"]): + var big_slot = ToolNotUsedScn.instantiate() + big_slot.set_data(single_slot) + slot.add_child(big_slot) + big_slot.uninstall_big_tool_button_pressed.connect(on_uninstall_signal_received) + installed_id.append(single_slot["installedKitchenEquipment"]["stateId"]) + installed_name.append(single_slot["installedKitchenEquipment"]["equipmentName"]) + var dict = { "name" : single_slot["installedKitchenEquipment"]["equipmentName"], + "stateId" : single_slot["installedKitchenEquipment"]["stateId"], + "isCooking" : single_slot["installedKitchenEquipment"]["isCooking"], + "foodId" : null} + + installed_tools_info.append(dict) + else: # cooking + var big_slot = ToolIsUsedScn.instantiate() + big_slot.set_data(single_slot) + slot.add_child(big_slot) + var dict = { "name" : single_slot["installedKitchenEquipment"]["equipmentName"], + "stateId" : single_slot["installedKitchenEquipment"]["stateId"], + "isCooking" : single_slot["installedKitchenEquipment"]["isCooking"], + "foodId" : single_slot["installedKitchenEquipment"]["cookingFood"]["stateId"]} + + installed_tools_info.append(dict) + +func on_signal_received(spaceNumber : int): + install_signal.emit(spaceNumber) + +func on_uninstall_signal_received(spaceNumber : int): + uninstall_signal.emit(spaceNumber) diff --git a/frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.tscn b/frontend/Savor-22b/scenes/house/kitchen/big_tool_slot.tscn similarity index 95% rename from frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.tscn rename to frontend/Savor-22b/scenes/house/kitchen/big_tool_slot.tscn index 1bff958f..ad3db8e8 100644 --- a/frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.tscn +++ b/frontend/Savor-22b/scenes/house/kitchen/big_tool_slot.tscn @@ -1,6 +1,6 @@ [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"] +[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) diff --git a/frontend/Savor-22b/scenes/house/kitchen/cook_menu.gd b/frontend/Savor-22b/scenes/house/kitchen/cook_menu.gd new file mode 100644 index 00000000..d6134d68 --- /dev/null +++ b/frontend/Savor-22b/scenes/house/kitchen/cook_menu.gd @@ -0,0 +1,29 @@ +extends Control + +@onready var description = $P/Desc + +var data +var required_time +var food_name + +var format_string = "[%s] 요리 조리중 +[%s 블록 남음]" + +func _ready(): + update_label() + +func update_label(): + if description == null: + return + + description.text = format_string % [food_name, required_time] + +func set_data(info: Dictionary): + data = info + + # set end times + var end_time = data["cookingEndBlockIndex"] + var current_time = SceneContext.block_index["blockQuery"]["blocks"][0]["index"] + required_time = end_time - current_time + + food_name = data["cookingFood"]["name"] diff --git a/frontend/Savor-22b/scenes/house/Kitchen/cook_menu.tscn b/frontend/Savor-22b/scenes/house/kitchen/cook_menu.tscn similarity index 94% rename from frontend/Savor-22b/scenes/house/Kitchen/cook_menu.tscn rename to frontend/Savor-22b/scenes/house/kitchen/cook_menu.tscn index 06022318..656550ac 100644 --- a/frontend/Savor-22b/scenes/house/Kitchen/cook_menu.tscn +++ b/frontend/Savor-22b/scenes/house/kitchen/cook_menu.tscn @@ -1,6 +1,6 @@ [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"] +[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) diff --git a/frontend/Savor-22b/scenes/house/kitchen/cook_slot.gd b/frontend/Savor-22b/scenes/house/kitchen/cook_slot.gd new file mode 100644 index 00000000..72988eaa --- /dev/null +++ b/frontend/Savor-22b/scenes/house/kitchen/cook_slot.gd @@ -0,0 +1,52 @@ +extends Control + +const CookMenuScn = preload("res://scenes/house/Kitchen/cook_menu.tscn") + +@onready var slot = $P/M/V/S/Slot + +var menus: Array +var large_slots: Dictionary +var large_arr: Array #큰 조리도구의 메뉴 + +func _ready(): + load_data() + + for menu in menus: + var single_menu = CookMenuScn.instantiate() + single_menu.set_data(menu) + slot.add_child(single_menu) + +func load_data(): + var refrigerator = SceneContext.user_state["inventoryState"]["kitchenEquipmentStateList"] + for items in refrigerator: + if(items.isCooking && items.equipmentCategoryType != "main"): + menus.append(items) + + refine_data() + +func refine_data(): + for menu1 in menus: + for big in SceneContext.installed_tool_info: + if menu1["cookingFood"].stateId == big.foodId: + menus.erase(menu1) + large_slots = SceneContext.user_kitchen_state["villageState"]["houseState"]["kitchenState"] + + var slot1 = large_slots["firstApplianceSpace"] + var slot2 = large_slots["secondApplianceSpace"] + var slot3 = large_slots["thirdApplianceSpace"] + + if (slot1["installedKitchenEquipment"]!= null): + var obj1 = slot1["installedKitchenEquipment"]["stateId"] + large_arr.append(obj1) + if (slot2["installedKitchenEquipment"] != null): + var obj2 = slot2["installedKitchenEquipment"]["stateId"] + large_arr.append(obj2) + if (slot3["installedKitchenEquipment"] != null): + var obj3 = slot3["installedKitchenEquipment"]["stateId"] + large_arr.append(obj3) + + for menu in menus: + for data in large_arr: + if data == menu["stateId"]: + menus.erase(menu) + diff --git a/frontend/Savor-22b/scenes/house/Kitchen/cook_slot.tscn b/frontend/Savor-22b/scenes/house/kitchen/cook_slot.tscn similarity index 95% rename from frontend/Savor-22b/scenes/house/Kitchen/cook_slot.tscn rename to frontend/Savor-22b/scenes/house/kitchen/cook_slot.tscn index f65f7397..e70be5ac 100644 --- a/frontend/Savor-22b/scenes/house/Kitchen/cook_slot.tscn +++ b/frontend/Savor-22b/scenes/house/kitchen/cook_slot.tscn @@ -1,6 +1,6 @@ [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"] +[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) diff --git a/frontend/Savor-22b/scenes/house/kitchen/tool_is_used.gd b/frontend/Savor-22b/scenes/house/kitchen/tool_is_used.gd new file mode 100644 index 00000000..aa8c02e2 --- /dev/null +++ b/frontend/Savor-22b/scenes/house/kitchen/tool_is_used.gd @@ -0,0 +1,40 @@ +extends Control + +@onready var button = $Button + +var data: Dictionary +var required_time +var menu_name +var state_id + +var format_string = "[%s] 조리 중 + +남은 조리 블록 %s 블록 +[%s]" + +func _ready(): + update_text() + +func update_text(): + if button == null: + return + + var end_time = data["installedKitchenEquipment"]["cookingEndBlockIndex"] + var current_time = SceneContext.block_index["blockQuery"]["blocks"][0]["index"] + var time_left = end_time - current_time + button.text = format_string % [menu_name, time_left, state_id] + +func set_data(info: Dictionary): + data = info + menu_name = data["installedKitchenEquipment"]["cookingFood"]["name"] + state_id = data["installedKitchenEquipment"]["cookingFood"]["stateId"] + time_info() + +func time_info(): + var recipe = SceneContext.recipe["recipe"] + + for single_recipe in recipe: + var recipe_name = single_recipe["resultFood"]["name"] + if(recipe_name == menu_name): + required_time = single_recipe["requiredBlockCount"] + diff --git a/frontend/Savor-22b/scenes/house/Kitchen/tool_is_used.tscn b/frontend/Savor-22b/scenes/house/kitchen/tool_is_used.tscn similarity index 94% rename from frontend/Savor-22b/scenes/house/Kitchen/tool_is_used.tscn rename to frontend/Savor-22b/scenes/house/kitchen/tool_is_used.tscn index 42fbc383..8982e42e 100644 --- a/frontend/Savor-22b/scenes/house/Kitchen/tool_is_used.tscn +++ b/frontend/Savor-22b/scenes/house/kitchen/tool_is_used.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://b7f85oe54slb5"] -[ext_resource type="Script" path="res://scenes/house/Kitchen/tool_is_used.gd" id="1_fyt0q"] +[ext_resource type="Script" path="res://scenes/house/kitchen/tool_is_used.gd" id="1_fyt0q"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jwjl7"] bg_color = Color(0.94902, 0.694118, 0.0784314, 1) diff --git a/frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.gd b/frontend/Savor-22b/scenes/house/kitchen/tool_not_used.gd similarity index 99% rename from frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.gd rename to frontend/Savor-22b/scenes/house/kitchen/tool_not_used.gd index b5384d4f..2339e353 100644 --- a/frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.gd +++ b/frontend/Savor-22b/scenes/house/kitchen/tool_not_used.gd @@ -14,18 +14,14 @@ var format_string = "[%s] 도구 설치됨 func _ready(): update_text() - func update_text(): if button == null: return button.text = format_string % [data["installedKitchenEquipment"]["equipmentName"]] - func set_data(info: Dictionary): data = info - func _on_uninstall_button_pressed(): uninstall_big_tool_button_pressed.emit(data.spaceNumber) - diff --git a/frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.tscn b/frontend/Savor-22b/scenes/house/kitchen/tool_not_used.tscn similarity index 94% rename from frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.tscn rename to frontend/Savor-22b/scenes/house/kitchen/tool_not_used.tscn index ed1b7596..e0fa6d34 100644 --- a/frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.tscn +++ b/frontend/Savor-22b/scenes/house/kitchen/tool_not_used.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://bg4tb16c7n00g"] -[ext_resource type="Script" path="res://scenes/house/Kitchen/tool_not_used.gd" id="1_s4ktm"] +[ext_resource type="Script" path="res://scenes/house/kitchen/tool_not_used.gd" id="1_s4ktm"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pjjvv"] bg_color = Color(0.32549, 1, 0.290196, 1) diff --git a/frontend/Savor-22b/scenes/house/Kitchen/tool_slot_empty.gd b/frontend/Savor-22b/scenes/house/kitchen/tool_slot_empty.gd similarity index 82% rename from frontend/Savor-22b/scenes/house/Kitchen/tool_slot_empty.gd rename to frontend/Savor-22b/scenes/house/kitchen/tool_slot_empty.gd index 3c87158b..c9c4d56c 100644 --- a/frontend/Savor-22b/scenes/house/Kitchen/tool_slot_empty.gd +++ b/frontend/Savor-22b/scenes/house/kitchen/tool_slot_empty.gd @@ -7,10 +7,8 @@ var data func _ready(): pass - - func set_data(info : Dictionary): data = info -func _on_button_button_down(): +func _on_button_down(): install_tools.emit(data.spaceNumber) diff --git a/frontend/Savor-22b/scenes/house/Kitchen/tool_slot_empty.tscn b/frontend/Savor-22b/scenes/house/kitchen/tool_slot_empty.tscn similarity index 92% rename from frontend/Savor-22b/scenes/house/Kitchen/tool_slot_empty.tscn rename to frontend/Savor-22b/scenes/house/kitchen/tool_slot_empty.tscn index 48d8418e..f0ee2dc7 100644 --- a/frontend/Savor-22b/scenes/house/Kitchen/tool_slot_empty.tscn +++ b/frontend/Savor-22b/scenes/house/kitchen/tool_slot_empty.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://jm7hptg5twbn"] -[ext_resource type="Script" path="res://scenes/house/Kitchen/tool_slot_empty.gd" id="1_7et8y"] +[ext_resource type="Script" path="res://scenes/house/kitchen/tool_slot_empty.gd" id="1_7et8y"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_q6vgf"] bg_color = Color(0.32549, 1, 0.290196, 1) @@ -37,4 +37,4 @@ text = "비어있음 조리도구 설치 가능" -[connection signal="button_down" from="Button" to="." method="_on_button_button_down"] +[connection signal="button_down" from="Button" to="." method="_on_button_down"] diff --git a/frontend/Savor-22b/scenes/house/kitchen_shop.gd b/frontend/Savor-22b/scenes/house/kitchen_shop.gd new file mode 100644 index 00000000..a63dea37 --- /dev/null +++ b/frontend/Savor-22b/scenes/house/kitchen_shop.gd @@ -0,0 +1,27 @@ +extends Control + +const ToolScn = preload("res://scenes/house/tool.tscn") + +@onready var grid = $M/V/Items/G + +signal buy_signal +signal close_tab + +var list + +func _ready(): + list = SceneContext.shop["kitchenEquipments"] + + for tool in list: + var tool_panel = ToolScn.instantiate() + tool_panel.set_slot_type() + tool_panel.set_info(tool) + tool_panel.buy_signal.connect(popup) + grid.add_child(tool_panel) + +func popup(): + buy_signal.emit() + +func _on_close_button_down(): + close_tab.emit() + queue_free() diff --git a/frontend/Savor-22b/scenes/house/kitchenshop.tscn b/frontend/Savor-22b/scenes/house/kitchen_shop.tscn similarity index 94% rename from frontend/Savor-22b/scenes/house/kitchenshop.tscn rename to frontend/Savor-22b/scenes/house/kitchen_shop.tscn index b79b913d..06ad7f42 100644 --- a/frontend/Savor-22b/scenes/house/kitchenshop.tscn +++ b/frontend/Savor-22b/scenes/house/kitchen_shop.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://bsj3rpdgusned"] -[ext_resource type="Script" path="res://scenes/house/kitchenshop.gd" id="1_aqlr8"] +[ext_resource type="Script" path="res://scenes/house/kitchen_shop.gd" id="1_aqlr8"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_rk6tx"] bg_color = Color(1, 0.541176, 0, 1) diff --git a/frontend/Savor-22b/scenes/house/kitchentools.gd b/frontend/Savor-22b/scenes/house/kitchen_tools.gd similarity index 54% rename from frontend/Savor-22b/scenes/house/kitchentools.gd rename to frontend/Savor-22b/scenes/house/kitchen_tools.gd index 8f64fbcd..5401697d 100644 --- a/frontend/Savor-22b/scenes/house/kitchentools.gd +++ b/frontend/Savor-22b/scenes/house/kitchen_tools.gd @@ -1,10 +1,10 @@ extends Control -const TOOL = preload("res://scenes/house/tool.tscn") +const ToolScn = preload("res://scenes/house/tool.tscn") @onready var grid = $M/V/Items/S/G -signal closetab +signal close_tab var tools @@ -12,13 +12,11 @@ func _ready(): tools = SceneContext.user_state.inventoryState["kitchenEquipmentStateList"] for tool in tools: - var toolpanel = TOOL.instantiate() - toolpanel.set_info(tool) - grid.add_child(toolpanel) - - + var tool_panel = ToolScn.instantiate() + tool_panel.set_info(tool) + grid.add_child(tool_panel) func _on_close_button_down(): - closetab.emit() + close_tab.emit() queue_free() diff --git a/frontend/Savor-22b/scenes/house/kitchentools.tscn b/frontend/Savor-22b/scenes/house/kitchen_tools.tscn similarity index 95% rename from frontend/Savor-22b/scenes/house/kitchentools.tscn rename to frontend/Savor-22b/scenes/house/kitchen_tools.tscn index e3d0e636..835d4f93 100644 --- a/frontend/Savor-22b/scenes/house/kitchentools.tscn +++ b/frontend/Savor-22b/scenes/house/kitchen_tools.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://cwqquis7w31g7"] -[ext_resource type="Script" path="res://scenes/house/kitchentools.gd" id="1_bkji1"] +[ext_resource type="Script" path="res://scenes/house/kitchen_tools.gd" id="1_bkji1"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_rk6tx"] bg_color = Color(1, 0.541176, 0, 1) diff --git a/frontend/Savor-22b/scenes/house/kitchenshop.gd b/frontend/Savor-22b/scenes/house/kitchenshop.gd deleted file mode 100644 index e8856dee..00000000 --- a/frontend/Savor-22b/scenes/house/kitchenshop.gd +++ /dev/null @@ -1,28 +0,0 @@ -extends Control - -const TOOL = preload("res://scenes/house/tool.tscn") - -@onready var grid = $M/V/Items/G - -signal buysignal -signal closetab - -var list - -func _ready(): - list = SceneContext.shop["kitchenEquipments"] - - for tool in list: - var toolpanel = TOOL.instantiate() - toolpanel.set_slottype() - toolpanel.set_info(tool) - toolpanel.buysignal.connect(popup) - grid.add_child(toolpanel) - -func popup(): - buysignal.emit() - - -func _on_close_button_down(): - closetab.emit() - queue_free() diff --git a/frontend/Savor-22b/scenes/house/recipe_book/ingredient.gd b/frontend/Savor-22b/scenes/house/recipe_book/ingredient.gd new file mode 100644 index 00000000..0cb4aea1 --- /dev/null +++ b/frontend/Savor-22b/scenes/house/recipe_book/ingredient.gd @@ -0,0 +1,14 @@ +extends Control + +@onready var button = $Ing +var ingredient_name +var format_string = "[%s]" + +func _ready(): + update_info() + +func set_ingredient_name(name: String): + ingredient_name = name + +func update_info(): + button.text = format_string % [ingredient_name] diff --git a/frontend/Savor-22b/scenes/house/recipebook/ingredient.tscn b/frontend/Savor-22b/scenes/house/recipe_book/ingredient.tscn similarity index 89% rename from frontend/Savor-22b/scenes/house/recipebook/ingredient.tscn rename to frontend/Savor-22b/scenes/house/recipe_book/ingredient.tscn index 29c0484f..dd9df9a4 100644 --- a/frontend/Savor-22b/scenes/house/recipebook/ingredient.tscn +++ b/frontend/Savor-22b/scenes/house/recipe_book/ingredient.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://me2nvitswvki"] -[ext_resource type="Script" path="res://scenes/house/recipebook/ingredient.gd" id="1_g877k"] +[ext_resource type="Script" path="res://scenes/house/recipe_book/ingredient.gd" id="1_g877k"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jup0i"] bg_color = Color(0.94902, 0.596078, 0.0784314, 1) diff --git a/frontend/Savor-22b/scenes/house/recipebook/recipe.gd b/frontend/Savor-22b/scenes/house/recipe_book/recipe.gd similarity index 59% rename from frontend/Savor-22b/scenes/house/recipebook/recipe.gd rename to frontend/Savor-22b/scenes/house/recipe_book/recipe.gd index 3f8e2774..5b8111d3 100644 --- a/frontend/Savor-22b/scenes/house/recipebook/recipe.gd +++ b/frontend/Savor-22b/scenes/house/recipe_book/recipe.gd @@ -1,27 +1,22 @@ extends Control -const ING = preload("res://scenes/house/recipebook/ingredient.tscn") +const IngredientScn = preload("res://scenes/house/recipe_book/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 +@onready var req_block = $panel/M/V/Blockreq var info - - -var name_format = "[%s] 레시피"; +var name_format = "[%s] 레시피" var block_format = "소요 블록 %s 블록" func _ready(): update_info() - - func set_info(recipe: Dictionary): info = recipe func update_info(): - # Setting names in UI var name = info.name name = name.left(name.length() -4) @@ -29,21 +24,21 @@ func update_info(): # Getting exist for ing in info["ingredientIDList"]: - var ing_ins = ING.instantiate() - ing_ins.set_ingname(ing["name"]) + var ing_ins = IngredientScn.instantiate() + ing_ins.set_ingredient_name(ing["name"]) ingredients.add_child(ing_ins) for ing in info["foodIDList"]: - var ing_ins = ING.instantiate() - ing_ins.set_ingname(ing["name"]) + var ing_ins = IngredientScn.instantiate() + ing_ins.set_ingredient_name(ing["name"]) ingredients.add_child(ing_ins) for tool in info["requiredKitchenEquipmentCategoryList"]: - var tool_ins = ING.instantiate() - tool_ins.set_ingname(tool["name"]) + var tool_ins = IngredientScn.instantiate() + tool_ins.set_ingredient_name(tool["name"]) tools.add_child(tool_ins) set_block_req() func set_block_req(): - reqblock.text = block_format % [ info["requiredBlockCount"] ] + req_block.text = block_format % [ info["requiredBlockCount"] ] diff --git a/frontend/Savor-22b/scenes/house/recipebook/recipe.tscn b/frontend/Savor-22b/scenes/house/recipe_book/recipe.tscn similarity index 93% rename from frontend/Savor-22b/scenes/house/recipebook/recipe.tscn rename to frontend/Savor-22b/scenes/house/recipe_book/recipe.tscn index 01d8185d..419689cf 100644 --- a/frontend/Savor-22b/scenes/house/recipebook/recipe.tscn +++ b/frontend/Savor-22b/scenes/house/recipe_book/recipe.tscn @@ -1,7 +1,7 @@ [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"] +[ext_resource type="StyleBox" uid="uid://b2nqsuwp80vsg" path="res://scenes/house/recipe_book/recipe_style_box_flat.tres" id="1_8ipq3"] +[ext_resource type="Script" path="res://scenes/house/recipe_book/recipe.gd" id="2_jlc81"] [node name="Recipe" type="Control"] custom_minimum_size = Vector2(700, 550) diff --git a/frontend/Savor-22b/scenes/house/recipe_book/recipe_book.gd b/frontend/Savor-22b/scenes/house/recipe_book/recipe_book.gd new file mode 100644 index 00000000..60f5dc24 --- /dev/null +++ b/frontend/Savor-22b/scenes/house/recipe_book/recipe_book.gd @@ -0,0 +1,19 @@ +extends Control + +signal close_all + +const RecipeScn = preload("res://scenes/house/recipe_book/recipe.tscn") + +@onready var grid = $background/M/V/S/G + +var recipe_list = SceneContext.recipe["recipe"] + +func _ready(): + for single_recipe in recipe_list: + var recipe = RecipeScn.instantiate() + recipe.set_info(single_recipe) + grid.add_child(recipe) + +func _on_close_button_down(): + queue_free() + close_all.emit() diff --git a/frontend/Savor-22b/scenes/house/recipebook/recipebook.tscn b/frontend/Savor-22b/scenes/house/recipe_book/recipe_book.tscn similarity index 96% rename from frontend/Savor-22b/scenes/house/recipebook/recipebook.tscn rename to frontend/Savor-22b/scenes/house/recipe_book/recipe_book.tscn index 07059575..6ac5bbf9 100644 --- a/frontend/Savor-22b/scenes/house/recipebook/recipebook.tscn +++ b/frontend/Savor-22b/scenes/house/recipe_book/recipe_book.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://cpx04yry0xj16"] -[ext_resource type="Script" path="res://scenes/house/recipebook/recipebook.gd" id="1_8dllv"] +[ext_resource type="Script" path="res://scenes/house/recipe_book/recipe_book.gd" id="1_8dllv"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tvose"] bg_color = Color(0.94902, 0.694118, 0.0784314, 1) diff --git a/frontend/Savor-22b/scenes/house/recipebook/recipebook_preset.tscn b/frontend/Savor-22b/scenes/house/recipe_book/recipe_book_preset.tscn similarity index 99% rename from frontend/Savor-22b/scenes/house/recipebook/recipebook_preset.tscn rename to frontend/Savor-22b/scenes/house/recipe_book/recipe_book_preset.tscn index e9cb933f..9a68395d 100644 --- a/frontend/Savor-22b/scenes/house/recipebook/recipebook_preset.tscn +++ b/frontend/Savor-22b/scenes/house/recipe_book/recipe_book_preset.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=12 format=3 uid="uid://blowb3mc1asp1"] -[ext_resource type="StyleBox" uid="uid://b2nqsuwp80vsg" path="res://scenes/house/recipebook/recipe_style_box_flat.tres" id="1_txpcy"] +[ext_resource type="StyleBox" uid="uid://b2nqsuwp80vsg" path="res://scenes/house/recipe_book/recipe_style_box_flat.tres" id="1_txpcy"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tvose"] bg_color = Color(0.94902, 0.694118, 0.0784314, 1) diff --git a/frontend/Savor-22b/scenes/house/recipebook/recipe_style_box_flat.tres b/frontend/Savor-22b/scenes/house/recipe_book/recipe_style_box_flat.tres similarity index 100% rename from frontend/Savor-22b/scenes/house/recipebook/recipe_style_box_flat.tres rename to frontend/Savor-22b/scenes/house/recipe_book/recipe_style_box_flat.tres diff --git a/frontend/Savor-22b/scenes/house/recipebook/ingredient.gd b/frontend/Savor-22b/scenes/house/recipebook/ingredient.gd deleted file mode 100644 index eb09a137..00000000 --- a/frontend/Savor-22b/scenes/house/recipebook/ingredient.gd +++ /dev/null @@ -1,20 +0,0 @@ -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] diff --git a/frontend/Savor-22b/scenes/house/recipebook/recipebook.gd b/frontend/Savor-22b/scenes/house/recipebook/recipebook.gd deleted file mode 100644 index deca668e..00000000 --- a/frontend/Savor-22b/scenes/house/recipebook/recipebook.gd +++ /dev/null @@ -1,22 +0,0 @@ -extends Control - -signal closeall - -const RECIPE = preload("res://scenes/house/recipebook/recipe.tscn") - -@onready var grid = $background/M/V/S/G - -var recipelist = SceneContext.recipe["recipe"] - -func _ready(): - for singlerecipe in recipelist: - var recipe = RECIPE.instantiate() - recipe.set_info(singlerecipe) - grid.add_child(recipe) - - - - -func _on_close_button_down(): - queue_free() - closeall.emit() diff --git a/frontend/Savor-22b/scenes/house/refrigerator.gd b/frontend/Savor-22b/scenes/house/refrigerator.gd index 1e08dcb6..56d2a073 100644 --- a/frontend/Savor-22b/scenes/house/refrigerator.gd +++ b/frontend/Savor-22b/scenes/house/refrigerator.gd @@ -1,10 +1,10 @@ extends Control -const FOOD = preload("res://scenes/house/food.tscn") +const FoodScn = preload("res://scenes/house/food.tscn") @onready var grid = $M/V/Items/S/G -signal closetab +signal close_tab var foods @@ -12,13 +12,11 @@ func _ready(): foods = SceneContext.user_state.inventoryState["refrigeratorStateList"] for food in foods: - var foodpanel = FOOD.instantiate() - foodpanel.set_info(food) - grid.add_child(foodpanel) - - + var food_panel = FoodScn.instantiate() + food_panel.set_info(food) + grid.add_child(food_panel) func _on_close_button_down(): - closetab.emit() + close_tab.emit() queue_free() diff --git a/frontend/Savor-22b/scenes/house/tool.gd b/frontend/Savor-22b/scenes/house/tool.gd index ddd62ab8..420ea334 100644 --- a/frontend/Savor-22b/scenes/house/tool.gd +++ b/frontend/Savor-22b/scenes/house/tool.gd @@ -1,13 +1,13 @@ extends Panel -@onready var toolname = $M/V/Name -@onready var tooldesc = $M/V/Desc -@onready var buybutton = $M/V/Buy +@onready var tool_name = $M/V/Name +@onready var tool_description = $M/V/Desc +@onready var buy_button = $M/V/Buy -signal buysignal +signal buy_signal var info -var isshop: bool = false +var is_shop: bool = false var desc_format_string = "%s : %s %s : %s %s" @@ -15,29 +15,26 @@ var desc_format_string = "%s : %s func _ready(): _update_info() - func _update_info(): - if toolname == null: + if tool_name == null: return - if (isshop): - toolname.text = info.name - tooldesc.text = desc_format_string % [info.categoryType, info.categoryLabel, "Price", info.price, "BBG"] - buybutton.visible = true + if (is_shop): + tool_name.text = info.name + tool_description.text = desc_format_string % [info.categoryType, info.categoryLabel, "Price", info.price, "BBG"] + buy_button.visible = true else: - toolname.text = info.equipmentName - tooldesc.text = info.stateId + tool_name.text = info.equipmentName + tool_description.text = info.stateId func set_info(info: Dictionary): self.info = info -func set_slottype(): - self.isshop = true +func set_slot_type(): + self.is_shop = true _update_info() - - func _on_buy_button_down(): SceneContext.selected_item_index = info.id SceneContext.selected_item_name = info.name - buysignal.emit() + buy_signal.emit() diff --git a/frontend/Savor-22b/scripts/scenes/intro.gd b/frontend/Savor-22b/scenes/intro/intro.gd similarity index 86% rename from frontend/Savor-22b/scripts/scenes/intro.gd rename to frontend/Savor-22b/scenes/intro/intro.gd index 71079fc8..ec726e3c 100644 --- a/frontend/Savor-22b/scripts/scenes/intro.gd +++ b/frontend/Savor-22b/scenes/intro/intro.gd @@ -1,7 +1,6 @@ extends Control func _ready(): - print("intro scene ready") _all_ready() func _all_ready(): @@ -13,16 +12,12 @@ func _all_ready(): _query_kitchen_slot_state() get_current_block() - print("block index") - print(SceneContext.block_index) - -func _on_quit_button_button_down(): - print("quit button down") + +func _on_quit_button__down(): get_tree().quit() -func _on_play_button_button_down(): - print("play button down") - get_tree().change_scene_to_file("res://scenes/select_village.tscn") +func _on_play_button_down(): + get_tree().change_scene_to_file("res://scenes/village/select_village.tscn") func _query_villages(): var query = GQLQuery.new("villages").set_props([ @@ -38,7 +33,6 @@ func _query_villages(): "owner", ]), ]) - #print(query.serialize()) var query_executor = SvrGqlClient.query('query', {}, query) query_executor.graphql_response.connect( func(data): @@ -51,7 +45,6 @@ func _query_assets(): var query = GQLQuery.new("asset").set_args({ "signer_address": "address", }) - #print(query.serialize()) var query_executor = SvrGqlClient.query( 'query', { @@ -68,8 +61,7 @@ func _query_assets(): }) func _query_user_state(): - #print("signer address: %s" % GlobalSigner.signer_address) - var query = GQLQuery.new("userState").set_args({ + var query = GQLQuery.new("userState").set_args({ "signer_address": "address", }).set_props([ GQLQuery.new("inventoryState").set_props([ @@ -143,21 +135,20 @@ func _query_user_state(): ]) ]) ]) - #print(query.serialize()) - var query_executor = SvrGqlClient.query( + var query_executor = SvrGqlClient.query( 'query', { "signer_address": "String!", }, query) - query_executor.graphql_response.connect( - func(data): - SceneContext.set_user_state(data) - ) - add_child(query_executor) - query_executor.run({ - "signer_address": GlobalSigner.signer_address - }) + query_executor.graphql_response.connect( + func(data): + SceneContext.set_user_state(data) + ) + add_child(query_executor) + query_executor.run({ + "signer_address": GlobalSigner.signer_address + }) func _query_shop(): var query = GQLQuery.new("shop").set_props([ @@ -176,7 +167,6 @@ func _query_shop(): "price" ]) ]) - #print(query.serialize()) var query_executor = SvrGqlClient.query( 'query',{}, query) @@ -209,7 +199,6 @@ func _query_recipe(): "name", ]) ]) - #print(query.serialize()) var query_executor = SvrGqlClient.query( 'query',{}, query) @@ -221,8 +210,7 @@ func _query_recipe(): query_executor.run({}) func _query_kitchen_slot_state(): - #print("signer address: %s" % GlobalSigner.signer_address) - + var query = GQLQuery.new("userState").set_args({ "signer_address": "address", }).set_props([ @@ -318,8 +306,7 @@ func _query_kitchen_slot_state(): ]), ]) - #print(query.serialize()) - + var query_executor = SvrGqlClient.query( 'query', { @@ -330,7 +317,6 @@ func _query_kitchen_slot_state(): query_executor.graphql_response.connect( func(data): - #print(data) SceneContext.set_user_kitchen_state(data) ) @@ -352,12 +338,13 @@ func get_current_block(): } }" - #print(query_string) - - var query_executor = SvrGqlClient2.raw(query_string) - query_executor.graphql_response.connect(func(data): - print("gql response: ", data) - SceneContext.get_current_block(data) + var query_executor = SvrExplorerGqlClient.raw(query_string) + query_executor.graphql_response.connect( + func(data): + SceneContext.get_current_block(data) ) add_child(query_executor) query_executor.run({}) + +func _on_quit_button_down(): + pass # Replace with function body. diff --git a/frontend/Savor-22b/scenes/intro.tscn b/frontend/Savor-22b/scenes/intro/intro.tscn similarity index 92% rename from frontend/Savor-22b/scenes/intro.tscn rename to frontend/Savor-22b/scenes/intro/intro.tscn index f95dcad7..9d66b3ad 100644 --- a/frontend/Savor-22b/scenes/intro.tscn +++ b/frontend/Savor-22b/scenes/intro/intro.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://cg773cnsx4rb0"] -[ext_resource type="Script" path="res://scripts/scenes/intro.gd" id="1_0m54y"] -[ext_resource type="Script" path="res://scenes/addressdisplay.gd" id="2_63u45"] +[ext_resource type="Script" path="res://scenes/intro/intro.gd" id="1_0m54y"] +[ext_resource type="Script" path="res://scenes/common/prefabs/address_display.gd" id="2_63u45"] [node name="Intro" type="Control"] layout_mode = 3 @@ -122,5 +122,5 @@ placeholder_text = "address_info" max_length = 100 script = ExtResource("2_63u45") -[connection signal="button_down" from="QuitButtonContainer/Button" to="." method="_on_quit_button_button_down"] -[connection signal="button_down" from="PlayButtonContainer/Button" to="." method="_on_play_button_button_down"] +[connection signal="button_down" from="QuitButtonContainer/Button" to="." method="_on_quit_button_down"] +[connection signal="button_down" from="PlayButtonContainer/Button" to="." method="_on_play_button_down"] diff --git a/frontend/Savor-22b/scenes/inventory/SlotModel.gd b/frontend/Savor-22b/scenes/inventory/SlotModel.gd deleted file mode 100644 index ed3c9928..00000000 --- a/frontend/Savor-22b/scenes/inventory/SlotModel.gd +++ /dev/null @@ -1,5 +0,0 @@ -class_name SlotModel; - -var title: String; -var icon: String; -var count: int; diff --git a/frontend/Savor-22b/scenes/inventory/Inventory.gd b/frontend/Savor-22b/scenes/inventory/inventory.gd similarity index 63% rename from frontend/Savor-22b/scenes/inventory/Inventory.gd rename to frontend/Savor-22b/scenes/inventory/inventory.gd index 45b2ed72..132ef9f0 100644 --- a/frontend/Savor-22b/scenes/inventory/Inventory.gd +++ b/frontend/Savor-22b/scenes/inventory/inventory.gd @@ -1,38 +1,38 @@ extends Node -class_name Inventory; +class_name Inventory -const kind_scene = preload("res://scenes/inventory/kind.tscn"); -const slot_scene = preload("res://scenes/inventory/slot.tscn"); +const KindScn = preload("res://scenes/inventory/kind.tscn") +const SlotScn = preload("res://scenes/inventory/slot.tscn") # Input: # Godot이 지원하지 않아서 주석으로 타입을 남깁니다. # Dictionary[String, Array[SlotModel]] -var data: Dictionary; +var data: Dictionary # State: -var current_kind: String; +var current_kind: String # Derived: -var kinds: Array; -var current_slots: Array; +var kinds: Array +var current_slots: Array # Called when the node enters the scene tree for the first time. func _ready(): - assert (data.size() > 0); + assert (data.size() > 0) - kinds = data.keys(); + kinds = data.keys() current_kind = kinds[0] - current_slots = data[current_kind]; + current_slots = data[current_kind] for kind in kinds: - var kind_instance := kind_scene.instantiate() + var kind_instance := KindScn.instantiate() kind_instance.title = kind kind_instance.enabled = kind == current_kind $"./ColorRect/VBoxContainer/Kinds".add_child(kind_instance) for slot in current_slots: - var slot_instance := slot_scene.instantiate() + var slot_instance := SlotScn.instantiate() slot_instance.title = slot.title slot_instance.icon = slot.icon slot_instance.count = slot.count diff --git a/frontend/Savor-22b/scenes/inventory/inventory.tscn b/frontend/Savor-22b/scenes/inventory/inventory.tscn index 6ae5583c..e4b622a5 100644 --- a/frontend/Savor-22b/scenes/inventory/inventory.tscn +++ b/frontend/Savor-22b/scenes/inventory/inventory.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://riiie4g746ea"] -[ext_resource type="Script" path="res://scenes/inventory/Inventory.gd" id="1_swc55"] +[ext_resource type="Script" path="res://scenes/inventory/inventory.gd" id="1_swc55"] [node name="Inventory" type="Control"] custom_minimum_size = Vector2(1000, 700) diff --git a/frontend/Savor-22b/scenes/inventory/Kind.gd b/frontend/Savor-22b/scenes/inventory/kind.gd similarity index 92% rename from frontend/Savor-22b/scenes/inventory/Kind.gd rename to frontend/Savor-22b/scenes/inventory/kind.gd index d66dff7f..56e0cd97 100644 --- a/frontend/Savor-22b/scenes/inventory/Kind.gd +++ b/frontend/Savor-22b/scenes/inventory/kind.gd @@ -1,7 +1,7 @@ extends Node -var title: String; -var enabled: bool; +var title: String +var enabled: bool # Called when the node enters the scene tree for the first time. func _ready(): diff --git a/frontend/Savor-22b/scenes/inventory/kind.tscn b/frontend/Savor-22b/scenes/inventory/kind.tscn index f0c75567..2c656912 100644 --- a/frontend/Savor-22b/scenes/inventory/kind.tscn +++ b/frontend/Savor-22b/scenes/inventory/kind.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://bjmiaawy6ktrp"] -[ext_resource type="Script" path="res://scenes/inventory/Kind.gd" id="1_y1brs"] +[ext_resource type="Script" path="res://scenes/inventory/kind.gd" id="1_y1brs"] [sub_resource type="LabelSettings" id="LabelSettings_4vsh2"] diff --git a/frontend/Savor-22b/scenes/inventory/Slot.gd b/frontend/Savor-22b/scenes/inventory/slot.gd similarity index 81% rename from frontend/Savor-22b/scenes/inventory/Slot.gd rename to frontend/Savor-22b/scenes/inventory/slot.gd index 0a93ae96..60d517d9 100644 --- a/frontend/Savor-22b/scenes/inventory/Slot.gd +++ b/frontend/Savor-22b/scenes/inventory/slot.gd @@ -1,14 +1,13 @@ extends Node -var title: String; -var icon: String; -var count: int; +var title: String +var icon: String +var count: int # Called when the node enters the scene tree for the first time. func _ready(): $Title.set_text("%s - %d" % [title, count]) - # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): pass diff --git a/frontend/Savor-22b/scenes/inventory/slot.tscn b/frontend/Savor-22b/scenes/inventory/slot.tscn index b6d8bd5b..9e8c5afc 100644 --- a/frontend/Savor-22b/scenes/inventory/slot.tscn +++ b/frontend/Savor-22b/scenes/inventory/slot.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://b86kl35ac31iq"] -[ext_resource type="Script" path="res://scenes/inventory/Slot.gd" id="1_jurhm"] +[ext_resource type="Script" path="res://scenes/inventory/slot.gd" id="1_0bce7"] [node name="Slot" type="Control"] custom_minimum_size = Vector2(100, 100) @@ -10,7 +10,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_jurhm") +script = ExtResource("1_0bce7") [node name="Title" type="RichTextLabel" parent="."] layout_mode = 0 diff --git a/frontend/Savor-22b/scenes/inventory/slot_model.gd b/frontend/Savor-22b/scenes/inventory/slot_model.gd new file mode 100644 index 00000000..a1a5f65e --- /dev/null +++ b/frontend/Savor-22b/scenes/inventory/slot_model.gd @@ -0,0 +1,5 @@ +class_name SlotModel + +var title: String +var icon: String +var count: int diff --git a/frontend/Savor-22b/scenes/shop/ask_popup.gd b/frontend/Savor-22b/scenes/shop/ask_popup.gd index 490149d9..c6e291f0 100644 --- a/frontend/Savor-22b/scenes/shop/ask_popup.gd +++ b/frontend/Savor-22b/scenes/shop/ask_popup.gd @@ -2,28 +2,26 @@ extends ColorRect signal buy_button_down -@onready var Itemname = $M/V/Itemname +@onready var item_name_label = $M/V/item_name -var itemname +var item_name var format_string = "%s %s" func _ready(): update_info() - - func update_info(): - if itemname == null: + if item_name == null: return - Itemname.text = format_string % [itemname, "을(를) + item_name_label.text = format_string % [item_name, "을(를) 구매하시겠습니까?"] func _on_buy_button_down(): buy_button_down.emit() -func set_itemname(itemname: String): - self.itemname = itemname +func set_item_name(item_name: String): + self.item_name = item_name func _on_cancel_button_down(): queue_free() diff --git a/frontend/Savor-22b/scenes/shop/ask_popup.tscn b/frontend/Savor-22b/scenes/shop/ask_popup.tscn index b61add57..c6e1b55a 100644 --- a/frontend/Savor-22b/scenes/shop/ask_popup.tscn +++ b/frontend/Savor-22b/scenes/shop/ask_popup.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://taqcgkosj1e6"] -[ext_resource type="PackedScene" uid="uid://co4t4p5pawylr" path="res://ui/asset.tscn" id="1_t0req"] +[ext_resource type="PackedScene" uid="uid://co4t4p5pawylr" path="res://scenes/common/prefabs/asset.tscn" id="1_t0req"] [ext_resource type="Script" path="res://scenes/shop/ask_popup.gd" id="1_ulgkj"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yhy67"] @@ -28,7 +28,7 @@ theme_override_constants/margin_bottom = 20 layout_mode = 2 theme_override_constants/separation = 20 -[node name="Itemname" type="Label" parent="M/V"] +[node name="item_name" type="Label" parent="M/V"] layout_mode = 2 size_flags_vertical = 1 theme_override_colors/font_color = Color(0, 0, 0, 1) diff --git a/frontend/Savor-22b/scenes/shop/shop_item.gd b/frontend/Savor-22b/scenes/shop/shop_item.gd index b742591b..f50d7afd 100644 --- a/frontend/Savor-22b/scenes/shop/shop_item.gd +++ b/frontend/Savor-22b/scenes/shop/shop_item.gd @@ -2,7 +2,7 @@ extends ColorRect signal button_down -@onready var itemname = $M/V/Itemname +@onready var item_name_label = $M/V/item_name @onready var desc = $M/V/Description/Text var item: Dictionary @@ -12,18 +12,16 @@ var desc_format_string = "%s : %s %s" func _ready(): update_item() - func update_item(): - if itemname == null: + if item_name_label == null: return - itemname.text = item.name + item_name_label.text = item.name desc.text = desc_format_string % ["가격", item.price, "BBG"] func set_item(info: Dictionary): item = info - func _on_buy_button_down(): SceneContext.selected_item_index = item.id SceneContext.selected_item_name = item.name diff --git a/frontend/Savor-22b/scenes/shop/shop_item.tscn b/frontend/Savor-22b/scenes/shop/shop_item.tscn index ac994ff1..f7f5fd05 100644 --- a/frontend/Savor-22b/scenes/shop/shop_item.tscn +++ b/frontend/Savor-22b/scenes/shop/shop_item.tscn @@ -29,7 +29,7 @@ theme_override_constants/margin_bottom = 20 layout_mode = 2 theme_override_constants/separation = 20 -[node name="Itemname" type="Label" parent="M/V"] +[node name="item_name" type="Label" parent="M/V"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 50 diff --git a/frontend/Savor-22b/scenes/shop/system_shop.gd b/frontend/Savor-22b/scenes/shop/system_shop.gd new file mode 100644 index 00000000..d27452c6 --- /dev/null +++ b/frontend/Savor-22b/scenes/shop/system_shop.gd @@ -0,0 +1,60 @@ +extends Panel + +const ShopItemScn = preload("res://scenes/shop/shop_item.tscn") +const AskPopupScn = preload("res://scenes/shop/ask_popup.tscn") +const DonePopupScn = preload("res://scenes/shop/done_popup.tscn") + +const GqlQuery = preload("res://gql/query.gd") + +@onready var shop_list = $M/H/C/M/S/Lists +@onready var popup = $Popups + +var shop_items = [] + +func _ready(): + shop_items = SceneContext.shop + var size = shop_items.size() + + for item in shop_items["items"]: + var single_item = ShopItemScn.instantiate() + single_item.set_item(item) + single_item.button_down.connect(buy_item) + shop_list.add_child(single_item) + +func buy_item(): + var ask_popup = AskPopupScn.instantiate() + ask_popup.buy_button_down.connect(buy_query) + ask_popup.set_item_name(SceneContext.selected_item_name) + popup.add_child(ask_popup) + +func buy_query(): + var item_num = SceneContext.selected_item_index + var gql_query = GqlQuery.new() + var query_string = gql_query.buy_shop_item_query_format.format([ + "\"%s\"" % GlobalSigner.signer.GetPublicKey(), + item_num], "{}") + + var query_executor = SvrGqlClient.raw(query_string) + query_executor.graphql_response.connect( + func(data): + var unsigned_tx = data["data"]["createAction_BuyShopItem"] + var signature = GlobalSigner.sign(unsigned_tx) + var mutation_executor = SvrGqlClient.raw_mutation(gql_query.stage_tx_query_format % [unsigned_tx, signature]) + add_child(mutation_executor) + mutation_executor.run({}) + ) + add_child(query_executor) + query_executor.run({}) + +func print_done_popup(): + clear_popup() + var pop = DonePopupScn.instantiate() + popup.add_child(pop) + +func clear_popup(): + if is_instance_valid(popup): + for pop in popup.get_children(): + pop.queue_free() + +func _on_close_button_down(): + queue_free() diff --git a/frontend/Savor-22b/scenes/shop/systemshop.tscn b/frontend/Savor-22b/scenes/shop/system_shop.tscn similarity index 94% rename from frontend/Savor-22b/scenes/shop/systemshop.tscn rename to frontend/Savor-22b/scenes/shop/system_shop.tscn index 006f26fa..0c78ddbd 100644 --- a/frontend/Savor-22b/scenes/shop/systemshop.tscn +++ b/frontend/Savor-22b/scenes/shop/system_shop.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=3 uid="uid://bqf2y10ecg1vu"] -[ext_resource type="PackedScene" uid="uid://co4t4p5pawylr" path="res://ui/asset.tscn" id="1_mqe47"] -[ext_resource type="Script" path="res://scenes/shop/systemshop.gd" id="1_oxfr7"] +[ext_resource type="PackedScene" uid="uid://co4t4p5pawylr" path="res://scenes/common/prefabs/asset.tscn" id="1_mqe47"] +[ext_resource type="Script" path="res://scenes/shop/system_shop.gd" id="1_oxfr7"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kwjar"] bg_color = Color(1, 1, 1, 1) diff --git a/frontend/Savor-22b/scenes/shop/systemshop.gd b/frontend/Savor-22b/scenes/shop/systemshop.gd deleted file mode 100644 index 41cf8362..00000000 --- a/frontend/Savor-22b/scenes/shop/systemshop.gd +++ /dev/null @@ -1,79 +0,0 @@ -extends Panel - -const ITEM = preload("res://scenes/shop/shop_item.tscn") -const SHOP_ASK_POPUP = preload("res://scenes/shop/ask_popup.tscn") -const SHOP_DONE_POPUP = preload("res://scenes/shop/done_popup.tscn") - -const Gql_query = preload("res://gql/query.gd") - -@onready var shoplist = $M/H/C/M/S/Lists -@onready var popup = $Popups - -var shopitems = [] - - - -func _ready(): - print("shop opened") - shopitems = SceneContext.shop - print(shopitems) - var size = shopitems.size() - - for item in shopitems["items"]: - print(item) - var singleitem = ITEM.instantiate() - singleitem.set_item(item) - singleitem.button_down.connect(buy_item) - shoplist.add_child(singleitem) - - - -func buy_item(): - print("buy item") - var askpopup = SHOP_ASK_POPUP.instantiate() - askpopup.buy_button_down.connect(buyquery) - askpopup.set_itemname(SceneContext.selected_item_name) - popup.add_child(askpopup) - - -func buyquery(): - var itemnum = SceneContext.selected_item_index - var gql_query = Gql_query.new() - var query_string = gql_query.buy_shop_item_query_format.format([ - "\"%s\"" % GlobalSigner.signer.GetPublicKey(), - itemnum], "{}") - 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_BuyShopItem"] - 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({}) - - print_done_popup() - -func print_done_popup(): - clear_popup() - var pop = SHOP_DONE_POPUP.instantiate() - popup.add_child(pop) - - - -func clear_popup(): - if is_instance_valid(popup): - for pop in popup.get_children(): - pop.queue_free() - -func _on_close_button_down(): - queue_free() diff --git a/frontend/Savor-22b/scenes/testpanel/test_panel.gd b/frontend/Savor-22b/scenes/testpanel/test_panel.gd deleted file mode 100644 index 678165f0..00000000 --- a/frontend/Savor-22b/scenes/testpanel/test_panel.gd +++ /dev/null @@ -1,65 +0,0 @@ -extends Control - -const Gql_query = preload("res://gql/query.gd") - -@onready var label = $Background/MarginContainer/GridContainer/Label -@onready var lineedit = $Background/MarginContainer/GridContainer/LineEdit -func _ready(): - pass - -func _input(event): - if event is InputEventKey and event.pressed: - if event.keycode == KEY_T: - get_tree().change_scene_to_file("res://scenes/testpanel/test_panel.tscn") - print("Test panel open") - - -func _on_button_pressed(): - get_tree().change_scene_to_file("res://scenes/farm.tscn") - - -func _on_button_2_pressed(): - - var test = SceneContext.shop - print(test) - - -func _on_button_3_pressed(): - test4() - -# use \" on every double quotation - -func test4(): - var string = lineedit.text - print(string) - var gql_query = Gql_query.new() - var query_string = "query -{ - createAction_CreateFood(publicKey:\"044B83CB8CE52392AD9E46FAF398F96C5CD7CDB95A9EA990A9A55CC575237D2B342D3C43AB5E6E149B87F82544769D70E93A10B0B38D9B579E0A895BF58CB7780F\", - recipeID: 2, - refrigeratorStateIdsToUse: [\"7435f34b-39f6-4829-a6df-4e6f9affab06\",\"aa2c9ec2-2788-4afa-8ee1-d43ec50127a3\",\"bda2e49a-ec87-4e42-bbab-e73488e8d750\"], - kitchenEquipmentStateIdsToUse: \"27d27975-b141-4963-b72a-d4cb0e71bc63\") -}" - - 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({}) - - -func _on_button_4_pressed(): - test4() diff --git a/frontend/Savor-22b/scenes/testpanel/test_panel.tscn b/frontend/Savor-22b/scenes/testpanel/test_panel.tscn deleted file mode 100644 index d0a8938e..00000000 --- a/frontend/Savor-22b/scenes/testpanel/test_panel.tscn +++ /dev/null @@ -1,75 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://bdfibt7fw8oj8"] - -[ext_resource type="Script" path="res://scenes/testpanel/test_panel.gd" id="1_5v2p1"] - -[node name="TestPanel" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_5v2p1") - -[node name="Background" type="ColorRect" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_top = -1.0 -offset_bottom = -1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="MarginContainer" type="MarginContainer" parent="Background"] -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 = 50 -theme_override_constants/margin_top = 50 -theme_override_constants/margin_right = 50 -theme_override_constants/margin_bottom = 50 - -[node name="GridContainer" type="GridContainer" parent="Background/MarginContainer"] -layout_mode = 2 -theme_override_constants/h_separation = 300 -theme_override_constants/v_separation = 300 -columns = 3 - -[node name="button" type="Button" parent="Background/MarginContainer/GridContainer"] -layout_mode = 2 -theme_override_font_sizes/font_size = 50 -text = "farm.tscn" - -[node name="button2" type="Button" parent="Background/MarginContainer/GridContainer"] -layout_mode = 2 -theme_override_font_sizes/font_size = 50 -text = "text set" - -[node name="Label" type="Label" parent="Background/MarginContainer/GridContainer"] -layout_mode = 2 -theme_override_colors/font_color = Color(0, 0, 0, 1) -theme_override_font_sizes/font_size = 50 -text = "label text" - -[node name="LineEdit" type="LineEdit" parent="Background/MarginContainer/GridContainer"] -custom_minimum_size = Vector2(300, 500) -layout_mode = 2 - -[node name="button3" type="Button" parent="Background/MarginContainer/GridContainer"] -layout_mode = 2 -theme_override_font_sizes/font_size = 50 -text = "sign" - -[node name="button4" type="Button" parent="Background/MarginContainer/GridContainer"] -layout_mode = 2 -theme_override_font_sizes/font_size = 50 -text = "sign" - -[connection signal="pressed" from="Background/MarginContainer/GridContainer/button" to="." method="_on_button_pressed"] -[connection signal="pressed" from="Background/MarginContainer/GridContainer/button2" to="." method="_on_button_2_pressed"] -[connection signal="pressed" from="Background/MarginContainer/GridContainer/button3" to="." method="_on_button_3_pressed"] -[connection signal="pressed" from="Background/MarginContainer/GridContainer/button4" to="." method="_on_button_4_pressed"] diff --git a/frontend/Savor-22b/ui/house_slot_button.gd b/frontend/Savor-22b/scenes/village/house_slot_button.gd similarity index 84% rename from frontend/Savor-22b/ui/house_slot_button.gd rename to frontend/Savor-22b/scenes/village/house_slot_button.gd index 09e8de26..4942330a 100644 --- a/frontend/Savor-22b/ui/house_slot_button.gd +++ b/frontend/Savor-22b/scenes/village/house_slot_button.gd @@ -5,7 +5,7 @@ signal button_down(child_index: int) @onready var button = $Button var house: Dictionary -var existhouses = SceneContext.get_selected_village()["houses"] +var exist_houses = SceneContext.get_selected_village()["houses"] var format_string = "%s (x = %d, y = %d)" @@ -18,14 +18,13 @@ func _update_button(): return button.text = format_string % [ house.owner, house.x, house.y ] - func set_house(house: Dictionary): self.house = house _update_button() func update_owner(): - for h1 in existhouses: + for h1 in exist_houses: if h1["x"] == house["x"] and h1["y"] == house["y"]: house["owner"] = h1["owner"] @@ -33,10 +32,8 @@ func disable_button_selected(): if(button.button_pressed): button.button_pressed = false - func disable_button(): button.disabled = true - -func _on_button_button_down(): +func _on_button_down(): button_down.emit(get_index()) diff --git a/frontend/Savor-22b/ui/house_slot_button.tscn b/frontend/Savor-22b/scenes/village/house_slot_button.tscn similarity index 91% rename from frontend/Savor-22b/ui/house_slot_button.tscn rename to frontend/Savor-22b/scenes/village/house_slot_button.tscn index bfb20ad3..6eee02c1 100644 --- a/frontend/Savor-22b/ui/house_slot_button.tscn +++ b/frontend/Savor-22b/scenes/village/house_slot_button.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=5 format=3 uid="uid://djwsh8gou8pgp"] -[ext_resource type="Script" path="res://ui/house_slot_button.gd" id="1_x2rs7"] +[ext_resource type="Script" path="res://scenes/village/house_slot_button.gd" id="1_scuya"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_phxol"] @@ -28,7 +28,7 @@ grow_vertical = 2 size_flags_horizontal = 2 size_flags_vertical = 0 color = Color(0.866667, 0.498039, 0.215686, 1) -script = ExtResource("1_x2rs7") +script = ExtResource("1_scuya") [node name="Button" type="Button" parent="."] layout_mode = 1 @@ -48,4 +48,4 @@ toggle_mode = true text = "집 설치 가능" text_overrun_behavior = 3 -[connection signal="button_down" from="Button" to="." method="_on_button_button_down"] +[connection signal="button_down" from="Button" to="." method="_on_button_down"] diff --git a/frontend/Savor-22b/scenes/village/select_house.gd b/frontend/Savor-22b/scenes/village/select_house.gd new file mode 100644 index 00000000..53a84ca2 --- /dev/null +++ b/frontend/Savor-22b/scenes/village/select_house.gd @@ -0,0 +1,140 @@ +extends Control + +const HouseSlotButtonScn = preload("res://scenes/village/house_slot_button.tscn") +const NoticePopupScn = preload("res://scenes/common/prefabs/notice_popup.tscn") +const ConfirmPopupScn = preload("res://scenes/common/prefabs/confirm_popup.tscn") +const GqlQuery = preload("res://gql/query.gd") + +@onready var notice_popup = $MarginContainer/Background/Noticepopup +@onready var confirm_popup = $MarginContainer/Background/ConfirmPopup +@onready var grid_container = $MarginContainer/Background/MarginContainer/ScrollContainer/HomeGridContainer + +var houses = [] +var exist_houses = SceneContext.get_selected_village()["houses"] + +func _ready(): + var size = SceneContext.selected_village_capacity + + grid_container.columns = SceneContext.selected_village_width + + var start_x_loc = -(( SceneContext.selected_village_width - 1 ) / 2) + var start_y_loc = (SceneContext.selected_village_height -1 ) / 2 + var end_x_loc = ( SceneContext.selected_village_width - 1 ) / 2 + + #create blank slots + for i in range(size): + var house = {"x" : start_x_loc, "y" : start_y_loc, "owner" : "none"} + houses.append(house) + + if(start_x_loc == end_x_loc): + start_y_loc -= 1 + start_x_loc = -(( SceneContext.selected_village_width - 1 ) / 2) + else: + start_x_loc += 1 + + for h1 in exist_houses: + for h2 in houses: + if h1["x"] == h2["x"] and h1["y"] == h2["y"]: + h2["owner"] = h1["owner"] + + for info in houses: + var button = HouseSlotButtonScn.instantiate() + button.set_house(info) + button.button_down.connect(button_selected) + grid_container.add_child(button) + +func button_selected(house_index): + var format_string1 = "house button down: %s" + var format_string2 = "selected slot location: %s" + SceneContext.selected_house_index = house_index + SceneContext.selected_house_location = houses[house_index] + + #Toggle mode + for slot in grid_container.get_children(): + if(slot.get_index() != house_index): + slot.disable_button_selected() + +func _on_button_pressed(): + get_tree().change_scene_to_file("res://scenes/village/select_village.tscn") + +func _on_build_button_down(): + if (SceneContext.selected_house_location["owner"] != "none"): + print_notice() + else: + var isHouseOwner = false + var villageState = SceneContext.user_state["villageState"] + if(villageState != null): + isHouseOwner = true + + if (isHouseOwner): + _query_relocation_cost_and_open() + else: + build_house() + +func _query_relocation_cost_and_open(): + var gql_query = GqlQuery.new() + gql_query.calculate_relocation_cost_query.graphql_response.connect( + func(data): + var confirm_popup_scn = ConfirmPopupScn.instantiate() + + confirm_popup_scn.set_label("%s 블록이 소요되며 %sBBG 가 필요합니다." % [ + str(data.data.calculateRelocationCost.durationBlocks), + str(data.data.calculateRelocationCost.price) + ]) + confirm_popup_scn.ok_button_clicked_signal.connect(build_house) + confirm_popup.add_child(confirm_popup_scn) + ) + add_child(gql_query.calculate_relocation_cost_query) + gql_query.calculate_relocation_cost_query.run({ + "villageId": SceneContext.user_state["villageState"]["houseState"]["villageId"], + "relocationVillageId": SceneContext.get_selected_village()["id"] + }) + +func print_notice(): + var box = NoticePopupScn.instantiate() + notice_popup.add_child(box) + +func build_house(): + var gql_query = GqlQuery.new() + var query_string = gql_query.place_house_query_format.format([ + "\"%s\"" % GlobalSigner.signer.GetPublicKey(), + SceneContext.get_selected_village()["id"], + SceneContext.selected_house_location.x, + SceneContext.selected_house_location.y], "{}") + + var query_executor = SvrGqlClient.raw(query_string) + query_executor.graphql_response.connect(func(data): + var unsigned_tx = data["data"]["createAction_PlaceUserHouse"] + var signature = GlobalSigner.sign(unsigned_tx) + var mutation_executor = SvrGqlClient.raw_mutation( + gql_query.stage_tx_query_format % [unsigned_tx, signature] + ) + add_child(mutation_executor) + mutation_executor.run({}) + ) + add_child(query_executor) + query_executor.run({}) + +func _on_refresh_button_down(): + Intro._query_villages() + + for child in grid_container.get_children(): + child.queue_free() + + for h0 in houses: + h0["owner"] = "none" + + exist_houses = SceneContext.get_selected_village()["houses"] + for h1 in exist_houses: + for h2 in houses: + if h1["x"] == h2["x"] and h1["y"] == h2["y"]: + h2["owner"] = h1["owner"] + + for info in houses: + var button = HouseSlotButtonScn.instantiate() + button.set_house(info) + button.button_down.connect(button_selected) + grid_container.add_child(button) + +func _on_back_button_down(): + get_tree().change_scene_to_file("res://scenes/village/village_view.tscn") diff --git a/frontend/Savor-22b/scenes/select_house.tscn b/frontend/Savor-22b/scenes/village/select_house.tscn similarity index 96% rename from frontend/Savor-22b/scenes/select_house.tscn rename to frontend/Savor-22b/scenes/village/select_house.tscn index a970e0b3..ef2f8836 100644 --- a/frontend/Savor-22b/scenes/select_house.tscn +++ b/frontend/Savor-22b/scenes/village/select_house.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://dy1e0tpo1lsby"] -[ext_resource type="Script" path="res://scripts/scenes/select_house.gd" id="1_012c4"] +[ext_resource type="Script" path="res://scenes/village/select_house.gd" id="1_012c4"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cba5k"] bg_color = Color(0.00392157, 0.00392157, 0.00392157, 1) @@ -173,6 +173,6 @@ offset_right = 640.0 offset_bottom = 340.0 [connection signal="pressed" from="TopMenuMarginContainer/HBoxContainer/HomeButton" to="." method="_on_button_pressed"] -[connection signal="button_down" from="TopMenuMarginContainer/HBoxContainer/BackButton" to="." method="_on_back_button_button_down"] -[connection signal="button_down" from="BottomMenuMarginContainer/Control/BuildButtonContainer/BuildButton" to="." method="_on_build_button_button_down"] -[connection signal="button_down" from="BottomMenuMarginContainer/Control/RefreshButtonContainer/RefreshButton" to="." method="_on_refresh_button_button_down"] +[connection signal="button_down" from="TopMenuMarginContainer/HBoxContainer/BackButton" to="." method="_on_back_button_down"] +[connection signal="button_down" from="BottomMenuMarginContainer/Control/BuildButtonContainer/BuildButton" to="." method="_on_build_button_down"] +[connection signal="button_down" from="BottomMenuMarginContainer/Control/RefreshButtonContainer/RefreshButton" to="." method="_on_refresh_button_down"] diff --git a/frontend/Savor-22b/scripts/scenes/select_village.gd b/frontend/Savor-22b/scenes/village/select_village.gd similarity index 60% rename from frontend/Savor-22b/scripts/scenes/select_village.gd rename to frontend/Savor-22b/scenes/village/select_village.gd index 8280482e..5a43c988 100644 --- a/frontend/Savor-22b/scripts/scenes/select_village.gd +++ b/frontend/Savor-22b/scenes/village/select_village.gd @@ -1,18 +1,17 @@ extends Control -const SELECT_VILLAGE_VILLAGE_BUTTON = preload("res://ui/select_village_village_button.tscn") +const SelectVillageButtonScn = preload("res://scenes/village/select_village_button.tscn") @onready var villages_v_box_container = $LeftMarginContainer/VillagesVBoxContainer @onready var village_info_label = $RightMarginContainer/MarginContainer/VBoxContainer/VillageInfoMarginContainer/ScrollContainer/Label func _ready(): - print("select_village scene ready") Intro._query_villages() _update_village_info_label() for village in SceneContext.villages: - var button = SELECT_VILLAGE_VILLAGE_BUTTON.instantiate() + var button = SelectVillageButtonScn.instantiate() button.set_village(village) - button.button_down.connect(_on_village_button_button_down) + button.button_down.connect(_on_village_button_down) villages_v_box_container.add_child(button) _update_village_info_label() @@ -21,21 +20,16 @@ func _update_village_info_label(): var json_string = JSON.stringify(SceneContext.get_selected_village(), "\t") village_info_label.text = json_string -func _on_village_button_button_down(village_index): +func _on_village_button_down(village_index): var format_string = "village button down: %s" - print(format_string % village_index) SceneContext.selected_village_index = village_index _update_village_info_label() -func _on_start_button_button_down(): - print("start button down: %s" % SceneContext.selected_village_index) - #get_tree().change_scene_to_file("res://village_view/VillageView.tscn") - #get_tree().change_scene_to_file("res://scenes/farm.tscn") - +func _on_start_button_down(): var village = SceneContext.get_selected_village() var capacity = village["height"] * village["width"] SceneContext.selected_village_capacity = capacity SceneContext.selected_village_width = village["width"] SceneContext.selected_village_height = village["height"] - get_tree().change_scene_to_file("res://scenes/select_house.tscn") + get_tree().change_scene_to_file("res://scenes/village/select_house.tscn") diff --git a/frontend/Savor-22b/scenes/select_village.tscn b/frontend/Savor-22b/scenes/village/select_village.tscn similarity index 96% rename from frontend/Savor-22b/scenes/select_village.tscn rename to frontend/Savor-22b/scenes/village/select_village.tscn index 6ee96b72..02d6234b 100644 --- a/frontend/Savor-22b/scenes/select_village.tscn +++ b/frontend/Savor-22b/scenes/village/select_village.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://cl8vvgnebwyi1"] -[ext_resource type="Script" path="res://scripts/scenes/select_village.gd" id="1_uohty"] +[ext_resource type="Script" path="res://scenes/village/select_village.gd" id="1_uohty"] [node name="SelectVillage" type="Control"] layout_mode = 3 @@ -106,4 +106,4 @@ layout_mode = 2 theme_override_font_sizes/font_size = 70 text = "Start" -[connection signal="button_down" from="RightMarginContainer/MarginContainer/VBoxContainer/StartButtonMarginContainer/StartButton" to="." method="_on_start_button_button_down"] +[connection signal="button_down" from="RightMarginContainer/MarginContainer/VBoxContainer/StartButtonMarginContainer/StartButton" to="." method="_on_start_button_down"] diff --git a/frontend/Savor-22b/ui/select_village_village_button.gd b/frontend/Savor-22b/scenes/village/select_village_button.gd similarity index 93% rename from frontend/Savor-22b/ui/select_village_village_button.gd rename to frontend/Savor-22b/scenes/village/select_village_button.gd index d1a0355b..7a9a83ed 100644 --- a/frontend/Savor-22b/ui/select_village_village_button.gd +++ b/frontend/Savor-22b/scenes/village/select_village_button.gd @@ -23,5 +23,5 @@ func set_village(village: Dictionary): self.village = village _update_button() -func _on_button_button_down(): +func _on_button_down(): button_down.emit(get_index()) diff --git a/frontend/Savor-22b/ui/select_village_village_button.tscn b/frontend/Savor-22b/scenes/village/select_village_button.tscn similarity index 79% rename from frontend/Savor-22b/ui/select_village_village_button.tscn rename to frontend/Savor-22b/scenes/village/select_village_button.tscn index d4f2ae09..79030a04 100644 --- a/frontend/Savor-22b/ui/select_village_village_button.tscn +++ b/frontend/Savor-22b/scenes/village/select_village_button.tscn @@ -1,13 +1,13 @@ [gd_scene load_steps=2 format=3 uid="uid://eddcwfe8kgp5"] -[ext_resource type="Script" path="res://ui/select_village_village_button.gd" id="1_lhmfv"] +[ext_resource type="Script" path="res://scenes/village/select_village_button.gd" id="1_rpa1m"] [node name="SelectVillageVillageButton" type="MarginContainer"] custom_minimum_size = Vector2(2.08165e-12, 200) theme_override_constants/margin_left = 10 theme_override_constants/margin_top = 10 theme_override_constants/margin_right = 10 -script = ExtResource("1_lhmfv") +script = ExtResource("1_rpa1m") [node name="Background" type="ColorRect" parent="."] layout_mode = 2 @@ -18,4 +18,4 @@ theme_override_font_sizes/font_size = 50 text = "Village #1 (Households X/Y)" -[connection signal="button_down" from="Button" to="." method="_on_button_button_down"] +[connection signal="button_down" from="Button" to="." method="_on_button_down"] diff --git a/frontend/Savor-22b/scenes/village/village_view.gd b/frontend/Savor-22b/scenes/village/village_view.gd new file mode 100644 index 00000000..995eb494 --- /dev/null +++ b/frontend/Savor-22b/scenes/village/village_view.gd @@ -0,0 +1,75 @@ +extends Control + +const HouseSlotButtonScn = preload("res://scenes/village/house_slot_button.tscn") +const SystemShopScn = preload("res://scenes/shop/system_shop.tscn") + +@onready var grid_container = $MarginContainer/Background/MarginContainer/ScrollContainer/HomeGridContainer +@onready var popups = $Popups + +var houses = [] +var exist_houses = SceneContext.get_selected_village()["houses"] + +func _ready(): + var size = SceneContext.selected_village_capacity + + grid_container.columns = SceneContext.selected_village_width + + var start_x_loc = -(( SceneContext.selected_village_width - 1 ) / 2) + var start_y_loc = (SceneContext.selected_village_height -1 ) / 2 + var end_x_loc = ( SceneContext.selected_village_width - 1 ) / 2 + + #create blank slots + for i in range(size): + var house = {"x" : start_x_loc, "y" : start_y_loc, "owner" : "none"} + houses.append(house) + + if(start_x_loc == end_x_loc): + start_y_loc -= 1 + start_x_loc = -(( SceneContext.selected_village_width - 1 ) / 2) + else: + start_x_loc += 1 + + for h1 in exist_houses: + for h2 in houses: + if h1["x"] == h2["x"] and h1["y"] == h2["y"]: + h2["owner"] = h1["owner"] + + for info in houses: + var button = HouseSlotButtonScn.instantiate() + button.set_house(info) + button.button_down.connect(button_selected) + grid_container.add_child(button) + + disable_buttons() + +func button_selected(house_index): + var format_string1 = "house button down: %s" + var format_string2 = "selected slot location: %s" + SceneContext.selected_house_index = house_index + SceneContext.selected_house_location = houses[house_index] + + #Toggle mode + for slot in grid_container.get_children(): + if(slot.get_index() != house_index): + slot.disable_button_selected() + +func disable_buttons(): + for slot in grid_container.get_children(): + slot.disable_button() + +func _on_home_button_down(): + get_tree().change_scene_to_file("res://scenes/village/select_village.tscn") + +func _on_enter_button_down(): + pass # Replace with function body. + +func _on_farm_button_down(): + get_tree().change_scene_to_file("res://scenes/farm/farm.tscn") + +#open shop with S input +func _input(event): + if event is InputEventKey and event.pressed: + if event.keycode == KEY_S: + var shop = SystemShopScn.instantiate() + popups.add_child(shop) + shop.set_position(Vector2(400, 150)) diff --git a/frontend/Savor-22b/scenes/village_view.tscn b/frontend/Savor-22b/scenes/village/village_view.tscn similarity index 97% rename from frontend/Savor-22b/scenes/village_view.tscn rename to frontend/Savor-22b/scenes/village/village_view.tscn index 97b6c371..b2800bc0 100644 --- a/frontend/Savor-22b/scenes/village_view.tscn +++ b/frontend/Savor-22b/scenes/village/village_view.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://wkyffjkvp7av"] -[ext_resource type="Script" path="res://scripts/scenes/village_view.gd" id="1_oar4x"] +[ext_resource type="Script" path="res://scenes/village/village_view.gd" id="1_oar4x"] [node name="VillageView" type="Control"] layout_mode = 3 @@ -153,6 +153,6 @@ anchors_preset = 0 offset_right = 40.0 offset_bottom = 40.0 -[connection signal="button_down" from="TopMenuMarginContainer/Control/HomeButtonContainer/HomeButton" to="." method="_on_home_button_button_down"] -[connection signal="button_down" from="TopMenuMarginContainer/Control/FarmButtonContainer/FarmButton" to="." method="_on_farm_button_button_down"] -[connection signal="button_down" from="BottomMenuMarginContainer/Control/EnterButtonContainer/EnterButton" to="." method="_on_enter_button_button_down"] +[connection signal="button_down" from="TopMenuMarginContainer/Control/HomeButtonContainer/HomeButton" to="." method="_on_home_button_down"] +[connection signal="button_down" from="TopMenuMarginContainer/Control/FarmButtonContainer/FarmButton" to="." method="_on_farm_button_down"] +[connection signal="button_down" from="BottomMenuMarginContainer/Control/EnterButtonContainer/EnterButton" to="." method="_on_enter_button_down"] diff --git a/frontend/Savor-22b/scripts/gql_test.gd b/frontend/Savor-22b/scripts/gql_test.gd deleted file mode 100644 index 4d3b39fd..00000000 --- a/frontend/Savor-22b/scripts/gql_test.gd +++ /dev/null @@ -1,27 +0,0 @@ -extends Node - -var queryExecutor: GQLQueryExecuter - -# Called when the node enters the scene tree for the first time. -func _ready(): - var query = GQLQuery.new("villages").set_props([ - "id", - "name", - "width", - "height", - "worldX", - "worldY", - ]) - - queryExecutor = SvrGqlClient.query('query', {}, query) - queryExecutor.graphql_response.connect(self.graphql_response) - add_child(queryExecutor) - - queryExecutor.run({}) - -func graphql_response(data: Dictionary): - print(data) - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass diff --git a/frontend/Savor-22b/scripts/scenes/farm.gd b/frontend/Savor-22b/scripts/scenes/farm.gd deleted file mode 100644 index 11148d15..00000000 --- a/frontend/Savor-22b/scripts/scenes/farm.gd +++ /dev/null @@ -1,299 +0,0 @@ -extends Control - -const FARM_SLOT_EMPTY = preload("res://ui/farm_slot_empty.tscn") -const FARM_SLOT_OCCUPIED = preload("res://ui/farm_slot_button.tscn") -const FARM_SLOT_DONE = preload("res://ui/farm_slot_done.tscn") - -const INSTALL_POPUP = preload("res://ui/farm_install_popup.tscn") -const DONE_POPUP = preload("res://ui/done_notice_popup.tscn") -const ACTION_POPUP = preload("res://ui/farm_action_popup.tscn") -const REMOVE_POPUP = preload("res://ui/farm_ask_remove_popup.tscn") -const REMOVE_DONE_POPUP = preload("res://ui/farm_remove_done_popup.tscn") - -const Gql_query = preload("res://gql/query.gd") - -@onready var leftfarm = $MC/HC/CR/MC/HC/Left -@onready var rightfarm = $MC/HC/CR/MC/HC/Right - -@onready var popuparea = $Popups - -var farms = [] -var itemStateIds = [] -var itemStateIdToUse - - -var harvestedName - -var actionSuccess = false - - -func _ready(): - print("farm scene ready") - - #print(SceneContext.user_state["villageState"]["houseFieldStates"]) - farms = SceneContext.user_state["villageState"]["houseFieldStates"] - - #print(SceneContext.user_state["inventoryState"]["itemStateList"]) - itemStateIds = SceneContext.user_state["inventoryState"]["itemStateList"] - - #create blank slots - # Left slot - for i in range(0,5): - var farm - if (farms[i] == null): - farm = FARM_SLOT_EMPTY.instantiate() - farm.im_left() - farm.button_down.connect(farm_selected) - else: - if(farms[i]["isHarvested"]): - farm = FARM_SLOT_DONE.instantiate() - farm.im_left() - farm.set_farm_slot(farms[i]) - farm.button_down.connect(farm_selected) - farm.button_down_name.connect(harvested_name) - farm.button_down_harvest.connect(harvest_seed) - else: - farm = FARM_SLOT_OCCUPIED.instantiate() - farm.im_left() - farm.button_down.connect(farm_selected) - farm.button_down_action.connect(control_seed) - farm.set_farm_slot(farms[i]) - - leftfarm.add_child(farm) - - # Right slot - for i in range(5,10): - var farm - if (farms[i] == null): - farm = FARM_SLOT_EMPTY.instantiate() - farm.im_right() - farm.button_down.connect(farm_selected) - else: - if(farms[i]["isHarvested"]): - farm = FARM_SLOT_DONE.instantiate() - farm.im_right() - farm.set_farm_slot(farms[i]) - farm.button_down.connect(farm_selected) - farm.button_down_name.connect(harvested_name) - farm.button_down_harvest.connect(harvest_seed) - else: - farm = FARM_SLOT_OCCUPIED.instantiate() - farm.im_right() - farm.button_down.connect(farm_selected) - farm.button_down_action.connect(control_seed) - farm.set_farm_slot(farms[i]) - - rightfarm.add_child(farm) - - -func farm_selected(farm_index): - var format_string = "farm selected: %s" - print(format_string % farm_index) - SceneContext.selected_field_index = farm_index - if (farms[farm_index] == null): - plant_popup() - #else: - #if(farms[farm_index]["isHarvested"]): - #done_popup() - #else: - #pass - -func plant_popup(): - if is_instance_valid(popuparea): - for child in popuparea.get_children(): - child.queue_free() - - var amount = itemStateIds.size() - #print(amount) - var mousepos = get_local_mouse_position() + Vector2(0, -200) - var installpopup = INSTALL_POPUP.instantiate() - installpopup.set_amount(amount) - popuparea.add_child(installpopup) - installpopup.set_position(mousepos) - installpopup.accept_button_down.connect(plant_seed) - - -func plant_seed(): - var gql_query = Gql_query.new() - var query_string = gql_query.plant_seed_query_format.format([ - "\"%s\"" % GlobalSigner.signer.GetPublicKey(), - SceneContext.selected_field_index, - "\"%s\"" % itemStateIds[0]["stateID"]], "{}") - 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_PlantingSeed"] - #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({}) - -func harvested_name(seedName): - harvestedName = seedName - - -func done_popup(): - print("알림 출력") - if is_instance_valid(popuparea): - for child in popuparea.get_children(): - child.queue_free() - - var donepopup = DONE_POPUP.instantiate() - donepopup.set_seedname(harvestedName) - popuparea.add_child(donepopup) - # 팝업 위치는 설정이 필요할 듯 - donepopup.set_position(Vector2(700,500)) - - -func harvest_seed(): - actionSuccess = false - var gql_query = Gql_query.new() - var query_string = gql_query.harvest_seed_query_format.format([ - "\"%s\"" % GlobalSigner.signer.GetPublicKey(), - SceneContext.selected_field_index], "{}") - 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_HarvestingSeed"] - #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({}) - actionSuccess = true - fetch_new() - -func action_popup(weed : bool): - print("행동 팝업") - if is_instance_valid(popuparea): - for child in popuparea.get_children(): - child.queue_free() - - var actionpopup = ACTION_POPUP.instantiate() - actionpopup.set_weed_button(weed) - popuparea.add_child(actionpopup) - var mousepos = get_local_mouse_position() + Vector2(0, -200) - actionpopup.set_position(mousepos) - actionpopup.button_down_remove.connect(remove_popup) - actionpopup.weed_action_signal.connect(remove_weed) - -func remove_popup(): - if is_instance_valid(popuparea): - for child in popuparea.get_children(): - child.queue_free() - - var removepopup = REMOVE_POPUP.instantiate() - popuparea.add_child(removepopup) - removepopup.set_position(Vector2(700,500)) - removepopup.button_yes.connect(remove_done_popup) - -func remove_done_popup(): - remove_seed() - if is_instance_valid(popuparea): - for child in popuparea.get_children(): - child.queue_free() - - var donepopup = REMOVE_DONE_POPUP.instantiate() - popuparea.add_child(donepopup) - donepopup.set_position(Vector2(700,500)) - donepopup.refresh_me.connect(fetch_new) - -func control_seed(weed : bool): - #code here - action_popup(weed) - -func remove_seed(): - var gql_query = Gql_query.new() - var query_string = gql_query.remove_seed_query_format.format([ - "\"%s\"" % GlobalSigner.signer.GetPublicKey(), - SceneContext.selected_field_index], "{}") - 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_RemovePlantedSeed"] - #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({}) - fetch_new() - -func fetch_new(): -# fetch datas - Intro._query_user_state() - Intro.get_current_block() - - # done popup - if(actionSuccess): - done_popup() - actionSuccess = false - -# delete old farm uis - if is_instance_valid(leftfarm): - for child in leftfarm.get_children(): - child.queue_free() - if is_instance_valid(rightfarm): - for child in rightfarm.get_children(): - child.queue_free() - - _ready() - -func remove_weed(): - var gql_query = Gql_query.new() - var query_string = gql_query.remove_weed_query_format.format([ - "\"%s\"" % GlobalSigner.signer.GetPublicKey(), - SceneContext.selected_field_index], "{}") - 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_RemoveWeed"] - #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({}) - 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") diff --git a/frontend/Savor-22b/scripts/scenes/house.gd b/frontend/Savor-22b/scripts/scenes/house.gd deleted file mode 100644 index 6a450c53..00000000 --- a/frontend/Savor-22b/scripts/scenes/house.gd +++ /dev/null @@ -1,238 +0,0 @@ -extends Control - -const HOUSE_INVENTORY = preload("res://scenes/house/house_inventory.tscn") -const ASK_POPUP = preload("res://scenes/shop/ask_popup.tscn") -const DONE_POPUP = preload("res://scenes/shop/done_popup.tscn") - -const RECIPE = preload("res://scenes/house/recipebook/recipebook.tscn") - -const SMALL_COOK = preload("res://scenes/house/Kitchen/cook_slot.tscn") -const LARGE_COOK = preload("res://scenes/house/Kitchen/big_tool_slot.tscn") - -const LARGE_INSTALLER = preload("res://scenes/house/bigtool_install_popup.tscn") - - -const COOK_BOOK = preload("res://scenes/house/Cook/cook_book.tscn") -const COOK_START_POPUP = preload("res://scenes/house/Cook/cook_started_popup.tscn") -const CONFIRM_POPUP_RESOURCE = preload("res://ui/confirm_popup.tscn") - - -const Gql_query = preload("res://gql/query.gd") - -@onready var subscene = $M/V/subscene -@onready var popup = $Popups -@onready var confirmPopup = $ConfirmPopup - -var selectedSpace - -func _ready(): - load_kitchen() - -func _on_inventory_button_button_down(): - clear_popup() - reload_subscene() - - var inventory = HOUSE_INVENTORY.instantiate() - inventory.buysignal.connect(buypopup) - inventory.closeall.connect(clear_popup) - subscene.add_child(inventory) - -func buypopup(): - var askpopup = ASK_POPUP.instantiate() - askpopup.set_itemname(SceneContext.selected_item_name) - askpopup.buy_button_down.connect(buyaction) - askpopup.set_position(Vector2(900,600)) - popup.add_child(askpopup) - -func buyaction(): - clear_popup() - buytool() - - var donepopup = DONE_POPUP.instantiate() - donepopup.set_position(Vector2(900,600)) - popup.add_child(donepopup) - -func buytool(): - var itemnum = SceneContext.selected_item_index - var gql_query = Gql_query.new() - var query_string = gql_query.buy_kitchen_equipment_query_format.format([ - "\"%s\"" % GlobalSigner.signer.GetPublicKey(), - itemnum], "{}") - 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_BuyKitchenEquipment"] - 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({}) - -func clear_popup(): - if is_instance_valid(popup): - for pop in popup.get_children(): - pop.queue_free() - load_kitchen() - -func reload_subscene(): - if is_instance_valid(subscene): - for scene in subscene.get_children(): - scene.queue_free() - Intro._query_user_state() - Intro._query_kitchen_slot_state() - - -func _on_recipe_button_button_down(): - clear_popup() - reload_subscene() - var Recipebookarea = MarginContainer.new() - #setting margincontainer constants - Recipebookarea.add_theme_constant_override("margin_top", 20) - Recipebookarea.add_theme_constant_override("margin_bottom", 20) - Recipebookarea.add_theme_constant_override("margin_left", 140) - Recipebookarea.add_theme_constant_override("margin_right", 140) - subscene.add_child(Recipebookarea) - - var recipebook = RECIPE.instantiate() - recipebook.closeall.connect(clear_popup) - - Recipebookarea.add_child(recipebook) - -func _on_farm_button_button_down(): - get_tree().change_scene_to_file("res://scenes/farm.tscn") - -func _on_village_button_button_down(): - get_tree().change_scene_to_file("res://scenes/village_view.tscn") - -func _on_refresh_button_button_down(): - clear_popup() - reload_subscene() - load_kitchen() - - -func load_kitchen(): - reload_subscene() - - var Kitchenarea = VBoxContainer.new() - Kitchenarea.add_theme_constant_override("separation", 20) - subscene.add_child(Kitchenarea) - - var smallslot = SMALL_COOK.instantiate() - Kitchenarea.add_child(smallslot) - - var largeslot = LARGE_COOK.instantiate() - largeslot.install_signal.connect(on_empty_slot_pressed) - largeslot.uninstall_signal.connect(on_uninstall_slot_pressed) - Kitchenarea.add_child(largeslot) - -func on_empty_slot_pressed(spaceNumber : int): - - var largeinstaller = LARGE_INSTALLER.instantiate() - - var installerarea = MarginContainer.new() - #setting margincontainer constants - installerarea.add_theme_constant_override("margin_top", 20) - installerarea.add_theme_constant_override("margin_bottom", 320) - installerarea.add_theme_constant_override("margin_left", 150) - installerarea.add_theme_constant_override("margin_right", 150) - subscene.add_child(installerarea) - installerarea.add_child(largeinstaller) - largeinstaller.install_signal.connect(install_tool) - largeinstaller.reload_signal.connect(load_kitchen) - - selectedSpace = spaceNumber - - -func install_tool(stateId : String): - var gql_query = Gql_query.new() - var query_string = gql_query.install_kitchen_equipment_query_format.format([ - "\"%s\"" % GlobalSigner.signer.GetPublicKey(), - "\"%s\"" % stateId, selectedSpace], "{}") - 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_InstallKitchenEquipmentAction"] - 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({}) - - -var cook_book - -func _on_cook_button_button_down(): - var Cookbookarea = MarginContainer.new() - #setting margincontainer constants - Cookbookarea.add_theme_constant_override("margin_top", 20) - Cookbookarea.add_theme_constant_override("margin_bottom", 20) - Cookbookarea.add_theme_constant_override("margin_left", 140) - Cookbookarea.add_theme_constant_override("margin_right", 140) - subscene.add_child(Cookbookarea) - - cook_book = COOK_BOOK.instantiate() - cook_book.closeall.connect(clear_popup) - cook_book.reload_signal.connect(reload_cookbook) - cook_book.cook_started.connect(cook_started_popup) - - Cookbookarea.add_child(cook_book) - -func reload_cookbook(): - clear_popup() - _on_cook_button_button_down() - -func cook_started_popup(): - var start_popup = COOK_START_POPUP.instantiate() - start_popup.close_book.connect(_on_refresh_button_button_down) - start_popup.set_position(Vector2(900,600)) - subscene.add_child(start_popup) - -func on_uninstall_slot_pressed(spaceNumber: int): - var confirmPopupResource = CONFIRM_POPUP_RESOURCE.instantiate() - - confirmPopupResource.set_label("설치된 조리도구를 제거하시겠습니까?") - confirmPopupResource.ok_button_clicked_signal.connect(uninsatll_big_tool.bind(spaceNumber)) - confirmPopup.add_child(confirmPopupResource) - -func uninsatll_big_tool(spaceNumber: int): - var gql_query = Gql_query.new() - var query_string = gql_query.uninstall_kitchen_equipment_query_format.format([ - "\"%s\"" % GlobalSigner.signer.GetPublicKey(), - "%s" % spaceNumber], "{}") - 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_UninstallKitchenEquipmentActionQuery"] - 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({}) - diff --git a/frontend/Savor-22b/scripts/scenes/select_house.gd b/frontend/Savor-22b/scripts/scenes/select_house.gd deleted file mode 100644 index 7f1c056e..00000000 --- a/frontend/Savor-22b/scripts/scenes/select_house.gd +++ /dev/null @@ -1,163 +0,0 @@ -extends Control - -const SELECT_HOUSE_BUTTON = preload("res://ui/house_slot_button.tscn") -const SLOT_IS_FULL = preload("res://ui/notice_popup.tscn") -const ConfirmPopupResource = preload("res://ui/confirm_popup.tscn") -const Gql_query = preload("res://gql/query.gd") - -@onready var noticepopup = $MarginContainer/Background/Noticepopup -@onready var confirmPopup = $MarginContainer/Background/ConfirmPopup -@onready var gridcontainer = $MarginContainer/Background/MarginContainer/ScrollContainer/HomeGridContainer - -var houses = [] -var existhouses = SceneContext.get_selected_village()["houses"] - - -func _ready(): - print("select_house scene ready") - var size = SceneContext.selected_village_capacity - - gridcontainer.columns = SceneContext.selected_village_width - - var startxloc = -(( SceneContext.selected_village_width - 1 ) / 2) - var startyloc = (SceneContext.selected_village_height -1 ) / 2 - var endxloc = ( SceneContext.selected_village_width - 1 ) / 2 - - print("startxloc: %s" % startxloc) - print("startyloc: %s" % startyloc) - print("endxloc: %s" % endxloc) - - - #create blank slots - for i in range(size): - var house = {"x" : startxloc, "y" : startyloc, "owner" : "none"} - houses.append(house) - - if(startxloc == endxloc): - startyloc -= 1 - startxloc = -(( SceneContext.selected_village_width - 1 ) / 2) - else: - startxloc += 1 - - for h1 in existhouses: - for h2 in houses: - if h1["x"] == h2["x"] and h1["y"] == h2["y"]: - h2["owner"] = h1["owner"] - - for info in houses: - var button = SELECT_HOUSE_BUTTON.instantiate() - button.set_house(info) - button.button_down.connect(button_selected) - gridcontainer.add_child(button) - - -func button_selected(house_index): - var format_string1 = "house button down: %s" - var format_string2 = "selected slot location: %s" - print(format_string1 % house_index) - print(format_string2 % houses[house_index]) - SceneContext.selected_house_index = house_index - SceneContext.selected_house_location = houses[house_index] - - #Toggle mode - for slot in gridcontainer.get_children(): - if(slot.get_index() != house_index): - slot.disable_button_selected() - - - -func _on_button_pressed(): - get_tree().change_scene_to_file("res://scenes/select_village.tscn") - - -func _on_build_button_button_down(): - if (SceneContext.selected_house_location["owner"] != "none"): - print_notice() - else: - var isHouseOwner = false - var villageState = SceneContext.user_state["villageState"] - if(villageState != null): - isHouseOwner = true - - if (isHouseOwner): - _query_relocation_cost_and_open() - else: - build_house() - - -func _query_relocation_cost_and_open(): - var gql_query = Gql_query.new() - gql_query.calculate_relocation_cost_query.graphql_response.connect( - func(data): - var confirmPopupResource = ConfirmPopupResource.instantiate() - - confirmPopupResource.set_label("%s 블록이 소요되며 %sBBG 가 필요합니다." % [ - str(data.data.calculateRelocationCost.durationBlocks), - str(data.data.calculateRelocationCost.price) - ]) - confirmPopupResource.ok_button_clicked_signal.connect(build_house) - confirmPopup.add_child(confirmPopupResource) - ) - add_child(gql_query.calculate_relocation_cost_query) - gql_query.calculate_relocation_cost_query.run({ - "villageId": SceneContext.user_state["villageState"]["houseState"]["villageId"], - "relocationVillageId": SceneContext.get_selected_village()["id"] - }) - - -func print_notice(): - var box = SLOT_IS_FULL.instantiate() - noticepopup.add_child(box) - -func build_house(): - var gql_query = Gql_query.new() - var query_string = gql_query.place_house_query_format.format([ - "\"%s\"" % GlobalSigner.signer.GetPublicKey(), - SceneContext.get_selected_village()["id"], - SceneContext.selected_house_location.x, - SceneContext.selected_house_location.y], "{}") - 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_PlaceUserHouse"] - 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({}) - - - -func _on_refresh_button_button_down(): - Intro._query_villages() - - for child in gridcontainer.get_children(): - child.queue_free() - - for h0 in houses: - h0["owner"] = "none" - - existhouses = SceneContext.get_selected_village()["houses"] - for h1 in existhouses: - for h2 in houses: - if h1["x"] == h2["x"] and h1["y"] == h2["y"]: - h2["owner"] = h1["owner"] - - for info in houses: - var button = SELECT_HOUSE_BUTTON.instantiate() - button.set_house(info) - button.button_down.connect(button_selected) - gridcontainer.add_child(button) - - -func _on_back_button_button_down(): - get_tree().change_scene_to_file("res://scenes/village_view.tscn") diff --git a/frontend/Savor-22b/scripts/scenes/village_view.gd b/frontend/Savor-22b/scripts/scenes/village_view.gd deleted file mode 100644 index d1a9752b..00000000 --- a/frontend/Savor-22b/scripts/scenes/village_view.gd +++ /dev/null @@ -1,97 +0,0 @@ -extends Control - -const SELECT_HOUSE_BUTTON = preload("res://ui/house_slot_button.tscn") - -const SYS_SHOP = preload("res://scenes/shop/systemshop.tscn") - - -@onready var gridcontainer = $MarginContainer/Background/MarginContainer/ScrollContainer/HomeGridContainer - -@onready var popups = $Popups - -var houses = [] -var existhouses = SceneContext.get_selected_village()["houses"] - - -func _ready(): - print("village view scene ready") - var size = SceneContext.selected_village_capacity - - gridcontainer.columns = SceneContext.selected_village_width - - var startxloc = -(( SceneContext.selected_village_width - 1 ) / 2) - var startyloc = (SceneContext.selected_village_height -1 ) / 2 - var endxloc = ( SceneContext.selected_village_width - 1 ) / 2 - - print("startxloc: %s" % startxloc) - print("startyloc: %s" % startyloc) - print("endxloc: %s" % endxloc) - - - #create blank slots - for i in range(size): - var house = {"x" : startxloc, "y" : startyloc, "owner" : "none"} - houses.append(house) - - if(startxloc == endxloc): - startyloc -= 1 - startxloc = -(( SceneContext.selected_village_width - 1 ) / 2) - else: - startxloc += 1 - - for h1 in existhouses: - for h2 in houses: - if h1["x"] == h2["x"] and h1["y"] == h2["y"]: - h2["owner"] = h1["owner"] - - for info in houses: - var button = SELECT_HOUSE_BUTTON.instantiate() - button.set_house(info) - button.button_down.connect(button_selected) - gridcontainer.add_child(button) - - disable_buttons() - - -func button_selected(house_index): - var format_string1 = "house button down: %s" - var format_string2 = "selected slot location: %s" - print(format_string1 % house_index) - print(format_string2 % houses[house_index]) - SceneContext.selected_house_index = house_index - SceneContext.selected_house_location = houses[house_index] - - #Toggle mode - for slot in gridcontainer.get_children(): - if(slot.get_index() != house_index): - slot.disable_button_selected() - - -func disable_buttons(): - print("button all disabled") - for slot in gridcontainer.get_children(): - slot.disable_button() - - -func _on_home_button_button_down(): - get_tree().change_scene_to_file("res://scenes/select_village.tscn") - - - - -func _on_enter_button_button_down(): - pass # Replace with function body. - - - -func _on_farm_button_button_down(): - get_tree().change_scene_to_file("res://scenes/farm.tscn") - -#open shop with S input -func _input(event): - if event is InputEventKey and event.pressed: - if event.keycode == KEY_S: - var shop = SYS_SHOP.instantiate() - popups.add_child(shop) - shop.set_position(Vector2(400, 150)) - diff --git a/frontend/Savor-22b/sprites/32x32-black-line.png b/frontend/Savor-22b/sprites/32x32-black-line.png deleted file mode 100644 index 693e497f..00000000 Binary files a/frontend/Savor-22b/sprites/32x32-black-line.png and /dev/null differ diff --git a/frontend/Savor-22b/sprites/32x32-black-line.png.import b/frontend/Savor-22b/sprites/32x32-black-line.png.import deleted file mode 100644 index 5809c60c..00000000 --- a/frontend/Savor-22b/sprites/32x32-black-line.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://c0dwyky4dbhth" -path="res://.godot/imported/32x32-black-line.png-bc6c28e8447eddaa67f294959080df4f.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sprites/32x32-black-line.png" -dest_files=["res://.godot/imported/32x32-black-line.png-bc6c28e8447eddaa67f294959080df4f.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/frontend/Savor-22b/sprites/house.png b/frontend/Savor-22b/sprites/house.png deleted file mode 100644 index 4a1430f5..00000000 Binary files a/frontend/Savor-22b/sprites/house.png and /dev/null differ diff --git a/frontend/Savor-22b/sprites/house.png.import b/frontend/Savor-22b/sprites/house.png.import deleted file mode 100644 index 1aaa397a..00000000 --- a/frontend/Savor-22b/sprites/house.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://dajunmx26gvr5" -path="res://.godot/imported/house.png-692a11096cd356792c6bc12472b23812.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sprites/house.png" -dest_files=["res://.godot/imported/house.png-692a11096cd356792c6bc12472b23812.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/frontend/Savor-22b/sprites/mid.png b/frontend/Savor-22b/sprites/mid.png deleted file mode 100644 index c199b2f8..00000000 Binary files a/frontend/Savor-22b/sprites/mid.png and /dev/null differ diff --git a/frontend/Savor-22b/sprites/mid.png.import b/frontend/Savor-22b/sprites/mid.png.import deleted file mode 100644 index 1b909e46..00000000 --- a/frontend/Savor-22b/sprites/mid.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://bq1id6g5rr7by" -path="res://.godot/imported/mid.png-015d2eccb18049e0a564a085722e3bbe.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sprites/mid.png" -dest_files=["res://.godot/imported/mid.png-015d2eccb18049e0a564a085722e3bbe.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/frontend/Savor-22b/ui/done_notice_popup.gd b/frontend/Savor-22b/ui/done_notice_popup.gd deleted file mode 100644 index c5c515ac..00000000 --- a/frontend/Savor-22b/ui/done_notice_popup.gd +++ /dev/null @@ -1,20 +0,0 @@ -extends ColorRect - -@onready var infotext = $VBoxContainer/Label - -var format_string = "%s %s" -var seedName: String - -func _ready(): - if infotext == null: - return - - - infotext.text = format_string % [seedName, "(이)가 수확되었습니다."] - -func set_seedname(name: String): - seedName = name - - -func _on_button_button_down(): - queue_free() diff --git a/frontend/Savor-22b/village_view/TemporaryView.gd b/frontend/Savor-22b/village_view/TemporaryView.gd deleted file mode 100644 index ae27e4b6..00000000 --- a/frontend/Savor-22b/village_view/TemporaryView.gd +++ /dev/null @@ -1,19 +0,0 @@ -extends Node -const village_view_node = preload("res://village_view/village_background_nine_patch_rect.tscn") - -# Called when the node enters the scene tree for the first time. -func _ready(): - print("village_view scene ready") - var village = SceneContext.get_selected_village() - var village_view_instance = village_view_node.instantiate() - village_view_instance.set_name("view") - #village_view_instance.initialize( - #1000, - #500, - #0, - #0, - #[Vector2(0,0),Vector2(1,0),Vector2(0,1),Vector2(1,1)]) - - add_child(village_view_instance) - village_view_instance.initialize_by_village(village) - diff --git a/frontend/Savor-22b/village_view/VillageView.gd b/frontend/Savor-22b/village_view/VillageView.gd deleted file mode 100644 index 5c39ce69..00000000 --- a/frontend/Savor-22b/village_view/VillageView.gd +++ /dev/null @@ -1,98 +0,0 @@ -class_name VillageViewClass -extends Node - -var width: int -var height: int -var worldX: int -var worldY: int -var root_position: Vector2 -var root_local_position: Vector2 - -@export_group("View nodes") -@export var bg: NinePatchRect -@export var root_rect: TextureRect - -const Gql_query = preload("res://gql/query.gd") -const Origin_house = preload("res://village_view/house_texture_rect.tscn") -const Coordinate_weight = 300 - -# Called when the node enters the scene tree for the first time. -# 이건 Start의 성격일지 Awake의 성격일지 아직은 잘 모르겠음 -func _ready(): - set_size() - -# Mouse in viewport coordinates. -func _input(event): - var mouse_event = event as InputEventMouseButton - if mouse_event != null and mouse_event.is_released() and mouse_event.button_index == MOUSE_BUTTON_LEFT and mouse_event.is_command_or_control_pressed(): - print("Mouse Click/Unclick at: ", event.position) - build_house() - -func initialize_by_village(village: Dictionary): - initialize( - village.width * Coordinate_weight, - village.height * Coordinate_weight, - village.worldX, - village.worldY, - village.houses.map(func(house): return Vector2(house.x, house.y)) - ) - -func initialize(width: int, height: int, worldX: int, worldY: int, houses=[]): - self.width = width - self.height = height - self.worldX = worldX - self.worldY = worldY - set_size() - - for house in houses.filter(func (argc): return argc is Vector2): - instantiate_house(house) - -func set_size(): - bg.size.x = width - bg.size.y = height - bg.custom_minimum_size = bg.size - bg.set_anchors_and_offsets_preset(Control.PRESET_CENTER, Control.PRESET_MODE_KEEP_SIZE) - root_position = get_tree().root.size / 2 - root_local_position = root_rect.global_position - bg.global_position - -func instantiate_house(pos: Vector2): - print("instantiate_house: ", pos) - var house = Origin_house.instantiate() - bg.add_child(house) - house.set_size(Vector2(Coordinate_weight, Coordinate_weight)) - house.set_global_position(pos * Coordinate_weight + root_position - Vector2(Coordinate_weight / 2, Coordinate_weight / 2)) - -func build_house(): - var pos = bg.get_local_mouse_position() - var relative_pos = pos - root_local_position - relative_pos /= Coordinate_weight - relative_pos.x = roundi(relative_pos.x) - relative_pos.y = roundi(relative_pos.y) - print("build house pos: ", relative_pos) - print("root pos: ", root_local_position) - print("mouse pos: ", pos) - print("public key: ", GlobalSigner.signer.GetPublicKey()) - var gql_query = Gql_query.new() - var query_string = gql_query.place_house_query_format.format([ - "\"%s\"" % GlobalSigner.signer.GetPublicKey(), - SceneContext.get_selected_village()["id"], - relative_pos.x, - relative_pos.y], "{}") - 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_PlaceUserHouse"] - 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({}) diff --git a/frontend/Savor-22b/village_view/VillageView.tscn b/frontend/Savor-22b/village_view/VillageView.tscn deleted file mode 100644 index 19feb92b..00000000 --- a/frontend/Savor-22b/village_view/VillageView.tscn +++ /dev/null @@ -1,18 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dpd6n3ur5g4y5"] - -[ext_resource type="Script" path="res://village_view/TemporaryView.gd" id="1_n4pdo"] - -[node name="Control" type="ScrollContainer"] -clip_children = 1 -custom_minimum_size = Vector2(300, 300) -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -pivot_offset = Vector2(960, 540) -size_flags_horizontal = 3 -size_flags_vertical = 3 -horizontal_scroll_mode = 2 -vertical_scroll_mode = 2 -script = ExtResource("1_n4pdo") diff --git a/frontend/Savor-22b/village_view/house_texture_rect.tscn b/frontend/Savor-22b/village_view/house_texture_rect.tscn deleted file mode 100644 index df27bdf9..00000000 --- a/frontend/Savor-22b/village_view/house_texture_rect.tscn +++ /dev/null @@ -1,19 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://cjvcx7fit5avb"] - -[ext_resource type="Texture2D" uid="uid://dajunmx26gvr5" path="res://sprites/house.png" id="1_4yb37"] - -[node name="House_TextureRect" type="TextureRect"] -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -20.0 -offset_top = -20.0 -offset_right = 20.0 -offset_bottom = 20.0 -grow_horizontal = 2 -grow_vertical = 2 -size_flags_horizontal = 4 -size_flags_vertical = 4 -texture = ExtResource("1_4yb37") diff --git a/frontend/Savor-22b/village_view/village_background_nine_patch_rect.tscn b/frontend/Savor-22b/village_view/village_background_nine_patch_rect.tscn deleted file mode 100644 index 43941447..00000000 --- a/frontend/Savor-22b/village_view/village_background_nine_patch_rect.tscn +++ /dev/null @@ -1,49 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://bnut6era2lyw3"] - -[ext_resource type="Texture2D" uid="uid://c0dwyky4dbhth" path="res://sprites/32x32-black-line.png" id="1_ig6sc"] -[ext_resource type="Script" path="res://village_view/VillageView.gd" id="2_1w4b1"] -[ext_resource type="Texture2D" uid="uid://bq1id6g5rr7by" path="res://sprites/mid.png" id="3_e4wt8"] - -[node name="VillageBackground_NinePatchRect" type="NinePatchRect" node_paths=PackedStringArray("bg", "root_rect")] -z_index = -1000 -texture_filter = 1 -custom_minimum_size = Vector2(40, 40) -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -150.0 -offset_top = -150.0 -offset_right = -110.0 -offset_bottom = -110.0 -grow_horizontal = 2 -grow_vertical = 2 -pivot_offset = Vector2(20, 20) -size_flags_horizontal = 6 -size_flags_vertical = 6 -mouse_filter = 1 -texture = ExtResource("1_ig6sc") -patch_margin_left = 3 -patch_margin_top = 3 -patch_margin_right = 3 -patch_margin_bottom = 3 -script = ExtResource("2_1w4b1") -bg = NodePath(".") -root_rect = NodePath("TextureRect") - -[node name="TextureRect" type="TextureRect" parent="."] -texture_filter = 1 -layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -20.0 -offset_top = -20.0 -offset_right = 44.0 -offset_bottom = 44.0 -grow_horizontal = 2 -grow_vertical = 2 -texture = ExtResource("3_e4wt8")