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 SimPe.Packages.GeneratableFile ReColorXObject(CloneSettings.BaseResourceType br, SimPe.Packages.GeneratableFile pkg, Interfaces.Files.IPackedFileDescriptor pfd, uint localgroup, ObjectWorkshopSettings settings) { settings.KeepOriginalMesh = true; SimPe.Packages.GeneratableFile package = pkg; // we need packages in the Gmaes and the Download Folder if (((!System.IO.File.Exists(ScenegraphHelper.GMND_PACKAGE)) || (!System.IO.File.Exists(ScenegraphHelper.MMAT_PACKAGE))) && (settings is OWCloneSettings)) { if (Message.Show(Localization.Manager.GetString("OW_Warning"), "Warning", MessageBoxButtons.YesNo) == DialogResult.No) { return(package); } } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = ExtensionProvider.BuildFilterString( new SimPe.ExtensionType[] { SimPe.ExtensionType.Package, SimPe.ExtensionType.AllFiles } ); if (sfd.ShowDialog() != DialogResult.OK) { return(package); } //create a Cloned Object to get all needed Files for the Process WaitingScreen.Wait(); try { WaitingScreen.UpdateMessage("Collecting needed Files"); if ((package == null) && (pfd != null)) { package = RecolorClone(br, package, pfd, localgroup, settings, false); } } finally { WaitingScreen.Stop(); } package.FileName = sfd.FileName; package.Save(); return(package); }
protected static SimPe.Packages.GeneratableFile ReColor(CloneSettings.BaseResourceType br, SimPe.Packages.GeneratableFile pkg, Interfaces.Files.IPackedFileDescriptor pfd, uint localgroup, ObjectWorkshopSettings settings, bool pkgcontainsonlybase) { SimPe.Packages.GeneratableFile package = pkg; // we need packages in the Gmaes and the Download Folder if (((!System.IO.File.Exists(ScenegraphHelper.GMND_PACKAGE)) || (!System.IO.File.Exists(ScenegraphHelper.MMAT_PACKAGE))) && (settings is OWCloneSettings)) { if (Message.Show(Localization.Manager.GetString("OW_Warning"), "Warning", MessageBoxButtons.YesNo) == DialogResult.No) { return(package); } } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = ExtensionProvider.BuildFilterString( new SimPe.ExtensionType[] { SimPe.ExtensionType.Package, SimPe.ExtensionType.AllFiles } ); if (sfd.ShowDialog() != DialogResult.OK) { return(package); } //create a Cloned Object to get all needed Files for the Process WaitingScreen.Wait(); try { WaitingScreen.UpdateMessage("Collecting needed Files"); if ((package == null) && (pfd != null)) { package = RecolorClone(br, package, pfd, localgroup, settings, pkgcontainsonlybase); } } finally { WaitingScreen.Stop(); } /*if (settings is OWRecolorSettings) * { * ObjectRecolor or = new ObjectRecolor(package); * or.EnableColorOptions(); * or.LoadReferencedMATDs(); * * //load all Pending Textures * ObjectCloner oc = new ObjectCloner(package); * }*/ /*SimPe.Packages.GeneratableFile dn_pkg = null; * if (System.IO.File.Exists(ScenegraphHelper.GMND_PACKAGE)) dn_pkg = SimPe.Packages.GeneratableFile.LoadFromFile(ScenegraphHelper.GMND_PACKAGE); * else dn_pkg = SimPe.Packages.GeneratableFile.LoadFromStream((System.IO.BinaryReader)null); * * SimPe.Packages.GeneratableFile gm_pkg = null; * if (System.IO.File.Exists(ScenegraphHelper.MMAT_PACKAGE)) gm_pkg = SimPe.Packages.GeneratableFile.LoadFromFile(ScenegraphHelper.MMAT_PACKAGE); * else gm_pkg = SimPe.Packages.GeneratableFile.LoadFromStream((System.IO.BinaryReader)null);*/ SimPe.Packages.GeneratableFile npackage = SimPe.Packages.GeneratableFile.CreateNew(); //.LoadFromStream((System.IO.BinaryReader)null); //Create the Templae for an additional MMAT npackage.FileName = sfd.FileName; ColorOptions cs = new ColorOptions(package); cs.Create(npackage); npackage.Save(); package = npackage; WaitingScreen.Stop(); #if DEBUG #else if (package != npackage) { package = null; } #endif return(package); }
/// <summary> /// Clone an object based on way Files are linked /// </summary> /// <param name="pfd"></param> /// <param name="localgroup"></param> /// <param name="onlydefault"></param> protected static SimPe.Packages.GeneratableFile RecolorClone(CloneSettings.BaseResourceType br, SimPe.Packages.GeneratableFile ppkg, Interfaces.Files.IPackedFileDescriptor pfd, uint localgroup, ObjectWorkshopSettings settings, bool pkgcontainsonlybase) { SimPe.Packages.GeneratableFile package = null; if (ppkg != null) { package = (SimPe.Packages.GeneratableFile)ppkg.Clone(); } if (ppkg == null || pkgcontainsonlybase) { if (!pkgcontainsonlybase) { package = SimPe.Packages.GeneratableFile.CreateNew(); } //Get the Base Object Data from the Objects.package File string[] modelname = new string[0]; if (br == CloneSettings.BaseResourceType.Objd) { modelname = BaseClone(localgroup, package, pkgcontainsonlybase); } else { SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] fii = FileTable.FileIndex.FindFile(pfd, null); if (fii.Length > 0) { SimPe.Interfaces.Files.IPackedFileDescriptor cpfd = fii[0].FileDescriptor.Clone(); cpfd = cpfd.Clone(); cpfd.UserData = fii[0].Package.Read(fii[0].FileDescriptor).UncompressedData; package.Add(cpfd); } } ObjectCloner objclone = new ObjectCloner(package); ArrayList exclude = new ArrayList(); //allways for recolors if (settings is OWRecolorSettings) { exclude.Add("stdMatEnvCubeTextureName"); exclude.Add("TXTR"); } else { exclude.Add("tsMaterialsMeshName"); exclude.Add("TXTR"); exclude.Add("stdMatEnvCubeTextureName"); } //do the recolor objclone.Setup = settings; objclone.Setup.BaseResource = br; objclone.Setup.OnlyDefaultMmats = (settings.OnlyDefaultMmats && br != CloneSettings.BaseResourceType.Xml); objclone.Setup.UpdateMmatGuids = objclone.Setup.OnlyDefaultMmats; /*objclone.Setup.IncludeWallmask = settings.IncludeWallmask; * objclone.Setup.IncludeAnimationResources = settings.IncludeAnimationResources; * objclone.Setup.KeepOriginalMesh = settings.KeepOriginalMesh; * objclone.Setup.PullResourcesByStr = settings.PullResourcesByStr; * objclone.Setup.StrInstances = settings.StrInstances;*/ objclone.RcolModelClone(modelname, exclude); //for clones only when cbparent is checked if (settings is OWCloneSettings) { if (((OWCloneSettings)settings).StandAloneObject || br == CloneSettings.BaseResourceType.Xml) { string[] names = Scenegraph.LoadParentModelNames(package, true); SimPe.Packages.File pkg = SimPe.Packages.File.LoadFromFile(null); ObjectCloner pobj = new ObjectCloner(pkg); pobj.Setup = settings; pobj.Setup.BaseResource = br; pobj.Setup.OnlyDefaultMmats = (settings.OnlyDefaultMmats && br != CloneSettings.BaseResourceType.Xml);; pobj.Setup.UpdateMmatGuids = pobj.Setup.OnlyDefaultMmats; /*pobj.Setup.IncludeWallmask = settings.IncludeWallmask; * pobj.Setup.IncludeAnimationResources = settings.IncludeAnimationResources; * pobj.Setup.KeepOriginalMesh = settings.KeepOriginalMesh; * pobj.Setup.PullResourcesByStr = settings.PullResourcesByStr; * pobj.Setup.StrInstances = settings.StrInstances;*/ pobj.RcolModelClone(names, exclude); pobj.AddParentFiles(modelname, package); } else { string[] modelnames = modelname; if (!((OWCloneSettings)settings).RemoveUselessResource) { modelnames = null; } objclone.RemoveSubsetReferences(Scenegraph.GetParentSubsets(package), modelnames); } } } return(package); }