PWAAT - DoubleQuotationAdjustment
Back to Home
using System;
using System.Collections.Generic;
using UnityEngine;
namespace TextEffect
{
// Token: 0x0200018B RID: 395
public class DoubleQuotationAdjustment : BaseMessageTextEffect
{
// Token: 0x06000E3E RID: 3646 RVA: 0x000911C0 File Offset: 0x0008F5C0
public override void MessageModifyMesh(ref List stream)
{
if (this.text_ == null)
{
return;
}
int num = this.CountChar(this.text_.text, '“');
num += this.CountChar(this.text_.text, '”');
TextAnchor alignment = this.text_.alignment;
float num2 = 0f;
if (alignment == TextAnchor.UpperCenter)
{
num2 = (float)num * (this.alignment_uppercenter_quotation_diff_ / 2f);
}
float num3 = 0f;
int i = 0;
int count = stream.Count;
int num4 = 0;
while (i < count)
{
Vector2 centerPosition = base.GetCenterPosition(i, stream);
if (this.text_.text[num4] == '“')
{
if (GSStatic.global_work_.language == Language.CHINA_S)
{
num3 += ((alignment != TextAnchor.UpperLeft) ? this.alignment_uppercenter_quotation_diff_china_s_ : this.alignment_upperleft_quotation_diff_china_s_);
}
else
{
num3 += ((alignment != TextAnchor.UpperLeft) ? this.alignment_uppercenter_quotation_diff_ : this.alignment_upperleft_quotation_diff_);
}
}
else if (num4 > 0 && this.text_.text[num4 - 1] == '”')
{
if (GSStatic.global_work_.language == Language.CHINA_S)
{
num3 += ((alignment != TextAnchor.UpperLeft) ? this.alignment_uppercenter_quotation_diff_china_s_ : this.alignment_upperleft_quotation_diff_china_s_);
}
else
{
num3 += ((alignment != TextAnchor.UpperLeft) ? this.alignment_uppercenter_quotation_diff_ : this.alignment_upperleft_quotation_diff_);
}
}
else if (GSStatic.global_work_.language != Language.JAPAN && GSStatic.global_work_.language != Language.USA)
{
if (this.text_.text[num4] == 'ï')
{
num3 += this.diaeresis_i_diff_;
}
if (num4 > 0 && this.text_.text[num4 - 1] == 'ï')
{
num3 += this.diaeresis_i_diff_;
}
}
for (int j = 0; j < 6; j++)
{
UIVertex uivertex = stream[i + j];
Vector2 vector = uivertex.position - centerPosition;
vector = new Vector2(vector.x + num3 - num2, vector.y);
uivertex.position = vector + centerPosition;
stream[i + j] = uivertex;
}
i += 6;
num4++;
}
this.text_.GraphicUpdateComplete();
}
// Token: 0x06000E3F RID: 3647 RVA: 0x00091449 File Offset: 0x0008F849
private int CountChar(string s, char c)
{
return s.Length - s.Replace(c.ToString(), string.Empty).Length;
}
// Token: 0x04001856 RID: 6230
[SerializeField]
private float alignment_upperleft_quotation_diff_ = 34f;
// Token: 0x04001857 RID: 6231
[SerializeField]
private float alignment_upperleft_quotation_diff_china_s_ = 32f;
// Token: 0x04001858 RID: 6232
[SerializeField]
private float alignment_uppercenter_quotation_diff_ = 25f;
// Token: 0x04001859 RID: 6233
[SerializeField]
private float alignment_uppercenter_quotation_diff_china_s_ = 24f;
// Token: 0x0400185A RID: 6234
[SerializeField]
private float diaeresis_i_diff_ = 2.8f;
// Token: 0x0400185B RID: 6235
private const char BEGIN_QUOTATION = '“';
// Token: 0x0400185C RID: 6236
private const char END_QUOTATION = '”';
// Token: 0x0400185D RID: 6237
private const char DIAERESIS_I = 'ï';
}
}
The DoubleQuotationAdjustment
class is a subclass of the BaseMessageTextEffect
class. It is used to adjust the position of double quotation marks in a text message, depending on the language and alignment of the text.
Here is the class declaration:
public class DoubleQuotationAdjustment : BaseMessageTextEffect
The main method in this class is MessageModifyMesh
. It modifies the vertices of the text mesh to adjust the position of the double quotation marks. Here is the method signature:
public override void MessageModifyMesh(ref List<UIVertex> stream)
The method CountChar
is a helper method that counts the number of occurrences of a specific character in a string. Here is the method signature:
private int CountChar(string s, char c)
The class also contains several private fields that store the adjustment values for different scenarios. Here are the field declarations:
[SerializeField]
private float alignment_upperleft_quotation_diff_ = 34f;
[SerializeField]
private float alignment_upperleft_quotation_diff_china_s_ = 32f;
[SerializeField]
private float alignment_uppercenter_quotation_diff_ = 25f;
[SerializeField]
private float alignment_uppercenter_quotation_diff_china_s_ = 24f;
[SerializeField]
private float diaeresis_i_diff_ = 2.8f;
And finally, the class contains several constant character fields that represent the characters to be adjusted. Here are the field declarations:
private const char BEGIN_QUOTATION = '“';
private const char END_QUOTATION = '”';
private const char DIAERESIS_I = 'ï';