Skip to content

Commit

Permalink
SVR-178: 밭 전체 화면 및 밭 목록 확인 기능 (#127)
Browse files Browse the repository at this point in the history
* fix: farm scene merge error

* feat: view current farms
  • Loading branch information
kth1888 authored Feb 19, 2024
1 parent 0623d61 commit 6442fb7
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 66 deletions.
67 changes: 16 additions & 51 deletions frontend/Savor-22b/scenes/farm.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[gd_scene load_steps=3 format=3 uid="uid://c10m1dv6u7ks7"]

[ext_resource type="Script" path="res://scripts/scenes/farm.gd" id="1_q2tum"]
[ext_resource type="PackedScene" uid="uid://c0qm0ud7mwmwb" path="res://ui/farm_slot_button.tscn" id="2_fjqrk"]
[ext_resource type="PackedScene" uid="uid://bjcg2kocdfuua" path="res://ui/farm_slot_done.tscn" id="3_5vjtx"]
[ext_resource type="PackedScene" uid="uid://bf6be56dhvlws" path="res://ui/farm_slot_empty.tscn" id="4_eb1ui"]
[ext_resource type="PackedScene" uid="uid://kttsr2bn7o31" path="res://ui/farm_install_popup.tscn" id="5_ka4ym"]


[node name="Farm" type="Control"]
layout_mode = 3
anchors_preset = 15
Expand All @@ -15,15 +13,15 @@ grow_vertical = 2
script = ExtResource("1_q2tum")
metadata/_edit_horizontal_guides_ = [-309.0]

[node name="ColorRect" type="ColorRect" parent="."]
[node name="Background" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="MarginContainer" type="MarginContainer" parent="."]
[node name="MC" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
Expand All @@ -35,17 +33,17 @@ theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10

[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
[node name="HC" type="HBoxContainer" parent="MC"]
layout_mode = 2
theme_override_constants/separation = 0

[node name="ColorRect" type="ColorRect" parent="MarginContainer/HBoxContainer"]
[node name="CR" type="ColorRect" parent="MC/HC"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.7
color = Color(0, 0, 0, 1)

[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/ColorRect"]
[node name="MC" type="MarginContainer" parent="MC/HC/CR"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
Expand All @@ -57,77 +55,43 @@ theme_override_constants/margin_top = 50
theme_override_constants/margin_right = 50
theme_override_constants/margin_bottom = 50

[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer"]
[node name="HC" type="HBoxContainer" parent="MC/HC/CR/MC"]
layout_mode = 2
theme_override_constants/separation = 100

[node name="Left" type="VBoxContainer" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer"]
[node name="Left" type="VBoxContainer" parent="MC/HC/CR/MC/HC"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 20


[node name="FarmSlotButton" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer/Left" instance=ExtResource("2_fjqrk")]
layout_mode = 2

[node name="FarmSlotButton2" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer/Left" instance=ExtResource("2_fjqrk")]
layout_mode = 2

[node name="FarmSlotButton3" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer/Left" instance=ExtResource("2_fjqrk")]
layout_mode = 2

[node name="FarmSlotDone" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer/Left" instance=ExtResource("3_5vjtx")]
layout_mode = 2

[node name="FarmSlotDone2" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer/Left" instance=ExtResource("3_5vjtx")]

layout_mode = 2

[node name="Right" type="VBoxContainer" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer"]
[node name="Right" type="VBoxContainer" parent="MC/HC/CR/MC/HC"]
layout_mode = 2
size_flags_horizontal = 3

theme_override_constants/separation = 20

[node name="FarmSlotButton" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer/Right" instance=ExtResource("2_fjqrk")]
layout_mode = 2

[node name="FarmSlotEmpty" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer/Right" instance=ExtResource("4_eb1ui")]
layout_mode = 2

[node name="FarmSlotEmpty2" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer/Right" instance=ExtResource("4_eb1ui")]
layout_mode = 2

[node name="FarmSlotEmpty3" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer/Right" instance=ExtResource("4_eb1ui")]
layout_mode = 2

[node name="FarmSlotEmpty4" parent="MarginContainer/HBoxContainer/ColorRect/MarginContainer/HBoxContainer/Right" instance=ExtResource("4_eb1ui")]

layout_mode = 2

[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"]
[node name="VBoxContainer" type="VBoxContainer" parent="MC/HC"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.3

[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/VBoxContainer"]
[node name="MarginContainer" type="MarginContainer" parent="MC/HC/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10

[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer/VBoxContainer/MarginContainer"]
[node name="VBoxContainer" type="VBoxContainer" parent="MC/HC/VBoxContainer/MarginContainer"]
layout_mode = 2

[node name="HomeButton" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer/MarginContainer/VBoxContainer"]
[node name="HomeButton" type="Button" parent="MC/HC/VBoxContainer/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 0
theme_override_font_sizes/font_size = 50
text = "Home"

[node name="InventoryButton" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer/MarginContainer/VBoxContainer"]
[node name="InventoryButton" type="Button" parent="MC/HC/VBoxContainer/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 0
theme_override_font_sizes/font_size = 50
Expand All @@ -139,6 +103,7 @@ offset_right = 40.0
offset_bottom = 40.0

[node name="ColorRect" parent="Popups" instance=ExtResource("5_ka4ym")]
visible = false
layout_mode = 0
offset_left = 1225.0
offset_top = 476.0
Expand Down
20 changes: 19 additions & 1 deletion frontend/Savor-22b/scenes/village_view.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ grow_vertical = 2
theme_override_font_sizes/font_size = 70
text = "Home"

[node name="FarmButtonContainer" type="ColorRect" parent="TopMenuMarginContainer/Control"]
layout_mode = 0
offset_left = 460.0
offset_right = 870.0
offset_bottom = 100.0
size_flags_horizontal = 4
color = Color(0, 0, 0, 1)

[node name="FarmButton" type="Button" parent="TopMenuMarginContainer/Control/FarmButtonContainer"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_font_sizes/font_size = 70
text = "Farm"

[node name="BottomMenuMarginContainer" type="MarginContainer" parent="."]
layout_mode = 0
offset_top = 940.0
Expand Down Expand Up @@ -131,5 +149,5 @@ offset_right = 640.0
offset_bottom = 340.0

[connection signal="button_down" from="TopMenuMarginContainer/Control/HomeButtonContainer/HomeButton" to="." method="_on_home_button_button_down"]
[connection signal="button_down" from="TopMenuMarginContainer/Control/FarmButtonContainer/FarmButton" to="." method="_on_farm_button_button_down"]
[connection signal="button_down" from="BottomMenuMarginContainer/Control/EnterButtonContainer/EnterButton" to="." method="_on_enter_button_button_down"]

42 changes: 42 additions & 0 deletions frontend/Savor-22b/scripts/scenes/farm.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
extends Control

const FARM_SLOT_EMPTY = preload("res://ui/farm_slot_empty.tscn")
const FARM_SLOT_OCCUPIED = preload("res://ui/farm_slot_button.tscn")
const FARM_SLOT_DONE = preload("res://ui/farm_slot_done.tscn")

@onready var leftfarm = $MC/HC/CR/MC/HC/Left
@onready var rightfarm = $MC/HC/CR/MC/HC/Right

var farms = []

func _ready():
print("farm scene ready")

print(SceneContext.user_state["villageState"]["houseFieldStates"])
farms = SceneContext.user_state["villageState"]["houseFieldStates"]

#create blank slots
for i in range(0,5):
var farm
if (farms[i] == null):
farm = FARM_SLOT_EMPTY.instantiate()
else:
if(farms[i]["isHarvested"]):
farm = FARM_SLOT_DONE.instantiate()
farm.set_farm_slot(farms[i])
else:
farm = FARM_SLOT_OCCUPIED.instantiate()
farm.set_farm_slot(farms[i])

leftfarm.add_child(farm)

for i in range(5,10):
var farm
if (farms[i] == null):
farm = FARM_SLOT_EMPTY.instantiate()
else:
if(farms[i]["isHarvested"]):
farm = FARM_SLOT_DONE.instantiate()
else:
farm = FARM_SLOT_OCCUPIED.instantiate()

rightfarm.add_child(farm)



13 changes: 13 additions & 0 deletions frontend/Savor-22b/scripts/scenes/intro.gd
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ func _query_user_state():
"itemName",
]),
]),
GQLQuery.new("villageState").set_props([
GQLQuery.new("houseFieldStates").set_props([
"installedSeedGuid",
"seedID",
"installedBlock",
"totalBlock",
"lastWeedBlock",
"weedRemovalCount",
"seedName",
"isHarvested",
"weedRemovalAble"
])
])
])
print(query.serialize())
var query_executor = SvrGqlClient.query(
Expand Down
2 changes: 1 addition & 1 deletion frontend/Savor-22b/scripts/scenes/select_village.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ func _on_start_button_button_down():
SceneContext.selected_village_width = village["width"]
SceneContext.selected_village_height = village["height"]

get_tree().change_scene_to_file("res://scenes/village_view.tscn")
get_tree().change_scene_to_file("res://scenes/select_house.tscn")
4 changes: 4 additions & 0 deletions frontend/Savor-22b/scripts/scenes/village_view.gd
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ func _on_home_button_button_down():
func _on_enter_button_button_down():
pass # Replace with function body.



func _on_farm_button_button_down():
get_tree().change_scene_to_file("res://scenes/farm.tscn")
13 changes: 6 additions & 7 deletions frontend/Savor-22b/ui/farm_slot_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ extends ColorRect

signal button_down(child_index: int)

@onready var button = $Button
@onready var button = $V/Button

var farm_slot: Dictionary

var format_string = """%s %s
(%d %s)"""

func _ready():
_update_button()

func _update_button():
if button == null:
return

button.text = """%s %s
(%d %s)""" % [
"벼",
"자라는 중",
1,
"블록 남음"]
button.text = format_string % [farm_slot.seedName, "자라는 중", farm_slot.totalBlock, "블록 남음"]


func set_farm_slot(farm_slot: Dictionary):
self.farm_slot = farm_slot
Expand Down
5 changes: 0 additions & 5 deletions frontend/Savor-22b/ui/farm_slot_button.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://c0qm0ud7mwmwb"]


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

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b1e62"]

bg_color = Color(0.6, 0.6, 0.6, 0)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ctkwv"]
Expand All @@ -20,7 +18,6 @@ offset_right = 500.0
offset_bottom = 300.0
size_flags_vertical = 3
color = Color(0.866667, 0.498039, 0.215686, 1)

script = ExtResource("1_vqq1f")

[node name="V" type="VBoxContainer" parent="."]
Expand All @@ -37,9 +34,7 @@ size_flags_vertical = 3
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 50
theme_override_styles/normal = SubResource("StyleBoxFlat_b1e62")

theme_override_styles/pressed = SubResource("StyleBoxFlat_ctkwv")

text = "[벼] 자라는 중
[N 블록 남음]"

Expand Down
26 changes: 26 additions & 0 deletions frontend/Savor-22b/ui/farm_slot_done.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
extends ColorRect

signal button_down(child_index: int)

@onready var button = $V/Button

var farm_slot: Dictionary

var format_string = "[%s] %s"

func _ready():
_update_button()

func _update_button():
if button == null:
return

button.text = format_string % [farm_slot.seedName, "수확하기"]


func set_farm_slot(farm_slot: Dictionary):
self.farm_slot = farm_slot
_update_button()

func _on_button_button_down():
button_down.emit(get_index())
5 changes: 4 additions & 1 deletion frontend/Savor-22b/ui/farm_slot_done.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://bjcg2kocdfuua"]
[gd_scene load_steps=4 format=3 uid="uid://bjcg2kocdfuua"]

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

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b1e62"]
bg_color = Color(0, 0.372549, 1, 1)
Expand All @@ -15,6 +17,7 @@ border_color = Color(1, 1, 1, 1)
offset_right = 500.0
offset_bottom = 300.0
size_flags_vertical = 3
script = ExtResource("1_jh5h4")

[node name="V" type="VBoxContainer" parent="."]
layout_mode = 1
Expand Down

0 comments on commit 6442fb7

Please sign in to comment.