Пример #1
0
 protected static void GetTimes(int t, Rect r, Vector2 p, float rst, float w, SStyles ss, bool more = false)
 {
     Rect rn = r;
     if (t == 1)
         rn.x += rst;
     rn.y += p.y + (p.y - 6) * (t - 1) + lastRect.height - (ss == SStyles.Underline ? 5 : 13);
     rn.width = w;
     rn.height = 2; //Thickness of the line
     GUI.DrawTexture(rn, Texture2D.whiteTexture);
 }
Пример #2
0
 //I have to try to combine this two functions from below
 internal Dictionary<int, FText> GetComputedFormat(string s)
 {
     unformatted = RemoveUndesiredTags(s);
     Dictionary <int, FText> lcal = new Dictionary<int, FText>();
     int i = 0,
         skipPos = -1,
         lPos = -1;
     SStyles lastStyle = SStyles.None;
     StringBuilder sb = new StringBuilder(unformatted);
     bool active = false;
     //I need to get where are the <u> and <s>
     for (; i < s.Length; ++i)
     {
         if (i == skipPos)
             continue;
         if (s[i] == '§' || s[i] == '&')
         {
             int rpos = s[i] == '§' ? sb.ToString().IndexOf('§') : sb.ToString().IndexOf('&');
             skipPos = i + 1;
             if (s[skipPos] == 'm' || s[skipPos] == 'n' || s[skipPos] == 'k')
             {
                 active = true;
                 sb.Remove(rpos, 2); //I have to make something to mix the styles inside
                 lastStyle = GetStyle(s[i + 1]);
                 if (lPos == -1)
                 {
                     lPos = rpos;
                     continue;
                 }
                 lcal.Add(rpos, new FText(rpos - lPos, lastStyle));
                 lPos = rpos;
             }
         }
         if (GetNewTag(sb.ToString(), i))
             active = false;
     }
     if (active)
         lcal.Add(lPos, new FText(GetEnd(sb.ToString(), lPos), lastStyle));
     //foreach (KeyValuePair<int, FText> t in lcal)
     //    UnityEngine.Debug.LogFormat("{0} {1}", t.Key, t.Value.ToString());
     message = Regex.Replace(s, "(&|§)(n|m|k)", "");
     return lcal;
 }
Пример #3
0
 public FText(int l, SStyles ss)
 {
     len = l;
     style = ss;
 }
Пример #4
0
 protected static void GetUnderline(Rect r, Vector2 p, int rpos, string os, string s, SStyles ss)
 { //I have to fix this
     float mm = (new GUIStyle(_text) { wordWrap = false }).CalcSize(new GUIContent(os)).x / os.Length; //Get the average that letters measures in px
     int letters = Mathf.FloorToInt((me.width - 5) / (mm + 2)); //Get how many letter occupies one paragraph
     float w = s.Length * mm, //Get the underlined string length in px
           wn = (letters - rpos % letters) * mm, //Get the left space that is after the first paragraph
           factor = (((me.width - 5) - wn) / rpos), //Get in another way, another more accurately letter-width
           rst = (rpos % letters) * factor, //Get how many space we have to displace to the right
           rw = letters * factor; //Another accurately way of getting the paragraph width
     int times = (int)Math.Ceiling(w / me.width); //Get how many paragrpahs has to be underlined
     if (times == 1) //If there is only one paragraph, only get the margin-left and the width calculated getting the letters that remain on a paragraph
         GetTimes(1, r, p, rst, w, ss);
     else if (times == 2) //If there is 2 paragraph, do the same for the first and for the second calculate the remaining space we have calculated before
         for (int k = 0; k < times; ++k)
             GetTimes(k + 1, r, p, rst, k == 0 ? wn : w - wn, ss);
     else if (times > 2) //If there is 3 paragraphs, calculate the space in the middle that is always the full chat
         for (int j = 0; j < times; ++j)
             GetTimes(j + 1, r, p, rst, j == 0 ? wn : (j < times - 1 ? rw : w - wn), ss);
 }