Require API question loading
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -8,6 +8,8 @@ var zone_list: GridContainer
|
||||
func _ready() -> void:
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
add_theme_constant_override("separation", 14)
|
||||
if not QuestionBankService.questions_changed.is_connected(_refresh_zones):
|
||||
QuestionBankService.questions_changed.connect(_refresh_zones)
|
||||
|
||||
var title := Label.new()
|
||||
title.text = "Study Map"
|
||||
@@ -27,9 +29,31 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func on_show(_payload: Variant = null) -> void:
|
||||
_refresh_zones()
|
||||
|
||||
|
||||
func _refresh_zones() -> void:
|
||||
if zone_list == null:
|
||||
return
|
||||
|
||||
for child in zone_list.get_children():
|
||||
child.queue_free()
|
||||
|
||||
if QuestionBankService.is_loading:
|
||||
var loading := Label.new()
|
||||
loading.text = "Loading question bank..."
|
||||
Style.set_label(loading, 20, Style.AMBER)
|
||||
zone_list.add_child(loading)
|
||||
return
|
||||
|
||||
if not QuestionBankService.has_questions():
|
||||
var empty := Label.new()
|
||||
empty.text = QuestionBankService.last_error if QuestionBankService.last_error != "" else "No API questions loaded."
|
||||
empty.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
Style.set_label(empty, 20, Style.RED)
|
||||
zone_list.add_child(empty)
|
||||
return
|
||||
|
||||
var systems: Array[String] = ["All Systems"]
|
||||
systems.append_array(QuestionBankService.get_systems())
|
||||
var stats: Dictionary = ProfileService.get_profile().get("system_stats", {})
|
||||
|
||||
Reference in New Issue
Block a user