Beispiel #1
0
        private void ImportTilemap(byte[] array, int layer, int offset)
        {
            if (!checkBox4.Checked || tilemap.Tilemaps_Tiles[layer] == null)
            {
                return;
            }
            int  counter = 0;
            int  extratiles = 256;
            bool mirror, invert;

            for (int i = 0; i < tilemap.Tilemaps_Tiles[layer].Length; i++)
            {
                int tile = Bits.GetShort(array, offset) & 0x1FF;
                mirror = Bits.GetBit(array, offset + 1, 6);
                invert = Bits.GetBit(array, offset + 1, 7);
                tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][tile];
                if (layer != 2)
                {
                    Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter, tile);
                    counter += 2; offset += 2;
                }
                else
                {
                    tilemap.Tilemaps_Bytes[layer][counter] = (byte)tile;
                    counter++; offset += 2;
                }
                if (tileset.Tilesets_tiles[layer] == null || tileset.Tilesets_tiles[layer].Length != 512)
                {
                    continue;
                }
                if (mirror || invert)
                {
                    Tile copy = tileset.Tilesets_tiles[layer][tile].Copy();
                    if (mirror)
                    {
                        Do.FlipHorizontal(copy);
                    }
                    if (invert)
                    {
                        Do.FlipVertical(copy);
                    }
                    Tile contains = Do.Contains(tileset.Tilesets_tiles[layer], copy);
                    if (contains == null)
                    {
                        tileset.Tilesets_tiles[layer][extratiles]       = copy;
                        tileset.Tilesets_tiles[layer][extratiles].Index = extratiles;
                        tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][extratiles];
                        Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter - 2, extratiles);
                        extratiles++;
                    }
                    else
                    {
                        tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][contains.Index];
                        Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter - 2, contains.Index);
                    }
                }
            }
        }
        private void LoadSearch(TreeView treeView, StringComparison stringComparison, bool matchWholeWord)
        {
            treeView.BeginUpdate();
            treeView.Nodes.Clear();
            if (searchBox.Text == "")
            {
                treeView.EndUpdate();
                return;
            }
            TreeNode tn;
            TreeNode cn;

            foreach (FormationPack fp in packs)
            {
                if (Do.Contains(
                        formations[fp.Formations[0]].ToString(),
                        searchBox.Text, stringComparison, matchWholeWord) ||
                    Do.Contains(
                        formations[fp.Formations[1]].ToString(),
                        searchBox.Text, stringComparison, matchWholeWord) ||
                    Do.Contains(
                        formations[fp.Formations[2]].ToString(),
                        searchBox.Text, stringComparison, matchWholeWord))
                {
                    tn     = treeView.Nodes.Add("PACK #" + fp.Index);
                    tn.Tag = (int)fp.Index;
                    if (Do.Contains(
                            formations[fp.Formations[0]].ToString(),
                            searchBox.Text, stringComparison, matchWholeWord))
                    {
                        cn     = tn.Nodes.Add(formations[fp.Formations[0]].ToString());
                        cn.Tag = (int)fp.Index;
                    }
                    if (Do.Contains(
                            formations[fp.Formations[1]].ToString(),
                            searchBox.Text, stringComparison, matchWholeWord))
                    {
                        cn     = tn.Nodes.Add(formations[fp.Formations[1]].ToString());
                        cn.Tag = (int)fp.Index;
                    }
                    if (Do.Contains(
                            formations[fp.Formations[2]].ToString(),
                            searchBox.Text, stringComparison, matchWholeWord))
                    {
                        cn     = tn.Nodes.Add(formations[fp.Formations[2]].ToString());
                        cn.Tag = (int)fp.Index;
                    }
                }
            }
            treeView.ExpandAll();
            treeView.EndUpdate();
        }
Beispiel #3
0
        public void RefreshHexEditor()
        {
            this.Updating     = true;
            vScrollBar1.Value = offset / 16;
            string bytes2  = "";
            string bytes3  = "";
            string offsets = "";

            // in case enlarging when at end of ROM
            while (last_line > current.Length)
            {
                offset -= 16;
            }
            //
            int offset_line = offset & 0xFFFFF0;

            for (int i = 0; i < line_count; i++)
            {
                offsets += (i * 16 + offset_line).ToString("X6");
                if (i < line_count - 1)
                {
                    offsets += "\r";
                }
                for (int a = 0; a < 16; a++)
                {
                    bytes2 += (current[i * 16 + offset_line + a]).ToString("X2") + " ";
                    bytes3 += (original[i * 16 + offset_line + a]).ToString("X2") + " ";
                }
            }
            //
            ROMOffsets.BeginUpdate();
            ROMOffsets.Text = offsets;
            ROMOffsets.EndUpdate();
            //
            ROMData.BeginUpdate();
            currentROMData.Text            = bytes2;
            originalROMData.Text           = bytes3;
            currentROMData.SelectionStart  = 0;
            currentROMData.SelectionLength = currentROMData.Text.Length;
            currentROMData.SelectionColor  = Color.DarkBlue;
            for (int offsetCounter = offset & 0xFFFFF0, i = 0; i < line_count * 16; i++)
            {
                // first set the length of the changed offsets, to colorize all at once (b/c faster)
                int    changedStart  = 0;
                int    changedLength = 0;
                Change change        = Do.FindOffset(oldProperties, offsetCounter++);
                if (change != null)
                {
                    changedStart = i * 3;
                    if (change.Values.Length == 1)
                    {
                        changedLength = 3;
                        while (Do.Contains(oldProperties, offsetCounter++))
                        {
                            changedLength += 3;
                        }
                        i += changedLength / 3;
                    }
                    else
                    {
                        offsetCounter--;
                        changedLength  = (change.Values.Length - (offsetCounter - change.Offset)) * 3;
                        i             += changedLength / 3;
                        offsetCounter += changedLength / 3;
                        offsetCounter++;
                    }
                }
                if (changedLength > 0)
                {
                    currentROMData.SelectionStart  = changedStart;
                    currentROMData.SelectionLength = changedLength;
                    currentROMData.SelectionColor  = change.Color;
                }
            }
            currentROMData.SelectionStart  = originalROMData.SelectionStart = selectionStart;
            currentROMData.SelectionLength = originalROMData.SelectionLength = selectionLength;
            ROMData.Focus();
            ROMData.EndUpdate();
            //
            UpdateInformationLabels();
            this.Updating = false;
        }