Skip to content

Commit

Permalink
Implement uninstall kitchen equipment (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
Atralupus authored Apr 23, 2024
1 parent 462d8f8 commit 66f901f
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 1 deletion.
7 changes: 7 additions & 0 deletions frontend/Savor-22b/gql/query.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions frontend/Savor-22b/scenes/house/Kitchen/big_tool_slot.gd
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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()
Expand All @@ -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)
5 changes: 5 additions & 0 deletions frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ extends Control

@onready var button = $Button

signal uninstall_big_tool_button_pressed

var data: Dictionary

var format_string = "[%s] 도구 설치됨
Expand All @@ -24,3 +26,6 @@ func set_data(info: Dictionary):
data = info


func _on_uninstall_button_pressed():
uninstall_big_tool_button_pressed.emit(data.spaceNumber)

2 changes: 2 additions & 0 deletions frontend/Savor-22b/scenes/house/Kitchen/tool_not_used.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ text = "[-- -] 도구 설치됨
식재료 사용 시
요리 조리 가능"

[connection signal="pressed" from="Button" to="." method="_on_uninstall_button_pressed"]
8 changes: 8 additions & 0 deletions frontend/Savor-22b/scenes/house/house.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
36 changes: 36 additions & 0 deletions frontend/Savor-22b/scripts/scenes/house.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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({})

1 change: 0 additions & 1 deletion frontend/Savor-22b/scripts/scenes/select_house.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 66f901f

Please sign in to comment.