nitro-engine/source
jonko0493 8932de1fff
Some checks failed
Documentation / Generate website (push) Has been cancelled
Documentation / Publish website with GitHub pages (push) Has been cancelled
rich text: Optionally return cursor position from dry run & allow indenting text
The goal of the changes made in this PR is to create something with this
effect ("Jonko" is in in green, the rest is in white):

    "Dear god." Jonko quickly replied,
    crestfallen.

In order to do this, I need to call `NE_RichTextRender3D` or
`NE_RichTextRender3DAlpha` three times: once to draw the first part of
the sentence with the white font, once to draw "Jonko" in turquoise, and
once to draw the remainder of the sentence in white again. In order to
ensure that text is being drawn in the correct location, I need the
position where the previous call stopped drawing, which leads to the
first change this PR makes: I have added a version of
`DSF_StringRenderDryRun` which accepts pointers to `final_x` and
`final_y` and stores the last position of `font->pointer_x` and
`font->pointer_y` in them and I have added a new variant of
`NE_RichTextRenderDryRun` called `NE_RichTextRenderDryRunWithPos` which
uses that DSF function and has analogous parameters.

These functions get us the position where we need to place the next
cursor, but the next issue is that currently NitroEngine and libDSF only
allow for specifying the position of the overall box to draw text in,
but not where to offset the cursor in that box. This leads to the
following problem ("Jonko" is in in green, the rest is in white):

    "Dear god." Jonko quickly replied,
                        crestfallen.

Thus, the second change: I have introduced new versions of
`DSF_StringRender3D` and `DSF_StringRender3DAlpha` which accept an
`xStart` position that is added to the `pointerX`. Correspondingly, I
have added versions of `NE_RichTextRender3D` and
`NE_RichTextRender3DAlpha` that use these new functions as well.

Let me know if there are any issues with how I've written this (C is not
my forte, after all), but the first screenshot is this being tested in
production code.
2025-06-11 00:03:38 +01:00
..
dsma library: Let user choose how to draw display lists 2023-10-09 00:59:23 +01:00
libdsf rich text: Optionally return cursor position from dry run & allow indenting text 2025-06-11 00:03:38 +01:00
NE2D.c library: Support setting texture coordinates in sprites 2024-03-24 16:14:21 +00:00
NEAlloc.c chore: Simplify copyright years in notices 2024-03-09 01:42:29 +00:00
NEAnimation.c chore: Simplify copyright years in notices 2024-03-09 01:42:29 +00:00
NECamera.c Use stdint.h types instead of libnds custom types 2024-07-29 00:09:41 +01:00
NEDisplayList.c library: Use safe DMA functions in BlocksDS 2023-10-16 02:55:39 +01:00
NEFAT.c chore: Simplify copyright years in notices 2024-03-09 01:42:29 +00:00
NEFormats.c chore: Simplify copyright years in notices 2024-03-09 01:42:29 +00:00
NEGeneral.c chore: Simplify copyright years in notices 2024-03-09 01:42:29 +00:00
NEGUI.c chore: Simplify copyright years in notices 2024-03-09 01:42:29 +00:00
NEMath.h chore: Simplify copyright years in notices 2024-03-09 01:42:29 +00:00
NEModel.c library: Allow users to specify model transformation matrices 2024-10-11 13:33:21 +02:00
NEPalette.c chore: Simplify copyright years in notices 2024-03-09 01:42:29 +00:00
NEPhysics.c chore: Simplify copyright years in notices 2024-03-09 01:42:29 +00:00
NEPolygon.c Use stdint.h types instead of libnds custom types 2024-07-29 00:09:41 +01:00
NERichText.c rich text: Optionally return cursor position from dry run & allow indenting text 2025-06-11 00:03:38 +01:00
NEText.c chore: Simplify copyright years in notices 2024-03-09 01:42:29 +00:00
NETexture.c library: Optimize copy of NE_RGB5 textures to VRAM 2024-06-05 02:28:40 +01:00