Esempio n. 1
0
        private void spriteList_SelectedIndexChanged(object sender, EventArgs e)
        {
            PACFile.PACEntry colentry = (PACFile.PACEntry)spriteList.Items[spriteList.SelectedIndex];
            var coloffset             = col.getOffsetByName(colentry.name);

            if (oldListIndex > 0)
            {
                var oldEntry = (PACFile.PACEntry)spriteList.Items[oldListIndex];
                int idx      = editedBoxes.BinarySearch(oldEntry);
                if (idx < 0)
                {
                    idx = ~idx;
                }
                editedBoxes.Insert(idx, oldEntry);
            }
            oldListIndex = spriteList.SelectedIndex;
            if (!is_gg)
            {
                var spritename   = colentry.name.Substring(0, colentry.name.Length - 7) + ".hip";
                var spriteoffset = img.getOffsetByName(spritename);
                oi = new OverlaidImage(img.path, spriteoffset, col.path, coloffset);
            }
            else
            {
                oi = new OverlaidImage(col.path, coloffset);
            }
            boxList.Items.Clear();
            foreach (var box in oi.hurtboxes)
            {
                boxList.Items.Add(box);
            }
            foreach (var box in oi.hitboxes)
            {
                boxList.Items.Add(box);
            }
            if (boxList.Items.Count != 0)
            {
                boxList.SelectedIndex = 0;
            }
            xLastMoved      = 0;
            yLastMoved      = 0;
            spriteBox.Image = oi.boxbitmap;
        }
Esempio n. 2
0
        private void saveCurrentBtn_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter          = ".pac files (*.pac)|*.pac|Guilty gear COL files (COL_*)|COL_*";
            sfd.Title           = "Save edited collision file";
            sfd.OverwritePrompt = true;
            sfd.ShowDialog();
            if (sfd.FileName != "" && !is_gg)
            {
                PACFile.PACEntry colentry = (PACFile.PACEntry)spriteList.Items[spriteList.SelectedIndex];
                int idx = editedBoxes.BinarySearch(colentry);
                if (idx < 0)
                {
                    idx = ~idx;
                }
                editedBoxes.Insert(idx, colentry);
                byte[] oldpac = File.ReadAllBytes(col.path);
                foreach (var jb in editedBoxes)
                {
                    int writestart = (int)(jb.offset + col.data_start);
                    int writeend   = writestart;
                    writeend += 4;
                    writeend += 2 + BitConverter.ToInt16(oldpac, writeend) * 0x20 + 3;
                    var chunkssize = BitConverter.ToInt32(oldpac, writeend) * 0x50;
                    writeend += 8 + 41 * 2 + chunkssize;
                    int    boxcount  = boxList.Items.Count;
                    byte[] currfloat = { 0, 0, 0, 0 };
                    for (var i = 0; i < boxcount; i++)
                    {
                        writeend += 4;
                        var currbox = (JonbinBox)boxList.Items[i];
                        currfloat = System.BitConverter.GetBytes(currbox.x);
                        Array.Copy(currfloat, 0, oldpac, writeend, 4);
                        writeend += 4;
                        currfloat = System.BitConverter.GetBytes(currbox.y);
                        Array.Copy(currfloat, 0, oldpac, writeend, 4);
                        writeend += 4; currfloat = System.BitConverter.GetBytes(currbox.width);
                        Array.Copy(currfloat, 0, oldpac, writeend, 4);
                        writeend += 4; currfloat = System.BitConverter.GetBytes(currbox.height);
                        Array.Copy(currfloat, 0, oldpac, writeend, 4);
                        writeend += 4;
                    }
                }
                File.WriteAllBytes(sfd.FileName, oldpac);
            }
            else if (sfd.FileName != "")
            {
                PACFile.PACEntry colentry = (PACFile.PACEntry)spriteList.Items[spriteList.SelectedIndex];
                int    writestart         = (int)(colentry.offset + col.data_start);
                int    writeend           = writestart;
                byte[] oldpac             = File.ReadAllBytes(col.path);
                writeend += 0x3C;
                writeend += 2 + BitConverter.ToInt16(oldpac, writeend) * 0x20 + 3;
                var chunkssize = BitConverter.ToInt32(oldpac, writeend) * 0x50;
                writeend += 8 + 41 * 2 + chunkssize;
                int    boxcount  = boxList.Items.Count;
                byte[] currfloat = { 0, 0, 0, 0 };
                for (var i = 0; i < boxcount; i++)
                {
                    writeend += 4;
                    var currbox = (JonbinBox)boxList.Items[i];
                    currfloat = System.BitConverter.GetBytes(currbox.x);
                    Array.Copy(currfloat, 0, oldpac, writeend, 4);
                    writeend += 4;
                    currfloat = System.BitConverter.GetBytes(currbox.y);
                    Array.Copy(currfloat, 0, oldpac, writeend, 4);
                    writeend += 4; currfloat = System.BitConverter.GetBytes(currbox.width);
                    Array.Copy(currfloat, 0, oldpac, writeend, 4);
                    writeend += 4; currfloat = System.BitConverter.GetBytes(currbox.height);
                    Array.Copy(currfloat, 0, oldpac, writeend, 4);
                    writeend += 4;
                }
                File.WriteAllBytes(sfd.FileName, oldpac);
            }
        }