@@ -259,6 +259,13 @@ void drawText(const char *text, int32_t x, int32_t y, uint8_t alpha, uint32_t co
259
259
}
260
260
}
261
261
262
+ uint16_t getMessageWidth (const char *text, float scale)
263
+ {
264
+ uint16_t LineLength = ttyd::fontmgr::FontGetMessageWidth (text);
265
+ float Width = static_cast <float >(LineLength + 15 ) * (scale + 0.05 );
266
+ return static_cast <uint16_t >(Width);
267
+ }
268
+
262
269
void drawTextWithWindow (const char *text, int32_t textPosX, int32_t textPosY, uint8_t alpha,
263
270
uint32_t textColor, float textScale, int32_t windowWidth, uint32_t windowColor, float windowCurve)
264
271
{
@@ -1490,14 +1497,15 @@ void drawMemoryChangeWatchPosition()
1490
1497
}
1491
1498
1492
1499
// Draw the help window
1493
- int32_t Width = 293 ;
1494
1500
int32_t Curve = 20 ;
1495
1501
uint32_t WindowColor = 0x151515F6 ;
1496
1502
int32_t TextPosX = -135 ;
1497
1503
int32_t TextPosY = 100 ;
1498
1504
Scale = 0.6 ;
1499
1505
1500
1506
const char *HelpText = " Press/Hold the D-Pad directions\n to move the watch\n\n Hold Y to hide this window\n\n Press B to cancel" ;
1507
+ int32_t Width = static_cast <int32_t >(getMessageWidth (HelpText, Scale));
1508
+
1501
1509
drawTextWithWindow (HelpText, TextPosX, TextPosY, Alpha, TextColor,
1502
1510
Scale, Width, WindowColor, Curve);
1503
1511
}
@@ -1832,10 +1840,10 @@ void drawErrorMessage(const char *line)
1832
1840
return ;
1833
1841
}
1834
1842
1835
- int32_t TextPosX = -130 ;
1836
- // int32_t WindowWidth = 305 ;
1837
- uint32_t LineLength = ttyd::fontmgr::FontGetMessageWidth ( line);
1838
- int32_t WindowWidth = 80 + (LineLength >> 1 ) - (LineLength % 10 );
1843
+ int32_t TextPosX = -130 ;
1844
+ float Scale = 0.6 ;
1845
+ int32_t WindowWidth = static_cast < int32_t >( getMessageWidth ( line, Scale) );
1846
+
1839
1847
drawErrorWindow (line, TextPosX, WindowWidth);
1840
1848
}
1841
1849
else
@@ -1875,22 +1883,6 @@ void drawFollowersErrorMessage()
1875
1883
drawPartnerFollowerMessage (CurrentLine);
1876
1884
}
1877
1885
1878
- void drawMemoryErrorMessage (const char *message)
1879
- {
1880
- uint32_t tempTimer = Timer;
1881
- if ((FunctionReturnCode < 0 ) && (tempTimer > 0 ))
1882
- {
1883
- if (checkForClosingErrorMessage ())
1884
- {
1885
- return ;
1886
- }
1887
-
1888
- int32_t PosX = -140 ;
1889
- int32_t WindowWidth = 275 ;
1890
- drawErrorWindow (message, PosX, WindowWidth);
1891
- }
1892
- }
1893
-
1894
1886
void drawNotInBattleErrorMessage ()
1895
1887
{
1896
1888
uint32_t tempTimer = Timer;
@@ -3485,13 +3477,10 @@ void drawPalaceSkipDetails()
3485
3477
}
3486
3478
3487
3479
uint32_t TextColor = 0xFFFFFFFF ;
3488
- // uint32_t WindowColor = 0x000000C0;
3489
3480
uint8_t Alpha = 0xFF ;
3490
3481
int32_t PosX = -232 ;
3491
3482
int32_t PosY = -70 ;
3492
3483
float Scale = 0.75 ;
3493
- // int32_t WindowWidth = 440;
3494
- // float WindowCurve = 0;
3495
3484
3496
3485
// Move the text up if the input display is active
3497
3486
if (Displays[BUTTON_INPUT_DISPLAY])
@@ -3514,12 +3503,6 @@ void drawPalaceSkipDetails()
3514
3503
PhantomEmberPosY,
3515
3504
PartnerPosY);
3516
3505
3517
- // uint32_t LineLength = ttyd::fontmgr::FontGetMessageWidth(tempDisplayBuffer);
3518
- // int32_t WindowWidth = 245 + (LineLength >> 1) - (LineLength % 10);
3519
-
3520
- /* drawTextWithWindow(tempDisplayBuffer, PosX, PosY, Alpha, TextColor,
3521
- Scale, WindowWidth, WindowColor, WindowCurve);*/
3522
-
3523
3506
drawText (tempDisplayBuffer, PosX, PosY, Alpha, TextColor, Scale);
3524
3507
3525
3508
// Draw Mario's coordinates if they're not already drawn
@@ -3574,7 +3557,6 @@ void drawActionCommandsTiming()
3574
3557
3575
3558
uint32_t TypeToDraw = DisplayActionCommands.TypeToDraw ;
3576
3559
char *tempDisplayBuffer = DisplayBuffer;
3577
- uint32_t IncrementWindowWidth = 129 ;
3578
3560
const char *TextToDraw;
3579
3561
3580
3562
const uint32_t SuccessfulTiming = 1 ;
@@ -3659,7 +3641,6 @@ void drawActionCommandsTiming()
3659
3641
case CannotBeSuperguarded:
3660
3642
{
3661
3643
TextToDraw = " Cannot superguard this attack" ;
3662
- IncrementWindowWidth += 7 ;
3663
3644
break ;
3664
3645
}
3665
3646
default :
@@ -3678,8 +3659,7 @@ void drawActionCommandsTiming()
3678
3659
int32_t WindowCurve = 10 ;
3679
3660
float Scale = 0.75 ;
3680
3661
3681
- uint32_t LineLength = ttyd::fontmgr::FontGetMessageWidth (TextToDraw);
3682
- int32_t WindowWidth = IncrementWindowWidth + (LineLength >> 1 ) - (LineLength % 10 );
3662
+ int32_t WindowWidth = static_cast <int32_t >(getMessageWidth (TextToDraw, Scale));
3683
3663
3684
3664
drawTextWithWindow (TextToDraw, TextPosX, TextPosY, Alpha, TextColor,
3685
3665
Scale, WindowWidth, WindowColor, WindowCurve);
0 commit comments