Beispiel #1
0
 public static MacroBook[] Load(Character C)
 {
     string BookNameFile = C.GetUserFileName("mcr.ttl");
       if (!File.Exists(BookNameFile))
     return null;
     BinaryReader BR = new BinaryReader(new FileStream(BookNameFile, FileMode.Open, FileAccess.Read), Encoding.ASCII);
     int BookCount = 1;
       if ((BR.BaseStream.Length - 0x18) % 16 != 0 || BR.ReadUInt32() != 1) {
     BR.Close();
     return null;
       }
       else {
     BookCount = (int) ((BR.BaseStream.Length - 0x18) / 16);
       }
       BR.BaseStream.Seek(0x18, SeekOrigin.Begin);
     List<MacroBook> Books = new List<MacroBook>();
       for (int i = 0; i < BookCount; ++i) {
       MacroBook MB = new MacroBook(BookNameFile, i, new string(BR.ReadChars(16)).TrimEnd('\0'));
     for (int j = 0; j < 10; ++j)
       MB.Folders.Add(MacroSet.Load(C.GetUserFileName(string.Format("mcr{0:#####}.dat", 10 * i + j)), string.Format("Macro Set {0}", j + 1)));
     Books.Add(MB);
       }
       BR.Close();
       return Books.ToArray();
 }
Beispiel #2
0
        public static MacroBook[] Load(Character C)
        {
            string BookNameFile = C.GetUserFileName("mcr.ttl");

            if (!File.Exists(BookNameFile))
            {
                return(null);
            }
            BinaryReader BR        = new BinaryReader(new FileStream(BookNameFile, FileMode.Open, FileAccess.Read), Encoding.ASCII);
            int          BookCount = 1;

            if ((BR.BaseStream.Length - 0x18) % 16 != 0 || BR.ReadUInt32() != 1)
            {
                BR.Close();
                return(null);
            }
            else
            {
                BookCount = (int)((BR.BaseStream.Length - 0x18) / 16);
            }
            BR.BaseStream.Seek(0x18, SeekOrigin.Begin);
            List <MacroBook> Books = new List <MacroBook>();

            for (int i = 0; i < BookCount; ++i)
            {
                MacroBook MB = new MacroBook(BookNameFile, i, new string(BR.ReadChars(16)).TrimEnd('\0'));
                for (int j = 0; j < 10; ++j)
                {
                    MB.Folders.Add(MacroSet.Load(C.GetUserFileName(string.Format("mcr{0:#####}.dat", 10 * i + j)), string.Format("Macro Set {0}", j + 1)));
                }
                Books.Add(MB);
            }
            BR.Close();
            return(Books.ToArray());
        }
Beispiel #3
0
 public CharacterMacros(Character C) : base(C.Name)
 {
     MacroBook[] Books = MacroBook.Load(C);
     if (Books != null)
     {
         this.Folders.AddRange(Books);
     }
     else
     {
         for (int j = 0; j < 10; ++j)
         {
             this.Folders.Add(MacroSet.Load(C.GetUserFileName(string.Format("mcr{0:#####}.dat", j)), string.Format("Macro Set {0}", j + 1)));
         }
     }
 }