public void ChangeMulti(int id, MultiComponentList multi) { if (multi != MultiComponentList.Empty) { int index = refmarker.TreeViewMulti.SelectedNode.Index; if (int.Parse(refmarker.TreeViewMulti.SelectedNode.Name) != id) { for (int i = 0; i < refmarker.TreeViewMulti.Nodes.Count; ++i) { if (int.Parse(refmarker.TreeViewMulti.Nodes[i].Name) == id) { index = i; break; } } } refmarker.TreeViewMulti.Nodes[index].Tag = multi; refmarker.TreeViewMulti.Nodes[index].ForeColor = Color.Black; if (index != refmarker.TreeViewMulti.SelectedNode.Index) refmarker.TreeViewMulti.SelectedNode = refmarker.TreeViewMulti.Nodes[index]; afterSelect_Multi(this, null); FiddlerControls.Events.FireMultiChangeEvent(this, index); } }
public static void Save(string path) { bool isUOAHS = PostHSFormat || Art.IsUOAHS(); string idx = Path.Combine(path, "multi.idx"); string mul = Path.Combine(path, "multi.mul"); using ( FileStream fsidx = new FileStream(idx, FileMode.Create, FileAccess.Write, FileShare.Write), fsmul = new FileStream(mul, FileMode.Create, FileAccess.Write, FileShare.Write)) { using (BinaryWriter binidx = new BinaryWriter(fsidx), binmul = new BinaryWriter(fsmul)) { for (int index = 0; index < 0x2000; ++index) { MultiComponentList comp = GetComponents(index); if (comp == MultiComponentList.Empty) { binidx.Write(-1); // lookup binidx.Write(-1); // length binidx.Write(-1); // extra } else { List <MultiComponentList.MultiTileEntry> tiles = RebuildTiles(comp.SortedTiles); binidx.Write((int)fsmul.Position); //lookup if (isUOAHS) { binidx.Write((tiles.Count * 16)); //length } else { binidx.Write((tiles.Count * 12)); //length } binidx.Write(-1); //extra for (int i = 0; i < tiles.Count; ++i) { binmul.Write(tiles[i].m_ItemID); binmul.Write(tiles[i].m_OffsetX); binmul.Write(tiles[i].m_OffsetY); binmul.Write(tiles[i].m_OffsetZ); if (isUOAHS) { binmul.Write((ulong)tiles[i].m_Flags); } else { binmul.Write((uint)tiles[i].m_Flags); } } } } } } }
public static MultiComponentList ImportFromFile(int index, string FileName, Multis.ImportType type) { try { return(m_Components[index] = new MultiComponentList(FileName, type)); } catch { return(m_Components[index] = MultiComponentList.Empty); } }
public static void Save(string path) { string idx = Path.Combine(path, "multi.idx"); string mul = Path.Combine(path, "multi.mul"); using (FileStream fsidx = new FileStream(idx, FileMode.Create, FileAccess.Write, FileShare.Write), fsmul = new FileStream(mul, FileMode.Create, FileAccess.Write, FileShare.Write)) { using (BinaryWriter binidx = new BinaryWriter(fsidx), binmul = new BinaryWriter(fsmul)) { for (int index = 0; index < 0x2000; ++index) { MultiComponentList comp = GetComponents(index); if (comp == MultiComponentList.Empty) { binidx.Write((int)-1); // lookup binidx.Write((int)-1); // length binidx.Write((int)-1); // extra } else { binidx.Write((int)fsmul.Position); //lookup binidx.Write((int)comp.SortedTiles.Length * (Art.IsUOHS ? 16 : 12)); //length binidx.Write((int)-1); //extra for (int i = 0; i < comp.SortedTiles.Length; ++i) { binmul.Write((ushort)comp.SortedTiles[i].m_ItemID); binmul.Write((short)comp.SortedTiles[i].m_OffsetX); binmul.Write((short)comp.SortedTiles[i].m_OffsetY); binmul.Write((short)comp.SortedTiles[i].m_OffsetZ); binmul.Write((int)comp.SortedTiles[i].m_Flags); if (Art.IsUOHS) { binmul.Write((int)comp.SortedTiles[i].m_Hue); } } } } } } }
public static MultiComponentList GetComponents(int index) { MultiComponentList empty; index = index & 16383; if (index < 0 || index >= (int)Multis.m_Components.Length) { empty = MultiComponentList.Empty; } else { empty = Multis.m_Components[index]; if (empty == null) { MultiComponentList[] mComponents = Multis.m_Components; MultiComponentList multiComponentList = Multis.Load(index); empty = multiComponentList; mComponents[index] = multiComponentList; } } return(empty); }
public static void Add(int index, MultiComponentList comp) { m_Components[index] = comp; }
private void ChangeComponentList(MultiComponentList multi) { MultiComponentBox.Clear(); if (multi != MultiComponentList.Empty) { bool isUOHSA = Art.IsUOAHS(); for (int x = 0; x < multi.Width; ++x) { for (int y = 0; y < multi.Height; ++y) { MTile[] tiles = multi.Tiles[x][y]; for (int i = 0; i < tiles.Length; ++i) { if (isUOHSA) MultiComponentBox.AppendText(String.Format("0x{0:X4} {1,3} {2,3} {3,2} {4,2} {5,2}\n", tiles[i].ID, x, y, tiles[i].Z, tiles[i].Flag, tiles[i].Unk1)); else MultiComponentBox.AppendText(String.Format("0x{0:X4} {1,3} {2,3} {3,2} {4,2}\n", tiles[i].ID, x, y, tiles[i].Z, tiles[i].Flag)); } } } } }
public static List <object[]> LoadFromDesigner(string fileName) { var multiList = new List <object[]>(); string root = Path.GetFileNameWithoutExtension(fileName); string idx = $"{root}.idx"; string bin = $"{root}.bin"; if ((!File.Exists(idx)) || (!File.Exists(bin))) { return(multiList); } using (var idxfs = new FileStream(idx, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var binfs = new FileStream(bin, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (var idxbin = new BinaryReader(idxfs)) using (var binbin = new BinaryReader(binfs)) { int count = idxbin.ReadInt32(); int version = idxbin.ReadInt32(); for (int i = 0; i < count; ++i) { var data = new object[2]; switch (version) { case 0: data[0] = ReadUOAString(idxbin); var arr = new List <MultiComponentList.MultiTileEntry>(); data[0] += "-" + ReadUOAString(idxbin); data[0] += "-" + ReadUOAString(idxbin); _ = idxbin.ReadInt32(); _ = idxbin.ReadInt32(); _ = idxbin.ReadInt32(); _ = idxbin.ReadInt32(); long filepos = idxbin.ReadInt64(); int reccount = idxbin.ReadInt32(); binbin.BaseStream.Seek(filepos, SeekOrigin.Begin); for (int j = 0; j < reccount; ++j) { int x; int y; int z; int index = x = y = z = 0; switch (binbin.ReadInt32()) { case 0: index = binbin.ReadInt32(); x = binbin.ReadInt32(); y = binbin.ReadInt32(); z = binbin.ReadInt32(); binbin.ReadInt32(); break; case 1: index = binbin.ReadInt32(); x = binbin.ReadInt32(); y = binbin.ReadInt32(); z = binbin.ReadInt32(); binbin.ReadInt32(); binbin.ReadInt32(); break; } var tempItem = new MultiComponentList.MultiTileEntry { m_ItemID = (ushort)index, m_Flags = 1, m_OffsetX = (short)x, m_OffsetY = (short)y, m_OffsetZ = (short)z, m_Unk1 = 0 }; arr.Add(tempItem); } data[1] = new MultiComponentList(arr); break; } multiList.Add(data); } } return(multiList); } }
/// <summary> /// Create a ComponentList from UltimaSDK /// </summary> public MultiEditorComponentList(MultiComponentList list, MultiEditor parent) { Parent = parent; Width = list.Width; Height = list.Height; Tiles = new List<MultiTile>(); for (int x = 0; x < Width; ++x) { for (int y = 0; y < Height; ++y) { for (int i = 0; i < list.Tiles[x][y].Length; ++i) { Tiles.Add(new MultiTile(list.Tiles[x][y][i].ID, x, y, list.Tiles[x][y][i].Z, list.Tiles[x][y][i].Flag)); } Tiles.Add(new FloorTile(x, y, Parent.DrawFloorZ)); } } CalcSolver(); Tiles.Sort(); UndoList = new UndoStruct[UndoListMaxSize]; Modified = true; RecalcMinMax(); }
public static List<Object[]> LoadFromDesigner(string FileName) { List<Object[]> multilist = new List<Object[]>(); string root = Path.GetFileNameWithoutExtension(FileName); string idx = String.Format("{0}.idx", root); string bin = String.Format("{0}.bin", root); if ((!File.Exists(idx)) || (!File.Exists(bin))) return multilist; using (FileStream idxfs = new FileStream(idx, FileMode.Open, FileAccess.Read, FileShare.Read), binfs = new FileStream(bin, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (BinaryReader idxbin = new BinaryReader(idxfs), binbin = new BinaryReader(binfs)) { int count = idxbin.ReadInt32(); int version = idxbin.ReadInt32(); for (int i = 0; i < count; ++i) { Object[] data = new Object[2]; switch (version) { case 0: data[0] = ReadUOAString(idxbin); List<MultiComponentList.MultiTileEntry> arr = new List<MultiComponentList.MultiTileEntry>(); data[0] += "-" + ReadUOAString(idxbin); data[0] += "-" + ReadUOAString(idxbin); int width = idxbin.ReadInt32(); int height = idxbin.ReadInt32(); int uwidth = idxbin.ReadInt32(); int uheight = idxbin.ReadInt32(); long filepos = idxbin.ReadInt64(); int reccount = idxbin.ReadInt32(); binbin.BaseStream.Seek(filepos, SeekOrigin.Begin); int index, x, y, z, level, hue; for (int j = 0; j < reccount; ++j) { index = x = y = z = level = hue = 0; int compVersion = binbin.ReadInt32(); switch (compVersion) { case 0: index = binbin.ReadInt32(); x = binbin.ReadInt32(); y = binbin.ReadInt32(); z = binbin.ReadInt32(); level = binbin.ReadInt32(); break; case 1: index = binbin.ReadInt32(); x = binbin.ReadInt32(); y = binbin.ReadInt32(); z = binbin.ReadInt32(); level = binbin.ReadInt32(); hue = binbin.ReadInt32(); break; } MultiComponentList.MultiTileEntry tempitem = new MultiComponentList.MultiTileEntry(); tempitem.m_ItemID = (ushort)index; tempitem.m_Flags = 1; tempitem.m_OffsetX = (short)x; tempitem.m_OffsetY = (short)y; tempitem.m_OffsetZ = (short)z; tempitem.m_Unk1 = 0; arr.Add(tempitem); } data[1] = new MultiComponentList(arr); break; } multilist.Add(data); } } return multilist; } }
static MultiComponentList() { MultiComponentList.Empty = new MultiComponentList(); }
public static List<MultiComponentList.MultiTileEntry> RebuildTiles(MultiComponentList.MultiTileEntry[] tiles) { List<MultiComponentList.MultiTileEntry> newtiles = new List<MultiComponentList.MultiTileEntry>(); newtiles.AddRange(tiles); if (newtiles[0].m_OffsetX == 0 && newtiles[0].m_OffsetY == 0 && newtiles[0].m_OffsetZ == 0) // found a centeritem { if (newtiles[0].m_ItemID != 0x1) // its a "good" one { for (int j = newtiles.Count - 1; j >= 0; --j) // remove all invis items { if (newtiles[j].m_ItemID == 0x1) newtiles.RemoveAt(j); } return newtiles; } else // a bad one { for (int i = 1; i < newtiles.Count; ++i) // do we have a better one? { if (newtiles[i].m_OffsetX == 0 && newtiles[i].m_OffsetY == 0 && newtiles[i].m_ItemID != 0x1 && newtiles[i].m_OffsetZ == 0 ) { MultiComponentList.MultiTileEntry centeritem = newtiles[i]; newtiles.RemoveAt(i); // jep so save it for (int j = newtiles.Count-1; j >= 0; --j) // and remove all invis { if (newtiles[j].m_ItemID == 0x1) newtiles.RemoveAt(j); } newtiles.Insert(0, centeritem); return newtiles; } } for (int j = newtiles.Count-1; j >= 1; --j) // nothing found so remove all invis exept the first { if (newtiles[j].m_ItemID == 0x1) newtiles.RemoveAt(j); } return newtiles; } } for (int i = 0; i < newtiles.Count; ++i) // is there a good one { if (newtiles[i].m_OffsetX == 0 && newtiles[i].m_OffsetY == 0 && newtiles[i].m_ItemID != 0x1 && newtiles[i].m_OffsetZ == 0) { MultiComponentList.MultiTileEntry centeritem = newtiles[i]; newtiles.RemoveAt(i); // store it for (int j = newtiles.Count-1; j >= 0; --j) // remove all invis { if (newtiles[j].m_ItemID == 0x1) newtiles.RemoveAt(j); } newtiles.Insert(0, centeritem); return newtiles; } } for (int j = newtiles.Count-1; j >= 0; --j) // nothing found so remove all invis { if (newtiles[j].m_ItemID == 0x1) newtiles.RemoveAt(j); } MultiComponentList.MultiTileEntry invisitem = new MultiComponentList.MultiTileEntry(); invisitem.m_ItemID = 0x1; // and create a new invis invisitem.m_OffsetX = 0; invisitem.m_OffsetY = 0; invisitem.m_OffsetZ = 0; invisitem.m_Flags = 0; invisitem.m_Unk1 = 0; newtiles.Insert(0, invisitem); return newtiles; }
public static MultiComponentList ImportFromFile(int index, string FileName, Multis.ImportType type) { try { return m_Components[index] = new MultiComponentList(FileName, type); } catch { return m_Components[index] = MultiComponentList.Empty; } }
public static List <Object[]> LoadFromDesigner(string FileName) { List <Object[]> multilist = new List <Object[]>(); string root = Path.GetFileNameWithoutExtension(FileName); string idx = $"{root}.idx"; string bin = $"{root}.bin"; if ((!File.Exists(idx)) || (!File.Exists(bin))) { return(multilist); } using (FileStream idxfs = new FileStream(idx, FileMode.Open, FileAccess.Read, FileShare.Read), binfs = new FileStream(bin, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (BinaryReader idxbin = new BinaryReader(idxfs), binbin = new BinaryReader(binfs)) { int count = idxbin.ReadInt32(); int version = idxbin.ReadInt32(); for (int i = 0; i < count; ++i) { Object[] data = new Object[2]; switch (version) { case 0: data[0] = ReadUOAString(idxbin); List <MultiComponentList.MultiTileEntry> arr = new List <MultiComponentList.MultiTileEntry>(); data[0] += "-" + ReadUOAString(idxbin); data[0] += "-" + ReadUOAString(idxbin); int width = idxbin.ReadInt32(); int height = idxbin.ReadInt32(); int uwidth = idxbin.ReadInt32(); int uheight = idxbin.ReadInt32(); long filepos = idxbin.ReadInt64(); int reccount = idxbin.ReadInt32(); binbin.BaseStream.Seek(filepos, SeekOrigin.Begin); int index, x, y, z, level, hue; for (int j = 0; j < reccount; ++j) { index = x = y = z = level = hue = 0; int compVersion = binbin.ReadInt32(); switch (compVersion) { case 0: index = binbin.ReadInt32(); x = binbin.ReadInt32(); y = binbin.ReadInt32(); z = binbin.ReadInt32(); level = binbin.ReadInt32(); break; case 1: index = binbin.ReadInt32(); x = binbin.ReadInt32(); y = binbin.ReadInt32(); z = binbin.ReadInt32(); level = binbin.ReadInt32(); hue = binbin.ReadInt32(); break; } MultiComponentList.MultiTileEntry tempitem = new MultiComponentList.MultiTileEntry(); tempitem.m_ItemID = (ushort)index; tempitem.m_Flags = 1; tempitem.m_OffsetX = (short)x; tempitem.m_OffsetY = (short)y; tempitem.m_OffsetZ = (short)z; tempitem.m_Unk1 = 0; arr.Add(tempitem); } data[1] = new MultiComponentList(arr); break; } multilist.Add(data); } } return(multilist); } }
public static List <object[]> LoadFromDesigner(string FileName) { var multilist = new List <object[]>(); var root = Path.GetFileNameWithoutExtension(FileName); var idx = String.Format("{0}.idx", root); var bin = String.Format("{0}.bin", root); if ((!File.Exists(idx)) || (!File.Exists(bin))) { return(multilist); } using (FileStream idxfs = new FileStream(idx, FileMode.Open, FileAccess.Read, FileShare.Read), binfs = new FileStream(bin, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (BinaryReader idxbin = new BinaryReader(idxfs), binbin = new BinaryReader(binfs)) { var count = idxbin.ReadInt32(); var version = idxbin.ReadInt32(); for (var i = 0; i < count; ++i) { var data = new object[2]; switch (version) { case 0: data[0] = ReadUOAString(idxbin); var arr = new List <MultiComponentList.MultiTileEntry>(); data[0] += "-" + ReadUOAString(idxbin); data[0] += "-" + ReadUOAString(idxbin); var width = idxbin.ReadInt32(); var height = idxbin.ReadInt32(); var uwidth = idxbin.ReadInt32(); var uheight = idxbin.ReadInt32(); var filepos = idxbin.ReadInt64(); var reccount = idxbin.ReadInt32(); binbin.BaseStream.Seek(filepos, SeekOrigin.Begin); int index, x, y, z, level, hue; for (var j = 0; j < reccount; ++j) { index = x = y = z = level = hue = 0; var compVersion = binbin.ReadInt32(); switch (compVersion) { case 0: index = binbin.ReadInt32(); x = binbin.ReadInt32(); y = binbin.ReadInt32(); z = binbin.ReadInt32(); level = binbin.ReadInt32(); break; case 1: index = binbin.ReadInt32(); x = binbin.ReadInt32(); y = binbin.ReadInt32(); z = binbin.ReadInt32(); level = binbin.ReadInt32(); hue = binbin.ReadInt32(); break; } var tempitem = new MultiComponentList.MultiTileEntry { m_ItemID = (ushort)index, m_Flags = 1, m_OffsetX = (short)x, m_OffsetY = (short)y, m_OffsetZ = (short)z, m_Unk1 = 0 }; arr.Add(tempitem); } data[1] = new MultiComponentList(arr); break; } multilist.Add(data); } } return(multilist); } }