Skip to content

multicolor text support#42

Open
henlo-birb wants to merge 8 commits into
devkitPro:masterfrom
henlo-birb:master
Open

multicolor text support#42
henlo-birb wants to merge 8 commits into
devkitPro:masterfrom
henlo-birb:master

Conversation

@henlo-birb

Copy link
Copy Markdown

adds support for drawing multicolor text in one call to C2D_DrawText using a new flag C2D_MultiColor

a u32 array must also be passed to C2D_DrawText formatted like: {start_idx0, color0, start_idx1, color1, ...} where the start_idx is the index of the character where the corresponding color starts in the string. This is kind of similar to the coloredtext format in the text drawing calls Love2D.

a u32 with the length of that array must be passed as well.

@fincs

fincs commented Jun 27, 2022

Copy link
Copy Markdown
Member

Good work, although indentation is a bit screwed up. This project uses hard tabs, not spaces.

@henlo-birb

henlo-birb commented Jun 27, 2022

Copy link
Copy Markdown
Author

I must've messed it up with autoformatting, oops, thanks tho!

@fincs

fincs commented Jun 29, 2022

Copy link
Copy Markdown
Member

Can you fix the formatting, please?

@henlo-birb

henlo-birb commented Jun 29, 2022

Copy link
Copy Markdown
Author

done! (assuming the only issue was the spaces instead of tabs) sorry, i got busy w/ other stuff

@LiquidFenrir LiquidFenrir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bug when a character is in the last range of colours and the next character also is.
You also don't properly reset to the default opaque black (or WithColor-provided value) when the first range doesn't start at the beginning of the text, instead drawing with the last drawn character's colour.

Comment thread source/text.c Outdated
Comment thread source/text.c Outdated
Comment thread source/text.c Outdated
Comment thread source/text.c Outdated
@henlo-birb

Copy link
Copy Markdown
Author

i think those should be fixed now, anything else?

@LiquidFenrir

Copy link
Copy Markdown
Contributor

Looks fine to me now, but I think cur-> charNo > colors[0] should be cur->charNo >= colors[0].
No space between the dereference and the field name (style problem), and imagining you start the range at character index 1, having greater than instead of greater or equal would make the if only be true at index 2 or more (logic problem).

@henlo-birb

Copy link
Copy Markdown
Author

fixed

@Fewnity

Fewnity commented Dec 9, 2022

Copy link
Copy Markdown

Hey! Any news about the pr?

@henlo-birb

Copy link
Copy Markdown
Author

Bumping again now that im doing 3ds stuff again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants