//改行などで別の行に線を引く必要があるばあい、その線を作成
		internal List<UguiNovelTextGeneratorAddtionalLine> MakeOtherLineInTextLineSub(UguiNovelTextGenerator generator)
		{
			List<UguiNovelTextGeneratorAddtionalLine> newLineList = new List<UguiNovelTextGeneratorAddtionalLine>();

			int endIndex = stringData.Count - 1;
			foreach (UguiNovelTextLine line in generator.LineDataList)
			{
				if ( textLine == line ) continue;

				bool isFind = false;
				int index = 0;
				int count = 0;
				for (int i = 0; i < stringData.Count; ++i )
				{
					//他の行に文字がある
					if (line.Characters.IndexOf(stringData[i]) >= 0)
					{
						if (!isFind)
						{
							index = i;
							endIndex = Mathf.Min(i, endIndex);
							isFind = true;
						}
						++count;
					}
				}
				if (isFind)
				{
					UguiNovelTextGeneratorAddtionalLine newLine = new UguiNovelTextGeneratorAddtionalLine(this, index, count,generator);
					newLineList.Add(newLine);
					newLine.InitTextLine(generator);
					if (!newLine.characteData.TrySetCharacterInfo(generator.NovelText.font))
					{
						Debug.LogError("Line Font Missing");
					}
				}
			}
			if(endIndex<stringData.Count-1)
			{
				stringData.RemoveRange(endIndex, stringData.Count-endIndex);
			}
			return newLineList;
		}
		//描画頂点作成
		public void MakeVerts(Color defaultColor, UguiNovelTextGenerator generator )
		{
			if (IsNoFontData) return;

			verts = new UIVertex[4];
			Color color = charData.CustomInfo.GetCustomedColor(defaultColor);
			for (int i = 0; i < 4; ++i)
			{
				verts[i] = UIVertex.simpleVert;
				verts[i].color = color;
			}

			WrapperUnityVersion.SetCharacterInfoToVertex(verts, this, generator.NovelText.font );

			//上付き文字の処理
			if (CustomInfo.IsSuperScript)
			{
				float offset = (1.0f - generator.SupOrSubSizeScale) * this.DefaultFontSize;
				for (int i = 0; i < 4; ++i)
				{
					verts[i].position.y += offset;
				}
			}

			//ダッシュの場合
			if (CustomInfo.IsDash)
			{
				//中央の位置に表示
				float h = Mathf.Abs(verts[2].position.y - verts[0].position.y);
				float y0 = PositionY + this.FontSize/2;
				verts[0].position.y = verts[1].position.y = y0 - h / 2;
				verts[2].position.y = verts[3].position.y = y0 + h / 2;

				//横に伸ばす処理を入れる
				//Slice処理のために頂点増やす
				UIVertex[] sliceVerts = new UIVertex[12];
				for( int i = 0;i < 12; ++i)
				{
					sliceVerts[i] = verts[i % 4];
				}
				float x0 = verts[0].position.x;
				float w0 = verts[1].position.x - verts[0].position.x;

				float x3 = x0 + Width;
				float x1 = x0 + w0 / 3;
				float x2 = x3 - w0 / 3;
				SetVertexX(sliceVerts, 0, x0, x1);
				SetVertexX(sliceVerts, 4, x1, x2);
				SetVertexX(sliceVerts, 8, x2, x3);
				
				//UV座標はFilpされてる可能性があるので注意
				Vector2 uvBottomLeft, uvBottomRight, uvTopRight, uvTopLeft;
				Vector2 uvBottomLeft2, uvBottomRight2, uvTopRight2, uvTopLeft2;

				uvBottomLeft = verts[0].uv0;
				uvBottomRight = verts[1].uv0;
				uvTopRight = verts[2].uv0;
				uvTopLeft = verts[3].uv0;

				uvBottomLeft2 = (uvBottomRight - uvBottomLeft) * 1 / 3 + uvBottomLeft;
				uvBottomRight2 = (uvBottomRight - uvBottomLeft) * 2 / 3 + uvBottomLeft;
				uvTopRight2 = (uvTopRight - uvTopLeft) * 2 / 3 + uvTopLeft;
				uvTopLeft2 = (uvTopRight - uvTopLeft) * 1 / 3 + uvTopLeft;

				SetVertexUV(sliceVerts, 0, uvBottomLeft, uvBottomLeft2, uvTopLeft2, uvTopLeft);
				SetVertexUV(sliceVerts, 4, uvBottomLeft2, uvBottomRight2, uvTopRight2, uvTopLeft2);
				SetVertexUV(sliceVerts, 8, uvBottomRight2, uvBottomRight, uvTopRight, uvTopRight2);

				verts = sliceVerts;
			}
		}
		//位置情報の初期化
		internal void InitPosition(UguiNovelTextGenerator generator)
		{
			//文字からの表示位置のオフセット
			Vector2 offset = Vector2.zero;

			float height = textLine.MaxFontSize;

			//高さを合わせる
			switch( LineType )
			{
				case Type.UnderLine:
					offset.y -= height / 2;
					break;
				case Type.Strike:
					break;
			}

			CharacteData.PositionX = TopCharaceter.PositionX + offset.x;
			CharacteData.PositionY = TopCharaceter.PositionY + offset.y;
		}
		//改行などで別の行に線を引く必要があるばあい、その線を作成
		internal List<UguiNovelTextGeneratorAddtionalLine> MakeOtherLineInTextLine(UguiNovelTextGenerator generator)
		{
			InitTextLine(generator);
			return MakeOtherLineInTextLineSub(generator);
		}
		//文字情報を取得した後の初期化
		internal void InitAfterCharacterInfo(UguiNovelTextGenerator generator)
		{
			//ルビの幅を初期化
			float w = 0;
			foreach (UguiNovelTextCharacter ruby in rubyList)
			{
				w += ruby.Width;
			}
			this.rubyWidth = w;

			//ルビをつける文字列の幅を初期化
			w = 0;
			foreach (UguiNovelTextCharacter charcter in stringData)
			{
				w += charcter.Width + generator.LetterSpaceSize;
			}
			this.stringWidth = w;

			//ルビの幅が本文の幅よりも長いなら
			//ルビの幅にあわせて本文をスペースをあけて表示する
			if (IsWideType)
			{
				float diff = RubyWidth - (StringWidth - (stringData.Count * generator.LetterSpaceSize));
				float space = diff / stringData.Count / 2;
				foreach (UguiNovelTextCharacter charcter in stringData)
				{
					charcter.RubySpaceSize = space;
				}
			}
		}
		//禁則のチェック
		internal bool CheckWordWrap( UguiNovelTextGenerator generator, UguiNovelTextCharacter current, UguiNovelTextCharacter prev)
		{
			//文字間無視文字は改行できない
			if (IsIgonreLetterSpace(prev, current))
			{
				return true;
			}

			//英文文字のWordWrap
			if ((generator.WordWrapType & UguiNovelTextGenerator.WordWrap.Default) == UguiNovelTextGenerator.WordWrap.Default)
			{
				if (CheckWordWrapDefaultEnd(prev) && CheckWordWrapDefaultTop(current))
				{
					return true;
				}
			}

			//日本語のWordWrap
			if ((generator.WordWrapType & UguiNovelTextGenerator.WordWrap.JapaneseKinsoku) == UguiNovelTextGenerator.WordWrap.JapaneseKinsoku)
			{
				if ((CheckKinsokuEnd(prev) || CheckKinsokuTop(current)))
				{
					return true;
				}
			}

			return false;
		}
		//Y座標を設定
		public void SetLineY(float y, UguiNovelTextGenerator generator )
		{
			Y0 = y;			//描画するサイズと、フォントデータのサイズでY値のオフセットをとる
			foreach (UguiNovelTextCharacter character in characters)
			{
				character.PositionY = Y0;
			}
		}
		//自動改行などのために線を増やす必要がある場合
		UguiNovelTextGeneratorAddtionalLine(UguiNovelTextGeneratorAddtionalLine srcLine, int index, int count, UguiNovelTextGenerator generator)
		{
			InitSub(srcLine.type, generator);
			for (int i = 0; i < count; ++i)
			{
				stringData.Add(srcLine.stringData[index+i]);
			}
		}
		void InitSub(Type type, UguiNovelTextGenerator generator)
		{
			this.type = type;
			//ダッシュ('—')の文字を作成
			CharData.CustomCharaInfo custom = new CharData.CustomCharaInfo();
			custom.IsDash = true;
			custom.DashSize = 1;
			CharData data = new CharData(CharData.Dash, custom);
			characteData = new UguiNovelTextCharacter(data, generator);
		}
		internal UguiNovelTextGeneratorAddtionalLine( Type type, List<UguiNovelTextCharacter> characters, int index, UguiNovelTextGenerator generator)
		{
			InitSub(type,generator);
			stringData.Add(characters[index]);
			for (int i = index + 1; i < characters.Count; ++i)
			{
				UguiNovelTextCharacter c = characters[i];
				if (IsLineEnd(c)) break;
				stringData.Add(c);
			}
		}
		internal UguiNovelTextGeneratorAddtional(List<UguiNovelTextCharacter> characters, UguiNovelTextGenerator generataor )
		{
			for (int i = 0; i < characters.Count; ++i  )
			{
				UguiNovelTextCharacter character = characters[i];

				//線の作成
				if (character.CustomInfo.IsStrikeTop)
				{
					lineList.Add(new UguiNovelTextGeneratorAddtionalLine(UguiNovelTextGeneratorAddtionalLine.Type.Strike, characters, i, generataor));
				}
				if (character.CustomInfo.IsUnderLineTop)
				{
					lineList.Add(new UguiNovelTextGeneratorAddtionalLine(UguiNovelTextGeneratorAddtionalLine.Type.UnderLine, characters, i, generataor));
				}

				//ルビ情報の作成
				if (character.CustomInfo.IsRubyTop)
				{
					rubyList.Add(new UguiNovelTextGeneratorAddtionalRuby(characters, i, generataor.NovelText.font, generataor.RubySizeScale));
				}
			}		
		}
		public void EndCharaData( UguiNovelTextGenerator generator )
		{
			//幅と、最大フォントサイズなどを設定
			maxFontSize = 0;
			float left = 0;
			float right = 0;
			for (int i = 0; i < characters.Count; ++i)
			{
				UguiNovelTextCharacter character = characters[i];
				maxFontSize = Mathf.Max(maxFontSize, character.DefaultFontSize);
				if (i == 0)
				{
					left = character.PositionX - character.RubySpaceSize;
				}
				if( i== characters.Count-1)
				{
					right = character.PositionX + character.Width + character.RubySpaceSize;
				}
			}
			width = Mathf.Abs(right-left);
			//uGUIは行間の基本値1=1.2の模様
			totalHeight = Mathf.CeilToInt(MaxFontSize * (generator.NovelText.lineSpacing+0.2f));
		}
Exemple #13
0
 //改行などで別の行に線を引く必要があるばあい、その線を作成
 internal List <UguiNovelTextGeneratorAdditionalLine> MakeOtherLineInTextLine(UguiNovelTextGenerator generator)
 {
     InitTextLine(generator);
     return(MakeOtherLineInTextLineSub(generator));
 }
Exemple #14
0
 internal UguiNovelTextGeneratorAdditionalLine(Type type, List <UguiNovelTextCharacter> characters, int index, UguiNovelTextGenerator generator)
 {
     this.stringData = new List <UguiNovelTextCharacter>();
     this.InitSub(type, generator);
     this.stringData.Add(characters[index]);
     for (int i = index + 1; i < characters.Count; i++)
     {
         UguiNovelTextCharacter c = characters[i];
         if (this.IsLineEnd(c))
         {
             break;
         }
         this.stringData.Add(c);
     }
 }
		//コンストラクタ
		public UguiNovelTextCharacter(CharData charData, UguiNovelTextGenerator generator )
		{
			Init(charData, generator.NovelText.font, generator.NovelText.fontSize, generator.NovelText.fontStyle, generator.Space );

			//上つき文字、下つき文字
			if (charData.CustomInfo.IsSuperOrSubScript)
			{
				this.fontSize = Mathf.FloorToInt(generator.SupOrSubSizeScale*this.fontSize);
			}

			//スペースの指定
			if (charData.CustomInfo.IsSpace)
			{
				width = charData.CustomInfo.SpaceSize;
			}

			//絵文字
			if (generator.EmojiData)
			{
				//スプライトを使うか
				if (CustomInfo.IsEmoji || generator.EmojiData.Contains(Char))
				{
					IsSprite = true;
				}

				//絵文字の制御
				if (IsSprite)
				{
					Sprite sprite = FindSpirte(generator);
					if (sprite)
					{
						float scale = sprite.rect.width / generator.EmojiData.Size;
						width = scale * fontSize;
					}
					else
					{
						Debug.LogError("Not found Emoji[" + Char + "]" + ":" + (int)Char);
					}
				}
			}
		}
Exemple #16
0
 private UguiNovelTextGeneratorAdditionalLine(UguiNovelTextGeneratorAdditionalLine srcLine, int index, int count, UguiNovelTextGenerator generator)
 {
     this.stringData = new List <UguiNovelTextCharacter>();
     this.InitSub(srcLine.type, generator);
     for (int i = 0; i < count; i++)
     {
         this.stringData.Add(srcLine.stringData[index + i]);
     }
 }
		//絵文字などのグラフィックオブジェクトを作成
		internal RectTransform AddGraphicObject(RectTransform parent, UguiNovelTextGenerator generator)
		{
			if (!IsSprite) return null;

			Sprite sprite = FindSpirte(generator);
			if (sprite)
			{
				RectTransform child = UtageToolKit.AddChildGameObjectComponent<RectTransform>(parent, sprite.name);
				child.gameObject.hideFlags = HideFlags.DontSave;
				Image image = child.gameObject.AddComponent<Image>();
				image.sprite = sprite;

				float scaleX, scaleY = 1.0f;
				scaleX = scaleY = 1.0f * FontSize / generator.EmojiData.Size;
				float w = sprite.rect.width * scaleX;
				float h = sprite.rect.height * scaleY;
				child.sizeDelta = new Vector2(w, h);
				child.localPosition = new Vector3(PositionX + w / 2, PositionY + h / 2, 0);
				return child;
			}
			else
			{
				return null;
			}
		}
        internal UguiNovelTextGeneratorAddtional(List <UguiNovelTextCharacter> characters, UguiNovelTextGenerator generataor)
        {
            for (int i = 0; i < characters.Count; ++i)
            {
                UguiNovelTextCharacter character = characters[i];

                //線の作成
                if (character.CustomInfo.IsStrikeTop)
                {
                    lineList.Add(new UguiNovelTextGeneratorAddtionalLine(UguiNovelTextGeneratorAddtionalLine.Type.Strike, characters, i, generataor));
                }
                if (character.CustomInfo.IsUnderLineTop)
                {
                    lineList.Add(new UguiNovelTextGeneratorAddtionalLine(UguiNovelTextGeneratorAddtionalLine.Type.UnderLine, characters, i, generataor));
                }

                //ルビ情報の作成
                if (character.CustomInfo.IsRubyTop)
                {
                    rubyList.Add(new UguiNovelTextGeneratorAddtionalRuby(characters, i, generataor));
                }
            }
        }
Exemple #19
0
        //改行などで別の行に線を引く必要があるばあい、その線を作成
        internal List <UguiNovelTextGeneratorAddtionalLine> MakeOtherLineInTextLineSub(UguiNovelTextGenerator generator)
        {
            List <UguiNovelTextGeneratorAddtionalLine> newLineList = new List <UguiNovelTextGeneratorAddtionalLine>();

            int endIndex = stringData.Count - 1;

            foreach (UguiNovelTextLine line in generator.LineDataList)
            {
                if (textLine == line)
                {
                    continue;
                }

                bool isFind = false;
                int  index  = 0;
                int  count  = 0;
                for (int i = 0; i < stringData.Count; ++i)
                {
                    //他の行に文字がある
                    if (line.Characters.IndexOf(stringData[i]) >= 0)
                    {
                        if (!isFind)
                        {
                            index    = i;
                            endIndex = Mathf.Min(i, endIndex);
                            isFind   = true;
                        }
                        ++count;
                    }
                }
                if (isFind)
                {
                    UguiNovelTextGeneratorAddtionalLine newLine = new UguiNovelTextGeneratorAddtionalLine(this, index, count, generator);
                    newLineList.Add(newLine);
                    newLine.InitTextLine(generator);
                    if (!newLine.characteData.TrySetCharacterInfo(generator.NovelText.font))
                    {
                        Debug.LogError("Line Font Missing");
                    }
                }
            }
            if (endIndex < stringData.Count - 1)
            {
                stringData.RemoveRange(endIndex, stringData.Count - endIndex);
            }
            return(newLineList);
        }
        //描画頂点作成
        public void MakeVerts(Color defaultColor, UguiNovelTextGenerator generator)
        {
            if (IsNoFontData)
            {
                return;
            }

            UnityEngine.Profiling.Profiler.BeginSample("MakeVerts!");
            if (verts == null)
            {
                verts = new UIVertex[4];
                for (int i = 0; i < 4; ++i)
                {
                    verts[i] = UIVertex.simpleVert;
                }
            }

            UnityEngine.Profiling.Profiler.BeginSample("GetCustomedColor");
            Color color = charData.CustomInfo.GetCustomedColor(defaultColor);

            color *= effectColor;
            for (int i = 0; i < verts.Length; ++i)
            {
                verts[i].color = color;
            }
            UnityEngine.Profiling.Profiler.EndSample();

            UnityEngine.Profiling.Profiler.BeginSample("SetCharacterInfoToVertex");
            WrapperUnityVersion.SetCharacterInfoToVertex(verts, this, ref this.charInfo, generator.NovelText.font);
            if (!generator.NovelText.font.dynamic && !generator.IsUnicodeFont)
            {
                float offset = this.fontSize;
                for (int i = 0; i < 4; ++i)
                {
                    verts[i].position.y += offset;
                }
            }
            UnityEngine.Profiling.Profiler.EndSample();

            UnityEngine.Profiling.Profiler.BeginSample("CustomInfo.IsSuperScript");
            //上付き文字の処理
            if (CustomInfo.IsSuperScript)
            {
                float offset = (1.0f - generator.SupOrSubSizeScale) * this.DefaultFontSize;
                for (int i = 0; i < 4; ++i)
                {
                    verts[i].position.y += offset;
                }
            }
            UnityEngine.Profiling.Profiler.EndSample();

            UnityEngine.Profiling.Profiler.BeginSample("IsDash");
            //ダッシュの場合
            if (CustomInfo.IsDash)
            {
                //中央の位置に表示
                float h  = Mathf.Abs(verts[2].position.y - verts[0].position.y);
                float y0 = PositionY + this.FontSize / 2;
                verts[0].position.y = verts[1].position.y = y0 - h / 2;
                verts[2].position.y = verts[3].position.y = y0 + h / 2;

                //横に伸ばす処理を入れる
                //Slice処理のために頂点増やす
                UIVertex[] sliceVerts = new UIVertex[12];
                for (int i = 0; i < 12; ++i)
                {
                    sliceVerts[i] = verts[i % 4];
                }
                float x0 = verts[0].position.x;
                float w0 = verts[1].position.x - verts[0].position.x;

                float x3 = x0 + Width;
                float x1 = x0 + w0 / 3;
                float x2 = x3 - w0 / 3;
                SetVertexX(sliceVerts, 0, x0, x1);
                SetVertexX(sliceVerts, 4, x1, x2);
                SetVertexX(sliceVerts, 8, x2, x3);

                //UV座標はFilpされてる可能性があるので注意
                Vector2 uvBottomLeft, uvBottomRight, uvTopRight, uvTopLeft;
                Vector2 uvBottomLeft2, uvBottomRight2, uvTopRight2, uvTopLeft2;

                uvBottomLeft  = verts[0].uv0;
                uvBottomRight = verts[1].uv0;
                uvTopRight    = verts[2].uv0;
                uvTopLeft     = verts[3].uv0;

                uvBottomLeft2  = (uvBottomRight - uvBottomLeft) * 1 / 3 + uvBottomLeft;
                uvBottomRight2 = (uvBottomRight - uvBottomLeft) * 2 / 3 + uvBottomLeft;
                uvTopRight2    = (uvTopRight - uvTopLeft) * 2 / 3 + uvTopLeft;
                uvTopLeft2     = (uvTopRight - uvTopLeft) * 1 / 3 + uvTopLeft;

                SetVertexUV(sliceVerts, 0, uvBottomLeft, uvBottomLeft2, uvTopLeft2, uvTopLeft);
                SetVertexUV(sliceVerts, 4, uvBottomLeft2, uvBottomRight2, uvTopRight2, uvTopLeft2);
                SetVertexUV(sliceVerts, 8, uvBottomRight2, uvBottomRight, uvTopRight, uvTopRight2);

                verts = sliceVerts;
            }
            UnityEngine.Profiling.Profiler.EndSample();

            UnityEngine.Profiling.Profiler.EndSample();
        }
		//使用するスプライトを検索
		Sprite FindSpirte(UguiNovelTextGenerator generator)
		{
			//絵文字の取得
			if (generator.EmojiData == null) return null;
			Sprite sprite = generator.EmojiData.GetSprite(Char);
			if (sprite == null)
			{
				if (CustomInfo.IsEmoji)
				{
					sprite = generator.EmojiData.GetSprite(charData.CustomInfo.EmojiKey);
				}
			}
			return sprite;
		}
Exemple #22
0
 //自動改行などのために線を増やす必要がある場合
 UguiNovelTextGeneratorAdditionalLine(UguiNovelTextGeneratorAdditionalLine srcLine, int index, int count, UguiNovelTextGenerator generator)
 {
     InitSub(srcLine.type, generator);
     for (int i = 0; i < count; ++i)
     {
         stringData.Add(srcLine.stringData[index + i]);
     }
 }
Exemple #23
0
 internal UguiNovelTextGeneratorAdditionalLine(Type type, List <UguiNovelTextCharacter> characters, int index, UguiNovelTextGenerator generator)
 {
     InitSub(type, generator);
     stringData.Add(characters[index]);
     for (int i = index + 1; i < characters.Count; ++i)
     {
         UguiNovelTextCharacter c = characters[i];
         if (IsLineEnd(c))
         {
             break;
         }
         stringData.Add(c);
     }
 }
Exemple #24
0
        internal UguiNovelTextGeneratorAdditionalRuby(List <UguiNovelTextCharacter> characters, int index, UguiNovelTextGenerator generator)
        {
            Font  font                  = generator.NovelText.get_font();
            float rubySizeScale         = generator.RubySizeScale;
            UguiNovelTextCharacter item = characters[index];
            int fontSize                = Mathf.CeilToInt(rubySizeScale * item.FontSize);

            this.stringData.Add(item);
            for (int i = index + 1; i < characters.Count; i++)
            {
                UguiNovelTextCharacter character2 = characters[i];
                if (!character2.CustomInfo.IsRuby || character2.CustomInfo.IsRubyTop)
                {
                    break;
                }
                this.stringData.Add(character2);
            }
            CharData.CustomCharaInfo customInfo = new CharData.CustomCharaInfo {
                IsColor = item.charData.CustomInfo.IsColor,
                color   = item.charData.CustomInfo.color
            };
            if (item.charData.CustomInfo.IsEmphasisMark)
            {
                for (int j = 0; j < this.stringData.Count; j++)
                {
                    CharData charData = new CharData(item.charData.CustomInfo.rubyStr[0], customInfo);
                    this.rubyList.Add(new UguiNovelTextCharacter(charData, font, fontSize, generator.BmpFontSize, item.FontStyle));
                }
            }
            else
            {
                foreach (char ch in item.charData.CustomInfo.rubyStr)
                {
                    CharData data2 = new CharData(ch, customInfo);
                    this.rubyList.Add(new UguiNovelTextCharacter(data2, font, fontSize, generator.BmpFontSize, item.FontStyle));
                }
            }
        }
		//位置情報の初期化
		internal void InitPosition(UguiNovelTextGenerator generator)
		{
			foreach( UguiNovelTextLine line in generator.LineDataList )
			{
				if( line.Characters.IndexOf(TopCharaceter) >= 0 )
				{
					this.textLine = line;
				}
			}
			float currentSpace = generator.LetterSpaceSize;
	
			//ルビをつける最初の文字からの表示位置のオフセット
			Vector2 offset;

			//ルビ同士の文字間
			float rubySpace = 0;

			//ルビの幅が本文の幅よりも長いなら
			//ルビの幅にあわせて本文をスペースをあけて表示する
			if (IsWideType)
			{
				offset.x = -TopCharaceter.RubySpaceSize;
			}
			else
			{
				rubySpace = (StringWidth - RubyWidth) / rubyList.Count;
				offset.x = -currentSpace / 2 + rubySpace / 2;
			}
			//高さを合わせる
			offset.y = this.textLine.MaxFontSize;


			float x = offset.x + TopCharaceter.PositionX;
			float y = offset.y + TopCharaceter.PositionY;
			foreach (UguiNovelTextCharacter ruby in rubyList)
			{
				ruby.PositionX = x;
				ruby.PositionY = y;
				x += ruby.Width + rubySpace;
			}
		}
Exemple #26
0
        internal List <UguiNovelTextGeneratorAdditionalLine> MakeOtherLineInTextLineSub(UguiNovelTextGenerator generator)
        {
            List <UguiNovelTextGeneratorAdditionalLine> list = new List <UguiNovelTextGeneratorAdditionalLine>();
            int index = this.stringData.Count - 1;

            foreach (UguiNovelTextLine line in generator.LineDataList)
            {
                if (this.textLine != line)
                {
                    bool flag  = false;
                    int  num2  = 0;
                    int  count = 0;
                    for (int i = 0; i < this.stringData.Count; i++)
                    {
                        if (line.Characters.IndexOf(this.stringData[i]) >= 0)
                        {
                            if (!flag)
                            {
                                num2  = i;
                                index = Mathf.Min(i, index);
                                flag  = true;
                            }
                            count++;
                        }
                    }
                    if (flag)
                    {
                        UguiNovelTextGeneratorAdditionalLine item = new UguiNovelTextGeneratorAdditionalLine(this, num2, count, generator);
                        list.Add(item);
                        item.InitTextLine(generator);
                        if (!item.characteData.TrySetCharacterInfo(generator.NovelText.get_font()))
                        {
                            Debug.LogError("Line Font Missing");
                        }
                    }
                }
            }
            if (index < (this.stringData.Count - 1))
            {
                this.stringData.RemoveRange(index, this.stringData.Count - index);
            }
            return(list);
        }
		//描画頂点を追加
		internal void AddVerts(List<UIVertex> verts, Vector2 endPosition, UguiNovelTextGenerator generator)
		{
			foreach (UguiNovelTextGeneratorAddtionalLine line in lineList)
			{
				verts.AddRange(line.GetDrawVertex(endPosition, generator));
			}

			foreach (UguiNovelTextGeneratorAddtionalRuby ruby in RubyList)
			{
				verts.AddRange(ruby.GetDrawVertex(endPosition));
			}
		}
		//頂点を作成
		internal void MakeVerts(Color color, UguiNovelTextGenerator generator)
		{
			foreach (UguiNovelTextGeneratorAddtionalLine line in lineList)
			{
				line.CharacteData.MakeVerts(color, generator);
			}

			foreach (UguiNovelTextGeneratorAddtionalRuby ruby in RubyList)
			{
				foreach (UguiNovelTextCharacter character in ruby.RubyList)
				{
					character.MakeVerts(color, generator);
				}
			}
		}
		//表示位置の初期化
		internal void InitPosition(UguiNovelTextGenerator generator)
		{
			
			//改行などによって複数の線が必要な場合を考慮
			List<UguiNovelTextGeneratorAddtionalLine> newLineList = new List<UguiNovelTextGeneratorAddtionalLine>();
			foreach (UguiNovelTextGeneratorAddtionalLine line in lineList)
			{
				newLineList.AddRange(line.MakeOtherLineInTextLine(generator));
			}
			//新たな線を追加
			lineList.AddRange(newLineList);

			//位置の初期化
			foreach (UguiNovelTextGeneratorAddtionalLine line in lineList)
			{
				line.InitPosition(generator);
			}

			foreach (UguiNovelTextGeneratorAddtionalRuby ruby in RubyList)
			{
				ruby.InitPosition(generator);
			}
		}
		//行の先頭だった場合のスペースサイズを取得
		internal float GetTopLetterSpace(UguiNovelTextCharacter lineTopCharacter, UguiNovelTextGenerator generator)
		{
			float space = 0;
			foreach (UguiNovelTextGeneratorAddtionalRuby ruby in RubyList)
			{
				if (!ruby.IsWideType && ruby.TopCharaceter == lineTopCharacter)
				{
					space = generator.LetterSpaceSize / 2;
					break;
				}
			}
			return space;
		}
		//文字情報を取得した後の初期化
		internal void InitAfterCharacterInfo(UguiNovelTextGenerator generator)
		{
			foreach (UguiNovelTextGeneratorAddtionalRuby ruby in RubyList)
			{
				ruby.InitAfterCharacterInfo(generator);
			}
		}
		//描画用の頂点情報を取得(文字送りに対応)
		internal List<UIVertex> GetDrawVertex(Vector2 endPosition, UguiNovelTextGenerator generator)
		{
			List<UIVertex> list = new List<UIVertex>();
			if (!TopCharaceter.IsVisible) return list;

			float xMin = TopCharaceter.PositionX;
			float xMax = TopCharaceter.EndPositionX;
			foreach (UguiNovelTextCharacter c in stringData)
			{
				if (!c.IsVisible) break;
				xMax = c.EndPositionX;
			}
			CharacteData.Width = xMax - xMin;
			CharacteData.MakeVerts(TopCharaceter.Verts[0].color, generator);
			list.AddRange(CharacteData.Verts);
			return list;
		}
		void InitTextLine(UguiNovelTextGenerator generator)
		{
			foreach (UguiNovelTextLine line in generator.LineDataList)
			{
				if (line.Characters.IndexOf(TopCharaceter) >= 0)
				{
					this.textLine = line;
				}
			}
		}