Пример #1
0
 public InMemory(string url, int pos, DirRec rec) : base(url, pos)
 {
     this.rec     = rec;
     display_text = url.Substring(url.LastIndexOf('/') + 1);
     Model.Add(url, this);
     Publisher.Register(this);
 }
Пример #2
0
        private void OnDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            Point    pt    = treeview.PointToClient(new Point(e.X, e.Y));

            DirRec   rec  = null;
            TreeNode node = treeview.GetNodeAt(pt);

            if (node == null)
            {
                rec = Iso9660.GetByPath("CD:ROOT");
            }
            else
            {
                rec = Iso9660.GetByPath(node.Name);
                if (!rec.FileFlags_Directory)
                {
                    node = node.Parent;
                    rec  = Iso9660.GetByPath(node.Name);
                }
            }
            if (node != null)
            {
                node.Expand();
            }
            Iso9660.ImportFiles(rec, files);
        }
Пример #3
0
 public static bool ImportFiles(DirRec dir, string[] files)
 {
     Console.WriteLine(dir.GetUrl());
     foreach (string file in files)
     {
         Console.WriteLine(file);
     }
     return(true);
     //if (!Iso9660.ReadFile(rec)) {
     //    return null;
     //}
     //byte[] data = new byte[rec.LenData];
     //if (!RamDisk.Get(rec.LbaData*2048, rec.LenData, data)) {
     //    return null;
     //}
     //string[] parts = rec.GetUrl().Split(new char[] {':'});
     //string dir = AppDomain.CurrentDomain.BaseDirectory+"tmp/";
     //string path = (dir+parts[1]).Replace('/', '\\');
     //try {
     //    Directory.CreateDirectory(Path.GetDirectoryName(path));
     //    FileStream file = File.Create(path);
     //    file.Write(data, 0, rec.LenData);
     //    file.Close();
     //    return path;
     //} catch (Exception e) {
     //    Logger.Fail("Cannot create file "+path+" "+e.Message);
     //    return null;
     //}
 }
Пример #4
0
        public static bool ResizeRecord(DirRec rec, int len)
        {
            // first check if there is enough space
            int lba = rec.LbaData;
            int num = (rec.LenData + 2047) / 2048;

            for (int i = num; i < len; i++)
            {
                if (RamDisk.map[lba + i] != 0)
                {
                    return(Logger.Fail("Cannot resize " + rec.GetFileName() + " not enough space"));
                }
            }
            // claim new sectors
            for (int i = num; i < len; i++)
            {
                RamDisk.map[lba + i] = 0x6F;
            }
            // free old sectors
            for (int i = len; i < num; i++)
            {
                RamDisk.map[lba + i] = 0x00;
            }
            rec.LenData = len;
            return(true);
        }
Пример #5
0
        public static string ExportDir(DirRec rec)
        {
            if (!Iso9660.ReadFile(rec))
            {
                return(null);
            }

            byte[] data = new byte[rec.LenRecord];
            if (!RamDisk.Get(rec.GetPos(), rec.LenRecord, data))
            {
                return(null);
            }

            string[] parts = rec.GetUrl().Split(new char[] { ':' });
            string   dir   = AppDomain.CurrentDomain.BaseDirectory + "tmp/";
            string   path  = (dir + parts[1]).Replace('/', '\\');

            try {
                Directory.CreateDirectory(Path.GetDirectoryName(path));
                FileStream file = File.Create(path);
                file.Write(data, 0, rec.LenRecord);
                file.Close();
                return(path);
            } catch (Exception e) {
                Logger.Fail("Cannot create file " + path + " " + e.Message);
                return(null);
            }
        }
Пример #6
0
 public MiscItem(string url, int pos, int index, DirRec rec) :
     base(url, 0, rec)
 {
     this.index = index;
     this.pos   = pos;
     name       = Model.GetRec("ITEMNAME.BIN");
     help       = Model.GetRec("ITEMHELP.BIN");
 }
Пример #7
0
 public RoomEnemySection(string url, int pos, int len, DirRec rec, Zone zone, Room room) :
     base(url, pos, rec)
 {
     this.len  = len;
     this.zone = zone;
     this.room = room;
     Enemies   = new List <RoomEnemy>();
 }
Пример #8
0
 public DirRec GetRootDir()
 {
     if (root == null)
     {
         root = new DirRec("CD:ROOT", GetPos() + 156);
     }
     return(root);
 }
Пример #9
0
        public override string GetExportName()
        {
            DirRec rec  = GetRec();
            string name = rec.GetFileName();

            string[] parts = name.Split(new char[] { '.' });
            return(parts[0] + "-IMAGE-" + id.ToString("D2"));
        }
Пример #10
0
 public Texture(string url, int pos, int len, int id, DirRec rec) :
     base(url, pos, rec)
 {
     this.id    = id;
     FileLength = this.len = len;
     this.buf   = new byte[len];
     RamDisk.Get(pos, len, buf);
     QueryFile();
 }
Пример #11
0
 public Actor(string url, int pos, DirRec rec,
              Zone zone, int zoneid, int actorid, DirRec zud_rec) :
     base(url, pos, rec)
 {
     this.zone    = zone;
     this.ZoneId  = zoneid;
     this.ActorId = actorid;
     zud          = Model.zuds[zud_rec.GetUrl()];
 }
Пример #12
0
 public Room(string url, int pos, DirRec rec,
             Zone zone, int zoneid, int roomid) :
     base(url, pos, rec)
 {
     mpd       = Model.mpds[rec.GetUrl()];
     this.zone = zone;
     ZoneId    = zoneid;
     RoomId    = roomid;
     Name      = rec.GetFileName();
 }
Пример #13
0
        public Zone(string url, int pos, DirRec rec) :
            base(url, pos, rec)
        {
            znd = Model.znds[rec.GetUrl()];

            string file = rec.GetFileName();
            string text = file.Substring(4, file.IndexOf('.') - 4);

            zoneid = int.Parse(text);
        }
Пример #14
0
        public static bool RenameRecord(DirRec rec, string name)
        {
            // compute new size of the record
            // make space for new record
            // update the parent records LenData
            // update affected records
            // rename the record

            // ALSO update the path tables if this record is a directory
            return(true);
        }
Пример #15
0
 public static void SetRec(string url, DirRec rec)
 {
     if (file_rec.ContainsKey(url))
     {
         file_rec[url] = rec;
     }
     else
     {
         file_rec.Add(url, rec);
     }
 }
Пример #16
0
        public string GetName(int index)
        {
            DirRec bin = Model.GetRec("ITEMNAME.BIN");

            if (bin != null)
            {
                int    pos     = bin.LbaData * 2048;
                byte[] kildean = new byte[0x18];
                RamDisk.Get(pos + index * 0x18, 0x18, kildean);
                return(Kildean.ToAscii(kildean));
            }
            return("");
        }
Пример #17
0
 public void OpenDisk()
 {
     treeview.Nodes.Clear();
     combobox.Items.Clear();
     combobox.Text = "";
     foreach (Zone zone in Model.zones.Values)
     {
         string key = zone.GetUrl();
         DirRec rec = zone.GetRec();
         string txt = rec.GetFileName();
         zones.Add(txt, key);
         combobox.Items.Add(txt);
     }
     sub_property.Notify(null);
 }
Пример #18
0
        public static bool ReadFile(DirRec dir)
        {
            int lba = dir.LbaData;
            int len = dir.LenData;

            for (int i = 0; i < len; i += 2048)
            {
                if (!RamDisk.Read(lba++))
                {
                    return(false);
                }
            }
            Logger.SetProgress(100);
            return(Logger.Pass("Read file " + dir.FileName));
        }
Пример #19
0
        public static int FindCapacity(DirRec rec)
        {
            int count    = (rec.LenData + 2047) / 2048;
            int capacity = count;

            for (int lba = rec.LbaData + count; lba < RamDisk.count; lba++)
            {
                if (Lba2Path.ContainsKey(lba))
                {
                    break;
                }
                capacity++;
            }
            return(capacity);
        }
Пример #20
0
        public static string FindCollision(DirRec rec, int sectors)
        {
            string collisions = "";
            int    lba        = rec.LbaData;
            int    len        = (rec.LenData + 2047) / 2048;

            for (int i = len; i < sectors; i++)
            {
                int key = lba + i;
                if (Lba2Path.ContainsKey(key))
                {
                    collisions = collisions + "    " + Lba2Path[key] + "\r\n";
                }
            }
            return(collisions);
        }
Пример #21
0
        public bool Load()
        {
            items.Clear();
            Iso9660.ReadFile(Model.GetRec("ITEMNAME.BIN"));
            Iso9660.ReadFile(Model.GetRec("ITEMHELP.BIN"));
            DirRec rec = Model.GetRec("ITEMNAME.BIN");

            for (int i = 0; i < 512; i++)
            {
                string   key = "DB:Items/Item_" + i;
                MiscItem obj = new MiscItem(key, 0, i, rec);
                items.Add(obj);
                Model.Add(key, obj);
                Publisher.Register(obj);
            }
            return(true);
        }
Пример #22
0
        public List <string> GetSkillNames()
        {
            List <string> list = new List <string>();
            DirRec        slus = Model.GetRec("SLUS");

            if (slus != null)
            {
                int index = 0;
                foreach (Skill skill in skills)
                {
                    string str = index.ToString("X2") + " " + skill.Name;
                    list.Add(str);
                    index++;
                }
            }
            return(list);
        }
Пример #23
0
        public bool OpenSection(TreeNode root)
        {
            DirRec rec   = GetRec();
            int    lba   = rec.LbaData;
            int    pos   = GetPos() - lba * 2048;
            int    count = len / 0x28;

            for (int i = 0; i < count; i++)
            {
                string    key   = GetUrl() + "/Enemy_" + i;
                RoomEnemy enemy = new RoomEnemy(key, pos + i * 0x28, rec, zone, room);
                string    name  = enemy.GetText();
                root.Nodes.Add(key, name, 35, 35);
                Enemies.Add(enemy);
            }
            return(true);
        }
Пример #24
0
        public bool Visit(string url, DirRec dir)
        {
            string   name = dir.GetFileName();
            TreeNode leaf = node.Nodes.Add(url, name);

            if (dir.FileFlags_Directory)
            {
                leaf.ImageIndex         = SysIcons.GetDirIconIndex(false);
                leaf.SelectedImageIndex = SysIcons.GetDirIconIndex(true);
                Iso9660.EnumDir(url, dir, new EnumDiskView(leaf));
            }
            else
            {
                int icon = SysIcons.GetFileIconIndex(name);
                leaf.ImageIndex = leaf.SelectedImageIndex = icon;
            }
            return(true);
        }
Пример #25
0
        public List <string> GetList()
        {
            List <string> list = new List <string>();
            DirRec        bin  = Model.GetRec("ITEMNAME.BIN");

            if (bin != null)
            {
                int pos = bin.LbaData * 2048;
                for (int i = 0; i < 512; i++)
                {
                    byte[] kildean = new byte[0x18];
                    RamDisk.Get(pos + i * 0x18, 0x18, kildean);
                    string str = Kildean.ToAscii(kildean);
                    list.Add(str);
                }
            }
            return(list);
        }
Пример #26
0
        public bool AddRoom(TreeNode root, int id, int pos)
        {
            int lba = RamDisk.GetS32(pos + 8 * id);

            try {
                string url = GetUrl() + "/Room/" + id;
                DirRec mpd = Iso9660.GetByLba(lba);
                Room   obj = new Room(mpd.GetUrl(), 0, mpd, this, zoneid, id);
                rooms.Add(obj);
                Model.Add(url, obj);
                Publisher.Register(obj);

                TreeNode node = root.Nodes.Add(url, mpd.GetFileName(), 1, 1);
                obj.AddRoom(node, url, id, pos);
                return(true);
            } catch {
                return(false);
            }
        }
Пример #27
0
        public bool Load()
        {
            skills.Clear();
            DirRec slus = Model.GetRec("SLUS");

            if (slus != null)
            {
                int    pos = 0x0003C1DC;
                byte[] buf = new byte[0x34];
                for (int i = 0; i < 256; i++)
                {
                    string key = "DB:Skills/Skill_" + i;
                    Skill  obj = new Skill(key, pos + i * 0x34, slus);
                    skills.Add(obj);
                    Model.Add(key, obj);
                    Publisher.Register(obj);
                }
            }
            return(true);
        }
Пример #28
0
        public int GetIndexByName(string name)
        {
            DirRec bin = Model.GetRec("ITEMNAME.BIN");

            if (bin != null)
            {
                int pos = bin.LbaData * 2048;
                for (int i = 0; i < 512; i++)
                {
                    byte[] kildean = new byte[0x18];
                    RamDisk.Get(pos + i * 0x18, 0x18, kildean);
                    string str = Kildean.ToAscii(kildean);
                    if (str == name)
                    {
                        return(i);
                    }
                }
            }
            return(0);
        }
Пример #29
0
        private void OnTree_NodeChange(object sender, TreeViewEventArgs e)
        {
            TreeNode node = treeview.SelectedNode;

            if (node != null)
            {
                string url = node.Name;
                if (url == "CD:PVD")
                {
                    sub_property.Notify(Iso9660.pvd);
                }
                else
                {
                    DirRec rec = Iso9660.GetByPath(url);
                    sub_property.Notify(rec);
                }
            }
            else
            {
                sub_property.Notify(null);
            }
        }
Пример #30
0
        public static bool MoveRecord(DirRec rec, int lba)
        {
            // first check if there is enough space
            int old = rec.LbaData;
            int len = (rec.LenData + 2047) / 2048;

            for (int i = 0; i < len; i++)
            {
                // self intersection is not a problem
                if ((lba + i >= old) && (lba + i < old + len))
                {
                    continue;
                }
                // check for collisions
                if (RamDisk.map[lba + i] != 0)
                {
                    return(Logger.Fail("Cannot move " + rec.GetFileName() + " not enough space"));
                }
            }
            // swap the sectors
            for (int i = 0; i < len; i++)
            {
                int src = old + i;
                int des = lba + i;
                if (!RamDisk.Swap(src, des))
                {
                    return(false);
                }
            }
            rec.LbaData = lba;
            for (int i = 0; i < len; i++)
            {
                RamDisk.map[lba + i] = 0x78;
                RamDisk.map[old + i] = 0x00;
            }
            return(true);
        }