lab menu
This commit is contained in:
parent
309bbcac5e
commit
c7788ed121
8 changed files with 100 additions and 32 deletions
|
|
@ -1,7 +1,11 @@
|
|||
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 anwsers: Array[int]
|
||||
var correctness: Array[bool]
|
||||
|
||||
func save():
|
||||
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_line("")
|
||||
for i in range(len(current_lab.tests)):
|
||||
if len(anwsers) <= i:
|
||||
if len(correctness) <= i:
|
||||
file.store_string("-".lpad(10))
|
||||
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_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)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
extends TabBar
|
||||
|
||||
func _ready() -> void:
|
||||
$ConfirmationDialog.confirmed.connect(LabRuntime.save)
|
||||
$ConfirmationDialog.confirmed.connect(LabRuntime.end_lab)
|
||||
|
||||
func _on_tab_clicked(tab: int) -> void:
|
||||
match tab:
|
||||
|
|
@ -8,6 +11,6 @@ func _on_tab_clicked(tab: int) -> void:
|
|||
1:
|
||||
$Questions.visible = true
|
||||
2:
|
||||
LabRuntime.save()
|
||||
$ConfirmationDialog.popup_centered()
|
||||
3:
|
||||
GuiSignalBus.clear_table.emit()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ func _ready() -> void:
|
|||
button.text = options[i]
|
||||
vbox.add_child(button)
|
||||
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)
|
||||
next()
|
||||
|
||||
|
|
@ -32,5 +32,7 @@ func next() -> void:
|
|||
else:
|
||||
get_parent().visible = false
|
||||
|
||||
func anwser(option: int):
|
||||
LabRuntime.anwsers.append(option)
|
||||
func anwser(option_number: int,correctness: bool):
|
||||
LabRuntime.anwsers.append(option_number)
|
||||
LabRuntime.correctness.append(correctness)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue