Beispiel #1
0
        public void OpenXmlPTP(Stream stream)
        {
            XDocument xDoc = XDocument.Load(stream, LoadOptions.PreserveWhitespace);

            XElement MSG1Doc = xDoc.Element("MSG1");

            foreach (var NAME in MSG1Doc.Element("CharacterNames").Elements())
            {
                int    Index         = Convert.ToInt32(NAME.Attribute("Index").Value);
                string OldNameSource = NAME.Element("OldNameSource").Value;
                string NewName       = NAME.Element("NewName").Value;

                names.Add(new PTPName(Index, OldNameSource, NewName));
            }

            foreach (var Message in MSG1Doc.Element("MSG").Elements())
            {
                int    Index = Convert.ToInt32(Message.Attribute("Index").Value);
                string Type  = Message.Element("Type").Value;
                string Name  = Message.Element("Name").Value;
                int    CharacterNameIndex = Convert.ToInt32(Message.Element("CharacterNameIndex").Value);

                MSG temp = new MSG(Index, Type, Name, CharacterNameIndex);
                msg.Add(temp);

                foreach (var Strings in Message.Element("MessageStrings").Elements())
                {
                    int    StringIndex = Convert.ToInt32(Strings.Attribute("Index").Value);
                    string NewString   = Strings.Element("NewString").Value;

                    MSGstr temp2 = new MSGstr(StringIndex, NewString)
                    {
                        CharacterIndex = CharacterNameIndex
                    };
                    temp.Strings.Add(temp2);

                    foreach (var Prefix in Strings.Elements("PrefixBytes"))
                    {
                        int    PrefixIndex = Convert.ToInt32(Prefix.Attribute("Index").Value);
                        string PrefixType  = Prefix.Attribute("Type").Value;
                        string PrefixBytes = Prefix.Value;

                        temp2.Prefix.Add(new TextBaseElement(PrefixType == "Text" ? true : false, PersonaEditorLib.Utilities.String.SplitString(PrefixBytes, '-')));
                    }

                    foreach (var Old in Strings.Elements("OldStringBytes"))
                    {
                        int    OldIndex = Convert.ToInt32(Old.Attribute("Index").Value);
                        string OldType  = Old.Attribute("Type").Value;
                        string OldBytes = Old.Value;

                        temp2.OldString.Add(new TextBaseElement(OldType == "Text" ? true : false, PersonaEditorLib.Utilities.String.SplitString(OldBytes, '-')));
                    }

                    foreach (var Postfix in Strings.Elements("PostfixBytes"))
                    {
                        int    PostfixIndex = Convert.ToInt32(Postfix.Attribute("Index").Value);
                        string PostfixType  = Postfix.Attribute("Type").Value;
                        string PostfixBytes = Postfix.Value;

                        temp2.Postfix.Add(new TextBaseElement(PostfixType == "Text" ? true : false, PersonaEditorLib.Utilities.String.SplitString(PostfixBytes, '-')));
                    }
                }
            }
        }
Beispiel #2
0
        public static void ParseStrings(this IList <MSGstr> Strings, byte[] SourceBytes)
        {
            Strings.Clear();

            int Index = 0;

            foreach (var Bytes in SplitSourceBytes(SourceBytes))
            {
                MSGstr MSG = new MSGstr(Index, "");

                List <TextBaseElement> temp = Bytes.GetTextBaseList();

                int tempdown = 0;
                int temptop  = temp.Count;

                for (int i = 0; i < temp.Count; i++)
                {
                    if (temp[i].IsText)
                    {
                        tempdown = i;
                        i        = temp.Count;
                    }
                    else
                    {
                        MSG.Prefix.Add(temp[i]);
                    }
                }

                if (MSG.Prefix.Count < temp.Count)
                {
                    for (int i = temp.Count - 1; i >= tempdown; i--)
                    {
                        if (temp[i].IsText)
                        {
                            temptop = i;
                            i       = 0;
                        }
                        else
                        {
                            MSG.Postfix.Add(temp[i]);
                        }
                    }

                    var temparray = MSG.Postfix.Reverse().ToList();

                    MSG.Postfix.Clear();
                    foreach (var a in temparray)
                    {
                        MSG.Postfix.Add(a);
                    }


                    for (int i = tempdown; i <= temptop; i++)
                    {
                        MSG.OldString.Add(temp[i]);
                    }
                }

                Strings.Add(MSG);
                Index++;
            }
        }