Exemple #1
0
        public static UIScreen HighScoreScreen(UIScreen replayScreen,
                                               SMAnalysis.AnalyzedCampaign[] campaigns, SMAnalysis.AnalyzedDayCampaign?days = null)
        {
            if (campaigns.Length == 0)
            {
                return(new UIScreen(new UINode(scores_nocampaign)));
            }
            var replays  = new Dictionary <string, int>();
            var key      = new InstanceRecord().RequestKey;
            var cmpIndex = 0;

            void AssignCampaign(int cmpInd)
            {
                cmpIndex     = cmpInd;
                key.campaign = key.boss.Item1.campaign = key.challenge.Item1.Item1.Item1.campaign =
                    key.stage.Item1.campaign = campaigns[cmpIndex].Key;
                AssignStage(0);
                if (campaigns[cmpIndex].bosses.Length > 0)
                {
                    AssignBoss(campaigns[cmpIndex].bosses[0].boss.key);
                }
                else
                {
                    throw new Exception("No high score handling for days menu implemented yet"); //AssignBoss(days!.bosses[]);
                }
            }

            void AssignBoss(string boss)
            {
                key.boss.Item1.boss = key.challenge.Item1.Item1.boss = boss;
                AssignBossPhase(0);
            }

            void AssignStage(int stage)
            {
                //Better not to mix with AssignBoss to avoid invalid assignments.
                key.stage.Item1.stage = stage;
                AssignStagePhase(0);
            }

            void AssignBossPhase(int phase)
            {
                key.boss.phase = key.challenge.Item1.phase = phase;
            }

            void AssignStagePhase(int phase)
            {
                key.stage.phase = phase;
            }

            key.stage.phase = 1; //only show full-stage practice
            AssignCampaign(0);
            key.type = 0;
            SaveData.p.ReplayData.ForEachI((i, r) => replays[r.metadata.RecordUuid] = i);
            var scoreNodes = SaveData.r.FinishedGames.Values
                             //If the user doesn't enter a name on the replay screen, the score won't show up, but it will still be recorded internally
                             .Where(g => !string.IsNullOrWhiteSpace(g.CustomNameOrPartial) && g.Score > 0)
                             .OrderByDescending(g => g.Score).Select(g => {
                //Don't need to show the request (eg. Yukari (Ex) p3) because it's shown by the option nodes above this
                var node = new UINode(g.AsDisplay(true, false));
                if (replays.TryGetValue(g.Uuid, out var i))
                {
                    node.SetConfirmOverride(() => (true, replayScreen.top[i]));
                }
                return(node.With(monospaceClass).With(small2Class)
                       .With(CheckmarkClass(replays.ContainsKey(g.Uuid)))
                       .VisibleIf(() => DUHelpers.Tuple4Eq(key, g.RequestKey)));
            });
            var optnodes = new UINode[] {
                new OptionNodeLR <short>(practice_type, i => key.type = i, new (LocalizedString, short)?[] {