extends SceneTree ## Photograph the end-of-match summary, for a free-for-all and for a team mode. ## ## godot --path . --windowed --resolution 1280x800 \ ## -s res://debug/summary_capture.gd -- ## ## Fed a synthetic result rather than a played match, so the screen can be looked ## at without spending ten minutes reaching a frag limit — and so the awkward ## cases (a draw, a long name, a team scoreline) can be put on screen on purpose ## instead of waiting for them to happen. var _out := "." func _initialize() -> void: var args := OS.get_cmdline_user_args() if args.size() > 0: _out = String(args[0]) _run() func _run() -> void: await process_frame UITheme.apply_global(self) var layer := CanvasLayer.new() root.add_child(layer) var back := ColorRect.new() back.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) back.color = Color(0.30, 0.42, 0.62) layer.add_child(back) var summary := MatchSummary.new() layer.add_child(summary) await _shot(summary, "ffa", { "reason": "score", "name": "Nicholas", "mode": GameMode.DEATHMATCH, "standings": [1, 2, 3], "stats": { 1: _p("Nicholas", 25, 25, 11, 4, 7), 2: _p("Papaya Enjoyer", 19, 19, 17, 2, 4), 3: _p("guest_4471", 8, 8, 24, 9, 2), }}) await _shot(summary, "team", { "reason": "time", "team": 2, "name": "MAGENTA TEAM", "mode": GameMode.TEAM_DEATHMATCH, "standings": [3, 1, 4, 2], "stats": { 1: _p("Nicholas", 14, 14, 9, 3, 5, 1), 2: _p("Papaya Enjoyer", 6, 6, 15, 1, 2, 1), 3: _p("guest_4471", 17, 17, 8, 6, 6, 2), 4: _p("bananaboat", 12, 12, 10, 4, 3, 2), }}) quit(0) func _shot(summary: MatchSummary, tag: String, result: Dictionary) -> void: summary.show_result(result) for _i in 6: await process_frame root.get_texture().get_image().save_png("%s/summary_%s.png" % [_out, tag]) print("summary_capture: saved ", tag) func _p(who: String, score: int, kills: int, deaths: int, assists: int, streak: int, team: int = 0) -> Dictionary: return {"username": who, "score": score, "kills": kills, "deaths": deaths, "assists": assists, "best_streak": streak, "team": team}