CTR - Custom Text Renderer
Posted: Mon May 18, 2020 1:56 pm
I thought I'd post some of my Game Editor projects to the forums. Here's the first one.
CTR - Custom Text Renderer for Game Editor
An alternative way to render text in Game Editor.
This text renderer doesn't use Game Editor's built-in text actors at all, but instead, uses normal actors for displaying the text. Every character is a unique clone.
The system requires the fonts to be in an image format. For creating the font images and configuring the font settings (letter spacing, word spacing, line spacing and indentation) use the Font Tool that is provided together with the system.
Features
Getting started
Extract the contents of the .zip and merge the CTR_template.ged to your game. You may need to make sure that there is no name collisions between your game and the template, as the actors, variables and functions of the template are not prefixed in any way yet.
When working with the project in Game Editor, make sure to configure the key used for exiting the game in a_textHandler's KeyDown and KeyUp events to something you can easily press. This is to make sure that all the allocated memory is freed upon exiting the 'Game Mode'.
I can provide more detailed instructions on the usage of the system if requested to.
Supported escape sequences
Custom escape sequences
The system also includes some custom escape sequences. All these sequences start with '$'.
License
Yeah, there's a license among the files. That's just me trying to get to the good habit of adding licensing to open source projects. The license allows you to do pretty much anything with CTR. If you want to do things "the right way", just copy the license among the files of the project where you use CTR, rename the file to CTR-LICENSE and mention CTR and me as its creator in your game's credits. But I'm not going to sue anyone for not doing so, rest assured.
Lastly
If anyone wants to use this, I'm more than willing to help, should you run into any problems. Just comment on this thread, PM me or @lcl me on the GE Discord, whichever you fancy.
CTR - Custom Text Renderer for Game Editor
An alternative way to render text in Game Editor.
This text renderer doesn't use Game Editor's built-in text actors at all, but instead, uses normal actors for displaying the text. Every character is a unique clone.
The system requires the fonts to be in an image format. For creating the font images and configuring the font settings (letter spacing, word spacing, line spacing and indentation) use the Font Tool that is provided together with the system.
- Download (hosted on GitHub)
Contents:
- source code of the system
- 4 example .ged projects
- Font Tool for generating image fonts
- a template project that can be merged to other .ged projects
Also available on GitHub
Features
- Automatic text alignment (left / center / right)
- Automatic line wrapping (allows fitting text in an area of a given width)
- Custom color coding (allows rendering text in multiple colors)
- Fitting text in an area of a given size (allows fitting large paragraphs of text in small windows by using scrollable text)
- Optimized performance (text is only updated on request)
Getting started
Extract the contents of the .zip and merge the CTR_template.ged to your game. You may need to make sure that there is no name collisions between your game and the template, as the actors, variables and functions of the template are not prefixed in any way yet.
When working with the project in Game Editor, make sure to configure the key used for exiting the game in a_textHandler's KeyDown and KeyUp events to something you can easily press. This is to make sure that all the allocated memory is freed upon exiting the 'Game Mode'.
I can provide more detailed instructions on the usage of the system if requested to.
Supported escape sequences
- \n - normal line break, if automatic line wrapping is in use, this may be ignored
- \v - forced line break (actually stands for vertical tab, but has been repurposed here)
- \t - tabulation
Custom escape sequences
The system also includes some custom escape sequences. All these sequences start with '$'.
- $$ - prints a single '$'
- $_ - a non-breaking space, is not allowed to be replaced with a newline for line wrapping
- $c000000 - deploys color override: all following text will be rendered using the specified color
- Each pair of characters after c represents a hexadecimal value between 0-255, first pair is for red, second for green, last one for blue
- Example: $c00ffff is interpreted as (0, 255, 255) i.e. cyan
- Each pair of characters after c represents a hexadecimal value between 0-255, first pair is for red, second for green, last one for blue
- $x - a finishing escape sequence, the character after x determines what effect is to be finished
- $xc - stops color override: all following text will be rendered using the normal color of the text in question
License
Yeah, there's a license among the files. That's just me trying to get to the good habit of adding licensing to open source projects. The license allows you to do pretty much anything with CTR. If you want to do things "the right way", just copy the license among the files of the project where you use CTR, rename the file to CTR-LICENSE and mention CTR and me as its creator in your game's credits. But I'm not going to sue anyone for not doing so, rest assured.
Lastly
If anyone wants to use this, I'm more than willing to help, should you run into any problems. Just comment on this thread, PM me or @lcl me on the GE Discord, whichever you fancy.