public bool TryFormat(ref StringReader reader, StringBuilder output, FormatterParams formatterParams)
 {
     if (reader.Read("range"))
     {
         if (!m_initialized)
         {
             ReloadRawText();
         }
         IFightValueProvider fightValueProvider = formatterParams.valueProvider as IFightValueProvider;
         if (fightValueProvider == null)
         {
             Log.Error("Cannot format Range for a object without range", 80, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\UI\\Localization\\TextFormatting\\ParserRules\\TooltipParserRules\\RangeParserRule.cs");
             return(false);
         }
         Tuple <int, int> range = fightValueProvider.GetRange();
         if (range == null)
         {
             Log.Error("Cannot format Range for a object without range", 87, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\UI\\Localization\\TextFormatting\\ParserRules\\TooltipParserRules\\RangeParserRule.cs");
             return(false);
         }
         formatterParams.valueProvider = new IndexedValueProvider(range.Item1.ToString(), range.Item2.ToString());
         formatterParams.formatter.AppendFormat(rawText, output, formatterParams);
         return(true);
     }
     return(false);
 }
        public bool TryFormat(ref StringReader input, StringBuilder output, FormatterParams formatterParams)
        {
            char current = input.current;

            char[] firstLetters = m_firstLetters;
            int    num          = firstLetters.Length;

            for (int i = 0; i < num; i++)
            {
                if (firstLetters[i] != current)
                {
                    continue;
                }
                IParserRuleWithPrefix[] array = m_rulesByLetters[i];
                int num2 = array.Length;
                for (int j = 0; j < num2; j++)
                {
                    StringReader input2 = input;
                    if (array[j].TryFormat(ref input2, output, formatterParams))
                    {
                        input = input2;
                        return(true);
                    }
                }
            }
            return(false);
        }
        public bool TryFormat(ref StringReader input, StringBuilder output, FormatterParams formatterParams)
        {
            if (input.current != open)
            {
                return(false);
            }
            StringReader stringReader = input.Copy();
            SubString    subString    = stringReader.ReadContent(open, close);

            subString.Trim();
            int position             = stringReader.position;
            List <IParserRule> rules = m_rules;
            int count = rules.Count;

            for (int i = 0; i < count; i++)
            {
                StringReader input2 = new StringReader(input.text);
                input2.position = subString.startIndex;
                input2.SetLimit(subString.endIndex);
                if (rules[i].TryFormat(ref input2, output, formatterParams))
                {
                    input.position = position;
                    return(true);
                }
            }
            return(false);
        }
示例#4
0
        private void AppendFormat(ref StringReader reader, StringBuilder writer, FormatterParams formatterParams)
        {
            IParserRule[] parserRules = m_parserRules;
            int           num         = m_parserRules.Length;

            while (reader.hasNext)
            {
                bool flag = false;
                for (int i = 0; i < num; i++)
                {
                    if (parserRules[i].TryFormat(ref reader, writer, formatterParams))
                    {
                        flag = true;
                        break;
                    }
                }
                IParserRule[] additionnalRules = formatterParams.additionnalRules;
                if (additionnalRules != null)
                {
                    for (int j = 0; j < additionnalRules.Length; j++)
                    {
                        if (additionnalRules[j].TryFormat(ref reader, writer, formatterParams))
                        {
                            flag = true;
                            break;
                        }
                    }
                }
                if (!flag)
                {
                    writer.Append(reader.ReadNext());
                }
            }
        }
示例#5
0
        public bool TryFormat(ref StringReader reader, StringBuilder output, FormatterParams formatterParams)
        {
            reader.SkipSpaces();
            SubString subString = reader.ReadWord();

            if (subString.length == 0)
            {
                return(false);
            }
            reader.SkipSpaces();
            if (reader.Read(','))
            {
                reader.SkipSpaces();
                if (reader.Read("select"))
                {
                    reader.SkipSpaces();
                    if (reader.Read(','))
                    {
                        string value = formatterParams.valueProvider.GetValue(subString.ToString());
                        FormatSelect(value, reader, output, formatterParams);
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#6
0
        public void AppendFormat(SubString text, StringBuilder output, FormatterParams formatterParams)
        {
            StringReader reader = new StringReader(text.originalText);

            reader.position = text.startIndex;
            reader.SetLimit(text.endIndex);
            AppendFormat(ref reader, output, formatterParams);
        }
 public bool TryFormat(ref StringReader input, StringBuilder output, FormatterParams parameters)
 {
     if (ReadBreakLine(ref input))
     {
         output.AppendLine();
         return(true);
     }
     return(false);
 }
 private static void Append(SubString text, StringBuilder output, FormatterParams formatterParams, string value)
 {
     text.Trim();
     formatterParams.additionnalRules = new IParserRule[1]
     {
         new ReplaceNumber(value)
     };
     formatterParams.formatter.AppendFormat(text, output, formatterParams);
 }
        private static void Format(StringReader reader, StringBuilder output, FormatterParams formatterParams)
        {
            SubString subString = reader.ReadWord();

            reader.SkipSpaces();
            string    value;
            SubString text = RuntimeData.TryGetText(subString.ToString(), out value) ? ((SubString)value) : subString;

            formatterParams.formatter.AppendFormat(text, output, formatterParams);
        }
示例#10
0
 public bool TryFormat(ref StringReader input, StringBuilder output, FormatterParams parameters)
 {
     if (input.remaining >= 2 && input.NextEquals("\\_"))
     {
         output.Append('\u00a0');
         input.position += 2;
         return(true);
     }
     return(false);
 }
 public bool TryFormat(ref StringReader reader, StringBuilder output, FormatterParams formatterParams)
 {
     if (reader.current == '%')
     {
         reader.position++;
         Format(reader, output, formatterParams);
         return(true);
     }
     return(false);
 }
示例#12
0
 public bool TryFormat(ref StringReader input, StringBuilder output, FormatterParams formatterParams)
 {
     if (input.current == '#')
     {
         output.Append(value);
         input.position++;
         return true;
     }
     return false;
 }
示例#13
0
 public bool TryFormat(ref StringReader input, StringBuilder output, FormatterParams parameters)
 {
     if (input.remaining >= 2 && input.NextEquals("\\v"))
     {
         output.AppendLine();
         input.position += 2;
         input.SkipSpaces();
         return(true);
     }
     return(false);
 }
示例#14
0
        public string Format(string pattern, FormatterParams formatterParams)
        {
            StringBuilder stringBuilder = GetStringBuilder();
            StringReader  reader        = new StringReader(pattern);

            AppendFormat(ref reader, stringBuilder, formatterParams);
            string result = stringBuilder.ToString();

            ReleaseStringBuilder(stringBuilder);
            return(result);
        }
 public bool TryFormat(ref StringReader reader, StringBuilder output, FormatterParams formatterParams)
 {
     if (reader.Read("value") && reader.ReadNext() == ':')
     {
         string name  = reader.ReadWord().ToString();
         string value = formatterParams.valueProvider.GetValue(name);
         output.Append(value);
         return(true);
     }
     return(false);
 }
 public bool TryFormat(ref StringReader reader, StringBuilder output, FormatterParams formatterParams)
 {
     if (reader.Read(m_text) && reader.Read(':'))
     {
         int id = reader.ReadInt();
         output.BeginKeyWord();
         output.Append(GetText(m_type, id));
         output.EndKeyWord();
         return(true);
     }
     return(false);
 }
示例#17
0
        private static void Format(StringReader reader, StringBuilder output, FormatterParams formatterParams)
        {
            SubString subString = reader.ReadWord();

            reader.SkipSpaces();
            string    value;
            SubString text = (reader.current == '[') ? reader.ReadContent('[', ']') : (RuntimeData.TryGetText($"KEYWORD.{subString}.NAME", out value) ? ((SubString)value) : subString);

            output.BeginKeyWord();
            formatterParams.formatter.AppendFormat(text, output, formatterParams);
            output.EndKeyWord();
        }
 public bool TryFormat(ref StringReader input, StringBuilder output, FormatterParams parameters)
 {
     if (input.remaining >= 2 && input.current == '\\')
     {
         char next = input.next;
         if (next == '{' || next == '}')
         {
             output.Append(next);
             input.position += 2;
             return(true);
         }
     }
     return(false);
 }
示例#19
0
 public bool TryFormat(ref StringReader reader, StringBuilder output, FormatterParams formatterParams)
 {
     if (reader.Read(text) && reader.Read(':'))
     {
         if (!m_initialized)
         {
             ReloadRawText();
         }
         string varName = reader.ReadWord().ToString();
         FormatValue(varName, output, formatterParams);
         return(true);
     }
     return(false);
 }
        public bool TryFormat(ref StringReader input, StringBuilder output, FormatterParams formatterParams)
        {
            SubString tagAttributes = new SubString(input.text, input.position, 0);
            SubString content       = new SubString(input.text, input.position, 0);

            if (!input.ReadTag("if", ref tagAttributes, ref content))
            {
                return(false);
            }
            if (GetCondition(tagAttributes).IsValidFor(formatterParams.context))
            {
                formatterParams.formatter.AppendFormat(content, output, formatterParams);
            }
            return(true);
        }
示例#21
0
        public bool TryFormat(ref StringReader input, StringBuilder output, FormatterParams formatterParams)
        {
            if (!MatchGroup(input))
            {
                return(false);
            }
            List <IParserRule> rules = m_rules;
            int count = rules.Count;

            for (int i = 0; i < count; i++)
            {
                if (rules[i].TryFormat(ref input, output, formatterParams))
                {
                    return(true);
                }
            }
            return(false);
        }
示例#22
0
        public bool TryFormat(ref StringReader reader, StringBuilder output, FormatterParams formatterParams)
        {
            reader.SkipSpaces();
            SubString subString = reader.ReadWord();

            if (subString.length == 0)
            {
                return(false);
            }
            reader.SkipSpaces();
            if (reader.hasNext)
            {
                return(false);
            }
            string value = formatterParams.valueProvider.GetValue(subString.ToString());

            output.Append(value);
            return(true);
        }
示例#23
0
        private void FormatValue(string varName, StringBuilder output, FormatterParams formatterParams)
        {
            IFightValueProvider fightValueProvider = formatterParams.valueProvider as IFightValueProvider;

            if (fightValueProvider != null && getModificationValue != null)
            {
                int num = getModificationValue(fightValueProvider);
                if (num != 0)
                {
                    int num2 = fightValueProvider.GetValueInt(varName) + num;
                    output.Append((num > 0) ? "<color=#008c00ff>" : "<color=#d90000ff>");
                    formatterParams.valueProvider = new IndexedValueProvider(num2.ToString());
                    formatterParams.formatter.AppendFormat(rawText, output, formatterParams);
                    output.Append("</color>");
                    return;
                }
            }
            string value = formatterParams.valueProvider.GetValue(varName);

            formatterParams.valueProvider = new IndexedValueProvider(value);
            formatterParams.formatter.AppendFormat(rawText, output, formatterParams);
        }
示例#24
0
        private void FormatSelect(string value, StringReader reader, StringBuilder output, FormatterParams formatterParams)
        {
            bool      num;
            SubString text;

            do
            {
                if (reader.hasNext)
                {
                    reader.SkipSpaces();
                    num  = reader.Read(value);
                    text = reader.ReadContent('[', ']');
                    continue;
                }
                return;
            }while (!num);
            text.Trim();
            formatterParams.formatter.AppendFormat(text, output, formatterParams);
        }
示例#25
0
 private void FormatSelect(string value, StringReader reader, StringBuilder output, FormatterParams formatterParams)
 {
     if (string.IsNullOrEmpty(value))
     {
         return;
     }
     PluralCategory pluralForOrdinal = formatterParams.formatter.pluralRules.GetPluralForOrdinal(int.Parse(value));
     int position = reader.position;
     while (reader.hasNext)
     {
         reader.SkipSpaces();
         bool num = reader.Read(PluralFormStrings[(int)pluralForOrdinal]);
         if (!num)
         {
             reader.ReadUntil('[');
         }
         SubString text = reader.ReadContent('[', ']');
         if (num)
         {
             Append(text, output, formatterParams, value);
             return;
         }
     }
     reader.position = position;
     while (reader.hasNext)
     {
         reader.SkipSpaces();
         bool num2 = reader.Read("other");
         if (!num2)
         {
             reader.ReadUntil('[');
         }
         SubString text2 = reader.ReadContent('[', ']');
         if (num2)
         {
             Append(text2, output, formatterParams, value);
             return;
         }
     }
     throw new TextFormatterException(reader.text, reader.position, "'other' content is not defined");
 }