62 lines
2.6 KiB
GDScript
62 lines
2.6 KiB
GDScript
class_name MenuScreen
|
|
extends Control
|
|
|
|
var app
|
|
var b_resume: Button
|
|
var coins_label: Label
|
|
var coll_label: Label
|
|
var notice_label: Label
|
|
|
|
|
|
func _ready() -> void:
|
|
var col := Style.column(self, 640, 40, 5)
|
|
Style.clabel(col, "Dinger", 64, Style.GOLD, "center", true)
|
|
Style.clabel(col, "Ein Kartenspiel: jeder gegen jeden", 22, Style.MUTED)
|
|
Style.spacer(col, 8)
|
|
coins_label = Style.clabel(col, "", 20, Style.GOLD)
|
|
coll_label = Style.clabel(col, "", 16, Style.MUTED)
|
|
Style.spacer(col, 8)
|
|
var grid := GridContainer.new()
|
|
grid.columns = 2
|
|
grid.add_theme_constant_override("h_separation", 12)
|
|
grid.add_theme_constant_override("v_separation", 8)
|
|
var center := CenterContainer.new()
|
|
center.add_child(grid)
|
|
col.add_child(center)
|
|
var sz := Vector2(270, 44)
|
|
if FileAccess.file_exists(app.battle_save_path()):
|
|
b_resume = Style.cbutton(grid, "Kampf fortsetzen", sz, _resume, Color("5a4628"))
|
|
Style.cbutton(grid, "Einzelspieler", sz, func(): app.show_screen(OpponentSelectScreen.new()), Color("285a3c"))
|
|
Style.cbutton(grid, "Kampagne", sz, func(): app.show_screen(CampaignScreen.new()), Color("285a3c"))
|
|
Style.cbutton(grid, "Netzwerkspiel", sz, func(): app.show_screen(LobbyScreen.new()), Color("285a3c"))
|
|
Style.cbutton(grid, "Booster öffnen", sz, func(): app.show_screen(BoosterScreen.new()))
|
|
Style.cbutton(grid, "Sammlung", sz, func(): app.show_screen(CollectionScreen.new()))
|
|
Style.cbutton(grid, "Einstellungen", sz, func(): app.show_screen(SettingsScreen.new()))
|
|
Style.cbutton(grid, "Beenden", sz, func(): get_tree().quit())
|
|
Style.spacer(col, 10)
|
|
notice_label = Style.clabel(col, "", 16, Style.GREEN)
|
|
notice_label.autowrap_mode = TextServer.AUTOWRAP_WORD
|
|
refresh()
|
|
|
|
|
|
## Unterbrochenen Kampf laden; eine unlesbare Datei wird verworfen.
|
|
func _resume() -> void:
|
|
var json := JSON.new()
|
|
var text := FileAccess.get_file_as_string(app.battle_save_path())
|
|
if json.parse(text) != OK or not (json.data is Dictionary) or not json.data.has("game"):
|
|
app.clear_battle_save()
|
|
app.show_screen(MenuScreen.new())
|
|
return
|
|
app.show_screen(BattleScreen.resume(json.data))
|
|
|
|
|
|
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()
|