Skip to content

Conversation

@michaeloa
Copy link

@michaeloa michaeloa commented Nov 5, 2025

Contributing #281 : suport for TextraTypist; adding adnimated and styled text labels such as TypingLabel and TextraLabel.

@michaeloa
Copy link
Author

First cut on implementing this. Having a little trouble with gradle format, so need to take a look at that (though hopefully the editorconfig has kept things relatively correct).

For now, I've just added support for TextraLabel and TypingLabel, the two main widgets. Not 100% sure about how prime-time the other widgets are, as I don't use them atm. But thinking it makes sense to start with a small(ish) commit, anyway.

Replaced VisUI with FWSkin in the tests, since I need support for Textra label styles.

Any obvious mistakes/issues that I need to address?

Copy link
Member

@czyzby czyzby left a comment

Choose a reason for hiding this comment

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

Looks pretty good, most comments are related to the test setup and documentation rather than the actual library sources. That being said, the support for the library is pretty basic - I originally thought that we could design and maintain a DSL for the markup syntax itself. Something along these lines:

richText {
   red()
   +"This text is red! "
   clearColor()
   +"Now it's not."
}

I know that's a much larger undertaking, so if it's not something you'd want to work on, don't worry about it. I'm happy to merge this as is either way.

Anyway, I'd appreciate it if you looked into the default libGDX font or using the VisUI assets to avoid putting a skin atlas and the associated image in test resources before we merge this.

@michaeloa
Copy link
Author

Looks pretty good, most comments are related to the test setup and documentation rather than the actual library sources. That being said, the support for the library is pretty basic - I originally thought that we could design and maintain a DSL for the markup syntax itself.

I'm not averse to adding more stuff (I've customized my own code a fair bit, but mostly with handling styles, etc), but not sure I see the utility of a function DSL for formatting. After all, everything here is just strings.

richText { red()+"This text is red! "+clearColor()+"Now it's not." }

Would be:

textraLabel("[RED]This text is red! []Now it's not.")

I would argue that very little is gained by creating fun red() = "[RED]".

I'd almost say the opposite - [/] is a lot less characters than italic() - coding [] is a lot faster than clearColor(). To me, it would be a lot more useful to have some vals for frequently used styles - e.g., const val RED = "[RED]" - I've done that myself in my current project, but even for that I'm not convinced it makes sense to make that part of a library as opposed to the user simply defining the exact few such constants they require for their own project.

That is at least my thoughts based on my own usage, I feel like such an addition would obfuscate more than simplify usage. Not to mention that even within textratypist there are some differences between typinglabel and textralabel that I suspect would cause confusion.

@michaeloa
Copy link
Author

Ugh. Sorry about some of those changes - I've the ktlint checker auto-enabled in my IntelliJ, and it tends to go crazy about files that don't conform, even when one don't intent to change them. Will try to see if I can reset the pointless changes.

@czyzby
Copy link
Member

czyzby commented Nov 15, 2025

If we're looking strictly at the number of characters used, sure, there's not much to gain. However, the main goals of the DSL would be the compile-time checks and discoverability of the operations. A typo in a string template could result in runtime errors or invalid rendering that could be difficult to pick up or even validate with unit tests. DSL would mostly get rid of these errors by validating the syntax at compile time on top of providing code completion and listing of the supported tags.

Like I said though, it's not critical to add a DSL to get this merged. You're welcome to try if you'd like to design one, but I think there's value in this module as is.

@czyzby
Copy link
Member

czyzby commented Nov 15, 2025

By the way, the syntax I came up with is perhaps not the best for dealing with strings. I like your idea of overloading + or perhaps even doing a fluid API. Something like this could be interesting:

richText { red("This is red!") + " This is not." }

@michaeloa
Copy link
Author

Having a busy week, so not much time to fix the last few issues here. Will hopefully find some time in the weekend.

@czyzby
Copy link
Member

czyzby commented Nov 21, 2025

No worries, take your time. Thanks for looking into this!

@michaeloa michaeloa marked this pull request as ready for review November 22, 2025 17:12
@michaeloa
Copy link
Author

Think this is ready now.

Ktx and Textratypist are my two go-to libs for game development, so I'll try to set some time aside to add more later.

Copy link
Member

@czyzby czyzby left a comment

Choose a reason for hiding this comment

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

Thanks, this looks great. I'll try to sort out KTX dependencies next week and do a proper libGDX version bump so that we can use the latest TextraTypist release.

const val ashleyVersion = "1.7.4"
const val gdxAiVersion = "1.8.2"
const val visUiVersion = "1.5.5"
const val textraTypistVersion = "2.1.9" // Cannot upgrade to 2.2.x until gdx 1.14.x.
Copy link

@tommyettinger tommyettinger Jan 1, 2026

Choose a reason for hiding this comment

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

There's 2.1.11 out now (or 2.2.10 if you can use libGDX 1.14.0) and I just pushed a small bugfix release today, again! I've been backporting releases to 1.13.1 mostly so KTX users can still use TextraTypist. It isn't that hard to backport, I have it understood well now and it's pretty much one find+replace.

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.

3 participants