Example #1
0
        public void Export(ObjectFX obj, string path)
        {
            UIObjectFX fx           = (UIObjectFX)obj;
            string     originalText = fx.OriginalText;
            List <int> indexList    = new List <int>();

            foreach (ControlObject controlObject in fx.ControlObjects)
            {
                indexList.Add(controlObject._Index);
            }
            indexList.Sort();
            indexList.Reverse();

            foreach (int index in indexList)
            {
                foreach (ControlObject controlObject in fx.ControlObjects)
                {
                    int startIndex = controlObject._Index;

                    if (startIndex == index)
                    {
                        int length = controlObject._Length;

                        originalText = originalText.Remove(startIndex, length);
                        originalText = originalText.Insert(startIndex, Format(controlObject));

                        break;
                    }
                }
            }
            File.WriteAllText(path, originalText, Encoding);
        }
Example #2
0
        public ObjectFX Import(string path)
        {
            if (!IsImportable(path))
            {
                throw new Exception(Resources.Msg_FormatException);
            }

            UIObjectFX obj = new UIObjectFX("MMEffectUI")
            {
                OriginalText = File.ReadAllText(path, Encoding),
            };

            obj.Data.Add("IMPORTPLUGIN", Name);
            obj.Data.Add("IMPORTPLUGIN_VERSION", Version);
            obj.Data.Add("IMPORTPLUGIN_GUID", Guid);

            foreach (Match match in regex.Matches(obj.OriginalText))
            {
                ControlObject controlObject = new ControlObject()
                {
                    Type  = match.Groups["type"].Value,
                    Name  = match.Groups["name"].Value,
                    Value = match.Groups["value"].Value
                };

                for (int i = 0; i < match.Groups["a_type"].Captures.Count; i++)
                {
                    ControlObject co = new ControlObject()
                    {
                        Type  = match.Groups["a_type"].Captures[i].Value,
                        Name  = match.Groups["a_name"].Captures[i].Value,
                        Value = match.Groups["a_value"].Captures[i].Value.Replace("\"", ""),
                    };

                    controlObject.ControlObjects.Add(co);
                }

                controlObject.IsStatic = match.Groups["static"].Success;
                controlObject.IsConst  = match.Groups["const"].Success;
                controlObject._Index   = match.Index;
                controlObject._Length  = match.Length;

                obj.ControlObjects.Add(controlObject);
            }

            return(obj);
        }