public override void EnableControl(ScannerItem[] items, bool active) { selection = items; if (!active) { OperationControl.Enabled = false; return; } if (items.Length > 1) { OperationControl.Enabled = false; return; } bool en = false; foreach (ScannerItem item in items) { SimPe.Cache.PackageState ps = item.PackageCacheItem.FindState(this.Uid, true); if (item.PackageCacheItem.Type == PackageType.Skin) { en = true; break; } } OperationControl.Enabled = en; }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { ps.Data = new uint[1]; ps.Data[0] = (uint)SimPe.PackedFiles.Wrapper.ShelveDimension.Indetermined; ps.State = TriState.True; if (si.PackageCacheItem.Type == PackageType.Object || si.PackageCacheItem.Type == PackageType.MaxisObject) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.OBJD_FILE); if (pfds.Length > 1) { ps.Data[0] = (uint)SimPe.PackedFiles.Wrapper.ShelveDimension.Multitile; } else if (pfds.Length > 0) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new ExtObjd(); objd.ProcessData(pfds[0], si.Package); SimPe.PackedFiles.Wrapper.ShelveDimension sd = objd.ShelveDimension; if (sd == SimPe.PackedFiles.Wrapper.ShelveDimension.Unknown1 || sd == SimPe.PackedFiles.Wrapper.ShelveDimension.Indetermined || sd == SimPe.PackedFiles.Wrapper.ShelveDimension.Unknown2) { ps.State = TriState.False; } ps.Data[0] = (uint)sd; } } UpdateState(si, ps, lvi); }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.GMDC); //ArrayList list = new ArrayList(); ps.State = TriState.True; uint fct = 0; uint vct = 0; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.Plugin.Rcol rcol = new GenericRcol(); rcol.ProcessData(pfd, si.Package, true); SimPe.Plugin.GeometryDataContainer gmdc = rcol.Blocks[0] as SimPe.Plugin.GeometryDataContainer; foreach (SimPe.Plugin.Gmdc.GmdcGroup g in gmdc.Groups) { fct += (uint)g.FaceCount; vct += (uint)g.UsedVertexCount; } rcol.Dispose(); } ps.Data = new uint[] { vct, fct }; UpdateState(si, ps, lvi); }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { this.LoadThumbnail(si, ps); 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); ps.Data = new uint[2]; ps.Data[0] = (uint)idno.Type; ps.Data[1] = idno.Uid; //check for duplicates if (ids.Contains(idno.Uid)) { ps.State = TriState.False; } else { ps.State = TriState.True; } } } if (si.PackageCacheItem.Thumbnail != null && WaitingScreen.Running) { WaitingScreen.UpdateImage(si.PackageCacheItem.Thumbnail); } UpdateState(si, ps, lvi); }
public void UpdateState(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { AbstractScanner.SetSubItem(lvi, this.StartColum + 1, ""); if (si.PackageCacheItem.Type == PackageType.Neighborhood) { if (si.PackageCacheItem.Thumbnail == null) { this.LoadThumbnail(si, ps); } //Add the Thumbnail if available if (si.PackageCacheItem.Thumbnail != null) { ListView.SmallImageList.Images.Add(si.PackageCacheItem.Thumbnail); lvi.ImageIndex = ListView.SmallImageList.Images.Count - 1; } if (ps.Data.Length > 1) { ids.Add(ps.Data[1]); AbstractScanner.SetSubItem(lvi, this.StartColum, ((NeighborhoodType)ps.Data[0]).ToString()); AbstractScanner.SetSubItem(lvi, this.StartColum + 1, "0x" + Helper.HexString(ps.Data[1]), ps); } } }
public override void EnableControl(ScannerItem[] items, bool active) { selection = items; if (!active) { OperationControl.Enabled = false; return; } if (items.Length == 0) { OperationControl.Enabled = false; } else if (items.Length == 1) { SimPe.Cache.PackageState ps = items[0].PackageCacheItem.FindState(this.Uid, true); if (ps.Data.Length > 0) { ScannerPanelForm.Form.cbshelve.SelectedValue = (SimPe.PackedFiles.Wrapper.ShelveDimension)ps.Data[0]; OperationControl.Enabled = true; } } else { ScannerPanelForm.Form.cbshelve.SelectedValue = SimPe.PackedFiles.Wrapper.ShelveDimension.Indetermined; OperationControl.Enabled = true; } }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { ps.Data = new uint[1]; ps.Data[0] = (uint)ReadyState.Yes; ps.State = TriState.True; if (si.PackageCacheItem.Type == PackageType.Object || si.PackageCacheItem.Type == PackageType.MaxisObject || si.PackageCacheItem.Type == PackageType.Recolor) { //this package does not contain a File in a Global Group, so it is probably not a Maxis Object! if (si.Package.FindFilesByGroup(Data.MetaData.GLOBAL_GROUP).Length == 0) { //all Files in the Local Group, this is not EP-Ready if (si.Package.FindFilesByGroup(Data.MetaData.LOCAL_GROUP).Length == si.Package.Index.Length) { ps.State = TriState.False; ps.Data[0] = (uint)ReadyState.NotUniversityReady; } //no Files in our Custom Group, so this might be a unready File (but it's not Sure!) if (si.Package.FindFilesByGroup(Data.MetaData.CUSTOM_GROUP).Length == 0) { ps.State = TriState.False; ps.Data[0] = (uint)ReadyState.Indetermined; } } } UpdateState(si, ps, lvi); }
public void UpdateState(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { if (ps.State != TriState.Null) { SimPe.PackedFiles.Wrapper.ShelveDimension cs = (SimPe.PackedFiles.Wrapper.ShelveDimension)ps.Data[0]; AbstractScanner.SetSubItem(lvi, this.StartColum, cs.ToString(), ps); } }
public void UpdateState(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { uint fct = ps.Data[1]; uint vct = ps.Data[0]; AbstractScanner.SetSubItem(lvi, this.StartColum, vct.ToString(), ps); AbstractScanner.SetSubItem(lvi, this.StartColum + 1, fct.ToString(), ps); }
public void UpdateState(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { if (ps.State != TriState.Null) { ReadyState cs = (ReadyState)ps.Data[0]; AbstractScanner.SetSubItem(lvi, this.StartColum, cs.ToString(), ps); } }
public void UpdateState(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { //Add the Thumbnail if available if (si.PackageCacheItem.Thumbnail != null) { ListView.SmallImageList.Images.Add(si.PackageCacheItem.Thumbnail); lvi.ImageIndex = ListView.SmallImageList.Images.Count - 1; } }
public void UpdateState(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { AbstractScanner.SetSubItem(lvi, this.StartColum + 1, ""); System.Drawing.Color cl = lvi.ForeColor; if (ps.State == TriState.True) { uint c = 0; uint a = 0; for (int i = 0; i < ps.Data.Length - 1; i += 2) { c |= ps.Data[i + 1]; a |= ps.Data[i]; } string age = ""; Data.Ages[] ages = (Data.Ages[])System.Enum.GetValues(typeof(Data.Ages)); foreach (Data.Ages ag in ages) { if ((a & (uint)ag) != 0) { if (age != "") { age += ", "; } age += ag.ToString(); } } if (a == 0) { cl = System.Drawing.Color.Red; } AbstractScanner.SetSubItem(lvi, this.StartColum, age, cl); if (si.PackageCacheItem.Type != SimPe.Cache.PackageType.Skin) { string category = ""; Data.SkinCategories[] cats = (Data.SkinCategories[])System.Enum.GetValues(typeof(Data.SkinCategories)); foreach (Data.SkinCategories cat in cats) { if ((c & (uint)cat) != 0) { if (category != "") { category += ", "; } category += cat.ToString(); } } if (c == 0) { cl = System.Drawing.Color.Red; } AbstractScanner.SetSubItem(lvi, this.StartColum + 1, category, cl); } } }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { ps.State = TriState.False; si.PackageCacheItem.Name = Localization.Manager.GetString("unknown"); SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.CTSS_FILE); if (pfds.Length == 0) { pfds = si.Package.FindFiles(Data.MetaData.STRING_FILE); } //Check for Str compatible Items if (pfds.Length > 0) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(pfds[0], si.Package, false); SimPe.PackedFiles.Wrapper.StrItemList list = str.FallbackedLanguageItems(Helper.WindowsRegistry.LanguageCode); foreach (SimPe.PackedFiles.Wrapper.StrToken item in list) { if (item.Title.Trim() != "") { ps.State = TriState.True; si.PackageCacheItem.Name = item.Title; break; } } } else { 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(Data.MetaData.MMAT); } //Check for Cpf compatible Items if (pfds.Length > 0) { SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf(); cpf.ProcessData(pfds[0], si.Package, false); si.PackageCacheItem.Name = cpf.GetSaveItem("name").StringValue; if (si.PackageCacheItem.Name.Trim() != "") { ps.State = TriState.True; } } } UpdateState(si, ps, lvi); }
public void UpdateState(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { string text = "yes"; if (ps.State == TriState.False) { text = "no"; } AbstractScanner.SetSubItem(lvi, this.StartColum, text, ps); }
public void LoadThumbnail(ScannerItem si, SimPe.Cache.PackageState ps) { if (si.PackageCacheItem.Type == PackageType.Neighborhood) { string name = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(si.FileName), System.IO.Path.GetFileNameWithoutExtension(si.FileName)) + ".png"; if (System.IO.File.Exists(name)) { Image img = Image.FromFile(name); si.PackageCacheItem.Thumbnail = ImageLoader.Preview(img, AbstractScanner.ThumbnailSize); } } }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { 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 ) { 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); data.Add(cpf.GetSaveItem("age").UIntegerValue); data.Add(cpf.GetSaveItem("category").UIntegerValue); } ps.Data = new uint[data.Count]; data.CopyTo(ps.Data); ps.State = TriState.True; } else { ps.State = TriState.False; } UpdateState(si, ps, lvi); }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.OBJD_FILE); ArrayList mylist = new ArrayList(); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new ExtObjd(); objd.ProcessData(pfd, si.Package, false); mylist.Add(objd.Guid); objd.Dispose(); } uint[] guids = new uint[mylist.Count]; mylist.CopyTo(guids); si.PackageCacheItem.Guids = guids; ps.State = TriState.True; UpdateState(si, ps, lvi); }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.MMAT); //ArrayList list = new ArrayList(); ps.State = TriState.True; //FileTable.FileIndex.StoreCurrentState(); if (!FileTable.FileIndex.ContainsPath(System.IO.Path.GetDirectoryName(si.FileName))) { FileIndex.AddIndexFromFolder(System.IO.Path.GetDirectoryName(si.FileName)); } FileIndex.AddIndexFromPackage(si.Package); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.Plugin.MmatWrapper mmat = new MmatWrapper(); mmat.ProcessData(pfd, si.Package, false); string m = mmat.ModelName.Trim().ToLower(); if (!m.EndsWith("_cres")) { m += "_cres"; } //Add the current package SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item = FileTable.FileIndex.FindFileByName(m, Data.MetaData.CRES, Data.MetaData.LOCAL_GROUP, true); if (item == null) { ps.State = TriState.False; } item = null; mmat.Dispose(); m = null; } //FileTable.FileIndex.RestoreLastState(); UpdateState(si, ps, lvi); }
public override void EnableControl(ScannerItem[] items, bool active) { selection = items; if (!active) { OperationControl.Enabled = false; return; } foreach (ScannerItem item in items) { SimPe.Cache.PackageState ps = item.PackageCacheItem.FindState(this.Uid, true); if ((ps.State != TriState.Null) && (ps.Data.Length > 0)) { if ((HealthState)ps.Data[0] != HealthState.Ok) { OperationControl.Enabled = true; return; } } } //foreach OperationControl.Enabled = false; }
/// <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(); } }
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(); } }
public void UpdateState(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { }
public override void EnableControl(ScannerItem[] items, bool active) { selection = items; if (!active) { this.OperationControl.Enabled = false; return; } bool en = false; int[] agect = new int[ScannerPanelForm.Form.cbages.Length]; for (int i = 0; i < agect.Length; i++) { agect[i] = 0; } int[] catct = new int[ScannerPanelForm.Form.cbcategories.Length]; for (int i = 0; i < catct.Length; i++) { catct[i] = 0; } int maxagecount = 0; foreach (ScannerItem si in items) { SimPe.Cache.PackageState ps = si.PackageCacheItem.FindState(this.Uid, true); for (int ct = 0; ct < ps.Data.Length - 1; ct += 2) { en = true; maxagecount++; for (int i = 0; i < agect.Length; i++) { if ((ps.Data[ct] & (uint)ScannerPanelForm.Form.cbages[i].Tag) != 0) { agect[i]++; } } for (int i = 0; i < catct.Length; i++) { if ((ps.Data[ct + 1] & (uint)ScannerPanelForm.Form.cbcategories[i].Tag) != 0) { catct[i]++; } } } //for ct } //Set the State of the Checkboxes for (int i = 0; i < agect.Length; i++) { if (agect[i] == 0) { ScannerPanelForm.Form.cbages[i].CheckState = System.Windows.Forms.CheckState.Unchecked; } else if (agect[i] == maxagecount) { ScannerPanelForm.Form.cbages[i].CheckState = System.Windows.Forms.CheckState.Checked; } else { ScannerPanelForm.Form.cbages[i].CheckState = System.Windows.Forms.CheckState.Indeterminate; } } //Set the State of the Checkboxes for (int i = 0; i < catct.Length; i++) { if (catct[i] == 0) { ScannerPanelForm.Form.cbcategories[i].CheckState = System.Windows.Forms.CheckState.Unchecked; } else if (catct[i] == maxagecount) { ScannerPanelForm.Form.cbcategories[i].CheckState = System.Windows.Forms.CheckState.Checked; } else { ScannerPanelForm.Form.cbcategories[i].CheckState = System.Windows.Forms.CheckState.Indeterminate; } } this.OperationControl.Enabled = en; }
public void UpdateState(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { AbstractScanner.SetSubItem(lvi, this.StartColum, si.PackageCacheItem.Name); }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { System.Drawing.Size sz = AbstractScanner.ThumbnailSize; if (si.PackageCacheItem.Type == PackageType.Object || si.PackageCacheItem.Type == PackageType.MaxisObject || si.PackageCacheItem.Type == PackageType.Recolor) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.OBJD_FILE); uint group = 0; if (pfds.Length > 0) { group = pfds[0].Group; } if (group == Data.MetaData.LOCAL_GROUP) { SimPe.Interfaces.Wrapper.IGroupCacheItem gci = FileTable.GroupCache.GetItem(si.FileName); if (gci != null) { group = gci.LocalGroup; } } string[] modelnames = SimPe.Plugin.Scenegraph.FindModelNames(si.Package); foreach (string modelname in modelnames) { System.Drawing.Image img = SimPe.Plugin.Workshop.GetThumbnail(group, modelname); if (img != null) { si.PackageCacheItem.Thumbnail = img; ps.State = TriState.True; break; } } } //no Thumbnail, do we have a Image File? if (ps.State == TriState.Null) { SimPe.PackedFiles.Wrapper.Picture pic = new Picture(); uint[] types = pic.AssignableTypes; foreach (uint type in types) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(type); if (pfds.Length > 0) { //get image with smallest Instance SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pfds[0]; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor p in pfds) { if (p.Instance < pfd.Instance) { pfd = p; } } pic.ProcessData(pfd, si.Package, false); si.PackageCacheItem.Thumbnail = pic.Image; if (si.PackageCacheItem.Thumbnail != null) { si.PackageCacheItem.Thumbnail = ImageLoader.Preview(si.PackageCacheItem.Thumbnail, sz); ps.State = TriState.True; } break; } } //foreach } //no Thumbnail generated by the Game? if (ps.State == TriState.Null) { //load the Texture Image SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.TXTR); if (pfds.Length > 0) { SimPe.Plugin.GenericRcol rcol = new GenericRcol(null, false); //get biggest texture SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pfds[0]; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor p in pfds) { if (p.Size > pfd.Size) { pfd = p; } } rcol.ProcessData(pfd, si.Package, false); SimPe.Plugin.ImageData id = (SimPe.Plugin.ImageData)rcol.Blocks[0]; SimPe.Plugin.MipMap mm = id.GetLargestTexture(sz); if (mm.Texture != null) { si.PackageCacheItem.Thumbnail = ImageLoader.Preview(mm.Texture, sz); ps.State = TriState.True; } rcol.Dispose(); } } if (si.PackageCacheItem.Thumbnail != null) { if (WaitingScreen.Running) { WaitingScreen.UpdateImage(si.PackageCacheItem.Thumbnail); } } UpdateState(si, ps, lvi); }
/// <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(); } }
public void UpdateState(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { ps.State = TriState.True; string guids = ""; string ff = SimPe.Localization.Manager.GetString("unknown"); foreach (uint guid in si.PackageCacheItem.Guids) { string flname = si.FileName.Trim().ToLower(); if (guids != "") { guids += ", "; } guids += "0x" + Helper.HexString(guid); /*foreach (MemoryCacheItem mci in cachefile.List) * { * if (mci.Guid == guid) * { * if (mci.ParentCacheContainer!=null) * { * if (mci.ParentCacheContainer.FileName.Trim().ToLower() != flname) * { * ps.State = TriState.False; * break; * } * } * } * }*/ string fl = si.Package.FileName.Trim().ToLower(); if (list.ContainsKey(guid)) { string cmp = (string)list[guid]; if (cmp != fl) { ps.State = TriState.False; ff = cmp; } else { ps.State = TriState.True; } } else { list.Add(guid, fl); } } string text = "no"; if (ps.State == TriState.False) { text = "yes"; } AbstractScanner.SetSubItem(lvi, this.StartColum, guids); AbstractScanner.SetSubItem(lvi, this.StartColum + 1, text, ps); AbstractScanner.SetSubItem(lvi, this.StartColum + 2, ff); }
/// <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 void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { ps.Data = new uint[1]; ps.State = TriState.True; ps.Data[0] = (uint)HealthState.Ok; if (si.Package.Header.Version != 0x100000001) { ps.Data[0] = (uint)HealthState.UnknownVersion; } else { if (si.Package.FileListFile != null) { foreach (SimPe.PackedFiles.Wrapper.ClstItem item in si.Package.FileListFile.Items) { SimPe.Interfaces.Files.IPackedFileDescriptor p = si.Package.FindFile(item.Type, item.SubType, item.Group, item.Instance); if (p == null) { ps.Data[0] = (uint)HealthState.WrongDirectory; break; } } if (ps.Data[0] == (uint)HealthState.Ok) { foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in si.Package.Index) { SimPe.Interfaces.Files.IPackedFile fl = si.Package.Read(pfd); if (pfd.Type == Data.MetaData.OBJD_FILE) { SimPe.PackedFiles.Wrapper.ExtObjd obj = new ExtObjd(); obj.ProcessData(pfd, si.Package); if (obj.Ok != SimPe.PackedFiles.Wrapper.ObjdHealth.Ok) { ps.Data[0] = (uint)HealthState.NonDefaultObjd; } if (obj.Ok == SimPe.PackedFiles.Wrapper.ObjdHealth.UnmatchingFilenames && Helper.WindowsRegistry.HiddenMode) { ps.Data[0] = (uint)HealthState.FaultyNamedObjd; } if (obj.Ok == ObjdHealth.OverLength) { ps.Data[0] = (uint)HealthState.FaultySizedObjd; } } if (pfd.Type == Data.MetaData.GMDC) { SimPe.Plugin.GenericRcol rcol = new GenericRcol(); rcol.ProcessData(pfd, si.Package); SimPe.Plugin.GeometryDataContainer gmdc = (SimPe.Plugin.GeometryDataContainer)rcol.Blocks[0]; foreach (SimPe.Plugin.Gmdc.GmdcGroup g in gmdc.Groups) { if (g.FaceCount > SimPe.Plugin.Gmdc.AbstractGmdcImporter.CRITICAL_FACE_AMOUNT) { ps.Data[0] = (uint)HealthState.BigMeshGeometry; } else if (g.UsedVertexCount > SimPe.Plugin.Gmdc.AbstractGmdcImporter.CRITICAL_VERTEX_AMOUNT) { ps.Data[0] = (uint)HealthState.BigMeshGeometry; } } } if (!fl.IsCompressed) { continue; } int pos = si.Package.FileListFile.FindFile(pfd); if (pos == -1) { ps.Data[0] = (uint)HealthState.IncompleteDirectory; break; } SimPe.PackedFiles.Wrapper.ClstItem item = si.Package.FileListFile.Items[pos]; if (fl.UncompressedSize != item.UncompressedSize) { ps.Data[0] = (uint)HealthState.WrongCompressionSize; break; } } } } if (ps.Data[0] != (uint)HealthState.Ok) { ps.State = TriState.False; } } UpdateState(si, ps, lvi); }
/// <summary> /// Set the Name and color of a Column /// </summary> /// <param name="lvi">The ListViewItem where you want to add that column</param> /// <param name="index">The Index of the Column</param> /// <param name="name">The Name you want to display</param> /// <param name="ps">If state is null, the default color is used, false will be red, true will be green</param> public static void SetSubItem(System.Windows.Forms.ListViewItem lvi, int index, string name, SimPe.Cache.PackageState ps) { System.Drawing.Color cl = lvi.ForeColor; if (ps != null) { if (ps.State == SimPe.Cache.TriState.True) { cl = System.Drawing.Color.Green; } else if (ps.State == SimPe.Cache.TriState.False) { cl = System.Drawing.Color.Red; } } SetSubItem(lvi, index, name, cl); }