64 lines
2.7 KiB
GDScript
64 lines
2.7 KiB
GDScript
class_name MenuScreen
|
|
extends Control
|
|
## Hauptmenü: links Titel und Spielarten, rechts drei Karten der eigenen Sammlung als Schaufenster.
|
|
|
|
var app
|
|
var coins_label: Label
|
|
var coll_label: Label
|
|
var notice_label: Label
|
|
|
|
|
|
func _ready() -> void:
|
|
var p: Profile = app.profile
|
|
Style.label(self, "Dinger", 76, Style.GOLD, Rect2(80, 64, 600, 90), "left", true)
|
|
Style.label(self, "Ein Kartenspiel: Duell um das Feld", 22, Style.MUTED, Rect2(84, 156, 600, 30), "left")
|
|
coins_label = Style.chip(self, "", Rect2(930, 20, 310, 38))
|
|
coll_label = Style.label(self, "", 15, Style.MUTED, Rect2(700, 64, 540, 24), "right")
|
|
var y := 230
|
|
for entry in [["Einzelspieler", func(): app.show_screen(OpponentSelectScreen.new())],
|
|
["Kampagne", func(): app.show_screen(CampaignScreen.new())],
|
|
["Netzwerkspiel", func(): app.show_screen(LobbyScreen.new())]]:
|
|
var b := Style.button(self, entry[0], Rect2(80, y, 380, 62), entry[1], Style.PRIMARY)
|
|
b.add_theme_font_size_override("font_size", 24)
|
|
y += 74
|
|
y += 18
|
|
var x := 80
|
|
for entry in [["Booster öffnen", func(): app.show_screen(BoosterScreen.new())],
|
|
["Sammlung", func(): app.show_screen(CollectionScreen.new())],
|
|
["Einstellungen", func(): app.show_screen(SettingsScreen.new())],
|
|
["Beenden", func(): get_tree().quit()]]:
|
|
Style.button(self, entry[0], Rect2(x, y, 166, 44), entry[1])
|
|
x += 176
|
|
notice_label = Style.label(self, "", 16, Style.GREEN, Rect2(80, y + 70, 760, 60), "left")
|
|
notice_label.autowrap_mode = TextServer.AUTOWRAP_WORD
|
|
_showcase(p)
|
|
refresh()
|
|
|
|
|
|
## Drei Karten der Sammlung, die höchsten Stufen zuerst, leicht gefächert.
|
|
func _showcase(p: Profile) -> void:
|
|
var cards: Array = Cards.all().duplicate()
|
|
cards.sort_custom(func(a, b):
|
|
if p.level(a.id) != p.level(b.id):
|
|
return p.level(a.id) > p.level(b.id)
|
|
return hash(a.id) % 97 < hash(b.id) % 97)
|
|
var spots := [[Vector2(830, 300), -0.14], [Vector2(950, 270), 0.0], [Vector2(1070, 300), 0.14]]
|
|
for i in 3:
|
|
var c: Cards.Card = cards[i]
|
|
var v := CardView.new(c, Vector2(180, 252), false, p.rarity(c.id))
|
|
v.position = spots[i][0]
|
|
v.rotation = spots[i][1]
|
|
v.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
add_child(v)
|
|
|
|
|
|
func refresh() -> void:
|
|
var p: Profile = app.profile
|
|
coins_label.text = tr("Münzen: %d · Staub: %d") % [p.coins, p.dust]
|
|
coll_label.text = tr("Aufgewertet: %d von %d Karten · Kampagne: %d/%d") % [
|
|
p.upgraded_count(), Cards.all().size(), p.campaign_stage, Campaign.total()]
|
|
var notes := p.take_notices()
|
|
notice_label.text = " · ".join(notes)
|
|
if not notes.is_empty():
|
|
app.save()
|