public override object Execute(List <string> args) { if (args.Count != 1) { return(false); } var stringID = CacheContext.GetStringId(args[0]); var newDefinition = new MultilingualUnicodeStringList { Data = new byte[0], Strings = new List <LocalizedString>() }; foreach (var oldString in Definition.Strings) { if (oldString.StringID == stringID) { continue; } var newString = new LocalizedString { Offsets = new int[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, StringID = oldString.StringID, StringIDStr = oldString.StringIDStr }; for (var i = 0; i < 12; i++) { if (oldString.Offsets[i] == -1) { continue; } newDefinition.SetString(newString, (GameLanguage)i, Definition.GetString(oldString, (GameLanguage)i)); } newDefinition.Strings.Add(newString); } Definition.Data = newDefinition.Data; Definition.Strings = newDefinition.Strings; return(true); }
public override bool Execute(List <string> args) { if (args.Count != 3) { return(false); } GameLanguage language; if (!ArgumentParser.ParseLanguage(args[0], out language)) { return(false); } // Look up the stringID that was passed in var stringIdStr = args[1]; var stringIdIndex = _stringIds.Strings.IndexOf(stringIdStr); if (stringIdIndex < 0) { Console.Error.WriteLine("Unable to find stringID \"{0}\".", stringIdStr); return(true); } var stringId = _stringIds.GetStringId(stringIdIndex); if (stringId == 0) { Console.Error.WriteLine("Failed to resolve the stringID."); return(true); } var newValue = ArgumentParser.Unescape(args[2]); // Look up or create a localized string entry var localizedStr = _unic.Strings.FirstOrDefault(s => s.StringId == stringId); var added = false; if (localizedStr == null) { // Add a new string localizedStr = new LocalizedString { StringId = stringId }; _unic.Strings.Add(localizedStr); added = true; } // Save the tag data _unic.SetString(localizedStr, language, newValue); using (var stream = _fileInfo.Open(FileMode.Open, FileAccess.ReadWrite)) TagSerializer.Serialize(new TagSerializationContext(stream, _cache, _tag), _unic); if (added) { Console.WriteLine("String added successfully."); } else { Console.WriteLine("String changed successfully."); } return(true); }