Beispiel #1
0
 IScoreValue IScores.GetScoreValue(HiScoresEntry entry)
 {
     if (entry is HiScoresSkill skill)
     {
         return(GetSkillScore(skill));
     }
     else
     {
         throw new ArgumentException("Skill entry required.", nameof(entry));
     }
 }
        //====== override: Window

        protected override void PaintContent(TextCanvas canvas)
        {
            var list = hiScoresList.GetList();

            for (int i = 0; i < hiScoresList.Capacity; i++)
            {
                HiScoresEntry entry = (i < list.Count) ? list[i] : null;

                PrintHiScoreItem(canvas, new Point(2, 1 + i), i, entry);
            }
        }
        private void PrintHiScoreItem(TextCanvas canvas, Point position, int itemIndex, HiScoresEntry entry)
        {
            var color = (entry is null) ? Color16.Gray : Color16.White;

            string name  = entry?.Name ?? "...";
            string score = entry?.Score.ToString() ?? "...";

            name  = name.PadLeft(20, ' ');
            score = score.PadLeft(5, ' ');

            canvas.WriteText(position, $"{itemIndex + 1}. {score} {name}", color, Appearance.BackColor);
        }
Beispiel #4
0
 public ScoreValue(HiScoresEntry entry, long score, int?rank)
 {
     Entry = entry;
     Score = score;
     Rank  = rank;
 }