Beispiel #1
0
    private List <DialogRichWord> preHandleWords(string input)
    {
        int idx = 0;
        List <DialogRichWord> sout = new List <DialogRichWord> ();
        float  size  = NORMAL_SIZE;
        string color = NORMAL_COLOR;

        while (idx < input.Length)
        {
            if (input [idx] == '#')
            {
                int j = idx + 1;
                while (j < input.Length && isDigitOrLetter(input [j]))
                {
                    j++;
                }
                string opt = input.Substring(idx, j - idx);
                if (opt.StartsWith("#c="))
                {
                    color = opt.Substring(3);
                }
                else if (opt.Equals("#c"))
                {
                    color = NORMAL_COLOR;
                }
                else if (opt.Equals("#size=big"))
                {
                    size = 60;
                }
                else if (opt.Equals("#size"))
                {
                    size = NORMAL_SIZE;
                }
                idx = j;
            }
            else
            {
                DialogRichWord w = new DialogRichWord();
                w.color   = color;
                w.size    = size;
                w.content = input [idx] + "";
                sout.Add(w);
                idx++;
            }
        }
        return(sout);
    }
Beispiel #2
0
 void textAppend(DialogRichWord word)
 {
     if (word.color != DialogModule.NORMAL_COLOR)
     {
         view.dialogContent.text += "<color=" + word.color + ">";
     }
     if (word.size != DialogModule.NORMAL_SIZE)
     {
         view.dialogContent.text += "<size=" + word.size + ">";
     }
     view.dialogContent.text += word.content + "";
     if (word.size != DialogModule.NORMAL_SIZE)
     {
         view.dialogContent.text += "</size>";
     }
     if (word.color != DialogModule.NORMAL_COLOR)
     {
         view.dialogContent.text += "</color>";
     }
 }