Merge pull request 'Main' (#19) from main into production
Reviewed-on: admin/step3#19
This commit is contained in:
+4
-124
@@ -28,10 +28,7 @@ var sidebar_content: VBoxContainer
|
||||
var drawer_backdrop: ColorRect
|
||||
var drawer_open := false
|
||||
var menu_button: Button
|
||||
var account_button: Button
|
||||
var account_chevron_button: Button
|
||||
var credits_badge: PanelContainer
|
||||
var account_menu: PanelContainer
|
||||
var nav_buttons: Dictionary = {}
|
||||
var current_nav_key := "home"
|
||||
var compact_shell := false
|
||||
@@ -56,8 +53,6 @@ func _update_responsive_layout() -> void:
|
||||
_apply_screen_margins(current_screen_name)
|
||||
if feedback_button != null:
|
||||
feedback_button.visible = AuthState.is_logged_in and size.x >= 560.0
|
||||
if account_chevron_button != null:
|
||||
account_chevron_button.visible = size.x >= 480.0
|
||||
if drawer_open and not compact_shell:
|
||||
_close_drawer()
|
||||
if app_menu != null:
|
||||
@@ -69,7 +64,6 @@ func _update_responsive_layout() -> void:
|
||||
|
||||
func show_screen(screen_name: String, payload: Variant = null) -> void:
|
||||
_close_app_menu()
|
||||
_close_account_menu()
|
||||
_close_drawer()
|
||||
for child in screens_host.get_children():
|
||||
if child.visible and child.has_method("on_hide"):
|
||||
@@ -188,26 +182,10 @@ func _build_ui() -> void:
|
||||
header.add_child(theme_button)
|
||||
_refresh_theme_button()
|
||||
|
||||
account_button = Button.new()
|
||||
account_button.tooltip_text = "Open account menu"
|
||||
account_button.custom_minimum_size = Vector2(44, 44)
|
||||
account_button.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
account_button.pressed.connect(_toggle_account_menu)
|
||||
_style_account_avatar(account_button)
|
||||
header.add_child(account_button)
|
||||
|
||||
account_chevron_button = Button.new()
|
||||
account_chevron_button.icon = preload("res://assets/icons/lucide/chevron-down.svg")
|
||||
account_chevron_button.tooltip_text = "Open account menu"
|
||||
account_chevron_button.custom_minimum_size = Vector2(28, 44)
|
||||
account_chevron_button.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
account_chevron_button.add_theme_constant_override("icon_max_width", 17)
|
||||
account_chevron_button.pressed.connect(_toggle_account_menu)
|
||||
_style_account_chevron(account_chevron_button)
|
||||
header.add_child(account_chevron_button)
|
||||
|
||||
credits_badge = CreditsBadge.new()
|
||||
credits_badge.store_requested.connect(func(): show_screen("rz_store"))
|
||||
credits_badge.store_requested.connect(func():
|
||||
if Brand.is_uat_environment():
|
||||
show_screen("rz_store"))
|
||||
header.add_child(credits_badge)
|
||||
|
||||
var screens_container := MarginContainer.new()
|
||||
@@ -375,7 +353,6 @@ func _build_ui() -> void:
|
||||
legal_document_dialog = preload("res://scripts/ui/legal_document_dialog.gd").new()
|
||||
legal_document_dialog.name = "LegalDocumentDialog"
|
||||
add_child(legal_document_dialog)
|
||||
_build_account_menu()
|
||||
_build_drawer()
|
||||
|
||||
AuthState.auth_changed.connect(_on_auth_changed)
|
||||
@@ -439,7 +416,7 @@ func _populate_navigation(container: VBoxContainer, include_brand: bool) -> void
|
||||
container.add_child(HSeparator.new())
|
||||
_add_nav_button(container, "donations", "Support RanaZe", "heart-pulse", true)
|
||||
_add_nav_button(container, "performance", "Profile", "user-round", true)
|
||||
_add_nav_button(container, "rz_store", "RZ Shop", "star", true)
|
||||
_add_nav_button(container, "rz_store", "RZ Shop", "star", true, Brand.is_uat_environment())
|
||||
_add_nav_button(container, "settings", "Settings", "settings", true)
|
||||
_add_nav_button(container, "logout", "Log out", "log-out", true)
|
||||
|
||||
@@ -508,27 +485,6 @@ func _update_header_title(screen_name: String) -> void:
|
||||
header_title.text = str(titles.get(screen_name, ""))
|
||||
|
||||
|
||||
func _build_account_menu() -> void:
|
||||
account_menu = PanelContainer.new()
|
||||
account_menu.visible = false
|
||||
account_menu.top_level = true
|
||||
account_menu.custom_minimum_size = Vector2(230, 230)
|
||||
account_menu.add_theme_stylebox_override("panel", Brand.panel_box(UIThemeService.is_dark_mode()))
|
||||
add_child(account_menu)
|
||||
var content := VBoxContainer.new()
|
||||
content.add_theme_constant_override("separation", 8)
|
||||
account_menu.add_child(content)
|
||||
for spec in [["Profile", "user-round", "performance"], ["Settings", "settings", "settings"], ["Log out", "log-out", "logout"]]:
|
||||
var button := Button.new()
|
||||
button.text = spec[0]
|
||||
button.icon = load("res://assets/icons/lucide/%s.svg" % spec[1])
|
||||
button.add_theme_constant_override("icon_max_width", 22)
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
button.custom_minimum_size = Vector2(0, 46)
|
||||
button.pressed.connect(_on_navigation_pressed.bind(spec[2]))
|
||||
content.add_child(button)
|
||||
|
||||
|
||||
func _build_drawer() -> void:
|
||||
drawer_backdrop = ColorRect.new()
|
||||
drawer_backdrop.visible = false
|
||||
@@ -570,25 +526,6 @@ func _on_drawer_backdrop_input(event: InputEvent) -> void:
|
||||
_close_drawer()
|
||||
|
||||
|
||||
func _toggle_account_menu() -> void:
|
||||
if account_menu == null:
|
||||
return
|
||||
if account_menu.visible:
|
||||
_close_account_menu()
|
||||
return
|
||||
account_menu.visible = true
|
||||
account_menu.size = account_menu.custom_minimum_size
|
||||
account_menu.position = Vector2(
|
||||
get_viewport_rect().size.x - account_menu.size.x - 24,
|
||||
82
|
||||
)
|
||||
|
||||
|
||||
func _close_account_menu() -> void:
|
||||
if account_menu != null:
|
||||
account_menu.visible = false
|
||||
|
||||
|
||||
func _screen_uses_shell(screen_name: String) -> bool:
|
||||
return AuthState.is_logged_in and screen_name not in ["login", "legal_consent", "player", "ccs_player"]
|
||||
|
||||
@@ -680,32 +617,6 @@ func _style_header_feedback_button(button: Button) -> void:
|
||||
button.add_theme_color_override("icon_hover_color", Brand.SKY_BLUE)
|
||||
|
||||
|
||||
func _style_account_avatar(button: Button) -> void:
|
||||
var dark := UIThemeService.is_dark_mode()
|
||||
var normal := StyleBoxFlat.new()
|
||||
normal.bg_color = Color("26324f") if dark else Color("dce5f5")
|
||||
normal.corner_radius_top_left = 22
|
||||
normal.corner_radius_top_right = 22
|
||||
normal.corner_radius_bottom_left = 22
|
||||
normal.corner_radius_bottom_right = 22
|
||||
var hover := normal.duplicate() as StyleBoxFlat
|
||||
hover.bg_color = Color("344465") if dark else Color("cad7ed")
|
||||
button.add_theme_stylebox_override("normal", normal)
|
||||
button.add_theme_stylebox_override("hover", hover)
|
||||
button.add_theme_stylebox_override("pressed", hover)
|
||||
button.add_theme_color_override("font_color", Color("f8fafc") if dark else Color("172033"))
|
||||
button.add_theme_color_override("font_hover_color", Color("ffffff") if dark else Color("0f172a"))
|
||||
|
||||
|
||||
func _style_account_chevron(button: Button) -> void:
|
||||
var empty := StyleBoxEmpty.new()
|
||||
button.add_theme_stylebox_override("normal", empty)
|
||||
button.add_theme_stylebox_override("hover", empty)
|
||||
button.add_theme_stylebox_override("pressed", empty)
|
||||
button.add_theme_color_override("icon_normal_color", Style.MUTED)
|
||||
button.add_theme_color_override("icon_hover_color", Style.TEXT)
|
||||
|
||||
|
||||
func _style_shell_theme_button(button: Button) -> void:
|
||||
var dark := UIThemeService.is_dark_mode()
|
||||
var normal := StyleBoxFlat.new()
|
||||
@@ -737,36 +648,18 @@ func _input(event: InputEvent) -> void:
|
||||
_close_drawer()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if account_menu != null and account_menu.visible:
|
||||
_close_account_menu()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if current_screen_name in ["player", "ccs_player", "flashcards_study"]:
|
||||
_toggle_app_menu()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _refresh_header_controls() -> void:
|
||||
if account_button != null:
|
||||
account_button.text = _account_initials(AuthState.username)
|
||||
if feedback_button != null:
|
||||
feedback_button.visible = AuthState.is_logged_in and size.x >= 560.0
|
||||
feedback_button.icon = preload("res://assets/icons/lucide/message-square.svg")
|
||||
feedback_button.add_theme_constant_override("icon_max_width", 21)
|
||||
|
||||
|
||||
func _account_initials(username: String) -> String:
|
||||
var cleaned := ""
|
||||
for character in username:
|
||||
if character.to_lower() != character.to_upper():
|
||||
cleaned += character
|
||||
elif character.is_valid_int():
|
||||
cleaned += character
|
||||
if cleaned.length() >= 2:
|
||||
break
|
||||
return cleaned.to_upper() if not cleaned.is_empty() else "ME"
|
||||
|
||||
|
||||
func open_feedback_dialog() -> void:
|
||||
if not AuthState.is_logged_in or feedback_dialog == null:
|
||||
return
|
||||
@@ -804,14 +697,8 @@ func _on_theme_changed(is_dark_mode: bool) -> void:
|
||||
if app_background != null:
|
||||
app_background.color = Brand.background_color(is_dark_mode)
|
||||
app_background.material = Brand.background_material(is_dark_mode)
|
||||
if account_menu != null:
|
||||
account_menu.add_theme_stylebox_override("panel", Brand.panel_box(is_dark_mode))
|
||||
if feedback_button != null:
|
||||
_style_header_feedback_button(feedback_button)
|
||||
if account_button != null:
|
||||
_style_account_avatar(account_button)
|
||||
if account_chevron_button != null:
|
||||
_style_account_chevron(account_chevron_button)
|
||||
if credits_badge != null:
|
||||
credits_badge.refresh_theme_controls()
|
||||
if sidebar != null:
|
||||
@@ -969,15 +856,8 @@ func exit_current_run() -> void:
|
||||
if current_screen_name == "flashcards_study":
|
||||
show_screen("flashcards_hub")
|
||||
return
|
||||
var was_core_run := BlockSessionService.session_kind == "core"
|
||||
var was_review_run := BlockSessionService.session_kind == "review"
|
||||
var was_dynamic_run := BlockSessionService.session_kind == "dynamic"
|
||||
if BlockSessionService.block_started and BlockSessionService.session_kind != "simulation":
|
||||
BlockSessionService.finish_block()
|
||||
elif BlockSessionService.session_kind == "simulation":
|
||||
BlockSessionService.block_started = false
|
||||
if was_review_run or was_dynamic_run:
|
||||
DashboardService.refresh()
|
||||
show_screen("dashboard")
|
||||
else:
|
||||
show_screen("selection", "exam" if was_core_run else "step3")
|
||||
|
||||
Reference in New Issue
Block a user