예제 #1
0
        public static void ParseStrings(IList <PTPMSGstr> Strings, byte[][] SourceBytes)
        {
            Strings.Clear();

            int Index = 0;

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

                List <TextBaseElement> temp = Bytes.GetTextBases().ToList();

                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++;
            }
        }
예제 #2
0
        private 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);
                int    Type  = Message.Element("Type").Value == "MSG" ? 0 : 1;
                string Name  = Message.Element("Name").Value;
                int    CharacterNameIndex = Convert.ToInt32(Message.Element("CharacterNameIndex").Value);

                PTPMSG temp = new PTPMSG(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;

                    PTPMSGstr temp2 = new PTPMSGstr(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, StringTool.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, StringTool.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, StringTool.SplitString(PostfixBytes, '-')));
                    }
                }
            }
        }