Ejemplo n.º 1
0
        public static Section_AHDR GetAsset(AssetHeader a, out bool success)
        {
            DialogResult d = a.ShowDialog();

            if (d == DialogResult.OK)
            {
                AHDRFlags flags =
                    (a.checkSourceFile.Checked ? AHDRFlags.SOURCE_FILE : 0) |
                    (a.checkSourceVirtual.Checked ? AHDRFlags.SOURCE_VIRTUAL : 0) |
                    (a.checkReadT.Checked ? AHDRFlags.READ_TRANSFORM : 0) |
                    (a.checkWriteT.Checked ? AHDRFlags.WRITE_TRANSFORM : 0);

                Section_ADBG ADBG = new Section_ADBG(0, a.assetName, a.assetFileName, a.checksum);

                Section_AHDR AHDR = new Section_AHDR(a.assetID, a.assetType, flags, ADBG, a.data)
                {
                    fileSize  = a.data.Length,
                    plusValue = 0
                };

                success = true;
                return(AHDR);
            }
            else
            {
                success = false;
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static Section_AHDR GetAsset(AssetHeader a, out bool success, out bool setPosition)
        {
            DialogResult d = a.ShowDialog();

            if (d == DialogResult.OK)
            {
                AHDRFlags flags =
                    (a.checkSourceFile.Checked ? AHDRFlags.SOURCE_FILE : 0) |
                    (a.checkSourceVirtual.Checked ? AHDRFlags.SOURCE_VIRTUAL : 0) |
                    (a.checkReadT.Checked ? AHDRFlags.READ_TRANSFORM : 0) |
                    (a.checkWriteT.Checked ? AHDRFlags.WRITE_TRANSFORM : 0);

                Section_ADBG ADBG = new Section_ADBG(0, a.assetName, a.assetFileName, a.checksum);

                Section_AHDR AHDR = new Section_AHDR(a.assetID, a.assetType, flags, ADBG, a.data)
                {
                    fileSize  = a.data.Length,
                    plusValue = 0
                };

                int alignment = 16;
                if (Functions.currentGame == Game.BFBB)
                {
                    if (AHDR.assetType == AssetType.CSN |
                        AHDR.assetType == AssetType.SND |
                        AHDR.assetType == AssetType.SNDS)
                    {
                        alignment = 32;
                    }
                    else if (AHDR.assetType == AssetType.CRDT)
                    {
                        alignment = 4;
                    }
                }

                int value = AHDR.fileSize % alignment;
                if (value != 0)
                {
                    AHDR.plusValue = alignment - value;
                }

                setPosition = a.setPosition;
                success     = true;
                return(AHDR);
            }
            else
            {
                success     = false;
                setPosition = false;
                return(null);
            }
        }
Ejemplo n.º 3
0
        private void buttonEditAsset_Click(object sender, EventArgs e)
        {
            try
            {
                uint         oldAssetID = CurrentlySelectedAssetIDs()[0];
                Section_AHDR AHDR       = AssetHeader.GetAsset(archive.GetFromAssetID(oldAssetID).AHDR, out bool success, out bool setPosition);

                if (success)
                {
                    archive.UnsavedChanges = true;
                    archive.RemoveAsset(oldAssetID);

                    while (archive.ContainsAsset(AHDR.assetID))
                    {
                        MessageBox.Show($"Archive already contains asset id [{AHDR.assetID.ToString("X8")}]. Will change it to [{(AHDR.assetID + 1).ToString("X8")}].");
                        AHDR.assetID++;
                    }

                    archive.AddAsset(comboBoxLayers.SelectedIndex, AHDR);
                    if (setPosition)
                    {
                        archive.SetAssetPositionToView(AHDR.assetID);
                    }

                    //PopulateAssetListAndComboBox();
                    SetSelectedIndices(new List <uint>()
                    {
                        AHDR.assetID
                    }, true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to edit asset: " + ex.Message);
            }
        }