Require API question loading

This commit is contained in:
hz
2026-07-09 21:35:54 -05:00
parent 930c35f181
commit 474c704aa9
4 changed files with 69 additions and 199 deletions
+18 -6
View File
@@ -7,6 +7,8 @@ var selected_system := "All Systems"
var system_label: Label
var size_spin: SpinBox
var mode_option: OptionButton
var status_label: Label
var start_button: Button
func _ready() -> void:
set_anchors_preset(Control.PRESET_FULL_RECT)
@@ -49,12 +51,17 @@ func _ready() -> void:
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)
status_label = Label.new()
status_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
Style.set_label(status_label, 16, Style.RED)
add_child(status_label)
start_button = Button.new()
start_button.text = "Launch Block"
start_button.custom_minimum_size = Vector2(220, 54)
Style.style_primary_button(start_button)
start_button.pressed.connect(_start_block)
add_child(start_button)
func on_show(payload: Variant = null) -> void:
@@ -63,8 +70,13 @@ func on_show(payload: Variant = null) -> void:
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)
start_button.disabled = available == 0
status_label.text = QuestionBankService.last_error if available == 0 else ""
func _start_block() -> void:
if not QuestionBankService.has_questions():
status_label.text = "Questions have not loaded from the API yet."
return
BlockSessionService.start_block(selected_system, int(size_spin.value), mode_option.get_item_text(mode_option.selected))
main.show_screen("player")