Jump to content


Photo
- - - - -

Fancy-Pants Text Engine (typewriter + formatting + autosizing)


  • Please log in to reply
3 replies to this topic

#1 Juju

Juju

    GMC Member

  • GMC Member
  • 1109 posts
  • Version:Unknown

Posted 30 November 2015 - 12:15 AM

  • Title: Juju's Text Engine v3 "Fancy Pants"
  • Description: A comprehensive text-drawing system allowing for character-by-character display, human-readable formatting, and autosizing to text box widths
  • GM Version: GMS
  • File type: .gmz
  • File size: 110kb
  • File link: Click Me
  • Required Extensions: None
  • Required DLLs: None

The only other text engines I could find were either a decade old, used rigid non-human-readable formatting, were designed around re-parsing text every frame, or relied upon a number of legacy functions that are no longer support in GM:S. So I made my own! All the features are turn-offable so it's deployable for a lot of situations.

 

This example is left as pure, simple text drawing. This isn't a dialogue engine, simply a robust method that takes input and plonks it on the screen. Since it makes no assumptions about use, this is an easy script to implement. Text is drawn to the screen by calling a single script (scr_juju_text) that pre-parses the input string and creates a container instance that handles drawing. This instance, when destroyed, also cleans up the data structures created by the parsing process. It's all encapsulated and neat and tidy.

 

At the moment, formatting is limited to font and colours. As a developer, you can add new definitions for tags by editing the contents of scr_juju_text_formatting. Inside is a simple switch statement with a bunch of presets that should help guide you in creating new styles. Quick word on alignment - the scripts assume you'll be using the GM standard text alignment of top and left. I may add alignment features if there's demand.


Edited by Juju, 10 December 2015 - 01:53 AM.

  • 1

Come find me @jujuadams

 

Try out my open-source 3D globe terrain generator!

How about a fancy-pants text engine?

Adding dialogue boxes to your games is now super easy. Also localisation. Also tweening.


#2 chance

chance

    GMC Member

  • Global Moderators
  • 8762 posts
  • Version:GM:Studio

Posted 30 November 2015 - 12:41 AM

Nice example.   I've only gone though it quickly so far, but it's a good example of string parsing with built-in formatting tags.   And even for members who don't need this level of versatility, I'd still recommend having a look to see how this is done.  It's worth the time.

 

Nice job on this.


  • 0

#3 LurchBrick

LurchBrick

    GMC Member

  • GMC Member
  • 141 posts

Posted 01 December 2015 - 08:21 AM

Nice work. I'd love to see you add more alignment features.


  • 0

#4 Juju

Juju

    GMC Member

  • GMC Member
  • 1109 posts
  • Version:Unknown

Posted 10 December 2015 - 11:41 AM

Working on version 4 now, codename "Frilly Knickers".


  • 0

Come find me @jujuadams

 

Try out my open-source 3D globe terrain generator!

How about a fancy-pants text engine?

Adding dialogue boxes to your games is now super easy. Also localisation. Also tweening.