From 44d3628359b0230b75dfcbba3398011c5a0cb01e Mon Sep 17 00:00:00 2001 From: Tae Hyoung Kang <78776542+kth1888@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:53:08 +0900 Subject: [PATCH 1/2] feat: kitchentool buyaction impl --- frontend/Savor-22b/gql/query.gd | 7 +++ frontend/Savor-22b/scenes/house/house.tscn | 5 ++ .../Savor-22b/scenes/house/house_inventory.gd | 6 +++ .../Savor-22b/scenes/house/kitchenshop.gd | 5 ++ frontend/Savor-22b/scenes/house/tool.gd | 10 ++++ frontend/Savor-22b/scenes/house/tool.tscn | 17 ++++++- frontend/Savor-22b/scripts/scenes/house.gd | 50 ++++++++++++++++++- 7 files changed, 97 insertions(+), 3 deletions(-) diff --git a/frontend/Savor-22b/gql/query.gd b/frontend/Savor-22b/gql/query.gd index ac3ef4c1..aa0bf256 100644 --- a/frontend/Savor-22b/gql/query.gd +++ b/frontend/Savor-22b/gql/query.gd @@ -55,3 +55,10 @@ var buy_shop_item_query_format = "query { desiredShopItemID: {} ) }" + +var buy_kitchen_equipment_query_format = "query { + createAction_BuyKitchenEquipment( + publicKey: {}, + desiredEquipmentID: {} + ) +}" diff --git a/frontend/Savor-22b/scenes/house/house.tscn b/frontend/Savor-22b/scenes/house/house.tscn index 54a88677..7eb9e7ef 100644 --- a/frontend/Savor-22b/scenes/house/house.tscn +++ b/frontend/Savor-22b/scenes/house/house.tscn @@ -74,4 +74,9 @@ theme_override_constants/margin_left = 20 theme_override_constants/margin_right = 20 theme_override_constants/margin_bottom = 20 +[node name="Popups" type="Control" parent="."] +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 + [connection signal="button_down" from="M/V/menus/V/InventoryButton" to="." method="_on_inventory_button_button_down"] diff --git a/frontend/Savor-22b/scenes/house/house_inventory.gd b/frontend/Savor-22b/scenes/house/house_inventory.gd index ac2c4cda..80c00229 100644 --- a/frontend/Savor-22b/scenes/house/house_inventory.gd +++ b/frontend/Savor-22b/scenes/house/house_inventory.gd @@ -5,6 +5,8 @@ const KITCHEN_SHOP = preload("res://scenes/house/kitchenshop.tscn") @onready var panel = $M/V/Panel/C +signal buysignal + func _ready(): var kitchens = KITCHEN_TOOLS.instantiate() @@ -23,9 +25,13 @@ func _on_shop_button_down(): clear_popup() var kitchens = KITCHEN_SHOP.instantiate() + kitchens.buysignal.connect(popup) panel.add_child(kitchens) func clear_popup(): if is_instance_valid(panel): for pop in panel.get_children(): pop.queue_free() + +func popup(): + buysignal.emit() diff --git a/frontend/Savor-22b/scenes/house/kitchenshop.gd b/frontend/Savor-22b/scenes/house/kitchenshop.gd index 9c9dc150..10fd0c16 100644 --- a/frontend/Savor-22b/scenes/house/kitchenshop.gd +++ b/frontend/Savor-22b/scenes/house/kitchenshop.gd @@ -4,6 +4,8 @@ const TOOL = preload("res://scenes/house/tool.tscn") @onready var grid = $M/V/Items/G +signal buysignal + var list func _ready(): @@ -13,5 +15,8 @@ func _ready(): var toolpanel = TOOL.instantiate() toolpanel.set_slottype() toolpanel.set_info(tool) + toolpanel.buysignal.connect(popup) grid.add_child(toolpanel) +func popup(): + buysignal.emit() diff --git a/frontend/Savor-22b/scenes/house/tool.gd b/frontend/Savor-22b/scenes/house/tool.gd index 4c53e098..ddd62ab8 100644 --- a/frontend/Savor-22b/scenes/house/tool.gd +++ b/frontend/Savor-22b/scenes/house/tool.gd @@ -2,6 +2,9 @@ extends Panel @onready var toolname = $M/V/Name @onready var tooldesc = $M/V/Desc +@onready var buybutton = $M/V/Buy + +signal buysignal var info var isshop: bool = false @@ -20,6 +23,7 @@ func _update_info(): if (isshop): toolname.text = info.name tooldesc.text = desc_format_string % [info.categoryType, info.categoryLabel, "Price", info.price, "BBG"] + buybutton.visible = true else: toolname.text = info.equipmentName tooldesc.text = info.stateId @@ -31,3 +35,9 @@ func set_slottype(): self.isshop = true _update_info() + + +func _on_buy_button_down(): + SceneContext.selected_item_index = info.id + SceneContext.selected_item_name = info.name + buysignal.emit() diff --git a/frontend/Savor-22b/scenes/house/tool.tscn b/frontend/Savor-22b/scenes/house/tool.tscn index 6bbfe77e..45e41a57 100644 --- a/frontend/Savor-22b/scenes/house/tool.tscn +++ b/frontend/Savor-22b/scenes/house/tool.tscn @@ -1,10 +1,13 @@ -[gd_scene load_steps=3 format=3 uid="uid://cjlj4mej5h001"] +[gd_scene load_steps=4 format=3 uid="uid://cjlj4mej5h001"] [ext_resource type="Script" path="res://scenes/house/tool.gd" id="1_fsq81"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_x6mfd"] bg_color = Color(1, 0.541176, 0, 1) +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_v31jt"] +bg_color = Color(0, 0, 0, 1) + [node name="Tool" type="Panel"] custom_minimum_size = Vector2(300, 200) offset_right = 300.0 @@ -38,10 +41,20 @@ theme_override_font_sizes/font_size = 40 text = "조리도구 이름" [node name="Desc" type="Label" parent="M/V"] -custom_minimum_size = Vector2(260, 132) +custom_minimum_size = Vector2(260, 82) layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 30 text = "조리도구 설명" autowrap_mode = 1 max_lines_visible = 3 + +[node name="Buy" type="Button" parent="M/V"] +visible = false +layout_mode = 2 +size_flags_horizontal = 8 +theme_override_font_sizes/font_size = 20 +theme_override_styles/normal = SubResource("StyleBoxFlat_v31jt") +text = " 구매 " + +[connection signal="button_down" from="M/V/Buy" to="." method="_on_buy_button_down"] diff --git a/frontend/Savor-22b/scripts/scenes/house.gd b/frontend/Savor-22b/scripts/scenes/house.gd index e3f0dac4..29a26827 100644 --- a/frontend/Savor-22b/scripts/scenes/house.gd +++ b/frontend/Savor-22b/scripts/scenes/house.gd @@ -1,8 +1,12 @@ 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 Gql_query = preload("res://gql/query.gd") @onready var subscene = $M/V/subscene +@onready var popup = $Popups func _ready(): pass # Replace with function body. @@ -12,5 +16,49 @@ func _ready(): func _on_inventory_button_button_down(): var inventory = HOUSE_INVENTORY.instantiate() - + inventory.buysignal.connect(buypopup) subscene.add_child(inventory) + + +func buypopup(): + var askpopup = ASK_POPUP.instantiate() + askpopup.set_itemname(SceneContext.selected_item_name) + askpopup.buy_button_down.connect(buyaction) + popup.add_child(askpopup) + +func buyaction(): + clear_popup() + buytool() + + var donepopup = DONE_POPUP.instantiate() + 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() From 259af12a2b5509a7d38d2f614ebd8788e912a349 Mon Sep 17 00:00:00 2001 From: Tae Hyoung Kang <78776542+kth1888@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:05:09 +0900 Subject: [PATCH 2/2] ui: added ui action details --- frontend/Savor-22b/scenes/house/house.tscn | 1 + frontend/Savor-22b/scenes/house/house_inventory.gd | 7 +++++-- frontend/Savor-22b/scenes/house/kitchenshop.gd | 6 ++++++ frontend/Savor-22b/scenes/house/kitchenshop.tscn | 2 ++ frontend/Savor-22b/scenes/house/kitchentools.gd | 8 ++++++++ frontend/Savor-22b/scenes/house/kitchentools.tscn | 2 ++ frontend/Savor-22b/scripts/scenes/house.gd | 11 +++++++++++ 7 files changed, 35 insertions(+), 2 deletions(-) diff --git a/frontend/Savor-22b/scenes/house/house.tscn b/frontend/Savor-22b/scenes/house/house.tscn index 7eb9e7ef..46f55419 100644 --- a/frontend/Savor-22b/scenes/house/house.tscn +++ b/frontend/Savor-22b/scenes/house/house.tscn @@ -80,3 +80,4 @@ offset_right = 40.0 offset_bottom = 40.0 [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"] diff --git a/frontend/Savor-22b/scenes/house/house_inventory.gd b/frontend/Savor-22b/scenes/house/house_inventory.gd index 80c00229..a5f104ac 100644 --- a/frontend/Savor-22b/scenes/house/house_inventory.gd +++ b/frontend/Savor-22b/scenes/house/house_inventory.gd @@ -18,13 +18,13 @@ func _ready(): func _on_tools_button_down(): clear_popup() var kitchens = KITCHEN_TOOLS.instantiate() - + kitchens.closetab.connect(closetab) panel.add_child(kitchens) func _on_shop_button_down(): clear_popup() var kitchens = KITCHEN_SHOP.instantiate() - + kitchens.closetab.connect(closetab) kitchens.buysignal.connect(popup) panel.add_child(kitchens) @@ -33,5 +33,8 @@ func clear_popup(): for pop in panel.get_children(): pop.queue_free() +func closetab(): + queue_free() + func popup(): buysignal.emit() diff --git a/frontend/Savor-22b/scenes/house/kitchenshop.gd b/frontend/Savor-22b/scenes/house/kitchenshop.gd index 10fd0c16..e8856dee 100644 --- a/frontend/Savor-22b/scenes/house/kitchenshop.gd +++ b/frontend/Savor-22b/scenes/house/kitchenshop.gd @@ -5,6 +5,7 @@ const TOOL = preload("res://scenes/house/tool.tscn") @onready var grid = $M/V/Items/G signal buysignal +signal closetab var list @@ -20,3 +21,8 @@ func _ready(): func popup(): buysignal.emit() + + +func _on_close_button_down(): + closetab.emit() + queue_free() diff --git a/frontend/Savor-22b/scenes/house/kitchenshop.tscn b/frontend/Savor-22b/scenes/house/kitchenshop.tscn index d21420d8..b79b913d 100644 --- a/frontend/Savor-22b/scenes/house/kitchenshop.tscn +++ b/frontend/Savor-22b/scenes/house/kitchenshop.tscn @@ -53,3 +53,5 @@ theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 40 theme_override_styles/normal = SubResource("StyleBoxFlat_rk6tx") text = " 닫기 " + +[connection signal="button_down" from="M/V/Button/Close" to="." method="_on_close_button_down"] diff --git a/frontend/Savor-22b/scenes/house/kitchentools.gd b/frontend/Savor-22b/scenes/house/kitchentools.gd index 93ec43ef..84fe1cb5 100644 --- a/frontend/Savor-22b/scenes/house/kitchentools.gd +++ b/frontend/Savor-22b/scenes/house/kitchentools.gd @@ -4,6 +4,8 @@ const TOOL = preload("res://scenes/house/tool.tscn") @onready var grid = $M/V/Items/G +signal closetab + var tools func _ready(): @@ -14,3 +16,9 @@ func _ready(): toolpanel.set_info(tool) grid.add_child(toolpanel) + + +func _on_close_button_down(): + closetab.emit() + queue_free() + diff --git a/frontend/Savor-22b/scenes/house/kitchentools.tscn b/frontend/Savor-22b/scenes/house/kitchentools.tscn index 1232da5f..3b9d2262 100644 --- a/frontend/Savor-22b/scenes/house/kitchentools.tscn +++ b/frontend/Savor-22b/scenes/house/kitchentools.tscn @@ -53,3 +53,5 @@ theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 40 theme_override_styles/normal = SubResource("StyleBoxFlat_rk6tx") text = " 닫기 " + +[connection signal="button_down" from="M/V/Button/Close" to="." method="_on_close_button_down"] diff --git a/frontend/Savor-22b/scripts/scenes/house.gd b/frontend/Savor-22b/scripts/scenes/house.gd index 29a26827..de56f1bb 100644 --- a/frontend/Savor-22b/scripts/scenes/house.gd +++ b/frontend/Savor-22b/scripts/scenes/house.gd @@ -24,6 +24,7 @@ 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(): @@ -31,6 +32,7 @@ func buyaction(): buytool() var donepopup = DONE_POPUP.instantiate() + donepopup.set_position(Vector2(900,600)) popup.add_child(donepopup) func buytool(): @@ -62,3 +64,12 @@ func clear_popup(): if is_instance_valid(popup): for pop in popup.get_children(): pop.queue_free() + + + +func _on_refresh_button_button_down(): + Intro._query_user_state() + + if is_instance_valid(subscene): + for scene in subscene.get_children(): + scene.queue_free()