diff --git a/frontend/Savor-22b/gql/query.gd b/frontend/Savor-22b/gql/query.gd index 90ff2b30..a08abf6d 100644 --- a/frontend/Savor-22b/gql/query.gd +++ b/frontend/Savor-22b/gql/query.gd @@ -48,6 +48,14 @@ var remove_seed_query_format = "query { ) }" +var remove_weed_query_format = "query { + createAction_RemoveWeed( + publicKey: {}, + fieldIndex: {} + ) +}" + + var buy_shop_item_query_format = "query { createAction_BuyShopItem( diff --git a/frontend/Savor-22b/scripts/scenes/farm.gd b/frontend/Savor-22b/scripts/scenes/farm.gd index 11fcce20..9daae033 100644 --- a/frontend/Savor-22b/scripts/scenes/farm.gd +++ b/frontend/Savor-22b/scripts/scenes/farm.gd @@ -182,16 +182,19 @@ func harvest_seed(): actionSuccess = true fetch_new() -func action_popup(): +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) - actionpopup.set_position(Vector2(700,500)) + 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): @@ -214,9 +217,9 @@ func remove_done_popup(): donepopup.set_position(Vector2(700,500)) donepopup.refresh_me.connect(fetch_new) -func control_seed(): +func control_seed(weed : bool): #code here - action_popup() + action_popup(weed) func remove_seed(): var gql_query = Gql_query.new() @@ -246,6 +249,7 @@ func remove_seed(): func fetch_new(): # fetch datas Intro._query_user_state() + Intro.get_current_block() # done popup if(actionSuccess): @@ -262,10 +266,34 @@ func fetch_new(): _ready() -func _on_refresh_button_button_down(): +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/ui/farm_action_popup.gd b/frontend/Savor-22b/ui/farm_action_popup.gd index d09618a0..6562e6f6 100644 --- a/frontend/Savor-22b/ui/farm_action_popup.gd +++ b/frontend/Savor-22b/ui/farm_action_popup.gd @@ -1,11 +1,15 @@ extends ColorRect signal button_down_remove +signal weed_action_signal func _ready(): pass # Replace with function body. +func set_weed_button(weed : bool): + if (weed): + $M/V/Weed.visible = true func _on_remove_button_down(): button_down_remove.emit() @@ -14,3 +18,8 @@ func _on_remove_button_down(): func _on_cancel_button_down(): queue_free() + + +func _on_weed_button_down(): + weed_action_signal.emit() + queue_free() diff --git a/frontend/Savor-22b/ui/farm_action_popup.tscn b/frontend/Savor-22b/ui/farm_action_popup.tscn index b08aea7e..fe27684a 100644 --- a/frontend/Savor-22b/ui/farm_action_popup.tscn +++ b/frontend/Savor-22b/ui/farm_action_popup.tscn @@ -6,9 +6,9 @@ bg_color = Color(0, 0, 0, 1) [node name="ActionPopup" type="ColorRect"] -custom_minimum_size = Vector2(400, 100) +custom_minimum_size = Vector2(400, 200) offset_right = 400.0 -offset_bottom = 200.0 +offset_bottom = 300.0 color = Color(0.866667, 0.498039, 0.215686, 1) script = ExtResource("1_ma8qk") @@ -34,6 +34,14 @@ theme_override_font_sizes/font_size = 50 theme_override_styles/normal = SubResource("StyleBoxFlat_yesvl") text = "종자 제거하기" +[node name="Weed" type="Button" parent="M/V"] +visible = false +layout_mode = 2 +theme_override_colors/font_color = Color(0, 1, 0, 1) +theme_override_font_sizes/font_size = 50 +theme_override_styles/normal = SubResource("StyleBoxFlat_yesvl") +text = "잡초 제거하기" + [node name="Cancel" type="Button" parent="M/V"] layout_mode = 2 theme_override_font_sizes/font_size = 50 @@ -41,4 +49,5 @@ theme_override_styles/normal = SubResource("StyleBoxFlat_yesvl") text = "행동 취소" [connection signal="button_down" from="M/V/Remove" to="." method="_on_remove_button_down"] +[connection signal="button_down" from="M/V/Weed" to="." method="_on_weed_button_down"] [connection signal="button_down" from="M/V/Cancel" to="." method="_on_cancel_button_down"] diff --git a/frontend/Savor-22b/ui/farm_slot_button.gd b/frontend/Savor-22b/ui/farm_slot_button.gd index c6ce06d0..8ff7a218 100644 --- a/frontend/Savor-22b/ui/farm_slot_button.gd +++ b/frontend/Savor-22b/ui/farm_slot_button.gd @@ -2,7 +2,7 @@ extends ColorRect signal button_down(child_index: int) signal button_down_action -signal weed_action + @onready var button = $V/Button @@ -25,7 +25,7 @@ func _update_button(): button.text = format_string % [farm_slot.seedName, "자라는 중", timeleft, "블록 남음"] if (farm_slot.weedRemovalAble): - pass + $Weed.visible = true func set_farm_slot(farm_slot: Dictionary): self.farm_slot = farm_slot @@ -36,7 +36,7 @@ func _on_button_button_down(): button_down.emit(get_index()) else: button_down.emit(get_index()+5) - button_down_action.emit() + button_down_action.emit(farm_slot.weedRemovalAble) func im_right(): diff --git a/frontend/Savor-22b/ui/farm_slot_button.tscn b/frontend/Savor-22b/ui/farm_slot_button.tscn index cdf2d0c4..9d78b50f 100644 --- a/frontend/Savor-22b/ui/farm_slot_button.tscn +++ b/frontend/Savor-22b/ui/farm_slot_button.tscn @@ -38,14 +38,18 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_ctkwv") text = "[벼] 자라는 중 [N 블록 남음]" -[node name="Label" type="Label" parent="V/Button"] -layout_mode = 2 -offset_top = 245.0 -offset_right = 500.0 -offset_bottom = 300.0 +[node name="Weed" type="Label" parent="."] +visible = false +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, 1, 0, 1) -theme_override_font_sizes/font_size = 40 +theme_override_font_sizes/font_size = 28 text = "[잡초 제거 필요]" -horizontal_alignment = 1 +horizontal_alignment = 2 +vertical_alignment = 2 [connection signal="button_down" from="V/Button" to="." method="_on_button_button_down"]