Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

[SVR-174] 이사기능 구현 #168

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions frontend/Savor-22b/gql/query.gd
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,19 @@ var install_kitchen_equipment_query_format = "query {
spaceNumber: {}
)
}"

var calculate_relocation_cost_query_template = GQLQuery.new("calculateRelocationCost").set_args({
"villageId": "villageId",
"relocationVillageId": "relocationVillageId",
}).set_props([
"durationBlocks",
"price",
])

var calculate_relocation_cost_query = SvrGqlClient.query(
'CalculateRelocationCost',
{
"villageId": "Int!",
"relocationVillageId": "Int!",
},
calculate_relocation_cost_query_template)
6 changes: 3 additions & 3 deletions frontend/Savor-22b/gql/svr_gql_client_2.gd
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
extends GQLClient2
extends GQLClient

func _ready():
print("client 2 ready")
#set_endpoint(false, "1.230.253.103", 38080, "/graphql")

set_endpoint_2(false, "localhost", 38080, "/graphql/explorer")
set_endpoint(false, "localhost", 38080, "/graphql/explorer")


func raw_mutation(query:String):
return GQLQueryExecuter2.new(endpoint, use_ssl, Mutation.new(query))
return GQLQueryExecuter.new(endpoint, use_ssl, Mutation.new(query))
7 changes: 7 additions & 0 deletions frontend/Savor-22b/scenes/select_house.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ offset_top = 300.0
offset_right = 640.0
offset_bottom = 340.0

[node name="ConfirmPopup" type="Control" parent="MarginContainer/Background"]
anchors_preset = 0
offset_left = 600.0
offset_top = 300.0
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"]
Expand Down
3 changes: 3 additions & 0 deletions frontend/Savor-22b/scripts/scenes/intro.gd
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func _query_user_state():
]),
]),
GQLQuery.new("villageState").set_props([
GQLQuery.new("houseState").set_props([
"villageId",
]),
GQLQuery.new("houseFieldStates").set_props([
"installedSeedGuid",
"seedID",
Expand Down
32 changes: 31 additions & 1 deletion frontend/Savor-22b/scripts/scenes/select_house.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ 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 = []
Expand Down Expand Up @@ -72,9 +74,37 @@ func _on_build_button_button_down():
if (SceneContext.selected_house_location["owner"] != "none"):
print_notice()
else:
build_house()
var isHouseOwner = false
var villageState = SceneContext.user_state["villageState"]
if(villageState != null):
isHouseOwner = true
print(isHouseOwner)

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()
Expand Down
25 changes: 25 additions & 0 deletions frontend/Savor-22b/ui/confirm_popup.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
extends ColorRect

signal ok_button_clicked_signal
signal cancel_button_clicked_signal

# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

func set_label(text):
$VBoxContainer/Label.text = text

func _on_ok_button_pressed():
ok_button_clicked_signal.emit()
queue_free()


func _on_cancel_button_pressed():
cancel_button_clicked_signal.emit()
queue_free()
51 changes: 51 additions & 0 deletions frontend/Savor-22b/ui/confirm_popup.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[gd_scene load_steps=2 format=3 uid="uid://dmgv25t8i3882"]

[ext_resource type="Script" path="res://ui/confirm_popup.gd" id="1_xg6hf"]

[node name="NoticePopup" type="ColorRect"]
offset_left = 5.0
offset_top = -38.0
offset_right = 1005.0
offset_bottom = 362.0
size_flags_horizontal = 3
size_flags_vertical = 3
color = Color(1, 1, 0.533333, 1)
script = ExtResource("1_xg6hf")

[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 30
alignment = 1

[node name="Label" type="Label" parent="VBoxContainer"]
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 50
text = "confirm"
horizontal_alignment = 1
vertical_alignment = 1

[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 120
alignment = 1

[node name="CancelButton" type="Button" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 50
text = "취소"

[node name="OkButton" type="Button" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_font_sizes/font_size = 50
text = " 확인 "

[connection signal="pressed" from="VBoxContainer/HBoxContainer/CancelButton" to="." method="_on_cancel_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/OkButton" to="." method="_on_ok_button_pressed"]
3 changes: 3 additions & 0 deletions frontend/Savor-22b/ui/notice_popup.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ extends ColorRect

func _on_button_pressed():
queue_free()

func set_label(text):
$MarginContainer/Label.text = text
Loading