Logger done
This commit is contained in:
parent
e08ae7a11f
commit
e9929f988f
9 changed files with 77 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://dfxlr4svnsdyx"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://dfxlr4svnsdyx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cqdtgvrotvjhb" path="res://src/ui/logger.gd" id="1_8dubc"]
|
||||
[ext_resource type="PackedScene" uid="uid://bcj0mesdlfsfj" path="res://scenes/popup_container.tscn" id="1_nt7q6"]
|
||||
[ext_resource type="Script" uid="uid://c5pv2idedy1oy" path="res://src/ui/reagents_gen.gd" id="2_x4jx1"]
|
||||
[ext_resource type="PackedScene" uid="uid://vhn8h4mhb6nh" path="res://scenes/drag_and_drop.tscn" id="3_yev5y"]
|
||||
|
|
@ -16,18 +17,45 @@ grow_vertical = 2
|
|||
mouse_filter = 2
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="TabBar" type="TabBar" parent="."]
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 31.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="TabBar" type="TabBar" parent="HSplitContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
size_flags_stretch_ratio = 4.0
|
||||
deselect_enabled = true
|
||||
tab_count = 3
|
||||
tab_0/title = "Ход работы"
|
||||
tab_1/title = "Вопросы для самопроверки"
|
||||
tab_2/title = "Отчёт"
|
||||
|
||||
[node name="InspectorPanel" type="PanelContainer" parent="HSplitContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="HSplitContainer/InspectorPanel"]
|
||||
layout_mode = 2
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/InspectorPanel/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Logger" type="TextEdit" parent="HSplitContainer/InspectorPanel/ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
editable = false
|
||||
wrap_mode = 1
|
||||
script = ExtResource("1_8dubc")
|
||||
|
||||
[node name="Reagents" parent="." instance=ExtResource("1_nt7q6")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
|
|
|
|||
|
|
@ -3,3 +3,7 @@ extends Node
|
|||
@warning_ignore_start("unused_signal")
|
||||
|
||||
signal interaction_confirmed(data: Dictionary)
|
||||
signal log_pushed(log_data: String)
|
||||
|
||||
func push(log_data: String):
|
||||
log_pushed.emit(log_data)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ var amount: float = 1.0
|
|||
func _on_interactible_interacted(with: DraggableObject) -> void:
|
||||
if with.is_in_group("flask"):
|
||||
with.get_node("%Inventory").add_inventory(%Inventory.extract(%Inventory.total_amount * amount))
|
||||
GuiSignalBus.push("%s содержимого пробирки перелито" % [str(amount*100)+"%"])
|
||||
|
||||
|
||||
func _on_h_slider_value_changed(value: float) -> void:
|
||||
|
|
|
|||
|
|
@ -9,12 +9,23 @@ func _on_interactible_interacted(with: DraggableObject) -> void:
|
|||
mini_inventory[0].substance = with.get_node("SubstanceData").substance
|
||||
mini_inventory[0].amount = 5
|
||||
mini_inventory[0].temperature = 20
|
||||
GuiSignalBus.push("Ложкой взято 5 мг. %s" % [mini_inventory[0].substance.get_formula()])
|
||||
|
||||
elif with.is_in_group("solid_source") and mini_inventory != []:
|
||||
mini_inventory = []
|
||||
GuiSignalBus.push("Ложка опустошена")
|
||||
elif with.is_in_group("flask") and mini_inventory != []:
|
||||
var log_message = "В пробирку засыпано "
|
||||
for sub in mini_inventory:
|
||||
log_message += "%s мг. %s, " % [str(sub.amount),sub.substance.get_formula()]
|
||||
GuiSignalBus.push(log_message)
|
||||
with.get_node("%Inventory").add_inventory(mini_inventory)
|
||||
mini_inventory = []
|
||||
|
||||
elif with.is_in_group("flask") and mini_inventory == []:
|
||||
mini_inventory = with.get_node("%Inventory").extract_solid(5)
|
||||
var log_message = "Из пробирки изъято "
|
||||
for sub in mini_inventory:
|
||||
log_message += "%s мг. %s, " % [str(sub.amount),sub.substance.get_formula()]
|
||||
GuiSignalBus.push(log_message)
|
||||
inventory_updated.emit(mini_inventory)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ func _on_interaction_interacted(with: DraggableObject) -> void:
|
|||
subs.temperature = 20
|
||||
with.get_node("%Inventory").add_substance(subs)
|
||||
$"../HBoxContainer/SpinBox".value = 0
|
||||
|
||||
GuiSignalBus.push("В пробирку залито %s мг. %s" % [str(subs.amount),subs.substance.get_formula()])
|
||||
|
||||
|
||||
func _on_progress_bar_value_changed(value: float) -> void:
|
||||
|
|
|
|||
|
|
@ -161,3 +161,4 @@ func check_for_reactions() -> void:
|
|||
check_for_reactions()
|
||||
recalculate_temperature()
|
||||
inventory_changed.emit(inventory.values())
|
||||
GuiSignalBus.push("Произошла реакция: " + found_reaction.formula())
|
||||
|
|
|
|||
|
|
@ -13,3 +13,20 @@ func input_substances_dict() -> Dictionary[StringName, ReactionSubstance]:
|
|||
result[el.substance.scientific_name] = el
|
||||
|
||||
return result
|
||||
|
||||
func formula() -> String:
|
||||
var result = ""
|
||||
|
||||
for i in range(len(input_substances)):
|
||||
result += str(input_substances[i].coefficient) + input_substances[i].substance.get_formula()
|
||||
if i != len(input_substances)-1:
|
||||
result += " + "
|
||||
|
||||
result += " = "
|
||||
|
||||
for i in range(len(output_substances)):
|
||||
result += str(output_substances[i].coefficient) + output_substances[i].substance.get_formula()
|
||||
if i != len(output_substances)-1:
|
||||
result += " + "
|
||||
|
||||
return result
|
||||
|
|
|
|||
8
src/ui/logger.gd
Normal file
8
src/ui/logger.gd
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
extends TextEdit
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
GuiSignalBus.log_pushed.connect(on_log_pushed)
|
||||
|
||||
func on_log_pushed(log_data: String):
|
||||
text += "\n" + log_data
|
||||
1
src/ui/logger.gd.uid
Normal file
1
src/ui/logger.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cqdtgvrotvjhb
|
||||
Loading…
Add table
Add a link
Reference in a new issue