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 GetCommand(info, tag, unic));
            context.AddCommand(new SetCommand(info, tag, unic));
        }
Beispiel #2
0
 public GetCommand(OpenTagCache info, TagInstance tag, MultilingualUnicodeStringList unic)
     : base(CommandFlags.Inherit,
           "get",
           "",
           "get <language> <string_id>",
           "")
 {
     Info = info;
     Tag = tag;
     Definition = unic;
 }
        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;
        }
Beispiel #4
0
 public SetCommand(OpenTagCache info, TagInstance 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;
     Definition = unic;
 }
Beispiel #5
0
 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;
 }