Ejemplo n.º 1
0
        public bool LoadParticleSystem(string filename)
        {
            /*
             * // make sure we have it checked out
             * if ((File.GetAttributes(filename) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
             * {
             * string str = String.Format("File : {0} is read only!\nYou are not allowed to load!\nMake sure you checked the file out of Perforce!", filename);
             * MessageBox.Show(str, "Read Only File", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             * return false;
             * }
             */

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

            mEffect = (ParticleEffect)s.Deserialize(st);
            st.Close();
            mEffect.postDeserialization();
            ResourcePathInfo pathInfo = new ResourcePathInfo(filename);

            mEffect.Name = pathInfo.RelativePath;

            //- strip out the art directory.   ResourcePathInfo should do this for you
            if (mArtDir.Length > 0)
            {
                mEffect.Name = mEffect.Name.Substring(mArtDir.Length);
            }

            bindData(0);
            refreshTreeView(true);
            return(true);
        }
Ejemplo n.º 2
0
        public bool SaveParticleSystem(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);

            mEffect.Name = pathInfo.RelativePath;

            //- strip out the art directory.   ResourcePathInfo should do this for you
            if (mArtDir.Length > 0)
            {
                mEffect.Name = mEffect.Name.Substring(mArtDir.Length);
            }

            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);


            SetTabName(mEffect.Name);
            return(true);
        }