/// <summary> /// (通过实体)填充模型值 /// </summary> /// <param name="modelEntry"></param> /// <param name="model"></param> public static void Fill(ModelEntry modelEntry, object model, bool ingoreNull = false) { if (model != null) { var plist = model.GetType().GetProperties(); foreach (var item in plist) { var fieldName = item.Name; var itemValue = item.GetValue(model, null); var stringValue = string.Empty; if (itemValue != null) { stringValue = Convert.ToString(itemValue); } if (modelEntry != null) { if (ingoreNull && string.IsNullOrWhiteSpace(stringValue)) { continue; } if (modelEntry.CurrentValues.PropertyValues.ContainsKey(fieldName)) { modelEntry.CurrentValues.PropertyValues[fieldName] = stringValue; } else { modelEntry.CurrentValues.PropertyValues.Add(fieldName, stringValue); } } } } }
private void updateList(List <ModelEntry> model, DataGridView bookEntries, int baseRow) { double totalSize = 0.0; int cumSize = 0; if (baseRow > 0) { var modelEntry = model[checked (baseRow - 1)]; cumSize = model[checked (baseRow - 1)].CumSize; totalSize = model[checked (baseRow - 1)].TotalPrice; } for (var i = baseRow; i < model.Count; i++) { ModelEntry modelEntry = model[i]; checked { cumSize += modelEntry.Size; } modelEntry.CumSize = cumSize; totalSize += modelEntry.Price * (double)modelEntry.Size; modelEntry.TotalPrice = totalSize; double avgPrice = totalSize / (double)cumSize; if (i > checked (bookEntries.Rows.Count - 1)) { bookEntries.Rows.Add(); } var row = bookEntries.Rows[i]; row.Cells[(int)Cell.MarketMaker].Value = modelEntry.MarketMaker; row.Cells[(int)Cell.Price].Value = PriceFormatter.FormatPrice(modelEntry.Price, mSecType, mTickSize); row.Cells[(int)Cell.Size].Value = modelEntry.Size; row.Cells[(int)Cell.CumSize].Value = cumSize; row.Cells[(int)Cell.AvgPrice].Value = avgPrice; } }
public void StartLoadingModel(ModelEntry model, ImportOptions options) { this.entry = model; Destroy(loadedModel); // remove old stuff if (objectImporter.ImportModelAsync(name, model.GetFullPath(), Parent, options, out string error)) { objectImporter.ImportError += OnImportError; objectImporter.ImportingComplete += OnImportComplete; objectImporter.ImportedModel += OnModelImported; } else { this.importError.Invoke(error); } // switch (model.Location) // { // case ModelEntry.ResourceLocation.StreamingAsset: // LoadFromStreamingAssets(model.Name, model.Path, options ?? new ImportOptions()); // break; // case ModelEntry.ResourceLocation.Local: // LoadFromStreamingAssets(model.Name, model.Path, options ?? new ImportOptions()); // break; // case ModelEntry.ResourceLocation.Remote: // LoadRemote(model.Name, model.Path, options ?? new ImportOptions()); // break; // default: // throw new NotImplementedException(); // } }
public void UpdateView(ModelEntry entry) { // percentageLabel.text = Mathf.RoundToInt(progress).ToString(); // progressBar.fillAmount = progress; nameLabel.text = entry.Name; pathLabel.text = entry.GetFullPath(); }
public ModelEntryController(EntryChunkController entrychunkcontroller, ModelEntry modelentry) : base(entrychunkcontroller, modelentry) { this.modelentry = modelentry; Node.Text = string.Format("Model Entry ({0})", modelentry.EIDString); Node.ImageKey = "modelentry"; Node.SelectedImageKey = "modelentry"; }
private void updateList(List <ModelEntry> model, DataGridView bookEntries, int baseRow) { double totalSize = 0.0; int cumSize = 0; if (baseRow > 0) { var modelEntry = model[checked (baseRow - 1)]; cumSize = model[checked (baseRow - 1)].CumSize; totalSize = model[checked (baseRow - 1)].TotalPrice; } for (var i = baseRow; i < model.Count; i++) { ModelEntry modelEntry = model[i]; checked { cumSize += modelEntry.Size; } modelEntry.CumSize = cumSize; totalSize += modelEntry.Price * (double)modelEntry.Size; modelEntry.TotalPrice = totalSize; double avgPrice = totalSize / (double)cumSize; if (i > checked (bookEntries.Rows.Count - 1)) { bookEntries.Rows.Add(); } var row = bookEntries.Rows[i]; bookEntries.Rows[i].SetValues(modelEntry.MarketMaker, mFormatPrice(modelEntry.Price), modelEntry.Size, cumSize, mFormatAvgPrice(avgPrice)); } }
/// <summary> /// 生成对应的模型并返回更新的字段列表 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="modelEntry"></param> /// <param name="fields"></param> /// <returns></returns> public static object ToModel(ModelEntry modelEntry, Type modeltype, out string[] fields) { var defaultInstance = Activator.CreateInstance(modeltype); var updateFields = defaultInstance.SetValue(modelEntry.CurrentValues.PropertyValues); fields = updateFields.ToArray(); return(defaultInstance); }
public static void ModelEntryWriter(string filename, ModelEntry entrytowrite) { try { using (BinaryWriter bw = new BinaryWriter(File.Open(filename, FileMode.Create))) { bw.Write(entrytowrite.UncompressedData); bw.Close(); } } catch (Exception ex) { ExceptionCatchAll(ex); return; } }
public static void ModelEntryWriter(string filename, ModelEntry entrytowrite) { try { using (BinaryWriter bw = new BinaryWriter(File.Open(filename, FileMode.Create))) { bw.Write(entrytowrite.UncompressedData); bw.Close(); } } catch (UnauthorizedAccessException) { MessageBox.Show("Unable to access the file. Maybe it's already in use by another proccess?", "Cannot write this file."); return; } }
public ModelGroupEntry FillModelGroupEntry(ModelGroupEntry MGE, ModelEntry ParentMod, BinaryReader bnr, int OffsetToStart, int ID) { MGE.ID = bnr.ReadInt32(); MGE.Field04 = bnr.ReadInt32(); MGE.Field08 = bnr.ReadInt32(); MGE.Field0C = bnr.ReadInt32(); MGE.SphereBound = new BoundingSphere(); MGE.SphereBound.Center.X = bnr.ReadSingle(); MGE.SphereBound.Center.Y = bnr.ReadSingle(); MGE.SphereBound.Center.Z = bnr.ReadSingle(); MGE.SphereBound.Radius = bnr.ReadSingle(); OffsetToStart = Convert.ToInt32(bnr.BaseStream.Position); return(MGE); }
public void Adjust(ModelEntry entry) { var meshFilters = loader.LoadedObject.GetComponentsInChildren <MeshFilter>(); float size = 0f; foreach (var filter in meshFilters) { Debug.Log(filter.mesh.bounds.size); size = Mathf.Max(filter.mesh.bounds.size.y, size); } Debug.Log(size); var distance = size * 0.5f / Mathf.Tan(camera.fieldOfView * 0.5f * Mathf.Deg2Rad); // Debug.Log(distance); this.camera.transform.position = new Vector3(0, size, -distance - 5); }
public void UpdateView(ModelEntry item) { nameLabel.text = item.Name; pathLabel.text = $"Path: {item.Path}"; switch (item.Location) { case ModelEntry.ResourceLocation.StreamingAsset: locationIcon.sprite = settings.LocalIcon; break; case ModelEntry.ResourceLocation.Local: locationIcon.sprite = settings.LocalIcon; break; case ModelEntry.ResourceLocation.Remote: locationIcon.sprite = settings.RemoteIcon; break; default: break; } }
private void btnReplaceReplace_Click(object sender, EventArgs e) { if (AllFiles == true) { //Checks All filenames for searched term. Gets to the parent node, checks all the children nodes, their tags, filenames, etc. for the term. //Goes to top node to begin iteration. TreeNode tn = Mainfrm.FindRootNode(Mainfrm.TreeSource.SelectedNode); Mainfrm.TreeSource.SelectedNode = tn; List <TreeNode> Nodes = new List <TreeNode>(); Mainfrm.AddChildren(Nodes, Mainfrm.TreeSource.SelectedNode); Mainfrm.TreeSource.BeginUpdate(); int RenameCount = 0; foreach (TreeNode tno in Nodes) { //Gets the node as a ArcEntryWrapper to allow access to all the variables and data. ArcEntryWrapper awrapper = tno as ArcEntryWrapper; if (awrapper != null) { if (awrapper.Tag as MaterialTextureReference == null || awrapper.Tag as LMTM3AEntry == null || awrapper.Tag as ModelBoneEntry == null || awrapper.Tag as MaterialMaterialEntry == null || awrapper.Tag as ModelGroupEntry == null || awrapper.Tag as Mission == null || awrapper.Tag as EffectNode == null) { { if (awrapper.Tag as string != null) { //Replaces the Term in the folder. string FolderName = awrapper.Tag as string; FolderName = FolderName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); RenameCount++; } else { //Goes through the treenode to replace all the names of the node. ArcEntry enty = new ArcEntry(); TextureEntry tenty = new TextureEntry(); ResourcePathListEntry lrpenty = new ResourcePathListEntry(); MSDEntry msdenty = new MSDEntry(); MaterialEntry matent = new MaterialEntry(); LMTEntry lmtenty = new LMTEntry(); ChainListEntry cstenty = new ChainListEntry(); ChainEntry chnenty = new ChainEntry(); ChainCollisionEntry cclentry = new ChainCollisionEntry(); ModelEntry mdlentry = new ModelEntry(); MissionEntry misenty = new MissionEntry(); GemEntry gementy = new GemEntry(); EffectListEntry eflenty = new EffectListEntry(); if (tno.Tag as ArcEntry != null) { enty = tno.Tag as ArcEntry; enty.EntryName = enty.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); enty.TrueName = enty.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); enty.FileName = enty.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = enty; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as TextureEntry != null) { tenty = tno.Tag as TextureEntry; tenty.EntryName = tenty.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tenty.TrueName = tenty.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tenty.FileName = tenty.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = tenty; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as ResourcePathListEntry != null) { lrpenty = tno.Tag as ResourcePathListEntry; lrpenty.EntryName = lrpenty.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); lrpenty.TrueName = lrpenty.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); lrpenty.FileName = lrpenty.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = lrpenty; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as LMTEntry != null) { lmtenty = tno.Tag as LMTEntry; lmtenty.EntryName = lmtenty.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); lmtenty.TrueName = lmtenty.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); lmtenty.FileName = lmtenty.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = lmtenty; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as MaterialEntry != null) { matent = tno.Tag as MaterialEntry; matent.EntryName = matent.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); matent.TrueName = matent.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); matent.FileName = matent.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = matent; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as MSDEntry != null) { msdenty = tno.Tag as MSDEntry; msdenty.EntryName = msdenty.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); msdenty.TrueName = msdenty.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); msdenty.FileName = msdenty.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = msdenty; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as ChainListEntry != null) { cstenty = tno.Tag as ChainListEntry; cstenty.EntryName = cstenty.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); cstenty.TrueName = cstenty.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); cstenty.FileName = cstenty.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = cstenty; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as ChainEntry != null) { chnenty = tno.Tag as ChainEntry; chnenty.EntryName = chnenty.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); chnenty.TrueName = chnenty.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); chnenty.FileName = chnenty.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = chnenty; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as ChainCollisionEntry != null) { cclentry = tno.Tag as ChainCollisionEntry; cclentry.EntryName = cclentry.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); cclentry.TrueName = cclentry.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); cclentry.FileName = cclentry.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = cclentry; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as ModelEntry != null) { mdlentry = tno.Tag as ModelEntry; mdlentry.EntryName = mdlentry.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); mdlentry.TrueName = mdlentry.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); mdlentry.FileName = mdlentry.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = mdlentry; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as MissionEntry != null) { misenty = tno.Tag as MissionEntry; misenty.EntryName = misenty.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); misenty.TrueName = misenty.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); misenty.FileName = misenty.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = misenty; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as GemEntry != null) { gementy = tno.Tag as GemEntry; gementy.EntryName = gementy.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); gementy.TrueName = gementy.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); gementy.FileName = gementy.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = gementy; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } else if (tno.Tag as EffectListEntry != null) { eflenty = tno.Tag as EffectListEntry; eflenty.EntryName = eflenty.EntryName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); eflenty.TrueName = eflenty.TrueName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); eflenty.FileName = eflenty.FileName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Tag = eflenty; tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); } RenameCount++; } } } } if (tno.Tag as string != null && tno.Tag as string == "Folder") { //Replaces the Term in the folder. string FolderName = tno.Text as string; FolderName = FolderName.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Text = tno.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); tno.Name = tno.Name.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); RenameCount++; } } Mainfrm.TreeSource.Update(); Mainfrm.TreeSource.EndUpdate(); MessageBox.Show("Replaced " + txtReplaceFind.Text + " with " + txtReplaceReplace.Text + " in " + RenameCount + " file and folder names."); Mainfrm.OpenFileModified = true; RenameCount = 0; } else { if (Mainfrm.TreeSource.SelectedNode.Tag is ResourcePathListEntry) { //Gets the text, then replaces every instance of the search term with the new term. string text = Mainfrm.txtRPList.Text; text = text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); Mainfrm.txtRPList.Text = text; } else if (Mainfrm.TreeSource.SelectedNode.Tag is MaterialEntry) { TreeNodeCollection TNoCollection = Mainfrm.TreeSource.SelectedNode.Nodes; foreach (TreeNode node in TNoCollection) { if (node.Tag as string != null) { if (node.Text as string == "Textures") { Mainfrm.TreeSource.SelectedNode = node; break; } } } TNoCollection = Mainfrm.TreeSource.SelectedNode.Nodes; Mainfrm.TreeSource.BeginUpdate(); foreach (TreeNode node in TNoCollection) { string Namer = node.Name as string; node.Text = node.Text.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); Namer = Namer.Replace(txtReplaceFind.Text, txtReplaceReplace.Text); node.Name = Namer; } Mainfrm.TreeSource.SelectedNode = Mainfrm.TreeSource.SelectedNode.Parent; //Now to update the Material file with all these, Whether they're changed or not. TreeNode Parentnode = Mainfrm.TreeSource.SelectedNode; MaterialEntry ParentMateial = Parentnode.Tag as MaterialEntry; MaterialTextureReference texref = new MaterialTextureReference(); string TermToInject = ""; //int count = 0; for (int i = 0; i < TNoCollection.Count; i++) { texref = TNoCollection[i].Tag as MaterialTextureReference; TermToInject = TNoCollection[i].Text; //Now for the actual file update. List <byte> NameToInject = new List <byte>(); NameToInject.AddRange(Encoding.ASCII.GetBytes(TermToInject)); int OffsetToUse; OffsetToUse = 64 + (88 * (texref.Index - 1)); byte[] NewName = new byte[64]; Array.Copy(NameToInject.ToArray(), 0, NewName, 0, NameToInject.ToArray().Length); Array.Copy(NewName, 0, ParentMateial.UncompressedData, OffsetToUse, NewName.Length); ParentMateial.CompressedData = Zlibber.Compressor(ParentMateial.UncompressedData); } Mainfrm.TreeSource.SelectedNode.Tag = ParentMateial; Mainfrm.OpenFileModified = true; Mainfrm.TreeSource.Update(); Mainfrm.TreeSource.EndUpdate(); } } }
public ModelBoneEntry FillModelBoneEntry(ModelBoneEntry MBoneE, ModelEntry ParentMod, BinaryReader bnr, int OffsetToStart, int ID) { bnr.BaseStream.Position = OffsetToStart; MBoneE.ID = Convert.ToInt32(bnr.ReadByte()); MBoneE.Parent = Convert.ToInt32(bnr.ReadByte()); MBoneE.SymmetryIndex = Convert.ToInt32(bnr.ReadByte()); MBoneE.Field3 = Convert.ToInt32(bnr.ReadByte()); MBoneE.Field4 = bnr.ReadSingle(); MBoneE.Length = bnr.ReadSingle(); MBoneE.Offset.X = bnr.ReadSingle(); MBoneE.Offset.Y = bnr.ReadSingle(); MBoneE.Offset.Z = bnr.ReadSingle(); MBoneE.JointLinks.Links = new List <PrimitiveJLink>(); ///* //Primitive Joint Links. for (int i = 0; i < ParentMod.PrimitiveJointLinkCount; i++) { bnr.BaseStream.Position = ((ParentMod.PrimitveOffset + ParentMod.PrimitiveCount * 56) + i * 144); MBoneE.JointLinks.curJointIndex = Convert.ToInt32(bnr.BaseStream.Position); if (MBoneE.JointLinks.curJointIndex == MBoneE.ID) { PrimitiveJLink PLink = new PrimitiveJLink(); PLink.JointIndex = bnr.ReadInt32(); PLink.Field04 = bnr.ReadInt32(); PLink.Field08 = bnr.ReadInt32(); PLink.Field0C = bnr.ReadInt32(); PLink.Vec10.X = bnr.ReadSingle(); PLink.Vec10.Y = bnr.ReadSingle(); PLink.Vec10.Z = bnr.ReadSingle(); PLink.Vec10.W = bnr.ReadSingle(); PLink.Vec20.X = bnr.ReadSingle(); PLink.Vec20.Y = bnr.ReadSingle(); PLink.Vec20.Z = bnr.ReadSingle(); PLink.Vec20.W = bnr.ReadSingle(); PLink.Vec30.X = bnr.ReadSingle(); PLink.Vec30.Y = bnr.ReadSingle(); PLink.Vec30.Z = bnr.ReadSingle(); PLink.Vec30.W = bnr.ReadSingle(); PLink.Mtx40.M11 = bnr.ReadSingle(); PLink.Mtx40.M12 = bnr.ReadSingle(); PLink.Mtx40.M13 = bnr.ReadSingle(); PLink.Mtx40.M14 = bnr.ReadSingle(); PLink.Mtx40.M21 = bnr.ReadSingle(); PLink.Mtx40.M22 = bnr.ReadSingle(); PLink.Mtx40.M23 = bnr.ReadSingle(); PLink.Mtx40.M24 = bnr.ReadSingle(); PLink.Mtx40.M31 = bnr.ReadSingle(); PLink.Mtx40.M32 = bnr.ReadSingle(); PLink.Mtx40.M33 = bnr.ReadSingle(); PLink.Mtx40.M34 = bnr.ReadSingle(); PLink.Mtx40.M41 = bnr.ReadSingle(); PLink.Mtx40.M42 = bnr.ReadSingle(); PLink.Mtx40.M43 = bnr.ReadSingle(); PLink.Mtx40.M44 = bnr.ReadSingle(); PLink.Vec80.X = bnr.ReadSingle(); PLink.Vec80.Y = bnr.ReadSingle(); PLink.Vec80.Z = bnr.ReadSingle(); PLink.Vec80.W = bnr.ReadSingle(); } } //*/ return(MBoneE); }
public static ArcFile LoadArc(TreeView tree, string filename, List<string> foldernames, bool IsBigEndian, bool Verifier = false,Type filetype = null, int arcsize = -1) { ArcFile arcfile = new ArcFile(); byte[] Bytes = File.ReadAllBytes(filename); using (BinaryReader br = new BinaryReader(File.Open(filename, FileMode.Open))) { arcsize = Bytes.Length; int Totalsize = arcsize; arcfile.FileLength = arcsize; arcfile.Tempname = filename; br.BaseStream.Position = 0; byte[] HeaderMagic = br.ReadBytes(4); //Checks file signature/Endianess. if (HeaderMagic[0] == 0x00 && HeaderMagic[1] == 0x43 && HeaderMagic[2] == 0x52 && HeaderMagic[3] == 0x41) { /* MessageBox.Show("This .arc file is not in the kind of endian I can deal with right now, so these will be in read only.\nDon't expect save to work... or for the program to be stable", "Just so you know...."); IsBigEndian = true; arcfile.HeaderMagic = HeaderMagic; arcfile.MaterialCount = 0; arcfile.arctable = new List<ArcEntry>(); arcfile.arcfiles = new List<object>(); arcfile.FileList = new List<string>(); arcfile.TypeHashes = new List<string>(); br.BaseStream.Position = 4; var data = br.ReadBytes(2); Array.Reverse(data); arcfile.UnknownFlag = br.ReadByte(); return arcfile; */ MessageBox.Show("This .arc file is not in the kind of endian I can deal with right now. Closing.", "Just so you know...."); br.Close(); return null; } if (HeaderMagic[0] != 0x41 && HeaderMagic[1] != 0x52 && HeaderMagic[2] != 0x43 && HeaderMagic[3] != 0x00) { MessageBox.Show("This .arc file is either not the correct kind or is not properly extracted, so I'm closing it.", "Oh dear"); br.Close(); return null; } #region PC Arc IsBigEndian = false; arcfile.HeaderMagic = HeaderMagic; arcfile.MaterialCount = 0; arcfile.arctable = new List<ArcEntry>(); arcfile.arcfiles = new List<object>(); arcfile.FileList = new List<string>(); arcfile.TypeHashes = new List<string>(); br.BaseStream.Position = 4; arcfile.UnknownFlag = br.ReadByte(); br.BaseStream.Position = 6; arcfile.FileCount = BitConverter.ToInt16((br.ReadBytes(2)), 0); arcfile.Version = arcfile.UnknownFlag; List<String> filenames = new List<String>(); List<string> subdref = new List<string>(); foldernames = subdref; //byte[] BytesTemp; //BytesTemp = new byte[] { }; List<byte> BytesTemp = new List<byte>(); byte[] HTTemp = new byte[] { }; int j = 8; int l = 64; int m = 80; int n = 4; //Iterates through the header/first part of the arc to get all the filenames and occupy the filename list. for (int i = 0; i < arcfile.FileCount; i++) { BytesTemp.Clear(); BytesTemp.TrimExcess(); j = 8 + (m * i); //Copies the specified range to isolate the bytes containing a filename. br.BaseStream.Position = j; BytesTemp.AddRange(br.ReadBytes(l)); BytesTemp.RemoveAll(ByteUtilitarian.IsZeroByte); filenames.Add(ByteUtilitarian.BytesToStringL(BytesTemp)); //For The Typehashes. n = 72 + (m * i); br.BaseStream.Position = n; HTTemp = br.ReadBytes(4); Array.Reverse(HTTemp); arcfile.TypeHashes.Add(ByteUtilitarian.HashBytesToString(HTTemp)); } //Fills in each file as an ArcEntry or TextureEntry as needed. j = 8; int IDCounter = 0; for (int i = 0; i < arcfile.FileCount; i++) { j = 8 + (80 * i); switch (arcfile.TypeHashes[i]) { //Texture Files. case "241F5DEB": TextureEntry newtexen = TextureEntry.FillTexEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(newtexen); arcfile.FileList.Add(newtexen.EntryName); foldernames.Clear(); IDCounter++; break; //Resource Path Lists. case "357EF6D4": ResourcePathListEntry newplen = ResourcePathListEntry.FillRPLEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(newplen); arcfile.FileList.Add(newplen.EntryName); foldernames.Clear(); IDCounter++; break; //Materials. Incomplete. case "2749C8A8": MaterialEntry Maten = MaterialEntry.FillMatEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(Maten); arcfile.FileList.Add(Maten.EntryName); foldernames.Clear(); IDCounter++; arcfile.MaterialCount++; break; //LMT Files. case "76820D81": LMTEntry LMTen = LMTEntry.FillLMTEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(LMTen); arcfile.FileList.Add(LMTen.EntryName); foldernames.Clear(); IDCounter++; break; //MSD Files. case "5B55F5B1": MSDEntry newmsden = MSDEntry.FillMSDEntry(filename, foldernames, tree, br, Bytes, j, IDCounter); arcfile.arcfiles.Add(newmsden); arcfile.FileList.Add(newmsden.EntryName); foldernames.Clear(); IDCounter++; break; //CST Files. case "326F732E": ChainListEntry CSTen = ChainListEntry.FillCSTEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(CSTen); arcfile.FileList.Add(CSTen.EntryName); foldernames.Clear(); IDCounter++; break; //CHN Files. case "3E363245": ChainEntry CHNen = ChainEntry.FillChainEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(CHNen); arcfile.FileList.Add(CHNen.EntryName); foldernames.Clear(); IDCounter++; break; //CCL Files. case "0026E7FF": ChainCollisionEntry CCLen = ChainCollisionEntry.FillChainCollEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(CCLen); arcfile.FileList.Add(CCLen.EntryName); foldernames.Clear(); IDCounter++; break; //MOD Files. case "58A15856": ModelEntry MODen = ModelEntry.FillModelEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(MODen); arcfile.FileList.Add(MODen.EntryName); foldernames.Clear(); IDCounter++; break; case "361EA2A5": MissionEntry MISen = MissionEntry.FillMissionEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(MISen); arcfile.FileList.Add(MISen.EntryName); foldernames.Clear(); IDCounter++; break; //Gem Files. case "448BBDD4": GemEntry GEMen = GemEntry.FillGEMEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(GEMen); arcfile.FileList.Add(GEMen.EntryName); foldernames.Clear(); IDCounter++; break; //EFL Files. case "6D5AE854": EffectListEntry EFLen = EffectListEntry.FillEFLEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(EFLen); arcfile.FileList.Add(EFLen.EntryName); foldernames.Clear(); IDCounter++; break; //New Formats go like this! /* case "********": *****Entry ****en = *****Entry.Fill*****Entry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(*****en); arcfile.FileList.Add(*****.EntryName); foldernames.Clear(); IDCounter++; break; */ default: //Everything not listed above. ArcEntry newentry = ArcEntry.FillArcEntry(filename, foldernames, tree, br, j, IDCounter); arcfile.arcfiles.Add(newentry); arcfile.FileList.Add(newentry.EntryName); foldernames.Clear(); IDCounter++; break; } } arcfile._FileAmount = Convert.ToUInt16(IDCounter); br.Close(); } return arcfile; #endregion }
/// <summary> /// Returns the model with the specified <paramref name="modelId"/> either from the model cache or /// requests and loads it from the plugin manager. /// </summary> /// <param name="modelId">Id of the model to retrieve.</param> /// <returns>Model with the specified <paramref name="modelId"/>.</returns> /// <exception cref="ArgumentException">If the specified <paramref name="modelId"/> is not registered.</exception> protected object GetOrLoadModel(Guid modelId) { ModelEntry entry; EnterWriteLock("GetOrLoadModel"); try { if (_modelCache.TryGetValue(modelId, out entry)) { entry.Use(); return entry.ModelInstance; } ServiceRegistration.Get<ILogger>().Debug("WorkflowManager: Loading GUI model '{0}'", modelId); object model = ServiceRegistration.Get<IPluginManager>().RequestPluginItem<object>( MODELS_REGISTRATION_LOCATION, modelId.ToString(), _modelItemStateTracker); if (model == null) throw new ArgumentException(string.Format("WorkflowManager: Model with id '{0}' is not available", modelId)); _modelCache[modelId] = new ModelEntry(model); return model; } finally { ExitWriteLock(); } }
public void ModelSelected(ModelEntry entry) { sm.ChangeState <LoadingGameState, ModelEntry>(entry); }
public void StartLoadingModel(ModelEntry model) { StartLoadingModel(model, Parameters); }
public void UpdateView(ModelEntry model, string error) { titleLabel.text = model.Name; errorLabel.text = error; }