119 lines
3.7 KiB
GDScript
119 lines
3.7 KiB
GDScript
extends PanelContainer
|
||
## Ayarlar paneli — ses/müzik/bildirim toggle, hesap bilgisi, çıkış, sürüm.
|
||
## Kod ile kurulur. Node adı "SettingsPanel". Alt-sheet (skills_panel deseni).
|
||
|
||
const PANEL_HEIGHT := 520.0
|
||
|
||
signal logout_requested
|
||
|
||
var _sound_chk: CheckButton
|
||
var _music_chk: CheckButton
|
||
var _notif_chk: CheckButton
|
||
var _email_lbl: Label
|
||
|
||
func _ready() -> void:
|
||
name = "SettingsPanel"
|
||
visible = false
|
||
_build_ui()
|
||
|
||
func _build_ui() -> void:
|
||
set_anchors_preset(Control.PRESET_BOTTOM_WIDE)
|
||
offset_top = -PANEL_HEIGHT
|
||
offset_left = 8
|
||
offset_right = -8
|
||
offset_bottom = -8
|
||
var sb := StyleBoxFlat.new()
|
||
sb.bg_color = Color(0.10, 0.10, 0.13, 0.97)
|
||
sb.set_corner_radius_all(10)
|
||
add_theme_stylebox_override("panel", sb)
|
||
|
||
var margin := MarginContainer.new()
|
||
margin.add_theme_constant_override("margin_left", 16)
|
||
margin.add_theme_constant_override("margin_right", 16)
|
||
margin.add_theme_constant_override("margin_top", 12)
|
||
margin.add_theme_constant_override("margin_bottom", 12)
|
||
add_child(margin)
|
||
|
||
var vbox := VBoxContainer.new()
|
||
vbox.add_theme_constant_override("separation", 10)
|
||
margin.add_child(vbox)
|
||
|
||
var top := HBoxContainer.new()
|
||
var title := Label.new()
|
||
title.text = "⚙ Ayarlar"
|
||
title.add_theme_font_size_override("font_size", 18)
|
||
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
top.add_child(title)
|
||
var close_btn := Button.new()
|
||
close_btn.text = "✕"
|
||
close_btn.pressed.connect(func() -> void: visible = false)
|
||
top.add_child(close_btn)
|
||
vbox.add_child(top)
|
||
|
||
vbox.add_child(_section("🔊 Ses"))
|
||
_sound_chk = _toggle_row(vbox, "Ses efektleri", Config.sound_on, func(v: bool) -> void:
|
||
Config.sound_on = v
|
||
Config.save_settings())
|
||
_music_chk = _toggle_row(vbox, "Müzik", Config.music_on, func(v: bool) -> void:
|
||
Config.music_on = v
|
||
Config.save_settings())
|
||
|
||
vbox.add_child(_section("🔔 Bildirim"))
|
||
_notif_chk = _toggle_row(vbox, "Bildirimlere izin ver", Config.notif_on, func(v: bool) -> void:
|
||
Config.notif_on = v
|
||
Config.save_settings())
|
||
|
||
vbox.add_child(_section("👤 Hesap"))
|
||
_email_lbl = Label.new()
|
||
_email_lbl.add_theme_color_override("font_color", Color(0.75, 0.8, 0.88))
|
||
vbox.add_child(_email_lbl)
|
||
|
||
var spacer := Control.new()
|
||
spacer.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||
vbox.add_child(spacer)
|
||
|
||
var logout_btn := Button.new()
|
||
logout_btn.text = "🚪 Çıkış Yap"
|
||
var lb_sb := StyleBoxFlat.new()
|
||
lb_sb.bg_color = Color(0.55, 0.18, 0.16)
|
||
lb_sb.set_corner_radius_all(6)
|
||
logout_btn.add_theme_stylebox_override("normal", lb_sb)
|
||
logout_btn.pressed.connect(func() -> void:
|
||
visible = false
|
||
logout_requested.emit())
|
||
vbox.add_child(logout_btn)
|
||
|
||
var ver := Label.new()
|
||
ver.text = "Stepstead • sürüm %s" % Config.VERSION
|
||
ver.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||
ver.add_theme_font_size_override("font_size", 11)
|
||
ver.add_theme_color_override("font_color", Color(1, 1, 1, 0.4))
|
||
vbox.add_child(ver)
|
||
|
||
func _section(txt: String) -> Label:
|
||
var l := Label.new()
|
||
l.text = txt
|
||
l.add_theme_font_size_override("font_size", 14)
|
||
l.add_theme_color_override("font_color", Color(0.9, 0.78, 0.5))
|
||
return l
|
||
|
||
func _toggle_row(parent: VBoxContainer, label: String, value: bool, cb: Callable) -> CheckButton:
|
||
var row := HBoxContainer.new()
|
||
var lbl := Label.new()
|
||
lbl.text = label
|
||
lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
row.add_child(lbl)
|
||
var chk := CheckButton.new()
|
||
chk.button_pressed = value
|
||
chk.toggled.connect(cb)
|
||
row.add_child(chk)
|
||
parent.add_child(row)
|
||
return chk
|
||
|
||
func open() -> void:
|
||
visible = true
|
||
_sound_chk.button_pressed = Config.sound_on
|
||
_music_chk.button_pressed = Config.music_on
|
||
_notif_chk.button_pressed = Config.notif_on
|
||
var email := str(Auth.user.get("email", ""))
|
||
_email_lbl.text = "E-posta: %s" % (email if email != "" else "—")
|