コード例 #1
0
        //---------------------------------------------------------------------
        // BASIC MENU FUNCTIONS
        //---------------------------------------------------------------------

        /// <summary>
        /// Helper function to save a HAM file, with lots of dumb error handling that doesn't work probably.
        /// </summary>
        private void SaveHAMFile()
        {
            if (saveHandler == null) //No save handler, so can't actually save right now
            {
                //HACK: Just call the save as handler for now... This needs restructuring
                mnuSaveAs_Click(this, new EventArgs());
                return; //and don't repeat the save code when we recall ourselves.
            }
            Stream stream = saveHandler.GetStream();

            if (stream == null)
            {
                MessageBox.Show(this, string.Format("Error opening save file {0}:\r\n{1}", saveHandler.GetUIName(), saveHandler.GetErrorMsg()));
            }
            else
            {
                datafile.Write(stream);
                if (saveHandler.FinalizeStream())
                {
                    MessageBox.Show(this, string.Format("Error writing save file {0}:\r\n{1}", saveHandler.GetUIName(), saveHandler.GetErrorMsg()));
                }
                else
                {
                    transactionManager.UnsavedFlag = false;
                }
            }
        }
コード例 #2
0
        private void SaveAsMenu_Click(object sender, EventArgs e)
        {
            if (isLowFi)
            {
                saveFileDialog1.Filter = "S11 Files|*.s11";
            }
            else
            {
                saveFileDialog1.Filter = "S22 Files|*.s22";
            }

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (saveFileDialog1.FileName != "")
                {
                    //Ensure the old save handler is detached from any UI properly.
                    if (saveHandler != null)
                    {
                        saveHandler.Destroy();
                    }
                    saveHandler = new FileSaveHandler(saveFileDialog1.FileName);
                    SaveSNDFile();
                    this.Text = string.Format("{0} - SND Editor", saveHandler.GetUIName());
                }
            }
        }
コード例 #3
0
        private void SXXEditor_FormClosing(object sender, FormClosingEventArgs e)
        {
            string currentFilename = "Untitled";

            if (saveHandler != null)
            {
                currentFilename = saveHandler.GetUIName();
            }

            if (transactionManager.UnsavedFlag)
            {
                switch (MessageBox.Show(this, string.Format("Would you like to save changes to {0}?", currentFilename), "Unsaved changes", MessageBoxButtons.YesNoCancel))
                {
                case DialogResult.Yes:
                    SaveSNDFile();
                    break;

                case DialogResult.No:
                    break;

                case DialogResult.Cancel:
                    e.Cancel = true;
                    break;
                }
            }
        }
コード例 #4
0
        public HXMEditor(EditorHXMFile datafile, StandardUI host, SaveHandler saveHandler)
        {
            InitializeComponent();

            robotPanel      = new EditorPanels.RobotPanel(transactionManager, 0);
            robotPanel.Dock = DockStyle.Fill;
            RobotTabPage.Controls.Add(robotPanel);
            components.Add(robotPanel);
            polymodelPanel      = new EditorPanels.PolymodelPanel(transactionManager, 1, host.DefaultPigFile, host.DefaultPalette, datafile);
            polymodelPanel.Dock = DockStyle.Fill;
            ModelTabPage.Controls.Add(polymodelPanel);
            components.Add(polymodelPanel);

            this.datafile = datafile;
            this.host     = host;
            palette       = host.DefaultPalette;
            modelRenderer = new ModelRenderer(datafile.BaseHAM, host.DefaultPigFile, palette);

            string currentFilename = "Untitled";

            if (saveHandler != null)
            {
                currentFilename = saveHandler.GetUIName();
            }

            this.saveHandler = saveHandler;
            this.Text        = string.Format("{0} - HXM Editor", currentFilename);

            transactionManager.undoEvent += DoUndoEvent;
        }
コード例 #5
0
        public HAMEditor(EditorHAMFile data, StandardUI host, PIGFile piggyFile, Palette palette, SaveHandler saveHandler)
        {
            InitializeComponent();

            this.palette   = palette;
            this.piggyFile = piggyFile;

            datafile         = data;
            this.host        = host;
            this.saveHandler = saveHandler;

            texturePanel        = new TMAPInfoPanel(transactionManager); components.Add(texturePanel);
            texturePanel.Dock   = DockStyle.Fill;
            vclipPanel          = new VClipPanel(transactionManager); components.Add(vclipPanel);
            vclipPanel.Dock     = DockStyle.Fill;
            eclipPanel          = new EClipPanel(transactionManager); components.Add(eclipPanel);
            eclipPanel.Dock     = DockStyle.Fill;
            wclipPanel          = new WClipPanel(transactionManager); components.Add(wclipPanel);
            wclipPanel.Dock     = DockStyle.Fill;
            robotPanel          = new RobotPanel(transactionManager, 4); components.Add(robotPanel);
            robotPanel.Dock     = DockStyle.Fill;
            weaponPanel         = new WeaponPanel(transactionManager, 5); components.Add(weaponPanel);
            weaponPanel.Dock    = DockStyle.Fill;
            polymodelPanel      = new PolymodelPanel(transactionManager, 6, piggyFile, palette, data); components.Add(polymodelPanel);
            polymodelPanel.Dock = DockStyle.Fill;
            soundPanel          = new SoundPanel(transactionManager, 7, datafile, host.DefaultSoundFile); components.Add(soundPanel);
            soundPanel.Dock     = DockStyle.Fill;
            reactorPanel        = new ReactorPanel(transactionManager, 8); components.Add(reactorPanel);
            reactorPanel.Dock   = DockStyle.Fill;
            TextureTabPage.Controls.Add(texturePanel);
            VClipTabPage.Controls.Add(vclipPanel);
            EffectsTabPage.Controls.Add(eclipPanel);
            DoorTabPage.Controls.Add(wclipPanel);
            RobotTabPage.Controls.Add(robotPanel);
            WeaponTabPage.Controls.Add(weaponPanel);
            ModelTabPage.Controls.Add(polymodelPanel);
            SoundTabPage.Controls.Add(soundPanel);
            ReactorTabPage.Controls.Add(reactorPanel);

            string currentFilename = "Untitled";

            if (saveHandler != null)
            {
                currentFilename = saveHandler.GetUIName();
            }

            this.Text = string.Format("{0} - HAM Editor", currentFilename);

            transactionManager.undoEvent += DoUndoEvent;

            datafile.CompatObjBitmaps = StandardUI.options.GetOption("CompatObjBitmaps", bool.FalseString) == bool.TrueString;
        }
コード例 #6
0
 private void mnuSaveAs_Click(object sender, EventArgs e)
 {
     saveFileDialog1.Filter = "HAM Files|*.HAM";
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         bool compatObjBitmaps = (StandardUI.options.GetOption("CompatObjBitmaps", bool.FalseString) == bool.TrueString);
         //Ensure the old save handler is detached from any UI properly.
         if (saveHandler != null)
         {
             saveHandler.Destroy();
         }
         saveHandler = new FileSaveHandler(saveFileDialog1.FileName);
         SaveHAMFile();
         this.Text = string.Format("{0} - HAM Editor", saveHandler.GetUIName());
     }
 }
コード例 #7
0
 private void SaveAsMenuItem_Click(object sender, EventArgs e)
 {
     saveFileDialog1.Filter = "HXM Files|*.hxm";
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         if (saveFileDialog1.FileName != "")
         {
             //Ensure the old save handler is detached from any UI properly.
             if (saveHandler != null)
             {
                 saveHandler.Destroy();
             }
             saveHandler = new FileSaveHandler(saveFileDialog1.FileName);
             SaveHXMFile();
             this.Text = string.Format("{0} - HXM Editor", saveHandler.GetUIName());
         }
     }
 }