protected override string GetResourceName(Data.TypeAlias ta) { //if (!SimPe.Helper.FileFormat) return base.GetResourceName(ta); if (!this.Processed) { this.ProcessData(FileDescriptor, Package); } string s = ""; if (SimPe.Helper.FileFormat) { s += version + ":"; } if (this["objectType"] != null) { s += (s.Length > 0 ? " " : "") + "(" + this["objectType"].Value + ")"; } if (this["folder"] != null) { s += (s.Length > 0 ? " " : "") + this["folder"].Value; } if (this["nodeText"] != null) { s += (s.Length > 0 ? " / " : "") + this["nodeText"].Value; } return(s); }
/// <summary> /// Override this to add your own Implementation for <see cref="ResourceName"/> /// </summary> /// <returns>null, if the Default Name should be generated</returns> protected override string GetResourceName(Data.TypeAlias ta) { if (!this.Processed) { ProcessData(FileDescriptor, Package, false); } return(this.FileName); }
/// <summary> /// Returns the describing TypeAlias for the passed Type /// </summary> /// <param name="type">The type you want to load the TypeAlias for</param> /// <returns>The TypeAlias representing the Type</returns> public static TypeAlias FindTypeAlias(UInt32 type) { Data.TypeAlias a = Helper.TGILoader.GetByType(type); if (a == null) { a = new Data.TypeAlias(false,Localization.Manager.GetString("unk") + "",type,"0x" + Helper.HexString(type)); } return(a); }
//all covered by AbstractWrapper protected override string GetResourceName(Data.TypeAlias ta) { if (!SimPe.Helper.FileFormat) { return(base.GetResourceName(ta)); } SimPe.Interfaces.Files.IPackedFile pf = Package.Read(FileDescriptor); byte[] ab = pf.GetUncompressedData(0x48); return((ab.Length > 0x44 ? "0x" + Helper.HexString(ab[0x44]) + ": " : "") + Helper.ToString(pf.GetUncompressedData(0x40))); }
protected override string GetResourceName(Data.TypeAlias ta) { ExtSDesc sdsc = FileTable.ProviderRegistry.SimDescriptionProvider.FindSim((ushort)this.FileDescriptor.Instance) as ExtSDesc; if (sdsc == null) { return(base.GetResourceName(ta)); } else { return(sdsc.SimName + " " + sdsc.SimFamilyName + " (Wants/Fears)"); } }
/// <summary> /// Returns the 64 Character Long embedded Filename /// </summary> /// <param name="ta">The Current Type</param> /// <returns></returns> string GetEmbeddedFileName(Data.TypeAlias ta) { if (Package == null) { return(null); } if (FileDescriptor == null) { return(null); } if (ta.containsfilename) { SimPe.Interfaces.Files.IPackedFile pf = Package.Read(FileDescriptor); return(Helper.ToString(pf.GetUncompressedData(0x40))); } else { return(null); } }
private void tbtype_TextChanged(object sender, System.EventArgs e) { cbtypes.Tag = true; Data.TypeAlias a = Data.MetaData.FindTypeAlias(Helper.HexStringToUInt(tbtype.Text)); this.AutoChange(sender, e); int ct = 0; foreach (Data.TypeAlias i in cbtypes.Items) { if (i == a) { cbtypes.SelectedIndex = ct; cbtypes.Tag = null; return; } ct++; } cbtypes.SelectedIndex = -1; cbtypes.Tag = null; }
/// <summary> /// Override this to add your own Implementation for <see cref="ResourceName"/> /// </summary> /// <param name="ta">The Current Type</param> /// <returns>null, if the Default Name should be generated</returns> protected virtual string GetResourceName(Data.TypeAlias ta) { return(null); }
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 void ExecuteEventHandler(object sender, SimPe.Events.ResourceEventArgs es) { if (!RealChangeEnabledStateEventHandler(null, es)) { System.Windows.Forms.MessageBox.Show(Localization.GetString("This is not an appropriate context in which to use this tool"), Localization.GetString(this.ToString())); return; } SimPe.Interfaces.Files.IPackedFileDescriptor pfd = null; for (int i = 0; i < es.Count; i++) { if (es[i].HasFileDescriptor) { pfd = es[i].Resource.FileDescriptor; break; } } Data.TypeAlias a = Helper.TGILoader.GetByType(pfd.Type); if (Data.MetaData.RcolList.Contains(a.Id)) { SimPe.Packages.PackedFileDescriptor fd = new SimPe.Packages.PackedFileDescriptor(); fd.Type = Data.MetaData.NAME_MAP; fd.Group = 0x52737256; fd.Instance = a.Id; fd.SubType = 0; SimPe.Plugin.Nmap nmap = new SimPe.Plugin.Nmap(FileTable.ProviderRegistry); nmap.FileDescriptor = fd; bool add = false; if (es.LoadedPackage.Package.FindFile(fd) == null) { add = true; } System.Collections.ArrayList list = new System.Collections.ArrayList(); foreach (SimPe.Events.ResourceContainer e in es) { if (!e.HasFileDescriptor) { continue; } if (e.Resource.FileDescriptor.Type != a.Id) { continue; } try { SimPe.Packages.PackedFileDescriptor p = (SimPe.Packages.PackedFileDescriptor)e.Resource.FileDescriptor; SimPe.Plugin.Rcol rcol = new SimPe.Plugin.GenericRcol(null, false); rcol.ProcessData(p, es.LoadedPackage.Package); p.Filename = rcol.FileName; list.Add(p); } catch (Exception) {} } //foreach nmap.Items = new SimPe.Packages.PackedFileDescriptor[list.Count]; list.CopyTo(nmap.Items); nmap.SynchronizeUserData(); if (add) { es.LoadedPackage.Package.Add(nmap.FileDescriptor); } } }