Esempio n. 1
0
 // Export
 private void Export_Architecture()
 {
     byte[] array = new byte[0x80000];
     ExportPalette(array, 0);
     ExportGraphics(array, 0x200);
     ExportTileset(array, 0, 0x10200);
     ExportTileset(array, 1, 0x11200);
     ExportTileset(array, 2, 0x12200);
     ExportTilemap(array, 0, 0x13200);
     ExportTilemap(array, 1, 0x33200);
     ExportTilemap(array, 2, 0x53200);
     ExportPriority(array, 0x73200);
     Do.Export(array, "", fullPath);
 }
Esempio n. 2
0
 public void Clear(int startIndex)
 {
     for (int i = startIndex; i < count; i++)
     {
         for (int a = 0; a < size; a++)
         {
             Reds[i * size + a]   = 0;
             Greens[i * size + a] = 0;
             Blues[i * size + a]  = 0;
         }
     }
     palette  = Do.RGBToColors(Reds, Greens, Blues);
     palettes = Do.RGBToColors(Reds, Greens, Blues, count, size);
 }
Esempio n. 3
0
        public int[] GetPreview(Glyph[] font, int[] palette, char[] text, bool shadow)
        {
            this.font    = font;
            this.palette = palette;
            int[] pixels = new int[256 * 16];

            // While there are more characters to draw
            for (int i = 0, c = 0; i < text.Length; i++)
            {
                if (text[i] >= 0x20 && text[i] <= 0x9F)
                {
                    int   width       = font[text[i] - 32].Width;
                    int   maxWidth    = font[text[i] - 32].MaxWidth;
                    int[] glyphPixels = font[text[i] - 32].GetPixels(palette);
                    int   left        = (maxWidth - width) / 2;

                    // 12 rows per character
                    for (int y = 0, b = 1; y < 12; y++, b++)
                    {
                        for (int x = 0, a = shadow ? c + 1 : c + left + 1; x < 8; x++, a++) // # of pixels per row
                        {
                            if (pixels[b * 256 + a] == 0)
                            {
                                pixels[b * 256 + a] = glyphPixels[y * maxWidth + x];
                            }
                        }
                    }
                    if (shadow)
                    {
                        c += Math.Max(font[text[i] - 32].GetRightMostPixel(palette), width + 1);
                    }
                    else
                    {
                        c += 8;
                    }
                }
            }
            if (shadow)
            {
                Do.DrawShadow(pixels, 256, palette[3]);
            }
            else
            {
                Do.DrawBorder(pixels, 256, palette[3]);
            }

            // Finished
            return(pixels);
        }
Esempio n. 4
0
 private void InitializeApplicationHistory()
 {
     if (form.Name == "Editor")
     {
         Do.AddHistory("LOADED LAZY SHELL APPLICATION");
     }
     else if (form.Name != "SpritePartitions" &&
              form.Name != "PaletteEditor" &&
              form.Name != "GraphicEditor" &&
              form.Name != "TileEditor" &&
              form.Name != "NPCEditor")
     {
         Do.AddHistory("OPENED FORM \"" + form.Name + "\"");
     }
 }
Esempio n. 5
0
        private void CheckedChanged(object sender, EventArgs e)
        {
            if (!LoggingAccept(sender))
            {
                return;
            }
            var    control = sender as CheckBox;
            string temp    = "\"" + control.Name + "\" | ";

            temp += "Checked = " + control.Checked;
            temp += " | Form \"" + form.Name + "\"";
            AddElementIndex(ref temp);
            //
            Do.AddHistory(temp);
            dateTime = DateTime.Now;
        }
Esempio n. 6
0
        private void SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!LoggingAccept(sender))
            {
                return;
            }
            string temp = "";

            if (sender is ComboBox)
            {
                var control = sender as ComboBox;
                temp += "\"" + control.Name + "\" | ";
                temp += "SelectedIndex = " + control.SelectedIndex;
            }
            else if (sender is Controls.NewToolStripComboBox)
            {
                var control = sender as Controls.NewToolStripComboBox;
                temp += "\"" + control.Name + "\" | ";
                temp += "SelectedIndex = " + control.SelectedIndex;
            }
            else if (sender is CheckedListBox || sender is Controls.NewCheckedListBox)
            {
                var control = sender as CheckedListBox;
                temp += "\"" + control.Name + "\" | ";
                if (control.SelectedItem == null)
                {
                    return;
                }
                temp += "\"" + control.SelectedItem.ToString().Trim() + "\" = ";
                temp += control.GetItemChecked(control.SelectedIndex);
            }
            else if (sender is ListBox || sender is Controls.NewListBox)
            {
                var control = sender as ListBox;
                temp += "\"" + control.Name + "\" | ";
                if (control.SelectedItem == null)
                {
                    return;
                }
                temp += "\"" + control.SelectedItem.ToString().Trim();
            }
            temp += " | Form \"" + form.Name + "\"";
            AddElementIndex(ref temp);
            //
            Do.AddHistory(temp);
            dateTime = DateTime.Now;
        }
Esempio n. 7
0
 private void SetSubtileImage()
 {
     int[] temp   = new int[8 * 8];
     int[] pixels = new int[64 * 64];
     Do.PixelsToPixels(
         tile.Subtiles[currentSubtile].Pixels,
         temp, 8, new Rectangle(0, 0, 8, 8));
     for (int y = 0; y < 64; y++)
     {
         for (int x = 0; x < 64; x++)
         {
             pixels[y * 64 + x] = temp[y / 8 * 8 + (x / 8)];
         }
     }
     subtileImage = Do.PixelsToImage(pixels, 64, 64);
     pictureBoxSubtile.Invalidate();
 }
Esempio n. 8
0
        private void MouseDown(object sender, MouseEventArgs e)
        {
            if (!LoggingAccept(sender))
            {
                return;
            }
            mouseDownControl = true;
            var    control = sender as Control;
            string temp    = "\"" + control.Name + "\" | ";

            temp += "MouseDown = (X:" + e.X + ",Y:" + e.Y + ")";
            temp += " | Form \"" + form.Name + "\"";
            AddElementIndex(ref temp);
            //
            Do.AddHistory(temp);
            dateTime = DateTime.Now;
        }
Esempio n. 9
0
 /// <summary>
 /// Performs a color math operation by applying the values of an RGB pixel array to another.
 /// Both arrays must be the same size.
 /// </summary>
 /// <param name="src">The pixels to apply to the destination array.</param>
 /// <param name="dst">The RGB pixel array to perform the operation on.</param>
 /// <param name="width">The width, in pixels, of the pixel maps.</param>
 /// <param name="height">The height, in pixels, of the pixel maps.</param>
 /// <param name="halfIntensity">Indicates whether to add the pixels at half their RGB value.</param>
 /// <param name="minusSubscreen">Indicates whether to subtract the pixels instead of adding them.</param>
 public static void ColorMath(int[] src, int[] dst, int width, int height, bool halfIntensity, bool minusSubscreen)
 {
     if (src == null || dst == null)
     {
         return;
     }
     for (int y = 0; y < height; y++)
     {
         for (int x = 0; x < width; x++)
         {
             if (src[y * width + x] != 0 && dst[y * width + x] != 0)
             {
                 dst[y * width + x] = Do.ColorMath(dst[y * width + x], src[y * width + x], halfIntensity, minusSubscreen);
             }
         }
     }
 }
Esempio n. 10
0
        // Colorize : Picture
        private void pictureBoxColorize_Paint(object sender, PaintEventArgs e)
        {
            int    width     = pictureBoxColorize.Width;
            int    height    = pictureBoxColorize.Height;
            double increment = (double)width / 255.0;
            int    x         = 0;

            for (double i = 0; i < width; i += increment, x++)
            {
                Pen pen = new Pen(Do.HSLtoRGBColor(x / 255.0, (double)colorizeSaturation.Value / 255.0, 0.5));
                e.Graphics.DrawLine(pen, (float)i, 0, (float)i, height);
            }
            double ratio = (double)pictureBoxColorize.Width / 255.0;

            x = Math.Min(pictureBoxColorize.Width, Math.Max(0, (int)((double)colorizeHue.Value * ratio)));
            e.Graphics.DrawLine(new Pen(Color.Black), x, 0, x, height);
        }
Esempio n. 11
0
        /// <summary>
        /// Converts a tileset's binary data to a manageable tile collection.
        /// </summary>
        /// <param name="src">The tileset's binary data.</param>
        /// <param name="dst">The tile collection to write to from the binary data.</param>
        /// <param name="graphics">The graphics to use for creating the subtile pixels.</param>
        /// <param name="format">The size of a single subtile's graphics, 0x10 or 0x20.</param>
        public void BuildTilesetTiles(byte[] src, Tile[] dst, byte[] graphics, byte format)
        {
            int offset = 0;

            for (int i = 0; i < Width / 16; i++)
            {
                for (int y = 0; y < Height; y++)
                {
                    for (int x = i * 16; x < i * 16 + 16; x++)
                    {
                        int index = y * Width + x;
                        if (index >= dst.Length)
                        {
                            continue;
                        }
                        dst[index] = new Tile(index);
                        for (int z = 0; z < 4; z++)
                        {
                            if (z == 2)
                            {
                                offset += this.tileSize * 30;
                            }
                            ushort tilenum = 0;
                            byte   status  = 0;
                            if (this.tileSize == 2)
                            {
                                tilenum = (ushort)(Bits.GetShort(src, offset++) & 0x03FF);
                                status  = src[offset++];
                            }
                            else
                            {
                                tilenum = src[offset++];
                                status  = (byte)(Palette_bytes[tilenum] << 2);
                            }
                            var subtile = Do.DrawSubtile(tilenum, status, graphics, PaletteSet.Palettes, format);
                            dst[index].Subtiles[z] = subtile;
                        }
                        if (x < i * 16 + 15)
                        {
                            offset -= this.tileSize * 32;
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Converts an XML node associated with a control tooltip to text and writes the output to file.
        /// </summary>
        /// <param name="writer">The output stream to use.</param>
        /// <param name="editor">The XML node to analyze.</param>
        private static void HelpTooltips(StringWriter writer, XmlNode parent, int indent)
        {
            string pad      = String.Empty.PadLeft(indent, ' ');
            var    tooltips = parent.SelectNodes("tooltip");

            if (tooltips.Count > 0)
            {
                writer.WriteLine(pad);
                writer.WriteLine(pad + "***TOOLTIPS***");
            }
            foreach (XmlNode tooltip in tooltips)
            {
                var title       = tooltip.SelectSingleNode("title");
                var description = tooltip.SelectSingleNode("description");
                writer.WriteLine(pad + "[" + title.InnerText + "]");
                writer.WriteLine(pad + "  " + Do.WordWrap(description.InnerText, 71, indent + 2));
            }
        }
Esempio n. 13
0
 //
 public void SetTilesetImage()
 {
     if (Tileset.Tilesets_tiles[Layer] != null)
     {
         int   height          = Layer < 2 ? Tileset.Height : Tileset.HeightL3;
         int[] tileSetPixels   = Do.TilesetToPixels(Tileset.Tilesets_tiles[Layer], 16, height, 0, false);
         int[] priority1Pixels = Do.TilesetToPixels(Tileset.Tilesets_tiles[Layer], 16, height, 0, true);
         tilesetImage   = Do.PixelsToImage(tileSetPixels, 256, height * 16);
         priority1      = Do.PixelsToImage(priority1Pixels, 256, height * 16);
         Picture.Height = height * 16;
     }
     else
     {
         tilesetImage   = null;
         priority1      = null;
         Picture.Height = 0;
     }
     Picture.Invalidate();
 }
Esempio n. 14
0
 /// <summary>
 /// Enable or disable all or some controls within a parent control, starting at the parent control.
 /// Returns the controls that already have the enable status set.
 /// </summary>
 /// <param name="main">The main parent controls.</param>
 /// <param name="enable">Enable or disable the controls.</param>
 /// <param name="childOnly">If set to true, only controls that contain no child controls will be modified.</param>
 /// <param name="skip">The controls to ignore when changing enabled status.</param>
 public static ArrayList EnableControls(object main, bool enable, bool childOnly, bool firstLoop, params object[] skip)
 {
     if (firstLoop)
     {
         set = new ArrayList();
     }
     if (main is ToolStrip)
     {
         foreach (ToolStripItem item in ((ToolStrip)main).Items)
         {
             if (!Do.Contains(item, skip))
             {
                 if (item.Enabled == enable)
                 {
                     set.Add(item);
                 }
                 else
                 {
                     item.Enabled = enable;
                 }
             }
         }
     }
     else
     {
         foreach (Control parent in ((Control)main).Controls)
         {
             if (parent.Controls.Count == 0 || !childOnly && !Do.Contains(parent, skip))
             {
                 if (parent.Enabled == enable)
                 {
                     set.Add(parent);
                 }
                 else
                 {
                     parent.Enabled = enable;
                 }
             }
             EnableControls(parent, enable, childOnly, false, skip);
         }
     }
     return(set);
 }
Esempio n. 15
0
 public void CreateIntroWindow()
 {
     if (Intro == null || !Intro.Visible)
     {
         Cursor.Current = Cursors.WaitCursor;
         Intro          = new Intro.OwnerForm();
         if (DockEditors)
         {
             Do.AddControl(MainForm.PanelForms, Intro);
         }
         else
         {
             Intro.Show();
         }
         loadedForms.Add(Intro);
         Cursor.Current = Cursors.Arrow;
     }
     Intro.KeyDown += new KeyEventHandler(editor_KeyDown);
     Intro.BringToFront();
 }
Esempio n. 16
0
 public void CreateSpritesWindow()
 {
     if (Sprites == null || !Sprites.Visible)
     {
         Cursor.Current = Cursors.WaitCursor;
         Sprites        = new Sprites.OwnerForm();
         if (DockEditors)
         {
             Do.AddControl(MainForm.PanelForms, Sprites);
         }
         else
         {
             Sprites.Show();
         }
         loadedForms.Add(Sprites);
         Cursor.Current = Cursors.Arrow;
     }
     Sprites.KeyDown += new KeyEventHandler(editor_KeyDown);
     Sprites.BringToFront();
 }
Esempio n. 17
0
 public void CreateNewGameWindow()
 {
     if (NewGame == null || !NewGame.Visible)
     {
         Cursor.Current = Cursors.WaitCursor;
         NewGame        = new NewGame.OwnerForm();
         if (DockEditors)
         {
             Do.AddControl(MainForm.PanelForms, NewGame);
         }
         else
         {
             NewGame.Show();
         }
         loadedForms.Add(NewGame);
         Cursor.Current = Cursors.Arrow;
     }
     NewGame.KeyDown += new KeyEventHandler(editor_KeyDown);
     NewGame.BringToFront();
 }
Esempio n. 18
0
 public void CreateAttacksWindow()
 {
     if (Attacks == null || !Attacks.Visible)
     {
         Cursor.Current = Cursors.WaitCursor;
         Attacks        = new Attacks.OwnerForm();
         if (DockEditors)
         {
             Do.AddControl(MainForm.PanelForms, Attacks);
         }
         else
         {
             Attacks.Show();
         }
         loadedForms.Add(Attacks);
         Cursor.Current = Cursors.Arrow;
     }
     Attacks.KeyDown += new KeyEventHandler(editor_KeyDown);
     Attacks.BringToFront();
 }
Esempio n. 19
0
 public void CreateMinecartWindow()
 {
     if (Minecart == null || !Minecart.Visible)
     {
         Cursor.Current = Cursors.WaitCursor;
         Minecart       = new Minecart.OwnerForm();
         if (DockEditors)
         {
             Do.AddControl(MainForm.PanelForms, Minecart);
         }
         else
         {
             Minecart.Show();
         }
         loadedForms.Add(Minecart);
         Cursor.Current = Cursors.Arrow;
     }
     Minecart.KeyDown += new KeyEventHandler(editor_KeyDown);
     Minecart.BringToFront();
 }
Esempio n. 20
0
 public void CreateFormationsWindow()
 {
     if (Formations == null || !Formations.Visible)
     {
         Cursor.Current = Cursors.WaitCursor;
         Formations     = new Formations.OwnerForm();
         if (DockEditors)
         {
             Do.AddControl(MainForm.PanelForms, Formations);
         }
         else
         {
             Formations.Show();
         }
         loadedForms.Add(Formations);
         Cursor.Current = Cursors.Arrow;
     }
     Formations.KeyDown += new KeyEventHandler(editor_KeyDown);
     Formations.BringToFront();
 }
Esempio n. 21
0
 public void CreateBattlefieldsWindow()
 {
     if (Battlefields == null || !Battlefields.Visible)
     {
         Cursor.Current = Cursors.WaitCursor;
         Battlefields   = new Battlefields.OwnerForm();
         if (DockEditors)
         {
             Do.AddControl(MainForm.PanelForms, Battlefields);
         }
         else
         {
             Battlefields.Show();
         }
         loadedForms.Add(Battlefields);
         Cursor.Current = Cursors.Arrow;
     }
     Battlefields.KeyDown += new KeyEventHandler(editor_KeyDown);
     Battlefields.BringToFront();
 }
Esempio n. 22
0
 public void CreateEventScriptsWindow()
 {
     if (EventScripts == null || !EventScripts.Visible)
     {
         Cursor.Current = Cursors.WaitCursor;
         EventScripts   = new OwnerForm();
         if (DockEditors)
         {
             Do.AddControl(MainForm.PanelForms, EventScripts);
         }
         else
         {
             EventScripts.Show();
         }
         loadedForms.Add(EventScripts);
         Cursor.Current = Cursors.Arrow;
     }
     EventScripts.KeyDown += new KeyEventHandler(editor_KeyDown);
     EventScripts.BringToFront();
 }
Esempio n. 23
0
 public void CreateWorldMapsWindow()
 {
     if (WorldMaps == null || !WorldMaps.Visible)
     {
         Cursor.Current = Cursors.WaitCursor;
         WorldMaps      = new WorldMaps.OwnerForm();
         if (DockEditors)
         {
             Do.AddControl(MainForm.PanelForms, WorldMaps);
         }
         else
         {
             WorldMaps.Show();
         }
         loadedForms.Add(WorldMaps);
         Cursor.Current = Cursors.Arrow;
     }
     WorldMaps.KeyDown += new KeyEventHandler(editor_KeyDown);
     WorldMaps.BringToFront();
 }
Esempio n. 24
0
 public void CreateMenusWindow()
 {
     if (Menus == null || !Menus.Visible)
     {
         Cursor.Current = Cursors.WaitCursor;
         Menus          = new Menus.OwnerForm();
         if (DockEditors)
         {
             Do.AddControl(MainForm.PanelForms, Menus);
         }
         else
         {
             Menus.Show();
         }
         loadedForms.Add(Menus);
         Cursor.Current = Cursors.Arrow;
     }
     Menus.KeyDown += new KeyEventHandler(editor_KeyDown);
     Menus.BringToFront();
 }
Esempio n. 25
0
        /// <summary>
        /// Converts an XML node associated with a section to text and writes the output to file.
        /// </summary>
        /// <param name="writer">The output stream to use.</param>
        /// <param name="editor">The XML node to analyze.</param>
        private static void HelpSection(StringWriter writer, XmlNode section, int indent)
        {
            string name = section.Attributes["title"].Value;
            string pad  = String.Empty.PadLeft(indent, ' ');

            writer.WriteLine(pad);
            writer.WriteLine(pad + String.Empty.PadLeft(name.Length, '_'));
            writer.WriteLine(pad + name);
            writer.WriteLine(pad + String.Empty.PadLeft(name.Length, '¯'));
            var description = section.SelectSingleNode("description");

            if (description != null)
            {
                writer.WriteLine(pad + Do.WordWrap(description.InnerText, 71, indent));
            }
            HelpTooltips(writer, section, indent + 3);
            foreach (XmlNode subeditor in section.SelectNodes("*[@type = 'subeditor']"))
            {
                HelpSubwindow(writer, section, indent + 3);
            }
        }
Esempio n. 26
0
        public static void DrawName(
            object sender, DrawItemEventArgs e, Preview preview, string[] names,
            Fonts.Glyph[] font, int[] palette, int xOffset, int yOffset,
            int startIndex, int endIndex, bool lastEmpty, bool shadow, Bitmap bgimage)
        {
            if (e.Index < 0 || e.Index >= names.Length)
            {
                return;
            }
            string name = names[e.Index];

            // set the pixels
            var temp   = preview.GetPreview(font, palette, name.ToCharArray(), shadow, false);
            var pixels = new int[256 * 32];

            for (int y = 0, c = yOffset; y < 14; y++, c++)
            {
                for (int x = 2, a = xOffset; x < 256; x++, a++)
                {
                    pixels[y * 256 + x] = temp[c * 256 + a];
                }
            }
            if (bgimage != null)
            {
                var background = new Rectangle(0, e.Index * 16 % bgimage.Height, bgimage.Width, 16);
                e.Graphics.DrawImage(bgimage, e.Bounds.X, e.Bounds.Y, background, GraphicsUnit.Pixel);
            }
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.DrawBackground();
            }
            if (lastEmpty && e.Index == names.Length - 1)
            {
                e.Graphics.DrawString("*** NOTHING ***", new Font("Arial Black", 7F), Brushes.White, e.Bounds.Location);
            }
            else
            {
                e.Graphics.DrawImage(Do.PixelsToImage(pixels, 256, 15), e.Bounds.Location);
            }
        }
Esempio n. 27
0
        private void NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (!LoggingAccept(sender))
            {
                return;
            }
            var    control = sender as TreeView;
            string text    = e.Node.Text;
            string temp    = "\"" + control.Name + "\" | ";

            temp += "\"" + text.Substring(0, Math.Min(30, text.Length));
            if (text.Length > 30)
            {
                temp += "...";
            }
            temp += "\"";
            temp += " | Form \"" + form.Name + "\"";
            AddElementIndex(ref temp);
            //
            Do.AddHistory(temp);
            dateTime = DateTime.Now;
        }
Esempio n. 28
0
 // Read/write buffer
 private void ReadFromBuffer()
 {
     Reds   = new int[count * size];
     Greens = new int[count * size];
     Blues  = new int[count * size];
     for (int i = 0; i < count; i++)
     {
         for (int a = 0; a < size; a++)
         {
             if ((i * Length) + (a * 2) + offset + 1 >= Buffer.Length)
             {
                 continue;
             }
             ushort color = Bits.GetShort(Buffer, (i * Length) + (a * 2) + offset);
             Reds[i * size + a]   = (color % 0x20) * 8;
             Greens[i * size + a] = ((color >> 5) % 0x20) * 8;
             Blues[i * size + a]  = ((color >> 10) % 0x20) * 8;
         }
     }
     palette  = Do.RGBToColors(Reds, Greens, Blues);
     palettes = Do.RGBToColors(Reds, Greens, Blues, count, size);
 }
Esempio n. 29
0
 private void SetTileImage()
 {
     int[] temp   = new int[16 * 16];
     int[] pixels = new int[64 * 64];
     for (int y = 0; y < 2; y++)
     {
         for (int x = 0; x < 2; x++)
         {
             Do.PixelsToPixels(
                 tile.Subtiles[y * 2 + x].Pixels,
                 temp, 16, new Rectangle(x * 8, y * 8, 8, 8));
         }
     }
     for (int y = 0; y < 64; y++)
     {
         for (int x = 0; x < 64; x++)
         {
             pixels[y * 64 + x] = temp[y / 4 * 16 + (x / 4)];
         }
     }
     tileImage = Do.PixelsToImage(pixels, 64, 64);
     pictureBoxTile.Invalidate();
 }
Esempio n. 30
0
        private void TextChanged(object sender, EventArgs e)
        {
            if (!LoggingAccept(sender))
            {
                return;
            }
            string temp = "";

            if (sender is TextBox)
            {
                var    control = sender as TextBox;
                string text    = control.Text;
                temp += "\"" + control.Name + "\" | ";
                temp += "Text = \"" + text.Substring(0, Math.Min(30, text.Length));
                if (text.Length > 30)
                {
                    temp += "...";
                }
            }
            else if (sender is ToolStripTextBox)
            {
                var    control = sender as ToolStripTextBox;
                string text    = control.Text;
                temp += "\"" + control.Name + "\" | ";
                temp += "Text = \"" + text.Substring(0, Math.Min(30, text.Length));
                if (text.Length > 30)
                {
                    temp += "...";
                }
            }
            temp += "\"";
            temp += " | Form \"" + form.Name + "\"";
            AddElementIndex(ref temp);
            //
            Do.AddHistory(temp);
            dateTime = DateTime.Now;
        }