Esempio n. 1
0
        /// <summary>
        /// Loads resources bank from a file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenBank(object sender, EventArgs e)
        {
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Filter           = "Resource bank (*.bnk)|*.bnk|All Files (*.*)|*.*";
                dlg.Title            = "Select resource to open...";
                dlg.DefaultExt       = ".bnk";
                dlg.RestoreDirectory = true;
                dlg.CheckFileExists  = true;
                dlg.CheckPathExists  = true;
                dlg.Multiselect      = false;


                DialogResult res = dlg.ShowDialog();
                if (res != DialogResult.OK)
                {
                    return;
                }

                // Erases all resources
                CloseAllTabs_OnClick(null, null);
                ResourceManager.ClearAssets();

                // Load bank
                Directory.SetCurrentDirectory(@"D:\Dev\ArcEngine\Games\DungeonEye");
                Storage = new BankStorage(dlg.FileName);
                ResourceManager.AddStorage(Storage);
            }

            ResourcePanel.RebuildResourceTree();

            Text = "ArcEngine Editor : " + Storage;
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a binary
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddBinaryMenu_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter           = "All Files (*.*)|*.*";
            dlg.Title            = "Select a binary file...";
            dlg.DefaultExt       = ".*";
            dlg.Multiselect      = true;
            dlg.RestoreDirectory = true;

            DialogResult res = dlg.ShowDialog();

            if (res != DialogResult.OK)
            {
                return;
            }

            // for each selected file, add it to the bank file
            for (int i = 0; i < dlg.FileNames.Length; i++)
            {
                ResourceManager.Load(dlg.SafeFileNames[i]);
            }

            ResourcePanel.RebuildResourceTree();
        }
Esempio n. 3
0
        /// <summary>
        /// Saves the resource under a new name from menu File/Save As
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FileSaveAs_OnClick(object sender, EventArgs e)
        {
            using (SaveFileDialog dlg = new SaveFileDialog())
            {
                dlg.Filter           = "Resource bank (*.bnk)|*.bnk|All Files (*.*)|*.*";
                dlg.Title            = "Save resource as...";
                dlg.DefaultExt       = ".bnk";
                dlg.RestoreDirectory = true;
                dlg.AddExtension     = true;
                dlg.CheckPathExists  = true;
                dlg.OverwritePrompt  = true;
                dlg.ValidateNames    = true;

                DialogResult res = dlg.ShowDialog();
                if (res != DialogResult.OK)
                {
                    return;
                }

                if (Storage != null)
                {
                    Storage.Dispose();
                }

                Storage = new BankStorage(dlg.FileName);
            }

            ResourceManager.SaveAssetsToStorage(Storage);

            ResourcePanel.RebuildResourceTree();
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a bank to the resourcemanager
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InsertBankMenu_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter     = "Resource bank (*.bnk)|*.bnk|All Files (*.*)|*.*";
            dlg.Title      = "Select resource to open...";
            dlg.DefaultExt = ".bnk";

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            ResourceManager.AddStorage(new BankStorage(dlg.FileName));

            ResourcePanel.RebuildResourceTree();
        }
Esempio n. 5
0
        /// <summary>
        /// Adds a binary to the bank
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddBinary_OnClick(object sender, EventArgs e)
        {
            if (Storage == null)
            {
                return;
            }

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter           = "All Files (*.*)|*.*";
            dlg.Title            = "Select a binary file...";
            dlg.DefaultExt       = ".*";
            dlg.Multiselect      = true;
            dlg.RestoreDirectory = true;

            DialogResult res = dlg.ShowDialog();

            if (res != DialogResult.OK)
            {
                return;
            }

            for (int i = 0; i < dlg.FileNames.Length; i++)
            {
                // Open storage file
                using (Stream to = Storage.OpenFile(dlg.FileNames[i], FileAccess.Write))
                {
                    // Temp memory stream
                    MemoryStream mem = new MemoryStream();

                    // Open file to copy
                    using (Stream from = new FileStream(dlg.FileNames[i], FileMode.Open))
                    {
                        mem.SetLength(from.Length);
                        from.Read(mem.GetBuffer(), 0, (int)from.Length);
                        mem.Flush();
                    }

                    mem.WriteTo(to);

                    mem.Close();
                }
            }

            ResourcePanel.RebuildResourceTree();
        }
Esempio n. 6
0
        /// <summary>
        /// Creates an empty resource bank
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CreateNewBank(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show("Erase all resources ?", "", MessageBoxButtons.YesNo);

            if (res != DialogResult.Yes)
            {
                return;
            }

            CloseAllTabs_OnClick(null, null);
            ResourceManager.ClearAssets();

            // New bank name
            if (Storage != null)
            {
                Storage.Dispose();
            }
            Storage = null;

            //
            ResourcePanel.RebuildResourceTree();
        }
Esempio n. 7
0
        /// <summary>
        ///  Adds resource to the manager
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuTool_AddExistingResource_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter     = "Resource bank (*.bnk)|*.bnk|All Files (*.*)|*.*";
            dlg.Title      = "Select resource to open...";
            dlg.DefaultExt = ".bnk";

            DialogResult res = dlg.ShowDialog();

            if (res != DialogResult.OK)
            {
                return;
            }

            // Stay back in the good directory
            Environment.CurrentDirectory = Application.StartupPath;


            ResourceManager.AddStorage(new BankStorage(dlg.FileName));

            ResourcePanel.RebuildResourceTree();
        }
Esempio n. 8
0
 /// <summary>
 /// Creates a new asset
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NewAssetBox_Click(object sender, EventArgs e)
 {
     new WizardForm(dockPanel, null).ShowDialog();
     ResourcePanel.RebuildResourceTree();
 }
Esempio n. 9
0
 /// <summary>
 /// Import an animation from a GIF image
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ImportAnimationFromGIF(object sender, EventArgs e)
 {
     new ImportGIFForm(Storage).ShowDialog();
     ResourcePanel.RebuildResourceTree();
 }