diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2017-10-28 20:03:24 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2017-10-28 20:03:24 -0400 |
commit | 975e28c01e70c63587c8633ffc3c50b7d1759dec (patch) | |
tree | 361d94f24acc207803afb8bff6ed7887dbbf391e /src/international_string_util.c | |
parent | d160ca467920d97245c012b8dd0cb8be6d06620a (diff) | |
parent | 5ea2f463d71d0bc2663e70a553557de0ccf40eef (diff) |
Merge branch 'master' into easy_chat
Diffstat (limited to 'src/international_string_util.c')
-rw-r--r-- | src/international_string_util.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/international_string_util.c b/src/international_string_util.c new file mode 100644 index 000000000..81985d614 --- /dev/null +++ b/src/international_string_util.c @@ -0,0 +1,57 @@ +#include "global.h" +#include "international_string_util.h" +#include "text.h" + +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; +} + +s32 GetMaxWidthInMenuTable(const struct MenuAction *str, s32 arg1) +{ + s32 i, var; + + for (var = 0, i = 0; i < arg1; i++) + { + s32 stringWidth = GetStringWidth(1, str[i].text, 0); + if (stringWidth > var) + var = stringWidth; + } + + return convert_pixel_width_to_tile_width(var); +} + +s32 sub_81DB3D8(const struct MenuAction *str, u8* arg1, s32 arg2) +{ + s32 i, var; + + for (var = 0, i = 0; i < arg2; i++) + { + s32 stringWidth = GetStringWidth(1, str[arg1[i]].text, 0); + if (stringWidth > var) + var = stringWidth; + } + + return convert_pixel_width_to_tile_width(var); +} |