1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-26 02:09:24 +01:00

fixed some issues with the new code width system

This commit is contained in:
Ell 2022-12-06 17:10:04 +01:00
parent b374d50815
commit 066ed9f8f7
2 changed files with 6 additions and 10 deletions

View file

@ -41,12 +41,6 @@ namespace MLEM.Formatting.Codes {
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>

View file

@ -167,19 +167,21 @@ namespace MLEM.Formatting {
var indexInToken = 0;
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 line = new CodePointSource(token.SplitDisplayString[l]);
while (charIndex < line.Length) {
var (codePoint, length) = line.GetCodePoint(charIndex);
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);
innerOffset.X += drawFont.MeasureString(character).X * scale;
if (indexInToken == 0)
innerOffset.X += selfWidth * scale;
charIndex += length;
indexInToken++;
}