protected void UpdateList() { WaitingScreen.Wait(); Application.DoEvents(); try { lv.Items.Clear(); ilist.Images.Clear(); ExpansionItem.NeighborhoodPaths paths = PathProvider.Global.GetNeighborhoodsForGroup(PathProvider.Global.CurrentGroup); foreach (ExpansionItem.NeighborhoodPath path in paths) { string sourcepath = path.Path; string[] dirs = System.IO.Directory.GetDirectories(sourcepath, "????"); foreach (string dir in dirs) { AddNeighborhood(path, dir); } } } finally { WaitingScreen.Stop(this); } }
public static void Execute(SimPe.Plugin.Anim.AnimResourceConst anim) { AnimPreview f = new AnimPreview(); WaitingScreen.Wait(); Wait.SubStart(anim.MeshBlock.Length); try { WaitingScreen.UpdateMessage(SimPe.Localization.GetString("Loading Meshes")); int ct = 0; foreach (SimPe.Plugin.Anim.AnimationMeshBlock amb in anim.MeshBlock) { f.lb.Items.Add(new ListedMeshBlocks(amb)); Wait.Progress = ct++; } } finally { Wait.SubStop(); WaitingScreen.Stop(); } f.ShowDialog(); f.timer1.Enabled = false; }
private void RcolSearch(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { if (cbusefileindex.Checked) { WaitingScreen.Wait(); try { SimPe.FileTable.FileIndex.Load(); } finally { WaitingScreen.Stop(this); } lblist.Items.Clear(); SimPe.Packages.PackedFileDescriptor pfd = new SimPe.Packages.PackedFileDescriptor(); pfd.SubType = Hashes.SubTypeHash(Hashes.StripHashFromName(tbflname.Text)); pfd.Instance = Hashes.InstanceHash(Hashes.StripHashFromName(tbflname.Text)); SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFileByInstance(pfd.LongInstance); //short Index if (items.Length == 0) { pfd.SubType = 0; items = FileTable.FileIndex.FindFileByInstance(pfd.LongInstance); } foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { lblist.Items.Add(item.Package.FileName); } btopen.Tag = true; } else { this.StartSearch(new SeekerFunction(this.RcolSearch), package.FindFile(Hashes.StripHashFromName(tbflname.Text))); } }
/// <summary> /// Install the Photostudio Templates /// </summary> /// <returns>true if success</returns> public static bool InstallTemplates() { WebClient Client = new WebClient(); if (Helper.StartedGui == Executable.Classic) { WaitingScreen.Wait(); } else { Wait.SubStart(); } try { string tempname = System.IO.Path.GetTempFileName() + ".exe"; DownloadFile("http://sims.ambertation.de/files/SimPE-Templates-Setup.exe", tempname); if (Helper.StartedGui == Executable.Classic) { WaitingScreen.Stop(); } else { Wait.SubStop(); } try { System.Diagnostics.Process p = System.Diagnostics.Process.Start(tempname); p.WaitForExit(); return(true); } finally { System.IO.File.Delete(tempname); } } catch (Exception ex) { Helper.ExceptionMessage("Unable to download the instalation File.", ex); } finally { if (Helper.StartedGui == Executable.Classic) { WaitingScreen.Stop(); } else { Wait.SubStop(); } } return(false); }
/// <summary> /// Doanload A File from the Internet /// </summary> /// <param name="URL"></param> /// <param name="Filename"></param> /// <param name="progress"></param> public static void DownloadFile(string URL, string Filename) { WebClient cli = new WebClient(); Stream fDnld = null, fOut = null; if (Helper.StartedGui == Executable.Classic) { WaitingScreen.Wait(); } else { Wait.SubStart(); } int total = 0; try { fDnld = cli.OpenRead(URL); string sTotal = cli.ResponseHeaders["Content-Length"]; int nTotal = (sTotal == null || sTotal.Length == 0) ? 0 : Convert.ToInt32(sTotal); fOut = File.Create(Filename); byte[] buf = new byte[4096]; int nBytesRead; while ((nBytesRead = fDnld.Read(buf, 0, buf.Length)) > 0) { total += nBytesRead; WaitingScreen.UpdateMessage(total.ToString() + " of " + nTotal.ToString()); Wait.Message = total.ToString() + " of " + nTotal.ToString(); fOut.Write(buf, 0, nBytesRead); } } catch { throw; } finally { if (Helper.StartedGui == Executable.Classic) { WaitingScreen.Stop(); } else { Wait.SubStop(); } if (fDnld != null) { fDnld.Close(); } if (fOut != null) { fOut.Close(); fOut.Dispose(); fOut = null; } } }
/// <summary> /// Build the SceneGraph /// </summary> /// <param name="prov"></param> /// <param name="simpe_pkg"></param> public void Execute(IProviderRegistry prov, SimPe.Interfaces.Files.IPackageFile simpe_pkg, ref SimPe.Interfaces.Files.IPackedFileDescriptor pfd) { this.pfd = pfd; this.open_pkg = simpe_pkg; WaitingScreen.Wait(); try { llopen.Enabled = false; SimPe.Interfaces.Files.IPackageFile orgpkg = simpe_pkg; DateTime start = DateTime.Now; FileTable.FileIndex.Load(); SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fileindex = FileTable.FileIndex.Clone(); fileindex.AddIndexFromPackage(simpe_pkg); SimPe.Interfaces.Scenegraph.IScenegraphFileIndex oldfileindex = FileTable.FileIndex; FileTable.FileIndex = fileindex; //find txtr File /*WaitingScreen.UpdateMessage("Collecting Global Files"); * string[] modelnames = Scenegraph.FindModelNames(simpe_pkg); * try * { * ObjectCloner oc = new ObjectCloner(); * oc.RcolModelClone(modelnames, false, false); * simpe_pkg = oc.Package; * } * catch (ScenegraphException) {}*/ FileTable.FileIndex = oldfileindex; gb.BuildGraph(simpe_pkg, fileindex); gb.FindUnused(orgpkg); WaitingScreen.Stop(); TimeSpan runtime = DateTime.Now.Subtract(start); if (Helper.WindowsRegistry.HiddenMode) { Text = "Runtime: " + runtime.TotalSeconds + " sek. = " + runtime.TotalMinutes + " min."; } RemoteControl.ShowSubForm(this); pfd = this.pfd; } #if !DEBUG catch (Exception ex) { Helper.ExceptionMessage("", ex); } #endif finally { WaitingScreen.Stop(); } }
private void NgbBackup(object sender, System.EventArgs e) { if (lv.SelectedItems.Count <= 0) { return; } SimPe.Packages.StreamFactory.CloseAll(); string path = System.IO.Path.GetDirectoryName(lv.SelectedItems[0].SubItems[1].Text).Trim(); string lable = lv.SelectedItems[0].SubItems[3].Text; //if a File in the current Neighborhood is opened - close it! CloseIfOpened(path); this.Cursor = Cursors.WaitCursor; WaitingScreen.Wait(); try { //create a Backup Folder string name = System.IO.Path.GetFileName(path); if (lable != "") { name = lable + "_" + name; } long grp = PathProvider.Global.SaveGamePathProvidedByGroup(path); if (grp > 1) { name = grp.ToString() + "_" + name; } string backuppath = System.IO.Path.Combine(PathProvider.Global.BackupFolder, name); string subname = DateTime.Now.ToString(); backuppath = System.IO.Path.Combine(backuppath, subname.Replace("\\", "-").Replace("/", "-").Replace(":", "-")); if (!System.IO.Directory.Exists(backuppath)) { System.IO.Directory.CreateDirectory(backuppath); } Helper.CopyDirectory(path, backuppath, true); } catch (Exception ex) { Helper.ExceptionMessage("", ex); } finally { WaitingScreen.Stop(this); this.Cursor = Cursors.Default; } }
/// <summary> /// Create a new Color Options package /// </summary> /// <param name="newpkg">The Package the color Option should be added to</param> /// <param name="ask">if ask is true, a Dialog will be displayed that lets the /// user decide which Subsets to recolor</param> public void Create(IPackageFile newpkg) { WaitingScreen.Wait(); try { //this.newpkg = newpkg; WaitingScreen.UpdateMessage("Loading available Color Options"); Hashtable fullmap = Scenegraph.GetMMATMap(package); Hashtable map = fullmap; ArrayList allowedSubsets = Scenegraph.GetRecolorableSubsets(package); //Check if the User can select a Subset bool userselect = false; if (map.Count > 1) { userselect = true; } else { if (map.Count == 1) { foreach (string s in map.Keys) { Hashtable ht = (Hashtable)map[s]; if (ht.Count > 1) { userselect = true; } } } } //let the user Select now if (userselect) { map = SubsetSelectForm.Execute(map, allowedSubsets); } ProcessMmatMap(newpkg, map, fullmap); } finally { WaitingScreen.Stop(); } }
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> /// Setup the Form /// </summary> /// <param name="map">The subset map</param> /// <param name="subsets">the subsets you want to present</param> /// <returns>Returns a New Instance of the selection Form</returns> public static SubsetSelectForm Prepare(Hashtable map, ArrayList subsets) { SubsetSelectForm ssf = new SubsetSelectForm(); ssf.listviews = new ArrayList(); ssf.txmtnames = new Hashtable(); WaitingScreen.Wait(); try { WaitingScreen.UpdateMessage("Show Subset Selection"); ssf.button1.Enabled = false; int top = 0; foreach (string subset in map.Keys) { if (!subsets.Contains(subset)) { continue; } ListView lv = ssf.AddSelection(ssf, subset, ref top); Hashtable families = (Hashtable)map[subset]; foreach (string family in families.Keys) { ArrayList mmats = (ArrayList)families[family]; mmats.Sort(new MmatListCompare()); ssf.AddItem(lv, mmats); } if (lv.Items.Count > 0) { lv.Items[0].Selected = true; } } } finally { WaitingScreen.Stop(); } return(ssf); }
protected void FillList() { this.Cursor = Cursors.WaitCursor; WaitingScreen.Wait(); ilist.Images.Clear(); this.iListSmall.Images.Clear(); lv.BeginUpdate(); lv.Items.Clear(); Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.SIM_DESCRIPTION_FILE); try { foreach (Interfaces.Files.IPackedFileDescriptor spfd in pfds) { Application.DoEvents(); PackedFiles.Wrapper.ExtSDesc sdesc = new SimPe.PackedFiles.Wrapper.ExtSDesc(); sdesc.ProcessData(spfd, package); bool doAdd = false; doAdd |= (this.cbNpc.Checked && realIsNPC(sdesc)); doAdd |= (this.cbTownie.Checked && realIsTownie(sdesc)); doAdd |= (this.ckbPlayable.Checked && realIsPlayable(sdesc)); doAdd |= (this.ckbUnEditable.Checked && realIsUneditable(sdesc)); //WaitingScreen.UpdateImage(ImageLoader.Preview(sdesc.Image, new Size(64, 64))); if (doAdd) { AddSim(sdesc); } } sorter.Sorting = lv.Sorting; lv.Sort(); } finally { lv.EndUpdate(); WaitingScreen.Stop(this); this.Cursor = Cursors.Default; } }
public Interfaces.Plugin.IToolResult ShowDialog(ref SimPe.Interfaces.Files.IPackedFileDescriptor pfd, ref SimPe.Interfaces.Files.IPackageFile package) { FixObject fo = new FixObject(package, FixVersion.UniversityReady, false); try { System.Collections.Hashtable map = fo.GetNameMap(false); if (map == null) { return(new ToolResult(false, false)); } WaitingScreen.Wait(); fo.Fix(map, false); fo.CleanUp(); fo.FixGroup(); } catch (Exception ex) { Helper.ExceptionMessage("", ex); } finally { WaitingScreen.Stop(); } if (Helper.StartedGui != Executable.Classic) { return(new ToolResult(false, false)); } else { return(new ToolResult(false, true)); } }
/// <summary> /// this Operation is fixing selected Packages that wer marked as problematic /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FixCompression(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { if (selection == null) { return; } WaitingScreen.Wait(); bool chg = false; try { foreach (ScannerItem si in selection) { if (si.PackageCacheItem.Thumbnail != null) { WaitingScreen.Update(si.PackageCacheItem.Thumbnail, si.FileName); } else { WaitingScreen.UpdateMessage(si.FileName); } SimPe.Cache.PackageState ps = si.PackageCacheItem.FindState(this.Uid, true); if ((ps.State != TriState.Null) && (ps.Data.Length > 0)) { if ((HealthState)ps.Data[0] != HealthState.Ok) { ps.State = TriState.True; ps.Data[0] = (uint)HealthState.Ok; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in si.Package.Index) { SimPe.Interfaces.Files.IPackedFile file = si.Package.Read(pfd); pfd.UserData = file.UncompressedData; pfd.MarkForReCompress = (file.IsCompressed || Data.MetaData.CompressionCandidates.Contains(pfd.Type)); if (pfd.Type == Data.MetaData.OBJD_FILE) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new ExtObjd(); objd.ProcessData(pfd, si.Package); if (objd.Ok != SimPe.PackedFiles.Wrapper.ObjdHealth.Ok) { objd.SynchronizeUserData(); objd.ProcessData(pfd, si.Package); if (objd.Ok != ObjdHealth.Ok) { ps.State = TriState.False; ps.Data[0] = (uint)HealthState.NonDefaultObjd; if (objd.Ok == SimPe.PackedFiles.Wrapper.ObjdHealth.UnmatchingFilenames && Helper.WindowsRegistry.HiddenMode) { ps.Data[0] = (uint)HealthState.FaultyNamedObjd; } if (objd.Ok == ObjdHealth.OverLength) { ps.Data[0] = (uint)HealthState.FaultySizedObjd; } } } } } si.Package.Save(); chg = true; si.ListViewItem.ForeColor = System.Drawing.Color.Black; this.ScanPackage(si, ps, si.ListViewItem); } } } if (chg && this.CallbackFinish != null) { this.CallbackFinish(false, false); } } catch (Exception ex) { Helper.ExceptionMessage("", ex); } finally { WaitingScreen.Stop(); } }
public static void Execute(SimPe.Events.ResourceContainers es) { //Select the Type if (Helper.WindowsRegistry.ReportFormat == Registry.ReportFormats.CSV) { Serializer.Formater = new CsvSerializer(); } System.Collections.Hashtable map = new System.Collections.Hashtable(); foreach (SimPe.Events.ResourceContainer e in es) { uint t = e.Resource.FileDescriptor.Type; SimPe.Events.ResourceContainers o = map[t] as SimPe.Events.ResourceContainers; if (o == null) { o = new SimPe.Events.ResourceContainers(); map[t] = o; } o.Add(e); } System.IO.StreamWriter sw = new System.IO.StreamWriter(new System.IO.MemoryStream()); string error = ""; int ct = 0; string max = "/ " + es.Count.ToString(); WaitingScreen.Wait(); try { foreach (uint type in map.Keys) { SimPe.Events.ResourceContainers rc = map[type] as SimPe.Events.ResourceContainers; bool first = true; foreach (SimPe.Events.ResourceContainer e in rc) { error += ProcessItem(sw, e, first); WaitingScreen.UpdateMessage((ct++).ToString() + " / " + max.ToString()); first = false; } } WaitingScreen.Stop(); if (error != "") { throw new Warning("Not all Selected Files were processed.", error); } if (f == null) { f = new Report(); } f.Execute(sw); } #if !DEBUG catch (Exception ex) { Helper.ExceptionMessage(ex); } #endif finally { sw.Close(); Serializer.ResetFormater(); WaitingScreen.Stop(); } }
public void UpdateGraph(Wrapper.SDesc sdsc, Wrapper.ExtFamilyTies famt) { this.BeginUpdate(); if (Parent != null) { this.Width = Parent.ClientRectangle.Width; this.Height = Parent.ClientRectangle.Height; } bool run = WaitingScreen.Running; WaitingScreen.Wait(); try { this.SaveBounds = false; this.AutoSize = true; this.Clear(); baseip = null; if (famt == null || sdsc == null) { this.EndUpdate(); if (!run) { WaitingScreen.Stop(); } return; } FamilyTieSim tie = famt.FindTies(sdsc); Wrapper.SDesc[] parents = famt.ParentSims(sdsc); Wrapper.SDesc[] siblings = famt.SiblingSims(sdsc); Wrapper.SDesc[] childs = famt.ChildSims(sdsc); int maxct = parents.Length + siblings.Length + childs.Length; if (maxct < 4) { this.LinearUpdateGraph(sdsc, famt); if (!run) { WaitingScreen.Stop(); } return; } double r = GraphPanel.GetPinCircleRadius(this.ItemSize, this.ItemSize, maxct); Point center = new Point( Math.Max(Width / 2, (int)r + 16 + ItemSize.Width / 2), Math.Max(Height / 2, (int)r + ItemSize.Height / 2) ); baseip = CreateItem(sdsc, 0, 0); baseip.Location = GraphPanel.GetCenterLocationOnPinCircle(center, r, ItemSize); baseip.Parent = this; this.SelectedElement = baseip; baseip.PanelColor = Color.Black; baseip.ForeColor = Color.White; baseip.EndUpdate(); int ct = 0; if (tie != null) { foreach (SDesc s in childs) { ImagePanel ip = AddTieToGraph(s, 0, 0, tie.FindTie(s).Type, false); ip.Location = GraphPanel.GetItemLocationOnPinCricle(center, r, ct++, maxct, ItemSize); ip.EndUpdate(); } foreach (SDesc s in siblings) { ImagePanel ip = AddTieToGraph(s, 0, 0, tie.FindTie(s).Type, false); ip.Location = GraphPanel.GetItemLocationOnPinCricle(center, r, ct++, maxct, ItemSize); ip.EndUpdate(); } foreach (SDesc s in parents) { ImagePanel ip = AddTieToGraph(s, 0, 0, tie.FindTie(s).Type, false); ip.Location = GraphPanel.GetItemLocationOnPinCricle(center, r, ct++, maxct, ItemSize); ip.EndUpdate(); } } this.EndUpdate(); } finally { if (!run) { WaitingScreen.Stop(); } } }
/// <summary> /// this Operation is fixing selected Packages that wer marked as problematic /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Set(SimPe.PackedFiles.Wrapper.ShelveDimension sd) { if (selection == null) { return; } WaitingScreen.Wait(); bool chg = false; try { foreach (ScannerItem si in selection) { if (si.PackageCacheItem.Thumbnail != null) { WaitingScreen.Update(si.PackageCacheItem.Thumbnail, si.FileName); } else { WaitingScreen.UpdateMessage(si.FileName); } SimPe.Cache.PackageState ps = si.PackageCacheItem.FindState(this.Uid, true); if (ps.Data.Length < 1) { continue; } if (ps.State == TriState.True && selection.Length > 1) { continue; } ps.State = TriState.Null; try { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.OBJD_FILE); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new ExtObjd(); objd.ProcessData(pfd, si.Package); objd.ShelveDimension = sd; objd.SynchronizeUserData(); } si.Package.Save(); } catch (Exception ex) { Helper.ExceptionMessage("", ex); } } if (chg && this.CallbackFinish != null) { this.CallbackFinish(false, false); } } catch (Exception ex) { Helper.ExceptionMessage("", ex); } finally { WaitingScreen.Stop(); } }
/// <summary> /// Set the Age of the Files /// </summary> /// <param name="name"></param> /// <param name="cbs"></param> /// <param name="yacheck">true, if you want to perform a check for YoungAdulst and add apropriate Filds to the cpf</param> void SetProperty(string name, CheckBox[] cbs, bool yacheck) { if (selection == null) { return; } WaitingScreen.Wait(); try { bool chg = false; foreach (ScannerItem si in selection) { if (si.PackageCacheItem.Type == SimPe.Cache.PackageType.Cloth || si.PackageCacheItem.Type == SimPe.Cache.PackageType.Skin || ((uint)si.PackageCacheItem.Type & (uint)SimPe.Cache.PackageType.Makeup) == (uint)SimPe.Cache.PackageType.Makeup || ((uint)si.PackageCacheItem.Type & (uint)SimPe.Cache.PackageType.Accessory) == (uint)SimPe.Cache.PackageType.Accessory || si.PackageCacheItem.Type == SimPe.Cache.PackageType.Hair ) { if (si.PackageCacheItem.Thumbnail != null) { WaitingScreen.Update(si.PackageCacheItem.Thumbnail, si.FileName); } else { WaitingScreen.UpdateMessage(si.FileName); } //make sure, the file is rescanned on the next Cache Update SimPe.Cache.PackageState ps = si.PackageCacheItem.FindState(this.Uid, true); ps.State = TriState.Null; Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.GZPS); if (pfds.Length == 0) { pfds = si.Package.FindFiles(0xCCA8E925); //Object XML } if (pfds.Length == 0) { pfds = si.Package.FindFiles(0x2C1FD8A1); //TextureOverlay XML } if (pfds.Length == 0) { pfds = si.Package.FindFiles(0x8C1580B5); //Hairtone XML } if (pfds.Length == 0) { pfds = si.Package.FindFiles(0x0C1FE246); //Mesh Overlay XML } ArrayList data = new ArrayList(); foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf(); cpf.ProcessData(pfd, si.Package, false); uint age = cpf.GetSaveItem(name).UIntegerValue; foreach (CheckBox cb in cbs) { if (cb.CheckState == CheckState.Indeterminate) { continue; } age |= (uint)cb.Tag; if (cb.CheckState == CheckState.Unchecked) { age ^= (uint)cb.Tag; } } if (yacheck) { //when Young Adult is set, we need to make sure that the Version is updated accordingly! if ((age & (uint)Data.Ages.YoungAdult) != 0) { AddUniversityFields(cpf); } } if (cpf.GetSaveItem(name).UIntegerValue != age) { chg = true; } cpf.GetSaveItem(name).UIntegerValue = age; cpf.SynchronizeUserData(); } si.Package.Save(); } } //foreach if (chg && this.CallbackFinish != null) { this.CallbackFinish(false, false); } } catch (Exception ex) { Helper.ExceptionMessage("", ex); } finally { WaitingScreen.Stop(); } }
protected override void StartThread() { string[] files = Directory.GetFiles(dir, "*.package"); if (Helper.StartedGui == Executable.Classic) { WaitingScreen.Wait(); } else { Wait.SubStart(files.Length); } try { bool breaked = false; SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); //ArrayList al = new ArrayList(); int ct = 0; int step = Math.Max(2, Wait.MaxProgress / 100); foreach (string file in files) { if (this.HaveToStop) { breaked = true; break; } SimPe.Packages.File fl = null; try { fl = SimPe.Packages.File.LoadFromFile(file); } catch { break; } IPackedFileDescriptor[] list = fl.FindFiles(Data.MetaData.OBJD_FILE); if (list.Length > 0) { AddSim(fl, list[0], ref ct, step); } //fl.Reader.Close(); } //foreach if (!breaked) { ScanFileTable(); } } catch (Exception ex) { Helper.ExceptionMessage(ex); } finally { if (Helper.StartedGui == Executable.Classic) { WaitingScreen.Stop(); } else { Wait.SubStop(); } } ended.Set(); }
/// <summary> /// Create a new Color Options package /// </summary> /// <param name="newpkg">The Package the color Option should be added to</param> /// <param name="fkt">The function that ahs to be called wne the Selection should be displayed</param> public void Create(IPackageFile newpkg, CreateSelectionCallback fkt) { WaitingScreen.Wait(); try { //this.newpkg = newpkg; WaitingScreen.UpdateMessage("Loading available Color Options"); Hashtable fullmap = Scenegraph.GetMMATMap(package); Hashtable map = fullmap; ArrayList allowedSubsets = Scenegraph.GetRecolorableSubsets(package); //Check if the User can select a Subset bool userselect = false; if (map.Count > 1) { userselect = true; } else { if (map.Count == 1) { foreach (string s in map.Keys) { Hashtable ht = (Hashtable)map[s]; if (ht.Count > 1) { userselect = true; } } } } SubsetSelectForm ssf = SubsetSelectForm.Prepare(map, allowedSubsets); fkt(ssf, userselect, fullmap); } finally { WaitingScreen.Stop(); } return; /*string[] subsets = GetSubsets(); * * //let the user Select * if ((subsets.Length>1) && (ask)) * { * Listing l = new Listing(); * subsets = l.Execute(subsets); * } * * WaitingScreen.Wait(); * WaitingScreen.UpdateMessage("Getting slave Subsets"); * SubsetItem[] subsetsi = GetSlaveSubsets(subsets); * * WaitingScreen.UpdateMessage("Getting Resource Nodes"); * ArrayList cres = GetCresNames(subsetsi); * * WaitingScreen.UpdateMessage("Getting Material Overrides"); * Hashtable mmats = GetMMATs(subsetsi, cres); * ArrayList guids = GetGUIDs(); * * LoadSubSetList(mmats, guids, subsetsi); * * WaitingScreen.UpdateMessage("Load LIFO Files"); * GetLifoFiles(); * * WaitingScreen.Stop();*/ }
/// <summary> /// Check for SimPE Updates /// </summary> /// <returns>true if success</returns> public static UpdateState CheckUpdate(ref long version, ref long qaversion) { if (!IsConnectedToInternet()) { return(new UpdateState(UpdateStates.Nothing)); } Helper.WindowsRegistry.LastUpdateCheck = DateTime.Now; WebClient Client = new WebClient(); bool run = true; if (Helper.StartedGui == Executable.Classic) { run = WaitingScreen.Running; WaitingScreen.Wait(); } else { Wait.SubStart(); } try { WaitingScreen.UpdateMessage("Check for new Updates"); Wait.Message = "Check for new Updates"; string content = DownloadContent("http://sims.ambertation.de/downloadnfo.txt?&browser=simpe"); //extract the Version String WaitingScreen.UpdateMessage("read latest Version"); Wait.Message = "Reciving latest Version"; UpdateState res = new UpdateState(UpdateStates.Nothing); try { version = GetVersion(content, "lversion"); qaversion = GetVersion(content, "qaversion"); if (version > Helper.SimPeVersionLong) { res.AddSimPeState(UpdateStates.NewRelease); } if (Helper.QARelease || Helper.WindowsRegistry.WasQAUser) { if (qaversion > Helper.SimPeVersionLong) { res.AddSimPeState(UpdateStates.NewQARelease); } } } catch (Exception ex) { if (!run) { WaitingScreen.Stop(); run = false; } Helper.ExceptionMessage("", ex); } try { bool first = true; System.Collections.Generic.List <string> urls = new System.Collections.Generic.List <string>(); foreach (IUpdatablePlugin pl in UpdateState.UpdateablePluginList) { string url = pl.GetUpdateInformation().VersionCheckUrl; if (urls.Contains(url.ToLower())) { continue; } urls.Add(url.ToLower()); content = DownloadContent(url); res.CheckPluginUpdates(content, first); first = false; } } catch (Exception ex) { if (!run) { WaitingScreen.Stop(); run = false; } Helper.ExceptionMessage("", ex); } if (Helper.StartedGui == Executable.Classic) { if (!run) { WaitingScreen.Stop(); } } else { Wait.SubStop(); } return(res); } catch (Exception ex) { Helper.ExceptionMessage(new Warning("SimPE was unable to connect to the Internet. It cannot lookup the latest Version.", "You can deactivate the Version Check in Extras->Preferences... .", ex)); } finally { if (Helper.StartedGui == Executable.Classic) { if (!run) { WaitingScreen.Stop(); } } else { Wait.SubStop(); } } return(new UpdateState(UpdateStates.Nothing)); }
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); }
void FillCategoryNodes(Hashtable mmap) { WaitingScreen.Wait(); try { FileTable.FileIndex.Load(); Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(Data.MetaData.GZPS, true); foreach (Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { SimPe.PackedFiles.Wrapper.Cpf skin = new SimPe.PackedFiles.Wrapper.Cpf(); skin.ProcessData(item); if (skin.GetSaveItem("type").StringValue == "skin") { bool added = false; uint skinage = skin.GetSaveItem("age").UIntegerValue; uint skincat = skin.GetSaveItem("category").UIntegerValue; if ((skincat & (uint)Data.SkinCategories.Skin) == (uint)Data.SkinCategories.Skin) { skincat = (uint)Data.SkinCategories.Skin; } if (skin.GetSaveItem("override0subset").StringValue.Trim().ToLower().StartsWith("hair")) { skincat = (uint)Data.SkinCategories.Skin; } if (skin.GetSaveItem("override0subset").StringValue.Trim().ToLower().StartsWith("bang")) { skincat = (uint)Data.SkinCategories.Skin; } uint skinsex = skin.GetSaveItem("gender").UIntegerValue; string name = skin.GetSaveItem("name").StringValue; foreach (uint age in mmap.Keys) { if ((age & skinage) == age) { Hashtable cats = (Hashtable)mmap[age]; foreach (uint cat in cats.Keys) { if ((cat & skincat) == cat) { Hashtable sex = (Hashtable)cats[cat]; foreach (uint g in sex.Keys) { if ((g & skinsex) == g) { TreeNode parent = (TreeNode)sex[g]; TreeNode node = new TreeNode(name); node.Tag = skin; parent.Nodes.Add(node); added = true; } } } } } } //foreach age if (!added) { TreeNode tn = new TreeNode(name); tn.Tag = skin; tvmale.Nodes.Add(tn); tvfemale.Nodes.Add((TreeNode)tn.Clone()); } } } } finally { WaitingScreen.Stop(); } }
/// <summary> /// Show the Relink Screen /// </summary> /// <param name="path">The Path where to look for character Files</param> /// <param name="wrp">The Sim Description Wrapper</param> /// <returns>The new SimID</returns> public static uint Execute(SimPe.PackedFiles.Wrapper.SDesc wrp) { Hashtable ht = wrp.nameprovider.StoredData; SimRelinkForm srf = new SimRelinkForm(); WaitingScreen.Wait(); try { foreach (SimPe.Data.Alias a in ht.Values) { ListViewItem lvi = new ListViewItem(a.Name + " " + (string)a.Tag[2]); lvi.Tag = a; if (a.Tag[1] != null) { lvi.ImageIndex = srf.ilist.Images.Count; Image img = SimPe.Plugin.ImageLoader.Preview((Image)a.Tag[1], srf.ilist.ImageSize); if (wrp.sdescprovider.FindSim(a.Id) != null) { Graphics gr = Graphics.FromImage(img); gr.FillRectangle(new Pen(Color.FromArgb(0x60, Color.Red), 1).Brush, 0, 0, img.Width, img.Height); } srf.ilist.Images.Add(img); } srf.lv.Items.Add(lvi); } srf.lv.Sort(); srf.btlink.Enabled = false; srf.ok = false; } finally { WaitingScreen.Stop(srf); } srf.ShowDialog(); if (srf.ok) { SimPe.Data.Alias a = (SimPe.Data.Alias)srf.lv.SelectedItems[0].Tag; SimPe.Packages.GeneratableFile pkg = SimPe.Packages.GeneratableFile.LoadFromFile((string)a.Tag[0]); Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.OBJD_FILE); if (pfds.Length == 1) { SimPe.PackedFiles.Wrapper.Objd objd = new SimPe.PackedFiles.Wrapper.Objd(null); objd.ProcessData(pfds[0], pkg); if (srf.cbfile.Checked) { objd.Guid = wrp.SimId; objd.SynchronizeUserData(); pkg.Save(); } else { wrp.SimId = objd.Guid; } } } return(wrp.SimId); }
private void Restore(object sender, System.EventArgs e) { if (lbdirs.SelectedIndex < 0) { return; } prov.SimDescriptionProvider.BasePackage = null; prov.SimFamilynameProvider.BasePackage = null; prov.SimNameProvider.BaseFolder = null; DialogResult dr = MessageBox.Show(Localization.Manager.GetString("backuprestore"), Localization.Manager.GetString("backup?"), MessageBoxButtons.YesNoCancel); if (dr != DialogResult.Cancel) { SimPe.Packages.StreamFactory.CloseAll(); this.Cursor = Cursors.WaitCursor; WaitingScreen.Wait(); try { string source = System.IO.Path.Combine(backuppath, lbdirs.Items[lbdirs.SelectedIndex].ToString()); if (dr == DialogResult.Yes) { //create backup of current string newback = System.IO.Path.Combine(backuppath, "(automatic) " + DateTime.Now.ToString().Replace("\\", "-").Replace(":", "-").Replace(".", "-")); if (!System.IO.Directory.Exists(newback)) { System.IO.Directory.CreateDirectory(newback); } Helper.CopyDirectory(path, newback, true); } //remove the Neighborhood try { SimPe.Packages.PackageMaintainer.Maintainer.RemovePackagesInPath(path); System.IO.Directory.Delete(path, true); } catch (Exception) {} //copy the backup System.IO.Directory.CreateDirectory(path); Helper.CopyDirectory(source, path, true); UpdateList(); WaitingScreen.Stop(this); MessageBox.Show("The backup was restored succesfully!"); } catch (Exception ex) { Helper.ExceptionMessage("", ex); } finally { WaitingScreen.Stop(); this.Cursor = Cursors.Default; } } }
/// <summary> /// Returns the Offset of the ResourceIndex in the current package /// </summary> /// <returns></returns> public HeaderIndex FindIndexOffset() { HeaderIndex hi = new HeaderIndex(pkg.Header); if (pkg is File) { ((File)pkg).ReloadReader(); } BinaryReader br = pkg.Reader; int step = 0x18; if (pkg.Header.IndexType == SimPe.Data.MetaData.IndexTypes.ptShortFileIndex) { step = 0x14; } long pos = br.BaseStream.Length - (4 * step + 1); long lastitem = -1; long firstitem = -1; SimPe.WaitingScreen.Wait(); try { while (pos > 0x04) { WaitingScreen.UpdateMessage("0x" + Helper.HexString(pos) + " / 0x" + Helper.HexString(br.BaseStream.Length)); bool hit = CouldBeIndexItem(br, pos, step, lastitem == -1); if (hit && lastitem == -1) { lastitem = br.BaseStream.Position; } if (!hit && lastitem != -1) { firstitem = pos + step; break; } if (lastitem == -1) { pos--; } else { pos -= step; } } } finally { WaitingScreen.Stop(); } hi.offset = (uint)firstitem; hi.size = (int)(lastitem - firstitem); hi.count = hi.size / step; if (firstitem == -1) { hi = pkg.Header.Index as HeaderIndex; } return(hi); }
/// <summary> /// This will build a SkinTone Replacement for the passed Skintone /// </summary> /// <param name="skintone">the skintone string</param> /// <param name="addtxtr">true, if you want to replace the default TXTR Files</param> /// <param name="addtxmt">true if you want to replace the default TXMT Files</param> /// <param name="sitem"></param> /// <param name="src"></param> /// <returns>the replacement package</returns> public SimPe.Packages.GeneratableFile BuildOverride(ScannerItem sitem, string skintone, string family, SimPe.Interfaces.Files.IPackageFile src, bool addtxmt, bool addtxtr, bool addref) { FileTable.FileIndex.Load(); SimPe.Packages.GeneratableFile pkg = SimPe.Packages.GeneratableFile.LoadFromStream((System.IO.BinaryReader)null); WaitingScreen.Wait(); //Save the old FileTable and the source File FileTable.FileIndex.Load(); FileTable.FileIndex.StoreCurrentState(); FileTable.FileIndex.AddIndexFromPackage(src); bool usefam = (skintone == "00000000-0000-0000-0000-000000000000"); try { //find al description Files that belong to the Skintone that should be replaced ArrayList basecpf = new ArrayList(); SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(Data.MetaData.GZPS, true); foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf(); cpf.ProcessData(item); if (cpf.GetSaveItem("skintone").StringValue != skintone) { continue; } //if (usefam) if (cpf.GetSaveItem("family").StringValue != family) { continue; } if (cpf.GetSaveItem("type").StringValue != "skin") { continue; } SimPe.Plugin.SkinChain sc = new SkinChain(cpf); basecpf.Add(sc); WaitingScreen.UpdateMessage(cpf.GetSaveItem("name").StringValue); } ArrayList compare = new ArrayList(); compare.Add("age"); //compare.Add("category"); compare.Add("fitness"); compare.Add("gender"); //compare.Add("outfit"); compare.Add("override0subset"); //compare.Add("override0resourcekeyidx"); //compare.Add("shapekeyidx"); //now select matching Files Interfaces.Files.IPackedFileDescriptor[] pfds = src.FindFiles(Data.MetaData.GZPS); #if DEBUG //we could add Debug Code here to see which cpfs were pulled :) /*SimPe.Packages.GeneratableFile f = SimPe.Packages.GeneratableFile.CreateNew(); * * foreach (SimPe.Plugin.SkinChain sc in basecpf) * { * sc.Cpf.SynchronizeUserData(); * f.Add(sc.Cpf.FileDescriptor); * * RefFile r = sc.ReferenceFile; * if (r!=null) * { * r.SynchronizeUserData(); * f.Add(r.FileDescriptor); * } * * //foreach (GenericRcol rcol in sc.TXTRs) * GenericRcol rcol = sc.TXTR; * if (rcol!=null) * { * rcol.SynchronizeUserData(); * f.Add(rcol.FileDescriptor); * } * * //foreach (GenericRcol rcol in sc.TXMTs) * rcol = sc.TXMT; * if (rcol!=null) * { * rcol.SynchronizeUserData(); * f.Add(rcol.FileDescriptor); * } * } * * f.Save(@"G:\skinbase.package"); * return f;*/ #endif foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { //load a description File for the new Skintone SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf(); cpf.ProcessData(pfd, src); int index = -1; int maxpoint = 0; //check if File is a match for (int i = 0; i < basecpf.Count; i++) { SimPe.Plugin.SkinChain sc = (SimPe.Plugin.SkinChain)basecpf[i]; int point = compare.Count; //scan for valid CPF Files foreach (string s in compare) { if (s == "age" || s == "category" || s == "outfit") { if ((sc.Cpf.GetSaveItem(s).UIntegerValue & cpf.GetSaveItem(s).UIntegerValue) == 0) { point--; } } else if (s == "override0subset") { string s1 = sc.Cpf.GetSaveItem(s).StringValue.Trim().ToLower(); string s2 = cpf.GetSaveItem(s).StringValue.Trim().ToLower(); if (s1 == "bottom") { s1 = "body"; } else if (s1 == "top") { s1 = "body"; } if (s2 == "bottom") { s2 = "body"; } else if (s2 == "top") { s2 = "body"; } if (s1 != s2) { point--; } } else if (sc.Cpf.GetSaveItem(s).UIntegerValue != cpf.GetSaveItem(s).UIntegerValue) { point--; } } if (point > maxpoint) { index = i; maxpoint = point; } } //yes, yes :D this is a match if (index >= 0 && maxpoint == compare.Count) { SimPe.Plugin.SkinChain sc = (SimPe.Plugin.SkinChain)basecpf[index]; SkinChain newsc = new SkinChain(cpf); if (sc.ReferenceFile != null && newsc.ReferenceFile != null && addref) { RefFile r = newsc.ReferenceFile; r.FileDescriptor = sc.ReferenceFile.FileDescriptor.Clone(); r.SynchronizeUserData(); if (pkg.FindFile(r.FileDescriptor) == null) { pkg.Add(r.FileDescriptor); } } if (sc.TXTR != null && newsc.TXTR != null && addtxtr) { SimPe.Plugin.GenericRcol txtr = newsc.TXTR; txtr.FileDescriptor = sc.TXTR.FileDescriptor.Clone(); #if DEBUG #else txtr.FileDescriptor.MarkForReCompress = true; #endif txtr.FileName = sc.TXTR.FileName; txtr.SynchronizeUserData(); if (pkg.FindFile(txtr.FileDescriptor) == null) { pkg.Add(txtr.FileDescriptor); } } if (sc.TXMT != null && newsc.TXMT != null && addtxmt) { SimPe.Plugin.GenericRcol txmt = newsc.TXMT; txmt.FileDescriptor = sc.TXMT.FileDescriptor.Clone(); #if DEBUG #else txmt.FileDescriptor.MarkForReCompress = true; #endif MaterialDefinition md = (MaterialDefinition)txmt.Blocks[0]; MaterialDefinition mdorg = (MaterialDefinition)sc.TXMT.Blocks[0]; txmt.FileName = sc.TXMT.FileName; md.FileDescription = mdorg.FileDescription; txmt.SynchronizeUserData(); if (pkg.FindFile(txmt.FileDescriptor) == null) { pkg.Add(txmt.FileDescriptor); } } } } SimPe.PackedFiles.Wrapper.Str str = new Str(); str.Add(new StrToken(0, 0, "SimPE Skin Override: " + skintone + " (from " + sitem.PackageCacheItem.Name + ")", "")); str.FileDescriptor = new SimPe.Packages.PackedFileDescriptor(); str.FileDescriptor.Type = Data.MetaData.STRING_FILE; str.FileDescriptor.Group = Data.MetaData.LOCAL_GROUP; str.FileDescriptor.LongInstance = 0; str.SynchronizeUserData(); pkg.Add(str.FileDescriptor); } finally { //restore the Previous FileTable FileTable.FileIndex.RestoreLastState(); WaitingScreen.Stop(); } return(pkg); }
public void ExtractAllFiles(string selpath, SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds, SimPe.Packages.ExtractableFile package) { int excount = 0; int filecount = 0; string xml = ""; bool run = WaitingScreen.Running; if (!run) { WaitingScreen.Wait(); } try { xml += "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + Helper.lbr; xml += "<package type=\"" + ((uint)package.Header.IndexType).ToString() + "\">" + Helper.lbr; for (int i = 0; i < pfds.Length; i++) { System.Windows.Forms.Application.DoEvents(); Packages.PackedFileDescriptor fii = (Packages.PackedFileDescriptor)pfds[i]; Data.TypeAlias a = fii.TypeName; fii.Path = null; string path = System.IO.Path.Combine(selpath, fii.Path); fii.Filename = null; string name = System.IO.Path.Combine(path, fii.Filename); try { if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } //make sure the sub xmls don't have a Filename fii.Path = ""; package.SavePackedFile(name, null, fii, true); fii.Path = null; xml += fii.GenerateXmlMetaInfo(); filecount++; } catch (Exception ex) { excount++; Helper.ExceptionMessage(Localization.Manager.GetString("errwritingfile") + " " + name, ex); if (excount >= 5) { if (Message.Show(Localization.Manager.GetString("ask000"), Localization.Manager.GetString("proceed"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { i = pfds.Length; } } } } //for i xml += "</package>" + Helper.lbr; System.IO.TextWriter tw = System.IO.File.CreateText(System.IO.Path.Combine(selpath, "package.xml")); try { tw.Write(xml); } catch (Exception ex) { Helper.ExceptionMessage(Localization.Manager.GetString("err001"), ex); } finally { tw.Close(); tw.Dispose(); tw = null; } } finally { if (!run) { WaitingScreen.Stop(); } } Message.Show(Localization.Manager.GetString("nfo000").Replace("{0}", filecount.ToString()), "Info", System.Windows.Forms.MessageBoxButtons.OK); }
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); }
private void MakeUnique(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { if (selection == null) { return; } WaitingScreen.Wait(); bool chg = false; try { Hashtable ids = Idno.FindUids(PathProvider.SimSavegameFolder, true); foreach (ScannerItem si in selection) { if (si.PackageCacheItem.Thumbnail != null) { WaitingScreen.Update(si.PackageCacheItem.Thumbnail, si.FileName); } else { WaitingScreen.UpdateMessage(si.FileName); } SimPe.Cache.PackageState ps = si.PackageCacheItem.FindState(this.Uid, true); if (si.PackageCacheItem.Type == PackageType.Neighborhood) { Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.IDNO); if (pfds.Length > 0) { Idno idno = new Idno(); idno.ProcessData(pfds[0], si.Package); idno.MakeUnique(ids); if (ps.Data.Length < 2) { ps.Data = new uint[2]; } if (idno.Uid != ps.Data[1]) { idno.SynchronizeUserData(); si.Package.Save(); chg = true; ps.Data[1] = idno.Uid; ps.State = TriState.True; } } } } if (chg && this.CallbackFinish != null) { this.CallbackFinish(false, false); } } #if !DEBUG catch (Exception ex) { Helper.ExceptionMessage("", ex); } #endif finally { WaitingScreen.Stop(); } }
/// <summary> /// Loads Memory Files form the Object Package /// </summary> public void LoadMemories() { memories = new Hashtable(); //if (BasePackage==null) return; Registry reg = Helper.WindowsRegistry; ArrayList list = new ArrayList(); Interfaces.Files.IPackedFileDescriptor pfd; SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); FileTable.FileIndex.Load(); Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFileDiscardingGroup(Data.MetaData.OBJD_FILE, 0x00000000000041A7); string max = " / " + items.Length.ToString(); int ct = 0; if (items.Length != 0) //found anything? { bool wasrunning = WaitingScreen.Running; WaitingScreen.Wait(); try { foreach (Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { ct++; if (ct % 137 == 1) { WaitingScreen.UpdateMessage(ct.ToString() + max); } pfd = item.FileDescriptor; string name = ""; objd.ProcessData(item); if (memories.Contains(objd.Guid)) { continue; } try { Interfaces.Scenegraph.IScenegraphFileIndexItem[] sitems = FileTable.FileIndex.FindFile(Data.MetaData.CTSS_FILE, pfd.Group, objd.CTSSInstance, null); if (sitems.Length > 0) { str.ProcessData(sitems[0]); SimPe.PackedFiles.Wrapper.StrItemList strs = str.LanguageItems(Helper.WindowsRegistry.LanguageCode); if (strs.Length > 0) { name = strs[0].Title; } //not found? if (name == "") { strs = str.LanguageItems(1); if (strs.Length > 0) { name = strs[0].Title; } } } } catch (Exception) { } //still no name? if (name == "") { name = objd.FileName; } #if DEBUG IAlias a = new Alias(objd.Guid, name, "{1}: {name} (0x{id})"); #else IAlias a = new Alias(objd.Guid, name, "{1}: {name}"); #endif object[] o = new object[3]; o[0] = pfd; o[1] = (Data.ObjectTypes)objd.Type; o[2] = null; SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); Interfaces.Scenegraph.IScenegraphFileIndexItem[] iitems = FileTable.FileIndex.FindFile(Data.MetaData.SIM_IMAGE_FILE, pfd.Group, 1, null); if (iitems.Length > 0) { pic.ProcessData(iitems[0]); System.Drawing.Image img = pic.Image; o[2] = img; WaitingScreen.Update(img, ct.ToString() + max); } a.Tag = o; if (!memories.Contains(objd.Guid)) { memories.Add(objd.Guid, a); } } //foreach item } finally { if (!wasrunning) { WaitingScreen.Stop(); } } } // if items>0 //System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Normal; }