public static void AddComplex(this StringDBTable stringdb, string key, string value) { StringTableManager.ComplexStringCollection stringCollection = null; if (!stringdb.ContainsKey(key)) { stringCollection = new StringTableManager.ComplexStringCollection(); stringCollection.AddString(value, 1f); stringdb[key] = stringCollection; } else { stringCollection = (StringTableManager.ComplexStringCollection)stringdb[key]; stringCollection.AddString(value, 1f); stringdb[key] = stringCollection; } }
private static Dictionary <string, StringTableManager.StringCollection> LoadEnemiesTable(string subDirectory) { TextAsset textAsset = (TextAsset)BraveResources.Load("strings/" + subDirectory + "/enemies", typeof(TextAsset), ".txt"); if (textAsset == null) { Debug.LogError("Failed to load string table: ENEMIES."); return(null); } StringReader stringReader = new StringReader(textAsset.text); Dictionary <string, StringTableManager.StringCollection> dictionary = new Dictionary <string, StringTableManager.StringCollection>(); StringTableManager.StringCollection stringCollection = null; string text; while ((text = stringReader.ReadLine()) != null) { if (!text.StartsWith("//")) { if (text.StartsWith("#")) { stringCollection = new StringTableManager.ComplexStringCollection(); if (dictionary.ContainsKey(text)) { Debug.LogError("Failed to add duplicate key to items table: " + text); } else { dictionary.Add(text, stringCollection); } } else { string[] array = text.Split(new char[] { '|' }); if (array.Length == 1) { stringCollection.AddString(array[0], 1f); } else { stringCollection.AddString(array[1], float.Parse(array[0])); } } } } return(dictionary); }
public void SetComplex(string key, List <string> values, List <float> weights) { StringTableManager.StringCollection stringCollection = new StringTableManager.ComplexStringCollection(); for (int i = 0; i < values.Count; i++) { string value = values[i]; float weight = weights[i]; stringCollection.AddString(value, weight); } this.Table[key] = stringCollection; int num = this._ChangeKeys.IndexOf(key); if (num > 0) { this._ChangeValues[num] = stringCollection; } else { this._ChangeKeys.Add(key); this._ChangeValues.Add(stringCollection); } JournalEntry.ReloadDataSemaphore++; }
internal static void LoadLocalizationTextGeneral(TextReader reader, Func <string, bool> dupe_check, Action <string, StringTableManager.StringCollection> assign_action, bool overwrite = false, string default_namespace = null) { // mostly based on copied StringTableManager code // all the files have duplicate loading code but it all seems to be doing // the same thing /shrug StringTableManager.StringCollection coll = null; string text; while ((text = reader.ReadLine()) != null) { if (!text.StartsWithInvariant("//")) { if (text.StartsWithInvariant("#")) { coll = new StringTableManager.ComplexStringCollection(); if (default_namespace != null) { var id = text.Substring(1); if (id.Count(':') > 1) { Logger.Error($"Failed to add invalid key to table: {id}"); continue; } if (!id.Contains(":")) { id = $"{default_namespace}:{id}"; } if (id.StartsWithInvariant("gungeon:")) { text = $"#{id.Substring("gungeon:".Length)}"; } else { text = $"#{id}"; } } if (dupe_check.Invoke(text) && !overwrite) { Logger.Error($"Failed to add duplicate key to table: {text}"); } else { assign_action.Invoke(text, coll); } } else { if (coll == null) { continue; } // ignore the KEY,EN stuff on ui.txt // we don't need it anyway because we have our own ID system string[] array = text.Split(new char[] { '|' }); if (array.Length == 1) { coll.AddString(array[0], 1f); } else { coll.AddString(array[1], float.Parse(array[0])); } } } } }