Beispiel #1
0
    public static string CorrectString(Text text, string baseStr, string endStr)
    {
        GameObject gameObject = (GameObject)Object.Instantiate <GameObject>((M0)((Component)text).get_gameObject(), (Transform)null, false);
        Text       component  = (Text)gameObject.GetComponent <Text>();
        float      spaceWidth = TextCorrectLimit.GetSpaceWidth(component);
        int        length1    = endStr.Length;
        float      num1       = 0.0f;

        for (int startIndex = 0; startIndex < length1; ++startIndex)
        {
            num1 += endStr[startIndex] != ' ' ? TextCorrectLimit.GetTextWidth(component, endStr.Substring(startIndex, 1)) : spaceWidth;
        }
        Rect  rect    = ((Graphic)text).get_rectTransform().get_rect();
        float num2    = ((Rect) ref rect).get_width() - num1;
        int   length2 = baseStr.Length;
        int   length3 = 0;
        float num3    = 0.0f;

        for (int startIndex = 0; startIndex < length2; ++startIndex)
        {
            num3 += baseStr[startIndex] != ' ' ? TextCorrectLimit.GetTextWidth(component, baseStr.Substring(startIndex, 1)) : spaceWidth;
            if ((double)num3 < (double)num2)
            {
                ++length3;
            }
            else
            {
                break;
            }
        }
        Object.Destroy((Object)gameObject);
        return(baseStr.Substring(0, length3) + (length3 != length2 ? endStr : string.Empty));
    }
 public void CalculateUI()
 {
     for (int index = 0; index < 20; ++index)
     {
         ListInfoBase listInfo = this.chaCtrl.lstCtrl.GetListInfo((ChaListDefine.CategoryNo) this.nowAcs.parts[index].type, this.nowAcs.parts[index].id);
         if (listInfo == null)
         {
             this.textDst[index].set_text("なし");
             this.textSrc[index].set_text("なし");
         }
         else
         {
             TextCorrectLimit.Correct(this.textDst[index], listInfo.Name, "…");
             this.textSrc[index].set_text(this.textDst[index].get_text());
         }
     }
 }
Beispiel #3
0
        public void Init()
        {
            List <NetSelectHNScrollController.ScrollData> source = new List <NetSelectHNScrollController.ScrollData>();

            foreach (KeyValuePair <int, NetworkInfo.UserInfo> keyValuePair in this.netInfo.dictUserInfo)
            {
                KeyValuePair <int, NetworkInfo.UserInfo> n = keyValuePair;
                int num = this.netInfo.lstCharaInfo.Where <NetworkInfo.CharaInfo>((Func <NetworkInfo.CharaInfo, bool>)(x => x.user_idx == n.Key)).ToArray <NetworkInfo.CharaInfo>().Length + this.netInfo.lstHousingInfo.Where <NetworkInfo.HousingInfo>((Func <NetworkInfo.HousingInfo, bool>)(x => x.user_idx == n.Key)).ToArray <NetworkInfo.HousingInfo>().Length;
                if (num != 0)
                {
                    source.Add(new NetSelectHNScrollController.ScrollData()
                    {
                        info =
                        {
                            userIdx    = n.Key,
                            drawname   = TextCorrectLimit.CorrectString(this.text, string.Format("({0}) {1}", (object)num, (object)n.Value.handleName), "…"),
                            handlename = n.Value.handleName
                        }
                    });
                }
            }
            using (new GameSystem.CultureScope())
                source = source.OrderBy <NetSelectHNScrollController.ScrollData, string>((Func <NetSelectHNScrollController.ScrollData, string>)(n => n.info.handlename)).ToList <NetSelectHNScrollController.ScrollData>();
            this.scrollerDatas = source.ToArray();
            int num1 = !((IList <NetSelectHNScrollController.ScrollData>) this.scrollerDatas).IsNullOrEmpty <NetSelectHNScrollController.ScrollData>() ? this.scrollerDatas.Length / this.countPerRow : 0;

            if (!((IList <NetSelectHNScrollController.ScrollData>) this.scrollerDatas).IsNullOrEmpty <NetSelectHNScrollController.ScrollData>() && this.scrollerDatas.Length % this.countPerRow > 0)
            {
                ++num1;
            }
            if (!this.view.IsInit)
            {
                this.view.InitListView(num1, new Func <LoopListView2, int, LoopListViewItem2>(this.OnUpdate), (LoopListViewInitParam)null);
            }
            else
            {
                if (this.view.SetListItemCount(num1, true))
                {
                    return;
                }
                this.view.RefreshAllShownItem();
            }
        }
Beispiel #4
0
 private static float GetSpaceWidth(Text textComp)
 {
     return(TextCorrectLimit.GetTextWidth(textComp, "m m") - TextCorrectLimit.GetTextWidth(textComp, "mm"));
 }
Beispiel #5
0
 public static void Correct(Text text, string baseStr, string endStr)
 {
     text.set_text(TextCorrectLimit.CorrectString(text, baseStr, endStr));
 }