internal static void PrepareForClone(SimPe.Interfaces.Files.IPackageFile package, SimPe.Interfaces.IAlias current, out SimPe.Interfaces.IAlias a, out uint localgroup, out SimPe.Interfaces.Files.IPackedFileDescriptor pfd) { FileTable.FileIndex.Load(); a = null; pfd = null; localgroup = Data.MetaData.LOCAL_GROUP; if (package != null) { if (package.FileName != null) { SimPe.Interfaces.Wrapper.IGroupCacheItem gci = SimPe.FileTable.GroupCache.GetItem(package.FileName); if (gci != null) { localgroup = gci.LocalGroup; } } } else { if (current != null) { a = current; pfd = (Interfaces.Files.IPackedFileDescriptor)a.Tag[0]; localgroup = (uint)a.Tag[1]; } } }
/// <summary> /// Load a List of Aliases form an XML File /// </summary> /// <param name="flname">Name of the File</param> /// <returns>The IAlias List</returns> public static SimPe.Interfaces.IAlias[] LoadFromXml(string flname) { if (!System.IO.File.Exists(flname)) return new SimPe.Interfaces.IAlias[0]; try { //read XML File System.Xml.XmlDocument xmlfile = new XmlDocument(); xmlfile.Load(flname); //seek Root Node XmlNodeList XMLData = xmlfile.GetElementsByTagName("alias"); ArrayList list = new ArrayList(); //Process all Root Node Entries for (int i=0; i<XMLData.Count; i++) { XmlNode node = XMLData.Item(i); foreach (XmlNode subnode in node) { if (subnode.LocalName.Trim().ToLower()=="item") { string sval = subnode.Attributes["value"].Value.Trim().ToString(); uint val = 0; if (sval.StartsWith("0x")) val = Convert.ToUInt32(sval, 16); else val = Convert.ToUInt32(sval); Alias a = new Alias(val, subnode.InnerText.Trim()); list.Add((SimPe.Interfaces.IAlias)a); } } } // for i SimPe.Interfaces.IAlias[] ret = new SimPe.Interfaces.IAlias[list.Count]; list.CopyTo(ret); return ret; } catch (Exception ex) { Helper.ExceptionMessage("", ex); } return new SimPe.Interfaces.IAlias[0]; }
public static SimPe.Packages.GeneratableFile Start(SimPe.Packages.GeneratableFile pkg, SimPe.Interfaces.IAlias a, ref Interfaces.Files.IPackedFileDescriptor pfd, uint localgroup, ObjectWorkshopSettings settings, bool containsonlybaseclone) { SimPe.Packages.GeneratableFile package = pkg; SimPe.Plugin.CloneSettings.BaseResourceType br = SimPe.Plugin.CloneSettings.BaseResourceType.Objd; if (pfd != null) { if (pfd.Type != Data.MetaData.OBJD_FILE) { br = SimPe.Plugin.CloneSettings.BaseResourceType.Xml; } } if (settings is OWCloneSettings) { OWCloneSettings cs = (OWCloneSettings)settings; package = RecolorClone(br, package, pfd, localgroup, settings, containsonlybaseclone); FixObject fo = new FixObject(package, FixVersion.UniversityReady, settings.RemoveNonDefaultTextReferences); System.Collections.Hashtable map = null; if (cs.FixResources) { map = fo.GetNameMap(true); if (map == null) { return(package); } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = ExtensionProvider.BuildFilterString( new SimPe.ExtensionType[] { SimPe.ExtensionType.Package, SimPe.ExtensionType.AllFiles } ); if (sfd.ShowDialog() == DialogResult.OK) { WaitingScreen.Wait(); try { package.FileName = sfd.FileName; fo.Fix(map, true); if (cs.RemoveUselessResource && br != SimPe.Plugin.CloneSettings.BaseResourceType.Xml) { fo.CleanUp(); } package.Save(); } finally { WaitingScreen.Stop(); } } else { package = null; } } if ((cs.CustomGroup) && (package != null)) { WaitingScreen.Wait(); try { fo.FixGroup(); if (cs.FixResources) { package.Save(); } } finally { WaitingScreen.Stop(); } } if (cs.ChangeObjectDescription) { UpdateDescription(cs, package); } //select a resource to display in SimPE pfd = null; if (package != null) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.OBJD_FILE); if (pfds.Length > 0) { pfd = pfds[0]; } } } else { /*if (br == SimPe.Plugin.CloneSettings.BaseResourceType.Xml) * package = ReColorXObject(br, package, pfd, localgroup, new OWRecolorSettings()); * else*/ package = ReColor(br, package, pfd, localgroup, new OWRecolorSettings(), containsonlybaseclone); //select a resource for display in SimPE pfd = null; if (package != null) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.TXTR); if (pfds.Length > 0) { pfd = pfds[0]; } } } settings.SetRemoteResult(false); if (settings.OpenWithRemoteControl) { if (package != null) { if (SimPe.RemoteControl.OpenMemoryPackage(package) && pfd != null) { settings.SetRemoteResult(SimPe.RemoteControl.OpenPackedFile(pfd, package)); } } } return(package); }
public static SimPe.Packages.GeneratableFile Start(SimPe.Packages.GeneratableFile pkg, SimPe.Interfaces.IAlias a, ref Interfaces.Files.IPackedFileDescriptor pfd, uint localgroup, ObjectWorkshopSettings settings) { return(Start(pkg, a, ref pfd, localgroup, settings, false)); }
protected static void PrepareForClone(SimPe.Interfaces.Files.IPackageFile package, out SimPe.Interfaces.IAlias a, out uint localgroup, out SimPe.Interfaces.Files.IPackedFileDescriptor pfd, out OWCloneSettings cs) { ObjectWorkshopHelper.PrepareForClone(package, null, out a, out localgroup, out pfd); cs = new OWCloneSettings(); cs.IncludeWallmask = false; cs.OnlyDefaultMmats = false; cs.IncludeAnimationResources = false; cs.CustomGroup = false; cs.FixResources = false; cs.RemoveUselessResource = false; cs.StandAloneObject = false; cs.RemoveNonDefaultTextReferences = false; cs.KeepOriginalMesh = false; cs.PullResourcesByStr = true; cs.ChangeObjectDescription = false; cs.OpenWithRemoteControl = false; }