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); } }
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); }
// ******************************************************************** // initialize model from file // ******************************************************************** public static bool Open() { Iso9660.EnumFileSys(new EnumModelFiles()); itemnames.Load(); skills.Load(); return(true); }
private void OnMenu_FileOpen(object sender, EventArgs e) { ofd.Title = "Open CD Image"; ofd.Filter = "CD Images|*.bin;*.img;*.iso|All Files|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { if (Iso9660.Open(ofd.FileName)) { //sub_property.Notify(Iso9660.pvd); //sub_property.Notify(Iso9660.root); zndeditor.OpenDisk(); } } }
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); }
public bool Notify(object obj) { win.Nodes.Clear(); this.obj = obj; if (obj != null) { string volume = Iso9660.pvd.VolumeIdentifier.Trim(); TreeNode root = win.Nodes.Add("CD:PVD", "CDROM"); root.ImageIndex = SysIcons.GetDiskIconIndex(); root.SelectedImageIndex = root.ImageIndex; TreeNode node = root.Nodes.Add("CD:ROOT", volume); node.ImageIndex = SysIcons.GetDiskIconIndex(); node.SelectedImageIndex = node.ImageIndex; return(Iso9660.EnumFileSys(new EnumDiskView(node))); } return(true); }
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); }
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); } }
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); } }
private void OnTreeDrag(object sender, ItemDragEventArgs e) { TreeNode node = e.Item as TreeNode; if (node == null) { return; } DirRec rec = Iso9660.GetByPath(node.Name); if (rec != null) { string path = (rec.FileFlags_Directory) ? Iso9660.ExportDir(rec) : Iso9660.ExportFile(rec); if (path != null) { string[] files = new string[] { path }; DataObject obj = new DataObject(DataFormats.FileDrop, files); DoDragDrop(obj, DragDropEffects.Copy | DragDropEffects.Move); } } }
public bool Visit(string url, DirRec dir) { string name = dir.GetFileName(); string ext = dir.GetFileExt(); if (extensions.Contains(ext)) { //Iso9660.ReadFile(dir); int lba = dir.LbaData; int len = dir.LenData; int pos = lba * 2048; switch (ext) { case ".BIN": Model.bins.Add(url, new BIN(url, pos)); break; case ".DAT": Model.dats.Add(url, new DAT(url, pos)); break; case ".PRG": Model.prgs.Add(url, new PRG(url, pos)); break; case ".SYD": Model.syds.Add(url, new SYD(url, pos)); break; case ".ARM": Model.arms.Add(url, new ARM(url, pos)); break; case ".ZND": Model.znds.Add(url, new ZND(url, pos)); break; case ".MPD": Model.mpds.Add(url, new MPD(url, pos)); break; case ".ZUD": Model.zuds.Add(url, new ZUD(url, pos)); break; case ".SHP": Model.shps.Add(url, new SHP(url, pos)); break; case ".WEP": Model.weps.Add(url, new WEP(url, pos)); break; case ".SEQ": Model.seqs.Add(url, new SEQ(url, pos)); break; } switch (ext) { case ".BIN": case ".DAT": case ".PRG": case ".SYD": case ".ARM": case ".ZND": case ".MPD": case ".ZUD": case ".SEQ": case ".SHP": case ".WEP": Model.SetPos(name, pos); Model.SetLen(name, len); Model.SetRec(name, dir); if (name == "ITEMNAME.BIN") { Model.SetPos("ITEMNAME.BIN", dir.LbaData * 2048); Model.SetLen("ITEMNAME.BIN", dir.LenData); Model.SetRec("ITEMNAME.BIN", dir); } if (name == "ITEMHELP.BIN") { Model.SetPos("ITEMHELP.BIN", dir.LbaData * 2048); Model.SetLen("ITEMHELP.BIN", dir.LenData); Model.SetRec("ITEMHELP.BIN", dir); } if (name == "00.SHP") { Model.lba_00_shp = lba; } if (name == "01.WEP") { Model.lba_01_wep = lba; } break; } if (ext == ".ZND") { string[] parts = url.Split(new char[] { ':' }); if (parts.Length > 1) { string key = "APP:" + parts[1]; Zone zone = new Zone(key, 0, dir); Model.zones.Add(key, zone); Model.Add(key, zone); Publisher.Register(zone); } } } else if (name.Contains("SLUS")) { int pos = dir.LbaData * 2048; int len = dir.LenData; Model.SetPos("SLUS", pos); Model.SetLen("SLUS", len); Model.SetRec("SLUS", dir); PRG prg = new PRG(url, pos); Model.prgs.Add(url, prg); Publisher.Register(prg); } else if (dir.FileFlags_Directory) { return(Iso9660.EnumDir(url, dir, this)); } return(true); }
private void OnMenu_FileClose(object sender, EventArgs e) { Iso9660.Close(); zndeditor.CloseDisk(); }
public bool AddActor(TreeNode root, int id, int pos, int lba) { try { // ************************************************************ // Add the actor string url = GetUrl() + "/Actors/Actor_" + id; string znd_file = GetRec().GetFileName(); DirRec zud = Iso9660.GetByLba(lba); Actor obj = new Actor(url, pos, GetRec(), this, zoneid, id, zud); actors.Add(obj); Model.Add(url, obj); Publisher.Register(obj); TreeNode node = root.Nodes.Add(url, obj.Name, 2, 2); // ************************************************************ // Add the ZUD file TreeNode tv_model = node.Nodes.Add(url + "/Model", zud.GetFileName(), 28, 28); tv_model.Nodes.Add(url + "/Model/SHP", "SHP", 28, 28); tv_model.Nodes.Add(url + "/Model/WEP", "WEP", 28, 28); tv_model.Nodes.Add(url + "/Model/SEQ", "SEQ Common", 29, 29); tv_model.Nodes.Add(url + "/Model/SEQ", "SEQ Battle", 29, 29); // ************************************************************ // Add bodyparts for (int j = 0; j < 6; j++) { string[] part_name = new string[] { "L.ARM", "R.ARM", "HEAD", "BODY", "LEGS", "OTHER", }; int ptr_part = pos + 0x238 + j * 0x5C; string k1 = url + "/BodyParts/" + part_name[j]; ActorBodyPart part = new ActorBodyPart(k1, ptr_part, GetRec()); bodyparts.Add(part); Model.Add(k1, part); Publisher.Register(part); } TreeNode tv_body = node.Nodes.Add(url + "/BodyParts", "BodyParts", 5, 5); tv_body.Nodes.Add(url + "/BodyParts/L.ARM", "L.ARM", 8, 8); tv_body.Nodes.Add(url + "/BodyParts/R.ARM", "R.ARM", 8, 8); tv_body.Nodes.Add(url + "/BodyParts/HEAD", "HEAD", 6, 6); tv_body.Nodes.Add(url + "/BodyParts/BODY", "BODY", 7, 7); tv_body.Nodes.Add(url + "/BodyParts/LEGS", "LEGS", 9, 9); tv_body.Nodes.Add(url + "/BodyParts/OTHER", "OTHER", 5, 5); // ************************************************************ // Add armours for (int j = 0; j < 6; j++) { string[] part_name = new string[] { "L.ARM", "R.ARM", "HEAD", "BODY", "LEGS", "OTHER", }; int ptr_part = pos + 0x238 + j * 0x5C + 0x20; string k2 = url + "/Equip/" + part_name[j]; ActorArmour armour = new ActorArmour(k2, ptr_part, GetRec()); armours.Add(armour); Model.Add(k2, armour); Publisher.Register(armour); } TreeNode tv_equip = node.Nodes.Add(url + "/Equip", "Equipment", 39, 39); tv_equip.Nodes.Add(url + "/Equip/L.ARM", "L.ARM", 8, 8); tv_equip.Nodes.Add(url + "/Equip/R.ARM", "R.ARM", 8, 8); tv_equip.Nodes.Add(url + "/Equip/HEAD", "HEAD", 6, 6); tv_equip.Nodes.Add(url + "/Equip/BODY", "BODY", 7, 7); tv_equip.Nodes.Add(url + "/Equip/LEGS", "LEGS", 9, 9); tv_equip.Nodes.Add(url + "/Equip/OTHER", "OTHER", 5, 5); // ************************************************************ // Add weapon ActorWeapon weapon = new ActorWeapon(url + "/Weapon", pos + 0x34, GetRec()); weapons.Add(weapon); Model.Add(url + "/Weapon", weapon); Publisher.Register(weapon); ActorBlade blade = new ActorBlade(url + "/Weapon/Blade", pos + 0x34, GetRec()); blades.Add(blade); Model.Add(url + "/Weapon/Blade", blade); Publisher.Register(blade); ActorGrip grip = new ActorGrip(url + "/Weapon/Grip", pos + 0x64, GetRec()); grips.Add(grip); Model.Add(url + "/Weapon/Grip", grip); Publisher.Register(grip); for (int j = 0; j < 3; j++) { int ptr_gem = pos + 0x94 + j * 0x30; string key = url + "/Weapon/Gem" + (j + 1); ActorGem gem = new ActorGem(key, ptr_gem, GetRec()); weapon_gems.Add(gem); Model.Add(key, gem); Publisher.Register(gem); } TreeNode tv_weapon = node.Nodes.Add(url + "/Weapon", "Weapon", 12, 12); tv_weapon.Nodes.Add(url + "/Weapon/Blade", "Blade", 13, 13); tv_weapon.Nodes.Add(url + "/Weapon/Grip", "Grip", 14, 14); tv_weapon.Nodes.Add(url + "/Weapon/Gem1", "Gem1", 24, 24); tv_weapon.Nodes.Add(url + "/Weapon/Gem2", "Gem2", 25, 25); tv_weapon.Nodes.Add(url + "/Weapon/Gem3", "Gem3", 26, 26); // ************************************************************ // Add shield ActorShield shield = new ActorShield(url + "/Shield", pos + 0x140, GetRec()); shields.Add(shield); Model.Add(url + "/Shield", shield); Publisher.Register(shield); for (int j = 0; j < 3; j++) { int ptr_gem = pos + 0x170 + j * 0x30; string key = url + "/Shield/Gem" + (j + 1); ActorGem gem = new ActorGem(key, ptr_gem, GetRec()); shield_gems.Add(gem); Model.Add(key, gem); Publisher.Register(gem); } TreeNode tv_shield = node.Nodes.Add(url + "/Shield", "Shield", 11, 11); tv_shield.Nodes.Add(url + "/Shield/Gem1", "Gem1", 24, 24); tv_shield.Nodes.Add(url + "/Shield/Gem2", "Gem2", 25, 25); tv_shield.Nodes.Add(url + "/Shield/Gem3", "Gem3", 26, 26); // ************************************************************ // Add accessory TreeNode tv_accessory = node.Nodes.Add(url + "/Accessory", "Accessory", 10, 10); ActorAccessory accessory = new ActorAccessory(url + "/Accessory", pos + 0x204, GetRec()); accessories.Add(accessory); Model.Add(url + "/Accessory", accessory); Publisher.Register(accessory); return(true); } catch { return(false); } }
public bool OpenZone(TreeView treeview) { DirRec rec = GetRec(); Iso9660.ReadFile(rec); int pos = znd.GetPos(); treeview.Nodes.Clear(); TreeNode root = new TreeNode(rec.GetFileName(), 0, 0); TreeNode tv_rooms = root.Nodes.Add("Zone/Rooms", "Rooms", 1, 1); TreeNode tv_actor = root.Nodes.Add("Zone/Actors", "Actors", 2, 2); TreeNode tv_image = root.Nodes.Add("Zone/Images", "Images", 3, 3); tv_rooms.ToolTipText = "List of rooms"; tv_actor.ToolTipText = "List of actors"; tv_image.ToolTipText = "Texture pack"; treeview.Nodes.Add(root); root.ToolTipText = "Zone"; string errors = ""; string file = GetRec().GetFileName(); int min = 0x20; int max = GetRec().LenData; if (min > max) { errors += "file is smaller than ZND header\n"; } int ptr_mpd = RamDisk.GetS32(pos + 0x00); int len_mpd = RamDisk.GetS32(pos + 0x04); int end_mpd = ptr_mpd + Math.Max(0, len_mpd); int ptr_zud = RamDisk.GetS32(pos + 0x08); int len_zud = RamDisk.GetS32(pos + 0x0C); int end_zud = ptr_zud + Math.Max(0, len_zud); int ptr_tim = RamDisk.GetS32(pos + 0x10); int len_tim = RamDisk.GetS32(pos + 0x14); int end_tim = ptr_tim + Math.Max(0, len_tim); if (len_mpd != 0) { if ((ptr_mpd < min) || (end_mpd > max)) { errors += "MPD section is out of bounds " + ptr_mpd.ToString("X8") + "..." + len_mpd.ToString("X8") + "\n"; } min = end_mpd; } if (len_zud != 0) { if ((ptr_zud < min) || (end_zud > max)) { errors += "ZUD section is out of bounds " + ptr_zud.ToString("X8") + "..." + len_zud.ToString("X8") + "\n"; } min = end_zud; } if (len_tim != 0) { if ((ptr_tim < min) || (end_tim > max)) { errors += "TIM section is out of bounds " + ptr_tim.ToString("X8") + "..." + len_tim.ToString("X8") + "\n"; } min = end_tim; } if (end_mpd > ptr_zud) { errors += "MPD and ZUD sections overlap\n"; } if (end_zud > ptr_tim) { errors += "ZUD and TIM sections overlap\n"; } if (errors != "") { return(Logger.Warn(file + " is corrupt\n" + errors)); } if (len_zud != 0) { int num_zud = RamDisk.GetS32(pos + ptr_zud); for (int i = 0; i < num_zud; i++) { int ptr = ptr_zud + 4 + 8 * num_zud + 0x464 * i; int lba = RamDisk.GetS32(pos + ptr_zud + 4 + 8 * i); AddActor(tv_actor, i, ptr, lba); } } if (len_tim != 0) { int num_tim = RamDisk.GetS32(pos + ptr_tim + 0x10); int ptrx = ptr_tim + 0x14; for (int i = 0; i < num_tim; i++) { int len = RamDisk.GetS32(pos + ptrx); try { string key = GetUrl() + "/Images/Image_" + i; Texture obj = new Texture(key, ptrx + 4, len, i, GetRec()); images.Add(obj as Texture); Model.Add(key, obj); Publisher.Register(obj); } catch {} ptrx += len + 4; } foreach (Texture img in images) { int index = images.IndexOf(img); string text = "Image_" + index.ToString("D2"); int icon = (img.IsLookUpTable()) ? 4 : 3; tv_image.Nodes.Add(img.GetUrl(), text, icon, icon); } } if (len_mpd != 0) { int num_mpd = len_mpd / 8; for (int i = 0; i < num_mpd; i++) { AddRoom(tv_rooms, i, pos + ptr_mpd); } } root.Expand(); tv_rooms.Expand(); tv_actor.Expand(); tv_image.Expand(); root.EnsureVisible(); return(true); }