mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 06:28:35 +01:00
fixed some issues with the new code width system
This commit is contained in:
parent
b374d50815
commit
066ed9f8f7
2 changed files with 6 additions and 10 deletions
|
@ -41,12 +41,6 @@ namespace MLEM.Formatting.Codes {
|
||||||
batch.Draw(this.image.CurrentRegion, new RectangleF(pos, new Vector2(font.LineHeight * scale)), actualColor);
|
batch.Draw(this.image.CurrentRegion, new RectangleF(pos, new Vector2(font.LineHeight * scale)), actualColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override bool DrawCharacter(GameTime time, SpriteBatch batch, int codePoint, string character, Token token, int indexInToken, ref Vector2 pos, GenericFont font, ref Color color, ref float scale, float depth) {
|
|
||||||
// we don't want to draw the first (space) character (in case it is set to a missing character in FNA)
|
|
||||||
return indexInToken == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -167,19 +167,21 @@ namespace MLEM.Formatting {
|
||||||
|
|
||||||
var indexInToken = 0;
|
var indexInToken = 0;
|
||||||
for (var l = 0; l < token.SplitDisplayString.Length; l++) {
|
for (var l = 0; l < token.SplitDisplayString.Length; l++) {
|
||||||
|
// only draw self at the start of the first line of the token!
|
||||||
|
if (indexInToken == 0) {
|
||||||
|
token.DrawSelf(time, batch, pos + innerOffset, drawFont, color, scale, depth);
|
||||||
|
innerOffset.X += selfWidth * scale;
|
||||||
|
}
|
||||||
|
|
||||||
var charIndex = 0;
|
var charIndex = 0;
|
||||||
var line = new CodePointSource(token.SplitDisplayString[l]);
|
var line = new CodePointSource(token.SplitDisplayString[l]);
|
||||||
while (charIndex < line.Length) {
|
while (charIndex < line.Length) {
|
||||||
var (codePoint, length) = line.GetCodePoint(charIndex);
|
var (codePoint, length) = line.GetCodePoint(charIndex);
|
||||||
var character = CodePointSource.ToString(codePoint);
|
var character = CodePointSource.ToString(codePoint);
|
||||||
|
|
||||||
if (indexInToken == 0)
|
|
||||||
token.DrawSelf(time, batch, pos + innerOffset, drawFont, color, scale, depth);
|
|
||||||
token.DrawCharacter(time, batch, codePoint, character, indexInToken, pos + innerOffset, drawFont, drawColor, scale, depth);
|
token.DrawCharacter(time, batch, codePoint, character, indexInToken, pos + innerOffset, drawFont, drawColor, scale, depth);
|
||||||
|
|
||||||
innerOffset.X += drawFont.MeasureString(character).X * scale;
|
innerOffset.X += drawFont.MeasureString(character).X * scale;
|
||||||
if (indexInToken == 0)
|
|
||||||
innerOffset.X += selfWidth * scale;
|
|
||||||
charIndex += length;
|
charIndex += length;
|
||||||
indexInToken++;
|
indexInToken++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue