Exemple #1
0
        internal DebugSwitchDisplay(intFunc update_function, List <Tuple <int, string, Color> > commands)
        {
            UpdateFunction = update_function;

            int x = 0;

            foreach (var tuple in commands)
            {
                TextSprite text = new TextSprite();
                text.loc = new Vector2(x + 4, 0);
                text.SetFont(Config.UI_FONT);
                text.text = tuple.Item2;
                Texts.Add(text);

                Sprite bg = new Sprite();
                bg.loc   = new Vector2(x, 0);
                bg.scale = new Vector2(tuple.Item1 / 16f, 1f);
                bg.tint  = tuple.Item3;
                Bgs.Add(bg);

                BgFadeTimes.Add(Index == BgFadeTimes.Count ? FADE_TIME : 0);

                BgColors.Add(tuple.Item3);

                x += tuple.Item1;
            }
            Width = commands.Select(tuple => tuple.Item1).Sum();
        }
        internal DebugIntDisplay(intFunc update_function, string caption, int places,
                                 Maybe <int> caption_width = default(Maybe <int>))
        {
            UpdateFunction = update_function;
            Places         = places;

            int x = 0;

            //Caption
            CaptionText     = new TextSprite();
            CaptionText.loc = new Vector2(x + 4, 0);
            CaptionText.SetFont(Config.UI_FONT);
            CaptionText.text = caption;
            if (caption_width.IsNothing)
            {
                caption_width = CaptionText.text_width + 8;
                caption_width = ((caption_width + 7) / 8) * 8;
            }
            x += caption_width;
            // Counter
            Text     = new RightAdjustedText();
            Text.loc = new Vector2(x + Places * 8 + 4, 0);
            Text.SetFont(Config.UI_FONT);

            Width = caption_width + (Places + 1) * 8;
        }