From b53e2cd1a96dcbd1d79e48152d8b32a736168c3b Mon Sep 17 00:00:00 2001 From: Jiwon Date: Sun, 12 May 2024 02:10:33 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=ED=94=84=EB=A1=A0=ED=8A=B8=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B0=8D=20=EC=BB=A8=EB=B2=A4=EC=85=98=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=EC=88=98=EC=A0=95=20(#172)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix all naming convention * Fix uppercase * cache clear --- .../{scripts => }/global/inventory.gd | 4 +- .../{scripts => }/global/scene_context.gd | 47 +-- .../sign/Signer.gd => global/signer.gd} | 2 +- .../svr_explorer_gql_client.gd} | 4 +- .../{gql => global}/svr_gql_client.gd | 2 - frontend/Savor-22b/gql/query.gd | 2 +- frontend/Savor-22b/project.godot | 15 +- .../Savor-22b/{Asset.gd => scenes/asset.gd} | 0 .../prefabs/address_display.gd} | 1 - .../{ui => scenes/common/prefabs}/asset.tscn | 4 +- .../common/prefabs}/confirm_popup.gd | 0 .../common/prefabs}/confirm_popup.tscn | 2 +- .../common/prefabs/done_notice_popup.gd | 19 ++ .../common/prefabs}/done_notice_popup.tscn | 4 +- .../common/prefabs}/dungeon_button.tscn | 0 .../common/prefabs}/notice_popup.gd | 2 - .../common/prefabs}/notice_popup.tscn | 2 +- frontend/Savor-22b/scenes/farm/farm.gd | 259 +++++++++++++++ .../Savor-22b/scenes/{ => farm}/farm.tscn | 8 +- .../{ui => scenes/farm}/farm_action_popup.gd | 2 - .../farm}/farm_action_popup.tscn | 2 +- .../farm}/farm_ask_remove_popup.gd | 5 - .../farm}/farm_ask_remove_popup.tscn | 2 +- .../{ui => scenes/farm}/farm_install_popup.gd | 10 +- .../farm}/farm_install_popup.tscn | 2 +- .../farm}/farm_remove_done_popup.gd | 3 +- .../farm}/farm_remove_done_popup.tscn | 4 +- .../{ui => scenes/farm}/farm_slot_button.gd | 17 +- .../{ui => scenes/farm}/farm_slot_button.tscn | 4 +- .../{ui => scenes/farm}/farm_slot_done.gd | 16 +- .../{ui => scenes/farm}/farm_slot_done.tscn | 4 +- .../{ui => scenes/farm}/farm_slot_empty.gd | 12 +- .../{ui => scenes/farm}/farm_slot_empty.tscn | 4 +- .../scenes/house/Kitchen/big_tool_slot.gd | 79 ----- .../scenes/house/Kitchen/cook_menu.gd | 31 -- .../scenes/house/Kitchen/cook_slot.gd | 34 -- .../scenes/house/Kitchen/tool_is_used.gd | 44 --- .../scenes/house/{bigtool.gd => big_tool.gd} | 6 +- .../house/{bigtool.tscn => big_tool.tscn} | 4 +- .../scenes/house/big_tool_install_popup.gd | 43 +++ ...popup.tscn => big_tool_install_popup.tscn} | 6 +- .../scenes/house/bigtool_install_popup.gd | 47 --- .../scenes/house/{Cook => cook}/cook_book.gd | 57 ++-- .../house/{Cook => cook}/cook_book.tscn | 3 +- .../{Cook => cook}/cook_started_popup.gd | 3 - .../{Cook => cook}/cook_started_popup.tscn | 2 +- .../scenes/house/{Cook => cook}/ingredient.gd | 29 +- .../house/{Cook => cook}/ingredient.tscn | 2 +- .../ingredient_big_tool.gd} | 23 +- .../ingredient_big_tool.tscn} | 4 +- .../house/{Cook => cook}/recipe_available.gd | 118 ++++--- .../{Cook => cook}/recipe_available.tscn | 2 +- .../house/{Cook => cook}/select_button.gd | 5 +- .../house/{Cook => cook}/select_button.tscn | 2 +- .../house/{Cook => cook}/select_popup.gd | 59 ++-- .../house/{Cook => cook}/select_popup.tscn | 4 +- .../{Cook => cook}/select_tool_button.gd | 6 +- .../{Cook => cook}/select_tool_button.tscn | 2 +- frontend/Savor-22b/scenes/house/food.gd | 18 +- frontend/Savor-22b/scenes/house/house.gd | 207 ++++++++++++ frontend/Savor-22b/scenes/house/house.tscn | 18 +- .../Savor-22b/scenes/house/house_inventory.gd | 36 +-- .../scenes/house/house_inventory.tscn | 2 +- .../install_kitchen_equipment.tscn | 0 .../scenes/house/kitchen/big_tool_slot.gd | 76 +++++ .../{Kitchen => kitchen}/big_tool_slot.tscn | 2 +- .../scenes/house/kitchen/cook_menu.gd | 29 ++ .../house/{Kitchen => kitchen}/cook_menu.tscn | 2 +- .../scenes/house/kitchen/cook_slot.gd | 52 +++ .../house/{Kitchen => kitchen}/cook_slot.tscn | 2 +- .../scenes/house/kitchen/tool_is_used.gd | 40 +++ .../{Kitchen => kitchen}/tool_is_used.tscn | 2 +- .../{Kitchen => kitchen}/tool_not_used.gd | 4 - .../{Kitchen => kitchen}/tool_not_used.tscn | 2 +- .../{Kitchen => kitchen}/tool_slot_empty.gd | 4 +- .../{Kitchen => kitchen}/tool_slot_empty.tscn | 4 +- .../Savor-22b/scenes/house/kitchen_shop.gd | 27 ++ .../{kitchenshop.tscn => kitchen_shop.tscn} | 2 +- .../{kitchentools.gd => kitchen_tools.gd} | 14 +- .../{kitchentools.tscn => kitchen_tools.tscn} | 2 +- .../Savor-22b/scenes/house/kitchenshop.gd | 28 -- .../scenes/house/recipe_book/ingredient.gd | 14 + .../ingredient.tscn | 2 +- .../{recipebook => recipe_book}/recipe.gd | 25 +- .../{recipebook => recipe_book}/recipe.tscn | 4 +- .../scenes/house/recipe_book/recipe_book.gd | 19 ++ .../recipe_book.tscn} | 2 +- .../recipe_book_preset.tscn} | 2 +- .../recipe_style_box_flat.tres | 0 .../scenes/house/recipebook/ingredient.gd | 20 -- .../scenes/house/recipebook/recipebook.gd | 22 -- .../Savor-22b/scenes/house/refrigerator.gd | 14 +- frontend/Savor-22b/scenes/house/tool.gd | 33 +- .../{scripts/scenes => scenes/intro}/intro.gd | 59 ++-- .../Savor-22b/scenes/{ => intro}/intro.tscn | 8 +- .../Savor-22b/scenes/inventory/SlotModel.gd | 5 - .../inventory/{Inventory.gd => inventory.gd} | 24 +- .../Savor-22b/scenes/inventory/inventory.tscn | 2 +- .../scenes/inventory/{Kind.gd => kind.gd} | 4 +- frontend/Savor-22b/scenes/inventory/kind.tscn | 2 +- .../scenes/inventory/{Slot.gd => slot.gd} | 7 +- frontend/Savor-22b/scenes/inventory/slot.tscn | 4 +- .../Savor-22b/scenes/inventory/slot_model.gd | 5 + frontend/Savor-22b/scenes/shop/ask_popup.gd | 14 +- frontend/Savor-22b/scenes/shop/ask_popup.tscn | 4 +- frontend/Savor-22b/scenes/shop/shop_item.gd | 8 +- frontend/Savor-22b/scenes/shop/shop_item.tscn | 2 +- frontend/Savor-22b/scenes/shop/system_shop.gd | 60 ++++ .../{systemshop.tscn => system_shop.tscn} | 4 +- frontend/Savor-22b/scenes/shop/systemshop.gd | 79 ----- .../Savor-22b/scenes/testpanel/test_panel.gd | 65 ---- .../scenes/testpanel/test_panel.tscn | 75 ----- .../village}/house_slot_button.gd | 9 +- .../village}/house_slot_button.tscn | 6 +- .../Savor-22b/scenes/village/select_house.gd | 140 ++++++++ .../scenes/{ => village}/select_house.tscn | 8 +- .../village}/select_village.gd | 18 +- .../scenes/{ => village}/select_village.tscn | 4 +- .../village/select_village_button.gd} | 2 +- .../village/select_village_button.tscn} | 6 +- .../Savor-22b/scenes/village/village_view.gd | 75 +++++ .../scenes/{ => village}/village_view.tscn | 8 +- frontend/Savor-22b/scripts/gql_test.gd | 27 -- frontend/Savor-22b/scripts/scenes/farm.gd | 299 ------------------ frontend/Savor-22b/scripts/scenes/house.gd | 238 -------------- .../Savor-22b/scripts/scenes/select_house.gd | 163 ---------- .../Savor-22b/scripts/scenes/village_view.gd | 97 ------ .../Savor-22b/sprites/32x32-black-line.png | Bin 144 -> 0 bytes .../sprites/32x32-black-line.png.import | 34 -- frontend/Savor-22b/sprites/house.png | Bin 333 -> 0 bytes frontend/Savor-22b/sprites/house.png.import | 34 -- frontend/Savor-22b/sprites/mid.png | Bin 318 -> 0 bytes frontend/Savor-22b/sprites/mid.png.import | 34 -- frontend/Savor-22b/ui/done_notice_popup.gd | 20 -- .../Savor-22b/village_view/TemporaryView.gd | 19 -- .../Savor-22b/village_view/VillageView.gd | 98 ------ .../Savor-22b/village_view/VillageView.tscn | 18 -- .../village_view/house_texture_rect.tscn | 19 -- .../village_background_nine_patch_rect.tscn | 49 --- 139 files changed, 1437 insertions(+), 2228 deletions(-) rename frontend/Savor-22b/{scripts => }/global/inventory.gd (83%) rename frontend/Savor-22b/{scripts => }/global/scene_context.gd (63%) rename frontend/Savor-22b/{scripts/sign/Signer.gd => global/signer.gd} (97%) rename frontend/Savor-22b/{gql/svr_gql_client_2.gd => global/svr_explorer_gql_client.gd} (70%) rename frontend/Savor-22b/{gql => global}/svr_gql_client.gd (70%) rename frontend/Savor-22b/{Asset.gd => scenes/asset.gd} (100%) rename frontend/Savor-22b/scenes/{addressdisplay.gd => common/prefabs/address_display.gd} (99%) rename frontend/Savor-22b/{ui => scenes/common/prefabs}/asset.tscn (83%) rename frontend/Savor-22b/{ui => scenes/common/prefabs}/confirm_popup.gd (100%) rename frontend/Savor-22b/{ui => scenes/common/prefabs}/confirm_popup.tscn (94%) create mode 100644 frontend/Savor-22b/scenes/common/prefabs/done_notice_popup.gd rename frontend/Savor-22b/{ui => scenes/common/prefabs}/done_notice_popup.tscn (91%) rename frontend/Savor-22b/{ui => scenes/common/prefabs}/dungeon_button.tscn (100%) rename frontend/Savor-22b/{ui => scenes/common/prefabs}/notice_popup.gd (98%) rename frontend/Savor-22b/{ui => scenes/common/prefabs}/notice_popup.tscn (91%) create mode 100644 frontend/Savor-22b/scenes/farm/farm.gd rename frontend/Savor-22b/scenes/{ => farm}/farm.tscn (95%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_action_popup.gd (99%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_action_popup.tscn (95%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_ask_remove_popup.gd (97%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_ask_remove_popup.tscn (95%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_install_popup.gd (63%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_install_popup.tscn (96%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_remove_done_popup.gd (79%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_remove_done_popup.tscn (91%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_slot_button.gd (69%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_slot_button.tscn (93%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_slot_done.gd (74%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_slot_done.tscn (91%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_slot_empty.gd (69%) rename frontend/Savor-22b/{ui => scenes/farm}/farm_slot_empty.tscn (92%) delete mode 100644 frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.gd delete mode 100644 frontend/Savor-22b/scenes/house/Kitchen/cook_menu.gd delete mode 100644 frontend/Savor-22b/scenes/house/Kitchen/cook_slot.gd delete mode 100644 frontend/Savor-22b/scenes/house/Kitchen/tool_is_used.gd rename frontend/Savor-22b/scenes/house/{bigtool.gd => big_tool.gd} (88%) rename frontend/Savor-22b/scenes/house/{bigtool.tscn => big_tool.tscn} (94%) create mode 100644 frontend/Savor-22b/scenes/house/big_tool_install_popup.gd rename frontend/Savor-22b/scenes/house/{bigtool_install_popup.tscn => big_tool_install_popup.tscn} (94%) delete mode 100644 frontend/Savor-22b/scenes/house/bigtool_install_popup.gd rename frontend/Savor-22b/scenes/house/{Cook => cook}/cook_book.gd (72%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/cook_book.tscn (96%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/cook_started_popup.gd (98%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/cook_started_popup.tscn (96%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/ingredient.gd (57%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/ingredient.tscn (97%) rename frontend/Savor-22b/scenes/house/{Cook/ingredient_bigtool.gd => cook/ingredient_big_tool.gd} (65%) rename frontend/Savor-22b/scenes/house/{Cook/ingredient_bigtool.tscn => cook/ingredient_big_tool.tscn} (93%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/recipe_available.gd (58%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/recipe_available.tscn (98%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/select_button.gd (86%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/select_button.tscn (90%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/select_popup.gd (57%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/select_popup.tscn (96%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/select_tool_button.gd (86%) rename frontend/Savor-22b/scenes/house/{Cook => cook}/select_tool_button.tscn (90%) create mode 100644 frontend/Savor-22b/scenes/house/house.gd rename frontend/Savor-22b/scenes/{ => house}/install_kitchen_equipment.tscn (100%) create mode 100644 frontend/Savor-22b/scenes/house/kitchen/big_tool_slot.gd rename frontend/Savor-22b/scenes/house/{Kitchen => kitchen}/big_tool_slot.tscn (95%) create mode 100644 frontend/Savor-22b/scenes/house/kitchen/cook_menu.gd rename frontend/Savor-22b/scenes/house/{Kitchen => kitchen}/cook_menu.tscn (94%) create mode 100644 frontend/Savor-22b/scenes/house/kitchen/cook_slot.gd rename frontend/Savor-22b/scenes/house/{Kitchen => kitchen}/cook_slot.tscn (95%) create mode 100644 frontend/Savor-22b/scenes/house/kitchen/tool_is_used.gd rename frontend/Savor-22b/scenes/house/{Kitchen => kitchen}/tool_is_used.tscn (94%) rename frontend/Savor-22b/scenes/house/{Kitchen => kitchen}/tool_not_used.gd (99%) rename frontend/Savor-22b/scenes/house/{Kitchen => kitchen}/tool_not_used.tscn (94%) rename frontend/Savor-22b/scenes/house/{Kitchen => kitchen}/tool_slot_empty.gd (82%) rename frontend/Savor-22b/scenes/house/{Kitchen => kitchen}/tool_slot_empty.tscn (92%) create mode 100644 frontend/Savor-22b/scenes/house/kitchen_shop.gd rename frontend/Savor-22b/scenes/house/{kitchenshop.tscn => kitchen_shop.tscn} (94%) rename frontend/Savor-22b/scenes/house/{kitchentools.gd => kitchen_tools.gd} (54%) rename frontend/Savor-22b/scenes/house/{kitchentools.tscn => kitchen_tools.tscn} (95%) delete mode 100644 frontend/Savor-22b/scenes/house/kitchenshop.gd create mode 100644 frontend/Savor-22b/scenes/house/recipe_book/ingredient.gd rename frontend/Savor-22b/scenes/house/{recipebook => recipe_book}/ingredient.tscn (89%) rename frontend/Savor-22b/scenes/house/{recipebook => recipe_book}/recipe.gd (59%) rename frontend/Savor-22b/scenes/house/{recipebook => recipe_book}/recipe.tscn (93%) create mode 100644 frontend/Savor-22b/scenes/house/recipe_book/recipe_book.gd rename frontend/Savor-22b/scenes/house/{recipebook/recipebook.tscn => recipe_book/recipe_book.tscn} (96%) rename frontend/Savor-22b/scenes/house/{recipebook/recipebook_preset.tscn => recipe_book/recipe_book_preset.tscn} (99%) rename frontend/Savor-22b/scenes/house/{recipebook => recipe_book}/recipe_style_box_flat.tres (100%) delete mode 100644 frontend/Savor-22b/scenes/house/recipebook/ingredient.gd delete mode 100644 frontend/Savor-22b/scenes/house/recipebook/recipebook.gd rename frontend/Savor-22b/{scripts/scenes => scenes/intro}/intro.gd (86%) rename frontend/Savor-22b/scenes/{ => intro}/intro.tscn (92%) delete mode 100644 frontend/Savor-22b/scenes/inventory/SlotModel.gd rename frontend/Savor-22b/scenes/inventory/{Inventory.gd => inventory.gd} (63%) rename frontend/Savor-22b/scenes/inventory/{Kind.gd => kind.gd} (92%) rename frontend/Savor-22b/scenes/inventory/{Slot.gd => slot.gd} (81%) create mode 100644 frontend/Savor-22b/scenes/inventory/slot_model.gd create mode 100644 frontend/Savor-22b/scenes/shop/system_shop.gd rename frontend/Savor-22b/scenes/shop/{systemshop.tscn => system_shop.tscn} (94%) delete mode 100644 frontend/Savor-22b/scenes/shop/systemshop.gd delete mode 100644 frontend/Savor-22b/scenes/testpanel/test_panel.gd delete mode 100644 frontend/Savor-22b/scenes/testpanel/test_panel.tscn rename frontend/Savor-22b/{ui => scenes/village}/house_slot_button.gd (84%) rename frontend/Savor-22b/{ui => scenes/village}/house_slot_button.tscn (91%) create mode 100644 frontend/Savor-22b/scenes/village/select_house.gd rename frontend/Savor-22b/scenes/{ => village}/select_house.tscn (96%) rename frontend/Savor-22b/{scripts/scenes => scenes/village}/select_village.gd (60%) rename frontend/Savor-22b/scenes/{ => village}/select_village.tscn (96%) rename frontend/Savor-22b/{ui/select_village_village_button.gd => scenes/village/select_village_button.gd} (93%) rename frontend/Savor-22b/{ui/select_village_village_button.tscn => scenes/village/select_village_button.tscn} (79%) create mode 100644 frontend/Savor-22b/scenes/village/village_view.gd rename frontend/Savor-22b/scenes/{ => village}/village_view.tscn (97%) delete mode 100644 frontend/Savor-22b/scripts/gql_test.gd delete mode 100644 frontend/Savor-22b/scripts/scenes/farm.gd delete mode 100644 frontend/Savor-22b/scripts/scenes/house.gd delete mode 100644 frontend/Savor-22b/scripts/scenes/select_house.gd delete mode 100644 frontend/Savor-22b/scripts/scenes/village_view.gd delete mode 100644 frontend/Savor-22b/sprites/32x32-black-line.png delete mode 100644 frontend/Savor-22b/sprites/32x32-black-line.png.import delete mode 100644 frontend/Savor-22b/sprites/house.png delete mode 100644 frontend/Savor-22b/sprites/house.png.import delete mode 100644 frontend/Savor-22b/sprites/mid.png delete mode 100644 frontend/Savor-22b/sprites/mid.png.import delete mode 100644 frontend/Savor-22b/ui/done_notice_popup.gd delete mode 100644 frontend/Savor-22b/village_view/TemporaryView.gd delete mode 100644 frontend/Savor-22b/village_view/VillageView.gd delete mode 100644 frontend/Savor-22b/village_view/VillageView.tscn delete mode 100644 frontend/Savor-22b/village_view/house_texture_rect.tscn delete mode 100644 frontend/Savor-22b/village_view/village_background_nine_patch_rect.tscn 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 693e497f101c81ca167aa64c1076e940bf7d3152..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 144 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}UY;(FArY;~ z2@(khIF|nBpYqp-ImJ+BgFzopr0M|At(*OVf 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 4a1430f5408e94082b0330fd8f35477ecd36d141..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 333 zcmV-T0kZyyP)Px$2T4RhR9J=8mO&1LAPhynlR1#_EZ)N%hj8aT<}Ab;F`L1VX`!WHh}~%{@6px( z@bCz&3%o|c0buF`x2|KVKmdTxvXq2w6X4)Y5;X!PxLHCgpn;ntGy*m7G)E;O30UAH z-zv}wS4rglUlG1~Un|10xC*FuZkP*EpjX+|5~Kn*!dVF-uzD}{*U*3L+l+mi$$KIY zKaxbWmCAu*ymLta;EwZ>h(OKmOF)%CNhFnN0jmVKg}JI&z%i=t18Gk!!`Ljqi3}0w z6~hHoL)atSagGuA1CtYx2)N_yGF%ckCouhzuLGl2Mhngfki=A`BvcD-iFn}*`!6deWN6?g4*nlHcrSNexPcoJuSjQs)(G9Hv%qZDb4SJubj^K}F8#%i70wN$d>kpEt*q?2@fK z`r#+j-KTdxdY`z-U(WF2j$}qxL198Q_bi2Lh4KNi505)HWOW4Cuxa#l91U(r>Iku6 zH&8Ar Date: Mon, 20 May 2024 12:15:02 +0900 Subject: [PATCH 2/4] fix: GqlClient usage (#182) --- frontend/Savor-22b/gql/query.gd | 181 +++++++----------- frontend/Savor-22b/gql/query_executor.gd | 138 +++++++++++++ frontend/Savor-22b/scenes/farm/farm.gd | 114 +++++------ .../Savor-22b/scenes/house/cook/cook_book.gd | 36 ++-- frontend/Savor-22b/scenes/house/house.gd | 87 ++++----- frontend/Savor-22b/scenes/shop/system_shop.gd | 34 ++-- .../Savor-22b/scenes/village/select_house.gd | 44 ++--- 7 files changed, 356 insertions(+), 278 deletions(-) create mode 100644 frontend/Savor-22b/gql/query_executor.gd diff --git a/frontend/Savor-22b/gql/query.gd b/frontend/Savor-22b/gql/query.gd index fdc388be..217aeda0 100644 --- a/frontend/Savor-22b/gql/query.gd +++ b/frontend/Savor-22b/gql/query.gd @@ -1,112 +1,77 @@ -var get_villages_query = "query { - villages { - id - name - width - height - worldX - worldY - } -}" - -var place_house_query_format = "query { - createAction_PlaceUserHouse( - publicKey: {}, - villageId: {}, - x: {}, - y: {} - ) -}" - -var stage_tx_query_format = "mutation { - stageTransaction( - unsignedTransaction:\"%s\", - signature:\"%s\") -}" - -var plant_seed_query_format = "query { - createAction_PlantingSeed( - publicKey: {}, - fieldIndex: {}, - itemStateIdToUse: {} - ) -}" - - -var harvest_seed_query_format = "query { - createAction_HarvestingSeed( - publicKey: {}, - fieldIndex: {} - ) -}" - - -var remove_seed_query_format = "query { - createAction_RemovePlantedSeed( - publicKey: {}, - fieldIndex: {} - ) -}" - -var remove_weed_query_format = "query { - createAction_RemoveWeed( - publicKey: {}, - fieldIndex: {} - ) -}" - - - -var buy_shop_item_query_format = "query { - createAction_BuyShopItem( - publicKey: {}, - desiredShopItemID: {} - ) -}" - -var buy_kitchen_equipment_query_format = "query { - createAction_BuyKitchenEquipment( - publicKey: {}, - desiredEquipmentID: {} - ) -}" - -var install_kitchen_equipment_query_format = "query { - createAction_InstallKitchenEquipmentAction( - publicKey: {}, - kitchenEquipmentStateID: {}, - spaceNumber: {} - ) -}" - -var create_food_query_format = "query { - createAction_CreateFood( - publicKey: {}, - recipeID: {}, - refrigeratorStateIdsToUse: {}, - kitchenEquipmentStateIdsToUse: {} - ) -}" - -var uninstall_kitchen_equipment_query_format = "query { - createAction_UninstallKitchenEquipmentActionQuery( - publicKey: {}, - spaceNumber: {}, - ) -}" - -var calculate_relocation_cost_query_template = GQLQuery.new("calculateRelocationCost").set_args({ +var stage_tx_mutation = GQLQuery.new("stageTransaction").set_args({ + "unsignedTransaction": "unsignedTransaction", + "signature": "signature", +}); + +var get_villages_query = GQLQuery.new("villages").set_props([ + "id", + "name", + "width", + "height", + "worldX", + "worldY" +]); + +var calculate_relocation_cost_query = GQLQuery.new("calculateRelocationCost").set_args({ "villageId": "villageId", - "relocationVillageId": "relocationVillageId", + "relocationVillageId": "relocationVillageId" }).set_props([ "durationBlocks", - "price", -]) + "price" +]); -var calculate_relocation_cost_query = SvrGqlClient.query( - 'CalculateRelocationCost', - { - "villageId": "Int!", - "relocationVillageId": "Int!", - }, - calculate_relocation_cost_query_template) +var place_house_query = GQLQuery.new("createAction_PlaceUserHouse").set_args({ + "publicKey": "publicKey", + "villageId": "villageId", + "x": "x", + "y": "y" +}); + +var plant_seed_query = GQLQuery.new("createAction_PlantingSeed").set_args({ + "publicKey": "publicKey", + "fieldIndex": "fieldIndex", + "itemStateIdToUse": "itemStateIdToUse" +}); + +var harvest_seed_query = GQLQuery.new("createAction_HarvestingSeed").set_args({ + "publicKey": "publicKey", + "fieldIndex": "fieldIndex" +}); + +var remove_seed_query = GQLQuery.new("createAction_RemovePlantedSeed").set_args({ + "publicKey": "publicKey", + "fieldIndex": "fieldIndex" +}); + +var remove_weed_query = GQLQuery.new("createAction_RemoveWeed").set_args({ + "publicKey": "publicKey", + "fieldIndex": "fieldIndex" +}); + +var buy_shop_item_query = GQLQuery.new("createAction_BuyShopItem").set_args({ + "publicKey": "publicKey", + "desiredShopItemID": "desiredShopItemID" +}); + +var buy_kitchen_equipment_query = GQLQuery.new("createAction_BuyKitchenEquipment").set_args({ + "publicKey": "publicKey", + "desiredEquipmentID": "desiredEquipmentID" +}); + +var install_kitchen_equipment_query = GQLQuery.new("createAction_InstallKitchenEquipmentAction").set_args({ + "publicKey": "publicKey", + "kitchenEquipmentStateID": "kitchenEquipmentStateID", + "spaceNumber": "spaceNumber" +}); + +var create_food_query = GQLQuery.new("createAction_CreateFood").set_args({ + "publicKey": "publicKey", + "recipeID": "recipeID", + "refrigeratorStateIdsToUse": "refrigeratorStateIdsToUse", + "kitchenEquipmentStateIdsToUse": "kitchenEquipmentStateIdsToUse" +}); + +var uninstall_kitchen_equipment_query = GQLQuery.new("createAction_UninstallKitchenEquipmentActionQuery").set_args({ + "publicKey": "publicKey", + "spaceNumber": "spaceNumber" +}); diff --git a/frontend/Savor-22b/gql/query_executor.gd b/frontend/Savor-22b/gql/query_executor.gd new file mode 100644 index 00000000..12c30ea7 --- /dev/null +++ b/frontend/Savor-22b/gql/query_executor.gd @@ -0,0 +1,138 @@ +extends Node + +class_name QueryExecutor + +const GqlQuery = preload("res://gql/query.gd"); +var gql_query = GqlQuery.new(); + +var stage_tx_mutation_executor = SvrGqlClient.mutation( + 'StageTransaction', + { + "unsignedTransaction": "String!", + "signature": "String!" + }, + gql_query.stage_tx_mutation +); + +var calculate_relocation_cost_query_executor = SvrGqlClient.query( + 'CalculateRelocationCost', + { + "villageId": "Int!", + "relocationVillageId": "Int!" + }, + gql_query.calculate_relocation_cost_query +); + +var get_villages_query_executor = SvrGqlClient.query( + 'GetVillages', + {}, + gql_query.get_villages_query +); + +var place_house_query_executor = SvrGqlClient.query( + 'PlaceHouse', + { + "publicKey": "String!", + "villageId": "Int!", + "x": "Int!", + "y": "Int!" + }, + gql_query.place_house_query +); + +var plant_seed_query_executor = SvrGqlClient.query( + 'PlantSeed', + { + "publicKey": "String!", + "fieldIndex": "Int!", + "itemStateIdToUse": "Int!" + }, + gql_query.plant_seed_query +); + +var harvest_seed_query_executor = SvrGqlClient.query( + 'HarvestSeed', + { + "publicKey": "String!", + "fieldIndex": "Int!" + }, + gql_query.harvest_seed_query +); + +var remove_seed_query_executor = SvrGqlClient.query( + 'RemoveSeed', + { + "publicKey": "String!", + "fieldIndex": "Int!" + }, + gql_query.remove_seed_query +); + +var remove_weed_query_executor = SvrGqlClient.query( + 'RemoveWeed', + { + "publicKey": "String!", + "fieldIndex": "Int!" + }, + gql_query.remove_weed_query +); + +var buy_shop_item_query_executor = SvrGqlClient.query( + 'BuyShopItem', + { + "publicKey": "String!", + "desiredShopItemID": "Int!" + }, + gql_query.buy_shop_item_query +); + +var buy_kitchen_equipment_query_executor = SvrGqlClient.query( + 'BuyKitchenEquipment', + { + "publicKey": "String!", + "desiredEquipmentID": "Int!" + }, + gql_query.buy_kitchen_equipment_query +); + +var install_kitchen_equipment_query_executor = SvrGqlClient.query( + 'InstallKitchenEquipment', + { + "publicKey": "String!", + "kitchenEquipmentStateID": "Int!", + "spaceNumber": "Int!" + }, + gql_query.install_kitchen_equipment_query +); + +var create_food_query_executor = SvrGqlClient.query( + 'CreateFood', + { + "publicKey": "String!", + "recipeID": "Int!", + "refrigeratorStateIdsToUse": "Int!", + "kitchenEquipmentStateIdsToUse": "Int!" + }, + gql_query.create_food_query +); + +var uninstall_kitchen_equipment_query_executor = SvrGqlClient.query( + 'UninstallKitchenEquipment', + { + "publicKey": "String!", + "spaceNumber": "Int!" + }, + gql_query.uninstall_kitchen_equipment_query +); + +func stage_action(params, query_executor, mutation_executor): + query_executor.graphql_response.connect( + func(data): + var unsigned_tx = data["data"][data["data"].keys()[0]] + var signature = GlobalSigner.sign(unsigned_tx) + mutation_executor.run({ + "unsignedTransaction": unsigned_tx, + "signature": signature + }) + ) + query_executor.run(params) diff --git a/frontend/Savor-22b/scenes/farm/farm.gd b/frontend/Savor-22b/scenes/farm/farm.gd index 624f1e8a..acb1e621 100644 --- a/frontend/Savor-22b/scenes/farm/farm.gd +++ b/frontend/Savor-22b/scenes/farm/farm.gd @@ -10,7 +10,6 @@ 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 @@ -22,7 +21,25 @@ var item_state_Id_to_use var harvested_name var action_success = false +var query_executor = QueryExecutor.new() +var remove_seed_query_executor +var remove_weed_query_executor +var plant_seed_query_executor +var harvest_seed_query_executor +var stage_tx_mutation_executor + func _ready(): + remove_seed_query_executor = query_executor.remove_seed_query_executor + remove_weed_query_executor = query_executor.remove_weed_query_executor + plant_seed_query_executor = query_executor.plant_seed_query_executor + harvest_seed_query_executor = query_executor.harvest_seed_query_executor + stage_tx_mutation_executor = query_executor.stage_tx_mutation_executor + add_child(remove_seed_query_executor) + add_child(remove_weed_query_executor) + add_child(plant_seed_query_executor) + add_child(harvest_seed_query_executor) + add_child(stage_tx_mutation_executor) + farms = SceneContext.user_state["villageState"]["houseFieldStates"] item_state_ids = SceneContext.user_state["inventoryState"]["itemStateList"] @@ -103,23 +120,15 @@ func plant_popup(): 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({}) + query_executor.stage_action( + { + "publicKey": GlobalSigner.signer.GetPublicKey(), + "fieldIndex": SceneContext.selected_field_index, + "itemStateIdToUse": item_state_ids[0]["stateID"], + }, + plant_seed_query_executor, + stage_tx_mutation_executor ) - add_child(query_executor) - query_executor.run({}) func set_harvested_name(seed_name): harvested_name = seed_name @@ -137,24 +146,15 @@ func done_popup(): 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({}) + + query_executor.stage_action( + { + "publicKey": GlobalSigner.signer.GetPublicKey(), + "fieldIndex": SceneContext.selected_field_index, + }, + harvest_seed_query_executor, + stage_tx_mutation_executor ) - add_child(query_executor) - query_executor.run({}) - action_success = true - fetch_new() func action_popup(weed : bool): if is_instance_valid(popup_area): @@ -195,22 +195,15 @@ func control_seed(weed : bool): 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({}) + query_executor.stage_action( + { + "publicKey": GlobalSigner.signer.GetPublicKey(), + "fieldIndex": SceneContext.selected_field_index, + }, + remove_seed_query_executor, + stage_tx_mutation_executor ) - add_child(query_executor) - query_executor.run({}) + fetch_new() func fetch_new(): @@ -234,23 +227,14 @@ func fetch_new(): _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({}) + query_executor.stage_action( + { + "publicKey": GlobalSigner.signer.GetPublicKey(), + "fieldIndex": SceneContext.selected_field_index, + }, + remove_weed_query_executor, + stage_tx_mutation_executor ) - add_child(query_executor) - query_executor.run({}) - fetch_new() func _on_refresh_button_down(): fetch_new() diff --git a/frontend/Savor-22b/scenes/house/cook/cook_book.gd b/frontend/Savor-22b/scenes/house/cook/cook_book.gd index 866a3e32..3c52b8a6 100644 --- a/frontend/Savor-22b/scenes/house/cook/cook_book.gd +++ b/frontend/Savor-22b/scenes/house/cook/cook_book.gd @@ -5,7 +5,6 @@ signal reload_signal signal cook_started 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 @@ -15,7 +14,16 @@ var installed_list = SceneContext.installed_tool_name var available_tool_list : Array var available_recipe_list : Array +var query_executor = QueryExecutor.new() +var create_food_query_executor +var stage_tx_mutation_executor + func _ready(): + create_food_query_executor = query_executor.create_food_query_executor + stage_tx_mutation_executor = query_executor.stage_tx_mutation_executor + add_child(create_food_query_executor) + add_child(stage_tx_mutation_executor) + var format_string = "[%s]" var unique_list = remove_duplicates(installed_list) installed_tool.text = format_string % [", ".join(unique_list)] @@ -78,24 +86,16 @@ func _on_cook_button_down(): else: tool_str = tool_arr[0] - 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\"]" % ingredient_str, - "[\"%s\"]" % tool_str], "{}") - - var query_executor = SvrGqlClient.raw(query_string) - query_executor.graphql_response.connect(func(data): - var unsigned_tx = data["data"]["createAction_CreateFood"] - 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({}) + query_executor.stage_action( + { + "publicKey": GlobalSigner.signer.GetPublicKey(), + "recipeID": SceneContext.selected_recipe_index, + "refrigeratorStateIdsToUse": ingredient_str, + "kitchenEquipmentStateIdsToUse": tool_str + }, + create_food_query_executor, + stage_tx_mutation_executor ) - add_child(query_executor) - query_executor.run({}) # Init past selected infos SceneContext.selected_ingredients = [] diff --git a/frontend/Savor-22b/scenes/house/house.gd b/frontend/Savor-22b/scenes/house/house.gd index bff681f9..d998ba36 100644 --- a/frontend/Savor-22b/scenes/house/house.gd +++ b/frontend/Savor-22b/scenes/house/house.gd @@ -10,7 +10,6 @@ const BigToolInstallPopupScn = preload("res://scenes/house/big_tool_install_popu 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 @@ -19,7 +18,22 @@ const GqlQuery = preload("res://gql/query.gd") var selected_space var cook_book +var query_executor = QueryExecutor.new() +var buy_kitchen_equipment_query_executor +var install_kitchen_equipment_query_executor +var uninstall_kitchen_equipment_query_executor +var stage_tx_mutation_executor + func _ready(): + buy_kitchen_equipment_query_executor = query_executor.buy_kitchen_equipment_query_executor + install_kitchen_equipment_query_executor = query_executor.install_kitchen_equipment_query_executor + uninstall_kitchen_equipment_query_executor = query_executor.uninstall_kitchen_equipment_query_executor + stage_tx_mutation_executor = query_executor.stage_tx_mutation_executor + add_child(buy_kitchen_equipment_query_executor) + add_child(install_kitchen_equipment_query_executor) + add_child(uninstall_kitchen_equipment_query_executor) + add_child(stage_tx_mutation_executor) + load_kitchen() func _on_inventory_button_down(): @@ -47,23 +61,16 @@ func buy_action(): 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({}) + var item_num = SceneContext.selected_item_index + + query_executor.stage_action( + { + "publicKey": GlobalSigner.signer.GetPublicKey(), + "desiredEquipmentID": item_num, + }, + buy_kitchen_equipment_query_executor, + stage_tx_mutation_executor ) - add_child(query_executor) - query_executor.run({}) func clear_popup(): if is_instance_valid(popup): @@ -137,22 +144,15 @@ func on_empty_slot_pressed(spaceNumber : int): 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({}) + query_executor.stage_action( + { + "publicKey": GlobalSigner.signer.GetPublicKey(), + "kitchenEquipmentStateID": stateId, + "spaceNumber": selected_space, + }, + install_kitchen_equipment_query_executor, + stage_tx_mutation_executor ) - add_child(query_executor) - query_executor.run({}) func _on_cook_button_down(): var cook_book_area = MarginContainer.new() @@ -188,20 +188,11 @@ func on_uninstall_slot_pressed(spaceNumber: int): 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({}) + query_executor.stage_action( + { + "publicKey": GlobalSigner.signer.GetPublicKey(), + "spaceNumber": spaceNumber, + }, + uninstall_kitchen_equipment_query_executor, + stage_tx_mutation_executor ) - add_child(query_executor) - query_executor.run({}) - diff --git a/frontend/Savor-22b/scenes/shop/system_shop.gd b/frontend/Savor-22b/scenes/shop/system_shop.gd index d27452c6..0336da4e 100644 --- a/frontend/Savor-22b/scenes/shop/system_shop.gd +++ b/frontend/Savor-22b/scenes/shop/system_shop.gd @@ -4,14 +4,23 @@ 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") +const GqlQueryExecutor = preload("res://gql/query_executor.gd") @onready var shop_list = $M/H/C/M/S/Lists @onready var popup = $Popups var shop_items = [] +var query_executor = QueryExecutor.new() +var buy_shop_item_query_executor +var stage_tx_mutation_executor + func _ready(): + buy_shop_item_query_executor = query_executor.buy_shop_item_query_executor + stage_tx_mutation_executor = query_executor.stage_tx_mutation_executor + add_child(buy_shop_item_query_executor) + add_child(stage_tx_mutation_executor) + shop_items = SceneContext.shop var size = shop_items.size() @@ -29,22 +38,15 @@ func buy_item(): 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({}) + + query_executor.stage_action( + { + "publicKey": GlobalSigner.signer.GetPublicKey(), + "desiredShopItemID": item_num, + }, + buy_shop_item_query_executor, + stage_tx_mutation_executor ) - add_child(query_executor) - query_executor.run({}) func print_done_popup(): clear_popup() diff --git a/frontend/Savor-22b/scenes/village/select_house.gd b/frontend/Savor-22b/scenes/village/select_house.gd index 53a84ca2..cf343573 100644 --- a/frontend/Savor-22b/scenes/village/select_house.gd +++ b/frontend/Savor-22b/scenes/village/select_house.gd @@ -3,7 +3,6 @@ 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 @@ -11,8 +10,16 @@ const GqlQuery = preload("res://gql/query.gd") var houses = [] var exist_houses = SceneContext.get_selected_village()["houses"] +var query_executor = QueryExecutor.new() +var place_house_query_executor +var stage_tx_mutation_executor func _ready(): + place_house_query_executor = query_executor.place_house_query_executor + stage_tx_mutation_executor = query_executor.stage_tx_mutation_executor + add_child(place_house_query_executor) + add_child(stage_tx_mutation_executor) + var size = SceneContext.selected_village_capacity grid_container.columns = SceneContext.selected_village_width @@ -72,8 +79,8 @@ func _on_build_button_down(): build_house() func _query_relocation_cost_and_open(): - var gql_query = GqlQuery.new() - gql_query.calculate_relocation_cost_query.graphql_response.connect( + var cost_query_executor = query_executor.calculate_relocation_cost_query_executor + cost_query_executor.graphql_response.connect( func(data): var confirm_popup_scn = ConfirmPopupScn.instantiate() @@ -84,8 +91,8 @@ func _query_relocation_cost_and_open(): 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({ + add_child(cost_query_executor) + cost_query_executor.run({ "villageId": SceneContext.user_state["villageState"]["houseState"]["villageId"], "relocationVillageId": SceneContext.get_selected_village()["id"] }) @@ -95,25 +102,16 @@ func print_notice(): 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({}) + query_executor.stage_action( + { + "publicKey": GlobalSigner.signer.GetPublicKey(), + "villageId": SceneContext.get_selected_village()["id"], + "x": SceneContext.selected_house_location.x, + "y": SceneContext.selected_house_location.y, + }, + place_house_query_executor, + stage_tx_mutation_executor ) - add_child(query_executor) - query_executor.run({}) func _on_refresh_button_down(): Intro._query_villages() From 26ece483ef25be8a8ba46f86ec5446a5da91f5a9 Mon Sep 17 00:00:00 2001 From: Jiwon Date: Sat, 25 May 2024 18:50:25 +0900 Subject: [PATCH 3/4] Handle dungeon id nullable value (#191) --- .../Action/RegisterTradeGoodAction.cs | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/backend/app/Savor22b/Action/RegisterTradeGoodAction.cs b/backend/app/Savor22b/Action/RegisterTradeGoodAction.cs index b718b2ef..e5f9b898 100644 --- a/backend/app/Savor22b/Action/RegisterTradeGoodAction.cs +++ b/backend/app/Savor22b/Action/RegisterTradeGoodAction.cs @@ -7,9 +7,9 @@ namespace Savor22b.Action; using Libplanet.Assets; using Libplanet.Headless.Extensions; using Libplanet.State; +using Savor22b.Action.Exceptions; using Savor22b.States; using Savor22b.States.Trade; -using Savor22b.Action.Exceptions; [ActionType(nameof(RegisterTradeGoodAction))] public class RegisterTradeGoodAction : SVRAction @@ -53,7 +53,9 @@ public RegisterTradeGoodAction(FungibleAssetValue price, int dungeonId) { [nameof(Price)] = Price.ToBencodex(), [nameof(FoodStateId)] = FoodStateId.Serialize(), - [nameof(ItemStateIds)] = ItemStateIds is null ? Null.Value : (List)ItemStateIds.Select(i => i.Serialize()), + [nameof(ItemStateIds)] = ItemStateIds is null + ? Null.Value + : (List)ItemStateIds.Select(i => i.Serialize()), [nameof(DungeonId)] = DungeonId.Serialize(), }.ToImmutableDictionary(); @@ -61,8 +63,13 @@ protected override void LoadPlainValueInternal(IImmutableDictionary e.ToGuid()).ToImmutableList(); - DungeonId = plainValue[nameof(DungeonId)].ToInteger(); + ItemStateIds = + plainValue[nameof(ItemStateIds)] is Null + ? null + : ((List)plainValue[nameof(ItemStateIds)]) + .Select(e => e.ToGuid()) + .ToImmutableList(); + DungeonId = plainValue[nameof(DungeonId)].ToNullableInteger(); } public override IAccountStateDelta Execute(IActionContext ctx) @@ -77,10 +84,12 @@ public override IAccountStateDelta Execute(IActionContext ctx) RootState rootState = states.GetState(ctx.Signer) is Dictionary rootStateEncoded ? new RootState(rootStateEncoded) : new RootState(); - TradeInventoryState tradeInventoryState = states.GetState(TradeInventoryState.StateAddress) is Dictionary tradeInventoryStateEncoded + TradeInventoryState tradeInventoryState = states.GetState(TradeInventoryState.StateAddress) + is Dictionary tradeInventoryStateEncoded ? new TradeInventoryState(tradeInventoryStateEncoded) : new TradeInventoryState(); - GlobalDungeonState globalDungeonState = states.GetState(GlobalDungeonState.StateAddress) is Dictionary globalDungeonStateEncoded + GlobalDungeonState globalDungeonState = states.GetState(GlobalDungeonState.StateAddress) + is Dictionary globalDungeonStateEncoded ? new GlobalDungeonState(globalDungeonStateEncoded) : new GlobalDungeonState(); @@ -89,7 +98,12 @@ public override IAccountStateDelta Execute(IActionContext ctx) if (FoodStateId is not null) { var foodState = inventoryState.GetRefrigeratorItem(FoodStateId.Value); - var foodGoodState = new FoodGoodState(ctx.Signer, ctx.Random.GenerateRandomGuid(), Price, foodState); + var foodGoodState = new FoodGoodState( + ctx.Signer, + ctx.Random.GenerateRandomGuid(), + Price, + foodState + ); inventoryState = inventoryState.RemoveRefrigeratorItem(FoodStateId.Value); tradeInventoryState = tradeInventoryState.RegisterGood(foodGoodState); } @@ -106,7 +120,8 @@ public override IAccountStateDelta Execute(IActionContext ctx) ctx.Signer, ctx.Random.GenerateRandomGuid(), Price, - itemStates.ToImmutableList()); + itemStates.ToImmutableList() + ); tradeInventoryState = tradeInventoryState.RegisterGood(itemsGoodState); } @@ -116,7 +131,8 @@ public override IAccountStateDelta Execute(IActionContext ctx) ctx.Signer, ctx.Random.GenerateRandomGuid(), Price, - DungeonId.Value); + DungeonId.Value + ); if (!globalDungeonState.IsDungeonConquestAddress(DungeonId.Value, ctx.Signer)) { From 4e42bc3dbb6e05239b4b24922a477e24de071663 Mon Sep 17 00:00:00 2001 From: Tae Hyoung Kang <78776542+kth1888@users.noreply.github.com> Date: Wed, 29 May 2024 16:39:28 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[=EB=AC=B4=EC=97=AD=20=EC=83=81=EC=A0=90]?= =?UTF-8?q?=20=EC=9D=B8=EB=B2=A4=ED=86=A0=EB=A6=AC=20=EB=B0=8F=20=ED=8C=90?= =?UTF-8?q?=EB=A7=A4=EB=AA=A9=EB=A1=9D=20=EA=B5=AC=ED=98=84=20(#190)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: trade shop inventory implement * feat: trade shop sell list implement * fix: code feedback * fix : ui problems at feedback * fix : ui problems #2 * fix : ui problems #3 --- frontend/Savor-22b/gql/query.gd | 35 ++++++ frontend/Savor-22b/gql/query_executor.gd | 21 +++- frontend/Savor-22b/scenes/farm/farm.gd | 3 + frontend/Savor-22b/scenes/farm/farm.tscn | 7 ++ .../scenes/house/cook/cook_book.tscn | 1 - frontend/Savor-22b/scenes/house/food.gd | 2 +- frontend/Savor-22b/scenes/house/house.gd | 3 + frontend/Savor-22b/scenes/house/house.tscn | 24 ++-- frontend/Savor-22b/scenes/market/inventory.gd | 38 +++++++ .../Savor-22b/scenes/market/inventory.tscn | 80 +++++++++++++ frontend/Savor-22b/scenes/market/market.gd | 55 +++++++++ frontend/Savor-22b/scenes/market/market.tscn | 100 ++++++++++++++++ frontend/Savor-22b/scenes/market/my_item.gd | 24 ++++ frontend/Savor-22b/scenes/market/my_item.tscn | 96 ++++++++++++++++ .../Savor-22b/scenes/market/my_trade_goods.gd | 21 ++++ .../scenes/market/my_trade_goods.tscn | 92 +++++++++++++++ .../scenes/market/sell_list_button_group.tres | 3 + .../Savor-22b/scenes/market/trade_goods.gd | 22 ++++ .../Savor-22b/scenes/market/trade_goods.tscn | 80 +++++++++++++ .../scenes/market/trade_inventory.gd | 47 ++++++++ .../scenes/market/trade_inventory.tscn | 107 ++++++++++++++++++ .../Savor-22b/scenes/village/village_view.gd | 4 + .../scenes/village/village_view.tscn | 5 + 23 files changed, 859 insertions(+), 11 deletions(-) create mode 100644 frontend/Savor-22b/scenes/market/inventory.gd create mode 100644 frontend/Savor-22b/scenes/market/inventory.tscn create mode 100644 frontend/Savor-22b/scenes/market/market.gd create mode 100644 frontend/Savor-22b/scenes/market/market.tscn create mode 100644 frontend/Savor-22b/scenes/market/my_item.gd create mode 100644 frontend/Savor-22b/scenes/market/my_item.tscn create mode 100644 frontend/Savor-22b/scenes/market/my_trade_goods.gd create mode 100644 frontend/Savor-22b/scenes/market/my_trade_goods.tscn create mode 100644 frontend/Savor-22b/scenes/market/sell_list_button_group.tres create mode 100644 frontend/Savor-22b/scenes/market/trade_goods.gd create mode 100644 frontend/Savor-22b/scenes/market/trade_goods.tscn create mode 100644 frontend/Savor-22b/scenes/market/trade_inventory.gd create mode 100644 frontend/Savor-22b/scenes/market/trade_inventory.tscn diff --git a/frontend/Savor-22b/gql/query.gd b/frontend/Savor-22b/gql/query.gd index 217aeda0..e44cd488 100644 --- a/frontend/Savor-22b/gql/query.gd +++ b/frontend/Savor-22b/gql/query.gd @@ -75,3 +75,38 @@ var uninstall_kitchen_equipment_query = GQLQuery.new("createAction_UninstallKitc "publicKey": "publicKey", "spaceNumber": "spaceNumber" }); + +var register_trade_good_query = GQLQuery.new("createAction_RegisterTradeGoodAction").set_args({ + "publicKey": "publicKey", + "price": "price", + "foodStateId": "foodStateId", + "itemStateIds": "itemStateIds" +}); + +var trade_inventory_state_query = GQLQuery.new("tradeInventoryState").set_props([ + GQLQuery.new("tradeGoods").set_props([ + "sellerAddress", + "productStateId", + "price", + "type", + GQLQuery.new("food").set_props([ + "stateId", + "ingredientId", + "foodID", + "name", + "grade", + "hp", + "attack", + "defense", + "speed", + "isSuperFood", + "level", + "isAvailable" + ]), + GQLQuery.new("items").set_props([ + "stateID", + "itemID", + "itemName" + ]) + ]) +]) diff --git a/frontend/Savor-22b/gql/query_executor.gd b/frontend/Savor-22b/gql/query_executor.gd index 12c30ea7..7f74dbb7 100644 --- a/frontend/Savor-22b/gql/query_executor.gd +++ b/frontend/Savor-22b/gql/query_executor.gd @@ -45,7 +45,7 @@ var plant_seed_query_executor = SvrGqlClient.query( { "publicKey": "String!", "fieldIndex": "Int!", - "itemStateIdToUse": "Int!" + "itemStateIdToUse": "Guid!" }, gql_query.plant_seed_query ); @@ -125,6 +125,25 @@ var uninstall_kitchen_equipment_query_executor = SvrGqlClient.query( gql_query.uninstall_kitchen_equipment_query ); + +var register_trade_good_query_executor = SvrGqlClient.query( + 'RegisterTradeGood', + { + "publicKey": "String!", + "price": "Int!", + "foodStateId": "Guid", + "itemStateIds": "[Guid]" + }, + gql_query.register_trade_good_query +); + +var trade_inventory_state_executor = SvrGqlClient.query( + 'tradeInventoryState', + {}, + gql_query.trade_inventory_state_query +); + + func stage_action(params, query_executor, mutation_executor): query_executor.graphql_response.connect( func(data): diff --git a/frontend/Savor-22b/scenes/farm/farm.gd b/frontend/Savor-22b/scenes/farm/farm.gd index acb1e621..87ef735c 100644 --- a/frontend/Savor-22b/scenes/farm/farm.gd +++ b/frontend/Savor-22b/scenes/farm/farm.gd @@ -241,3 +241,6 @@ func _on_refresh_button_down(): func _on_home_button_down(): get_tree().change_scene_to_file("res://scenes/house/house.tscn") + +func _on_market_button_down(): + get_tree().change_scene_to_file("res://scenes/market/market.tscn") diff --git a/frontend/Savor-22b/scenes/farm/farm.tscn b/frontend/Savor-22b/scenes/farm/farm.tscn index 838188d2..9ab2bdee 100644 --- a/frontend/Savor-22b/scenes/farm/farm.tscn +++ b/frontend/Savor-22b/scenes/farm/farm.tscn @@ -94,6 +94,12 @@ size_flags_vertical = 0 theme_override_font_sizes/font_size = 50 text = "부엌으로" +[node name="MarketButton" type="Button" parent="MC/HC/VBoxContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 0 +theme_override_font_sizes/font_size = 50 +text = "무역 상점" + [node name="InventoryButton" type="Button" parent="MC/HC/VBoxContainer/MarginContainer/VBoxContainer"] layout_mode = 2 size_flags_vertical = 0 @@ -112,4 +118,5 @@ offset_right = 40.0 offset_bottom = 40.0 [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/MarketButton" to="." method="_on_market_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/scenes/house/cook/cook_book.tscn b/frontend/Savor-22b/scenes/house/cook/cook_book.tscn index 5e96b6c9..0dbb2154 100644 --- a/frontend/Savor-22b/scenes/house/cook/cook_book.tscn +++ b/frontend/Savor-22b/scenes/house/cook/cook_book.tscn @@ -1,7 +1,6 @@ [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/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/food.gd b/frontend/Savor-22b/scenes/house/food.gd index b77a9370..dbbb29dc 100644 --- a/frontend/Savor-22b/scenes/house/food.gd +++ b/frontend/Savor-22b/scenes/house/food.gd @@ -18,4 +18,4 @@ func _update_info(): 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 index d998ba36..60a3690d 100644 --- a/frontend/Savor-22b/scenes/house/house.gd +++ b/frontend/Savor-22b/scenes/house/house.gd @@ -107,6 +107,9 @@ func _on_farm_button_down(): func _on_village_button_down(): get_tree().change_scene_to_file("res://scenes/village/village_view.tscn") +func _on_market_button_down(): + get_tree().change_scene_to_file("res://scenes/market/market.tscn") + func _on_refresh_button_down(): clear_popup() reload_sub_scene() diff --git a/frontend/Savor-22b/scenes/house/house.tscn b/frontend/Savor-22b/scenes/house/house.tscn index 283d27df..58a4c35b 100644 --- a/frontend/Savor-22b/scenes/house/house.tscn +++ b/frontend/Savor-22b/scenes/house/house.tscn @@ -32,7 +32,7 @@ offset_right = 40.0 offset_bottom = 23.0 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 60 -text = " 집 화면" +text = " 집 " [node name="M" type="MarginContainer" parent="."] layout_mode = 1 @@ -56,47 +56,54 @@ theme_override_constants/margin_bottom = 20 custom_minimum_size = Vector2(500, 2.08165e-12) layout_mode = 2 size_flags_horizontal = 8 -columns = 5 +columns = 6 [node name="FarmButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 -theme_override_font_sizes/font_size = 50 +theme_override_font_sizes/font_size = 45 text = "밭으로" [node name="VillageButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 -theme_override_font_sizes/font_size = 50 +theme_override_font_sizes/font_size = 45 text = " 마을로 " +[node name="MarketButton" type="Button" parent="M/V/menus/V"] +custom_minimum_size = Vector2(200, 2.08165e-12) +layout_mode = 2 +size_flags_vertical = 0 +theme_override_font_sizes/font_size = 45 +text = " 무역 상점 " + [node name="RecipeButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 -theme_override_font_sizes/font_size = 50 +theme_override_font_sizes/font_size = 45 text = " 레시피북 " [node name="InventoryButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 -theme_override_font_sizes/font_size = 50 +theme_override_font_sizes/font_size = 45 text = " 인벤토리 " [node name="RefreshButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 -theme_override_font_sizes/font_size = 50 +theme_override_font_sizes/font_size = 45 text = " 새로고침 " [node name="M" type="MarginContainer" parent="M/V/menus"] layout_mode = 2 size_flags_horizontal = 0 -theme_override_constants/margin_left = 250 +theme_override_constants/margin_left = 100 [node name="CookButton" type="Button" parent="M/V/menus/M"] custom_minimum_size = Vector2(380, 2.08165e-12) @@ -132,6 +139,7 @@ offset_bottom = 340.0 [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/MarketButton" to="." method="_on_market_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"] diff --git a/frontend/Savor-22b/scenes/market/inventory.gd b/frontend/Savor-22b/scenes/market/inventory.gd new file mode 100644 index 00000000..cc668d3b --- /dev/null +++ b/frontend/Savor-22b/scenes/market/inventory.gd @@ -0,0 +1,38 @@ +extends Control + +const MyItemScn = preload("res://scenes/market/my_item.tscn") + +@onready var inventory_container = $MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer/MarginContainer/GridContainer + +var items +var grouped_items = {} + +func _ready(): + load_items() + + +func load_items(): + items = SceneContext.user_state.inventoryState["refrigeratorStateList"] + sort_inventory_by_items() + + for item in grouped_items.values(): + for grade in item.values(): + var item_scene = MyItemScn.instantiate() + item_scene.set_info(grade) + inventory_container.add_child(item_scene) + +func sort_inventory_by_items(): + for item in items: + var name = item["name"] + var grade = item["grade"] + + # 이름이 존재하지 않으면 새로 추가 + if not grouped_items.has(name): + grouped_items[name] = {} + + # 등급이 존재하지 않으면 이름 하위에 새로 추가 + if not grouped_items[name].has(grade): + grouped_items[name][grade] = [] + + # 아이템을 등급 배열에 추가 + grouped_items[name][grade].append(item) diff --git a/frontend/Savor-22b/scenes/market/inventory.tscn b/frontend/Savor-22b/scenes/market/inventory.tscn new file mode 100644 index 00000000..d3ec04c3 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/inventory.tscn @@ -0,0 +1,80 @@ +[gd_scene load_steps=4 format=3 uid="uid://81w3i6nbxjix"] + +[ext_resource type="Script" path="res://scenes/market/inventory.gd" id="1_xk4wq"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8vjfi"] +bg_color = Color(0, 0, 0, 0) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_as0cg"] +bg_color = Color(0.94902, 0.694118, 0.243137, 1) + +[node name="Inventory" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -1220.0 +offset_bottom = -130.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_xk4wq") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 3 + +[node name="TitlePanel" type="Panel" parent="MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(200, 70) +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_styles/panel = SubResource("StyleBoxFlat_8vjfi") + +[node name="TitleLabel" type="Label" parent="MarginContainer/VBoxContainer/TitlePanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 40 +text = "인벤토리" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="InventoryPanel" type="Panel" parent="MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(2.08165e-12, 750) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_as0cg") + +[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer/InventoryPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer"] +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 20 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 20 + +[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer/MarginContainer"] +layout_mode = 2 +theme_override_constants/h_separation = 25 +theme_override_constants/v_separation = 50 +columns = 2 diff --git a/frontend/Savor-22b/scenes/market/market.gd b/frontend/Savor-22b/scenes/market/market.gd new file mode 100644 index 00000000..036a0e58 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/market.gd @@ -0,0 +1,55 @@ +extends Control + +signal query_received + +const InventoryScn = preload("res://scenes/market/inventory.tscn") +const SellListScn = preload("res://scenes/market/trade_inventory.tscn") + +@onready var inventory_container = $VBoxContainer/MarginContainer/SubMenuHBoxContainer/InventoryMarginContainer +@onready var trade_inventory_container = $VBoxContainer/MarginContainer/SubMenuHBoxContainer/SellListMarginContainer + +var query_executor = QueryExecutor.new() +var stage_tx_mutation_executor +var trade_inventory_state_executor + +var inventory_state + +func _ready(): + stage_tx_mutation_executor = query_executor.stage_tx_mutation_executor + trade_inventory_state_executor = query_executor.trade_inventory_state_executor + add_child(stage_tx_mutation_executor) + add_child(trade_inventory_state_executor) + + load_initial_scene() + +func load_initial_scene(): + load_inventory() + + query_trade_inventory_state() + query_received.connect(load_trade_inventory) + +func load_inventory(): + var inventory = InventoryScn.instantiate() + inventory_container.add_child(inventory) + +func load_trade_inventory(): + if (inventory_state != null): + var trade_inventory = SellListScn.instantiate() + trade_inventory_container.add_child(trade_inventory) + trade_inventory.set_list(inventory_state) + +func props_only_query_action(query_executor): # query with no args + query_executor.graphql_response.connect( + func(data): + inventory_state = data["data"]["tradeInventoryState"]["tradeGoods"] + query_received.emit() + ) + query_executor.run({}) + +func query_trade_inventory_state(): + props_only_query_action( + trade_inventory_state_executor + ) + +func _on_village_button_down(): + get_tree().change_scene_to_file("res://scenes/village/village_view.tscn") diff --git a/frontend/Savor-22b/scenes/market/market.tscn b/frontend/Savor-22b/scenes/market/market.tscn new file mode 100644 index 00000000..537e9a23 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/market.tscn @@ -0,0 +1,100 @@ +[gd_scene load_steps=3 format=3 uid="uid://5hl0imlbiaaj"] + +[ext_resource type="Script" path="res://scenes/market/market.gd" id="1_ibysf"] +[ext_resource type="PackedScene" uid="uid://co4t4p5pawylr" path="res://scenes/common/prefabs/asset.tscn" id="2_mauxh"] + +[node name="Market" 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_ibysf") + +[node name="Background" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Title" type="Label" parent="Background"] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 23.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 60 +text = " 무역 상점" + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +custom_minimum_size = Vector2(1920, 1080) +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = 4.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 20 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 20 + +[node name="TopMenuHBoxContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer2"] +layout_mode = 2 +theme_override_constants/separation = 50 +alignment = 2 + +[node name="AssetPanel" type="Panel" parent="VBoxContainer/MarginContainer2/TopMenuHBoxContainer"] +custom_minimum_size = Vector2(600, 2.08165e-12) +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/MarginContainer2/TopMenuHBoxContainer/AssetPanel"] +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_right = 50 + +[node name="Asset" parent="VBoxContainer/MarginContainer2/TopMenuHBoxContainer/AssetPanel/MarginContainer" instance=ExtResource("2_mauxh")] +layout_mode = 2 + +[node name="VillageButton" type="Button" parent="VBoxContainer/MarginContainer2/TopMenuHBoxContainer"] +custom_minimum_size = Vector2(200, 2.08165e-12) +layout_mode = 2 +size_flags_vertical = 0 +theme_override_font_sizes/font_size = 50 +text = " 마을로 " + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"] +custom_minimum_size = Vector2(1920, 950) +layout_mode = 2 + +[node name="SubMenuHBoxContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer"] +layout_mode = 2 + +[node name="InventoryMarginContainer" type="MarginContainer" parent="VBoxContainer/MarginContainer/SubMenuHBoxContainer"] +custom_minimum_size = Vector2(700, 2.08165e-12) +layout_mode = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 50 + +[node name="SellListMarginContainer" type="MarginContainer" parent="VBoxContainer/MarginContainer/SubMenuHBoxContainer"] +custom_minimum_size = Vector2(1220, 2.08165e-12) +layout_mode = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 50 + +[connection signal="button_down" from="VBoxContainer/MarginContainer2/TopMenuHBoxContainer/VillageButton" to="." method="_on_village_button_down"] diff --git a/frontend/Savor-22b/scenes/market/my_item.gd b/frontend/Savor-22b/scenes/market/my_item.gd new file mode 100644 index 00000000..440971ad --- /dev/null +++ b/frontend/Savor-22b/scenes/market/my_item.gd @@ -0,0 +1,24 @@ +extends Control + +@onready var item_name_label = $Background/MarginContainer/VBoxContainer/NameLabel +@onready var item_grade_label = $Background/MarginContainer/VBoxContainer/HBoxContainer/GradeLabel +@onready var item_amount_label = $Background/MarginContainer/VBoxContainer/HBoxContainer/AmountLabel + +var info + +func _ready(): + _update_info() + +func _update_info(): + if $Background == null: + return + + item_name_label.text = info[0]["name"] + item_grade_label.text = info[0]["grade"] + "등급" + item_amount_label.text = "%s 개" % [info.size()] + +func set_info(info: Array): + self.info = info + +func _on_register_trade_button_down(): + pass # 물건 올리기 기능이 들어갈 예정 diff --git a/frontend/Savor-22b/scenes/market/my_item.tscn b/frontend/Savor-22b/scenes/market/my_item.tscn new file mode 100644 index 00000000..e6076ec7 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/my_item.tscn @@ -0,0 +1,96 @@ +[gd_scene load_steps=4 format=3 uid="uid://c7yghm5bsqwif"] + +[ext_resource type="Script" path="res://scenes/market/my_item.gd" id="1_5wh4n"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_21if1"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 30 +corner_radius_top_right = 30 +corner_radius_bottom_right = 30 +corner_radius_bottom_left = 30 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_oq8hu"] +bg_color = Color(0, 0, 0, 1) +border_width_left = 3 +border_width_top = 3 +border_width_right = 3 +border_width_bottom = 3 +border_color = Color(1, 1, 1, 1) +corner_radius_top_left = 15 +corner_radius_top_right = 15 +corner_radius_bottom_right = 15 +corner_radius_bottom_left = 15 + +[node name="MyItem" type="Control"] +custom_minimum_size = Vector2(320, 190) +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -1610.0 +offset_bottom = -890.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_5wh4n") + +[node name="Background" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_21if1") + +[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 = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 5 + +[node name="VBoxContainer" type="VBoxContainer" parent="Background/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 10 + +[node name="NameLabel" type="Label" parent="Background/MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +text = "아이템 이름" + +[node name="HBoxContainer" type="HBoxContainer" parent="Background/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="AmountLabel" type="Label" parent="Background/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 25 +text = "10 개" +horizontal_alignment = 2 + +[node name="MarginContainer" type="MarginContainer" parent="Background/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="GradeLabel" type="Label" parent="Background/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 25 +text = "A등급" +horizontal_alignment = 2 + +[node name="RegisterTradeButton" type="Button" parent="Background/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 8 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 35 +theme_override_styles/normal = SubResource("StyleBoxFlat_oq8hu") +text = " 아이템 등록하기 " + +[connection signal="button_down" from="Background/MarginContainer/VBoxContainer/RegisterTradeButton" to="." method="_on_register_trade_button_down"] diff --git a/frontend/Savor-22b/scenes/market/my_trade_goods.gd b/frontend/Savor-22b/scenes/market/my_trade_goods.gd new file mode 100644 index 00000000..d2791664 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/my_trade_goods.gd @@ -0,0 +1,21 @@ +extends Control + +@onready var item_button = $ItemSelectButton +@onready var description_label = $BackgroundPanel/MarginContainer/VBoxContainer/DescriptionLabel + +var info +var desc_format_string = "%s : %s +%s %s +%s : %s +%s : %s%s" + +func _ready(): + _update_info() + +func _update_info(): + if description_label == null: + return + description_label.text = desc_format_string % ["품목명",info.food["name"],info.food["grade"]," 등급","stateId",info.food["stateId"],"가격",info.price," BBG"] + +func set_info(info: Dictionary): + self.info = info diff --git a/frontend/Savor-22b/scenes/market/my_trade_goods.tscn b/frontend/Savor-22b/scenes/market/my_trade_goods.tscn new file mode 100644 index 00000000..e341a11d --- /dev/null +++ b/frontend/Savor-22b/scenes/market/my_trade_goods.tscn @@ -0,0 +1,92 @@ +[gd_scene load_steps=4 format=3 uid="uid://bwosqhxgrw2w5"] + +[ext_resource type="Script" path="res://scenes/market/my_trade_goods.gd" id="1_4ajeb"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3bs65"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 40 +corner_radius_top_right = 40 +corner_radius_bottom_right = 40 +corner_radius_bottom_left = 40 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_lobix"] +bg_color = Color(0, 0, 0, 1) +border_width_left = 3 +border_width_top = 3 +border_width_right = 3 +border_width_bottom = 3 +border_color = Color(1, 1, 1, 1) +corner_radius_top_left = 15 +corner_radius_top_right = 15 +corner_radius_bottom_right = 15 +corner_radius_bottom_left = 15 + +[node name="MyTradeGoods" type="Control"] +custom_minimum_size = Vector2(500, 430) +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -25.0 +offset_right = -1445.0 +offset_bottom = -670.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_4ajeb") + +[node name="BackgroundPanel" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_3bs65") + +[node name="MarginContainer" type="MarginContainer" parent="BackgroundPanel"] +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 = 25 +theme_override_constants/margin_top = 30 +theme_override_constants/margin_right = 25 +theme_override_constants/margin_bottom = 30 + +[node name="VBoxContainer" type="VBoxContainer" parent="BackgroundPanel/MarginContainer"] +layout_mode = 2 + +[node name="DescriptionLabel" type="Label" parent="BackgroundPanel/MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(2.08165e-12, 280) +layout_mode = 2 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 30 +text = "품목명 : 참치 +A 등급 +foodstateId : ~~ +가격 : 10 +" +autowrap_mode = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="BackgroundPanel/MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/separation = 20 +alignment = 2 + +[node name="PriceEditButton" type="Button" parent="BackgroundPanel/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 8 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_lobix") +text = " 가격 수정 " + +[node name="CancelButton" type="Button" parent="BackgroundPanel/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 8 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_lobix") +text = " 등록 취소 " diff --git a/frontend/Savor-22b/scenes/market/sell_list_button_group.tres b/frontend/Savor-22b/scenes/market/sell_list_button_group.tres new file mode 100644 index 00000000..5c8d95f1 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/sell_list_button_group.tres @@ -0,0 +1,3 @@ +[gd_resource type="ButtonGroup" format=3 uid="uid://di66p0jb8cdpk"] + +[resource] diff --git a/frontend/Savor-22b/scenes/market/trade_goods.gd b/frontend/Savor-22b/scenes/market/trade_goods.gd new file mode 100644 index 00000000..49276702 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/trade_goods.gd @@ -0,0 +1,22 @@ +extends Control + +@onready var item_button = $ItemSelectButton +@onready var description_label = $BackgroundPanel/MarginContainer/VBoxContainer/DescriptionLabel + +var info +var desc_format_string = "%s : %s +%s %s +%s : %s +%s : %s%s +%s : %s" + +func _ready(): + _update_info() + +func _update_info(): + if description_label == null: + return + description_label.text = desc_format_string % ["품목명",info.food["name"],info.food["grade"]," 등급","stateId",info.food["stateId"],"가격",info.price," BBG","게시자",info.sellerAddress] + +func set_info(info: Dictionary): + self.info = info diff --git a/frontend/Savor-22b/scenes/market/trade_goods.tscn b/frontend/Savor-22b/scenes/market/trade_goods.tscn new file mode 100644 index 00000000..c8f28daa --- /dev/null +++ b/frontend/Savor-22b/scenes/market/trade_goods.tscn @@ -0,0 +1,80 @@ +[gd_scene load_steps=4 format=3 uid="uid://crw3yutudcodf"] + +[ext_resource type="Script" path="res://scenes/market/trade_goods.gd" id="1_vfbu4"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3bs65"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 40 +corner_radius_top_right = 40 +corner_radius_bottom_right = 40 +corner_radius_bottom_left = 40 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_lobix"] +bg_color = Color(0, 0, 0, 1) +border_width_left = 3 +border_width_top = 3 +border_width_right = 3 +border_width_bottom = 3 +border_color = Color(1, 1, 1, 1) +corner_radius_top_left = 15 +corner_radius_top_right = 15 +corner_radius_bottom_right = 15 +corner_radius_bottom_left = 15 + +[node name="TradeGoods" type="Control"] +custom_minimum_size = Vector2(500, 430) +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -25.0 +offset_right = -1445.0 +offset_bottom = -670.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_vfbu4") + +[node name="BackgroundPanel" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_3bs65") + +[node name="MarginContainer" type="MarginContainer" parent="BackgroundPanel"] +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 = 25 +theme_override_constants/margin_top = 30 +theme_override_constants/margin_right = 25 +theme_override_constants/margin_bottom = 30 + +[node name="VBoxContainer" type="VBoxContainer" parent="BackgroundPanel/MarginContainer"] +layout_mode = 2 + +[node name="DescriptionLabel" type="Label" parent="BackgroundPanel/MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(2.08165e-12, 280) +layout_mode = 2 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 30 +text = "품목명 : 김 +A 등급 +foodstateId : dbfb5df1-9a5a-4f03-b19b-f385595ddc14 +가격 : 10 +게시자 : 0xae9bbb0090e20a8d1c8c3a2667b55951f8e +" +autowrap_mode = 1 + +[node name="BuyButton" type="Button" parent="BackgroundPanel/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 8 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_lobix") +text = " 구매 " diff --git a/frontend/Savor-22b/scenes/market/trade_inventory.gd b/frontend/Savor-22b/scenes/market/trade_inventory.gd new file mode 100644 index 00000000..7874c232 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/trade_inventory.gd @@ -0,0 +1,47 @@ +extends Control + +const TradeGoodsScn = preload("res://scenes/market/trade_goods.tscn") +const MyTradeGoodsScn = preload("res://scenes/market/my_trade_goods.tscn") + +@onready var list_container = $MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer/CenterContainer/GridContainer + +var goods +var my_address = GlobalSigner.signer_address + +func _ready(): + pass + +func set_list(data: Array): + goods = data + load_list() + +func load_list(): + clear_list_panel() + + for good in goods: + if(good["sellerAddress"] != my_address): + add_lists(good, false) + +func _on_my_sell_list_button_down(): + clear_list_panel() + + for good in goods: + if(good["sellerAddress"] == my_address): + add_lists(good, true) + +func clear_list_panel(): + if is_instance_valid(list_container): + for posted_item in list_container.get_children(): + posted_item.queue_free() + +func add_lists(good: Dictionary, is_mine: bool): + var trade_goods_scene + if(!is_mine): + trade_goods_scene = TradeGoodsScn.instantiate() + else: + trade_goods_scene = MyTradeGoodsScn.instantiate() + trade_goods_scene.set_info(good) + list_container.add_child(trade_goods_scene) + +func _on_whole_sell_list_button_down(): + load_list() diff --git a/frontend/Savor-22b/scenes/market/trade_inventory.tscn b/frontend/Savor-22b/scenes/market/trade_inventory.tscn new file mode 100644 index 00000000..3168a5a5 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/trade_inventory.tscn @@ -0,0 +1,107 @@ +[gd_scene load_steps=7 format=3 uid="uid://bu43d13qwmtcr"] + +[ext_resource type="Script" path="res://scenes/market/trade_inventory.gd" id="1_2sbin"] +[ext_resource type="ButtonGroup" uid="uid://di66p0jb8cdpk" path="res://scenes/market/sell_list_button_group.tres" id="2_68j2i"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4l2s6"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 25 +corner_radius_top_right = 25 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vqa0t"] +bg_color = Color(0.94902, 0.694118, 0.243137, 1) +corner_radius_top_left = 25 +corner_radius_top_right = 25 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_af182"] +bg_color = Color(0.94902, 0.694118, 0.243137, 1) +corner_radius_top_left = 25 +corner_radius_top_right = 25 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_as0cg"] +bg_color = Color(0.94902, 0.694118, 0.243137, 1) + +[node name="SellList" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -700.0 +offset_bottom = -130.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_2sbin") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = -1 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/separation = 20 + +[node name="WholeSellListButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] +custom_minimum_size = Vector2(200, 70) +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_4l2s6") +theme_override_styles/pressed = SubResource("StyleBoxFlat_vqa0t") +theme_override_styles/focus = SubResource("StyleBoxFlat_vqa0t") +toggle_mode = true +button_pressed = true +button_group = ExtResource("2_68j2i") +text = "판매목록" + +[node name="MySellListButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] +custom_minimum_size = Vector2(240, 70) +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_4l2s6") +theme_override_styles/pressed = SubResource("StyleBoxFlat_af182") +theme_override_styles/focus = SubResource("StyleBoxFlat_af182") +toggle_mode = true +button_group = ExtResource("2_68j2i") +text = "내 판매목록" + +[node name="ListPanel" type="Panel" parent="MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(2.08165e-12, 750) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_as0cg") + +[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer/ListPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 50 + +[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer"] +layout_mode = 2 + +[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer/CenterContainer"] +layout_mode = 2 +theme_override_constants/h_separation = 50 +theme_override_constants/v_separation = 50 +columns = 2 + +[connection signal="button_down" from="MarginContainer/VBoxContainer/HBoxContainer/WholeSellListButton" to="." method="_on_whole_sell_list_button_down"] +[connection signal="button_down" from="MarginContainer/VBoxContainer/HBoxContainer/MySellListButton" to="." method="_on_my_sell_list_button_down"] diff --git a/frontend/Savor-22b/scenes/village/village_view.gd b/frontend/Savor-22b/scenes/village/village_view.gd index 995eb494..1264eb52 100644 --- a/frontend/Savor-22b/scenes/village/village_view.gd +++ b/frontend/Savor-22b/scenes/village/village_view.gd @@ -66,6 +66,8 @@ func _on_enter_button_down(): 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: @@ -73,3 +75,5 @@ func _input(event): var shop = SystemShopScn.instantiate() popups.add_child(shop) shop.set_position(Vector2(400, 150)) + + diff --git a/frontend/Savor-22b/scenes/village/village_view.tscn b/frontend/Savor-22b/scenes/village/village_view.tscn index b2800bc0..a1995620 100644 --- a/frontend/Savor-22b/scenes/village/village_view.tscn +++ b/frontend/Savor-22b/scenes/village/village_view.tscn @@ -68,6 +68,11 @@ grow_vertical = 2 theme_override_font_sizes/font_size = 70 text = " 내 밭으로 가기 " +[node name="HBoxContainer" type="HBoxContainer" parent="TopMenuMarginContainer/Control"] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 + [node name="BottomMenuMarginContainer" type="MarginContainer" parent="."] layout_mode = 0 offset_top = 940.0