extends Control signal back_pressed var current_label: Label var best_label: Label var goal_label: Label var week_row: HBoxContainer func _ready() -> void: var margin := MarginContainer.new() margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) margin.add_theme_constant_override("margin_left", 12) margin.add_theme_constant_override("margin_right", 12) margin.add_theme_constant_override("margin_top", UI.safe_top()) margin.add_theme_constant_override("margin_bottom", UI.safe_bottom()) add_child(margin) var column := VBoxContainer.new() column.add_theme_constant_override("separation", 6) margin.add_child(column) var top := HBoxContainer.new() top.add_theme_constant_override("separation", 6) column.add_child(top) var back := UI.round_button("res://assets/icons/arrow-left.svg", 40) back.pressed.connect(func() -> void: back_pressed.emit()) top.add_child(back) var title := UI.label("Daily Streak", 22) title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER title.size_flags_horizontal = Control.SIZE_EXPAND_FILL top.add_child(title) var scroll := ScrollContainer.new() scroll.size_flags_horizontal = Control.SIZE_EXPAND_FILL scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED column.add_child(scroll) var content := VBoxContainer.new() content.size_flags_horizontal = Control.SIZE_EXPAND_FILL content.add_theme_constant_override("separation", 8) scroll.add_child(content) var emblem := CenterContainer.new() content.add_child(emblem) var star := UI.icon("res://assets/icons/star_gold.svg", 96, Palette.WHITE) emblem.add_child(star) current_label = UI.label("0", 52, Palette.ORANGE, true) content.add_child(current_label) content.add_child(UI.heading("Current Streak", 20, Palette.ORANGE)) var best_panel := UI.panel(Palette.WHITE, 22, 8) best_panel.size_flags_horizontal = Control.SIZE_SHRINK_CENTER best_label = UI.label("Best streak: 0", 12, Palette.MUTED) best_label.autowrap_mode = TextServer.AUTOWRAP_OFF best_label.custom_minimum_size = Vector2(160, 0) best_panel.add_child(best_label) content.add_child(best_panel) goal_label = UI.label("", 12, Palette.INK) content.add_child(goal_label) content.add_child(UI.heading("This week", 18)) week_row = HBoxContainer.new() week_row.add_theme_constant_override("separation", 4) week_row.alignment = BoxContainer.ALIGNMENT_CENTER content.add_child(week_row) var gift := CenterContainer.new() content.add_child(gift) var gift_row := HBoxContainer.new() gift_row.custom_minimum_size = Vector2(150, 0) gift_row.add_theme_constant_override("separation", 6) gift.add_child(gift_row) gift_row.add_child(UI.icon("res://assets/icons/star_gold.svg", 22, Palette.WHITE)) var gift_text := UI.label("7-day gift", 12, Palette.MUTED) gift_text.autowrap_mode = TextServer.AUTOWRAP_OFF gift_text.custom_minimum_size = Vector2(110, 0) gift_row.add_child(gift_text) UI.pass_scroll_input(content) SaveGame.progress_changed.connect(refresh) refresh() func refresh() -> void: var streak := SaveGame.daily_streak() current_label.text = str(streak) best_label.text = "Best streak: %d" % SaveGame.best_streak() goal_label.text = Daily.goal_text(streak) _build_week() func _build_week() -> void: for child in week_row.get_children(): child.queue_free() var keys: Array = Daily.week_keys() var labels: Array = Daily.weekday_labels() var history: Array = SaveGame.daily_history() var today := Daily.today_key() for i in range(7): var key := str(keys[i]) var done := history.has(key) var is_today := key == today var chip := VBoxContainer.new() chip.add_theme_constant_override("separation", 2) chip.add_child(UI.label(str(labels[i]), 9, Palette.MUTED)) var circle := PanelContainer.new() circle.custom_minimum_size = Vector2(42, 42) var style := StyleBoxFlat.new() style.bg_color = Palette.GOLD if done else Palette.PAPER style.corner_radius_top_left = 21 style.corner_radius_top_right = 21 style.corner_radius_bottom_left = 21 style.corner_radius_bottom_right = 21 style.border_width_left = 3 if is_today else 1 style.border_width_right = 3 if is_today else 1 style.border_width_top = 3 if is_today else 1 style.border_width_bottom = 3 if is_today else 1 style.border_color = Palette.ORANGE if is_today else Palette.PAPER_DARK circle.add_theme_stylebox_override("panel", style) if done: var center := CenterContainer.new() circle.add_child(center) center.add_child(UI.icon("res://assets/icons/star_white.svg", 20, Palette.WHITE)) chip.add_child(circle) week_row.add_child(chip) UI.pass_scroll_input(week_row)