1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 20:58:34 +01:00

fixed animations using the wrong index

This commit is contained in:
Ellpeck 2020-02-08 18:29:07 +01:00
parent f8f4dfbff4
commit 2083868874

View file

@ -90,7 +90,7 @@ namespace MLEM.Formatting {
var innerOffset = new Vector2(); var innerOffset = new Vector2();
var formatIndex = 0; var formatIndex = 0;
for (var i = 0; i < unformattedText.Length; i++) { foreach (var c in unformattedText) {
// check if the current character's index has a formatting code // check if the current character's index has a formatting code
if (formatting.TryGetValue(formatIndex, out var codes)) { if (formatting.TryGetValue(formatIndex, out var codes)) {
foreach (var code in codes) { foreach (var code in codes) {
@ -119,21 +119,20 @@ namespace MLEM.Formatting {
break; break;
case FormattingCode.Type.Animation: case FormattingCode.Type.Animation:
currAnim = code.Animation; currAnim = code.Animation;
animStart = i; animStart = formatIndex;
break; break;
} }
} }
} }
var c = unformattedText[i];
var cSt = c.ToString(); var cSt = c.ToString();
if (c == '\n') { if (c == '\n') {
innerOffset.X = 0; innerOffset.X = 0;
innerOffset.Y += regularFont.LineHeight * scale; innerOffset.Y += regularFont.LineHeight * scale;
} else { } else {
if (currStyle == TextStyle.Shadow) if (currStyle == TextStyle.Shadow)
currAnim(settings, currFont, batch, unformattedText, i, animStart, cSt, pos + innerOffset + settings.DropShadowOffset * scale, settings.DropShadowColor, scale, depth, timeIntoAnimation); currAnim(settings, currFont, batch, unformattedText, formatIndex, animStart, cSt, pos + innerOffset + settings.DropShadowOffset * scale, settings.DropShadowColor, scale, depth, timeIntoAnimation);
currAnim(settings, currFont, batch, unformattedText, i, animStart, cSt, pos + innerOffset, currColor, scale, depth, timeIntoAnimation); currAnim(settings, currFont, batch, unformattedText, formatIndex, animStart, cSt, pos + innerOffset, currColor, scale, depth, timeIntoAnimation);
innerOffset.X += regularFont.MeasureString(cSt).X * scale; innerOffset.X += regularFont.MeasureString(cSt).X * scale;
formatIndex++; formatIndex++;
} }