This commit is contained in:
rendo 2026-02-18 11:02:22 +05:00
commit c7788ed121
8 changed files with 100 additions and 32 deletions

View file

@ -1,5 +1,7 @@
[gd_scene format=3 uid="uid://c2ciwyjf7au6l"] [gd_scene format=3 uid="uid://c2ciwyjf7au6l"]
[ext_resource type="Script" uid="uid://cbytg16bl0hsc" path="res://ui/lab_menu.gd" id="1_sjdrh"]
[node name="LabMenu" type="Control" unique_id=198999369] [node name="LabMenu" type="Control" unique_id=198999369]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
@ -7,3 +9,25 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="Panel" type="Panel" parent="." unique_id=978863524]
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="Panel" unique_id=1649245052]
layout_mode = 1
anchors_preset = 13
anchor_left = 0.5
anchor_right = 0.5
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_sjdrh")
[node name="Label" type="Label" parent="Panel/VBoxContainer" unique_id=1904569453]
layout_mode = 2
text = "Выберите лабораторную работу"

View file

@ -3,10 +3,8 @@
[ext_resource type="Script" uid="uid://cqdtgvrotvjhb" path="res://src/ui/logger.gd" id="1_8dubc"] [ext_resource type="Script" uid="uid://cqdtgvrotvjhb" path="res://src/ui/logger.gd" id="1_8dubc"]
[ext_resource type="Script" uid="uid://457xdl1tsmde" path="res://src/ui/control_buttons_holder.gd" id="1_ktti3"] [ext_resource type="Script" uid="uid://457xdl1tsmde" path="res://src/ui/control_buttons_holder.gd" id="1_ktti3"]
[ext_resource type="PackedScene" uid="uid://bcj0mesdlfsfj" path="res://scenes/popup_container.tscn" id="1_nt7q6"] [ext_resource type="PackedScene" uid="uid://bcj0mesdlfsfj" path="res://scenes/popup_container.tscn" id="1_nt7q6"]
[ext_resource type="Script" uid="uid://14snb0pu3b1t" path="res://src/ui/lab_tabs.gd" id="1_p7vwb"] [ext_resource type="PackedScene" uid="uid://dfn58nti8uxf0" path="res://ui/tab_bar.tscn" id="1_p7vwb"]
[ext_resource type="PackedScene" uid="uid://opfal5aq2p5e" path="res://scenes/worktabs.tscn" id="2_p7vwb"]
[ext_resource type="Script" uid="uid://c5pv2idedy1oy" path="res://src/ui/reagents_gen.gd" id="2_x4jx1"] [ext_resource type="Script" uid="uid://c5pv2idedy1oy" path="res://src/ui/reagents_gen.gd" id="2_x4jx1"]
[ext_resource type="PackedScene" uid="uid://be746nxgkc5ay" path="res://scenes/questions.tscn" id="3_ktti3"]
[ext_resource type="Script" uid="uid://cfl3n0ihnpd2v" path="res://scenes/tool_generator.gd" id="11_vdcm2"] [ext_resource type="Script" uid="uid://cfl3n0ihnpd2v" path="res://scenes/tool_generator.gd" id="11_vdcm2"]
[node name="UserInterface" type="Control" unique_id=1780432093] [node name="UserInterface" type="Control" unique_id=1780432093]
@ -27,28 +25,8 @@ anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="TabBar" type="TabBar" parent="HSplitContainer" unique_id=723713577] [node name="TabBar" parent="HSplitContainer" unique_id=877427232 instance=ExtResource("1_p7vwb")]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 0
size_flags_stretch_ratio = 4.0
deselect_enabled = true
tab_count = 4
tab_0/title = "Ход работы"
tab_1/title = "Вопросы для самопроверки"
tab_2/title = "Отчёт"
tab_3/title = "Очистить"
script = ExtResource("1_p7vwb")
[node name="Worktabs" parent="HSplitContainer/TabBar" unique_id=468314618 instance=ExtResource("2_p7vwb")]
visible = false
top_level = true
layout_mode = 1
[node name="Questions" parent="HSplitContainer/TabBar" unique_id=2060279649 instance=ExtResource("3_ktti3")]
visible = false
top_level = true
layout_mode = 1
[node name="InspectorPanel" type="PanelContainer" parent="HSplitContainer" unique_id=918152974] [node name="InspectorPanel" type="PanelContainer" parent="HSplitContainer" unique_id=918152974]
layout_mode = 2 layout_mode = 2
@ -123,7 +101,5 @@ offset_bottom = 49.03595
[node name="Generator" type="Node" parent="Intruments" unique_id=1693437228] [node name="Generator" type="Node" parent="Intruments" unique_id=1693437228]
script = ExtResource("11_vdcm2") script = ExtResource("11_vdcm2")
[connection signal="tab_clicked" from="HSplitContainer/TabBar" to="HSplitContainer/TabBar" method="_on_tab_clicked"]
[editable path="Reagents"] [editable path="Reagents"]
[editable path="Intruments"] [editable path="Intruments"]

View file

@ -1,7 +1,11 @@
extends Node extends Node
const LAB_PREFAB: PackedScene = preload("uid://c7r4rhgj3ucao")
const MENU_PREFAB: PackedScene = preload("uid://c7r4rhgj3ucao")
var current_lab: Labwork = preload("res://labs/lab-electrolyte.tres") var current_lab: Labwork = preload("res://labs/lab-electrolyte.tres")
var anwsers: Array[int] var anwsers: Array[int]
var correctness: Array[bool]
func save(): func save():
var path: String = OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP) + "/" + current_lab.lab_name + "-" + Time.get_datetime_string_from_system() + ".txt" var path: String = OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP) + "/" + current_lab.lab_name + "-" + Time.get_datetime_string_from_system() + ".txt"
@ -17,10 +21,18 @@ func save():
file.store_string(str(anwsers[i]).lpad(10)) file.store_string(str(anwsers[i]).lpad(10))
file.store_line("") file.store_line("")
for i in range(len(current_lab.tests)): for i in range(len(current_lab.tests)):
if len(anwsers) <= i: if len(correctness) <= i:
file.store_string("-".lpad(10)) file.store_string("-".lpad(10))
else: else:
file.store_string(("+" if anwsers[i] == current_lab.tests[i].correct_anwser else "-").lpad(10)) file.store_string(("+" if correctness[i] else "-").lpad(10))
file.store_line("") file.store_line("")
file.store_line("Ход работы:") file.store_line("Ход работы:")
file.store_string(LabLogger.instance.text) file.store_string(LabLogger.instance.text)
func start_lab(lab: Labwork):
current_lab = lab
anwsers.clear()
get_tree().change_scene_to_packed(LAB_PREFAB)
func end_lab():
get_tree().change_scene_to_packed(MENU_PREFAB)

View file

@ -1,5 +1,8 @@
extends TabBar extends TabBar
func _ready() -> void:
$ConfirmationDialog.confirmed.connect(LabRuntime.save)
$ConfirmationDialog.confirmed.connect(LabRuntime.end_lab)
func _on_tab_clicked(tab: int) -> void: func _on_tab_clicked(tab: int) -> void:
match tab: match tab:
@ -8,6 +11,6 @@ func _on_tab_clicked(tab: int) -> void:
1: 1:
$Questions.visible = true $Questions.visible = true
2: 2:
LabRuntime.save() $ConfirmationDialog.popup_centered()
3: 3:
GuiSignalBus.clear_table.emit() GuiSignalBus.clear_table.emit()

View file

@ -16,7 +16,7 @@ func _ready() -> void:
button.text = options[i] button.text = options[i]
vbox.add_child(button) vbox.add_child(button)
button.pressed.connect(next) button.pressed.connect(next)
button.pressed.connect(anwser.bind(i)) button.pressed.connect(anwser.bind(i,question.options.find(options[i]) == question.correct_anwser))
add_child(vbox) add_child(vbox)
next() next()
@ -32,5 +32,7 @@ func next() -> void:
else: else:
get_parent().visible = false get_parent().visible = false
func anwser(option: int): func anwser(option_number: int,correctness: bool):
LabRuntime.anwsers.append(option) LabRuntime.anwsers.append(option_number)
LabRuntime.correctness.append(correctness)

14
ui/lab_menu.gd Normal file
View file

@ -0,0 +1,14 @@
extends Node
const LAB_DIR = "res://labs/"
func _ready() -> void:
for lab_file in ResourceLoader.list_directory(LAB_DIR):
if lab_file.ends_with("/"):
continue
var lab: Labwork = load(LAB_DIR + lab_file)
var button: Button = Button.new()
button.pressed.connect(LabRuntime.start_lab.bind(lab))
add_child(button)
button.text = lab.lab_name

1
ui/lab_menu.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://cbytg16bl0hsc

36
ui/tab_bar.tscn Normal file
View file

@ -0,0 +1,36 @@
[gd_scene format=3 uid="uid://dfn58nti8uxf0"]
[ext_resource type="Script" uid="uid://14snb0pu3b1t" path="res://src/ui/lab_tabs.gd" id="1_ieq68"]
[ext_resource type="PackedScene" uid="uid://opfal5aq2p5e" path="res://scenes/worktabs.tscn" id="2_hyo0h"]
[ext_resource type="PackedScene" uid="uid://be746nxgkc5ay" path="res://scenes/questions.tscn" id="3_lhsfi"]
[node name="TabBar" type="TabBar" unique_id=877427232]
size_flags_horizontal = 3
size_flags_vertical = 0
size_flags_stretch_ratio = 4.0
deselect_enabled = true
tab_count = 4
tab_0/title = "Ход работы"
tab_1/title = "Вопросы для самопроверки"
tab_2/title = "Отчёт"
tab_3/title = "Очистить"
script = ExtResource("1_ieq68")
[node name="Worktabs" parent="." unique_id=666307058 instance=ExtResource("2_hyo0h")]
visible = false
top_level = true
layout_mode = 1
[node name="Questions" parent="." unique_id=2060279649 instance=ExtResource("3_lhsfi")]
visible = false
top_level = true
layout_mode = 1
[node name="ConfirmationDialog" type="ConfirmationDialog" parent="." unique_id=2026035561]
oversampling_override = 1.0
size = Vector2i(1008, 100)
ok_button_text = "Составить отчёт"
dialog_text = "Вы уверены, что хотите закончить лабораторную работу и составить отчёт? Отчёт будет отправлен на ваш рабочий стол"
cancel_button_text = "Отменить"
[connection signal="tab_clicked" from="." to="." method="_on_tab_clicked"]