İlk commit: Stepstead Godot istemci (4.6 Mobile)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
commit
6a1706051d
346 changed files with 14415 additions and 0 deletions
113
scripts/daily_panel.gd
Normal file
113
scripts/daily_panel.gd
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
extends PanelContainer
|
||||
## Günlük hedef + streak paneli — kod ile kurulur, hud.gd ekler. Node adı "DailyPanel".
|
||||
|
||||
var _title: Label
|
||||
var _progress: ProgressBar
|
||||
var _progress_lbl: Label
|
||||
var _streak_lbl: Label
|
||||
var _claim_btn: Button
|
||||
var _result_lbl: Label
|
||||
|
||||
func _ready() -> void:
|
||||
name = "DailyPanel"
|
||||
visible = false
|
||||
_build_ui()
|
||||
|
||||
func _build_ui() -> void:
|
||||
set_anchors_preset(Control.PRESET_CENTER_TOP)
|
||||
offset_top = 90
|
||||
offset_left = -170
|
||||
offset_right = 170
|
||||
var sb := StyleBoxFlat.new()
|
||||
sb.bg_color = Color(0.10, 0.12, 0.10, 0.97)
|
||||
sb.border_color = Color(0.75, 0.62, 0.35)
|
||||
sb.set_border_width_all(1)
|
||||
sb.set_corner_radius_all(10)
|
||||
sb.set_content_margin_all(14)
|
||||
add_theme_stylebox_override("panel", sb)
|
||||
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 8)
|
||||
add_child(vbox)
|
||||
|
||||
var top := HBoxContainer.new()
|
||||
_title = Label.new()
|
||||
_title.text = "🎁 Günlük Hedef"
|
||||
_title.add_theme_font_size_override("font_size", 17)
|
||||
_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)
|
||||
|
||||
_progress = ProgressBar.new()
|
||||
_progress.custom_minimum_size = Vector2(0, 22)
|
||||
_progress.show_percentage = false
|
||||
vbox.add_child(_progress)
|
||||
|
||||
_progress_lbl = Label.new()
|
||||
_progress_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_progress_lbl.add_theme_font_size_override("font_size", 13)
|
||||
vbox.add_child(_progress_lbl)
|
||||
|
||||
_streak_lbl = Label.new()
|
||||
_streak_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_streak_lbl.add_theme_font_size_override("font_size", 13)
|
||||
_streak_lbl.add_theme_color_override("font_color", Color(0.9, 0.78, 0.5))
|
||||
vbox.add_child(_streak_lbl)
|
||||
|
||||
_claim_btn = Button.new()
|
||||
_claim_btn.text = "Ödülü Al"
|
||||
_claim_btn.pressed.connect(_on_claim)
|
||||
vbox.add_child(_claim_btn)
|
||||
|
||||
_result_lbl = Label.new()
|
||||
_result_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_result_lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
_result_lbl.add_theme_font_size_override("font_size", 13)
|
||||
_result_lbl.visible = false
|
||||
vbox.add_child(_result_lbl)
|
||||
|
||||
func open() -> void:
|
||||
visible = true
|
||||
_result_lbl.visible = false
|
||||
await refresh()
|
||||
|
||||
func refresh() -> void:
|
||||
var res: Dictionary = await GameState.daily_status()
|
||||
if not res.ok or not (res.body is Dictionary):
|
||||
_progress_lbl.text = "Yüklenemedi"
|
||||
_claim_btn.disabled = true
|
||||
return
|
||||
var d: Dictionary = res.body
|
||||
var goal := int(d.get("goal", 1))
|
||||
var today := int(d.get("today_steps", 0))
|
||||
_progress.max_value = goal
|
||||
_progress.value = mini(today, goal)
|
||||
_progress_lbl.text = "👣 %d / %d" % [today, goal]
|
||||
_streak_lbl.text = "🔥 Streak: %d gün • Ödül: +%d👣 +%d🪙" % [
|
||||
int(d.get("streak_days", 0)), int(d.get("bonus_steps", 0)), int(d.get("bonus_gold", 0))]
|
||||
if bool(d.get("claimed_today", false)):
|
||||
_claim_btn.text = "✅ Bugün alındı"
|
||||
_claim_btn.disabled = true
|
||||
elif bool(d.get("claimable", false)):
|
||||
_claim_btn.text = "🎁 Ödülü Al"
|
||||
_claim_btn.disabled = false
|
||||
else:
|
||||
_claim_btn.text = "Hedefe %d adım kaldı" % maxi(0, goal - today)
|
||||
_claim_btn.disabled = true
|
||||
|
||||
func _on_claim() -> void:
|
||||
_claim_btn.disabled = true
|
||||
var res: Dictionary = await GameState.daily_claim()
|
||||
if res.ok and res.body is Dictionary:
|
||||
var b: Dictionary = res.body
|
||||
_result_lbl.text = "🎉 +%d👣 +%d🪙 — %d günlük streak!" % [
|
||||
int(b.get("bonus_steps", 0)), int(b.get("bonus_gold", 0)), int(b.get("streak_days", 0))]
|
||||
_result_lbl.visible = true
|
||||
elif res.body is Dictionary and res.body.has("detail"):
|
||||
_result_lbl.text = "⚠ " + str(res.body["detail"])
|
||||
_result_lbl.visible = true
|
||||
await refresh()
|
||||
Loading…
Add table
Add a link
Reference in a new issue