From 028e72ab8de1df0444b32aeb1e3fc4c511e7fec3 Mon Sep 17 00:00:00 2001 From: Tae Hyoung Kang <78776542+kth1888@users.noreply.github.com> Date: Thu, 23 May 2024 01:24:35 +0900 Subject: [PATCH 1/6] feat: trade shop inventory implement --- frontend/Savor-22b/gql/query.gd | 7 ++ frontend/Savor-22b/gql/query_executor.gd | 12 +++ .../scenes/house/cook/cook_book.tscn | 1 - frontend/Savor-22b/scenes/house/food.gd | 2 +- frontend/Savor-22b/scenes/market/market.gd | 52 ++++++++++ frontend/Savor-22b/scenes/market/market.tscn | 99 +++++++++++++++++++ frontend/Savor-22b/scenes/market/my_item.gd | 27 +++++ frontend/Savor-22b/scenes/market/my_item.tscn | 37 +++++++ .../Savor-22b/scenes/market/posted_item.tscn | 72 ++++++++++++++ .../Savor-22b/scenes/market/sell_list.tscn | 87 ++++++++++++++++ .../scenes/market/sell_list_button_group.tres | 3 + .../scenes/market/trade_inventory.gd | 18 ++++ .../scenes/market/trade_inventory.tscn | 74 ++++++++++++++ .../Savor-22b/scenes/village/village_view.gd | 6 ++ .../scenes/village/village_view.tscn | 23 +++++ 15 files changed, 518 insertions(+), 2 deletions(-) create mode 100644 frontend/Savor-22b/scenes/market/market.gd create mode 100644 frontend/Savor-22b/scenes/market/market.tscn create mode 100644 frontend/Savor-22b/scenes/market/my_item.gd create mode 100644 frontend/Savor-22b/scenes/market/my_item.tscn create mode 100644 frontend/Savor-22b/scenes/market/posted_item.tscn create mode 100644 frontend/Savor-22b/scenes/market/sell_list.tscn create mode 100644 frontend/Savor-22b/scenes/market/sell_list_button_group.tres create mode 100644 frontend/Savor-22b/scenes/market/trade_inventory.gd create mode 100644 frontend/Savor-22b/scenes/market/trade_inventory.tscn diff --git a/frontend/Savor-22b/gql/query.gd b/frontend/Savor-22b/gql/query.gd index 217aeda0..6c8b254a 100644 --- a/frontend/Savor-22b/gql/query.gd +++ b/frontend/Savor-22b/gql/query.gd @@ -75,3 +75,10 @@ var uninstall_kitchen_equipment_query = GQLQuery.new("createAction_UninstallKitc "publicKey": "publicKey", "spaceNumber": "spaceNumber" }); + +var register_trade_good_query = GQLQuery.new("createAction_RegisterTradeGoodAction").set_args({ + "publicKey": "publicKey", + "price": "price", + "foodStateId": "foodStateId", + "itemStateIds": "itemStateIds" +}); diff --git a/frontend/Savor-22b/gql/query_executor.gd b/frontend/Savor-22b/gql/query_executor.gd index 12c30ea7..d2a5f68a 100644 --- a/frontend/Savor-22b/gql/query_executor.gd +++ b/frontend/Savor-22b/gql/query_executor.gd @@ -125,6 +125,18 @@ var uninstall_kitchen_equipment_query_executor = SvrGqlClient.query( gql_query.uninstall_kitchen_equipment_query ); + +var register_trade_good_query_executor = SvrGqlClient.query( + 'RegisterTradeGood', + { + "publicKey": "String!", + "price": "Int!", + "foodStateId": "Int!", + "itemStateIds": "Int!" + }, + gql_query.uninstall_kitchen_equipment_query +); + func stage_action(params, query_executor, mutation_executor): query_executor.graphql_response.connect( func(data): diff --git a/frontend/Savor-22b/scenes/house/cook/cook_book.tscn b/frontend/Savor-22b/scenes/house/cook/cook_book.tscn index 5e96b6c9..0dbb2154 100644 --- a/frontend/Savor-22b/scenes/house/cook/cook_book.tscn +++ b/frontend/Savor-22b/scenes/house/cook/cook_book.tscn @@ -1,7 +1,6 @@ [gd_scene load_steps=7 format=3 uid="uid://bb0hth2o7k30q"] [ext_resource type="Script" path="res://scenes/house/cook/cook_book.gd" id="1_q1ejr"] -[ext_resource type="Script" path="res://scenes/house/recipe_book/recipe_book.gd" id="1_2wc5e"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tvose"] bg_color = Color(0.94902, 0.694118, 0.0784314, 1) diff --git a/frontend/Savor-22b/scenes/house/food.gd b/frontend/Savor-22b/scenes/house/food.gd index b77a9370..dbbb29dc 100644 --- a/frontend/Savor-22b/scenes/house/food.gd +++ b/frontend/Savor-22b/scenes/house/food.gd @@ -18,4 +18,4 @@ func _update_info(): func set_info(info: Dictionary): self.info = info - \ No newline at end of file + diff --git a/frontend/Savor-22b/scenes/market/market.gd b/frontend/Savor-22b/scenes/market/market.gd new file mode 100644 index 00000000..3ac72f53 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/market.gd @@ -0,0 +1,52 @@ +extends Control + +const TradeInventoryScn = preload("res://scenes/market/trade_inventory.tscn") +const SellListScn = preload("res://scenes/market/sell_list.tscn") + +@onready var inventory_container = $VBoxContainer/MarginContainer/SubMenuHBoxContainer/InventoryMarginContainer +@onready var sell_list_container = $VBoxContainer/MarginContainer/SubMenuHBoxContainer/SellListMarginContainer + +var query_executor = QueryExecutor.new() +var register_trade_good_query_executor +var stage_tx_mutation_executor + +func _ready(): + register_trade_good_query_executor = query_executor.register_trade_good_query_executor + stage_tx_mutation_executor = query_executor.stage_tx_mutation_executor + add_child(register_trade_good_query_executor) + add_child(stage_tx_mutation_executor) + + + load_initial_scene() + + test_register() + + +func load_initial_scene(): + load_inventory() + load_sell_list() + +func load_inventory(): + var inventory = TradeInventoryScn.instantiate() + inventory_container.add_child(inventory) + +func load_sell_list(): + var sell_list = SellListScn.instantiate() + sell_list_container.add_child(sell_list) + + +func test_register(): + query_executor.stage_action( + { + "publicKey": GlobalSigner.signer.GetPublicKey(), + "price": 10, + "foodStateId": "8ef2aa23-3595-4036-9ee9-7802d4663891", + "itemStateIds": [] + }, + register_trade_good_query_executor, + stage_tx_mutation_executor + ) + + +func _on_village_button_down(): + get_tree().change_scene_to_file("res://scenes/village/village_view.tscn") diff --git a/frontend/Savor-22b/scenes/market/market.tscn b/frontend/Savor-22b/scenes/market/market.tscn new file mode 100644 index 00000000..ef6fc395 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/market.tscn @@ -0,0 +1,99 @@ +[gd_scene load_steps=3 format=3 uid="uid://5hl0imlbiaaj"] + +[ext_resource type="Script" path="res://scenes/market/market.gd" id="1_ibysf"] +[ext_resource type="PackedScene" uid="uid://co4t4p5pawylr" path="res://scenes/common/prefabs/asset.tscn" id="2_mauxh"] + +[node name="Market" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_ibysf") + +[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="Title" type="Label" parent="Background"] +offset_right = 40.0 +offset_bottom = 23.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 60 +text = " 무역 화면" + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +custom_minimum_size = Vector2(1920, 1080) +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = 4.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 20 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 20 + +[node name="TopMenuHBoxContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer2"] +layout_mode = 2 +theme_override_constants/separation = 50 +alignment = 2 + +[node name="AssetPanel" type="Panel" parent="VBoxContainer/MarginContainer2/TopMenuHBoxContainer"] +custom_minimum_size = Vector2(600, 2.08165e-12) +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/MarginContainer2/TopMenuHBoxContainer/AssetPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_right = 50 + +[node name="Asset" parent="VBoxContainer/MarginContainer2/TopMenuHBoxContainer/AssetPanel/MarginContainer" instance=ExtResource("2_mauxh")] +layout_mode = 2 + +[node name="VillageButton" type="Button" parent="VBoxContainer/MarginContainer2/TopMenuHBoxContainer"] +custom_minimum_size = Vector2(200, 2.08165e-12) +layout_mode = 2 +size_flags_vertical = 0 +theme_override_font_sizes/font_size = 50 +text = " 마을로 " + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"] +custom_minimum_size = Vector2(1920, 950) +layout_mode = 2 + +[node name="SubMenuHBoxContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer"] +layout_mode = 2 + +[node name="InventoryMarginContainer" type="MarginContainer" parent="VBoxContainer/MarginContainer/SubMenuHBoxContainer"] +custom_minimum_size = Vector2(700, 2.08165e-12) +layout_mode = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 50 + +[node name="SellListMarginContainer" type="MarginContainer" parent="VBoxContainer/MarginContainer/SubMenuHBoxContainer"] +custom_minimum_size = Vector2(1220, 2.08165e-12) +layout_mode = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 50 + +[connection signal="button_down" from="VBoxContainer/MarginContainer2/TopMenuHBoxContainer/VillageButton" to="." method="_on_village_button_down"] diff --git a/frontend/Savor-22b/scenes/market/my_item.gd b/frontend/Savor-22b/scenes/market/my_item.gd new file mode 100644 index 00000000..852c555b --- /dev/null +++ b/frontend/Savor-22b/scenes/market/my_item.gd @@ -0,0 +1,27 @@ +extends Control + +#@onready var food_name = $M/V/Name +#@onready var food_description = $M/V/Desc + +@onready var item_button = $ItemSelectButton + +var info +var desc_format_string = "%s +%s : %s +%s : %s" + +func _ready(): + _update_info() + +func _update_info(): + if item_button == null: + return + item_button.text = desc_format_string % [info.name, "등급", info.grade, "stateId", info.stateId] + + +func set_info(info: Dictionary): + self.info = info + + +func _on_item_select_button_down(): + print(info) diff --git a/frontend/Savor-22b/scenes/market/my_item.tscn b/frontend/Savor-22b/scenes/market/my_item.tscn new file mode 100644 index 00000000..8a90c047 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/my_item.tscn @@ -0,0 +1,37 @@ +[gd_scene load_steps=3 format=3 uid="uid://c7yghm5bsqwif"] + +[ext_resource type="Script" path="res://scenes/market/my_item.gd" id="1_5wh4n"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_21if1"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 30 +corner_radius_top_right = 30 +corner_radius_bottom_right = 30 +corner_radius_bottom_left = 30 + +[node name="MyItem" type="Control"] +custom_minimum_size = Vector2(310, 200) +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -1610.0 +offset_bottom = -880.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_5wh4n") + +[node name="ItemSelectButton" type="Button" parent="."] +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(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_21if1") +text = "아이템 정보" +text_overrun_behavior = 1 + +[connection signal="button_down" from="ItemSelectButton" to="." method="_on_item_select_button_down"] diff --git a/frontend/Savor-22b/scenes/market/posted_item.tscn b/frontend/Savor-22b/scenes/market/posted_item.tscn new file mode 100644 index 00000000..884cc7e5 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/posted_item.tscn @@ -0,0 +1,72 @@ +[gd_scene load_steps=3 format=3 uid="uid://crw3yutudcodf"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3bs65"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 40 +corner_radius_top_right = 40 +corner_radius_bottom_right = 40 +corner_radius_bottom_left = 40 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_lobix"] +bg_color = Color(0, 0, 0, 1) +border_width_left = 3 +border_width_top = 3 +border_width_right = 3 +border_width_bottom = 3 +border_color = Color(1, 1, 1, 1) +corner_radius_top_left = 15 +corner_radius_top_right = 15 +corner_radius_bottom_right = 15 +corner_radius_bottom_left = 15 + +[node name="PostedItem" type="Control"] +custom_minimum_size = Vector2(380, 410) +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -1540.0 +offset_bottom = -670.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="BackgroundPanel" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_3bs65") + +[node name="MarginContainer" type="MarginContainer" parent="BackgroundPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 25 +theme_override_constants/margin_top = 30 +theme_override_constants/margin_right = 25 +theme_override_constants/margin_bottom = 30 + +[node name="VBoxContainer" type="VBoxContainer" parent="BackgroundPanel/MarginContainer"] +layout_mode = 2 + +[node name="DescriptionLabel" type="Label" parent="BackgroundPanel/MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(2.08165e-12, 280) +layout_mode = 2 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +text = "품목명 : 참치 +게시자 : 맛도리 해적단 +게시 마을 : 외로운 섬" + +[node name="BuyButton" type="Button" parent="BackgroundPanel/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 8 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_lobix") +text = " 구매 " diff --git a/frontend/Savor-22b/scenes/market/sell_list.tscn b/frontend/Savor-22b/scenes/market/sell_list.tscn new file mode 100644 index 00000000..d5827364 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/sell_list.tscn @@ -0,0 +1,87 @@ +[gd_scene load_steps=6 format=3 uid="uid://bu43d13qwmtcr"] + +[ext_resource type="ButtonGroup" uid="uid://di66p0jb8cdpk" path="res://scenes/market/sell_list_button_group.tres" id="1_vyf2b"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4l2s6"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 25 +corner_radius_top_right = 25 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vqa0t"] +bg_color = Color(0.94902, 0.694118, 0.243137, 1) +corner_radius_top_left = 25 +corner_radius_top_right = 25 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_af182"] +bg_color = Color(0.94902, 0.694118, 0.243137, 1) +corner_radius_top_left = 25 +corner_radius_top_right = 25 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_as0cg"] +bg_color = Color(0.94902, 0.694118, 0.243137, 1) + +[node name="SellList" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -700.0 +offset_bottom = -130.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/separation = 20 + +[node name="WholeSellListButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] +custom_minimum_size = Vector2(200, 70) +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_4l2s6") +theme_override_styles/pressed = SubResource("StyleBoxFlat_vqa0t") +toggle_mode = true +button_pressed = true +button_group = ExtResource("1_vyf2b") +text = "판매목록" + +[node name="MySellListButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] +custom_minimum_size = Vector2(240, 70) +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_4l2s6") +theme_override_styles/pressed = SubResource("StyleBoxFlat_af182") +toggle_mode = true +button_group = ExtResource("1_vyf2b") +text = "내 판매목록" + +[node name="ListPanel" type="Panel" parent="MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(2.08165e-12, 750) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_as0cg") + +[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer/ListPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer"] +layout_mode = 2 diff --git a/frontend/Savor-22b/scenes/market/sell_list_button_group.tres b/frontend/Savor-22b/scenes/market/sell_list_button_group.tres new file mode 100644 index 00000000..5c8d95f1 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/sell_list_button_group.tres @@ -0,0 +1,3 @@ +[gd_resource type="ButtonGroup" format=3 uid="uid://di66p0jb8cdpk"] + +[resource] diff --git a/frontend/Savor-22b/scenes/market/trade_inventory.gd b/frontend/Savor-22b/scenes/market/trade_inventory.gd new file mode 100644 index 00000000..78ed1d62 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/trade_inventory.gd @@ -0,0 +1,18 @@ +extends Control + +const MyItemScn = preload("res://scenes/market/my_item.tscn") + +@onready var inventory_container = $MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer/GridContainer + +var items + +func _ready(): + load_items() + +func load_items(): + items = SceneContext.user_state.inventoryState["refrigeratorStateList"] + + for item in items: + var item_scene = MyItemScn.instantiate() + item_scene.set_info(item) + inventory_container.add_child(item_scene) diff --git a/frontend/Savor-22b/scenes/market/trade_inventory.tscn b/frontend/Savor-22b/scenes/market/trade_inventory.tscn new file mode 100644 index 00000000..6ae4076a --- /dev/null +++ b/frontend/Savor-22b/scenes/market/trade_inventory.tscn @@ -0,0 +1,74 @@ +[gd_scene load_steps=4 format=3 uid="uid://81w3i6nbxjix"] + +[ext_resource type="Script" path="res://scenes/market/trade_inventory.gd" id="1_2sbin"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8vjfi"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 25 +corner_radius_top_right = 25 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_as0cg"] +bg_color = Color(0.94902, 0.694118, 0.243137, 1) + +[node name="TradeInventory" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -1220.0 +offset_bottom = -130.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_2sbin") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 + +[node name="TitlePanel" type="Panel" parent="MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(200, 70) +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_styles/panel = SubResource("StyleBoxFlat_8vjfi") + +[node name="TitleLabel" type="Label" parent="MarginContainer/VBoxContainer/TitlePanel"] +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(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +text = "인벤토리" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="InventoryPanel" type="Panel" parent="MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(2.08165e-12, 750) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_as0cg") + +[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer/InventoryPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer"] +layout_mode = 2 + +[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer"] +layout_mode = 2 +theme_override_constants/h_separation = 50 +theme_override_constants/v_separation = 50 +columns = 2 diff --git a/frontend/Savor-22b/scenes/village/village_view.gd b/frontend/Savor-22b/scenes/village/village_view.gd index 995eb494..88a41cb4 100644 --- a/frontend/Savor-22b/scenes/village/village_view.gd +++ b/frontend/Savor-22b/scenes/village/village_view.gd @@ -66,6 +66,10 @@ func _on_enter_button_down(): func _on_farm_button_down(): get_tree().change_scene_to_file("res://scenes/farm/farm.tscn") +func _on_market_button_down(): + get_tree().change_scene_to_file("res://scenes/market/market.tscn") + + #open shop with S input func _input(event): if event is InputEventKey and event.pressed: @@ -73,3 +77,5 @@ func _input(event): var shop = SystemShopScn.instantiate() popups.add_child(shop) shop.set_position(Vector2(400, 150)) + + diff --git a/frontend/Savor-22b/scenes/village/village_view.tscn b/frontend/Savor-22b/scenes/village/village_view.tscn index b2800bc0..5a4a0be5 100644 --- a/frontend/Savor-22b/scenes/village/village_view.tscn +++ b/frontend/Savor-22b/scenes/village/village_view.tscn @@ -68,6 +68,28 @@ grow_vertical = 2 theme_override_font_sizes/font_size = 70 text = " 내 밭으로 가기 " +[node name="MarketButtonContainer" type="ColorRect" parent="TopMenuMarginContainer/Control"] +offset_left = 920.0 +offset_right = 1370.0 +offset_bottom = 100.0 +size_flags_horizontal = 4 +color = Color(0, 0, 0, 1) + +[node name="MarketButton" type="Button" parent="TopMenuMarginContainer/Control/MarketButtonContainer"] +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 = "무역 화면 가기 " + +[node name="HBoxContainer" type="HBoxContainer" parent="TopMenuMarginContainer/Control"] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 + [node name="BottomMenuMarginContainer" type="MarginContainer" parent="."] layout_mode = 0 offset_top = 940.0 @@ -155,4 +177,5 @@ offset_bottom = 40.0 [connection signal="button_down" from="TopMenuMarginContainer/Control/HomeButtonContainer/HomeButton" to="." method="_on_home_button_down"] [connection signal="button_down" from="TopMenuMarginContainer/Control/FarmButtonContainer/FarmButton" to="." method="_on_farm_button_down"] +[connection signal="button_down" from="TopMenuMarginContainer/Control/MarketButtonContainer/MarketButton" to="." method="_on_market_button_down"] [connection signal="button_down" from="BottomMenuMarginContainer/Control/EnterButtonContainer/EnterButton" to="." method="_on_enter_button_down"] From 19d0673654d62127e69fee3f6213c4422fdec696 Mon Sep 17 00:00:00 2001 From: Tae Hyoung Kang <78776542+kth1888@users.noreply.github.com> Date: Sun, 26 May 2024 12:11:49 +0900 Subject: [PATCH 2/6] feat: trade shop sell list implement --- frontend/Savor-22b/gql/query.gd | 28 +++++++++++ frontend/Savor-22b/gql/query_executor.gd | 16 +++++-- frontend/Savor-22b/scenes/market/market.gd | 48 ++++++++++++++++--- frontend/Savor-22b/scenes/market/market.tscn | 5 ++ .../Savor-22b/scenes/market/posted_item.gd | 28 +++++++++++ .../Savor-22b/scenes/market/posted_item.tscn | 11 +++-- frontend/Savor-22b/scenes/market/sell_list.gd | 45 +++++++++++++++++ .../Savor-22b/scenes/market/sell_list.tscn | 22 ++++++++- .../scenes/village/village_view.tscn | 1 + 9 files changed, 188 insertions(+), 16 deletions(-) create mode 100644 frontend/Savor-22b/scenes/market/posted_item.gd create mode 100644 frontend/Savor-22b/scenes/market/sell_list.gd diff --git a/frontend/Savor-22b/gql/query.gd b/frontend/Savor-22b/gql/query.gd index 6c8b254a..e44cd488 100644 --- a/frontend/Savor-22b/gql/query.gd +++ b/frontend/Savor-22b/gql/query.gd @@ -82,3 +82,31 @@ var register_trade_good_query = GQLQuery.new("createAction_RegisterTradeGoodActi "foodStateId": "foodStateId", "itemStateIds": "itemStateIds" }); + +var trade_inventory_state_query = GQLQuery.new("tradeInventoryState").set_props([ + GQLQuery.new("tradeGoods").set_props([ + "sellerAddress", + "productStateId", + "price", + "type", + GQLQuery.new("food").set_props([ + "stateId", + "ingredientId", + "foodID", + "name", + "grade", + "hp", + "attack", + "defense", + "speed", + "isSuperFood", + "level", + "isAvailable" + ]), + GQLQuery.new("items").set_props([ + "stateID", + "itemID", + "itemName" + ]) + ]) +]) diff --git a/frontend/Savor-22b/gql/query_executor.gd b/frontend/Savor-22b/gql/query_executor.gd index d2a5f68a..ea0b3edb 100644 --- a/frontend/Savor-22b/gql/query_executor.gd +++ b/frontend/Savor-22b/gql/query_executor.gd @@ -45,7 +45,7 @@ var plant_seed_query_executor = SvrGqlClient.query( { "publicKey": "String!", "fieldIndex": "Int!", - "itemStateIdToUse": "Int!" + "itemStateIdToUse": "Guid!" }, gql_query.plant_seed_query ); @@ -131,15 +131,23 @@ var register_trade_good_query_executor = SvrGqlClient.query( { "publicKey": "String!", "price": "Int!", - "foodStateId": "Int!", - "itemStateIds": "Int!" + "foodStateId": "Guid", + "itemStateIds": "[Guid]" }, - gql_query.uninstall_kitchen_equipment_query + gql_query.register_trade_good_query ); +var trade_inventory_state_executor = SvrGqlClient.query( + 'tradeInventoryState', + {}, + gql_query.trade_inventory_state_query +); + + func stage_action(params, query_executor, mutation_executor): query_executor.graphql_response.connect( func(data): + print(data) # 지워야함 var unsigned_tx = data["data"][data["data"].keys()[0]] var signature = GlobalSigner.sign(unsigned_tx) mutation_executor.run({ diff --git a/frontend/Savor-22b/scenes/market/market.gd b/frontend/Savor-22b/scenes/market/market.gd index 3ac72f53..ab8a5690 100644 --- a/frontend/Savor-22b/scenes/market/market.gd +++ b/frontend/Savor-22b/scenes/market/market.gd @@ -1,5 +1,7 @@ extends Control +signal query_received + const TradeInventoryScn = preload("res://scenes/market/trade_inventory.tscn") const SellListScn = preload("res://scenes/market/sell_list.tscn") @@ -9,44 +11,76 @@ const SellListScn = preload("res://scenes/market/sell_list.tscn") var query_executor = QueryExecutor.new() var register_trade_good_query_executor var stage_tx_mutation_executor +var trade_inventory_state_executor + +var inventory_state + func _ready(): register_trade_good_query_executor = query_executor.register_trade_good_query_executor stage_tx_mutation_executor = query_executor.stage_tx_mutation_executor + trade_inventory_state_executor = query_executor.trade_inventory_state_executor add_child(register_trade_good_query_executor) add_child(stage_tx_mutation_executor) + add_child(trade_inventory_state_executor) load_initial_scene() - - test_register() + + print(inventory_state) func load_initial_scene(): load_inventory() - load_sell_list() + + query_trade_inventory_state() + query_received.connect(load_sell_list) + func load_inventory(): var inventory = TradeInventoryScn.instantiate() inventory_container.add_child(inventory) func load_sell_list(): - var sell_list = SellListScn.instantiate() - sell_list_container.add_child(sell_list) + print(inventory_state) + if (inventory_state != null): + var sell_list = SellListScn.instantiate() + sell_list_container.add_child(sell_list) + sell_list.set_list(inventory_state) + + + func test_register(): + var food_id = "0cffada3-dccf-48ee-942c-2617ac46952b" query_executor.stage_action( { "publicKey": GlobalSigner.signer.GetPublicKey(), - "price": 10, - "foodStateId": "8ef2aa23-3595-4036-9ee9-7802d4663891", + "price": 150, + "foodStateId": food_id, "itemStateIds": [] }, register_trade_good_query_executor, stage_tx_mutation_executor ) +func query_action(query_executor): # query with no args + query_executor.graphql_response.connect( + func(data): + inventory_state = data["data"]["tradeInventoryState"]["tradeGoods"] + query_received.emit() + ) + query_executor.run({}) + +func query_trade_inventory_state(): + query_action( + trade_inventory_state_executor + ) func _on_village_button_down(): get_tree().change_scene_to_file("res://scenes/village/village_view.tscn") + + +func _on_test_button_down(): + test_register() diff --git a/frontend/Savor-22b/scenes/market/market.tscn b/frontend/Savor-22b/scenes/market/market.tscn index ef6fc395..8d692352 100644 --- a/frontend/Savor-22b/scenes/market/market.tscn +++ b/frontend/Savor-22b/scenes/market/market.tscn @@ -21,6 +21,7 @@ grow_horizontal = 2 grow_vertical = 2 [node name="Title" type="Label" parent="Background"] +layout_mode = 0 offset_right = 40.0 offset_bottom = 23.0 theme_override_colors/font_color = Color(0, 0, 0, 1) @@ -73,6 +74,9 @@ size_flags_vertical = 0 theme_override_font_sizes/font_size = 50 text = " 마을로 " +[node name="TestButton" type="Button" parent="VBoxContainer/MarginContainer2/TopMenuHBoxContainer"] +layout_mode = 2 + [node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"] custom_minimum_size = Vector2(1920, 950) layout_mode = 2 @@ -97,3 +101,4 @@ theme_override_constants/margin_right = 50 theme_override_constants/margin_bottom = 50 [connection signal="button_down" from="VBoxContainer/MarginContainer2/TopMenuHBoxContainer/VillageButton" to="." method="_on_village_button_down"] +[connection signal="button_down" from="VBoxContainer/MarginContainer2/TopMenuHBoxContainer/TestButton" to="." method="_on_test_button_down"] diff --git a/frontend/Savor-22b/scenes/market/posted_item.gd b/frontend/Savor-22b/scenes/market/posted_item.gd new file mode 100644 index 00000000..b6ce696a --- /dev/null +++ b/frontend/Savor-22b/scenes/market/posted_item.gd @@ -0,0 +1,28 @@ +extends Control + +#@onready var food_name = $M/V/Name +#@onready var food_description = $M/V/Desc + +@onready var item_button = $ItemSelectButton +@onready var description_label = $BackgroundPanel/MarginContainer/VBoxContainer/DescriptionLabel + +var info +var desc_format_string = "%s : %s +%s : %s%s +%s : %s" + +func _ready(): + _update_info() + +func _update_info(): + if description_label == null: + return + description_label.text = desc_format_string % ["품목명",info.food["name"],"가격",info.price," BBG","게시자",info.sellerAddress] + + +func set_info(info: Dictionary): + self.info = info + + +func _on_item_select_button_down(): + print(info) diff --git a/frontend/Savor-22b/scenes/market/posted_item.tscn b/frontend/Savor-22b/scenes/market/posted_item.tscn index 884cc7e5..e2e2f98a 100644 --- a/frontend/Savor-22b/scenes/market/posted_item.tscn +++ b/frontend/Savor-22b/scenes/market/posted_item.tscn @@ -1,4 +1,6 @@ -[gd_scene load_steps=3 format=3 uid="uid://crw3yutudcodf"] +[gd_scene load_steps=4 format=3 uid="uid://crw3yutudcodf"] + +[ext_resource type="Script" path="res://scenes/market/posted_item.gd" id="1_3mj4d"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3bs65"] bg_color = Color(0, 0, 0, 1) @@ -20,7 +22,7 @@ corner_radius_bottom_right = 15 corner_radius_bottom_left = 15 [node name="PostedItem" type="Control"] -custom_minimum_size = Vector2(380, 410) +custom_minimum_size = Vector2(410, 410) layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -29,6 +31,7 @@ offset_right = -1540.0 offset_bottom = -670.0 grow_horizontal = 2 grow_vertical = 2 +script = ExtResource("1_3mj4d") [node name="BackgroundPanel" type="Panel" parent="."] layout_mode = 1 @@ -60,8 +63,10 @@ layout_mode = 2 theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_font_sizes/font_size = 40 text = "품목명 : 참치 +가격 : 10 게시자 : 맛도리 해적단 -게시 마을 : 외로운 섬" +" +text_overrun_behavior = 1 [node name="BuyButton" type="Button" parent="BackgroundPanel/MarginContainer/VBoxContainer"] layout_mode = 2 diff --git a/frontend/Savor-22b/scenes/market/sell_list.gd b/frontend/Savor-22b/scenes/market/sell_list.gd new file mode 100644 index 00000000..f9da7d1d --- /dev/null +++ b/frontend/Savor-22b/scenes/market/sell_list.gd @@ -0,0 +1,45 @@ +extends Control + +const PostedItemScn = preload("res://scenes/market/posted_item.tscn") + +@onready var list_container = $MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer/CenterContainer/GridContainer + +var goods +var my_address = GlobalSigner.signer_address + +func _ready(): + pass + +func set_list(data: Array): + goods = data + load_list() + + +func load_list(): + clear_list_panel() + + for good in goods: + if(good["sellerAddress"] != my_address): + add_lists(good) + + +func _on_my_sell_list_button_down(): + clear_list_panel() + + for good in goods: + if(good["sellerAddress"] == my_address): + add_lists(good) + +func clear_list_panel(): + if is_instance_valid(list_container): + for posted_item in list_container.get_children(): + posted_item.queue_free() + +func add_lists(good: Dictionary): + var posted_item_scene = PostedItemScn.instantiate() + posted_item_scene.set_info(good) + list_container.add_child(posted_item_scene) + + +func _on_whole_sell_list_button_down(): + load_list() diff --git a/frontend/Savor-22b/scenes/market/sell_list.tscn b/frontend/Savor-22b/scenes/market/sell_list.tscn index d5827364..cbb4f21b 100644 --- a/frontend/Savor-22b/scenes/market/sell_list.tscn +++ b/frontend/Savor-22b/scenes/market/sell_list.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=6 format=3 uid="uid://bu43d13qwmtcr"] +[gd_scene load_steps=7 format=3 uid="uid://bu43d13qwmtcr"] +[ext_resource type="Script" path="res://scenes/market/sell_list.gd" id="1_n5ek1"] [ext_resource type="ButtonGroup" uid="uid://di66p0jb8cdpk" path="res://scenes/market/sell_list_button_group.tres" id="1_vyf2b"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4l2s6"] @@ -29,6 +30,7 @@ offset_right = -700.0 offset_bottom = -130.0 grow_horizontal = 2 grow_vertical = 2 +script = ExtResource("1_n5ek1") [node name="MarginContainer" type="MarginContainer" parent="."] layout_mode = 1 @@ -83,5 +85,21 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer"] +[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer"] layout_mode = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 50 + +[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer"] +layout_mode = 2 + +[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer/CenterContainer"] +layout_mode = 2 +theme_override_constants/h_separation = 50 +theme_override_constants/v_separation = 50 +columns = 2 + +[connection signal="button_down" from="MarginContainer/VBoxContainer/HBoxContainer/WholeSellListButton" to="." method="_on_whole_sell_list_button_down"] +[connection signal="button_down" from="MarginContainer/VBoxContainer/HBoxContainer/MySellListButton" to="." method="_on_my_sell_list_button_down"] diff --git a/frontend/Savor-22b/scenes/village/village_view.tscn b/frontend/Savor-22b/scenes/village/village_view.tscn index 5a4a0be5..f3815d9d 100644 --- a/frontend/Savor-22b/scenes/village/village_view.tscn +++ b/frontend/Savor-22b/scenes/village/village_view.tscn @@ -69,6 +69,7 @@ theme_override_font_sizes/font_size = 70 text = " 내 밭으로 가기 " [node name="MarketButtonContainer" type="ColorRect" parent="TopMenuMarginContainer/Control"] +layout_mode = 0 offset_left = 920.0 offset_right = 1370.0 offset_bottom = 100.0 From 3ddde1838a419d2a8e5585e4be5ad6af4f181624 Mon Sep 17 00:00:00 2001 From: Tae Hyoung Kang <78776542+kth1888@users.noreply.github.com> Date: Sun, 26 May 2024 18:51:14 +0900 Subject: [PATCH 3/6] fix: code feedback --- frontend/Savor-22b/gql/query_executor.gd | 1 - frontend/Savor-22b/scenes/market/inventory.gd | 18 +++ .../Savor-22b/scenes/market/inventory.tscn | 74 ++++++++++++ frontend/Savor-22b/scenes/market/market.gd | 53 ++------- frontend/Savor-22b/scenes/market/market.tscn | 4 - frontend/Savor-22b/scenes/market/my_item.gd | 7 +- frontend/Savor-22b/scenes/market/sell_list.gd | 45 -------- .../Savor-22b/scenes/market/sell_list.tscn | 105 ------------------ .../market/{posted_item.gd => trade_goods.gd} | 8 -- .../{posted_item.tscn => trade_goods.tscn} | 6 +- .../scenes/market/trade_inventory.gd | 44 ++++++-- .../scenes/market/trade_inventory.tscn | 71 ++++++++---- 12 files changed, 192 insertions(+), 244 deletions(-) create mode 100644 frontend/Savor-22b/scenes/market/inventory.gd create mode 100644 frontend/Savor-22b/scenes/market/inventory.tscn delete mode 100644 frontend/Savor-22b/scenes/market/sell_list.gd delete mode 100644 frontend/Savor-22b/scenes/market/sell_list.tscn rename frontend/Savor-22b/scenes/market/{posted_item.gd => trade_goods.gd} (79%) rename frontend/Savor-22b/scenes/market/{posted_item.tscn => trade_goods.tscn} (93%) diff --git a/frontend/Savor-22b/gql/query_executor.gd b/frontend/Savor-22b/gql/query_executor.gd index ea0b3edb..7f74dbb7 100644 --- a/frontend/Savor-22b/gql/query_executor.gd +++ b/frontend/Savor-22b/gql/query_executor.gd @@ -147,7 +147,6 @@ var trade_inventory_state_executor = SvrGqlClient.query( func stage_action(params, query_executor, mutation_executor): query_executor.graphql_response.connect( func(data): - print(data) # 지워야함 var unsigned_tx = data["data"][data["data"].keys()[0]] var signature = GlobalSigner.sign(unsigned_tx) mutation_executor.run({ diff --git a/frontend/Savor-22b/scenes/market/inventory.gd b/frontend/Savor-22b/scenes/market/inventory.gd new file mode 100644 index 00000000..78ed1d62 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/inventory.gd @@ -0,0 +1,18 @@ +extends Control + +const MyItemScn = preload("res://scenes/market/my_item.tscn") + +@onready var inventory_container = $MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer/GridContainer + +var items + +func _ready(): + load_items() + +func load_items(): + items = SceneContext.user_state.inventoryState["refrigeratorStateList"] + + for item in items: + var item_scene = MyItemScn.instantiate() + item_scene.set_info(item) + inventory_container.add_child(item_scene) diff --git a/frontend/Savor-22b/scenes/market/inventory.tscn b/frontend/Savor-22b/scenes/market/inventory.tscn new file mode 100644 index 00000000..17deb2b5 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/inventory.tscn @@ -0,0 +1,74 @@ +[gd_scene load_steps=4 format=3 uid="uid://81w3i6nbxjix"] + +[ext_resource type="Script" path="res://scenes/market/inventory.gd" id="1_6c1t0"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8vjfi"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 25 +corner_radius_top_right = 25 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_as0cg"] +bg_color = Color(0.94902, 0.694118, 0.243137, 1) + +[node name="Inventory" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -1220.0 +offset_bottom = -130.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_6c1t0") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 + +[node name="TitlePanel" type="Panel" parent="MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(200, 70) +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_styles/panel = SubResource("StyleBoxFlat_8vjfi") + +[node name="TitleLabel" type="Label" parent="MarginContainer/VBoxContainer/TitlePanel"] +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(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +text = "인벤토리" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="InventoryPanel" type="Panel" parent="MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(2.08165e-12, 750) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_as0cg") + +[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer/InventoryPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer"] +layout_mode = 2 + +[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer"] +layout_mode = 2 +theme_override_constants/h_separation = 50 +theme_override_constants/v_separation = 50 +columns = 2 diff --git a/frontend/Savor-22b/scenes/market/market.gd b/frontend/Savor-22b/scenes/market/market.gd index ab8a5690..036a0e58 100644 --- a/frontend/Savor-22b/scenes/market/market.gd +++ b/frontend/Savor-22b/scenes/market/market.gd @@ -2,70 +2,43 @@ extends Control signal query_received -const TradeInventoryScn = preload("res://scenes/market/trade_inventory.tscn") -const SellListScn = preload("res://scenes/market/sell_list.tscn") +const InventoryScn = preload("res://scenes/market/inventory.tscn") +const SellListScn = preload("res://scenes/market/trade_inventory.tscn") @onready var inventory_container = $VBoxContainer/MarginContainer/SubMenuHBoxContainer/InventoryMarginContainer -@onready var sell_list_container = $VBoxContainer/MarginContainer/SubMenuHBoxContainer/SellListMarginContainer +@onready var trade_inventory_container = $VBoxContainer/MarginContainer/SubMenuHBoxContainer/SellListMarginContainer var query_executor = QueryExecutor.new() -var register_trade_good_query_executor var stage_tx_mutation_executor var trade_inventory_state_executor var inventory_state - func _ready(): - register_trade_good_query_executor = query_executor.register_trade_good_query_executor stage_tx_mutation_executor = query_executor.stage_tx_mutation_executor trade_inventory_state_executor = query_executor.trade_inventory_state_executor - add_child(register_trade_good_query_executor) add_child(stage_tx_mutation_executor) add_child(trade_inventory_state_executor) - load_initial_scene() - print(inventory_state) - - func load_initial_scene(): load_inventory() query_trade_inventory_state() - query_received.connect(load_sell_list) - + query_received.connect(load_trade_inventory) func load_inventory(): - var inventory = TradeInventoryScn.instantiate() + var inventory = InventoryScn.instantiate() inventory_container.add_child(inventory) -func load_sell_list(): - print(inventory_state) +func load_trade_inventory(): if (inventory_state != null): - var sell_list = SellListScn.instantiate() - sell_list_container.add_child(sell_list) - sell_list.set_list(inventory_state) - - + var trade_inventory = SellListScn.instantiate() + trade_inventory_container.add_child(trade_inventory) + trade_inventory.set_list(inventory_state) - - -func test_register(): - var food_id = "0cffada3-dccf-48ee-942c-2617ac46952b" - query_executor.stage_action( - { - "publicKey": GlobalSigner.signer.GetPublicKey(), - "price": 150, - "foodStateId": food_id, - "itemStateIds": [] - }, - register_trade_good_query_executor, - stage_tx_mutation_executor - ) - -func query_action(query_executor): # query with no args +func props_only_query_action(query_executor): # query with no args query_executor.graphql_response.connect( func(data): inventory_state = data["data"]["tradeInventoryState"]["tradeGoods"] @@ -74,13 +47,9 @@ func query_action(query_executor): # query with no args query_executor.run({}) func query_trade_inventory_state(): - query_action( + props_only_query_action( trade_inventory_state_executor ) func _on_village_button_down(): get_tree().change_scene_to_file("res://scenes/village/village_view.tscn") - - -func _on_test_button_down(): - test_register() diff --git a/frontend/Savor-22b/scenes/market/market.tscn b/frontend/Savor-22b/scenes/market/market.tscn index 8d692352..ec109007 100644 --- a/frontend/Savor-22b/scenes/market/market.tscn +++ b/frontend/Savor-22b/scenes/market/market.tscn @@ -74,9 +74,6 @@ size_flags_vertical = 0 theme_override_font_sizes/font_size = 50 text = " 마을로 " -[node name="TestButton" type="Button" parent="VBoxContainer/MarginContainer2/TopMenuHBoxContainer"] -layout_mode = 2 - [node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"] custom_minimum_size = Vector2(1920, 950) layout_mode = 2 @@ -101,4 +98,3 @@ theme_override_constants/margin_right = 50 theme_override_constants/margin_bottom = 50 [connection signal="button_down" from="VBoxContainer/MarginContainer2/TopMenuHBoxContainer/VillageButton" to="." method="_on_village_button_down"] -[connection signal="button_down" from="VBoxContainer/MarginContainer2/TopMenuHBoxContainer/TestButton" to="." method="_on_test_button_down"] diff --git a/frontend/Savor-22b/scenes/market/my_item.gd b/frontend/Savor-22b/scenes/market/my_item.gd index 852c555b..4f4ebdc9 100644 --- a/frontend/Savor-22b/scenes/market/my_item.gd +++ b/frontend/Savor-22b/scenes/market/my_item.gd @@ -1,8 +1,5 @@ extends Control -#@onready var food_name = $M/V/Name -#@onready var food_description = $M/V/Desc - @onready var item_button = $ItemSelectButton var info @@ -18,10 +15,8 @@ func _update_info(): return item_button.text = desc_format_string % [info.name, "등급", info.grade, "stateId", info.stateId] - func set_info(info: Dictionary): self.info = info - func _on_item_select_button_down(): - print(info) + pass # 물건 올리기 기능이 들어갈 예정 diff --git a/frontend/Savor-22b/scenes/market/sell_list.gd b/frontend/Savor-22b/scenes/market/sell_list.gd deleted file mode 100644 index f9da7d1d..00000000 --- a/frontend/Savor-22b/scenes/market/sell_list.gd +++ /dev/null @@ -1,45 +0,0 @@ -extends Control - -const PostedItemScn = preload("res://scenes/market/posted_item.tscn") - -@onready var list_container = $MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer/CenterContainer/GridContainer - -var goods -var my_address = GlobalSigner.signer_address - -func _ready(): - pass - -func set_list(data: Array): - goods = data - load_list() - - -func load_list(): - clear_list_panel() - - for good in goods: - if(good["sellerAddress"] != my_address): - add_lists(good) - - -func _on_my_sell_list_button_down(): - clear_list_panel() - - for good in goods: - if(good["sellerAddress"] == my_address): - add_lists(good) - -func clear_list_panel(): - if is_instance_valid(list_container): - for posted_item in list_container.get_children(): - posted_item.queue_free() - -func add_lists(good: Dictionary): - var posted_item_scene = PostedItemScn.instantiate() - posted_item_scene.set_info(good) - list_container.add_child(posted_item_scene) - - -func _on_whole_sell_list_button_down(): - load_list() diff --git a/frontend/Savor-22b/scenes/market/sell_list.tscn b/frontend/Savor-22b/scenes/market/sell_list.tscn deleted file mode 100644 index cbb4f21b..00000000 --- a/frontend/Savor-22b/scenes/market/sell_list.tscn +++ /dev/null @@ -1,105 +0,0 @@ -[gd_scene load_steps=7 format=3 uid="uid://bu43d13qwmtcr"] - -[ext_resource type="Script" path="res://scenes/market/sell_list.gd" id="1_n5ek1"] -[ext_resource type="ButtonGroup" uid="uid://di66p0jb8cdpk" path="res://scenes/market/sell_list_button_group.tres" id="1_vyf2b"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4l2s6"] -bg_color = Color(0, 0, 0, 1) -corner_radius_top_left = 25 -corner_radius_top_right = 25 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vqa0t"] -bg_color = Color(0.94902, 0.694118, 0.243137, 1) -corner_radius_top_left = 25 -corner_radius_top_right = 25 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_af182"] -bg_color = Color(0.94902, 0.694118, 0.243137, 1) -corner_radius_top_left = 25 -corner_radius_top_right = 25 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_as0cg"] -bg_color = Color(0.94902, 0.694118, 0.243137, 1) - -[node name="SellList" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_right = -700.0 -offset_bottom = -130.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_n5ek1") - -[node name="MarginContainer" type="MarginContainer" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] -layout_mode = 2 - -[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] -layout_mode = 2 -theme_override_constants/separation = 20 - -[node name="WholeSellListButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] -custom_minimum_size = Vector2(200, 70) -layout_mode = 2 -size_flags_horizontal = 0 -theme_override_colors/font_color = Color(1, 1, 1, 1) -theme_override_font_sizes/font_size = 40 -theme_override_styles/normal = SubResource("StyleBoxFlat_4l2s6") -theme_override_styles/pressed = SubResource("StyleBoxFlat_vqa0t") -toggle_mode = true -button_pressed = true -button_group = ExtResource("1_vyf2b") -text = "판매목록" - -[node name="MySellListButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] -custom_minimum_size = Vector2(240, 70) -layout_mode = 2 -size_flags_horizontal = 0 -theme_override_colors/font_color = Color(1, 1, 1, 1) -theme_override_font_sizes/font_size = 40 -theme_override_styles/normal = SubResource("StyleBoxFlat_4l2s6") -theme_override_styles/pressed = SubResource("StyleBoxFlat_af182") -toggle_mode = true -button_group = ExtResource("1_vyf2b") -text = "내 판매목록" - -[node name="ListPanel" type="Panel" parent="MarginContainer/VBoxContainer"] -custom_minimum_size = Vector2(2.08165e-12, 750) -layout_mode = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_as0cg") - -[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer/ListPanel"] -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="MarginContainer/VBoxContainer/ListPanel/ScrollContainer"] -layout_mode = 2 -theme_override_constants/margin_left = 50 -theme_override_constants/margin_top = 50 -theme_override_constants/margin_right = 50 -theme_override_constants/margin_bottom = 50 - -[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer"] -layout_mode = 2 - -[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer/CenterContainer"] -layout_mode = 2 -theme_override_constants/h_separation = 50 -theme_override_constants/v_separation = 50 -columns = 2 - -[connection signal="button_down" from="MarginContainer/VBoxContainer/HBoxContainer/WholeSellListButton" to="." method="_on_whole_sell_list_button_down"] -[connection signal="button_down" from="MarginContainer/VBoxContainer/HBoxContainer/MySellListButton" to="." method="_on_my_sell_list_button_down"] diff --git a/frontend/Savor-22b/scenes/market/posted_item.gd b/frontend/Savor-22b/scenes/market/trade_goods.gd similarity index 79% rename from frontend/Savor-22b/scenes/market/posted_item.gd rename to frontend/Savor-22b/scenes/market/trade_goods.gd index b6ce696a..04de1518 100644 --- a/frontend/Savor-22b/scenes/market/posted_item.gd +++ b/frontend/Savor-22b/scenes/market/trade_goods.gd @@ -1,8 +1,5 @@ extends Control -#@onready var food_name = $M/V/Name -#@onready var food_description = $M/V/Desc - @onready var item_button = $ItemSelectButton @onready var description_label = $BackgroundPanel/MarginContainer/VBoxContainer/DescriptionLabel @@ -19,10 +16,5 @@ func _update_info(): return description_label.text = desc_format_string % ["품목명",info.food["name"],"가격",info.price," BBG","게시자",info.sellerAddress] - func set_info(info: Dictionary): self.info = info - - -func _on_item_select_button_down(): - print(info) diff --git a/frontend/Savor-22b/scenes/market/posted_item.tscn b/frontend/Savor-22b/scenes/market/trade_goods.tscn similarity index 93% rename from frontend/Savor-22b/scenes/market/posted_item.tscn rename to frontend/Savor-22b/scenes/market/trade_goods.tscn index e2e2f98a..b90dad51 100644 --- a/frontend/Savor-22b/scenes/market/posted_item.tscn +++ b/frontend/Savor-22b/scenes/market/trade_goods.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://crw3yutudcodf"] -[ext_resource type="Script" path="res://scenes/market/posted_item.gd" id="1_3mj4d"] +[ext_resource type="Script" path="res://scenes/market/trade_goods.gd" id="1_vfbu4"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3bs65"] bg_color = Color(0, 0, 0, 1) @@ -21,7 +21,7 @@ corner_radius_top_right = 15 corner_radius_bottom_right = 15 corner_radius_bottom_left = 15 -[node name="PostedItem" type="Control"] +[node name="TradeGoods" type="Control"] custom_minimum_size = Vector2(410, 410) layout_mode = 3 anchors_preset = 15 @@ -31,7 +31,7 @@ offset_right = -1540.0 offset_bottom = -670.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_3mj4d") +script = ExtResource("1_vfbu4") [node name="BackgroundPanel" type="Panel" parent="."] layout_mode = 1 diff --git a/frontend/Savor-22b/scenes/market/trade_inventory.gd b/frontend/Savor-22b/scenes/market/trade_inventory.gd index 78ed1d62..9af4aebb 100644 --- a/frontend/Savor-22b/scenes/market/trade_inventory.gd +++ b/frontend/Savor-22b/scenes/market/trade_inventory.gd @@ -1,18 +1,42 @@ extends Control -const MyItemScn = preload("res://scenes/market/my_item.tscn") +const TradeGoodsScn = preload("res://scenes/market/trade_goods.tscn") -@onready var inventory_container = $MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer/GridContainer +@onready var list_container = $MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer/CenterContainer/GridContainer -var items +var goods +var my_address = GlobalSigner.signer_address func _ready(): - load_items() + pass -func load_items(): - items = SceneContext.user_state.inventoryState["refrigeratorStateList"] +func set_list(data: Array): + goods = data + load_list() + +func load_list(): + clear_list_panel() - for item in items: - var item_scene = MyItemScn.instantiate() - item_scene.set_info(item) - inventory_container.add_child(item_scene) + for good in goods: + if(good["sellerAddress"] != my_address): + add_lists(good) + +func _on_my_sell_list_button_down(): + clear_list_panel() + + for good in goods: + if(good["sellerAddress"] == my_address): + add_lists(good) + +func clear_list_panel(): + if is_instance_valid(list_container): + for posted_item in list_container.get_children(): + posted_item.queue_free() + +func add_lists(good: Dictionary): + var trade_goods_scene = TradeGoodsScn.instantiate() + trade_goods_scene.set_info(good) + list_container.add_child(trade_goods_scene) + +func _on_whole_sell_list_button_down(): + load_list() diff --git a/frontend/Savor-22b/scenes/market/trade_inventory.tscn b/frontend/Savor-22b/scenes/market/trade_inventory.tscn index 6ae4076a..97e13f5a 100644 --- a/frontend/Savor-22b/scenes/market/trade_inventory.tscn +++ b/frontend/Savor-22b/scenes/market/trade_inventory.tscn @@ -1,21 +1,32 @@ -[gd_scene load_steps=4 format=3 uid="uid://81w3i6nbxjix"] +[gd_scene load_steps=7 format=3 uid="uid://bu43d13qwmtcr"] [ext_resource type="Script" path="res://scenes/market/trade_inventory.gd" id="1_2sbin"] +[ext_resource type="ButtonGroup" uid="uid://di66p0jb8cdpk" path="res://scenes/market/sell_list_button_group.tres" id="2_68j2i"] -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8vjfi"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4l2s6"] bg_color = Color(0, 0, 0, 1) corner_radius_top_left = 25 corner_radius_top_right = 25 +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vqa0t"] +bg_color = Color(0.94902, 0.694118, 0.243137, 1) +corner_radius_top_left = 25 +corner_radius_top_right = 25 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_af182"] +bg_color = Color(0.94902, 0.694118, 0.243137, 1) +corner_radius_top_left = 25 +corner_radius_top_right = 25 + [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_as0cg"] bg_color = Color(0.94902, 0.694118, 0.243137, 1) -[node name="TradeInventory" type="Control"] +[node name="SellList" type="Control"] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_right = -1220.0 +offset_right = -700.0 offset_bottom = -130.0 grow_horizontal = 2 grow_vertical = 2 @@ -32,31 +43,41 @@ grow_vertical = 2 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] layout_mode = 2 -[node name="TitlePanel" type="Panel" parent="MarginContainer/VBoxContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/separation = 20 + +[node name="WholeSellListButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] custom_minimum_size = Vector2(200, 70) layout_mode = 2 size_flags_horizontal = 0 -theme_override_styles/panel = SubResource("StyleBoxFlat_8vjfi") +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_4l2s6") +theme_override_styles/pressed = SubResource("StyleBoxFlat_vqa0t") +toggle_mode = true +button_pressed = true +button_group = ExtResource("2_68j2i") +text = "판매목록" -[node name="TitleLabel" type="Label" parent="MarginContainer/VBoxContainer/TitlePanel"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 +[node name="MySellListButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] +custom_minimum_size = Vector2(240, 70) +layout_mode = 2 +size_flags_horizontal = 0 theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_font_sizes/font_size = 40 -text = "인벤토리" -horizontal_alignment = 1 -vertical_alignment = 1 +theme_override_styles/normal = SubResource("StyleBoxFlat_4l2s6") +theme_override_styles/pressed = SubResource("StyleBoxFlat_af182") +toggle_mode = true +button_group = ExtResource("2_68j2i") +text = "내 판매목록" -[node name="InventoryPanel" type="Panel" parent="MarginContainer/VBoxContainer"] +[node name="ListPanel" type="Panel" parent="MarginContainer/VBoxContainer"] custom_minimum_size = Vector2(2.08165e-12, 750) layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_as0cg") -[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer/InventoryPanel"] +[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer/ListPanel"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -64,11 +85,21 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer"] +[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer"] layout_mode = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 50 -[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer"] +[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer"] +layout_mode = 2 + +[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer/CenterContainer"] layout_mode = 2 theme_override_constants/h_separation = 50 theme_override_constants/v_separation = 50 columns = 2 + +[connection signal="button_down" from="MarginContainer/VBoxContainer/HBoxContainer/WholeSellListButton" to="." method="_on_whole_sell_list_button_down"] +[connection signal="button_down" from="MarginContainer/VBoxContainer/HBoxContainer/MySellListButton" to="." method="_on_my_sell_list_button_down"] From c78d21aeff39fddf23af9a7cab40bbd04a9a7cc4 Mon Sep 17 00:00:00 2001 From: Tae Hyoung Kang <78776542+kth1888@users.noreply.github.com> Date: Mon, 27 May 2024 19:16:55 +0900 Subject: [PATCH 4/6] fix : ui problems at feedback --- frontend/Savor-22b/scenes/farm/farm.gd | 3 + frontend/Savor-22b/scenes/farm/farm.tscn | 7 +++ frontend/Savor-22b/scenes/house/house.gd | 3 + frontend/Savor-22b/scenes/house/house.tscn | 22 ++++--- frontend/Savor-22b/scenes/market/inventory.gd | 2 +- .../Savor-22b/scenes/market/inventory.tscn | 20 ++++-- frontend/Savor-22b/scenes/market/my_item.gd | 11 ++-- frontend/Savor-22b/scenes/market/my_item.tscn | 62 +++++++++++++++++-- .../Savor-22b/scenes/market/trade_goods.gd | 3 +- .../Savor-22b/scenes/market/trade_goods.tscn | 10 +-- .../scenes/market/trade_inventory.tscn | 4 +- .../Savor-22b/scenes/village/village_view.gd | 2 - .../scenes/village/village_view.tscn | 19 ------ 13 files changed, 118 insertions(+), 50 deletions(-) diff --git a/frontend/Savor-22b/scenes/farm/farm.gd b/frontend/Savor-22b/scenes/farm/farm.gd index acb1e621..87ef735c 100644 --- a/frontend/Savor-22b/scenes/farm/farm.gd +++ b/frontend/Savor-22b/scenes/farm/farm.gd @@ -241,3 +241,6 @@ func _on_refresh_button_down(): func _on_home_button_down(): get_tree().change_scene_to_file("res://scenes/house/house.tscn") + +func _on_market_button_down(): + get_tree().change_scene_to_file("res://scenes/market/market.tscn") diff --git a/frontend/Savor-22b/scenes/farm/farm.tscn b/frontend/Savor-22b/scenes/farm/farm.tscn index 838188d2..78370e9f 100644 --- a/frontend/Savor-22b/scenes/farm/farm.tscn +++ b/frontend/Savor-22b/scenes/farm/farm.tscn @@ -94,6 +94,12 @@ size_flags_vertical = 0 theme_override_font_sizes/font_size = 50 text = "부엌으로" +[node name="MarketButton" type="Button" parent="MC/HC/VBoxContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 0 +theme_override_font_sizes/font_size = 50 +text = "무역으로" + [node name="InventoryButton" type="Button" parent="MC/HC/VBoxContainer/MarginContainer/VBoxContainer"] layout_mode = 2 size_flags_vertical = 0 @@ -112,4 +118,5 @@ offset_right = 40.0 offset_bottom = 40.0 [connection signal="button_down" from="MC/HC/VBoxContainer/MarginContainer/VBoxContainer/HomeButton" to="." method="_on_home_button_down"] +[connection signal="button_down" from="MC/HC/VBoxContainer/MarginContainer/VBoxContainer/MarketButton" to="." method="_on_market_button_down"] [connection signal="button_down" from="MC/HC/VBoxContainer/MarginContainer/VBoxContainer/RefreshButton" to="." method="_on_refresh_button_down"] diff --git a/frontend/Savor-22b/scenes/house/house.gd b/frontend/Savor-22b/scenes/house/house.gd index d998ba36..60a3690d 100644 --- a/frontend/Savor-22b/scenes/house/house.gd +++ b/frontend/Savor-22b/scenes/house/house.gd @@ -107,6 +107,9 @@ func _on_farm_button_down(): func _on_village_button_down(): get_tree().change_scene_to_file("res://scenes/village/village_view.tscn") +func _on_market_button_down(): + get_tree().change_scene_to_file("res://scenes/market/market.tscn") + func _on_refresh_button_down(): clear_popup() reload_sub_scene() diff --git a/frontend/Savor-22b/scenes/house/house.tscn b/frontend/Savor-22b/scenes/house/house.tscn index 283d27df..441aec40 100644 --- a/frontend/Savor-22b/scenes/house/house.tscn +++ b/frontend/Savor-22b/scenes/house/house.tscn @@ -56,47 +56,54 @@ theme_override_constants/margin_bottom = 20 custom_minimum_size = Vector2(500, 2.08165e-12) layout_mode = 2 size_flags_horizontal = 8 -columns = 5 +columns = 6 [node name="FarmButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 -theme_override_font_sizes/font_size = 50 +theme_override_font_sizes/font_size = 45 text = "밭으로" [node name="VillageButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 -theme_override_font_sizes/font_size = 50 +theme_override_font_sizes/font_size = 45 text = " 마을로 " +[node name="MarketButton" type="Button" parent="M/V/menus/V"] +custom_minimum_size = Vector2(200, 2.08165e-12) +layout_mode = 2 +size_flags_vertical = 0 +theme_override_font_sizes/font_size = 45 +text = " 무역으로 " + [node name="RecipeButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 -theme_override_font_sizes/font_size = 50 +theme_override_font_sizes/font_size = 45 text = " 레시피북 " [node name="InventoryButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 -theme_override_font_sizes/font_size = 50 +theme_override_font_sizes/font_size = 45 text = " 인벤토리 " [node name="RefreshButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 -theme_override_font_sizes/font_size = 50 +theme_override_font_sizes/font_size = 45 text = " 새로고침 " [node name="M" type="MarginContainer" parent="M/V/menus"] layout_mode = 2 size_flags_horizontal = 0 -theme_override_constants/margin_left = 250 +theme_override_constants/margin_left = 200 [node name="CookButton" type="Button" parent="M/V/menus/M"] custom_minimum_size = Vector2(380, 2.08165e-12) @@ -132,6 +139,7 @@ offset_bottom = 340.0 [connection signal="button_down" from="M/V/menus/V/FarmButton" to="." method="_on_farm_button_down"] [connection signal="button_down" from="M/V/menus/V/VillageButton" to="." method="_on_village_button_down"] +[connection signal="button_down" from="M/V/menus/V/MarketButton" to="." method="_on_market_button_down"] [connection signal="button_down" from="M/V/menus/V/RecipeButton" to="." method="_on_recipe_button_down"] [connection signal="button_down" from="M/V/menus/V/InventoryButton" to="." method="_on_inventory_button_down"] [connection signal="button_down" from="M/V/menus/V/RefreshButton" to="." method="_on_refresh_button_down"] diff --git a/frontend/Savor-22b/scenes/market/inventory.gd b/frontend/Savor-22b/scenes/market/inventory.gd index 78ed1d62..7c931387 100644 --- a/frontend/Savor-22b/scenes/market/inventory.gd +++ b/frontend/Savor-22b/scenes/market/inventory.gd @@ -2,7 +2,7 @@ extends Control const MyItemScn = preload("res://scenes/market/my_item.tscn") -@onready var inventory_container = $MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer/GridContainer +@onready var inventory_container = $MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer/MarginContainer/GridContainer var items diff --git a/frontend/Savor-22b/scenes/market/inventory.tscn b/frontend/Savor-22b/scenes/market/inventory.tscn index 17deb2b5..fcfceb9e 100644 --- a/frontend/Savor-22b/scenes/market/inventory.tscn +++ b/frontend/Savor-22b/scenes/market/inventory.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=4 format=3 uid="uid://81w3i6nbxjix"] -[ext_resource type="Script" path="res://scenes/market/inventory.gd" id="1_6c1t0"] +[ext_resource type="Script" path="res://scenes/market/inventory.gd" id="1_xk4wq"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8vjfi"] -bg_color = Color(0, 0, 0, 1) +bg_color = Color(0.94902, 0.694118, 0.243137, 1) corner_radius_top_left = 25 corner_radius_top_right = 25 @@ -19,7 +19,7 @@ offset_right = -1220.0 offset_bottom = -130.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_6c1t0") +script = ExtResource("1_xk4wq") [node name="MarginContainer" type="MarginContainer" parent="."] layout_mode = 1 @@ -31,6 +31,7 @@ grow_vertical = 2 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] layout_mode = 2 +theme_override_constants/separation = -1 [node name="TitlePanel" type="Panel" parent="MarginContainer/VBoxContainer"] custom_minimum_size = Vector2(200, 70) @@ -45,7 +46,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 40 text = "인벤토리" horizontal_alignment = 1 @@ -67,8 +68,15 @@ grow_vertical = 2 [node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer"] layout_mode = 2 -[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer"] +[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 20 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 20 + +[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer/MarginContainer"] layout_mode = 2 -theme_override_constants/h_separation = 50 +theme_override_constants/h_separation = 25 theme_override_constants/v_separation = 50 columns = 2 diff --git a/frontend/Savor-22b/scenes/market/my_item.gd b/frontend/Savor-22b/scenes/market/my_item.gd index 4f4ebdc9..515dc412 100644 --- a/frontend/Savor-22b/scenes/market/my_item.gd +++ b/frontend/Savor-22b/scenes/market/my_item.gd @@ -1,11 +1,11 @@ extends Control @onready var item_button = $ItemSelectButton +@onready var item_name_label = $ItemSelectButton/MarginContainer/VBoxContainer/HBoxContainer/NameLabel +@onready var item_grade_label = $ItemSelectButton/MarginContainer/VBoxContainer/HBoxContainer/GradeLabel +@onready var item_stateid_label = $ItemSelectButton/MarginContainer/VBoxContainer/StateIdLabel var info -var desc_format_string = "%s -%s : %s -%s : %s" func _ready(): _update_info() @@ -13,7 +13,10 @@ func _ready(): func _update_info(): if item_button == null: return - item_button.text = desc_format_string % [info.name, "등급", info.grade, "stateId", info.stateId] + + item_name_label.text = info.name + item_grade_label.text = info.grade + "등급" + item_stateid_label.text = info.stateId func set_info(info: Dictionary): self.info = info diff --git a/frontend/Savor-22b/scenes/market/my_item.tscn b/frontend/Savor-22b/scenes/market/my_item.tscn index 8a90c047..5449d218 100644 --- a/frontend/Savor-22b/scenes/market/my_item.tscn +++ b/frontend/Savor-22b/scenes/market/my_item.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=3 format=3 uid="uid://c7yghm5bsqwif"] +[gd_scene load_steps=4 format=3 uid="uid://c7yghm5bsqwif"] [ext_resource type="Script" path="res://scenes/market/my_item.gd" id="1_5wh4n"] @@ -9,13 +9,20 @@ corner_radius_top_right = 30 corner_radius_bottom_right = 30 corner_radius_bottom_left = 30 +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8dykl"] +bg_color = Color(0.345098, 0.345098, 0.345098, 1) +corner_radius_top_left = 30 +corner_radius_top_right = 30 +corner_radius_bottom_right = 30 +corner_radius_bottom_left = 30 + [node name="MyItem" type="Control"] -custom_minimum_size = Vector2(310, 200) +custom_minimum_size = Vector2(320, 200) layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_right = -1610.0 +offset_right = -1600.0 offset_bottom = -880.0 grow_horizontal = 2 grow_vertical = 2 @@ -31,7 +38,52 @@ grow_vertical = 2 theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_font_sizes/font_size = 40 theme_override_styles/normal = SubResource("StyleBoxFlat_21if1") -text = "아이템 정보" -text_overrun_behavior = 1 +theme_override_styles/hover = SubResource("StyleBoxFlat_8dykl") + +[node name="MarginContainer" type="MarginContainer" parent="ItemSelectButton"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 5 +theme_override_constants/margin_top = 5 +theme_override_constants/margin_right = 4 +theme_override_constants/margin_bottom = 5 + +[node name="VBoxContainer" type="VBoxContainer" parent="ItemSelectButton/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 5 + +[node name="HBoxContainer" type="HBoxContainer" parent="ItemSelectButton/MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(310, 2.08165e-12) +layout_mode = 2 + +[node name="NameLabel" type="Label" parent="ItemSelectButton/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 35 +text = "아이템 이름" + +[node name="MarginContainer" type="MarginContainer" parent="ItemSelectButton/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="GradeLabel" type="Label" parent="ItemSelectButton/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 25 +text = "A등급" +horizontal_alignment = 2 + +[node name="StateIdLabel" type="Label" parent="ItemSelectButton/MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(310, 130) +layout_mode = 2 +size_flags_vertical = 1 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 25 +text = "stateId:" +autowrap_mode = 3 [connection signal="button_down" from="ItemSelectButton" to="." method="_on_item_select_button_down"] diff --git a/frontend/Savor-22b/scenes/market/trade_goods.gd b/frontend/Savor-22b/scenes/market/trade_goods.gd index 04de1518..87c1ef8a 100644 --- a/frontend/Savor-22b/scenes/market/trade_goods.gd +++ b/frontend/Savor-22b/scenes/market/trade_goods.gd @@ -5,6 +5,7 @@ extends Control var info var desc_format_string = "%s : %s +%s : %s %s : %s%s %s : %s" @@ -14,7 +15,7 @@ func _ready(): func _update_info(): if description_label == null: return - description_label.text = desc_format_string % ["품목명",info.food["name"],"가격",info.price," BBG","게시자",info.sellerAddress] + description_label.text = desc_format_string % ["품목명",info.food["name"],"stateId",info.food["stateId"],"가격",info.price," BBG","게시자",info.sellerAddress] func set_info(info: Dictionary): self.info = info diff --git a/frontend/Savor-22b/scenes/market/trade_goods.tscn b/frontend/Savor-22b/scenes/market/trade_goods.tscn index b90dad51..daecc300 100644 --- a/frontend/Savor-22b/scenes/market/trade_goods.tscn +++ b/frontend/Savor-22b/scenes/market/trade_goods.tscn @@ -22,12 +22,13 @@ corner_radius_bottom_right = 15 corner_radius_bottom_left = 15 [node name="TradeGoods" type="Control"] -custom_minimum_size = Vector2(410, 410) +custom_minimum_size = Vector2(500, 430) layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_right = -1540.0 +offset_left = -25.0 +offset_right = -1445.0 offset_bottom = -670.0 grow_horizontal = 2 grow_vertical = 2 @@ -61,12 +62,13 @@ layout_mode = 2 custom_minimum_size = Vector2(2.08165e-12, 280) layout_mode = 2 theme_override_colors/font_color = Color(1, 1, 1, 1) -theme_override_font_sizes/font_size = 40 +theme_override_font_sizes/font_size = 30 text = "품목명 : 참치 +foodstateId : ~~ 가격 : 10 게시자 : 맛도리 해적단 " -text_overrun_behavior = 1 +autowrap_mode = 1 [node name="BuyButton" type="Button" parent="BackgroundPanel/MarginContainer/VBoxContainer"] layout_mode = 2 diff --git a/frontend/Savor-22b/scenes/market/trade_inventory.tscn b/frontend/Savor-22b/scenes/market/trade_inventory.tscn index 97e13f5a..3168a5a5 100644 --- a/frontend/Savor-22b/scenes/market/trade_inventory.tscn +++ b/frontend/Savor-22b/scenes/market/trade_inventory.tscn @@ -42,6 +42,7 @@ grow_vertical = 2 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] layout_mode = 2 +theme_override_constants/separation = -1 [node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] layout_mode = 2 @@ -51,10 +52,10 @@ theme_override_constants/separation = 20 custom_minimum_size = Vector2(200, 70) layout_mode = 2 size_flags_horizontal = 0 -theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_font_sizes/font_size = 40 theme_override_styles/normal = SubResource("StyleBoxFlat_4l2s6") theme_override_styles/pressed = SubResource("StyleBoxFlat_vqa0t") +theme_override_styles/focus = SubResource("StyleBoxFlat_vqa0t") toggle_mode = true button_pressed = true button_group = ExtResource("2_68j2i") @@ -68,6 +69,7 @@ theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_font_sizes/font_size = 40 theme_override_styles/normal = SubResource("StyleBoxFlat_4l2s6") theme_override_styles/pressed = SubResource("StyleBoxFlat_af182") +theme_override_styles/focus = SubResource("StyleBoxFlat_af182") toggle_mode = true button_group = ExtResource("2_68j2i") text = "내 판매목록" diff --git a/frontend/Savor-22b/scenes/village/village_view.gd b/frontend/Savor-22b/scenes/village/village_view.gd index 88a41cb4..1264eb52 100644 --- a/frontend/Savor-22b/scenes/village/village_view.gd +++ b/frontend/Savor-22b/scenes/village/village_view.gd @@ -66,8 +66,6 @@ func _on_enter_button_down(): func _on_farm_button_down(): get_tree().change_scene_to_file("res://scenes/farm/farm.tscn") -func _on_market_button_down(): - get_tree().change_scene_to_file("res://scenes/market/market.tscn") #open shop with S input diff --git a/frontend/Savor-22b/scenes/village/village_view.tscn b/frontend/Savor-22b/scenes/village/village_view.tscn index f3815d9d..a1995620 100644 --- a/frontend/Savor-22b/scenes/village/village_view.tscn +++ b/frontend/Savor-22b/scenes/village/village_view.tscn @@ -68,24 +68,6 @@ grow_vertical = 2 theme_override_font_sizes/font_size = 70 text = " 내 밭으로 가기 " -[node name="MarketButtonContainer" type="ColorRect" parent="TopMenuMarginContainer/Control"] -layout_mode = 0 -offset_left = 920.0 -offset_right = 1370.0 -offset_bottom = 100.0 -size_flags_horizontal = 4 -color = Color(0, 0, 0, 1) - -[node name="MarketButton" type="Button" parent="TopMenuMarginContainer/Control/MarketButtonContainer"] -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 = "무역 화면 가기 " - [node name="HBoxContainer" type="HBoxContainer" parent="TopMenuMarginContainer/Control"] layout_mode = 0 offset_right = 40.0 @@ -178,5 +160,4 @@ offset_bottom = 40.0 [connection signal="button_down" from="TopMenuMarginContainer/Control/HomeButtonContainer/HomeButton" to="." method="_on_home_button_down"] [connection signal="button_down" from="TopMenuMarginContainer/Control/FarmButtonContainer/FarmButton" to="." method="_on_farm_button_down"] -[connection signal="button_down" from="TopMenuMarginContainer/Control/MarketButtonContainer/MarketButton" to="." method="_on_market_button_down"] [connection signal="button_down" from="BottomMenuMarginContainer/Control/EnterButtonContainer/EnterButton" to="." method="_on_enter_button_down"] From 4ef0f13349d9c2239369669b345cc40ef857d588 Mon Sep 17 00:00:00 2001 From: Tae Hyoung Kang <78776542+kth1888@users.noreply.github.com> Date: Tue, 28 May 2024 01:25:20 +0900 Subject: [PATCH 5/6] fix : ui problems #2 --- frontend/Savor-22b/scenes/farm/farm.tscn | 2 +- frontend/Savor-22b/scenes/house/house.tscn | 6 +- frontend/Savor-22b/scenes/market/inventory.gd | 26 +++++- .../Savor-22b/scenes/market/inventory.tscn | 6 +- frontend/Savor-22b/scenes/market/market.tscn | 2 +- frontend/Savor-22b/scenes/market/my_item.gd | 19 ++-- frontend/Savor-22b/scenes/market/my_item.tscn | 75 ++++++++------- .../Savor-22b/scenes/market/my_trade_goods.gd | 20 ++++ .../scenes/market/my_trade_goods.tscn | 91 +++++++++++++++++++ .../Savor-22b/scenes/market/trade_goods.tscn | 6 +- .../scenes/market/trade_inventory.gd | 13 ++- 11 files changed, 203 insertions(+), 63 deletions(-) create mode 100644 frontend/Savor-22b/scenes/market/my_trade_goods.gd create mode 100644 frontend/Savor-22b/scenes/market/my_trade_goods.tscn diff --git a/frontend/Savor-22b/scenes/farm/farm.tscn b/frontend/Savor-22b/scenes/farm/farm.tscn index 78370e9f..458eb143 100644 --- a/frontend/Savor-22b/scenes/farm/farm.tscn +++ b/frontend/Savor-22b/scenes/farm/farm.tscn @@ -98,7 +98,7 @@ text = "부엌으로" layout_mode = 2 size_flags_vertical = 0 theme_override_font_sizes/font_size = 50 -text = "무역으로" +text = "무역하러 가기" [node name="InventoryButton" type="Button" parent="MC/HC/VBoxContainer/MarginContainer/VBoxContainer"] layout_mode = 2 diff --git a/frontend/Savor-22b/scenes/house/house.tscn b/frontend/Savor-22b/scenes/house/house.tscn index 441aec40..38eac7ed 100644 --- a/frontend/Savor-22b/scenes/house/house.tscn +++ b/frontend/Savor-22b/scenes/house/house.tscn @@ -32,7 +32,7 @@ offset_right = 40.0 offset_bottom = 23.0 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 60 -text = " 집 화면" +text = " 집 " [node name="M" type="MarginContainer" parent="."] layout_mode = 1 @@ -77,7 +77,7 @@ custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 theme_override_font_sizes/font_size = 45 -text = " 무역으로 " +text = " 무역하러 가기 " [node name="RecipeButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) @@ -103,7 +103,7 @@ text = " 새로고침 " [node name="M" type="MarginContainer" parent="M/V/menus"] layout_mode = 2 size_flags_horizontal = 0 -theme_override_constants/margin_left = 200 +theme_override_constants/margin_left = 100 [node name="CookButton" type="Button" parent="M/V/menus/M"] custom_minimum_size = Vector2(380, 2.08165e-12) diff --git a/frontend/Savor-22b/scenes/market/inventory.gd b/frontend/Savor-22b/scenes/market/inventory.gd index 7c931387..cc668d3b 100644 --- a/frontend/Savor-22b/scenes/market/inventory.gd +++ b/frontend/Savor-22b/scenes/market/inventory.gd @@ -5,14 +5,34 @@ const MyItemScn = preload("res://scenes/market/my_item.tscn") @onready var inventory_container = $MarginContainer/VBoxContainer/InventoryPanel/ScrollContainer/CenterContainer/MarginContainer/GridContainer var items +var grouped_items = {} func _ready(): load_items() + func load_items(): items = SceneContext.user_state.inventoryState["refrigeratorStateList"] + sort_inventory_by_items() + for item in grouped_items.values(): + for grade in item.values(): + var item_scene = MyItemScn.instantiate() + item_scene.set_info(grade) + inventory_container.add_child(item_scene) + +func sort_inventory_by_items(): for item in items: - var item_scene = MyItemScn.instantiate() - item_scene.set_info(item) - inventory_container.add_child(item_scene) + var name = item["name"] + var grade = item["grade"] + + # 이름이 존재하지 않으면 새로 추가 + if not grouped_items.has(name): + grouped_items[name] = {} + + # 등급이 존재하지 않으면 이름 하위에 새로 추가 + if not grouped_items[name].has(grade): + grouped_items[name][grade] = [] + + # 아이템을 등급 배열에 추가 + grouped_items[name][grade].append(item) diff --git a/frontend/Savor-22b/scenes/market/inventory.tscn b/frontend/Savor-22b/scenes/market/inventory.tscn index fcfceb9e..d3ec04c3 100644 --- a/frontend/Savor-22b/scenes/market/inventory.tscn +++ b/frontend/Savor-22b/scenes/market/inventory.tscn @@ -3,9 +3,7 @@ [ext_resource type="Script" path="res://scenes/market/inventory.gd" id="1_xk4wq"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8vjfi"] -bg_color = Color(0.94902, 0.694118, 0.243137, 1) -corner_radius_top_left = 25 -corner_radius_top_right = 25 +bg_color = Color(0, 0, 0, 0) [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_as0cg"] bg_color = Color(0.94902, 0.694118, 0.243137, 1) @@ -31,7 +29,7 @@ grow_vertical = 2 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] layout_mode = 2 -theme_override_constants/separation = -1 +theme_override_constants/separation = 3 [node name="TitlePanel" type="Panel" parent="MarginContainer/VBoxContainer"] custom_minimum_size = Vector2(200, 70) diff --git a/frontend/Savor-22b/scenes/market/market.tscn b/frontend/Savor-22b/scenes/market/market.tscn index ec109007..537e9a23 100644 --- a/frontend/Savor-22b/scenes/market/market.tscn +++ b/frontend/Savor-22b/scenes/market/market.tscn @@ -26,7 +26,7 @@ offset_right = 40.0 offset_bottom = 23.0 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 60 -text = " 무역 화면" +text = " 무역 상점" [node name="VBoxContainer" type="VBoxContainer" parent="."] custom_minimum_size = Vector2(1920, 1080) diff --git a/frontend/Savor-22b/scenes/market/my_item.gd b/frontend/Savor-22b/scenes/market/my_item.gd index 515dc412..440971ad 100644 --- a/frontend/Savor-22b/scenes/market/my_item.gd +++ b/frontend/Savor-22b/scenes/market/my_item.gd @@ -1,9 +1,8 @@ extends Control -@onready var item_button = $ItemSelectButton -@onready var item_name_label = $ItemSelectButton/MarginContainer/VBoxContainer/HBoxContainer/NameLabel -@onready var item_grade_label = $ItemSelectButton/MarginContainer/VBoxContainer/HBoxContainer/GradeLabel -@onready var item_stateid_label = $ItemSelectButton/MarginContainer/VBoxContainer/StateIdLabel +@onready var item_name_label = $Background/MarginContainer/VBoxContainer/NameLabel +@onready var item_grade_label = $Background/MarginContainer/VBoxContainer/HBoxContainer/GradeLabel +@onready var item_amount_label = $Background/MarginContainer/VBoxContainer/HBoxContainer/AmountLabel var info @@ -11,15 +10,15 @@ func _ready(): _update_info() func _update_info(): - if item_button == null: + if $Background == null: return - item_name_label.text = info.name - item_grade_label.text = info.grade + "등급" - item_stateid_label.text = info.stateId + item_name_label.text = info[0]["name"] + item_grade_label.text = info[0]["grade"] + "등급" + item_amount_label.text = "%s 개" % [info.size()] -func set_info(info: Dictionary): +func set_info(info: Array): self.info = info -func _on_item_select_button_down(): +func _on_register_trade_button_down(): pass # 물건 올리기 기능이 들어갈 예정 diff --git a/frontend/Savor-22b/scenes/market/my_item.tscn b/frontend/Savor-22b/scenes/market/my_item.tscn index 5449d218..e6076ec7 100644 --- a/frontend/Savor-22b/scenes/market/my_item.tscn +++ b/frontend/Savor-22b/scenes/market/my_item.tscn @@ -9,81 +9,88 @@ corner_radius_top_right = 30 corner_radius_bottom_right = 30 corner_radius_bottom_left = 30 -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8dykl"] -bg_color = Color(0.345098, 0.345098, 0.345098, 1) -corner_radius_top_left = 30 -corner_radius_top_right = 30 -corner_radius_bottom_right = 30 -corner_radius_bottom_left = 30 +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_oq8hu"] +bg_color = Color(0, 0, 0, 1) +border_width_left = 3 +border_width_top = 3 +border_width_right = 3 +border_width_bottom = 3 +border_color = Color(1, 1, 1, 1) +corner_radius_top_left = 15 +corner_radius_top_right = 15 +corner_radius_bottom_right = 15 +corner_radius_bottom_left = 15 [node name="MyItem" type="Control"] -custom_minimum_size = Vector2(320, 200) +custom_minimum_size = Vector2(320, 190) layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_right = -1600.0 -offset_bottom = -880.0 +offset_right = -1610.0 +offset_bottom = -890.0 grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_5wh4n") -[node name="ItemSelectButton" type="Button" parent="."] +[node name="Background" type="Panel" parent="."] 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(1, 1, 1, 1) -theme_override_font_sizes/font_size = 40 -theme_override_styles/normal = SubResource("StyleBoxFlat_21if1") -theme_override_styles/hover = SubResource("StyleBoxFlat_8dykl") +theme_override_styles/panel = SubResource("StyleBoxFlat_21if1") -[node name="MarginContainer" type="MarginContainer" parent="ItemSelectButton"] +[node name="MarginContainer" type="MarginContainer" parent="Background"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -theme_override_constants/margin_left = 5 -theme_override_constants/margin_top = 5 -theme_override_constants/margin_right = 4 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 theme_override_constants/margin_bottom = 5 -[node name="VBoxContainer" type="VBoxContainer" parent="ItemSelectButton/MarginContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="Background/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 10 + +[node name="NameLabel" type="Label" parent="Background/MarginContainer/VBoxContainer"] layout_mode = 2 -theme_override_constants/separation = 5 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +text = "아이템 이름" -[node name="HBoxContainer" type="HBoxContainer" parent="ItemSelectButton/MarginContainer/VBoxContainer"] -custom_minimum_size = Vector2(310, 2.08165e-12) +[node name="HBoxContainer" type="HBoxContainer" parent="Background/MarginContainer/VBoxContainer"] layout_mode = 2 -[node name="NameLabel" type="Label" parent="ItemSelectButton/MarginContainer/VBoxContainer/HBoxContainer"] +[node name="AmountLabel" type="Label" parent="Background/MarginContainer/VBoxContainer/HBoxContainer"] layout_mode = 2 theme_override_colors/font_color = Color(1, 1, 1, 1) -theme_override_font_sizes/font_size = 35 -text = "아이템 이름" +theme_override_font_sizes/font_size = 25 +text = "10 개" +horizontal_alignment = 2 -[node name="MarginContainer" type="MarginContainer" parent="ItemSelectButton/MarginContainer/VBoxContainer/HBoxContainer"] +[node name="MarginContainer" type="MarginContainer" parent="Background/MarginContainer/VBoxContainer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 -[node name="GradeLabel" type="Label" parent="ItemSelectButton/MarginContainer/VBoxContainer/HBoxContainer"] +[node name="GradeLabel" type="Label" parent="Background/MarginContainer/VBoxContainer/HBoxContainer"] layout_mode = 2 theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_font_sizes/font_size = 25 text = "A등급" horizontal_alignment = 2 -[node name="StateIdLabel" type="Label" parent="ItemSelectButton/MarginContainer/VBoxContainer"] -custom_minimum_size = Vector2(310, 130) +[node name="RegisterTradeButton" type="Button" parent="Background/MarginContainer/VBoxContainer"] layout_mode = 2 -size_flags_vertical = 1 +size_flags_horizontal = 8 theme_override_colors/font_color = Color(1, 1, 1, 1) -theme_override_font_sizes/font_size = 25 -text = "stateId:" -autowrap_mode = 3 +theme_override_font_sizes/font_size = 35 +theme_override_styles/normal = SubResource("StyleBoxFlat_oq8hu") +text = " 아이템 등록하기 " -[connection signal="button_down" from="ItemSelectButton" to="." method="_on_item_select_button_down"] +[connection signal="button_down" from="Background/MarginContainer/VBoxContainer/RegisterTradeButton" to="." method="_on_register_trade_button_down"] diff --git a/frontend/Savor-22b/scenes/market/my_trade_goods.gd b/frontend/Savor-22b/scenes/market/my_trade_goods.gd new file mode 100644 index 00000000..46ae2129 --- /dev/null +++ b/frontend/Savor-22b/scenes/market/my_trade_goods.gd @@ -0,0 +1,20 @@ +extends Control + +@onready var item_button = $ItemSelectButton +@onready var description_label = $BackgroundPanel/MarginContainer/VBoxContainer/DescriptionLabel + +var info +var desc_format_string = "%s : %s +%s : %s +%s : %s%s" + +func _ready(): + _update_info() + +func _update_info(): + if description_label == null: + return + description_label.text = desc_format_string % ["품목명",info.food["name"],"stateId",info.food["stateId"],"가격",info.price," BBG"] + +func set_info(info: Dictionary): + self.info = info diff --git a/frontend/Savor-22b/scenes/market/my_trade_goods.tscn b/frontend/Savor-22b/scenes/market/my_trade_goods.tscn new file mode 100644 index 00000000..aaa54c7f --- /dev/null +++ b/frontend/Savor-22b/scenes/market/my_trade_goods.tscn @@ -0,0 +1,91 @@ +[gd_scene load_steps=4 format=3 uid="uid://bwosqhxgrw2w5"] + +[ext_resource type="Script" path="res://scenes/market/my_trade_goods.gd" id="1_4ajeb"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3bs65"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 40 +corner_radius_top_right = 40 +corner_radius_bottom_right = 40 +corner_radius_bottom_left = 40 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_lobix"] +bg_color = Color(0, 0, 0, 1) +border_width_left = 3 +border_width_top = 3 +border_width_right = 3 +border_width_bottom = 3 +border_color = Color(1, 1, 1, 1) +corner_radius_top_left = 15 +corner_radius_top_right = 15 +corner_radius_bottom_right = 15 +corner_radius_bottom_left = 15 + +[node name="MyTradeGoods" type="Control"] +custom_minimum_size = Vector2(500, 430) +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -25.0 +offset_right = -1445.0 +offset_bottom = -670.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_4ajeb") + +[node name="BackgroundPanel" type="Panel" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_3bs65") + +[node name="MarginContainer" type="MarginContainer" parent="BackgroundPanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 25 +theme_override_constants/margin_top = 30 +theme_override_constants/margin_right = 25 +theme_override_constants/margin_bottom = 30 + +[node name="VBoxContainer" type="VBoxContainer" parent="BackgroundPanel/MarginContainer"] +layout_mode = 2 + +[node name="DescriptionLabel" type="Label" parent="BackgroundPanel/MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(2.08165e-12, 280) +layout_mode = 2 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 30 +text = "품목명 : 참치 +foodstateId : ~~ +가격 : 10 +" +autowrap_mode = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="BackgroundPanel/MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/separation = 20 +alignment = 2 + +[node name="PriceEditButton" type="Button" parent="BackgroundPanel/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 8 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_lobix") +text = " 가격 수정 " + +[node name="CancelButton" type="Button" parent="BackgroundPanel/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 8 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_font_sizes/font_size = 40 +theme_override_styles/normal = SubResource("StyleBoxFlat_lobix") +text = " 등록 취소 " diff --git a/frontend/Savor-22b/scenes/market/trade_goods.tscn b/frontend/Savor-22b/scenes/market/trade_goods.tscn index daecc300..26688be4 100644 --- a/frontend/Savor-22b/scenes/market/trade_goods.tscn +++ b/frontend/Savor-22b/scenes/market/trade_goods.tscn @@ -63,10 +63,10 @@ custom_minimum_size = Vector2(2.08165e-12, 280) layout_mode = 2 theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_font_sizes/font_size = 30 -text = "품목명 : 참치 -foodstateId : ~~ +text = "품목명 : 김 +foodstateId : dbfb5df1-9a5a-4f03-b19b-f385595ddc14 가격 : 10 -게시자 : 맛도리 해적단 +게시자 : 0xae9bbb0090e20a8d1c8c3a2667b55951f8e " autowrap_mode = 1 diff --git a/frontend/Savor-22b/scenes/market/trade_inventory.gd b/frontend/Savor-22b/scenes/market/trade_inventory.gd index 9af4aebb..7874c232 100644 --- a/frontend/Savor-22b/scenes/market/trade_inventory.gd +++ b/frontend/Savor-22b/scenes/market/trade_inventory.gd @@ -1,6 +1,7 @@ extends Control const TradeGoodsScn = preload("res://scenes/market/trade_goods.tscn") +const MyTradeGoodsScn = preload("res://scenes/market/my_trade_goods.tscn") @onready var list_container = $MarginContainer/VBoxContainer/ListPanel/ScrollContainer/MarginContainer/CenterContainer/GridContainer @@ -19,22 +20,26 @@ func load_list(): for good in goods: if(good["sellerAddress"] != my_address): - add_lists(good) + add_lists(good, false) func _on_my_sell_list_button_down(): clear_list_panel() for good in goods: if(good["sellerAddress"] == my_address): - add_lists(good) + add_lists(good, true) func clear_list_panel(): if is_instance_valid(list_container): for posted_item in list_container.get_children(): posted_item.queue_free() -func add_lists(good: Dictionary): - var trade_goods_scene = TradeGoodsScn.instantiate() +func add_lists(good: Dictionary, is_mine: bool): + var trade_goods_scene + if(!is_mine): + trade_goods_scene = TradeGoodsScn.instantiate() + else: + trade_goods_scene = MyTradeGoodsScn.instantiate() trade_goods_scene.set_info(good) list_container.add_child(trade_goods_scene) From b9f754a2adb7c624f755ef4eae03715952ae10fd Mon Sep 17 00:00:00 2001 From: Tae Hyoung Kang <78776542+kth1888@users.noreply.github.com> Date: Tue, 28 May 2024 01:47:07 +0900 Subject: [PATCH 6/6] fix : ui problems #3 --- frontend/Savor-22b/scenes/farm/farm.tscn | 2 +- frontend/Savor-22b/scenes/house/house.tscn | 2 +- frontend/Savor-22b/scenes/market/my_trade_goods.gd | 3 ++- frontend/Savor-22b/scenes/market/my_trade_goods.tscn | 1 + frontend/Savor-22b/scenes/market/trade_goods.gd | 3 ++- frontend/Savor-22b/scenes/market/trade_goods.tscn | 1 + 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/Savor-22b/scenes/farm/farm.tscn b/frontend/Savor-22b/scenes/farm/farm.tscn index 458eb143..9ab2bdee 100644 --- a/frontend/Savor-22b/scenes/farm/farm.tscn +++ b/frontend/Savor-22b/scenes/farm/farm.tscn @@ -98,7 +98,7 @@ text = "부엌으로" layout_mode = 2 size_flags_vertical = 0 theme_override_font_sizes/font_size = 50 -text = "무역하러 가기" +text = "무역 상점" [node name="InventoryButton" type="Button" parent="MC/HC/VBoxContainer/MarginContainer/VBoxContainer"] layout_mode = 2 diff --git a/frontend/Savor-22b/scenes/house/house.tscn b/frontend/Savor-22b/scenes/house/house.tscn index 38eac7ed..58a4c35b 100644 --- a/frontend/Savor-22b/scenes/house/house.tscn +++ b/frontend/Savor-22b/scenes/house/house.tscn @@ -77,7 +77,7 @@ custom_minimum_size = Vector2(200, 2.08165e-12) layout_mode = 2 size_flags_vertical = 0 theme_override_font_sizes/font_size = 45 -text = " 무역하러 가기 " +text = " 무역 상점 " [node name="RecipeButton" type="Button" parent="M/V/menus/V"] custom_minimum_size = Vector2(200, 2.08165e-12) diff --git a/frontend/Savor-22b/scenes/market/my_trade_goods.gd b/frontend/Savor-22b/scenes/market/my_trade_goods.gd index 46ae2129..d2791664 100644 --- a/frontend/Savor-22b/scenes/market/my_trade_goods.gd +++ b/frontend/Savor-22b/scenes/market/my_trade_goods.gd @@ -5,6 +5,7 @@ extends Control var info var desc_format_string = "%s : %s +%s %s %s : %s %s : %s%s" @@ -14,7 +15,7 @@ func _ready(): func _update_info(): if description_label == null: return - description_label.text = desc_format_string % ["품목명",info.food["name"],"stateId",info.food["stateId"],"가격",info.price," BBG"] + description_label.text = desc_format_string % ["품목명",info.food["name"],info.food["grade"]," 등급","stateId",info.food["stateId"],"가격",info.price," BBG"] func set_info(info: Dictionary): self.info = info diff --git a/frontend/Savor-22b/scenes/market/my_trade_goods.tscn b/frontend/Savor-22b/scenes/market/my_trade_goods.tscn index aaa54c7f..e341a11d 100644 --- a/frontend/Savor-22b/scenes/market/my_trade_goods.tscn +++ b/frontend/Savor-22b/scenes/market/my_trade_goods.tscn @@ -64,6 +64,7 @@ layout_mode = 2 theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_font_sizes/font_size = 30 text = "품목명 : 참치 +A 등급 foodstateId : ~~ 가격 : 10 " diff --git a/frontend/Savor-22b/scenes/market/trade_goods.gd b/frontend/Savor-22b/scenes/market/trade_goods.gd index 87c1ef8a..49276702 100644 --- a/frontend/Savor-22b/scenes/market/trade_goods.gd +++ b/frontend/Savor-22b/scenes/market/trade_goods.gd @@ -5,6 +5,7 @@ extends Control var info var desc_format_string = "%s : %s +%s %s %s : %s %s : %s%s %s : %s" @@ -15,7 +16,7 @@ func _ready(): func _update_info(): if description_label == null: return - description_label.text = desc_format_string % ["품목명",info.food["name"],"stateId",info.food["stateId"],"가격",info.price," BBG","게시자",info.sellerAddress] + description_label.text = desc_format_string % ["품목명",info.food["name"],info.food["grade"]," 등급","stateId",info.food["stateId"],"가격",info.price," BBG","게시자",info.sellerAddress] func set_info(info: Dictionary): self.info = info diff --git a/frontend/Savor-22b/scenes/market/trade_goods.tscn b/frontend/Savor-22b/scenes/market/trade_goods.tscn index 26688be4..c8f28daa 100644 --- a/frontend/Savor-22b/scenes/market/trade_goods.tscn +++ b/frontend/Savor-22b/scenes/market/trade_goods.tscn @@ -64,6 +64,7 @@ layout_mode = 2 theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_font_sizes/font_size = 30 text = "품목명 : 김 +A 등급 foodstateId : dbfb5df1-9a5a-4f03-b19b-f385595ddc14 가격 : 10 게시자 : 0xae9bbb0090e20a8d1c8c3a2667b55951f8e