/// <summary> /// Returns a Language String (if available in the passed Language) /// </summary> /// <param name="l">the Language</param> /// <returns>List of Strings</returns> public StrToken FallbackedLanguageItem(Data.MetaData.Languages l, int index) { StrItemList list = this.LanguageItems(l); StrToken name; if (list.Length > index) { name = list[index]; } else { name = new StrToken(0, 0, "", ""); } if (name.Title.Trim() == "") { list = this.LanguageItems(1); if (list.Length > index) { name = list[index]; } } return(name); }
void LoadTurnOns() { if (turnons != null) { return; } turnons = new System.Collections.Generic.Dictionary <int, string>(); if (SimPe.PathProvider.Global.EPInstalled < 2) { return; } SimPe.Packages.File pkg = SimPe.Packages.File.LoadFromFile(System.IO.Path.Combine(PathProvider.Global.Latest.InstallFolder, @"TSData\Res\Text\UIText.package")); SimPe.PackedFiles.Wrapper.Str str = new Str(); SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pkg.FindFile(Data.MetaData.STRING_FILE, 0, Data.MetaData.LOCAL_GROUP, 0xe1); if (pfd != null) { str.ProcessData(pfd, pkg); SimPe.PackedFiles.Wrapper.StrItemList strs = str.FallbackedLanguageItems(Helper.WindowsRegistry.LanguageCode); for (int i = 0; i < strs.Count; i++) { turnons[i] = strs[i].Title; } } }
/// <summary> /// Removes this Item From the List /// </summary> /// <param name="item">The Item you want to remove</param> public void Remove(StrToken item) { StrItemList lng = (StrItemList)lines[item.Language.Id]; if (lng != null) { lng.Remove(item); } }
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); }
/// <summary> /// Returns all Language-specific Strings /// </summary> /// <param name="l">the Language</param> /// <returns>List of Strings</returns> public StrItemList LanguageItems(Data.MetaData.Languages l) { StrItemList items = (StrItemList)lines[(byte)l]; if (items == null) { items = new StrItemList(); } return(items); }
public override object Clone() { StrItemList sil = new StrItemList(); foreach (StrToken si in this) { sil.Add(si); } return(sil); }
/// <summary> /// Removes all String Items that are not assigned to the Default Language /// </summary> public void ClearNonDefault() { StrItemList sil = this.Items; foreach (StrToken si in sil) { if (si.Language.Id != 1) { this.Remove(si); } } }
/// <summary> /// Adds a new String Item /// </summary> /// <param name="item">The Item you want to add</param> public void Add(StrToken item) { StrItemList lng = (StrItemList)lines[item.Language.Id]; if (lng == null) { lng = new StrItemList(); lines[item.Language.Id] = lng; } lng.Add(item); }
/// <summary> /// Copy the content of the Default Language down to the other Languages /// </summary> public void CopyFromDefaultToAll() { StrItemList sil = this.Items; StrItemList def = this.LanguageItems(new StrLanguage(1)); foreach (StrToken si in sil) { if (si.Language.Id != 1) { if (si.Index > 0 && si.Index < def.Count) { si.Title = def[si.Index].Title; si.Description = def[si.Index].Description; } } } }
void LoadWantTable(SDescVersions version) { wnl = null; if (version == SDescVersions.BaseGame) { string flname = System.IO.Path.Combine(PathProvider.Global.GetExpansion(Expansions.BaseGame).InstallFolder, @"TSData\Res\Objects\objects.package"); if (System.IO.File.Exists(flname)) { SimPe.Packages.File fl = SimPe.Packages.File.LoadFromFile(flname); Interfaces.Files.IPackedFileDescriptor pfd = fl.FindFile(0x53545223, 0, 0x7FE59FD0, 0xc8); if (pfd != null) { SimPe.PackedFiles.Wrapper.Str str = new Str(); str.ProcessData(pfd, fl); SimPe.PackedFiles.Wrapper.StrItemList list = str.LanguageItems(1); string xml = "<wantSimulator>" + Helper.lbr; xml += " <persondata>" + Helper.lbr; for (int sid = 0; sid < list.Length; sid++) { SimPe.PackedFiles.Wrapper.StrToken si = list[sid]; xml += " <persondata id=\"" + (sid + 1).ToString() + "\" name=\"" + si.Title + "\" /> " + Helper.lbr; } xml += " </persondata>" + Helper.lbr; xml += "</wantSimulator>" + Helper.lbr; wnl = new SimPe.Plugin.WantNameLoader(xml); } } } if (wnl == null) { FileTable.FileIndex.Load(); wnl = new SimPe.Plugin.WantNameLoader(version); } }
/// <summary> /// Returns all Langugae specific Strings, if the String is not included in the passed /// Language the Fallback String (use en) will be returned /// </summary> /// <param name="l">the Language</param> /// <returns>List of Strings</returns> public StrItemList FallbackedLanguageItems(Data.MetaData.Languages l) { if (l == Data.MetaData.Languages.English) { return(this.LanguageItems(l)); } StrItemList real = (StrItemList)LanguageItems(l).Clone(); StrItemList fallback = null; if (this.Languages.Contains(Data.MetaData.Languages.English)) { fallback = LanguageItems(Data.MetaData.Languages.English); } else if (this.Languages.Count == 1) { fallback = LanguageItems(Languages[0]); } else { fallback = LanguageItems(Data.MetaData.Languages.English); } for (int i = 0; i < fallback.Length; i++) { if (real.Length <= i) { real.Add(fallback[i]); } else if ((real[i] == null) || (real[i].Title.Trim() == "")) { real[i] = fallback[i]; } } return(real); }
private int CreateCollectibleAlias(SimPe.PackedFiles.Wrapper.StrItemList strs, SimPe.PackedFiles.Wrapper.Picture pic, string line, int index) { index--; string image = GetUIListAttribute(line, "image"); string id = GetUIAttribute(line, "id"); int nr = Helper.StringToInt32(id, 0, 16) / 2 - 1; string[] stgi = image.Split(new char[] { ',' }); UInt32 g = Helper.StringToUInt32(stgi[0], 0, 16); UInt32 i = Helper.StringToUInt32(stgi[1], 0, 16); string name = GetUITextAttribute(line, "tiptext"); if (index < strs.Count) { name = strs[index].Title; } System.Drawing.Image img = null; img = LoadCollectibleIcon(pic, g, i); collectibles[nr] = new CollectibleAlias((ulong)Math.Pow(2, nr), nr, name, img); return(index); }
void LoadCollectibles() { if (collectibles != null) { return; } collectibles = new System.Collections.Generic.Dictionary <int, CollectibleAlias>(); if (SimPe.PathProvider.Global.EPInstalled < 11) { return; } SimPe.Packages.File pkg = SimPe.Packages.File.LoadFromFile(System.IO.Path.Combine(PathProvider.Global.Latest.InstallFolder, @"TSData\Res\Text\UIText.package")); SimPe.PackedFiles.Wrapper.Str str = new Str(); SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pkg.FindFile(Data.MetaData.STRING_FILE, 0, Data.MetaData.LOCAL_GROUP, 0xb7); if (pfd != null) { str.ProcessData(pfd, pkg); SimPe.PackedFiles.Wrapper.StrItemList strs = str.FallbackedLanguageItems(Helper.WindowsRegistry.LanguageCode); pkg = SimPe.Packages.File.LoadFromFile(System.IO.Path.Combine(PathProvider.Global.Latest.InstallFolder, @"TSData\Res\UI\ui.package")); pfd = pkg.FindFile(0, 0, 0xA99D8A11, 0xACDC6300); if (pfd != null) { try { SimPe.PackedFiles.Wrapper.Xml xml = new SimPe.PackedFiles.Wrapper.Xml(); xml.ProcessData(pfd, pkg); string[] lines = xml.Text.Split(new char[] { '\r' }); SimPe.PackedFiles.Wrapper.Picture pic = new Picture(); SimPe.FileTable.FileIndex.Load(); foreach (string fulline in lines) { string line = fulline.ToLower().Trim(); if (line.StartsWith("<legacy") && line.IndexOf("enabled\"") > 0 && line.IndexOf("tipres=") >= 0) { line = line.Replace("<legacy", "").Replace(">", "").Trim(); string tipres = GetUIListAttribute(line, "tipres"); int index = Helper.StringToInt32(tipres.Split(new char[] { ',' })[1], 0, 16) & 0xFFFF; int testnr = (int)((Helper.StringToInt32(tipres.Split(new char[] { ',' })[1], 0, 16) & 0xFFFF0000) >> 16); if (index > 0 && testnr == 0xb7) { index = CreateCollectibleAlias(strs, pic, line, index); } } } } catch (Exception e) { System.Diagnostics.Debug.WriteLine("ERROR during Voyage Collectible Image Parsing:\n" + e.ToString()); if (Helper.DebugMode) { Helper.ExceptionMessage(e); } } } } }