public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, MultilingualUnicodeStringList unic)
        {
            if (info.StringIds == null)
                return;

            context.AddCommand(new ListCommand(info, unic));
            context.AddCommand(new SetCommand(info, tag, unic));
        }
 public static CommandContext Create(CommandContext parent, OpenTagCache info, HaloTag tag, MultilingualUnicodeStringList unic)
 {
     var context = new CommandContext(parent, string.Format("{0:X8}.unic", tag.Index));
     if (info.StringIds != null)
     {
         context.AddCommand(new UnicListCommand(info, unic));
         context.AddCommand(new UnicSetCommand(info, tag, unic));
     }
     return context;
 }
        public static CommandContext Create(CommandContext parent, OpenTagCache info, TagInstance tag, MultilingualUnicodeStringList unic)
        {
            var groupName = info.StringIds.GetString(tag.Group.Name);

            var context = new CommandContext(parent,
                string.Format("{0:X8}.{1}", tag.Index, groupName));

            Populate(context, info, tag, unic);

            return context;
        }
        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;
        }
        public UnicSetCommand(OpenTagCache info, HaloTag tag, MultilingualUnicodeStringList unic)
            : 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.")
        {
            _info = info;
            _tag = tag;
            _unic = unic;
        }
        public ListCommand(OpenTagCache info, MultilingualUnicodeStringList definition)
            : 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?
            Info = info;
            Definition = definition;
        }
 /// <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;
 }