예제 #1
0
        public bool Open(PTP PTP, Encoding New)
        {
            Name.Clear();
            Msg.Clear();
            foreach (var a in PTP.names)
            {
                Name.Add(new Names(a.Index, a.NewName.GetTextBaseList(New).GetByteArray().ToArray()));
            }

            foreach (var a in PTP.msg)
            {
                int          Index          = a.Index;
                string       Name           = a.Name;
                MSGs.MsgType Type           = a.Type == "MSG" ? MSGs.MsgType.MSG : MSGs.MsgType.SEL;
                int          CharacterIndex = a.CharacterIndex;

                byte[] MsgBytes = a.GetNew(New);

                Msg.Add(new MSGs(Index, Name, Type, CharacterIndex, MsgBytes.ToArray()));
            }

            return(true);
        }
예제 #2
0
        public static void SaveOldPTP(PTP ptp, string path)
        {
            XDocument xDoc     = new XDocument();
            XElement  Document = new XElement("MSG1");

            xDoc.Add(Document);
            XElement CharName = new XElement("CharacterNames");

            Document.Add(CharName);

            foreach (var NAME in ptp.names)
            {
                XElement Name = new XElement("Name");
                Name.Add(new XAttribute("Index", NAME.Index));
                Name.Add(new XElement("OldNameSource", BitConverter.ToString(NAME.OldName)));
                Name.Add(new XElement("NewName", NAME.NewName));
                CharName.Add(Name);
            }

            XElement MES = new XElement("MSG");

            Document.Add(MES);

            foreach (var MSG in ptp.msg)
            {
                XElement Msg = new XElement("Message");
                Msg.Add(new XAttribute("Index", MSG.Index));
                Msg.Add(new XElement("Type", MSG.Type));
                Msg.Add(new XElement("Name", MSG.Name));
                Msg.Add(new XElement("CharacterNameIndex", MSG.CharacterIndex));

                XElement Strings = new XElement("MessageStrings");
                Msg.Add(Strings);
                foreach (var STR in MSG.Strings)
                {
                    XElement String = new XElement("String");
                    String.Add(new XAttribute("Index", STR.Index));
                    Strings.Add(String);

                    for (int i = 0; i < STR.Prefix.Count; i++)
                    {
                        XElement PrefixBytes = new XElement("PrefixBytes", BitConverter.ToString(STR.Prefix[i].Array));
                        PrefixBytes.Add(new XAttribute("Index", i));
                        PrefixBytes.Add(new XAttribute("Type", STR.Prefix[i].IsText ? "Text" : "System"));
                        String.Add(PrefixBytes);
                    }

                    for (int i = 0; i < STR.OldString.Count; i++)
                    {
                        XElement OldStringBytes = new XElement("OldStringBytes", BitConverter.ToString(STR.OldString[i].Array));
                        OldStringBytes.Add(new XAttribute("Index", i));
                        OldStringBytes.Add(new XAttribute("Type", STR.OldString[i].IsText ? "Text" : "System"));
                        String.Add(OldStringBytes);
                    }

                    String.Add(new XElement("NewString", STR.NewString));

                    for (int i = 0; i < STR.Postfix.Count; i++)
                    {
                        XElement PostfixBytes = new XElement("PostfixBytes", BitConverter.ToString(STR.Postfix[i].Array));
                        PostfixBytes.Add(new XAttribute("Index", i));
                        PostfixBytes.Add(new XAttribute("Type", STR.Postfix[i].IsText ? "Text" : "System"));
                        String.Add(PostfixBytes);
                    }
                }

                MES.Add(Msg);
            }

            xDoc.Save(path);
        }