Initial STEP 3 study game and questions API
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
extends VBoxContainer
|
||||
|
||||
const Style := preload("res://scripts/ui/ui_style.gd")
|
||||
|
||||
var main: Control
|
||||
var selected_system := "All Systems"
|
||||
var system_label: Label
|
||||
var size_spin: SpinBox
|
||||
var mode_option: OptionButton
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
add_theme_constant_override("separation", 16)
|
||||
|
||||
var title := Label.new()
|
||||
title.text = "Block Setup"
|
||||
Style.set_label(title, 34, Style.TEXT)
|
||||
add_child(title)
|
||||
|
||||
system_label = Label.new()
|
||||
Style.set_label(system_label, 22, Style.CYAN)
|
||||
add_child(system_label)
|
||||
|
||||
var size_row := HBoxContainer.new()
|
||||
size_row.add_child(Label.new())
|
||||
size_row.get_child(0).text = "Question count"
|
||||
size_spin = SpinBox.new()
|
||||
size_spin.min_value = 1
|
||||
size_spin.max_value = 40
|
||||
size_spin.value = 6
|
||||
size_spin.custom_minimum_size = Vector2(110, 44)
|
||||
size_row.add_child(size_spin)
|
||||
add_child(size_row)
|
||||
|
||||
var mode_row := HBoxContainer.new()
|
||||
var mode_label := Label.new()
|
||||
mode_label.text = "Mode"
|
||||
mode_row.add_child(mode_label)
|
||||
mode_option = OptionButton.new()
|
||||
mode_option.add_item("Tutor")
|
||||
mode_option.add_item("Timed")
|
||||
mode_option.custom_minimum_size = Vector2(180, 44)
|
||||
mode_row.add_child(mode_option)
|
||||
add_child(mode_row)
|
||||
|
||||
var note := Label.new()
|
||||
note.text = "Tutor mode shows explanations after each answer. Timed mode scores the block at the end."
|
||||
note.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
Style.set_label(note, 16, Style.MUTED)
|
||||
add_child(note)
|
||||
|
||||
var start := Button.new()
|
||||
start.text = "Launch Block"
|
||||
start.custom_minimum_size = Vector2(220, 54)
|
||||
Style.style_primary_button(start)
|
||||
start.pressed.connect(_start_block)
|
||||
add_child(start)
|
||||
|
||||
|
||||
func on_show(payload: Variant = null) -> void:
|
||||
selected_system = str(payload) if payload != null else "All Systems"
|
||||
system_label.text = "Zone: %s" % selected_system
|
||||
var available := QuestionBankService.get_questions_for_system(selected_system).size()
|
||||
size_spin.max_value = max(1, available)
|
||||
size_spin.value = min(size_spin.value, available)
|
||||
|
||||
|
||||
func _start_block() -> void:
|
||||
BlockSessionService.start_block(selected_system, int(size_spin.value), mode_option.get_item_text(mode_option.selected))
|
||||
main.show_screen("player")
|
||||
Reference in New Issue
Block a user