Fancy version 0.7.5
Get Latest Release fancy.scm | GitHub Repo | Project with Demo!

Fancy is a Script module for "fancy" text in Adventure Game Studio, you can have text with multiple colors, fonts, with sprites and other. It brings it's own Typed-Text mechanism and additional fancyness.
The cheatsheet of tags are below. Some tags are "solo", they don't require a closing tag.
Note: use "\n" for linefeed, old lone "[" ags linefeed is not supported.
Notice that if you need to pass a number that is dynamic you can use String.Format to create the string with the proper number, like if the sprite icon you want to put in your text is from a dynamic sprite or the color of a word comes from a character speech color.

Usage
I will improve this soon, for now some small examples
Using a regular drawing surface:
Code: ags
Simple not-useful typed text example:
Code: ags
Script API
License
This module is created by eri0o is provided with MIT License, see LICENSE for more details.
Get Latest Release fancy.scm | GitHub Repo | Project with Demo!
Fancy is a Script module for "fancy" text in Adventure Game Studio, you can have text with multiple colors, fonts, with sprites and other. It brings it's own Typed-Text mechanism and additional fancyness.
The cheatsheet of tags are below. Some tags are "solo", they don't require a closing tag.
- Color tag is "[c:123]" and "[/c]", where "123" is an ags color for the text.
- Outline color tag is "[o:123]" and "[/o]", where "123" is an ags color for the outline.
- Font tag is "[f:123]" and "[/f]", where "123" is an ags font index.
- Sprite tag is solo "[s:123]", where "123" is an ags sprite.
Note: use "\n" for linefeed, old lone "[" ags linefeed is not supported.
Notice that if you need to pass a number that is dynamic you can use String.Format to create the string with the proper number, like if the sprite icon you want to put in your text is from a dynamic sprite or the color of a word comes from a character speech color.

Usage
I will improve this soon, for now some small examples
Using a regular drawing surface:
function room_AfterFadeIn()
{
Fancy.AddAlias("red", 64493); // this should be at game_start
DrawingSurface* surf = Room.GetDrawingSurfaceForBackground();
surf.DrawingColor = 10565;
surf.DrawRectangle(48, 48, 248, 108);
surf.DrawFancyString(48, 48, "Hello!\n[o:8560]Can you find me the [c:27647]blue cup [s:2041][/c][/o]?\nI lost it in the [c:red]dangerous [f:0]planet[/f][/c], somewhere.", FancyConfig.Create(eFontSpeech, 22422), 200);
}
Simple not-useful typed text example:
FancyTypedText fttb; // has to be global
function room_AfterFadeIn()
{
Fancy.AddAlias("red", 64493); // this should be at game_start
Fancy.AddAlias("ico_bcup", 2041); // this should be at game_start
fttb.FancyConfig.Font = eFontSpeech;
fttb.FancyConfig.TextColor = 22422;
fttb.SetDrawingArea(48, 40, 200);
fttb.Start("Hello!\n[o:8560]Can you find me the [c:27647]blue cup [s:ico_bcup][/c][/o]?\nI lost it in the [c:red]dangerous [f:0]planet[/f][/c], somewhere.");
}
void repeatedly_execute_always()
{
if(fttb.IsTextBeingTyped)
{
DrawingSurface* surf = Room.GetDrawingSurfaceForBackground();
surf.DrawingColor = 10565;
surf.DrawRectangle(48, 40, 248, 90);
fttb.DrawTyped(surf);
}
}
Script API
Spoiler
Script Extensions
DrawingSurface.DrawFancyString
Code: ags Draw the text from a fancy string on the drawing surface.
DynamicSprite.CreateFromFancyString
Code: ags Create a sprite with the text of a fancy string
DynamicSprite.CreateFromFancyTextBox
Code: ags Create a sprite of a textbox with a fancy string using a 9-piece.
Character.FancySay
Code: ags A Say alternative that support fancy strings
Character.FancySayTyped
Code: ags A Say alternative that support fancy strings, it types it instead of readily drawing
Button.Fancify
Code: ags Sets a button NormalGraphic and additional sprites from it's text, assumed as fancy string, and 9-piece.
Button.UnFancify
Code: ags Removes fancyness from button (clear any altered sprites)
Fancy
This is a global struct you can't instantiate, it contains static methods for global configuration meant to be used at game start.
Fancy.AddAlias
Code: ags
Allows adding a global alias to a tag-value. Ex: AddAlias("red", 63488) allows using [c:red] instead of [c:63488].
This may be useful if you want to be able to change your mind later on what is the specific of a color, or you want to have an easier type remembering sprite icons you are reusing in your texts.
Alias added here are global to all of Fancy. It's recommended that you only add an alias once to everything you need at the game_start of your project, make it easier to manage aliases.
Fancy.FancyConfig
Code: ags
This is the default global FancyConfig, if you don't specify or if you pass null to a method that requires a FancyConfig as parameter it will use this config instead.
Fancy9Piece
This is a managed struct that holds a 9-piece that can be used for drawing text boxes.
Fancy9Piece.CreateFromTextWindowGui
Code: ags Create a 9 piece fancy compatible from a Text Window GUI.
Fancy9Piece.CreateFrom9Sprites
Code: ags Create a 9 piece fancy from 9 sprite slots.
You can optionally pass a color instead of a sprite for the center piece, by passing 0 to center_piece and a valid ags color in bg_color.
FancyConfig
This is a managed struct meant to configure an instance from FancyTextBase and extensions, prefer using it's Create method.
FancyConfig.Create
Code: ags Configuration structure for fancy text drawing, allowing customization of font, text color, line spacing, and alignment.
By default, when using create, if you don't set, outline color is initially set for COLOR_TRANSPARENT and outline width is initially set to 1, align is set to eAlignBottomLeft and line_spacing is 0.
FancyTextBase
FancyTextBase.SetDrawingArea
Code: ags Sets the area for drawing fancy text, specifying the position and width.
FancyTextBase.Text
Code: ags Sets the text content for the fancy text, this is where the parsing of the text happens.
FancyTextBase.PlainText
Code: ags Get the set text without tags.
FancyTextBase.Draw
Code: ags Draws the fancy text on the specified drawing surface.
FancyTextBase.FancyConfig
Code: ags Property to set the Fancy Text rendering configuration.
FancyTextBox
FancyTextBox.CreateTextBoxSprite
Code: ags Create a sprite of a textbox with a fancy string using the configured 9-piece
FancyTextBox.Fancy9Piece
Code: ags Setup the 9-piece for the Text Box creation.
FancyTypedText
FancyTypedText.Clear
Code: ags Clears all text and resets everything for typed text.
FancyTypedText.Start
Code: ags Sets a new string and resets everything to start typing. You can then use Tick repeatedly to advance the text.
FancyTypedText.Skip
Code: ags Skips all remaining typing of the text.
FancyTypedText.Tick
Code: ags Updates the typed text state, advancing it by a single tick.
FancyTypedText.DrawTyped
Code: ags Draws the typed text in it's current state.
FancyTypedText.CreateTypedSprite
Code: ags Create a sprite of the text being typed.
FancyTypedText.IsTextBeingTyped
Code: ags True if a text is being typed in the FancyTypedText, and not finished.
DrawingSurface.DrawFancyString
void DrawingSurface.DrawFancyString(int x, int y, const string text, optional FancyConfig* config, optional int width);
DynamicSprite.CreateFromFancyString
DynamicSprite* DynamicSprite.CreateFromFancyString(const string text, optional FancyConfig* config, optional width);
DynamicSprite.CreateFromFancyTextBox
DynamicSprite* DynamicSprite.CreateFromFancyTextBox(const string text, optional FancyConfig* config, optional width, optional Fancy9Piece* f9p);
Character.FancySay
void Character.FancySay( const string text, optional FancyConfig* config, optional int width, optional Fancy9Piece* f9p );
Character.FancySayTyped
void Character.FancySayTyped( const string text, optional FancyConfig* config, optional int width, optional Fancy9Piece* f9p );
Button.Fancify
void Button.Fancify(optional Fancy9Piece* normal, optional Fancy9Piece* mouse_over, optional Fancy9Piece* pushed);
Button.UnFancify
void Button.UnFancify();
Fancy
This is a global struct you can't instantiate, it contains static methods for global configuration meant to be used at game start.
Fancy.AddAlias
static void Fancy.AddAlias(String key, int value);
Allows adding a global alias to a tag-value. Ex: AddAlias("red", 63488) allows using [c:red] instead of [c:63488].
This may be useful if you want to be able to change your mind later on what is the specific of a color, or you want to have an easier type remembering sprite icons you are reusing in your texts.
Alias added here are global to all of Fancy. It's recommended that you only add an alias once to everything you need at the game_start of your project, make it easier to manage aliases.
Fancy.FancyConfig
static attribute FancyConfig* Fancy.FancyConfig;
This is the default global FancyConfig, if you don't specify or if you pass null to a method that requires a FancyConfig as parameter it will use this config instead.
Fancy9Piece
This is a managed struct that holds a 9-piece that can be used for drawing text boxes.
Fancy9Piece.CreateFromTextWindowGui
static Fancy9Piece* Fancy9Piece.CreateFromTextWindowGui(GUI* text_window_gui);
Fancy9Piece.CreateFrom9Sprites
static Fancy9Piece* Fancy9Piece.CreateFrom9Sprites(int top , int bottom, int left, int right, int top_left, int top_right, int bottom_left, int bottom_right, int center_piece = 0, int bg_color = 0);
You can optionally pass a color instead of a sprite for the center piece, by passing 0 to center_piece and a valid ags color in bg_color.
FancyConfig
This is a managed struct meant to configure an instance from FancyTextBase and extensions, prefer using it's Create method.
FancyConfig.Create
static FancyConfig* FancyConfig.Create(FontType font, int color, int outline_color, int outline_width, Alignment align, int line_spacing);
By default, when using create, if you don't set, outline color is initially set for COLOR_TRANSPARENT and outline width is initially set to 1, align is set to eAlignBottomLeft and line_spacing is 0.
FancyTextBase
FancyTextBase.SetDrawingArea
void FancyTextBase.SetDrawingArea(int x, int y, int width = FANCY_INFINITE_WIDTH);
FancyTextBase.Text
attribute String FancyTextBase.Text;
FancyTextBase.PlainText
attribute readonly String FancyTextBase.PlainText;
FancyTextBase.Draw
void FancyTextBase.Draw(DrawingSurface* surf);
FancyTextBase.FancyConfig
attribute FancyConfig* FancyTextBase.FancyConfig;
FancyTextBox
FancyTextBox.CreateTextBoxSprite
DynamicSprite* FancyTextBox.CreateTextBoxSprite();
FancyTextBox.Fancy9Piece
atrribute Fancy9Piece* FancyTextBox.Fancy9Piece;
FancyTypedText
FancyTypedText.Clear
void FancyTypedText.Clear();
FancyTypedText.Start
void FancyTypedText.Start(String text);
FancyTypedText.Skip
void FancyTypedText.Skip();
FancyTypedText.Tick
void FancyTypedText.Tick();
FancyTypedText.DrawTyped
void FancyTypedText.DrawTyped(DrawingSurface* surf);
FancyTypedText.CreateTypedSprite
DynamicSprite* FancyTypedText.CreateTypedSprite();
FancyTypedText.IsTextBeingTyped
attribute readonly bool FancyTypedText.IsTextBeingTyped;
[close]
License
This module is created by eri0o is provided with MIT License, see LICENSE for more details.