Alchemy
Loading...
Searching...
No Matches

measure.c File Reference

Sizing windows to their text and fitting them on the screen. More...

Go to the source code of this file.

Functions

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.
void UiText_MeasureResourceEntries (s32 message, s32 *x, s32 *y)
 Decodes message no and returns its text's width and height in pixels.
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 and the height (15 pixels a line) in pixels.
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 the height of its tallest page, in pixels, with each line's extra character gap in spacing as UiText_MeasureEntryDimensions.

Detailed Description

Sizing windows to their text and fitting them on the screen.

Part of window.c, the window object, compiled only through it.

Definition in file measure.c.

Function Documentation

◆ UiWindow_FitOnScreen()

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.

flags: bit 0 measures every page (UiText_MeasureAllPages) rather than the first; bit 1 takes the size in *pw and *ph as given, in tiles, instead of measuring. Measuring returns the size in tiles in *pw and *ph and fills spacing with each line's extra character gap.

Definition at line 17 of file measure.c.

Referenced by UiText_OpenMessageWindow(), UiWindow_FitOnScreen(), and UiWork_StepChannelScript().

◆ UiText_MeasureResourceEntries()

void UiText_MeasureResourceEntries ( s32 message,
s32 * x,
s32 * y )

Decodes message no and returns its text's width and height in pixels.

Definition at line 93 of file measure.c.

Referenced by UiText_MeasureResourceEntries().

◆ UiText_MeasureEntryDimensions()

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 and the height (15 pixels a line) in pixels.

With spacing set, fills one entry per line with the extra gap between characters, in 1/256 pixel, that spreads the line to fill the window. spacing, when non-NULL, has room for four line entries.

Definition at line 106 of file measure.c.

Referenced by UiText_GetResourceDimensionsAlt(), UiText_MeasureEntryDimensions(), UiText_MeasureResourceEntries(), UiText_SetRenderString(), and UiWindow_FitOnScreen().

◆ UiText_MeasureAllPages()

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 the height of its tallest page, in pixels, with each line's extra character gap in spacing as UiText_MeasureEntryDimensions.

The text must fit 16 page-height slots; this routine does not clamp the page count.

Definition at line 275 of file measure.c.

Referenced by UiText_GetResourceDimensionsAlt(), UiText_MeasureAllPages(), and UiWindow_FitOnScreen().