Skip to content

Commit

Permalink
fix: code feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kth1888 committed May 26, 2024
1 parent adc978b commit 42d4949
Show file tree
Hide file tree
Showing 12 changed files with 192 additions and 244 deletions.
1 change: 0 additions & 1 deletion frontend/Savor-22b/gql/query_executor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
18 changes: 18 additions & 0 deletions frontend/Savor-22b/scenes/market/inventory.gd
Original file line number Diff line number Diff line change
@@ -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)
74 changes: 74 additions & 0 deletions frontend/Savor-22b/scenes/market/inventory.tscn
Original file line number Diff line number Diff line change
@@ -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
53 changes: 11 additions & 42 deletions frontend/Savor-22b/scenes/market/market.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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()
4 changes: 0 additions & 4 deletions frontend/Savor-22b/scenes/market/market.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
7 changes: 1 addition & 6 deletions frontend/Savor-22b/scenes/market/my_item.gd
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 # 물건 올리기 기능이 들어갈 예정
45 changes: 0 additions & 45 deletions frontend/Savor-22b/scenes/market/sell_list.gd

This file was deleted.

105 changes: 0 additions & 105 deletions frontend/Savor-22b/scenes/market/sell_list.tscn

This file was deleted.

Loading

0 comments on commit 42d4949

Please sign in to comment.