/// <summary> /// presents the SaveDialog and returns the selected Filename (or null) /// </summary> /// <param name="multi"></param> /// <returns></returns> string SetupSaveDialog(string name, bool multi) { name = name.Replace(" ", "").Replace(":", "_").Replace(@"\", "_"); if (!multi) { System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog(); sfd.FileName = name; sfd.Filter = ExtensionProvider.BuildFilterString( new SimPe.ExtensionType[] { SimPe.ExtensionType.ExtractedFile, SimPe.ExtensionType.AllFiles } ); sfd.Title = SimPe.Localization.GetString(this.ToString()); if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { return(sfd.FileName); } } else { System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { return(fbd.SelectedPath); } } return(null); }
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); }
/// <summary> /// Load a list of FIleDescriptors from the disc /// </summary> /// <param name="add">true if you want to add them lateron</param> /// <returns></returns> protected SimPe.Collections.PackedFileDescriptors LoadDescriptors(bool add) { System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); if (!add) { ofd.Filter = ExtensionProvider.BuildFilterString( new SimPe.ExtensionType[] { SimPe.ExtensionType.ExtractedFile, SimPe.ExtensionType.ExtractedFileDescriptor, SimPe.ExtensionType.AllFiles } ); } else { ofd.Filter = ExtensionProvider.BuildFilterString( new SimPe.ExtensionType[] { SimPe.ExtensionType.ExtractedFileDescriptor, SimPe.ExtensionType.ExtrackedPackageDescriptor, SimPe.ExtensionType.ExtractedFile, SimPe.ExtensionType.Package, SimPe.ExtensionType.DisabledPackage, SimPe.ExtensionType.AllFiles } ); } ofd.Title = SimPe.Localization.GetString(this.ToString()); ofd.Multiselect = add; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SimPe.Collections.PackedFileDescriptors pfds = LoadedPackage.LoadDescriptorsFromDisk(ofd.FileNames); return(pfds); } return(new SimPe.Collections.PackedFileDescriptors()); }
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); }
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); }