55 lines
1.8 KiB
GDScript
55 lines
1.8 KiB
GDScript
extends VBoxContainer
|
|
|
|
const Style := preload("res://scripts/ui/ui_style.gd")
|
|
|
|
var main: Control
|
|
var zone_list: GridContainer
|
|
|
|
func _ready() -> void:
|
|
set_anchors_preset(Control.PRESET_FULL_RECT)
|
|
add_theme_constant_override("separation", 14)
|
|
|
|
var title := Label.new()
|
|
title.text = "Study Map"
|
|
Style.set_label(title, 34, Style.TEXT)
|
|
add_child(title)
|
|
|
|
var help := Label.new()
|
|
help.text = "Choose a system zone. Strong scores unlock momentum badges and level progress."
|
|
help.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
Style.set_label(help, 16, Style.MUTED)
|
|
add_child(help)
|
|
|
|
zone_list = GridContainer.new()
|
|
zone_list.columns = 3
|
|
zone_list.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
|
add_child(zone_list)
|
|
|
|
|
|
func on_show(_payload: Variant = null) -> void:
|
|
for child in zone_list.get_children():
|
|
child.queue_free()
|
|
|
|
var systems: Array[String] = ["All Systems"]
|
|
systems.append_array(QuestionBankService.get_systems())
|
|
var stats: Dictionary = ProfileService.get_profile().get("system_stats", {})
|
|
|
|
for system_name in systems:
|
|
var button := Button.new()
|
|
button.custom_minimum_size = Vector2(260, 110)
|
|
button.text = _zone_text(system_name, stats)
|
|
Style.style_chip(button, Style.CYAN if system_name == "All Systems" else Style.MAGENTA)
|
|
button.pressed.connect(func(zone_name: String = system_name): main.show_screen("setup", zone_name))
|
|
zone_list.add_child(button)
|
|
|
|
|
|
func _zone_text(system_name: String, stats: Dictionary) -> String:
|
|
if system_name == "All Systems" or not stats.has(system_name):
|
|
return "%s\nStart block" % system_name
|
|
var seen := int(stats[system_name].get("seen", 0))
|
|
var correct := int(stats[system_name].get("correct", 0))
|
|
var accuracy := 0
|
|
if seen > 0:
|
|
accuracy = int(round(float(correct) / float(seen) * 100.0))
|
|
return "%s\n%d seen | %d%%" % [system_name, seen, accuracy]
|