Ejemplo n.º 1
0
 public Macro Clone()
 {
     Macro M = new Macro(this.Name_);
       for (int i = 0; i < 6; ++i)
     M.Commands_[i] = this.Commands_[i];
       return M;
 }
Ejemplo n.º 2
0
 public void Remove(Macro M)
 {
     this.InnerList.Remove(M);
 }
Ejemplo n.º 3
0
 public int  IndexOf(Macro M)
 {
     return(this.InnerList.IndexOf(M));
 }
Ejemplo n.º 4
0
 public bool Contains(Macro M)
 {
     return(this.InnerList.Contains(M));
 }
Ejemplo n.º 5
0
 public void Add(Macro M)
 {
     this.InnerList.Add(M);
 }
Ejemplo n.º 6
0
 internal static Macro LoadFromXml(XmlElement MacroNode)
 {
     Macro M = new Macro();
     if (MacroNode.Attributes["name"] != null)
     {
         M.Name_ = MacroNode.Attributes["name"].InnerText;
     }
     Encoding E = new FFXIEncoding();
     for (int i = 0; i < 6; ++i)
     {
         XmlNode CommandNode = MacroNode.SelectSingleNode(String.Format("command[@line = {0}]", i + 1));
         if (CommandNode != null && CommandNode is XmlElement)
         {
             string CommandText = String.Empty;
             foreach (XmlNode XN in CommandNode.ChildNodes)
             {
                 if (XN is XmlText)
                 {
                     CommandText += XN.InnerText;
                 }
             }
             M.Commands_[i] = CommandText;
         }
     }
     return M;
 }
Ejemplo n.º 7
0
 internal static Macro ReadFromDATFile(BinaryReader BR, Encoding E)
 {
     Macro M = new Macro();
     if (BR != null)
     {
         BR.ReadInt32(); // Unknown
         for (int i = 0; i < 6; ++i)
         {
             // 6 Lines of text, 61 bytes each, null-terminated shift-jis
             string Command = "";
             Command = E.GetString(BR.ReadBytes(61));
             M.Commands_[i] = Command.TrimEnd('\0');
         }
         M.Name_ = E.GetString(BR.ReadBytes(10)).TrimEnd('\0');
     }
     return M;
 }
Ejemplo n.º 8
0
 public void Remove(Macro   M)
 {
     this.InnerList.Remove  (M);
 }
Ejemplo n.º 9
0
 public int IndexOf(Macro   M)
 {
     return this.InnerList.IndexOf (M);
 }
Ejemplo n.º 10
0
 public bool Contains(Macro   M)
 {
     return this.InnerList.Contains(M);
 }
Ejemplo n.º 11
0
 public void AddRange(Macro[] M)
 {
     this.InnerList.AddRange(M);
 }
Ejemplo n.º 12
0
 public void Add(Macro   M)
 {
     this.InnerList.Add     (M);
 }
Ejemplo n.º 13
0
        public static MacroFolder Load(string PathName, string FolderName)
        {
            FileStream DATFile = null;

            if (File.Exists(PathName))
            {
                try { DATFile = new FileStream(PathName, FileMode.Open, FileAccess.Read, FileShare.Read); }
                catch { }
            }
            BinaryReader BR = null;

            if (DATFile != null)
            {
                try {
                    BR = new BinaryReader(DATFile, Encoding.ASCII);
                    if (BR.BaseStream.Length != 7624 || BR.ReadUInt32() != 1)
                    {
                        BR.Close();
                        BR = null;
                    }
                    if (BR != null)
                    {
                        BR.ReadUInt32();                     // Unknown - sometimes zero, sometimes 0x80000000
                        byte[] StoredMD5 = BR.ReadBytes(16); // MD5 Checksum of the rest of the data
#if VerifyChecksum
                        {
                            byte[] Data = BR.ReadBytes(7600);
                            BR.BaseStream.Seek(-7600, SeekOrigin.Current);
                            MD5    Hash        = new MD5CryptoServiceProvider();
                            byte[] ComputedMD5 = Hash.ComputeHash(Data);
                            for (int i = 0; i < 16; ++i)
                            {
                                if (StoredMD5[i] != ComputedMD5[i])
                                {
                                    string Message = String.Format("MD5 Checksum failure for {0}:\n- Stored Hash  :", PathName);
                                    for (int j = 0; j < 16; ++j)
                                    {
                                        Message += String.Format(" {0:X2}", StoredMD5[j]);
                                    }
                                    Message += "\n- Computed Hash:";
                                    for (int j = 0; j < 16; ++j)
                                    {
                                        Message += String.Format(" {0:X2}", ComputedMD5[j]);
                                    }
                                    Message += '\n';
                                    MessageBox.Show(null, Message, "Warning");
                                    break;
                                }
                            }
                        }
#endif
                    }
                } catch { }
            }
            MacroSet MS = new MacroSet(FolderName);
            MS.FileName_ = PathName;
            MS.Folders.Add(new MacroFolder("Top Bar (Control)"));
            MS.Folders.Add(new MacroFolder("Bottom Bar (Alt)"));
            Encoding E = new FFXIEncoding();
            for (int i = 0; i < 2; ++i)
            {
                for (int j = 0; j < 10; ++j)
                {
                    MS.Folders[i].Macros.Add((BR != null) ? Macro.ReadFromDATFile(BR, E) : new Macro());
                }
            }
            MS.LockTree();
            if (BR != null)
            {
                BR.Close();
            }
            return(MS);
        }