/// <summary> /// Returns the Thumbnail of an Object /// </summary> /// <param name="group"></param> /// <param name="modelname"></param> /// <returns>The Thumbnail</returns> public static Image GetThumbnail(string message, uint[] types, uint group, uint inst, SimPe.Packages.File thumbs) { foreach (uint type in types) { //0x6C2A22C3 Interfaces.Files.IPackedFileDescriptor[] pfds = thumbs.FindFile(type, group, inst); if (pfds.Length == 0) { pfds = thumbs.FindFile(type, 0, inst); } if (pfds.Length > 0) { Interfaces.Files.IPackedFileDescriptor pfd = pfds[0]; try { SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); pic.ProcessData(pfd, thumbs); Bitmap bm = (Bitmap)ImageLoader.Preview(pic.Image, WaitingScreen.ImageSize); if (WaitingScreen.Running) { WaitingScreen.Update(bm, message); } return(pic.Image); } catch (Exception) {} } } return(null); }
/// <summary> /// Returns the Thumbnail of an Object /// </summary> /// <param name="group"></param> /// <param name="modelname"></param> /// <returns>The Thumbnail</returns> public static Image GetThumbnail(string message, uint[] types, uint group, uint inst, SimPe.Packages.File thumbs) { /*ArrayList types = new ArrayList(); * types.Add(0xAC2950C1); // Objects * types.Add(0xEC3126C4); // Terrain * types.Add(0xCC48C51F); //chimney * types.Add(0x2C30E040); //fence Arch * types.Add(0xCC30CDF8); //fences * types.Add(0x8C311262); //floors * types.Add(0x2C43CBD4); //foundtaion / pools * types.Add(0xCC44B5EC); //modular Stairs * types.Add(0xCC489E46); //roof * types.Add(0x8C31125E); //wall*/ foreach (uint type in types) { //0x6C2A22C3 Interfaces.Files.IPackedFileDescriptor[] pfds = thumbs.FindFile(type, group, inst); if (pfds.Length == 0) { pfds = thumbs.FindFile(type, 0, inst); } if (pfds.Length > 0) { Interfaces.Files.IPackedFileDescriptor pfd = pfds[0]; try { SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); pic.ProcessData(pfd, thumbs); Bitmap bm = (Bitmap)ImageLoader.Preview(pic.Image, WaitingScreen.ImageSize); if (WaitingScreen.Running) { WaitingScreen.Update(bm, message); } return(pic.Image); } catch (Exception) { } } } return(null); }
/// <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(); } }
/// <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(); } }
/// <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> /// 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; }
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> /// this Operation is fixing selected Packages that wer marked as problematic /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Fix(string name) { 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 ((ReadyState)ps.Data[0] == ReadyState.Yes) { continue; } string mname = name; DateTime now = DateTime.Now; mname += now.Date.ToShortDateString(); mname += "-" + now.Hour.ToString("x"); mname += now.Minute.ToString("x"); mname += now.Second.ToString("x"); mname += now.Millisecond.ToString("x"); ps.State = TriState.Null; try { SimPe.Plugin.FixPackage.Fix(si.FileName, mname, FixVersion.UniversityReady); } catch (Exception ex) { Helper.ExceptionMessage("", ex); } } if (chg && this.CallbackFinish != null) { this.CallbackFinish(false, false); } } catch (Exception ex) { Helper.ExceptionMessage("", ex); } finally { WaitingScreen.Stop(); } }