Esempio n. 1
0
 //フォントの文字画像の設定を試行
 bool TryeSetFontCharcters(Font font, List <UguiNovelTextCharacter> characterDataList)
 {
     foreach (UguiNovelTextCharacter character in characterDataList)
     {
         if (!character.TrySetCharacterInfo(font))
         {
             return(false);
         }
     }
     return(Addtional.TrySetFontCharcters(font));
 }
Esempio n. 2
0
        //各頂点データを構築
        void MakeVerts(List <UguiNovelTextLine> lineList)
        {
            Color color = NovelText.color;

            foreach (UguiNovelTextLine line in lineList)
            {
                foreach (UguiNovelTextCharacter character in line.Characters)
                {
                    character.MakeVerts(color, this);
                }
            }
            Addtional.MakeVerts(color, this);
        }
        //頂点情報を作成
        void Refresh()
        {
            if (isRequestingCharactersInTexture)
            {
                if (isDebugLog)
                {
                    Debug.LogError("RequestingCharactersInTexture on Reflesh");
                }
                return;
            }

            //TextData作成
            textData = new TextData(NovelText.text);
            if (isDebugLog)
            {
                Debug.Log(textData.ParsedText.OriginalText);
            }

            //描画範囲のサイズを設定しておく
            Rect rect = CachedRectTransform.rect;

            maxWidth  = Mathf.Abs(rect.width);
            maxHeight = Mathf.Abs(rect.height);

            //文字データを作成
            List <UguiNovelTextCharacter> characterDataList = CreateCharacterDataList();

            //拡張的な情報を作成
            addtional = new UguiNovelTextGeneratorAddtional(characterDataList, this);
            //フォントの文字画像を準備・設定
            InitFontCharactes(NovelText.font, characterDataList);
            //拡張的な情報の初期化
            Addtional.InitAfterCharacterInfo(this);
            //独自の改行処理を入れる
            AutoLineBreak(characterDataList);
            //行ごとの文字データを作成
            lineDataList = CreateLineList(characterDataList);
            //テキストのアンカーを適用する
            ApplyTextAnchor(lineDataList, NovelText.alignment);
            //Offsetを適用する
            ApplyOffset(lineDataList);
            //拡張的な情報の表示位置を初期化
            Addtional.InitPosition(this);
            //各頂点データを構築
            MakeVerts(lineDataList);

            isInitGraphicObjectList = false;
            HasChangedLitte         = false;
            HasChanged   = false;
            IsRebuidFont = false;
        }
Esempio n. 4
0
        //フォントの文字画像の作成のための情報を作成
        List <RequestCharactersInfo> MakeRequestCharactersInfoList(List <UguiNovelTextCharacter> characterDataList)
        {
            List <RequestCharactersInfo> infoList = new List <RequestCharactersInfo>();

            foreach (UguiNovelTextCharacter characterData in characterDataList)
            {
                AddToRequestCharactersInfoList(characterData, infoList);
            }
            List <UguiNovelTextCharacter> addtionalCharacterList = Addtional.MakeCharacterList();

            foreach (UguiNovelTextCharacter characterData in addtionalCharacterList)
            {
                AddToRequestCharactersInfoList(characterData, infoList);
            }
            return(infoList);
        }
Esempio n. 5
0
        //描画用頂点データリストを作成
        List <UIVertex> CreateVertexList(List <UguiNovelTextLine> lineList, int max)
        {
            List <UIVertex> verts = new List <UIVertex>();

            if (lineList == null || (max <= 0 && lineList.Count <= 0))
            {
                return(verts);
            }

            int count = 0;
            UguiNovelTextCharacter lastCaracter = null;

            foreach (UguiNovelTextLine line in lineList)
            {
                if (line.IsOver)
                {
                    break;
                }

                for (int i = 0; i < line.Characters.Count; ++i)
                {
                    UguiNovelTextCharacter character = line.Characters[i];
                    character.IsVisible = (count < max);
                    ++count;
                    if (character.IsBr)
                    {
                        continue;
                    }
                    if (character.IsVisible)
                    {
                        lastCaracter = character;
                        if (!character.IsNoFontData)
                        {
                            verts.AddRange(character.Verts);
                        }
                        endPosition = new Vector3(lastCaracter.EndPositionX, line.Y0, 0);
                    }
                }
            }

            Addtional.AddVerts(verts, endPosition, this);
            return(verts);
        }
Esempio n. 6
0
 static int Addtional(Addtional aa, int leftNumber, int rightNumber)
 {
     return(aa(leftNumber, rightNumber));
 }
Esempio n. 7
0
        //自動改行処理を行う
        void AutoLineBreak(List <UguiNovelTextCharacter> characterDataList)
        {
            float indentSize = 0;
            int   index      = 0;

            //infoListがテキストの文字数ぶんになるまでループ
            while (index < characterDataList.Count)
            {
                //行の開始インデックス
                int   beginIndex         = index;
                float currentLetterSpace = 0;   //文字間のサイズ
                float x = 0;                    //現在のX位置
                //一行ぶん(改行までの)の処理をループ内で処理
                while (index < characterDataList.Count)
                {
                    UguiNovelTextCharacter currentData = characterDataList[index];
                    bool isAutoLineBreak = false;                       //自動改行をするか

                    //行の先頭で、先頭の文字スペースが必要場合があるので加算する
                    if (x == 0)
                    {
                        currentLetterSpace = Addtional.GetTopLetterSpace(currentData, this);
                        x += indentSize;
                        if (index == 0 && IsAutoIndentation(currentData.Char))
                        {
                            indentSize = currentData.Width + LetterSpaceSize;
                        }
                    }

                    //文字間の適用
                    if (currentData.CustomInfo.IsRuby)
                    {
                        currentLetterSpace += currentData.RubySpaceSize;
                    }
                    x += currentLetterSpace;

                    if (currentData.IsBlank)
                    {
                        //改行文字かスペース
                    }
                    else
                    {
                        //横幅を越えるなら自動改行
                        isAutoLineBreak = IsOverMaxWidth(x, Addtional.GetMaxWidth(currentData));
                        if (isAutoLineBreak)
                        {
                            //自動改行処理
                            //改行すべき文字の位置まで戻る
                            index       = GetAutoLineBreakIndex(characterDataList, beginIndex, index);
                            currentData = characterDataList[index];
                            currentData.isAutoLineBreak = true;
                        }
                    }
                    //1文字進める
                    ++index;
                    //改行処理
                    if (currentData.IsBrOrAutoBr)
                    {
                        //改行なので行処理のループ終了
                        break;
                    }
                    else
                    {
                        currentData.InitPositionX(x, currentLetterSpace);
                        //X位置を進める
                        x += currentData.Width;
                        if (currentData.RubySpaceSize != 0)
                        {
                            currentLetterSpace = currentData.RubySpaceSize;
                        }
                        else
                        {
                            currentLetterSpace = LetterSpaceSize;

                            //文字間を無視する場合のチェック
                            if (TextSettings)
                            {
                                if (index < characterDataList.Count)
                                {
                                    if (TextSettings.IsIgonreLetterSpace(currentData, characterDataList[index]))
                                    {
                                        currentLetterSpace = 0;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }