Example #1
0
 public TextLayer(int x, int y, Font font, FontJustify justify, bool opaque = false)
     : base(opaque)
 {
     this.set_target_position(x, y);
     this.font                 = font;
     this.started_at           = -1;
     this.seconds              = -1;
     this.frame                = null;
     this.frame_old            = null;
     this.justify              = justify;
     this.blink_frames         = -1;
     this.blink_frames_counter = 0;
 }
Example #2
0
 public TextLayer(int x, int y, Font font, FontJustify justify, bool opaque = false)
     : base(opaque)
 {
     this.set_target_position(x, y);
     this.font = font;
     this.started_at = -1;
     this.seconds = -1;
     this.frame = null;
     this.frame_old = null;
     this.justify = justify;
     this.blink_frames = -1;
     this.blink_frames_counter = 0;
 }
Example #3
0
        public ScoreDisplay(GameController game, int priority, FontJustify left_players_justify = FontJustify.Right)
            : base(game, priority)
        {
            this.layer       = new ScoreLayer(128, 32, this);
            this.font_common = FontManager.instance.font_named("Font07x5.dmd");
            this.font_18x12  = FontManager.instance.font_named("Font18x12.dmd");
            this.font_18x11  = FontManager.instance.font_named("Font18x11.dmd");
            this.font_18x10  = FontManager.instance.font_named("Font18x10.dmd");
            this.font_14x10  = FontManager.instance.font_named("Font14x10.dmd");
            this.font_14x9   = FontManager.instance.font_named("Font14x9.dmd");
            this.font_14x8   = FontManager.instance.font_named("Font14x8.dmd");
            this.font_09x5   = FontManager.instance.font_named("Font09x5.dmd");
            this.font_09x6   = FontManager.instance.font_named("Font09x6.dmd");
            this.font_09x7   = FontManager.instance.font_named("Font09x7.dmd");

            this.score_posns = new Dictionary <bool, List <Pair <int, int> > >();

            this.set_left_players_justify(left_players_justify);
        }
Example #4
0
        public ScoreDisplay(GameController game, int priority, FontJustify left_players_justify = FontJustify.Right)
            : base(game, priority)
        {
            this.layer = new ScoreLayer(128, 32, this);
            this.font_common = FontManager.instance.font_named("Font07x5.dmd");
            this.font_18x12 = FontManager.instance.font_named("Font18x12.dmd");
            this.font_18x11 = FontManager.instance.font_named("Font18x11.dmd");
            this.font_18x10 = FontManager.instance.font_named("Font18x10.dmd");
            this.font_14x10 = FontManager.instance.font_named("Font14x10.dmd");
            this.font_14x9 = FontManager.instance.font_named("Font14x9.dmd");
            this.font_14x8 = FontManager.instance.font_named("Font14x8.dmd");
            this.font_09x5 = FontManager.instance.font_named("Font09x5.dmd");
            this.font_09x6 = FontManager.instance.font_named("Font09x6.dmd");
            this.font_09x7 = FontManager.instance.font_named("Font09x7.dmd");

            this.score_posns = new Dictionary<bool, List<Pair<int, int>>>();

            this.set_left_players_justify(left_players_justify);
        }
Example #5
0
 private int draw_text(int y, string text, Font font, FontJustify justify, bool draw)
 {
     if (GetMaxValueInList(font.char_widths) * text.Length > this.width)
     {
         // We need to do some word wrapping
         string line = "";
         int    w    = 0;
         foreach (char ch in text)
         {
             line += ch;
             w    += font.size(ch.ToString()).First;
             if (w > this.width)
             {
                 // Too much! We need to back-track for the last space. If possible...
                 int idx = line.LastIndexOf(' ');
                 if (idx == -1)
                 {
                     // No space, we'll have to break before this char and continue
                     y    = this.draw_line(y, line.Substring(0, line.Length - 1), font, justify, draw);
                     line = ch.ToString();
                 }
                 else
                 {
                     // We found a space!
                     y    = this.draw_line(y, line.Substring(0, idx), font, justify, draw);
                     line = line.Substring(idx + 1, line.Length - idx - 1);
                 }
                 // Recalculate w
                 w = font.size(line).First;
             }
         }
         if (line.Length > 0) // Left-over text we have to draw
         {
             y = this.draw_line(y, line, font, justify, draw);
         }
         return(y);
     }
     else
     {
         return(this.draw_line(y, text, font, justify, draw));
     }
 }
Example #6
0
        /// <summary>
        /// Call to set the justification of the left-hand players' scores in a multiplayer game.
        /// Valid values for left_player_justify are FontJustify.Left and FontJustify.Right
        /// </summary>
        public void set_left_players_justify(FontJustify left_players_justify)
        {
            List <Pair <int, int> > position_entries;

            this.score_posns.Clear();
            if (left_players_justify == FontJustify.Left)
            {
                position_entries = new List <Pair <int, int> >();
                position_entries.Add(new Pair <int, int>(0, 0));
                position_entries.Add(new Pair <int, int>(128, 0));
                position_entries.Add(new Pair <int, int>(0, 11));
                position_entries.Add(new Pair <int, int>(128, 11));
                this.score_posns.Add(true, position_entries);
                position_entries.Clear();
                position_entries.Add(new Pair <int, int>(0, -1));
                position_entries.Add(new Pair <int, int>(128, -1));
                position_entries.Add(new Pair <int, int>(0, 16));
                position_entries.Add(new Pair <int, int>(128, 16));
                this.score_posns.Add(false, position_entries);
            }
            else
            {
                position_entries = new List <Pair <int, int> >();
                position_entries.Add(new Pair <int, int>(75, 0));
                position_entries.Add(new Pair <int, int>(128, 0));
                position_entries.Add(new Pair <int, int>(75, 11));
                position_entries.Add(new Pair <int, int>(128, 11));
                this.score_posns.Add(true, position_entries);
                position_entries.Clear();
                position_entries.Add(new Pair <int, int>(52, -1));
                position_entries.Add(new Pair <int, int>(128, -1));
                position_entries.Add(new Pair <int, int>(52, 16));
                position_entries.Add(new Pair <int, int>(128, 16));
                this.score_posns.Add(false, position_entries);
            }
            this.score_justs = new FontJustify[4] {
                left_players_justify, FontJustify.Right, left_players_justify, FontJustify.Right
            };
        }
Example #7
0
        /// <summary>
        /// Draw a line without concern for word wrapping
        /// </summary>
        private int draw_line(int y, string text, Font font, FontJustify justify, bool draw)
        {
            int w = 0;

            if (draw)
            {
                int x = 0; // TODO: x should be set based on justify
                if (justify != FontJustify.Left)
                {
                    w = font.size(text).First;
                    if (justify == FontJustify.Center)
                    {
                        x = (this.frame.width - w) / 2;
                    }
                    else
                    {
                        x = (this.frame.width - w);
                    }
                }
                font.draw(this.frame, text, x, y);
            }
            y += font.char_size;
            return(y);
        }
Example #8
0
 /// <summary>
 /// Draw a line without concern for word wrapping
 /// </summary>
 private int draw_line(int y, string text, Font font, FontJustify justify, bool draw)
 {
     int w = 0;
     if (draw)
     {
         int x = 0; // TODO: x should be set based on justify
         if (justify != FontJustify.Left)
         {
             w = font.size(text).First;
             if (justify == FontJustify.Center)
                 x = (this.frame.width - w) / 2;
             else
                 x = (this.frame.width - w);
         }
         font.draw(this.frame, text, x, y);
     }
     y += font.char_size;
     return y;
 }
Example #9
0
 private int draw_text(int y, string text, Font font, FontJustify justify, bool draw)
 {
     if (GetMaxValueInList(font.char_widths) * text.Length > this.width)
     {
         // We need to do some word wrapping
         string line = "";
         int w = 0;
         foreach (char ch in text)
         {
             line += ch;
             w += font.size(ch.ToString()).First;
             if (w > this.width)
             {
                 // Too much! We need to back-track for the last space. If possible...
                 int idx = line.LastIndexOf(' ');
                 if (idx == -1)
                 {
                     // No space, we'll have to break before this char and continue
                     y = this.draw_line(y, line.Substring(0, line.Length - 1), font, justify, draw);
                     line = ch.ToString();
                 }
                 else
                 {
                     // We found a space!
                     y = this.draw_line(y, line.Substring(0, idx), font, justify, draw);
                     line = line.Substring(idx + 1, line.Length - idx - 1);
                 }
                 // Recalculate w
                 w = font.size(line).First;
             }
         }
         if (line.Length > 0) // Left-over text we have to draw
             y = this.draw_line(y, line, font, justify, draw);
         return y;
     }
     else
         return this.draw_line(y, text, font, justify, draw);
 }
Example #10
0
 /// <summary>
 /// Call to set the justification of the left-hand players' scores in a multiplayer game.
 /// Valid values for left_player_justify are FontJustify.Left and FontJustify.Right
 /// </summary>
 public void set_left_players_justify(FontJustify left_players_justify)
 {
     List<Pair<int, int>> position_entries;
     this.score_posns.Clear();
     if (left_players_justify == FontJustify.Left)
     {
         position_entries = new List<Pair<int, int>>();
         position_entries.Add(new Pair<int, int>(0, 0));
         position_entries.Add(new Pair<int, int>(128, 0));
         position_entries.Add(new Pair<int, int>(0, 11));
         position_entries.Add(new Pair<int, int>(128, 11));
         this.score_posns.Add(true, position_entries);
         position_entries.Clear();
         position_entries.Add(new Pair<int, int>(0, -1));
         position_entries.Add(new Pair<int, int>(128, -1));
         position_entries.Add(new Pair<int, int>(0, 16));
         position_entries.Add(new Pair<int, int>(128, 16));
         this.score_posns.Add(false, position_entries);
     }
     else
     {
         position_entries = new List<Pair<int, int>>();
         position_entries.Add(new Pair<int, int>(75, 0));
         position_entries.Add(new Pair<int, int>(128, 0));
         position_entries.Add(new Pair<int, int>(75, 11));
         position_entries.Add(new Pair<int, int>(128, 11));
         this.score_posns.Add(true, position_entries);
         position_entries.Clear();
         position_entries.Add(new Pair<int, int>(52, -1));
         position_entries.Add(new Pair<int, int>(128, -1));
         position_entries.Add(new Pair<int, int>(52, 16));
         position_entries.Add(new Pair<int, int>(128, 16));
         this.score_posns.Add(false, position_entries);
     }
     this.score_justs = new FontJustify[4] { left_players_justify, FontJustify.Right, left_players_justify, FontJustify.Right };
 }