Exemple #1
0
        private void picPalette_Click(object sender, EventArgs e)
        {
            var          mouseEventArgs = (MouseEventArgs)e;
            PaletteImage image          = _selectedPalette.HitTest(mouseEventArgs.Location);

            SetSelectedImage(image);
        }
Exemple #2
0
        /**<summary>Draws the path scaffold supports.</summary>*/
        public void DrawScaffoldSupport(PaletteImage p, Point position, DrawSettings drawSettings, int rotation)
        {
            int offset = 109;

            if (drawSettings.Slope == -1)
            {
                graphicsData.paletteImages[offset + (rotation % 2 == 0 ? 46 : 22)].DrawWithOffset(p,
                                                                                                  Point.Add(position, new Size(12, 32 - 6)), drawSettings.Darkness, false);
            }
            else
            {
                int offset2 = 0;
                switch (drawSettings.Slope)
                {
                case 0: offset2 = 5; break;

                case 1: offset2 = 11; break;

                case 2: offset2 = 8; break;

                case 3: offset2 = 2; break;
                }
                graphicsData.paletteImages[offset + (drawSettings.Slope % 2 == 0 ? 24 : 0) + offset2].DrawWithOffset(p,
                                                                                                                     Point.Add(position, new Size(12, 32 - 6)), drawSettings.Darkness, false);
                graphicsData.paletteImages[offset + (drawSettings.Slope % 2 == 0 ? 47 : 23)].DrawWithOffset(p,
                                                                                                            Point.Add(position, new Size(12, 16 - 6)), drawSettings.Darkness, false);
                offset = 164;
                graphicsData.paletteImages[offset + (drawSettings.Slope + 3) % 4].DrawWithOffset(p,
                                                                                                 Point.Add(position, new Size(12, -6)), drawSettings.Darkness, false);
            }
        }
Exemple #3
0
        /**<summary>Draws the path base.</summary>*/
        public void DrawPath(PaletteImage p, Point position, DrawSettings drawSettings, uint pathConnections)
        {
            if (drawSettings.Elevation > 0 && !Header.Flags.HasFlag(FootpathFlags.OverlayPath))
            {
                return;
            }

            int offset = (drawSettings.Queue ? 51 : 0);

            if (drawSettings.Slope == -1)
            {
                int connection = 0;
                if (PathSpriteIndexes.ContainsKey(pathConnections))
                {
                    connection = PathSpriteIndexes[pathConnections];
                }
                else if (PathSpriteIndexes.ContainsKey(pathConnections & 0xF))
                {
                    connection = PathSpriteIndexes[pathConnections & 0xF];
                }

                graphicsData.paletteImages[offset + connection].DrawWithOffset(p, position, drawSettings.Darkness, false);
            }
            else
            {
                graphicsData.paletteImages[offset + 16 + (drawSettings.Slope + 3) % 4].DrawWithOffset(p, position, drawSettings.Darkness, false);
            }
        }
Exemple #4
0
        private void DrawFrame(PaletteImage p, Point position, DrawSettings drawSettings, int frame, bool glass)
        {
            bool offset = Header.Flags.HasFlag(SmallSceneryFlags.Offset);
            bool fullSquare = Header.Flags.HasFlag(SmallSceneryFlags.FullSquare);
            bool half = Header.Flags.HasFlag(SmallSceneryFlags.HalfSpace);
            bool threeFourths = Header.Flags.HasFlag(SmallSceneryFlags.ThreeFourthsSpace);
            int  cornerX = 0, cornerY = 0;

            switch (drawSettings.Corner)
            {
            case 0: cornerX = -16; cornerY = 0; break;

            case 1: cornerX = 0; cornerY = -8; break;

            case 2: cornerX = 16; cornerY = 0; break;

            case 3: cornerX = 0; cornerY = 8; break;
            }

            graphicsData.paletteImages[frame].DrawWithOffset(p,
                                                             position.X + (fullSquare ? 0 : cornerX) + (offset ? 0 : 0) + (half ? 0 : 0),
                                                             position.Y + (fullSquare ? 0 : cornerY) + (offset ? (!fullSquare ? 13 : 0) + (half ? 11 : 0) + 3 : 16) + (half ? -12 : 0),
                                                             drawSettings.Darkness, glass,
                                                             (Header.Flags.HasFlag(SmallSceneryFlags.Color1) || Header.Flags.HasFlag(SmallSceneryFlags.Color2)) ? drawSettings.Remap1 : RemapColors.None,
                                                             (Header.Flags.HasFlag(SmallSceneryFlags.Color2) || (Header.Flags.HasFlag(SmallSceneryFlags.Color1) && glass)) ? (glass ? drawSettings.Remap1 : drawSettings.Remap2) : RemapColors.None,
                                                             RemapColors.None
                                                             );
        }
 private void DrawFrame(PaletteImage p, Point position, DrawSettings drawSettings, int frame)
 {
     graphicsData.paletteImages[frame].DrawWithOffset(p, position, drawSettings.Darkness, false,
                                                      (Header.Flags.HasFlag(LargeSceneryFlags.Color1) || Header.Flags.HasFlag(LargeSceneryFlags.Color2)) ? drawSettings.Remap1 : RemapColors.None,
                                                      (Header.Flags.HasFlag(LargeSceneryFlags.Color2)) ? drawSettings.Remap2 : RemapColors.None,
                                                      RemapColors.None
                                                      );
 }
        //=========== DRAWING ============
        #region Drawing

        /** <summary> Constructs the default object. </summary> */
        public override bool Draw(PaletteImage p, Point position, DrawSettings drawSettings)
        {
            try {
                graphicsData.paletteImages[drawSettings.Frame].Draw(p, Point.Add(position, new Size(-16, -14)), 0, false, RemapColors.SeaGreen);
            }
            catch (IndexOutOfRangeException) { return(false); }
            catch (ArgumentOutOfRangeException) { return(false); }
            return(true);
        }
 /**<summary>Draws the object data in the dialog.</summary>*/
 public override bool DrawDialog(PaletteImage p, Point position, Size dialogSize, DrawSettings drawSettings)
 {
     try {
         graphicsData.paletteImages[Header.PreviewIndex].Draw(p, position, drawSettings.Darkness, false);
     }
     catch (IndexOutOfRangeException) { return(false); }
     catch (ArgumentOutOfRangeException) { return(false); }
     return(true);
 }
 /**<summary>Inserts the specified palette image at the specified index.</summary>*/
 public void Insert(int index, PaletteImage paletteImage)
 {
     if (paletteImage != null)
     {
         paletteImages.Insert(index, paletteImage);
         palettes.Insert(index, null);
         imageDirectory.entries.Insert(index, paletteImage.entry);
         numImages++;
     }
 }
 /**<summary>Adds the specified palette image.</summary>*/
 public void Add(PaletteImage paletteImage)
 {
     paletteImages.Add(paletteImage);
     palettes.Add(null);
     imageDirectory.entries.Add(paletteImage.entry);
     if (paletteImage != null)
     {
         numImages++;
     }
 }
Exemple #10
0
        public void BasicImageTest()
        {
            Bitmap b = new Bitmap(1, 1);
            Color  c = Color.FromArgb(255, 255, 0, 0);

            b.SetPixel(0, 0, c);
            PaletteImage p = new PaletteImage(b);

            Assert.AreEqual(c, p.baseImage.GetPixel(0, 0));
        }
Exemple #11
0
 /**<summary>Draws the object data in the dialog.</summary>*/
 public override bool DrawDialog(PaletteImage p, Point position, Size dialogSize, DrawSettings drawSettings)
 {
     try {
         position = Point.Add(position, new Size(dialogSize.Width / 2, dialogSize.Height / 2));
         graphicsData.paletteImages[0].DrawWithOffset(p, Point.Add(position, new Size(-20, -16)), drawSettings.Darkness, false);
     }
     catch (IndexOutOfRangeException) { return(false); }
     catch (ArgumentOutOfRangeException) { return(false); }
     return(true);
 }
Exemple #12
0
        private void DrawDialogFrame(PaletteImage p, Point position, DrawSettings drawSettings, int frame, bool glass)
        {
            Size offset = new Size(16, 16);

            graphicsData.paletteImages[frame].DrawWithOffset(p, Point.Add(position, offset), drawSettings.Darkness, glass,
                                                             (Header.Flags.HasFlag(WallFlags.Remap1) || Header.Flags.HasFlag(WallFlags.Remap2) || Header.Flags.HasFlag(WallFlags.Remap3)) ? drawSettings.Remap1 : (glass ? drawSettings.Remap1 : RemapColors.None),
                                                             (Header.Flags.HasFlag(WallFlags.Remap2) || Header.Flags.HasFlag(WallFlags.Remap3)) ? (glass ? drawSettings.Remap1 : drawSettings.Remap2) : (glass ? drawSettings.Remap1 : RemapColors.None),
                                                             Header.Flags.HasFlag(WallFlags.Remap3) ? (glass ? drawSettings.Remap1 : drawSettings.Remap3) : (glass ? drawSettings.Remap1 : RemapColors.None)
                                                             );
        }
 /**<summary>Removes the specified palette image.</summary>*/
 public void Remove(PaletteImage paletteImage)
 {
     if (paletteImage != null)
     {
         int index = paletteImages.IndexOf(paletteImage);
         paletteImages.RemoveAt(index);
         palettes.RemoveAt(index);
         imageDirectory.entries.RemoveAt(index);
         numImages--;
     }
 }
 /**<summary>Draws the object data in the dialog.</summary>*/
 public override bool DrawDialog(PaletteImage p, Point position, Size dialogSize, DrawSettings drawSettings)
 {
     try {
         graphicsData.paletteImages[drawSettings.Rotation].DrawWithOffset(p, Point.Add(position, new Size(dialogSize.Width / 2, (dialogSize.Height - 78) / 2)),
                                                                          drawSettings.Darkness, false,
                                                                          (Header.Flags.HasFlag(LargeSceneryFlags.Color1) || Header.Flags.HasFlag(LargeSceneryFlags.Color2)) ? drawSettings.Remap1 : RemapColors.None,
                                                                          (Header.Flags.HasFlag(LargeSceneryFlags.Color2)) ? drawSettings.Remap2 : RemapColors.None,
                                                                          RemapColors.None
                                                                          );
     }
     catch (IndexOutOfRangeException) { return(false); }
     catch (ArgumentOutOfRangeException) { return(false); }
     return(true);
 }
Exemple #15
0
        //=========== DRAWING ============
        #region Drawing

        /** <summary> Constructs the default object. </summary> */
        public override bool Draw(PaletteImage p, Point position, DrawSettings drawSettings)
        {
            try {
                bool fullSquare   = Header.Flags.HasFlag(SmallSceneryFlags.FullSquare);
                bool drawMain2    = Header.Flags.HasFlag(SmallSceneryFlags.DrawMainTwo);
                bool dialogFrames = Header.Flags.HasFlag(SmallSceneryFlags.DialogFrames);
                bool glass        = Header.Flags.HasFlag(SmallSceneryFlags.Glass);
                bool spray1       = Header.Flags.HasFlag(SmallSceneryFlags.FountainSpray1);
                bool spray4       = Header.Flags.HasFlag(SmallSceneryFlags.FountainSpray4);
                bool clock        = Header.Flags.HasFlag(SmallSceneryFlags.Clock);
                bool animation    = Header.Flags.HasFlag(SmallSceneryFlags.Animation);

                int offset = (dialogFrames ? 4 : 0);

                if (spray1)
                {
                    DrawFrame(p, position, drawSettings, offset + drawSettings.Rotation, false);
                    DrawFrame(p, position, drawSettings, offset + 4 + drawSettings.Rotation + drawSettings.Frame * 4, false);
                }
                else if (spray4)
                {
                    DrawFrame(p, position, drawSettings, offset + drawSettings.Rotation, false);
                    DrawFrame(p, position, drawSettings, offset + 8 + drawSettings.Rotation + drawSettings.Frame * 4, false);
                    DrawFrame(p, position, drawSettings, offset + 4 + drawSettings.Rotation, false);
                    DrawFrame(p, position, drawSettings, offset + 24 + drawSettings.Rotation + drawSettings.Frame * 4, false);
                }
                else if (clock)
                {
                    DrawFrame(p, position, drawSettings, offset + drawSettings.Rotation, false);
                    DrawFrame(p, position, drawSettings, offset + 68 + (drawSettings.Frame / 15 + drawSettings.Rotation * 12) % 48, false);
                    DrawFrame(p, position, drawSettings, offset + 8 + (drawSettings.Frame % 60 + drawSettings.Rotation * 15) % 60, false);
                }
                else
                {
                    DrawFrame(p, position, drawSettings, offset + drawSettings.Rotation + drawSettings.Frame * 4, false);
                    if (drawMain2)
                    {
                        DrawFrame(p, position, drawSettings, offset + 4 + drawSettings.Rotation + drawSettings.Frame * 4, false);
                    }
                    else if (glass)
                    {
                        DrawFrame(p, position, drawSettings, offset + 4 + drawSettings.Rotation + drawSettings.Frame * 4, true);
                    }
                }
            }
            catch (IndexOutOfRangeException) { return(false); }
            catch (ArgumentOutOfRangeException) { return(false); }
            return(true);
        }
Exemple #16
0
 public Texture(UpperString name, ResourceNamespace resourceNamespace, Shader shader,
                RgbaImage rgbaImage, PaletteImage paletteImage = null)
 {
     Name      = name;
     Namespace = resourceNamespace;
     Material  = new Material(shader)
     {
         mainTexture = rgbaImage.ToTexture(),
         name        = $"{name.String} ({resourceNamespace})"
     };
     Dimension        = rgbaImage.Dimension;
     InverseDimension = new Vector2(1.0f / Dimension.Width, 1.0f / Dimension.Height);
     Rgba             = new Optional <RgbaImage>(rgbaImage);
     Palette          = new Optional <PaletteImage>(paletteImage);
 }
Exemple #17
0
        //=========== DRAWING ============
        #region Drawing

        /**<summary>Constructs the default object.</summary>*/
        public override bool Draw(PaletteImage p, Point position, DrawSettings drawSettings)
        {
            try {
                WaterSprites[2].DrawWithOffset(p, Point.Add(position, new Size(0, 0)), drawSettings.Darkness, false);
                WaterSprites[3].DrawWithOffset(p, Point.Add(position, new Size(2, 0)), drawSettings.Darkness, false);
                WaterSprites[4].DrawWithOffset(p, Point.Add(position, new Size(-2, 0)), drawSettings.Darkness, false);
                WaterSprites[3].DrawWithOffset(p, Point.Add(position, new Size(-30, 16)), drawSettings.Darkness, false);
                WaterSprites[4].DrawWithOffset(p, Point.Add(position, new Size(30, 16)), drawSettings.Darkness, false);

                WaterSprites[0].DrawWithOffset(p, Point.Add(position, new Size(0, -15)), drawSettings.Darkness, true);
                WaterSprites[1].DrawWithOffset(p, Point.Add(position, new Size(0, -15)), drawSettings.Darkness, false);
            }
            catch (IndexOutOfRangeException) { return(false); }
            catch (ArgumentOutOfRangeException) { return(false); }
            return(true);
        }
Exemple #18
0
        /**<summary>Constructs the default object.</summary>*/
        public override bool Draw(PaletteImage p, Point position, DrawSettings drawSettings)
        {
            position.Y -= drawSettings.Elevation * 2;
            if (drawSettings.Queue)
            {
                drawSettings.PathConnections &= 0x0000000F;
            }
            int offset = (drawSettings.Queue ? 51 : 0);

            bool[,] connections = new bool[5, 5];

            for (int x = 0; x < 5; x++)
            {
                for (int y = 0; y < 5; y++)
                {
                    connections[x, y] = false;
                }
            }

            switch (drawSettings.Slope)
            {
            case 0:
            case 2: drawSettings.PathConnections = Convert.ToByte("1010", 2); break;

            case 1:
            case 3: drawSettings.PathConnections = Convert.ToByte("0101", 2); break;
            }

            connections[2, 2] = true;

            connections[3, 2] = (drawSettings.PathConnections & Convert.ToByte("00000001", 2)) != 0;
            connections[2, 3] = (drawSettings.PathConnections & Convert.ToByte("00000010", 2)) != 0;
            connections[1, 2] = (drawSettings.PathConnections & Convert.ToByte("00000100", 2)) != 0;
            connections[2, 1] = (drawSettings.PathConnections & Convert.ToByte("00001000", 2)) != 0;

            connections[3, 3] = (drawSettings.PathConnections & Convert.ToByte("00010000", 2)) != 0;
            connections[1, 3] = (drawSettings.PathConnections & Convert.ToByte("00100000", 2)) != 0;
            connections[1, 1] = (drawSettings.PathConnections & Convert.ToByte("01000000", 2)) != 0;
            connections[3, 1] = (drawSettings.PathConnections & Convert.ToByte("10000000", 2)) != 0;

            try {
                DrawPathParts(p, position, drawSettings, connections);
            }
            catch (IndexOutOfRangeException) { return(false); }
            catch (ArgumentOutOfRangeException) { return(false); }
            return(true);
        }
Exemple #19
0
        //=========== DRAWING ============
        #region Drawing

        /**<summary>Constructs the default object.</summary>*/
        public override bool Draw(PaletteImage p, Point position, DrawSettings drawSettings)
        {
            try {
                if (Header.Flags.HasFlag(PathAdditionFlags.JumpFountain) || Header.Flags.HasFlag(PathAdditionFlags.JumpSnowball))
                {
                    graphicsData.paletteImages[1 + 0].DrawWithOffset(p, position, drawSettings.Darkness, false);
                    graphicsData.paletteImages[1 + 1].DrawWithOffset(p, position, drawSettings.Darkness, false);
                    graphicsData.paletteImages[1 + 2].DrawWithOffset(p, position, drawSettings.Darkness, false);
                    graphicsData.paletteImages[1 + 3].DrawWithOffset(p, position, drawSettings.Darkness, false);
                }
                else
                {
                    Size offset = Size.Empty;
                    if (Header.Subtype == PathAdditionSubtypes.Bench || Header.Subtype == PathAdditionSubtypes.LitterBin)
                    {
                        switch (drawSettings.Rotation)
                        {
                        case 0: offset = new Size(16 - 4, 8 + 2); break;

                        case 1: offset = new Size(16 - 4, 24 - 4); break;

                        case 2: offset = new Size(-16 + 4, 24 - 4); break;

                        case 3: offset = new Size(-16 + 4, 8 + 4); break;
                        }
                    }
                    else
                    {
                        switch (drawSettings.Rotation)
                        {
                        case 0: offset = new Size(16, 8); break;

                        case 1: offset = new Size(16, 24); break;

                        case 2: offset = new Size(-16, 24); break;

                        case 3: offset = new Size(-16, 8); break;
                        }
                    }
                    graphicsData.paletteImages[1 + drawSettings.Rotation].DrawWithOffset(p, Point.Add(position, offset), drawSettings.Darkness, false);
                }
            }
            catch (IndexOutOfRangeException) { return(false); }
            catch (ArgumentOutOfRangeException) { return(false); }
            return(true);
        }
 /**<summary>Sets the specified palette image at the specified index.</summary>*/
 public void Set(int index, PaletteImage paletteImage)
 {
     if (paletteImage != null)
     {
         if (this.paletteImages[index] == null)
         {
             this.numImages++;
             if (this.palettes[index] != null)
             {
                 this.palettes[index] = null;
                 this.numPalettes--;
             }
         }
         this.paletteImages[index]          = paletteImage;
         this.imageDirectory.entries[index] = paletteImage.entry;
     }
 }
 /**<summary>Sets the specified palette image at the specified index.</summary>*/
 public void Set(int index, PaletteImage paletteImage)
 {
     if (paletteImage != null)
     {
         if (paletteImages[index] == null)
         {
             numImages++;
             if (palettes[index] != null)
             {
                 palettes[index] = null;
                 numPalettes--;
             }
         }
         paletteImages[index]          = paletteImage;
         imageDirectory.entries[index] = paletteImage.entry;
     }
 }
        //=========== DRAWING ============
        #region Drawing

        /**<summary>Constructs the default object.</summary>*/
        public override bool Draw(PaletteImage p, Point position, DrawSettings drawSettings)
        {
            try {
                graphicsData.paletteImages[drawSettings.Rotation * 2 + 0].DrawWithOffset(p, position, drawSettings.Darkness, false,
                                                                                         Header.Flags.HasFlag(PathBannerFlags.Color1) ? drawSettings.Remap1 : RemapColors.None,
                                                                                         RemapColors.None,
                                                                                         RemapColors.None
                                                                                         );
                graphicsData.paletteImages[drawSettings.Rotation * 2 + 1].DrawWithOffset(p, position, drawSettings.Darkness, false,
                                                                                         Header.Flags.HasFlag(PathBannerFlags.Color1) ? drawSettings.Remap1 : RemapColors.None,
                                                                                         RemapColors.None,
                                                                                         RemapColors.None
                                                                                         );
            }
            catch (IndexOutOfRangeException) { return(false); }
            catch (ArgumentOutOfRangeException) { return(false); }
            return(true);
        }
Exemple #23
0
        private void ChangeTabIcon(object sender, EventArgs e)
        {
            if (this.openFileDialogIcon.ShowDialog(this) == DialogResult.OK)
            {
                try {
                    this.sceneryGroup.GraphicsData.Set(0, PaletteImage.FromBuffer(Resources.TabBack));
                    this.sceneryGroup.GraphicsData.Set(1, PaletteImage.FromBuffer(Resources.TabFront));

                    Bitmap icon             = (Bitmap)Bitmap.FromFile(this.openFileDialogIcon.FileName);
                    Color  transparentColor = icon.GetPixel(0, 0);

                    for (int i = 0; i < 2; i++)
                    {
                        for (int x = 0; x < this.sceneryGroup.GraphicsData.GetPaletteImage(i).Width; x++)
                        {
                            for (int y = 0; y < this.sceneryGroup.GraphicsData.GetPaletteImage(i).Height; y++)
                            {
                                if (x < icon.Width && y < icon.Height && (i == 1 || y < 26))
                                {
                                    int colorIndex = FindClosestColor(icon.GetPixel(x, y), transparentColor);
                                    if (colorIndex != 0)
                                    {
                                        this.sceneryGroup.GraphicsData.GetPaletteImage(i).Pixels[x, y] = (byte)colorIndex;
                                    }
                                }
                            }
                        }
                    }

                    Graphics g = Graphics.FromImage(this.iconImage);

                    PaletteImage icon2 = this.sceneryGroup.GraphicsData.GetPaletteImage(1);
                    icon2.Draw(g, (46 - icon2.Width) / 2, (46 - icon2.Height) / 2, Palette.SceneryGroupPalette);
                    g.Dispose();

                    this.iconView.Image = this.iconImage;

                    changed = true;
                }
                catch (Exception) {
                    ErrorMessageBox.Show(this, "Error using image for tab icon.", "File may not be an image.");
                }
            }
        }
 /**<summary>Draws the object data in the dialog.</summary>*/
 public override bool DrawDialog(PaletteImage p, Point position, Size dialogSize, DrawSettings drawSettings)
 {
     try {
         position = Point.Add(position, new Size(dialogSize.Width / 2, dialogSize.Height / 2));
         graphicsData.paletteImages[drawSettings.Rotation * 2 + 0].DrawWithOffset(p, position, drawSettings.Darkness, false,
                                                                                  Header.Flags.HasFlag(PathBannerFlags.Color1) ? drawSettings.Remap1 : RemapColors.None,
                                                                                  RemapColors.None,
                                                                                  RemapColors.None
                                                                                  );
         graphicsData.paletteImages[drawSettings.Rotation * 2 + 1].DrawWithOffset(p, position, drawSettings.Darkness, false,
                                                                                  Header.Flags.HasFlag(PathBannerFlags.Color1) ? drawSettings.Remap1 : RemapColors.None,
                                                                                  RemapColors.None,
                                                                                  RemapColors.None
                                                                                  );
     }
     catch (IndexOutOfRangeException) { return(false); }
     catch (ArgumentOutOfRangeException) { return(false); }
     return(true);
 }
Exemple #25
0
        private void SetSelectedImage(PaletteImage image)
        {
            PictureBox picSelectedImage = Controls.Find("picSelectedImage", true).First() as PictureBox;

            if (picSelectedImage == null)
            {
                throw new Exception("Control [picSelectedImage] not found on form.");
            }

            Label lblSelectedImage = Controls.Find("lblSelectedImage", true).First() as Label;

            if (lblSelectedImage == null)
            {
                throw new Exception("Control [lblSelectedImage] not found on form.");
            }

            picSelectedImage.Image = image?.Bitmap;
            lblSelectedImage.Text  = image?.Name;
            _selectedImage         = image;
        }
Exemple #26
0
        /**<summary>Draws the path pole supports.</summary>*/
        public void DrawPoleSupport(PaletteImage p, Point position, DrawSettings drawSettings)
        {
            position.Y += drawSettings.Elevation * 2;
            if (drawSettings.Slope != -1)
            {
                position.Y -= drawSettings.Elevation / 2;
            }
            int offset = 129;

            while (drawSettings.Elevation > 8)
            {
                graphicsData.paletteImages[offset + 15].DrawWithOffset(p,
                                                                       position, drawSettings.Darkness, false);
                drawSettings.Elevation -= 8;
                position.Y             += 16;
            }
            if (Header.Flags.HasFlag(FootpathFlags.PoleBase))
            {
                position.Y -= 6;
                graphicsData.paletteImages[offset + 9].DrawWithOffset(p,
                                                                      position, drawSettings.Darkness, false);
                int slopeOffset = 17;
                switch (drawSettings.Slope)
                {
                case 0: slopeOffset = 19; break;

                case 1: slopeOffset = 25; break;

                case 2: slopeOffset = 26; break;

                case 3: slopeOffset = 20; break;
                }
                graphicsData.paletteImages[offset + slopeOffset].DrawWithOffset(p,
                                                                                Point.Add(position, new Size(0, 6)), drawSettings.Darkness, false);
            }
            else
            {
                graphicsData.paletteImages[offset + 15].DrawWithOffset(p,
                                                                       position, drawSettings.Darkness, false);
            }
        }
Exemple #27
0
        /**<summary>Draws all 4 parts of the path in order.</summary>*/
        public void DrawPathParts(PaletteImage p, Point position, DrawSettings drawSettings, bool[,] connections)
        {
            int[] indexes = { 7, 3, 0, 6, -1, 4, 2, 1, 5 };
            int   slope   = drawSettings.Slope;

            for (int type = 0; type < 4; type++)
            {
                for (int i = 0; i < indexes.Length; i++)
                {
                    if (indexes[i] == -1)
                    {
                        drawSettings.Slope = slope;
                        switch (type)
                        {
                        case 0: DrawSupports(p, position, drawSettings, Math.Max(0, slope), drawSettings.PathConnections); break;

                        case 1: DrawElevatedPath(p, position, drawSettings, Math.Max(0, slope), drawSettings.PathConnections); break;

                        case 2: DrawPath(p, position, drawSettings, drawSettings.PathConnections); break;

                        case 3: DrawRailing(p, position, drawSettings, drawSettings.PathConnections); break;
                        }
                        drawSettings.Slope = -1;
                    }
                    else if ((drawSettings.PathConnections & (1 << indexes[i])) != 0)
                    {
                        switch (type)
                        {
                        case 0: DrawSupports(p, GetConnectionPoint(position, indexes[i], slope), drawSettings, Math.Max(0, slope), ConvertConnections(connections, indexes[i])); break;

                        case 1: DrawElevatedPath(p, GetConnectionPoint(position, indexes[i], slope), drawSettings, Math.Max(0, slope), ConvertConnections(connections, indexes[i])); break;

                        case 2: DrawPath(p, GetConnectionPoint(position, indexes[i], slope), drawSettings, ConvertConnections(connections, indexes[i])); break;

                        case 3: DrawRailing(p, GetConnectionPoint(position, indexes[i], slope), drawSettings, ConvertConnections(connections, indexes[i])); break;
                        }
                    }
                }
            }
        }
Exemple #28
0
        /**<summary>Draws the elevated path.</summary>*/
        public void DrawElevatedPath(PaletteImage p, Point position, DrawSettings drawSettings, int rotation, uint pathConnections)
        {
            if (drawSettings.Elevation == 0)
            {
                return;
            }

            int offset     = 109;
            int connection = 0;

            if (PathSpriteIndexes.ContainsKey(pathConnections & 0xF))
            {
                connection = PathSpriteIndexes[pathConnections & 0xF];
            }

            if (drawSettings.Slope == -1)
            {
                if (Header.Flags.HasFlag(FootpathFlags.PoleSupports))
                {
                    graphicsData.paletteImages[offset + connection].DrawWithOffset(p, position, drawSettings.Darkness, false);
                }
                else
                {
                    offset = 158;
                    graphicsData.paletteImages[offset + ((rotation + 1) % 2)].DrawWithOffset(p, position, drawSettings.Darkness, false);
                }
            }
            else
            {
                if (Header.Flags.HasFlag(FootpathFlags.PoleSupports))
                {
                    graphicsData.paletteImages[offset + 16 + (drawSettings.Slope + 3) % 4].DrawWithOffset(p, position, drawSettings.Darkness, false);
                }
                else
                {
                    offset = 158;
                    graphicsData.paletteImages[offset + 2 + (drawSettings.Slope + 3) % 4].DrawWithOffset(p, position, drawSettings.Darkness, false);
                }
            }
        }
Exemple #29
0
        //=========== DRAWING ============
        #region Drawing

        /** <summary> Constructs the default object. </summary> */
        public override bool Draw(PaletteImage p, Point position, DrawSettings drawSettings)
        {
            try {
                bool flat      = Header.Flags.HasFlag(WallFlags.Flat);
                bool twoSides  = Header.Flags.HasFlag(WallFlags.TwoSides);
                bool door      = Header.Flags.HasFlag(WallFlags.Door);
                bool glass     = Header.Flags.HasFlag(WallFlags.Glass);
                bool animation = ((Header.Effects >> 4) & 0x1) == 0x1;

                int offset        = (2 + (!flat ? 4 : 0)) * (twoSides ? 2 : 1) * (door ? 2 : 1);
                int slopeRotation = (drawSettings.Rotation % (twoSides ? 4 : 2)) * (door ? 2 : 1);
                if (drawSettings.Slope >= 0 && !flat)
                {
                    if (drawSettings.Slope % 2 != drawSettings.Rotation % 2)
                    {
                        if (drawSettings.Slope >= 2)
                        {
                            slopeRotation = (7 - drawSettings.Slope) * (door ? 2 : 1);
                        }
                        else
                        {
                            slopeRotation = (3 - drawSettings.Slope) * (door ? 2 : 1);
                        }
                    }
                }

                DrawFrame(p, position, drawSettings, slopeRotation + drawSettings.Frame * offset, false);
                if (door)
                {
                    DrawFrame(p, position, drawSettings, slopeRotation + 1 + drawSettings.Frame * offset, false);
                }
                if (glass)
                {
                    DrawFrame(p, position, drawSettings, offset + slopeRotation + drawSettings.Frame * offset, true);
                }
            }
            catch (IndexOutOfRangeException) { return(false); }
            catch (ArgumentOutOfRangeException) { return(false); }
            return(true);
        }
Exemple #30
0
        //=========== DRAWING ============
        #region Drawing

        /** <summary> Constructs the default object. </summary> */
        public override bool Draw(PaletteImage p, Point position, DrawSettings drawSettings)
        {
            try {
                int xoffset = ((drawSettings.Rotation == 1 || drawSettings.Rotation == 2) ? -32 : 32);
                int yoffset = ((drawSettings.Rotation == 2 || drawSettings.Rotation == 3) ? -16 : 16);
                if (drawSettings.Rotation >= 2)
                {
                    xoffset *= -1; yoffset *= -1;
                }
                int sideFrame = (drawSettings.Rotation < 2 ? 0 : 1);

                graphicsData.paletteImages[drawSettings.Rotation * 3 + 1 + sideFrame].DrawWithOffset(p,
                                                                                                     Point.Add(position, new Size(-xoffset, -yoffset)), drawSettings.Darkness, false);
                graphicsData.paletteImages[drawSettings.Rotation * 3 + 0].DrawWithOffset(p,
                                                                                         position, drawSettings.Darkness, false);
                graphicsData.paletteImages[drawSettings.Rotation * 3 + 2 - sideFrame].DrawWithOffset(p,
                                                                                                     Point.Add(position, new Size(xoffset, yoffset)), drawSettings.Darkness, false);
            }
            catch (IndexOutOfRangeException) { return(false); }
            catch (ArgumentOutOfRangeException) { return(false); }
            return(true);
        }