public static CommandContext Create(CommandContext parent, FileInfo fileInfo, TagCache cache, HaloTag tag,
			MultilingualUnicodeStringList unic, StringIdCache stringIds)
        {
            var context = new CommandContext(parent, string.Format("{0:X8}.unic", tag.Index));
            if (stringIds != null)
            {
                context.AddCommand(new UnicListCommand(unic, stringIds));
                context.AddCommand(new UnicSetCommand(fileInfo, cache, tag, unic, stringIds));
            }
            return context;
        }
Example #2
0
        public UnicSetCommand(FileInfo fileInfo, TagCache cache, HaloTag tag, MultilingualUnicodeStringList unic, StringIdCache stringIds)
            : base(CommandFlags.None,

			"set",
			"Set the value of a string",

			"set <language> <stringid> <value>",

			"Sets the string associated with a stringID in a language.\n" +
			"Remember to put the string value in quotes if it contains spaces.\n" +
			"If the string does not exist, it will be added.")
        {
            _fileInfo = fileInfo;
            _cache = cache;
            _tag = tag;
            _unic = unic;
            _stringIds = stringIds;
        }
        public UnicListCommand(MultilingualUnicodeStringList unic, StringIdCache stringIds)
            : base(CommandFlags.Inherit,

			"list",
			"List strings",

			"list <language> [filter]",

			"Lists the strings belonging to a language.\n" +
			"If a filter is specified, only strings containing the filter will be listed.\n" +
			"\n" +
			"Available languages:\n" +
			"\n" +
			"english, japanese, german, french, spanish, mexican, italian, korean,\n" +
			"chinese-trad, chinese-simp, portuguese, russian")
        {
            // TODO: Can we dynamically generate the language list from the dictionary in ArgumentParser?
            _unic = unic;
            _stringIds = stringIds;
        }
 /// <summary>
 /// Filters a set of localized strings and prepares them for display.
 /// </summary>
 /// <param name="unic">The string list.</param>
 /// <param name="stringIds">The string ID cache to use.</param>
 /// <param name="strings">The strings to display.</param>
 /// <param name="language">The language to display strings from.</param>
 /// <param name="filter">The filter to match strings and stringIDs against. Can be <c>null</c> to display everything.</param>
 /// <returns>The strings to print.</returns>
 public static List<DisplayString> PrepareForDisplay(MultilingualUnicodeStringList unic, StringIdCache stringIds, IEnumerable<LocalizedString> strings, GameLanguage language, string filter)
 {
     // Filter the input strings
     var display = new List<DisplayString>();
     foreach (var localizedString in strings)
     {
         var str = unic.GetString(localizedString, language);
         if (str == null)
             continue;
         var stringId = stringIds.GetString(localizedString.StringId);
         if (filter != null && !str.Contains(filter) && !stringId.Contains(filter))
             continue;
         display.Add(new DisplayString
         {
             StringId = stringId,
             String = str
         });
     }
     display.Sort((a, b) => String.Compare(a.StringId, b.StringId, StringComparison.Ordinal));
     return display;
 }