diff --git a/frontend/Savor-22b/gql/query.gd b/frontend/Savor-22b/gql/query.gd index b99948d1..b3776f4f 100644 --- a/frontend/Savor-22b/gql/query.gd +++ b/frontend/Savor-22b/gql/query.gd @@ -79,6 +79,13 @@ var install_kitchen_equipment_query_format = "query { ) }" +var uninstall_kitchen_equipment_query_format = "query { + createAction_UninstallKitchenEquipmentActionQuery( + publicKey: {}, + spaceNumber: {}, + ) +}" + var calculate_relocation_cost_query_template = GQLQuery.new("calculateRelocationCost").set_args({ "villageId": "villageId", "relocationVillageId": "relocationVillageId", diff --git a/frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.gd b/frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.gd index 814aa518..9803b262 100644 --- a/frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.gd +++ b/frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.gd @@ -1,6 +1,7 @@ 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") @@ -47,6 +48,7 @@ func set_slot(name : String): 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"]) else: # cooking var bigslot = SLOT_USED.instantiate() @@ -55,3 +57,6 @@ func set_slot(name : String): 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/tool_not_used.gd b/frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.gd index 76948931..b5384d4f 100644 --- a/frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.gd +++ b/frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.gd @@ -2,6 +2,8 @@ extends Control @onready var button = $Button +signal uninstall_big_tool_button_pressed + var data: Dictionary var format_string = "[%s] 도구 설치됨 @@ -24,3 +26,6 @@ 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 index f5c25a90..ed1b7596 100644 --- a/frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.tscn +++ b/frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.tscn @@ -37,3 +37,5 @@ text = "[-- -] 도구 설치됨 식재료 사용 시 요리 조리 가능" + +[connection signal="pressed" from="Button" to="." method="_on_uninstall_button_pressed"] diff --git a/frontend/Savor-22b/scenes/house/house.tscn b/frontend/Savor-22b/scenes/house/house.tscn index c4bd89ee..33bcd9a0 100644 --- a/frontend/Savor-22b/scenes/house/house.tscn +++ b/frontend/Savor-22b/scenes/house/house.tscn @@ -122,6 +122,14 @@ anchors_preset = 0 offset_right = 40.0 offset_bottom = 40.0 +[node name="ConfirmPopup" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 0 +offset_left = 600.0 +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"] diff --git a/frontend/Savor-22b/scripts/scenes/house.gd b/frontend/Savor-22b/scripts/scenes/house.gd index 16c17cf0..fe30f44d 100644 --- a/frontend/Savor-22b/scripts/scenes/house.gd +++ b/frontend/Savor-22b/scripts/scenes/house.gd @@ -11,10 +11,13 @@ const LARGE_COOK = preload("res://scenes/house/Kitchen/big_tool_slot.tscn") const LARGE_INSTALLER = preload("res://scenes/house/bigtool_install_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 @@ -124,6 +127,7 @@ func load_kitchen(): 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): @@ -167,3 +171,35 @@ func install_tool(stateId : String): ) add_child(query_executor) query_executor.run({}) + +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 index a6436dc5..7f1c056e 100644 --- a/frontend/Savor-22b/scripts/scenes/select_house.gd +++ b/frontend/Savor-22b/scripts/scenes/select_house.gd @@ -78,7 +78,6 @@ func _on_build_button_button_down(): var villageState = SceneContext.user_state["villageState"] if(villageState != null): isHouseOwner = true - print(isHouseOwner) if (isHouseOwner): _query_relocation_cost_and_open()