Exemplo n.º 1
0
        protected void SaveAs()
        {
            try
            {
                SaveFileDialog d = new SaveFileDialog();
                d.Filter           = GetFilter();
                d.InitialDirectory = GetInitialDirectory();
                if (d.ShowDialog() == DialogResult.OK)
                {
                    XmlSerializer s  = new XmlSerializer(typeof(TriggerRoot), new Type[] { });
                    Stream        st = File.Open(d.FileName, FileMode.Create);
                    mSavedFileName = d.FileName;

                    TriggerRoot root = TriggerData;
                    root.Name = Path.GetFileName(mSavedFileName);
                    root.Type = mType;
                    s.Serialize(st, root);

                    //s.Serialize(st, TriggerData);
                    st.Close();
                    this.Parent.Text = Path.GetFileName(d.FileName);

                    triggerHostArea1.Scan(true);


                    XMBProcessor.CreateXMB(mSavedFileName, false);
                }
            }
            catch (System.Exception ex)
            {
                CoreGlobals.getErrorManager().OnException(ex);
            }
        }
Exemplo n.º 2
0
        public bool WriteParticleSystem(string filename)
        {
            //-- if the file exists make sure we have it checked out
            if (File.Exists(filename) && ((File.GetAttributes(filename) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly))
            {
                string str = String.Format("File: {0} is read only!\nYou are not allowed to save!\nMake sure you checked the file out of Perforce!", filename);
                MessageBox.Show(str, "Read Only File", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            mEffect.preSerialization();

            if (!Path.HasExtension(filename))
            {
                filename = String.Format("{0}.pfx", filename);
            }

            ResourcePathInfo pathInfo = new ResourcePathInfo(filename);

            XmlSerializer s  = new XmlSerializer(typeof(ParticleEffect), new Type[] { });
            Stream        st = File.Create(filename);

            s.Serialize(st, mEffect);
            st.Close();
            mEffect.postDeserialization();

            XMBProcessor.CreateXMB(filename, false);

            return(true);
        }
Exemplo n.º 3
0
        private void bakeFinalButton_Click(object sender, EventArgs e)
        {
            //check topic permission
            if (CoreGlobals.getEditorMain().mPhoenixScenarioEditor.CheckTopicPermission("Sim") == false)
            {
                return;
            }

            TriggerFinalBake.eBuildMode mode = TriggerFinalBake.eBuildMode.NoOptimizations;
            try
            {
                mode = (TriggerFinalBake.eBuildMode)Enum.Parse(typeof(TriggerFinalBake.eBuildMode), buildModeCombo.SelectedItem.ToString());
            }
            catch (System.Exception ex2)
            {
                CoreGlobals.getErrorManager().OnException(ex2);
            }

            //export
            string fileName = Path.Combine(CoreGlobals.ScenarioDirectory, CoreGlobals.ScenarioFile);

            if (TriggerFinalBake.eBuildMode.NoOptimizations == mode)
            {
                XMBProcessor.CreateXMB(fileName, false);
            }
            else
            {
                string tempFile = TriggerFinalBake.OptimizeScenarioScripts(fileName, mode);
                XMBProcessor.CreateXMB(tempFile, false);
                File.Copy(tempFile + ".xmb", fileName + ".xmb", true);
            }
        }
Exemplo n.º 4
0
        private void Save()
        {
            try
            {
                if (mSavedFileName != "")
                {
                    XmlSerializer s  = new XmlSerializer(typeof(TriggerRoot), new Type[] { });
                    Stream        st = File.Open(mSavedFileName, FileMode.Create);

                    TriggerRoot root = TriggerData;
                    root.Name = Path.GetFileName(mSavedFileName);
                    root.Type = mType;
                    s.Serialize(st, root);
                    st.Close();

                    triggerHostArea1.Scan(true);

                    TriggerFinalBake.eBuildMode mode = TriggerFinalBake.eBuildMode.NoOptimizations;

                    try
                    {
                        mode = (TriggerFinalBake.eBuildMode)Enum.Parse(typeof(TriggerFinalBake.eBuildMode), buildMode.SelectedItem.ToString());
                    }
                    catch (System.Exception ex2)
                    {
                        CoreGlobals.getErrorManager().OnException(ex2);
                    }

                    //must have _raw_ tag for optimizations
                    if (mSavedFileName.Contains(TriggerFinalBake.sTriggerRaw) == false && TriggerFinalBake.eBuildMode.NoOptimizations != mode)
                    {
                        CoreGlobals.ShowMessage("filename not compatible with optimizations.");
                        mode = TriggerFinalBake.eBuildMode.NoOptimizations;
                    }

                    if (TriggerFinalBake.eBuildMode.NoOptimizations == mode)
                    {
                        XMBProcessor.CreateXMB(mSavedFileName, false);
                    }
                    else
                    {
                        string tempFile = TriggerFinalBake.OptimizeTriggerScript(mSavedFileName, mode);
                        XMBProcessor.CreateXMB(tempFile, false);

                        //File.Copy(tempFile + ".xmb", mSavedFileName + ".xmb", true);
                    }
                }
                else
                {
                    SaveAs();
                }
            }
            catch (System.Exception ex)
            {
                CoreGlobals.getErrorManager().OnException(ex);
            }
        }
Exemplo n.º 5
0
        static public void writeTerrainTypes()
        {
            string fileName = CoreGlobals.getWorkPaths().mGameDataDirectory + @"\" + mTextureDefFileName;

            if (!P4CanEdit(fileName, false))
            {
                if (MessageBox.Show("data\\terrainTextureDefinitions.xml is not checked out from perforce.\n This file must be checked out in order to make changes.\nWould you like to check it out?", "ALERT!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    P4AddFileToChangeList(CoreGlobals.getWorkPaths().mGameDataDirectory + @"\" + mTextureDefFileName);
                }
                else
                {
                    MessageBox.Show("You must check out hise file before you can save it.");
                    return;
                }
            }



            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            {
                TerrainTextureDef defaultDef = new TerrainTextureDef();
                defaultDef.toDefaultValues();

                TerrainTextureDefXML kDef = new TerrainTextureDefXML();
                for (int i = 0; i < mTextureList.Count; i++)
                {
                    string tName = mTextureList[i].Theme + @"\" + mTextureList[i].TextureName;

                    if (File.Exists(CoreGlobals.getWorkPaths().mTerrainTexturesPath + @"\" + tName + "_df.ddx"))
                    {
                        //check to ensure we actually have sim data that's not defaulted...
                        if ((mTextureList[i].ObstructLand != defaultDef.ObstructLand) || (mTextureList[i].TileType != defaultDef.TileType))
                        {
                            kDef.mTypes.Add(mTextureList[i]);
                        }
                    }
                }

                XmlSerializer s  = new XmlSerializer(typeof(TerrainTextureDefXML), new Type[] { typeof(TerrainTextureDef) });
                Stream        st = File.OpenWrite(fileName);
                s.Serialize(st, kDef);

                st.Close();

                XMBProcessor.CreateXMB(fileName, false);
            }
        }
Exemplo n.º 6
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                XmlSerializer s  = new XmlSerializer(typeof(ScenarioDescriptionsXml), new Type[] { });
                Stream        st = File.Open(mDescriptionFilename, FileMode.Create);
                s.Serialize(st, mScenarioDescriptions);
                st.Close();

                XMBProcessor.CreateXMB(mDescriptionFilename, false);
            }
            catch (System.Exception ex)
            {
                CoreGlobals.getErrorManager().OnException(ex);
            }
        }
Exemplo n.º 7
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (mLastFileName != "")
            {
                try
                {
                    Stream s = new FileStream(mLastFileName, FileMode.Create);
                    mTables.SaveToTableXML(s);

                    XMBProcessor.CreateXMB(mLastFileName, false);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 8
0
        public void CreateNewEffectVisFile(string newAnimFile, string gr2file)
        {
            XmlDocument animTemplateDoc = new XmlDocument();

            animTemplateDoc.Load(CoreGlobals.getWorkPaths().mGameArtDirectory + "\\template\\effect" + CoreGlobals.getWorkPaths().mUnitDataExtension);

            XmlNodeList nodes = animTemplateDoc.SelectNodes("//asset[@type='Particle']/file");

            if (nodes.Count > 0)
            {
                nodes[0].InnerText = gr2file.Replace(".pfx", "");;
            }
            string newFullFileName = Path.Combine(CoreGlobals.getWorkPaths().mGameArtDirectory, newAnimFile);

            animTemplateDoc.Save(newFullFileName);

            XMBProcessor.CreateXMB(newFullFileName, false);
        }
Exemplo n.º 9
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            string fileName = mFilename;

            if (File.Exists(fileName) == false)
            {
                CoreGlobals.ShowMessage("File Missing: " + fileName);
                return;
            }
            if ((File.GetAttributes(fileName) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
            {
                CoreGlobals.ShowMessage("Please check out: " + fileName);
                return;
            }


            BaseLoader <ProtoConceptDatabase> .Save(mFilename, mDatabase);

            XMBProcessor.CreateXMB(mFilename, false);
        }
Exemplo n.º 10
0
        static public void writeTerrainPalette(string fileName, List <string> texSet)
        {
            if (File.Exists(fileName))
            {
                if (P4CanEdit(fileName, true))
                {
                    File.Delete(fileName);
                }
                else
                {
                    return;
                }
            }
            else if (Path.GetFileNameWithoutExtension(fileName) != mDefaultSetFileName)
            {
                if (MessageBox.Show(fileName + " does not exist in perforce.\n Would you like to add it?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    P4AddFileToChangeList(fileName);
                }
            }

            {
                TerrainTextureSetXML kDef = new TerrainTextureSetXML();
                kDef.mTextures = new List <TerrainSetTexture>(texSet.Count);

                for (int i = 0; i < texSet.Count; i++)
                {
                    kDef.mTextures.Add(new TerrainSetTexture());
                    kDef.mTextures[kDef.mTextures.Count - 1].mTypeName = texSet[i];
                }


                XmlSerializer s  = new XmlSerializer(typeof(TerrainTextureSetXML), new Type[] { typeof(TerrainSetTexture) });
                Stream        st = File.OpenWrite(fileName);
                s.Serialize(st, kDef);

                st.Close();

                XMBProcessor.CreateXMB(fileName, false);
            }
        }
Exemplo n.º 11
0
        private void SaveAsButton_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.InitialDirectory = CoreGlobals.getWorkPaths().mGameDataAIDataDirectory;
            sfd.Filter           = "AIData (*" + CoreGlobals.getWorkPaths().mAIDataExtension + ")|*" + CoreGlobals.getWorkPaths().mAIDataExtension;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Stream s = new FileStream(sfd.FileName, FileMode.Create);
                    mTables.SaveToTableXML(s);
                    mLastFileName = sfd.FileName;

                    XMBProcessor.CreateXMB(mLastFileName, false);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 12
0
        static void quickSaveFile(bool forceAutoSave)
        {
            using (PerfSection p3 = new PerfSection("quickSaveFile"))
            {
                string scenerioPath = CoreGlobals.getWorkPaths().mGameScenarioDirectory;
                string scenarioName = scenerioPath + @"\" + fName + @"\" + fName + ".scn";
                string terrainName  = Path.ChangeExtension(scenarioName, "ted");
                string lightsetName = Path.ChangeExtension(scenarioName, "gls");


                if (forceAutoSave || !File.Exists(scenarioName))
                {
                    if (!Directory.Exists(scenerioPath + @"\" + fName))
                    {
                        Directory.CreateDirectory(scenerioPath + @"\" + fName);
                    }

                    XMBProcessor.Pause();
                    SimGlobals.getSimMain().SaveScenario(scenarioName, terrainName, lightsetName, true);
                    SimGlobals.getSimMain().SaveExtasMacro(scenarioName);
                    XMBProcessor.Unpause();
                }
            }
        }
Exemplo n.º 13
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            BaseLoader <UserClassDefinitions> .Save(mFileName, mUserClassDefinitions);

            XMBProcessor.CreateXMB(mFileName, false);
        }
Exemplo n.º 14
0
        static public bool doExport(String terrainFileName,
                                    String scenarioFileName,
                                    String outputOverrideDir,
                                    ref ExportSettings expSettings, ref ExportResults results,
                                    bool doXTD, bool doXTT, bool doXTH, bool doXSD, bool doLRP, bool doDEP, bool doTAG, bool doXMB)
        {
            //This is now done outside using work topics
            //if (CoreGlobals.UsingPerforce == true)
            //{
            //   if (!checkPerforceFileAlloances(terrainFileName, scenarioFileName,
            //                                 doXTD, doXTT, doXTH, doXSD, doLRP, doDEP, doTAG, doXMB))
            //      return false;
            //}

            init();
            int maxValues = (doXTD?1:0) +
                            (doXTT?1:0) +
                            (doXTH?1:0) +
                            (doXSD?1:0) +
                            (doLRP?1:0) +
                            (doDEP?1:0) +
                            (doTAG?1:0) +
                            (doXMB?1:0) +
                            (expSettings.AmbientOcclusion != AmbientOcclusion.eAOQuality.cAO_Off?1:0)
            ;

            initOverrideDir(outputOverrideDir);


            mEPB.Init(maxValues);
            mEPB.setName(Path.GetFileNameWithoutExtension(terrainFileName));
            mEPB.Show();
            DateTime start = DateTime.Now;


            GC.Collect();
            GC.WaitForPendingFinalizers();


            mECF.clear();
            mDEP.clear();

            bool sofarSoGood = true;



            if (sofarSoGood && doXTT)
            {
                XTTExporter XTTexporter = new XTTExporter();
                sofarSoGood &= XTTexporter.export_XTT(terrainFileName, expSettings, ref results);
                XTTexporter.destroy();
                XTTexporter = null;
                ExportTo360.mECF.clear();
                ExportProgressDialog.Increase();
            }



            //From here on out we don't need textures in memory..
            if (sofarSoGood && (expSettings.AmbientOcclusion != AmbientOcclusion.eAOQuality.cAO_Off || doXTH))
            {
                BRenderDevice.getTextureManager().freeAllD3DTextureHandles();
            }



            if (sofarSoGood && doXTD)
            {
                XTDExporter XTDexporter = new XTDExporter();
                sofarSoGood &= XTDexporter.export_XTD(terrainFileName, expSettings, ref results);
                XTDexporter.destroy();
                XTDexporter = null;
                ExportTo360.mECF.clear();
                ExportProgressDialog.Increase();
            }



            if (sofarSoGood && doXSD)
            {
                XSDExporter XSDexporter = new XSDExporter();
                sofarSoGood &= XSDexporter.export_XSD(scenarioFileName, expSettings, ref results);
                XSDexporter.destroy();
                if (sofarSoGood && doLRP)
                {
                    sofarSoGood &= XSDexporter.CreateLRP(spliceFilenameWithOverride(scenarioFileName));
                }
                XSDexporter = null;
                ExportTo360.mECF.clear();
                ExportProgressDialog.Increase();
            }


            if (sofarSoGood && doXTH)
            {
                XTHExporter XTHexporter = new XTHExporter();
                sofarSoGood &= XTHexporter.export_XTH(terrainFileName, expSettings, ref results);
                XTHexporter.destroy();
                XTHexporter = null;
                ExportTo360.mECF.clear();
                ExportProgressDialog.Increase();
            }


            // OVERRIDE! if ANY terrain files are changed, then generate a .TAG
            if (sofarSoGood && doTAG && (doXTT | doXTD | doXTH | doXSD))
            {
                TAG      mTAG            = new TAG();
                String[] extentions      = new String[] { ".XTD", ".XTT", ".XTH", ".XSD", ".LRP" };
                String   desiredFilename = "";
                for (int i = 0; i < extentions.Length - 1; i++)
                {
                    desiredFilename = spliceFilenameWithOverride(Path.ChangeExtension(terrainFileName, extentions[i]));
                    mTAG.addFile(desiredFilename);
                }

                //XSD
                desiredFilename = spliceFilenameWithOverride(Path.ChangeExtension(scenarioFileName, extentions[extentions.Length - 2]));
                mTAG.addFile(desiredFilename);
                desiredFilename = spliceFilenameWithOverride(Path.ChangeExtension(scenarioFileName, extentions[extentions.Length - 1]));
                mTAG.addFile(desiredFilename);

                mTAG.writeToFile(spliceFilenameWithOverride(Path.ChangeExtension(scenarioFileName, ".TAG")));
                mTAG = null;


                ExportProgressDialog.Increase();
            }



            if (sofarSoGood && doXTT && doDEP) //CLM XTT is the only one that marks dependents currently...
            {
                mDEP.writeToFile(spliceFilenameWithOverride(terrainFileName));
            }



            if (sofarSoGood && doXMB)
            {
                string outputDir = null;
                if (mOutputOverrideDir != null)
                {
                    outputDir = spliceFilenameWithOverride(terrainFileName);
                    outputDir = Path.GetDirectoryName(outputDir);
                }

                if (File.Exists(Path.ChangeExtension(scenarioFileName, ".SCN")))
                {
                    XMBProcessor.CreateXMB(Path.ChangeExtension(scenarioFileName, ".SCN"), outputDir, false);
                }
                if (File.Exists(Path.ChangeExtension(scenarioFileName, ".GLS")))
                {
                    XMBProcessor.CreateXMB(Path.ChangeExtension(scenarioFileName, ".GLS"), outputDir, false);
                }

                if (File.Exists(Path.ChangeExtension(scenarioFileName, ".DEP")))
                {
                    XMBProcessor.CreateXMB(spliceFilenameWithOverride(Path.ChangeExtension(scenarioFileName, ".DEP")), false);
                }
                ExportProgressDialog.Increase();
            }



            TimeSpan ts = DateTime.Now - start;

            results.totalTime = ts.TotalMinutes;

            destroy();

            GC.Collect();
            GC.WaitForPendingFinalizers();

            //if we've cleared the textures, force them to reload..
            if (expSettings.AmbientOcclusion != AmbientOcclusion.eAOQuality.cAO_Off || doXTH)
            {
                BRenderDevice.getTextureManager().reloadTexturesIfNeeded(true);
            }

            mOutputOverrideDir = null;

            return(sofarSoGood);
        }