public override void Draw(GameTime gameTime)
        {
            bool mouseInside = MouseIsInside();

            // For now we just pretend tiles can be either solid or not, no in-between:
            if (edgesConflict)
            {
                Color = new Microsoft.Xna.Framework.Graphics.Color(255, 0, 255);
            }
            else if (edges[0] || edges[1] || edges[2] || edges[3])
            {
                if (mouseInside)
                {
                    Color = new Microsoft.Xna.Framework.Graphics.Color(255, 127, 127);
                }
                else
                {
                    Color = new Microsoft.Xna.Framework.Graphics.Color(255, 0, 0);
                }
            }
            else
            {
                Color = new Microsoft.Xna.Framework.Graphics.Color(1.0f, 1.0f, 1.0f, (mouseInside ? 0.8f : 0.5f));
            }

            base.Draw(gameTime);
        }
Example #2
0
        public void LoadDataFromXMLDocument(string filename)
        {
            Microsoft.Xna.Framework.Graphics.Color color;
            Font        font;
            XmlDocument document = new XmlDocument();

            document.Load(filename);
            XmlNode nextSibling = document.FirstChild.NextSibling;
            XmlNode node        = nextSibling.ChildNodes.Item(0);

            this.personBubble.BackgroundTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\PersonBubble\Data\" + node.Attributes.GetNamedItem("FileName").Value);
            this.personBubble.BackgroundSize.X  = int.Parse(node.Attributes.GetNamedItem("Width").Value);
            this.personBubble.BackgroundSize.Y  = int.Parse(node.Attributes.GetNamedItem("Height").Value);
            this.personBubble.PopoutOffset.X    = int.Parse(node.Attributes.GetNamedItem("PopoutX").Value);
            this.personBubble.PopoutOffset.Y    = int.Parse(node.Attributes.GetNamedItem("PopoutY").Value);
            node = nextSibling.ChildNodes.Item(1);
            this.personBubble.PortraitClient = StaticMethods.LoadRectangleFromXMLNode(node);
            node = nextSibling.ChildNodes.Item(2);
            this.personBubble.ClientPosition   = StaticMethods.LoadRectangleFromXMLNode(node);
            this.personBubble.TextClientWidth  = this.personBubble.ClientPosition.Width;
            this.personBubble.TextClientHeight = this.personBubble.ClientPosition.Height;
            this.personBubble.TextRowMargin    = int.Parse(node.Attributes.GetNamedItem("RowMargin").Value);
            StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
            this.personBubble.TextBuilder.SetFreeTextBuilder(this.graphicsDevice, font);
            this.personBubble.DefaultTextColor = color;
            node = nextSibling.ChildNodes.Item(3);
            this.personBubble.PersonSpecialTextTimeLast = int.Parse(node.Attributes.GetNamedItem("TimeLast").Value);
            color = new Microsoft.Xna.Framework.Graphics.Color {
                PackedValue = uint.Parse(node.Attributes.GetNamedItem("Color").Value)
            };
            this.personBubble.PersonSpecialTextColor = color;
            this.personBubble.TextTree.LoadFromXmlFile(@"GameComponents\PersonBubble\Data\PersonBubbleTree.xml");
        }
Example #3
0
        internal pSprite(Texture2D texture, FieldTypes fieldType, OriginTypes originType, ClockTypes clockType,
                         Vector2 startPosition, float drawDepth, bool alwaysDraw, Color colour, Object tag)
        {
            Type = SpriteTypes.Image;

            localTexture = texture;

            Disposable = false;

            SpriteEffect = SpriteEffects.None;

            OriginType = originType;

            UpdateTextureSize();
            UpdateTextureAlignment();

            Clock           = clockType;
            CurrentPosition = startPosition;
            StartPosition   = CurrentPosition;
            CurrentRotation = 0;
            CurrentScale    = 1;
            Depth           = drawDepth;
            AlwaysDraw      = alwaysDraw;
            Field           = fieldType;
            CurrentColour   = colour;
            StartColour     = colour;
            Tag             = tag;
        }
Example #4
0
        public Floor(string name, string price, string desc, Bitmap[] lods, GraphicsDevice gd, string spriteName)
        {
            myFloorName  = name;
            myFloorDesc  = desc;
            myFloorPrice = price;
            mySpriteName = spriteName;
            myFloorLods  = new Texture2D[3];
            myGD         = gd;

            for (int i = 0; i < 3; i++)
            {
                MemoryStream ms = new MemoryStream();
                Microsoft.Xna.Framework.Graphics.Color[] pixels = new Microsoft.Xna.Framework.Graphics.Color[lods[i].Height * lods[i].Width];
                for (int j = 0; j < lods[i].Height; j++)
                {
                    for (int k = 0; k < lods[i].Width; k++)
                    {
                        System.Drawing.Color currentColor = lods[i].GetPixel(k, j);
                        pixels[j * lods[i].Width + k] = new Microsoft.Xna.Framework.Graphics.Color(currentColor.R, currentColor.G, currentColor.B, currentColor.A);
                    }
                }

                myFloorLods[i] = new Texture2D(gd, lods[i].Width, lods[i].Height);
                myFloorLods[i].SetData <Microsoft.Xna.Framework.Graphics.Color>(pixels);
            }
            Texture2D dummy = CatalogImage;
        }
        int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)
        {
            if (deviceNumber == 1)
            {
                int j = 0;
            }
            Marshal.Copy(pBuffer, bgrData, 0, BufferLen);
            Color[] colorData = new Color[BufferLen / 3];
            int     colIdx    = colorData.Length - 1;

            for (int i = 0; i < colorData.Length; i++)
            {
                colorData[i] = new Microsoft.Xna.Framework.Graphics.Color(bgrData[3 * i + 2], bgrData[3 * i + 1], bgrData[3 * i]);
            }
            if (swapA)
            {
                camTextureA.SetData <Microsoft.Xna.Framework.Graphics.Color>(colorData);
            }
            else
            {
                camTextureB.SetData <Microsoft.Xna.Framework.Graphics.Color>(colorData);
            }
            swapA = !swapA;

            return(0);
        }
Example #6
0
        public Floor(string name, string price, string desc, Bitmap[] lods, GraphicsDevice gd, string spriteName)
        {
            myFloorName = name;
            myFloorDesc = desc;
            myFloorPrice = price;
            mySpriteName = spriteName;
            myFloorLods = new Texture2D[3];
            myGD = gd;

            for (int i = 0; i < 3; i++)
            {
                MemoryStream ms = new MemoryStream();
                Microsoft.Xna.Framework.Graphics.Color[] pixels = new Microsoft.Xna.Framework.Graphics.Color[lods[i].Height * lods[i].Width];
                for (int j = 0; j < lods[i].Height; j++)
                {
                    for (int k = 0; k < lods[i].Width; k++)
                    {
                        System.Drawing.Color currentColor = lods[i].GetPixel(k, j);
                        pixels[j * lods[i].Width + k] = new Microsoft.Xna.Framework.Graphics.Color(currentColor.R, currentColor.G, currentColor.B, currentColor.A);
                    }
                }

                myFloorLods[i] = new Texture2D(gd, lods[i].Width, lods[i].Height);
                myFloorLods[i].SetData<Microsoft.Xna.Framework.Graphics.Color>(pixels);
            }
            Texture2D dummy = CatalogImage;
        }
Example #7
0
 public DMultiLineTextBox(DGuiManager guiManager, float x, float y, int width, int height, string text, 
     Color fillColor, Color borderColor)
     : this(guiManager, x, y, width, height, text)
 {
     this.ColorTheme.FillColor = fillColor;
     this.ColorTheme.BorderColor = borderColor;
 }
Example #8
0
 public void CorrectAlphaBorders(uint[] pixels, int width, int height, int maxSteps)
 {
     bool[] pixelsMask = new bool[pixels.Length];
     for (int i = 0; i < pixels.Length; i++)
     {
         // if Alpha > 0
         if (pixels[i] >= 16777216)
         {
             pixelsMask[i] = true;
         }
     }
     for (int i = 0; i < pixelsMask.Length; i++)
     {
         // if alpha, check each borders to fill it with a copy
         if (pixelsMask[i] == true)
         {
             double   widthSize      = (double)width;
             Point    pixRef         = new Point((int)(i % widthSize), (int)Math.Floor(i / widthSize));
             uint     pixRefPos      = (uint)(pixRef.Y * width + pixRef.X);
             uint     colorRef       = pixels[pixRefPos];
             XnaColor referenceColor = XnaColor.Black;
             referenceColor.PackedValue = colorRef;
             // remove alpha value
             referenceColor.A = 0;
             colorRef         = referenceColor.PackedValue;
             CheckAroundPixel(pixels, pixelsMask, colorRef, pixRef, width, height, 1, maxSteps);
         }
     }
 }
Example #9
0
        private Bitmap Texture2DToBitmap(Texture2D texture)
        {
            int width  = texture.Width;
            int height = texture.Height;

            Microsoft.Xna.Framework.Graphics.Color[] data = new Microsoft.Xna.Framework.Graphics.Color[width * height];
            texture.GetData <Microsoft.Xna.Framework.Graphics.Color>(data);
            Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);

            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, width, height);
            BitmapData bitmapData         = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);

            unsafe {
                byte *ptr         = (byte *)bitmapData.Scan0.ToPointer();
                int   offsetSrc   = 0;
                int   offsetDestY = 0;
                for (int y = 0; y < height; y++)
                {
                    int offsetDest = offsetDestY;
                    for (int x = 0; x < width; x++)
                    {
                        Microsoft.Xna.Framework.Graphics.Color color = data[offsetSrc];
                        ptr[offsetDest + 0] = color.B;
                        ptr[offsetDest + 1] = color.G;
                        ptr[offsetDest + 2] = color.R;
                        ptr[offsetDest + 3] = 255;
                        offsetSrc++;
                        offsetDest += 4;
                    }
                    offsetDestY += bitmapData.Stride;
                }
            }
            bitmap.UnlockBits(bitmapData);
            return(bitmap);
        }
Example #10
0
        public Wall(string name, string price, string desc, Bitmap[,] rotsByLods, GraphicsDevice gd, string spriteName)
        {
            myWallName = name;
            myWallDesc = desc;
            myWallPrice = price;
            mySpriteName = spriteName;
            myWallRotsS1 = new Texture2D[3,4];
            myGD = gd;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    MemoryStream ms = new MemoryStream();
                    Microsoft.Xna.Framework.Graphics.Color[] pixels = new Microsoft.Xna.Framework.Graphics.Color[rotsByLods[i, j].Height * rotsByLods[i, j].Width];
                    for (int k = 0; k < rotsByLods[i, j].Height; k++)
                    {
                        for (int l = 0; l < rotsByLods[i, j].Width; l++)
                        {
                            System.Drawing.Color currentColor = rotsByLods[i, j].GetPixel(l, k);
                            pixels[k * rotsByLods[i, j].Width + l] = new Microsoft.Xna.Framework.Graphics.Color(currentColor.R, currentColor.G, currentColor.B, currentColor.A);
                        }
                    }

                    myWallRotsS1[i, j] = new Texture2D(gd, rotsByLods[i, j].Width, rotsByLods[i, j].Height);
                    myWallRotsS1[i, j].SetData<Microsoft.Xna.Framework.Graphics.Color>(pixels);
                }
            }
            myWallRotsS2 = myWallRotsS1;
        }
Example #11
0
        private void SpriteSheetGenerator_Load(object sender, EventArgs e)
        {
            Array fileFormats = Enum.GetValues(typeof(ImageFileFormat));

            foreach (object format in fileFormats)
            {
                comboBoxFileFormat.Items.Add(format.ToString());
            }
            comboBoxFileFormat.SelectedItem = "Png";
            MilkshakePreferences prefs = MilkshakeForm.Instance.Preferences;

            this.LastInputDir  = ConvertStringToList(prefs.ToolSpritesheetLastInputFolder);
            this.LastOutputDir = ConvertStringToList(prefs.ToolSpritesheetLastOutputFolder);
            this.LastNames     = ConvertStringToList(prefs.ToolSpritesheetLastOutputName);
            LoadCombobox(comboBoxInputDir, this.LastInputDir);
            LoadCombobox(comboBoxOutputDir, this.LastOutputDir);
            LoadCombobox(comboBoxName, this.LastNames);
            numericUpDownSafeBorderSize.Value = (decimal)prefs.ToolSpritesheetLastSafeBorderSize;
            checkBoxAlphaCorrection.Checked   = prefs.ToolSpritesheetLastCorrectTransparencyColor;
            checkBoxOverrideBaseColor.Checked = prefs.ToolSpritesheetLastReplaceBaseColor;
            checkBoxPowerOf2.Checked          = prefs.ToolSpritesheetLastPadTexturePowerOfTwo;
            XnaColor backColor = prefs.ToolSpritesheetLastBaseColor;

            this.BaseTextureColor    = GdiColor.FromArgb(backColor.R, backColor.G, backColor.B);
            pictureBoxTint.BackColor = this.BaseTextureColor;
            CheckValidation();
        }
Example #12
0
        public Wall(string name, string price, string desc, Bitmap[,] rotsByLods, GraphicsDevice gd, string spriteName)
        {
            myWallName   = name;
            myWallDesc   = desc;
            myWallPrice  = price;
            mySpriteName = spriteName;
            myWallRotsS1 = new Texture2D[3, 4];
            myGD         = gd;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    MemoryStream ms = new MemoryStream();
                    Microsoft.Xna.Framework.Graphics.Color[] pixels = new Microsoft.Xna.Framework.Graphics.Color[rotsByLods[i, j].Height * rotsByLods[i, j].Width];
                    for (int k = 0; k < rotsByLods[i, j].Height; k++)
                    {
                        for (int l = 0; l < rotsByLods[i, j].Width; l++)
                        {
                            System.Drawing.Color currentColor = rotsByLods[i, j].GetPixel(l, k);
                            pixels[k * rotsByLods[i, j].Width + l] = new Microsoft.Xna.Framework.Graphics.Color(currentColor.R, currentColor.G, currentColor.B, currentColor.A);
                        }
                    }

                    myWallRotsS1[i, j] = new Texture2D(gd, rotsByLods[i, j].Width, rotsByLods[i, j].Height);
                    myWallRotsS1[i, j].SetData <Microsoft.Xna.Framework.Graphics.Color>(pixels);
                }
            }
            myWallRotsS2 = myWallRotsS1;
        }
Example #13
0
        public void Render(Microsoft.Xna.Framework.Graphics.Color XColor)
        {
            //myTexture = Texture2D.FromFile(device, fullPath);
            //textureScreenBuffer.GenerateMipMaps(TextureFilter.Point);

            //device.Clear(Microsoft.Xna.Framework.Graphics.Color.CornflowerBlue);
            device.Clear(XColor);

            // FOR BLOCKY PIXELS, USE THIS CODE
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
            device.SamplerStates[0].MagFilter = TextureFilter.Point;

            // FOR ANTI-ALIASED PIXELS, USE THIS CODE
            //spriteBatch.Begin();

            spriteBatch.Draw(textureScreenBuffer0, new Microsoft.Xna.Framework.Rectangle(0, 0, vdb.pnlNT2000.Width, vdb.pnlNT2000.Height), Microsoft.Xna.Framework.Graphics.Color.White);
            spriteBatch.Draw(textureScreenBuffer1, new Microsoft.Xna.Framework.Rectangle(512, 0, vdb.pnlNT2000.Width, vdb.pnlNT2000.Height), Microsoft.Xna.Framework.Graphics.Color.White);
            spriteBatch.Draw(textureScreenBuffer2, new Microsoft.Xna.Framework.Rectangle(0, 480, vdb.pnlNT2000.Width, vdb.pnlNT2000.Height), Microsoft.Xna.Framework.Graphics.Color.White);
            spriteBatch.Draw(textureScreenBuffer3, new Microsoft.Xna.Framework.Rectangle(512, 480, vdb.pnlNT2000.Width, vdb.pnlNT2000.Height), Microsoft.Xna.Framework.Graphics.Color.White);

            spriteBatch.End();

            //base.Update();
            device.Present();
        }
Example #14
0
        public override void DrawForPicking(IsometricView.SetPickingPixel setPixelDelegate, ushort UId)
        {
            Texture2D tex = GetCurrentTexture();

            Microsoft.Xna.Framework.Graphics.Color[] newTex = new Microsoft.Xna.Framework.Graphics.Color[tex.Width * tex.Height];
            tex.GetData <Microsoft.Xna.Framework.Graphics.Color>(newTex);

            int x_pos = ScreenPosition[0] + GameObject.GlobalXTranslation;
            int y_pos = ScreenPosition[1] + GameObject.GlobalYTranslation;

            for (int y = 0; y < tex.Height; y++)
            {
                for (int x = 0; x < tex.Width; x++)
                {
                    int i = tex.Width * y + x;

                    if (x_pos + x < 800 && y_pos + y < 600 && x_pos + x >= 0 && y_pos + y >= 0)
                    {
                        if (newTex[i].A != 0)
                        {
                            Microsoft.Xna.Framework.Graphics.Color c = new Microsoft.Xna.Framework.Graphics.Color((byte)myPosition[0], (byte)myPosition[1], (byte)(UId & 0xFF), (byte)(UId >> 8));
                            setPixelDelegate(c, x_pos + x, y_pos + y);
                        }
                        else
                        {
                            Microsoft.Xna.Framework.Graphics.Color c = new Microsoft.Xna.Framework.Graphics.Color(255, 255, 0, 0);
                            setPixelDelegate(c, x_pos + x, y_pos + y);
                        }
                    }
                }
            }
        }
Example #15
0
        public static Bitmap GetImageFromSprite( SpriteEd sprite )
        {
            try
            {
                Bitmap img = new Bitmap( sprite.Width, sprite.Height );
                Color[] colors = new Color[sprite.Width * sprite.Height];

                sprite.GetData<Color>( colors );

                int x;
                int y = -1;

                for( int i = 0; i < colors.Length; i++ )
                {
                    x = i % sprite.Width;
                    if( x == 0 )
                        y++;

                    img.SetPixel( x, y, Color2.FromArgb( colors[i].A, colors[i].R, colors[i].G, colors[i].B ) );
                }

                return img;
            }
            catch( Exception e )
            {
                MessageBox.Show( e.Message );
                return null;
            }
        }
Example #16
0
 public void Draw(SpriteBatch spriteBatch, Microsoft.Xna.Framework.Graphics.Color color, float Depth)
 {
     if (this.textTexture != null)
     {
         spriteBatch.Draw(this.textTexture, this.alignedPosition, null, color, 0f, Vector2.Zero, SpriteEffects.None, Depth + -0.0001f);
     }
 }
Example #17
0
            public int BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)
            {
                if (_Tex == null)
                {
                    _Tex = new Texture2D(parent._g, width, height, 1, TextureUsage.None, SurfaceFormat.Bgr32);
                }


                byte[] bgrData = new byte[BufferLen];
                Marshal.Copy(pBuffer, bgrData, 0, BufferLen);
                Color[] colorData = new Color[BufferLen / 3];
                for (int i = 0; i < colorData.Length; i++)
                {
                    colorData[i] = new Microsoft.Xna.Framework.Graphics.Color(bgrData[3 * i + 2], bgrData[3 * i + 1], bgrData[3 * i]);
                }
                _Tex.SetData <Microsoft.Xna.Framework.Graphics.Color>(colorData);

                GrabberInfo gi = new GrabberInfo();

                gi._Ptr = pBuffer;
                gi._Len = BufferLen;

                parent.NewFrame(gi);
                return(0);
            }
Example #18
0
 /// <summary>
 /// 绘制图像
 /// </summary>
 public virtual void Draw(SpriteBatch sprite)
 {
     var tmp = new SpriteEffects();
     if ((this.parameter & 1) == 1) { tmp = SpriteEffects.FlipHorizontally; }
     if ((this.parameter & 2) == 2) { tmp = tmp | SpriteEffects.FlipVertically; }
     this.color = new Color(color.R, color.G, color.B, this.alpha);
     sprite.Draw(this.texturearray[currentFrameIndex], this.position, null, this.color, this.rotate, this.origin, this.scale, tmp, this.layer);
 }
Example #19
0
        private void trackBarOpacity_Scroll(object sender, EventArgs e)
        {
            labelOpacity.Text = trackBarOpacity.Value.ToString();
            XnaColor newColor = TileGrid.Tint;

            newColor.A    = (byte)trackBarOpacity.Value;
            TileGrid.Tint = newColor;
        }
Example #20
0
 public FreeTextList()
 {
     this.TextList = new List<TextItem>();
     this.displayOffset = Microsoft.Xna.Framework.Point.Zero;
     this.align = TextAlign.None;
     this.textColor = Microsoft.Xna.Framework.Graphics.Color.Black;
     this.Builder = new FreeTextBuilder();
 }
Example #21
0
 public FreeTextList()
 {
     this.TextList      = new List <TextItem>();
     this.displayOffset = Microsoft.Xna.Framework.Point.Zero;
     this.align         = TextAlign.None;
     this.textColor     = Microsoft.Xna.Framework.Graphics.Color.Black;
     this.Builder       = new FreeTextBuilder();
 }
Example #22
0
 private void btnPlayer2_Click(object sender, EventArgs e)
 {
     colors = new ColorDialog();
     if (colors.ShowDialog() != DialogResult.Cancel)
     {
         picPlayer2.BackColor = colors.Color;
         player2Color         = new Microsoft.Xna.Framework.Graphics.Color(picPlayer2.BackColor.R, picPlayer2.BackColor.G, picPlayer2.BackColor.B, picPlayer2.BackColor.A);
     }
 }
Example #23
0
        internal static String GetHTMLFromColor(XnaColor color)
        {
            String html = "#";

            html += color.R.ToString("X2", CultureInfo.InvariantCulture);
            html += color.G.ToString("X2", CultureInfo.InvariantCulture);
            html += color.B.ToString("X2", CultureInfo.InvariantCulture);
            return(html);
        }
Example #24
0
 public FreeText(FreeTextBuilder builder)
 {
     this.position      = Microsoft.Xna.Framework.Rectangle.Empty;
     this.displayOffset = Microsoft.Xna.Framework.Point.Zero;
     this.align         = TextAlign.None;
     this.textColor     = Microsoft.Xna.Framework.Graphics.Color.Black;
     this.textTexture   = null;
     this.Builder       = builder;
 }
Example #25
0
        /// <summary>
        /// Method to draw a spritebatch 2d line, without primatives
        /// Source: http://www.xnawiki.com/index.php/Drawing_2D_lines_without_using_primitives
        /// </summary>
        /// <param name="width">width of line</param>
        /// <param name="color">color of line</param>
        /// <param name="point1">vertex 1 of ray</param>
        /// <param name="point2">vertex 2 of ray</param>
        /// <param name="spriteBatch">Sprite batch instance</param>
        /// <param name="blankTexture">Blank texture to use as a point</param>
        public static void Draw2DLine(float width, Microsoft.Xna.Framework.Graphics.Color color, Vector2 point1, Vector2 point2, SpriteBatch spriteBatch, Texture2D blankTexture)
        {
            float angle  = (float)Math.Atan2(point2.Y - point1.Y, point2.X - point1.X);
            float length = Vector2.Distance(point1, point2);

            spriteBatch.Draw(blankTexture, point1, null, color,
                             angle, Vector2.Zero, new Vector2(length, width),
                             SpriteEffects.None, 0);
        }
Example #26
0
 public TreeDemoControl()
 {
     CameraHeight    = 2000;
     BackgroundColor = Color.CornflowerBlue;
     Profiles        = new List <TreeProfile>();
     ProfileNames    = new List <string>();
     timer           = new Stopwatch();
     timer.Start();
 }
Example #27
0
 public FreeText(FreeTextBuilder builder)
 {
     this.position = Microsoft.Xna.Framework.Rectangle.Empty;
     this.displayOffset = Microsoft.Xna.Framework.Point.Zero;
     this.align = TextAlign.None;
     this.textColor = Microsoft.Xna.Framework.Graphics.Color.Black;
     this.textTexture = null;
     this.Builder = builder;
 }
Example #28
0
 public FreeText(GraphicsDevice device, Font font)
 {
     this.position      = Microsoft.Xna.Framework.Rectangle.Empty;
     this.displayOffset = Microsoft.Xna.Framework.Point.Zero;
     this.align         = TextAlign.None;
     this.textColor     = Microsoft.Xna.Framework.Graphics.Color.Black;
     this.textTexture   = null;
     this.Builder       = new FreeTextBuilder();
     this.Builder.SetFreeTextBuilder(device, font);
 }
Example #29
0
 public FreeText(GraphicsDevice device, Font font)
 {
     this.position = Microsoft.Xna.Framework.Rectangle.Empty;
     this.displayOffset = Microsoft.Xna.Framework.Point.Zero;
     this.align = TextAlign.None;
     this.textColor = Microsoft.Xna.Framework.Graphics.Color.Black;
     this.textTexture = null;
     this.Builder = new FreeTextBuilder();
     this.Builder.SetFreeTextBuilder(device, font);
 }
Example #30
0
 public FreeTextList(GraphicsDevice device, Font font, Microsoft.Xna.Framework.Graphics.Color color)
 {
     this.TextList      = new List <TextItem>();
     this.displayOffset = Microsoft.Xna.Framework.Point.Zero;
     this.align         = TextAlign.None;
     this.textColor     = Microsoft.Xna.Framework.Graphics.Color.Black;
     this.Builder       = new FreeTextBuilder();
     this.Builder.SetFreeTextBuilder(device, font);
     this.textColor = color;
 }
Example #31
0
 public RigidBody_c(Body_c b, Shape cg, HullMaker hull, float radius, Microsoft.Xna.Framework.Graphics.Color c)
 {
     maxRadius    = radius;
     body         = b;
     collideModel = cg;
     renderModel  = hull;
     id           = idcounter;
     colour       = c;
     idcounter++;
 }
Example #32
0
        private void Options_Load(object sender, EventArgs e)
        {
            highlight            = OptionsHolder.HighlightMoves;
            chkHighlight.Checked = highlight;
            player1Color         = OptionsHolder.Player1Color;
            player2Color         = OptionsHolder.Player2Color;

            picPlayer1.BackColor = System.Drawing.Color.FromArgb((int)player1Color.A, (int)player1Color.R, (int)player1Color.G, (int)player1Color.B);
            picPlayer2.BackColor = System.Drawing.Color.FromArgb(player2Color.A, player2Color.R, player2Color.G, player2Color.B);
        }
Example #33
0
 public FreeTextList(GraphicsDevice device, Font font, Microsoft.Xna.Framework.Graphics.Color color)
 {
     this.TextList = new List<TextItem>();
     this.displayOffset = Microsoft.Xna.Framework.Point.Zero;
     this.align = TextAlign.None;
     this.textColor = Microsoft.Xna.Framework.Graphics.Color.Black;
     this.Builder = new FreeTextBuilder();
     this.Builder.SetFreeTextBuilder(device, font);
     this.textColor = color;
 }
Example #34
0
        private Color MapToColor(CColor meshColor)
        {
            Color color = new Color();

            color.A = meshColor.A;
            color.B = meshColor.B;
            color.G = meshColor.G;
            color.R = meshColor.R;

            return(color);
        }
Example #35
0
 /// <summary>
 /// Notify this piece that it's been selected, and tint it a different colour so the user
 /// knows it too.
 /// </summary>
 /// <param name="select">Whether or not this level art has been selected by the editor</param>
 public void EditorSelect(bool select)
 {
     EditorSelected = select;
     if (EditorSelected)
     {
         Tint = Microsoft.Xna.Framework.Graphics.Color.Yellow;
     }
     else
     {
         Tint = Microsoft.Xna.Framework.Graphics.Color.White;
     }
 }
Example #36
0
        //public void SetWindowPos(IntPtr handle, bool topMost)
        //{
        //    const int HWND_TOPMOST = -1;
        //    const int HWND_NOTOPMOST = -2;
        //    const int SWP_SHOWWINDOW = 0x0040;
        //    const int SWP_HIDEWINDOW = 0x0080;
        //    const int SWP_NOREDRAW = 0x0008;

        //    if (topMost)
        //        SetWindowPos(handle, new IntPtr(HWND_TOPMOST), 0, 0, screenResX, screenResY, SWP_SHOWWINDOW);
        //    else
        //        SetWindowPos(handle, new IntPtr(HWND_NOTOPMOST), 0, 0, screenResX, screenResY, SWP_NOREDRAW);
        //}

        public void  CreateScreenSaver(int width, int height, Color titleFontColor, Color backColor, string fontName, int fontSize, FontStyle fontStyle)
        {
            screenSaverSize      = Utils.ScaleDimension(width, height, screenResX - (int)(100 * ratioX), screenResY - (int)(150 * ratioY));
            screenSaverX         = (screenResX - screenSaverSize.Width) / 2 - 1;
            screenSaverY         = (((screenResY - (int)(150 * ratioY)) - screenSaverSize.Height) / 2) + (int)(50 * ratioY) - 1;
            screenSaverFontColor = titleFontColor;
            screenSaverBackcolor = backColor;
            screenSaverTitle     = new CLabel(0, screenResY - (int)(100 * ratioY), screenResX, (int)(50 * ratioY), "",
                                              fontName, fontSize, fontStyle, screenSaverFontColor, screenSaverBackcolor,
                                              TextAlign.Center, false);
            CreateArrow();
        }
Example #37
0
        public CLabel CreateStarLabel(string keyname, int posX, int posY, int width, int height, string text,
                                      int fontSize, FontStyle fontStyle,
                                      Color fontColor, Color backColor, bool isVisible)
        {
            var newItem = new CLabel(posX, posY, width, height, text,
                                     "Wingdings", 9, FontStyle.Regular, fontColor, backColor, TextAlign.Center, true);

            newItem.KeyName = keyname;
            newItem.Visible = isVisible;
            labels.Add(newItem);
            return(newItem);
        }
Example #38
0
        public void CustomInitialize()
        {
            mOldCameraSetup     = CameraSave.FromCamera(SpriteManager.Camera);
            mOldBackgroundColor = SpriteManager.Camera.BackgroundColor;
            SpriteManager.Camera.UsePixelCoordinates();
            SpriteManager.Camera.BackgroundColor = Color.Black;
            CurrentState = VariableState.Transparent;

            mOldTimeSpan = FlatRedBallServices.Game.TargetElapsedTime;
            // Go to 10 fps to make loading go faster
            FlatRedBallServices.Game.TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 100);;
        }
Example #39
0
		public void CustomInitialize()
		{
            mOldCameraSetup = CameraSave.FromCamera(SpriteManager.Camera);
            mOldBackgroundColor = SpriteManager.Camera.BackgroundColor;
            SpriteManager.Camera.UsePixelCoordinates();
            SpriteManager.Camera.BackgroundColor = Color.Black;
            CurrentState = VariableState.Transparent;

            mOldTimeSpan = FlatRedBallServices.Game.TargetElapsedTime;
            // Go to 10 fps to make loading go faster
            FlatRedBallServices.Game.TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 100); ;

		}
Example #40
0
 internal void FlashColour(Color colour, int duration)
 {
     if (StartColour == colour)
     {
         return;
     }
     lock (this)
         Transformations.RemoveAll(t => t.Type == TransformationType.Colour);
     Transformations.Add(
         new Transformation(colour, StartColour,
                            GameBase.GetTime(Clock) - (int)GameBase.ElapsedMilliseconds,
                            GameBase.GetTime(Clock) + duration));
 }
Example #41
0
 public void RefreshObjects(string defaultImageFile, Color saverFontColor, Color saverBackColor)
 {
     if (screenSaverImage != null)
     {
         screenSaverImage.FileNotFoundName = defaultImageFile;
     }
     labels.RemoveAll(c => c.KeyName.StartsWith("RomListLabel_"));
     labels.RemoveAll(c => c.KeyName.StartsWith("RomListStarLabel_"));
     screenSaverFontColor       = saverFontColor;
     screenSaverBackcolor       = saverBackColor;
     screenSaverTitle.ForeColor = screenSaverFontColor;
     screenSaverTitle.BackColor = screenSaverBackcolor;
 }
Example #42
0
 //protected Rectangle rectangle;
 public StaticGraphic(Device graphicDevice, string source, Vector2 position,
                                   float rotate, float scale, Color color, byte alpha, byte parameter)
 {
     this.texturearray = new Texture2D[] { Texture2D.FromFile(graphicDevice, source) };
     this.origin = new Vector2(0, 0);
     this.position = position;
     this.rotate = rotate;
     this.scale = new Vector2(scale, scale);
     this.layer = 0;
     this.color = color;
     this.alpha = alpha;
     this.parameter = parameter;
     this.currentFrameIndex = 0;
 }
 internal void Draw(SpriteBatch spriteBatch)
 {
     if (this.ShowingFaction != null)
     {
         Microsoft.Xna.Framework.Rectangle? sourceRectangle = null;
         spriteBatch.Draw(this.BackgroundTexture, this.BackgroundDisplayPosition, sourceRectangle, Microsoft.Xna.Framework.Graphics.Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.2f);
         foreach (LabelText text in this.LabelTexts)
         {
             text.Label.Draw(spriteBatch, 0.1999f);
             text.Text.Draw(spriteBatch, 0.1999f);
         }
         foreach (TechniqueItem item in this.AllTechniques)
         {
             Microsoft.Xna.Framework.Graphics.Color white = Microsoft.Xna.Framework.Graphics.Color.White;
             Microsoft.Xna.Framework.Graphics.Color black = Microsoft.Xna.Framework.Graphics.Color.Black;
             if (item == this.current)
             {
                 white = new Microsoft.Xna.Framework.Graphics.Color((byte) 150, (byte) 150, (byte) 150);
                 black = Microsoft.Xna.Framework.Graphics.Color.White;
             }
             item.Text.Draw(spriteBatch, black, 0.1989f);
             if (this.ShowingFaction.IsTechniqueUpgrading(item.LinkedTechnique.ID))
             {
                 sourceRectangle = null;
                 spriteBatch.Draw(this.ButtonUpgradingTexture, item.Position, sourceRectangle, white, 0f, Vector2.Zero, SpriteEffects.None, 0.199f);
             }
             else if (this.ShowingFaction.HasTechnique(item.LinkedTechnique.ID))
             {
                 sourceRectangle = null;
                 spriteBatch.Draw(this.ButtonUpgradedTexture, item.Position, sourceRectangle, white, 0f, Vector2.Zero, SpriteEffects.None, 0.199f);
             }
             else if (this.Control && this.ShowingFaction.MatchTechnique(item.LinkedTechnique, this.UpgradingArchitecture))
             {
                 sourceRectangle = null;
                 spriteBatch.Draw(this.ButtonAvailableTexture, item.Position, sourceRectangle, white, 0f, Vector2.Zero, SpriteEffects.None, 0.199f);
             }
             else
             {
                 sourceRectangle = null;
                 spriteBatch.Draw(this.ButtonBasicTexture, item.Position, sourceRectangle, white, 0f, Vector2.Zero, SpriteEffects.None, 0.199f);
             }
         }
         this.CommentsText.Draw(spriteBatch, 0.1999f);
     }
 }
        public override void Draw(GameTime gameTime)
        {
            bool mouseInside = MouseIsInside();

            // For now we just pretend tiles can be either solid or not, no in-between:
            if (conflict)
            {
                Color = new Microsoft.Xna.Framework.Graphics.Color(255, 0, 255);
            }
            else if (destructable)
            {
                if (mouseInside)
                {
                    Color = new Microsoft.Xna.Framework.Graphics.Color(255, 127, 127);
                }
                else
                {
                    Color = new Microsoft.Xna.Framework.Graphics.Color(255, 0, 0);
                }
            }
            else
            {
                Color = new Microsoft.Xna.Framework.Graphics.Color(1.0f, 1.0f, 1.0f, (mouseInside ? 0.8f : 0.5f));
            }
            Vector2 topLeft = new Vector2(Bounds.Left, Bounds.Top);
            Vector2 topRight = new Vector2(Bounds.Right, Bounds.Top);
            Vector2 bottomLeft = new Vector2(Bounds.Left, Bounds.Bottom);
            Vector2 bottomRight = new Vector2(Bounds.Right, Bounds.Bottom);

            PrimitiveDrawer.Instance.DrawLine(SpriteBatch, topLeft, bottomRight, Color);
            PrimitiveDrawer.Instance.DrawLine(SpriteBatch, topLeft + (bottomLeft - topLeft) * (2.0f / 3.0f),
                                                           bottomRight - (bottomRight - bottomLeft) * (2.0f / 3.0f), Color);
            PrimitiveDrawer.Instance.DrawLine(SpriteBatch, topLeft + (bottomLeft - topLeft) * (1.0f / 3.0f),
                                                           bottomRight - (bottomRight - bottomLeft) * (1.0f / 3.0f), Color);
            PrimitiveDrawer.Instance.DrawLine(SpriteBatch, topLeft + (topRight - topLeft) * (1.0f / 3.0f),
                                                           bottomRight - (bottomRight - topRight) * (1.0f / 3.0f), Color);
            PrimitiveDrawer.Instance.DrawLine(SpriteBatch, topLeft + (topRight - topLeft) * (2.0f / 3.0f),
                                                           bottomRight - (bottomRight - topRight) * (2.0f / 3.0f), Color);
            base.Draw(gameTime);
        }
Example #45
0
        public override void DrawForPicking(IsometricView.SetPickingPixel setPixelDelegate, ushort UId)
        {
            int x_pos = ScreenPosition[0] + GameObject.GlobalXTranslation;
            int y_pos = ScreenPosition[1] + GameObject.GlobalYTranslation;

            x_pos -= Width;
            y_pos -= Height / 4;

            if (x_pos + Width < 0 || x_pos > 800 || y_pos + Height > 600 || y_pos < 0)
                return;

            Texture2D tex = myFloorLods[DrawSize];
            Microsoft.Xna.Framework.Graphics.Color[] newTex = new Microsoft.Xna.Framework.Graphics.Color[tex.Width * tex.Height];
            tex.GetData<Microsoft.Xna.Framework.Graphics.Color>(newTex);

            for (int y = tex.Height - 1; y >= 0; y--)
            {
                for (int x = 0; x < tex.Width; x++)
                {
                    int i = tex.Width * y + x;

                    if (x_pos + x < 800 && y_pos + y < 600 && x_pos + x >= 0 && y_pos + y >= 0)
                    {
                        if (newTex[i].A != 0)
                        {
                            Microsoft.Xna.Framework.Graphics.Color c = new Microsoft.Xna.Framework.Graphics.Color((byte)myPosition[0], (byte)myPosition[1], (byte)(UId & 0xFF), (byte)(UId >> 8));
                            setPixelDelegate(c, x_pos + x, y_pos + y);
                        }
                        else
                        {
                            Microsoft.Xna.Framework.Graphics.Color c = new Microsoft.Xna.Framework.Graphics.Color(255, 255, 0, 0);
                            setPixelDelegate(c, x_pos + x, y_pos + y);
                        }
                    }
                }
            }
        }
Example #46
0
 public override void Clear(G.Color color)
 {
     if (color != backgroundColor)
     {
         Canvas.Background = new SolidColorBrush(color.ToSilverlightColor());
         backgroundColor = color;
     }
 }
        int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)
        {
            if (deviceNumber == 1)
            {
                int j = 0;
            }
            Marshal.Copy(pBuffer, bgrData, 0, BufferLen);
            Color[] colorData = new Color[BufferLen / 3];
            int colIdx = colorData.Length - 1;
            for (int i = 0; i < colorData.Length; i++)
            {
                colorData[i] = new Microsoft.Xna.Framework.Graphics.Color(bgrData[3 * i + 2], bgrData[3 * i + 1], bgrData[3 * i]);
            }
            if (swapA)
            {
                camTextureA.SetData<Microsoft.Xna.Framework.Graphics.Color>(colorData);
            }
            else
            {
                camTextureB.SetData<Microsoft.Xna.Framework.Graphics.Color>(colorData);
            }
            swapA = !swapA;

            return 0;
        }
 public static void LoadFontAndColorFromXMLNode(XmlNode node, out Font font, out Microsoft.Xna.Framework.Graphics.Color color)
 {
     font = new Font(node.Attributes.GetNamedItem("FontName").Value, float.Parse(node.Attributes.GetNamedItem("FontSize").Value), (FontStyle) Enum.Parse(typeof(FontStyle), node.Attributes.GetNamedItem("FontStyle").Value));
     color = new Microsoft.Xna.Framework.Graphics.Color();
     color.PackedValue = uint.Parse(node.Attributes.GetNamedItem("FontColor").Value);
 }
 public void LoadDataFromXMLDocument(string filename)
 {
     XmlNode node3;
     Font font;
     Microsoft.Xna.Framework.Graphics.Color color;
     XmlDocument document = new XmlDocument();
     document.Load(filename);
     XmlNode nextSibling = document.FirstChild.NextSibling;
     XmlNode node = nextSibling.ChildNodes.Item(0);
     this.personDetail.BackgroundSize.X = int.Parse(node.Attributes.GetNamedItem("Width").Value);
     this.personDetail.BackgroundSize.Y = int.Parse(node.Attributes.GetNamedItem("Height").Value);
     this.personDetail.BackgroundTexture = Texture2D.FromFile(this.graphicsDevice, @"GameComponents\PersonDetail\Data\" + node.Attributes.GetNamedItem("FileName").Value);
     node = nextSibling.ChildNodes.Item(1);
     Microsoft.Xna.Framework.Rectangle rectangle = StaticMethods.LoadRectangleFromXMLNode(node);
     StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
     this.personDetail.SurNameText = new FreeText(this.graphicsDevice, font, color);
     this.personDetail.SurNameText.Position = rectangle;
     this.personDetail.SurNameText.Align = (TextAlign) Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value);
     node = nextSibling.ChildNodes.Item(2);
     rectangle = StaticMethods.LoadRectangleFromXMLNode(node);
     StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
     this.personDetail.GivenNameText = new FreeText(this.graphicsDevice, font, color);
     this.personDetail.GivenNameText.Position = rectangle;
     this.personDetail.GivenNameText.Align = (TextAlign) Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value);
     node = nextSibling.ChildNodes.Item(3);
     rectangle = StaticMethods.LoadRectangleFromXMLNode(node);
     StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
     this.personDetail.CalledNameText = new FreeText(this.graphicsDevice, font, color);
     this.personDetail.CalledNameText.Position = rectangle;
     this.personDetail.CalledNameText.Align = (TextAlign) Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value);
     node = nextSibling.ChildNodes.Item(4);
     this.personDetail.PortraitClient = StaticMethods.LoadRectangleFromXMLNode(node);
     node = nextSibling.ChildNodes.Item(5);
     for (int i = 0; i < node.ChildNodes.Count; i += 2)
     {
         LabelText item = new LabelText();
         node3 = node.ChildNodes.Item(i);
         rectangle = StaticMethods.LoadRectangleFromXMLNode(node3);
         StaticMethods.LoadFontAndColorFromXMLNode(node3, out font, out color);
         item.Label = new FreeText(this.graphicsDevice, font, color);
         item.Label.Position = rectangle;
         item.Label.Align = (TextAlign) Enum.Parse(typeof(TextAlign), node3.Attributes.GetNamedItem("Align").Value);
         item.Label.Text = node3.Attributes.GetNamedItem("Label").Value;
         node3 = node.ChildNodes.Item(i + 1);
         rectangle = StaticMethods.LoadRectangleFromXMLNode(node3);
         StaticMethods.LoadFontAndColorFromXMLNode(node3, out font, out color);
         item.Text = new FreeText(this.graphicsDevice, font, color);
         item.Text.Position = rectangle;
         item.Text.Align = (TextAlign) Enum.Parse(typeof(TextAlign), node3.Attributes.GetNamedItem("Align").Value);
         item.PropertyName = node3.Attributes.GetNamedItem("PropertyName").Value;
         this.personDetail.LabelTexts.Add(item);
     }
     node = nextSibling.ChildNodes.Item(6);
     this.personDetail.TitleClient = StaticMethods.LoadRectangleFromXMLNode(node);
     this.personDetail.TitleText.ClientWidth = this.personDetail.TitleClient.Width;
     this.personDetail.TitleText.ClientHeight = this.personDetail.TitleClient.Height;
     this.personDetail.TitleText.RowMargin = int.Parse(node.Attributes.GetNamedItem("RowMargin").Value);
     StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
     this.personDetail.TitleText.Builder.SetFreeTextBuilder(this.graphicsDevice, font);
     this.personDetail.TitleText.DefaultColor = color;
     node = nextSibling.ChildNodes.Item(7);
     this.personDetail.SkillBlockSize.X = int.Parse(node.Attributes.GetNamedItem("Width").Value);
     this.personDetail.SkillBlockSize.Y = int.Parse(node.Attributes.GetNamedItem("Height").Value);
     this.personDetail.SkillDisplayOffset.X = int.Parse(node.Attributes.GetNamedItem("OffsetX").Value);
     this.personDetail.SkillDisplayOffset.Y = int.Parse(node.Attributes.GetNamedItem("OffsetY").Value);
     StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
     this.personDetail.AllSkillTexts = new FreeTextList(this.graphicsDevice, font, color);
     this.personDetail.AllSkillTexts.Align = (TextAlign) Enum.Parse(typeof(TextAlign), node.Attributes.GetNamedItem("Align").Value);
     Microsoft.Xna.Framework.Graphics.Color color2 = new Microsoft.Xna.Framework.Graphics.Color {
         PackedValue = uint.Parse(node.Attributes.GetNamedItem("SkillColor").Value)
     };
     this.personDetail.PersonSkillTexts = new FreeTextList(this.graphicsDevice, font, color2);
     this.personDetail.PersonSkillTexts.Align = this.personDetail.AllSkillTexts.Align;
     Microsoft.Xna.Framework.Graphics.Color color3 = new Microsoft.Xna.Framework.Graphics.Color {
         PackedValue = uint.Parse(node.Attributes.GetNamedItem("LearnableColor").Value)
     };
     this.personDetail.LearnableSkillTexts = new FreeTextList(this.graphicsDevice, font, color3);
     this.personDetail.LearnableSkillTexts.Align = this.personDetail.AllSkillTexts.Align;
     node = nextSibling.ChildNodes.Item(8);
     this.personDetail.StuntClient = StaticMethods.LoadRectangleFromXMLNode(node);
     this.personDetail.StuntText.ClientWidth = this.personDetail.StuntClient.Width;
     this.personDetail.StuntText.ClientHeight = this.personDetail.StuntClient.Height;
     this.personDetail.StuntText.RowMargin = int.Parse(node.Attributes.GetNamedItem("RowMargin").Value);
     StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
     this.personDetail.StuntText.Builder.SetFreeTextBuilder(this.graphicsDevice, font);
     this.personDetail.StuntText.DefaultColor = color;
     node = nextSibling.ChildNodes.Item(9);
     this.personDetail.InfluenceClient = StaticMethods.LoadRectangleFromXMLNode(node);
     this.personDetail.InfluenceText.ClientWidth = this.personDetail.InfluenceClient.Width;
     this.personDetail.InfluenceText.ClientHeight = this.personDetail.InfluenceClient.Height;
     this.personDetail.InfluenceText.RowMargin = int.Parse(node.Attributes.GetNamedItem("RowMargin").Value);
     this.personDetail.InfluenceText.TitleColor = StaticMethods.LoadColor(node.Attributes.GetNamedItem("TitleColor").Value);
     this.personDetail.InfluenceText.SubTitleColor = StaticMethods.LoadColor(node.Attributes.GetNamedItem("SubTitleColor").Value);
     this.personDetail.InfluenceText.SubTitleColor2 = StaticMethods.LoadColor(node.Attributes.GetNamedItem("SubTitleColor2").Value);
     this.personDetail.InfluenceText.SubTitleColor3 = StaticMethods.LoadColor(node.Attributes.GetNamedItem("SubTitleColor3").Value);
     StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
     this.personDetail.InfluenceText.Builder.SetFreeTextBuilder(this.graphicsDevice, font);
     this.personDetail.InfluenceText.DefaultColor = color;
     node = nextSibling.ChildNodes.Item(10);
     this.personDetail.ConditionClient = StaticMethods.LoadRectangleFromXMLNode(node);
     this.personDetail.ConditionText.ClientWidth = this.personDetail.ConditionClient.Width;
     this.personDetail.ConditionText.ClientHeight = this.personDetail.ConditionClient.Height;
     this.personDetail.ConditionText.RowMargin = int.Parse(node.Attributes.GetNamedItem("RowMargin").Value);
     this.personDetail.ConditionText.TitleColor = StaticMethods.LoadColor(node.Attributes.GetNamedItem("TitleColor").Value);
     this.personDetail.ConditionText.SubTitleColor = StaticMethods.LoadColor(node.Attributes.GetNamedItem("SubTitleColor").Value);
     this.personDetail.ConditionText.PositiveColor = StaticMethods.LoadColor(node.Attributes.GetNamedItem("PositiveColor").Value);
     this.personDetail.ConditionText.NegativeColor = StaticMethods.LoadColor(node.Attributes.GetNamedItem("NegativeColor").Value);
     StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
     this.personDetail.ConditionText.Builder.SetFreeTextBuilder(this.graphicsDevice, font);
     this.personDetail.ConditionText.DefaultColor = color;
     node = nextSibling.ChildNodes.Item(11);
     this.personDetail.BiographyClient = StaticMethods.LoadRectangleFromXMLNode(node);
     this.personDetail.BiographyText.ClientWidth = this.personDetail.BiographyClient.Width;
     this.personDetail.BiographyText.ClientHeight = this.personDetail.BiographyClient.Height;
     this.personDetail.BiographyText.RowMargin = int.Parse(node.Attributes.GetNamedItem("RowMargin").Value);
     this.personDetail.BiographyText.TitleColor = StaticMethods.LoadColor(node.Attributes.GetNamedItem("TitleColor").Value);
     this.personDetail.BiographyText.SubTitleColor = StaticMethods.LoadColor(node.Attributes.GetNamedItem("SubTitleColor").Value);
     this.personDetail.BiographyText.SubTitleColor2 = StaticMethods.LoadColor(node.Attributes.GetNamedItem("SubTitleColor2").Value);
     StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
     this.personDetail.BiographyText.Builder.SetFreeTextBuilder(this.graphicsDevice, font);
     this.personDetail.BiographyText.DefaultColor = color;
     /*
     node = nextSibling.ChildNodes.Item(12);
     this.personDetail.GuanzhiClient = StaticMethods.LoadRectangleFromXMLNode(node);
     this.personDetail.GuanzhiText.ClientWidth = this.personDetail.GuanzhiClient.Width;
     this.personDetail.GuanzhiText.ClientHeight = this.personDetail.GuanzhiClient.Height;
     this.personDetail.GuanzhiText.RowMargin = int.Parse(node.Attributes.GetNamedItem("RowMargin").Value);
     StaticMethods.LoadFontAndColorFromXMLNode(node, out font, out color);
     this.personDetail.GuanzhiText.Builder.SetFreeTextBuilder(this.graphicsDevice, font);
     this.personDetail.GuanzhiText.DefaultColor = color;
      */
 }
        /// <summary>
        /// Initializes the control.
        /// </summary>
        protected override void OnCreateControl()
        {
            // Don't initialize the graphics device if we are running in the designer.
            if (!DesignMode)
            {
                graphicsDeviceService = GraphicsDeviceService.AddRef(Handle,
                                                                     ClientSize.Width,
                                                                     ClientSize.Height);

                // Register the service, so components like ContentManager can find it.
                services.AddService<IGraphicsDeviceService>(graphicsDeviceService);

                // Give derived classes a chance to initialize themselves.
                Initialize( );
                LoadContent( );
                UnloadContent( );

                Global.GraphicsDevice = GraphicsDevice;

                Color2[] color = new Color2[1] { Color2.White };
                Global.Pixel = new Texture2D( GraphicsDevice, 1, 1, 1, TextureUsage.None, SurfaceFormat.Color );
                Global.Pixel.SetData<Color2>( color );
            }

            base.OnCreateControl();
        }
Example #51
0
        /// <summary>
        /// 建立贴图并添加到缓冲中。
        /// 尽量在第一次绘制之前调用该函数,这样可以避免建立贴图的过程造成游戏的停滞
        /// </summary>
        /// <param name="text">要创建的字符串</param>
        /// <param name="fontName">字体</param>
        /// <returns></returns>
        public Texture2D BuildTexture( string text, string fontName )
        {
            TextKey key = new TextKey( text, fontName );

            if (cache.ContainsKey( key ))
                return null;

            if (!fonts.ContainsKey( fontName ))
            {
                Log.Write( "error fontName used in BuildTexture" );
                return null;
            }

            System.Drawing.Font font = fonts[fontName];

            System.Drawing.SizeF size = mesureGraphics.MeasureString( text, font );
            int texWidth = (int)size.Width;
            int texHeight = (int)size.Height;

            System.Drawing.Bitmap textMap = new System.Drawing.Bitmap( texWidth, texHeight );
            System.Drawing.Graphics curGraphics = System.Drawing.Graphics.FromImage( textMap );
            curGraphics.DrawString( text, font, System.Drawing.Brushes.White, new System.Drawing.PointF() );

            Texture2D texture = new Texture2D( engine.Device, texWidth, texHeight, 1, TextureUsage.None, SurfaceFormat.Color );
            Microsoft.Xna.Framework.Graphics.Color[] data = new Microsoft.Xna.Framework.Graphics.Color[texWidth * texHeight];
            for (int y = 0; y < texHeight; y++)
            {
                for (int x = 0; x < texWidth; x++)
                {
                    data[y * texWidth + x] = ConvertHelper.SysColorToXNAColor( textMap.GetPixel( x, y ) );
                }
            }

            texture.SetData<Microsoft.Xna.Framework.Graphics.Color>( data );

            cache.Add( key, texture );

            curGraphics.Dispose();

            return texture;
        }
Example #52
0
        public override void DrawForPicking(IsometricView.SetPickingPixel setPixelDelegate, ushort UId)
        {
            Texture2D tex = GetCurrentTexture();
            Microsoft.Xna.Framework.Graphics.Color[] newTex = new Microsoft.Xna.Framework.Graphics.Color[tex.Width * tex.Height];
            tex.GetData<Microsoft.Xna.Framework.Graphics.Color>(newTex);

            int x_pos = ScreenPosition[0] + GameObject.GlobalXTranslation;
            int y_pos = ScreenPosition[1] + GameObject.GlobalYTranslation;

            for (int y = 0; y < tex.Height; y++)
            {
                for (int x = 0; x < tex.Width; x++)
                {
                    int i = tex.Width * y + x;

                    if (x_pos + x < 800 && y_pos + y < 600 && x_pos + x >= 0 && y_pos + y >= 0)
                    {
                        if (newTex[i].A != 0)
                        {
                            Microsoft.Xna.Framework.Graphics.Color c = new Microsoft.Xna.Framework.Graphics.Color((byte)myPosition[0], (byte)myPosition[1], (byte)(UId & 0xFF), (byte)(UId >> 8));
                            setPixelDelegate(c, x_pos + x, y_pos + y);
                        }
                        else
                        {
                            Microsoft.Xna.Framework.Graphics.Color c = new Microsoft.Xna.Framework.Graphics.Color(255, 255, 0, 0);
                            setPixelDelegate(c, x_pos + x, y_pos + y);
                        }
                    }
                }
            }
        }
 public static Microsoft.Xna.Framework.Graphics.Color LoadColor(String code)
 {
     Microsoft.Xna.Framework.Graphics.Color color = new Microsoft.Xna.Framework.Graphics.Color();
     color.PackedValue = uint.Parse(code);
     return color;
 }
Example #54
0
 public static GdiColor GetGDIColor(XnaColor color)
 {
     return System.Drawing.Color.FromArgb(255,
         (int)color.R, (int)color.G, (int)color.B);
 }
Example #55
0
 private Texture2D CreateSelectionBoxTexture(int width, int height)
 {
     Texture2D selectionBox = new Texture2D(Game.GraphicsDevice, width, height, 1, TextureUsage.None, SurfaceFormat.Color);
     int count = selectionBox.Width * selectionBox.Height;
     Color[] colorArray = new Color[count];
     for (int i = 0; i < count; i++)
         colorArray[i] = _selectionBoxColor;
     selectionBox.SetData<Color>(colorArray);
     return selectionBox;
 }
Example #56
0
        public static Texture2D ManualTextureMask(Texture2D Texture, Microsoft.Xna.Framework.Graphics.Color AlphaColor, Microsoft.Xna.Framework.Graphics.Color NonAlphaColor)
        {
            Microsoft.Xna.Framework.Graphics.Color[] data = new Microsoft.Xna.Framework.Graphics.Color[Texture.Width * Texture.Height];
            Texture.GetData(data);

            for (int i = 0; i < data.Length; i++)
            {
                data[i].A = 255;
                if (data[i].A != 0)
                    data[i] = NonAlphaColor;
                else
                    data[i] = AlphaColor;
            }

            Texture2D ret = new Texture2D(Texture.GraphicsDevice, Texture.Width, Texture.Height);

            ret.SetData(data);

            return ret;
        }
Example #57
0
 internal static String GetHTMLFromColor(XnaColor color)
 {
     String html = "#";
     html += color.R.ToString("X2", CultureInfo.InvariantCulture);
     html += color.G.ToString("X2", CultureInfo.InvariantCulture);
     html += color.B.ToString("X2", CultureInfo.InvariantCulture);
     return html;
 }
 private Microsoft.Xna.Framework.Graphics.Color[] GetColorDataFromTexture(Texture2D texture)
 {
     var colors = new Microsoft.Xna.Framework.Graphics.Color[texture.Width * texture.Height];
     texture.GetData(colors);
     return colors;
 }
Example #59
0
        public static SpriteEd GetSpriteFromImage( GraphicsDevice graphicsDevice, Bitmap image )
        {
            try
            {
                SpriteEd sprite = new SpriteEd( graphicsDevice, image.Width, image.Height, 1, TextureUsage.None, SurfaceFormat.Color );
                Color[] colors = new Color[image.Width * image.Height];

                int x;
                int y = -1;

                for ( int i = 0; i < colors.Length; i++ )
                {
                    x = i % image.Width;
                    if ( x == 0 )
                        y++;

                    colors[i] = ColorToXNAColor( image.GetPixel( x, y ) );
                }

                sprite.SetData( colors );
                sprite.Bitmap = image;
                return sprite;
            }
            catch ( Exception e )
            {
                ErrorReport.Throw( e );
                return null;
            }
        }
Example #60
0
 public static Color Lerp( Color color1, Color color2, float amount )
 {
     return new Color( Lerp( color1.R, color2.R, amount ), Lerp( color1.G, color2.G, amount ), Lerp( color1.B, color2.B, amount ) );
 }