Exemple #1
0
        public void Initialize(DrawArgs drawArgs)
        {
            // Initialize fonts
            if (m_drawingFont == null)
            {
                System.Drawing.Font localHeaderFont = new System.Drawing.Font("Arial", 12.0f, FontStyle.Italic | FontStyle.Bold);
                m_drawingFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, localHeaderFont);

                System.Drawing.Font wingdings = new System.Drawing.Font("Wingdings", 12.0f);
                m_wingdingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, wingdings);

                System.Drawing.Font worldwinddings = new System.Drawing.Font("World Wind dings", 12.0f);
                m_worldwinddingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, worldwinddings);
            }

            // Initialize icon if any
            if (m_imageName.Trim() != string.Empty)
            {
                object key = null;

                // Icon image from file
                m_iconTexture = (IconTexture)DrawArgs.Textures[m_imageName];
                if (m_iconTexture == null)
                {
                    key           = m_imageName;
                    m_iconTexture = new IconTexture(drawArgs.device, m_imageName);
                }

                if (m_iconTexture != null)
                {
                    m_iconTexture.ReferenceCount++;

                    if (key != null)
                    {
                        // New texture, cache it
                        DrawArgs.Textures.Add(key, m_iconTexture);
                    }

                    if (m_size.Width == 0)
                    {
                        m_size.Width = m_iconTexture.Width;
                    }

                    if (m_size.Height == 0)
                    {
                        m_size.Height = m_iconTexture.Height;
                    }

                    this.XScale = (float)m_size.Width / m_iconTexture.Width;
                    this.YScale = (float)m_size.Height / m_iconTexture.Height;
                }

                if (m_sprite == null)
                {
                    m_sprite = new Sprite(drawArgs.device);
                }
            }

            m_isInitialized = true;
        }
    protected void InitTexture()
    {
        statusBackgroundTexture = new Texture2D(1, 1);
        statusBackgroundTexture.SetPixel(0, 0, new Color(0.5f, 0.5f, 1.0f, 0.75f));
        statusBackgroundTexture.Apply();

        hpBarFrontNormalTexture = new Texture2D(1, 1);
        hpBarFrontNormalTexture.SetPixel(0, 0, new Color(0.0f, 1.0f, 0.0f, 1.0f));
        hpBarFrontNormalTexture.Apply();

        hpBarFrontDangerTexture = new Texture2D(1, 1);
        hpBarFrontDangerTexture.SetPixel(0, 0, new Color(1.0f, 0.0f, 0.0f, 1.0f));
        hpBarFrontDangerTexture.Apply();

        hpBarBackTexture = new Texture2D(1, 1);
        hpBarBackTexture.SetPixel(0, 0, new Color(0.0f, 0.0f, 0.0f, 1.0f));
        hpBarBackTexture.Apply();

        mpBarFrontTexture = new Texture2D(1, 1);
        mpBarFrontTexture.SetPixel(0, 0, new Color(0.0f, 0.0f, 1.0f, 1.0f));
        mpBarFrontTexture.Apply();

        mpBarBackTexture = new Texture2D(1, 1);
        mpBarBackTexture.SetPixel(0, 0, new Color(0.0f, 0.0f, 0.0f, 1.0f));
        mpBarBackTexture.Apply();

        activeBorderTexture = new Texture2D((int)activeBorderRect.width, (int)activeBorderRect.height);
        for (int i = 0; i < activeBorderRect.width; i++)
        {
            for (int j = 0; j < activeBorderRect.height; j++)
            {
                if (i > activeBorderRect.x + 10.0f && i < activeBorderRect.width - 10.0f && j > activeBorderRect.y + 10.0f && j < activeBorderRect.height - 10.0f)
                {
                    activeBorderTexture.SetPixel(i, j, new Color(0.0f, 0.0f, 0.0f, 0.0f));
                }
                else
                {
                    activeBorderTexture.SetPixel(i, j, new Color(1.0f, 1.0f, 0.3f, 1.0f));
                }
            }
        }
        activeBorderTexture.Apply();

        downIconTexture = new Texture2D(IconTexture.width, IconTexture.height);
        for (int i = 0; i < downIconTexture.width; i++)
        {
            for (int j = 0; j < downIconTexture.height; j++)
            {
                Color pixel = IconTexture.GetPixel(i, j);
                float color = 0.2126f * pixel.r + 0.7152f * pixel.g + 0.0722f * pixel.b;
                downIconTexture.SetPixel(i, j, new Color(color, color, color, pixel.a));
            }
        }
        downIconTexture.Apply();
    }
Exemple #3
0
        /// <summary>
        /// Initializes the button by loading the texture, creating the sprite and figure out the scaling.
        ///
        /// Called on the GUI thread.
        /// </summary>
        /// <param name="drawArgs">The drawing arguments passed from the WW GUI thread.</param>
        public void Initialize(DrawArgs drawArgs)
        {
            object key = null;

            m_imageName = Path.GetDirectoryName(Application.ExecutablePath) + @"\Plugins\Navigator\world.png";

            // Icon image from file
            m_iconTexture = (IconTexture)DrawArgs.Textures[m_imageName];
            if (m_iconTexture == null)
            {
                key           = m_imageName;
                m_iconTexture = new IconTexture(drawArgs.device, m_imageName);
            }

            if (m_iconTexture != null)
            {
                m_iconTexture.ReferenceCount++;

                if (key != null)
                {
                    // New texture, cache it
                    DrawArgs.Textures.Add(key, m_iconTexture);
                }

                if (m_size.Width == 0)
                {
                    m_size.Width = m_iconTexture.Width;
                }

                if (m_size.Height == 0)
                {
                    m_size.Height = m_iconTexture.Height;
                }

                this.XScale = (float)m_size.Width / m_iconTexture.Width;
                this.YScale = (float)m_size.Height / m_iconTexture.Height;
            }

            if (m_sprite == null)
            {
                m_sprite = new Sprite(drawArgs.device);
            }

            if (m_crossHairs == null)
            {
                m_crossHairs = new Line(drawArgs.device);
            }

            m_isInitialized = true;
        }
Exemple #4
0
        /// <summary>
        /// Initializes the button by loading the texture, creating the sprite and figure out the scaling.
        ///
        /// Called on the GUI thread.
        /// </summary>
        /// <param name="drawArgs">The drawing arguments passed from the WW GUI thread.</param>
        public void Initialize(DrawArgs drawArgs)
        {
            object key = null;

            this.m_imageName = Path.GetDirectoryName(Application.ExecutablePath) + @"\Plugins\Navigator\compass.png";

            // Icon image from file
            this.m_iconTexture = (IconTexture)DrawArgs.Textures[this.m_imageName];
            if (this.m_iconTexture == null)
            {
                key = this.m_imageName;
                this.m_iconTexture = new IconTexture(drawArgs.device, this.m_imageName);
            }

            if (this.m_iconTexture != null)
            {
                this.m_iconTexture.ReferenceCount++;

                if (key != null)
                {
                    // New texture, cache it
                    DrawArgs.Textures.Add(key, this.m_iconTexture);
                }

                if (this.m_size.Width == 0)
                {
                    this.m_size.Width = this.m_iconTexture.Width;
                }

                if (this.m_size.Height == 0)
                {
                    this.m_size.Height = this.m_iconTexture.Height;
                }

                this.XScale = (float)this.m_size.Width / this.m_iconTexture.Width;
                this.YScale = (float)this.m_size.Height / this.m_iconTexture.Height;
            }

            if (this.m_sprite == null)
            {
                this.m_sprite = new Sprite(drawArgs.device);
            }

            this.m_isInitialized = true;
        }
Exemple #5
0
        /// <summary>
        /// Initializes the button by loading the texture, creating the sprite and figure out the scaling.
        ///
        /// Called on the GUI thread.
        /// </summary>
        /// <param name="drawArgs">The drawing arguments passed from the WW GUI thread.</param>
        public void Initialize(DrawArgs drawArgs)
        {
            object key = null;

            /// TODO - Make this work the same way as Icons including fetch from URL

            // Icon image from file
            m_iconTexture = (IconTexture)DrawArgs.Textures[m_imageName];
            if (m_iconTexture == null)
            {
                key           = m_imageName;
                m_iconTexture = new IconTexture(drawArgs.device, m_imageName);
            }

            if (m_iconTexture != null)
            {
                m_iconTexture.ReferenceCount++;

                if (key != null)
                {
                    // New texture, cache it
                    DrawArgs.Textures.Add(key, m_iconTexture);
                }

                if (m_size.Width == 0)
                {
                    m_size.Width = m_iconTexture.Width;
                }

                if (m_size.Height == 0)
                {
                    m_size.Height = m_iconTexture.Height;
                }

                this.XScale = (float)m_size.Width / m_iconTexture.Width;
                this.YScale = (float)m_size.Height / m_iconTexture.Height;
            }

            if (m_sprite == null)
            {
                m_sprite = new Sprite(drawArgs.device);
            }

            m_isInitialized = true;
        }
Exemple #6
0
        public void Initialize(DrawArgs drawArgs)
        {
            // Initialize fonts
            if (m_drawingFont == null)
            {
                System.Drawing.Font localHeaderFont = new System.Drawing.Font("Arial", 12.0f, FontStyle.Italic | FontStyle.Bold);
                m_drawingFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, localHeaderFont);
            }

            if (m_wingdingsFont == null)
            {
                System.Drawing.Font wingdings = new System.Drawing.Font("Wingdings", 12.0f);
                m_wingdingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, wingdings);
            }

            if (m_worldwinddingsFont == null)
            {
                AddFontResource(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf"));
                System.Drawing.Text.PrivateFontCollection fpc = new System.Drawing.Text.PrivateFontCollection();
                fpc.AddFontFile(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf"));
                System.Drawing.Font m_worldwinddings = new System.Drawing.Font(fpc.Families[0], 12.0f);
                m_worldwinddingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, m_worldwinddings);
            }

            // Initialize icon if any
            if (m_imageName.Trim() != string.Empty)
            {
                object key = null;

                // Icon image from file
                m_iconTexture = (IconTexture)DrawArgs.Textures[m_imageName];
                if (m_iconTexture == null)
                {
                    key           = m_imageName;
                    m_iconTexture = new IconTexture(drawArgs.device, m_imageName);
                }

                if (m_iconTexture != null)
                {
                    m_iconTexture.ReferenceCount++;

                    if (key != null)
                    {
                        // New texture, cache it
                        DrawArgs.Textures.Add(key, m_iconTexture);
                    }

                    if (m_size.Width == 0)
                    {
                        m_size.Width = m_iconTexture.Width;
                    }

                    if (m_size.Height == 0)
                    {
                        m_size.Height = m_iconTexture.Height;
                    }

                    this.XScale = (float)m_size.Width / m_iconTexture.Width;
                    this.YScale = (float)m_size.Height / m_iconTexture.Height;
                }

                if (m_sprite == null)
                {
                    m_sprite = new Sprite(drawArgs.device);
                }
            }

            m_isInitialized = true;
        }
Exemple #7
0
 public void Dispose()
 {
     IconTexture?.Dispose();
     Blocks?.Dispose();
 }