I'm using pyglet to make a game. At some point, this game will have an in-game help/reference to some "core" RPG rules, plus descriptions and such (the game uses Pathfinder SRD). So there are long formatted texts (with different sizes, colors, etc.). An example of the style I'm aiming to provide (further formatting will be made): In-game SRD
Currently I'm using pyglet's formatted document model (plain text with a few python generated fields for style/formatting):
"""
{font_name 'Fontin'}{.align "center"}{bold True}{font_size 28}{italic True}{indent 0}{color (128,144,160, 223)}
The Title
{.align "left"}{bold False}{font_size 12}
Huge amount of text with further reformatting goes here...
And ends with a copyright notice (section 15 of OGL).
"""
- If I store the texts in json (under specific keys for class, race, etc.), this one-time processing may take a few seconds; storing text in the body of a .py (such as this one, with 5k lines), within a dictionary, is worth it, any reason not to do it?
- Decoding during runtime using
pyglet.text.decode_attributed
takes some time. But considering that when done the game reference will have maybe a hundred 'pages', decoding before runtime (decode the whole dictionary or json) would take a great amount of pre-game time spent. So pre-decode, or decode on fly (which means that some texts, if I don't make an efficient code, could be redundantly recoded)? Threads are not reliable on pyglet... - Rendering and later switching the content of the
pyglet.text.layout.ScrollableTextLayout
document takes 1-2 seconds on big chunks of text, more if the text is not previously decoded; - Or maybe there any other libraries that could be used to render text on pyglet's context (with some adjustments)... Consider, however, that in the current format I'm able to both show the whole stuff on a "Reference" view or extract little amounts of text from it for a tooltip, for example...
- Some final considerations: performance matters here as I'm aiming at low-spec machines. The game will be a graphical roguelike / 2d rpg, requiring more than libtcod/curses, but no 3d graphics, thats why I'm using pyglet for now. But the formatted text aspect, specifically, is troubling me.