9#define FIT_FIXED_LIMIT 1
18 u32 *windowWidth,
u32 *windowHeight,
u16 *spacing,
20#if !defined(FIT_FIXED_LIMIT)
31#if !defined(FIT_FIXED_LIMIT)
46 if (*windowWidth == 0 && *windowHeight == 0)
51 *windowWidth = (*windowWidth + 19) >> 3;
52 *windowHeight = (*windowHeight + 15) >> 3;
53#if !defined(FIT_FIXED_LIMIT)
62 right = x + *windowWidth;
63 if (right > rightLimit) {
64 overflow = right - rightLimit;
65 fittedPosition = x - overflow;
66 if (fittedPosition >= 0)
71 bottom = y + *windowHeight;
73 overflow = bottom - 20;
74 fittedPosition = y - overflow;
75 if (fittedPosition >= 0)
84 if (x > rightLimit - *windowWidth)
85 x = rightLimit - *windowWidth;
86 if (y > 20 - *windowHeight)
87 y = 20 - *windowHeight;
107 u32 *outHeight,
u16 *spacing) {
117 u16 lineSpacingCounts[4];
121#if (LANGUAGE == LANGUAGE_JAPANESE)
126#if (LANGUAGE == LANGUAGE_JAPANESE)
135 code = work->
entries[entryIndex];
140#if (LANGUAGE != LANGUAGE_JAPANESE)
147 if (style == 1 || style == 5)
159 else if (code == 0x21)
161 else if (code == 0xa1 || code == 0xa4)
169 if (style == 1 || style == 5)
180#if !(LANGUAGE == LANGUAGE_SPANISH) && !(LANGUAGE == LANGUAGE_FRENCH) && \
181 !(LANGUAGE == LANGUAGE_ITALIAN)
186#if (LANGUAGE != LANGUAGE_JAPANESE)
189 lineWidth += trailing;
191 lineSpacingCounts[lines] =
count;
192 lineWidths[lines] = lineWidth;
193 if (width < lineWidth)
224#if (LANGUAGE != LANGUAGE_JAPANESE)
227 lineWidth += trailing;
229 lineSpacingCounts[lines] =
count;
230 lineWidths[lines] = lineWidth;
231 if (width < lineWidth)
233#if (LANGUAGE == LANGUAGE_JAPANESE) || (LANGUAGE == LANGUAGE_ENGLISH)
241 width = (width + 19) >> 3;
242 width = (width << 3) - 16;
243 if (spacing !=
NULL) {
245 while (lineIndex <= lines) {
246 if (lineSpacingCounts[lineIndex] <= 1) {
249 gap = width - lineWidths[lineIndex];
253 gap = ((gap << 8) / (lineSpacingCounts[lineIndex] - 1));
254#if (LANGUAGE != LANGUAGE_JAPANESE)
255 if (gap < 0 || gap > 0xc00)
258 if (gap < 0 || gap > 0x800)
260 if (gap < 0 || gap > 0x100)
278 u16 lineSpacingCounts[4];
292#if (LANGUAGE == LANGUAGE_JAPANESE)
308 pageHeights[10] = 15;
309 pageHeights[11] = 15;
310 pageHeights[12] = 15;
312 pageHeights[13] = 15;
313 pageHeights[14] = 15;
314 pageHeights[15] = 15;
320 code = work->
entries[entryIndex];
323#if (LANGUAGE != LANGUAGE_JAPANESE)
341 else if (code == 0x21)
343 else if (code == 0xa1 || code == 0xa4)
362#if (LANGUAGE != LANGUAGE_JAPANESE)
363 lineSpacingCounts[line] = ++
count;
366 lineSpacingCounts[line] =
count;
368 lineWidths[line] = width;
369 if (page == 0 && maxWidth < width)
375 pageHeights[page] += 15;
378#if (LANGUAGE != LANGUAGE_JAPANESE)
379 lineSpacingCounts[line] = ++
count;
382 lineSpacingCounts[line] =
count;
384 lineWidths[line] = width;
385 if (page == 0 && maxWidth < width)
390#if (LANGUAGE != LANGUAGE_JAPANESE)
391 lineSpacingCounts[line] = ++
count;
394 lineSpacingCounts[line] =
count;
396 lineWidths[line] = width;
397 if (page == 0 && maxWidth < width)
422#if !(LANGUAGE == LANGUAGE_GERMAN) && !(LANGUAGE == LANGUAGE_FRENCH)
426 for (pageIndex = 0; pageIndex < page; pageIndex++) {
428 *outHeight = pageHeights[0];
429 else if (*outHeight < pageHeights[pageIndex])
430 *outHeight = pageHeights[pageIndex];
432 *outWidth = maxWidth;
433 maxWidth = (((maxWidth + 19) >> 3) << 3) - 16;
434 if (spacing !=
NULL) {
435 for (lineIndex = 0; lineIndex <= line; lineIndex++) {
436 if (lineSpacingCounts[lineIndex] <= 1) {
439 gap = maxWidth - lineWidths[lineIndex];
443 gap = (gap << 8) / (lineSpacingCounts[lineIndex] - 1);
444#if (LANGUAGE == LANGUAGE_JAPANESE)
445 if (gap < 0 || gap > 0x800)
447 if (gap < 0 || gap > 0x100)
s32 UiText_BuildRenderEntries(s32 script, s32 clear)
Decodes message script into the ring of decoded text (UiRenderWork.entries) and returns where it star...
const struct FontGlyph gUiText_Glyphs[]
void UiText_MeasureAllPages(s32 entryIndex, u32 *outWidth, u32 *outHeight, u16 *spacing)
Measures decoded text from start over all its pages: the width of the first page's longest line and t...
void UiText_MeasureEntryDimensions(s32 entryIndex, u32 *outWidth, u32 *outHeight, u16 *spacing)
Measures decoded text from entryIndex to its first page's end: returns the width of the longest line ...
void UiText_MeasureResourceEntries(s32 message, s32 *x, s32 *y)
Decodes message no and returns its text's width and height in pixels.
void UiWindow_FitOnScreen(s32 entryIndex, s32 *windowX, s32 *windowY, u32 *windowWidth, u32 *windowHeight, u16 *spacing, u32 flags)
Sizes a window for decoded text no and moves (*px, *py) so the window fits on the screen.
The window system's work: the windows' tilemap, the windows, the three text channels,...
u8 mode
Set while Mind Read shows thoughts: round frame corners, colour 8 text with no shadow,...
u16 entries[RENDER_ENTRY_MASK+1]
decoded text, a ring of codes
u16 count
where the next code goes in entries
u16 outline
the current channel's, copied in to draw
#define RENDER_ENTRY_MASK
s32 UiText_GetResourceDimensions(s32 no, s32 *x, s32 *y, u32 *width, u32 *height)
s32 UiText_GetResourceDimensionsAlt(s32 no, s32 *x, s32 *y, u32 *width, u32 *height)
#define DEFINE_GET_RESOURCE_DIMENSIONS(name, flags)
Defines name(no, x, y, width, height): decodes message no and fits a window for it on the screen near...
What every part of the window object shares: its includes, edition values, macros and the codes of de...
@ TEXT_WINDOW_STATE
the next entry is the window effect to run
@ TEXT_OUTLINE
the next entry is the outline colour
@ TEXT_VOICED_MARK
dakuten
@ TEXT_PAGE
wait for a button, then clear the window for a new page
@ TEXT_SEMIVOICED_MARK
handakuten
@ TEXT_COLOUR
the next entry is the text colour
@ TEXT_LINE_SPACING
the next entry is the line spacing