2017-10-09 15:40:08 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "text.h"
|
2017-11-19 22:48:46 +01:00
|
|
|
#include "international_string_util.h"
|
2017-10-09 15:40:08 +02:00
|
|
|
|
|
|
|
extern s32 convert_pixel_width_to_tile_width(s32 a0); // script menu
|
|
|
|
|
|
|
|
s32 GetStringCenterAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth)
|
|
|
|
{
|
|
|
|
return GetStringCenterAlignXOffsetWithLetterSpacing(fontId, str, totalWidth, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 GetStringRightAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth)
|
|
|
|
{
|
|
|
|
return GetStringWidthDifference(fontId, str, totalWidth, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 GetStringCenterAlignXOffsetWithLetterSpacing(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing)
|
|
|
|
{
|
|
|
|
return GetStringWidthDifference(fontId, str, totalWidth, letterSpacing) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 GetStringWidthDifference(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing)
|
|
|
|
{
|
|
|
|
s32 stringWidth = GetStringWidth(fontId, str, letterSpacing);
|
|
|
|
if (totalWidth > stringWidth)
|
|
|
|
return totalWidth - stringWidth;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
s32 GetMaxWidthInMenuTable(const struct MenuAction *str, s32 arg1)
|
2017-10-09 15:40:08 +02:00
|
|
|
{
|
|
|
|
s32 i, var;
|
|
|
|
|
|
|
|
for (var = 0, i = 0; i < arg1; i++)
|
|
|
|
{
|
2017-10-23 00:55:07 +02:00
|
|
|
s32 stringWidth = GetStringWidth(1, str[i].text, 0);
|
2017-10-09 15:40:08 +02:00
|
|
|
if (stringWidth > var)
|
|
|
|
var = stringWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
return convert_pixel_width_to_tile_width(var);
|
|
|
|
}
|
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
s32 sub_81DB3D8(const struct MenuAction *str, u8* arg1, s32 arg2)
|
2017-10-09 15:40:08 +02:00
|
|
|
{
|
|
|
|
s32 i, var;
|
|
|
|
|
|
|
|
for (var = 0, i = 0; i < arg2; i++)
|
|
|
|
{
|
2017-10-23 00:55:07 +02:00
|
|
|
s32 stringWidth = GetStringWidth(1, str[arg1[i]].text, 0);
|
2017-10-09 15:40:08 +02:00
|
|
|
if (stringWidth > var)
|
|
|
|
var = stringWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
return convert_pixel_width_to_tile_width(var);
|
|
|
|
}
|