Ejemplo n.º 1
0
        public override void Draw(SpriteBatch spriteBatch, Point offset)
        {
            var items = Items.Where(i => i.Visible).ToArray();

            int x     = offset.X + Position.X;
            int y     = offset.Y + Position.Y;
            int width = 0;

            if (items.Length > 0)
            {
                width = (Position.Width - ((items.Length - 1) * 5)) / items.Length;
            }

            foreach (var item in items)
            {
                // Style des aktuellen Elementes ermitteln
                NineTileRenderer renderer = Manager.Button;
                float            alpha    = (item.Enabled ? 1f : 0.3f);
                if (item.Equals(SelectedItem))
                {
                    renderer = Manager.ButtonHovered;
                }

                // Hintergrund rendern
                renderer.Draw(spriteBatch, new Rectangle(x, y, width, Position.Height), alpha);

                // Text-Inhalt zentriert rendern
                Vector2 size = Manager.Font.MeasureString(item.ToString());
                spriteBatch.DrawString(Manager.Font, item.ToString(), new Vector2(x + ((width - size.X) / 2f), y + ((Position.Height - size.Y) / 2f)), Color.White * alpha);
                x += width + 5;
            }
        }
Ejemplo n.º 2
0
        protected override void LoadContent()
        {
            // Sprite Batch erstellen
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Standard Pixel erstellen
            Pixel = new Texture2D(GraphicsDevice, 1, 1);
            Pixel.SetData(new [] { Color.White });

            // Schriftart laden
            Font = Game.Content.Load <SpriteFont>("HudFont");

            // Hintergründe laden
            Texture2D texture = Game.Content.Load <Texture2D>("ui");

            Panel         = new NineTileRenderer(texture, new Rectangle(190, 100, 100, 100), new Point(30, 30));
            Border        = new NineTileRenderer(texture, new Rectangle(283, 200, 93, 94), new Point(30, 30));
            Button        = new NineTileRenderer(texture, new Rectangle(0, 282, 190, 49), new Point(10, 10));
            ButtonHovered = new NineTileRenderer(texture, new Rectangle(0, 143, 190, 45), new Point(10, 10));

            // Arrow
            Rectangle source = new Rectangle(325, 486, 22, 21);

            Color[] buffer = new Color[source.Width * source.Height];
            texture.GetData(0, source, buffer, 0, buffer.Length);
            Arrow = new Texture2D(GraphicsDevice, source.Width, source.Height);
            Arrow.SetData(buffer);

            // Waiting Coin
            WaitingCoin = Game.Content.Load <Texture2D>("coin_gold");
        }
Ejemplo n.º 3
0
        protected override void LoadContent()
        {
            // Sprite Batch erstellen
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Standard Pixel erstellen
            Pixel = new Texture2D(GraphicsDevice, 1, 1);
            Pixel.SetData(new [] { Color.White });

            // Schriftart laden
            Font = Game.Content.Load <SpriteFont>("HudFont");

            // Hintergründe laden
            Texture2D texture;

            texture     = Game.Content.Load <Texture2D>("ui_elements\\ui_theme");
            Bolt_Panel1 = new NineTileRenderer(texture, new Rectangle(0, 288, 512, 128), new Point(30, 30));
            Bolt_Panel2 = new NineTileRenderer(texture, new Rectangle(0, 432, 512, 128), new Point(30, 30));
            Bolt_Panel3 = new NineTileRenderer(texture, new Rectangle(0, 576, 512, 128), new Point(30, 30));
            Bolt_Panel4 = new NineTileRenderer(texture, new Rectangle(0, 720, 512, 128), new Point(30, 30));

            Bolt_Panel5 = new NineTileRenderer(texture, new Rectangle(800, 288, 512, 128), new Point(30, 30));
            Bolt_Panel6 = new NineTileRenderer(texture, new Rectangle(800, 432, 512, 128), new Point(30, 30));
            Bolt_Panel7 = new NineTileRenderer(texture, new Rectangle(800, 576, 512, 128), new Point(30, 30));
            Bolt_Panel8 = new NineTileRenderer(texture, new Rectangle(800, 720, 512, 128), new Point(30, 30));

            Small_Panel1 = new NineTileRenderer(texture, new Rectangle(528, 544, 256, 64), new Point(15, 15));
            Small_Panel2 = new NineTileRenderer(texture, new Rectangle(528, 624, 256, 64), new Point(15, 15));
            Small_Panel3 = new NineTileRenderer(texture, new Rectangle(528, 704, 256, 64), new Point(15, 15));
            Small_Panel4 = new NineTileRenderer(texture, new Rectangle(528, 784, 256, 64), new Point(15, 15));

            Small_Panel5 = new NineTileRenderer(texture, new Rectangle(1328, 544, 256, 64), new Point(15, 15));
            Small_Panel6 = new NineTileRenderer(texture, new Rectangle(1328, 624, 256, 64), new Point(15, 15));
            Small_Panel7 = new NineTileRenderer(texture, new Rectangle(1328, 704, 256, 64), new Point(15, 15));
            Small_Panel8 = new NineTileRenderer(texture, new Rectangle(1328, 784, 256, 64), new Point(15, 15));

            texture       = Game.Content.Load <Texture2D>("ui");
            Panel         = new NineTileRenderer(texture, new Rectangle(190, 100, 100, 100), new Point(30, 30));
            Border        = new NineTileRenderer(texture, new Rectangle(283, 200, 93, 94), new Point(30, 30));
            Button        = new NineTileRenderer(texture, new Rectangle(0, 282, 190, 49), new Point(10, 10));
            ButtonHovered = new NineTileRenderer(texture, new Rectangle(0, 143, 190, 45), new Point(10, 10));


            // Arrow
            Rectangle source = new Rectangle(325, 486, 22, 21);

            Color[] buffer = new Color[source.Width * source.Height];
            texture.GetData(0, source, buffer, 0, buffer.Length);
            Arrow = new Texture2D(GraphicsDevice, source.Width, source.Height);
            Arrow.SetData(buffer);

            // Waiting Coin
            WaitingCoin = Game.Content.Load <Texture2D>("coin_gold");
        }
Ejemplo n.º 4
0
        public override void Draw(SpriteBatch spriteBatch, Point offset)
        {
            int x     = offset.X + Position.X;
            int y     = offset.Y + Position.Y;
            var items = Items.Where(i => i.Visible);
            int width = 120;

            x += (Position.Width - (width * items.Count())) / 2;

            foreach (var item in items)
            {
                // Style des aktuellen Elementes ermitteln
                NineTileRenderer renderer = Manager.Button;
                float            alpha    = (item.Enabled ? 1f : 0.3f);
                if (item.Equals(SelectedItem))
                {
                    renderer = Manager.ButtonHovered;
                }

                // Hintergrund rendern
                renderer.Draw(spriteBatch, new Rectangle(x, y, width, Position.Height), alpha);

                // Icon rendern
                if (!string.IsNullOrEmpty(item.Icon))
                {
                    Texture2D icon   = Manager.GetIcon(item.Icon);
                    int       margin = (width - icon.Width * 2) / 2;
                    spriteBatch.Draw(icon, new Rectangle(x + margin, y + 20, 42, 42), Color.White * alpha);
                }

                // Text-Inhalt zentriert rendern
                string  text = item.ToString();
                Vector2 size = Manager.Font.MeasureString(text);
                spriteBatch.DrawString(Manager.Font, text, new Vector2(x + ((width - size.X) / 2), y + 100f), Color.White * alpha);

                // Preis
                text = item.Value.ToString();
                size = Manager.Font.MeasureString(text);
                spriteBatch.DrawString(Manager.Font, text, new Vector2(x + ((width - size.X) / 2), y + 120f), Color.White * alpha);

                x += width;
            }
        }
Ejemplo n.º 5
0
        public override void Draw(SpriteBatch spriteBatch, Point offset)
        {
            int x = offset.X + Position.X;
            int y = offset.Y + Position.Y;

            foreach (var item in Items.Where(i => i.Visible))
            {
                // Style des aktuellen Elementes ermitteln
                NineTileRenderer renderer = Manager.Small_Panel7;
                float            alpha    = (item.Enabled ? 1f : 0.3f);
                if (item.Equals(SelectedItem))
                {
                    renderer = Manager.Small_Panel6;
                }

                // Hintergrund rendern
                renderer.Draw(spriteBatch, new Rectangle(x, y, Position.Width, 50), alpha);

                // Text-Inhalt zentriert rendern
                Vector2 size = Manager.Font.MeasureString(item.ToString());
                spriteBatch.DrawString(Manager.Font, item.ToString(), new Vector2(x + ((Position.Width - size.X) / 2f), y + ((50f - size.Y) / 2f)), Color.White * alpha);
                y += 55;
            }
        }