So I've been planning an engine for a game I'm making, writing up a number of design documents and stuff before actually coding anything. The engine I'm writing is modular, and I'm just starting on the text engine. I've already written the inputmanager as practically all the other managers rely on the inputmanager for input.
What I've got so far is by no means a complete and concise list of features, however I think I've got all I need for a flexible text engine.
The one problem I'm having however is how I'll go about managing the arrays that deal with colour codes, icons and so forth. I'm not sure whether to combine all these into a single 2d array with one row for colours, another for icons etc or if I should keep each type as a seperate 1d array. With the inputmanager I've only used one 2d array for the keycodes in one row and their pressed state in the other. What do you think would be better?
Below is my current design:
The dialog manager will support:
• Dialog
• Letter-by-letter scrolling
• Instant scrolling
• Automatic smart line breaking
• Sound effects (triggered via the SE manager)
• Opcodes
• Multiple languages
The game will pause for dialog. 2 surfaces will be used for drawing the textbox, one being the background and the other being the text. Selectors and continuation arrows will be drawn as sprites.
Opcodes allow things like colour changes, icons and such to be linked into the text for rich and dynamic dialog. A list of the codes are as follows:
• / - Allows the use of a special character to show up as text rather than being translated into an operation. Should not override colour codes.
• % - Newline character for forcing line breaks.
• #000 - Sets the text to a colour until another colour code or #\ to return to the script default. Colours are defined in an array which the code references the number of the colour from. Because of the way this script works, all sprite fonts must be plain white only. Must ignore icons as they should not be colourized.
• $000 - Uses the icon font to place an icon in the text. Can be used to give a visual representation of a required quest item, for example. The number is the subimage of the icon font.
• @NAME References a variable or string and displays the resulting value/string.
• ~SENAME triggers an SE when the dialog reaches this tag. To avoid SE overload in case of the player instant scrolling the text, only one of these should be used per dialog script call.
Each GM script can contain a max of 16 arguments, starting from 0.
A single string of dialog passed through the main text() script should use these arguments:
• 0 - The text string.
• 1 - The script to use for the type of textbox which includes things like placement on screen, background, default text colouring, font sprite, language etc.
• 2 - The number of choices available to the player, can be left blank if the dialog is not a question.
• 3 - Whether the player can opt-out (cancel) making a choice.
• 4-11 - In pairs. These are the names of choices and the scripts that are activated when a choice is chosen. The text displayed for the choice can contain opcodes and should therefore go through the dialog parser before drawing. Choices will only show if argument2 contains the correct number of choices avaliable. If no choice is selected (and if cancelling is allowed) -1 is returned, and the dialog script continues.