-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.BBCode
223 lines (146 loc) · 10.4 KB
/
README.BBCode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
[size=14pt][b][color=maroon]F[/color][color=hotpink]a[/color][color=navy]n[/color][color=purple]c[/color][color=limegreen]y[/color][/b][/size] [color=gray][b]version 0.7.5 [/b][/color]
[url="https://github.com/ericoporto/fancy/releases/download/v0.7.5/fancy.scm"]Get Latest Release [b]fancy.scm[/b][/url] | [url="https://github.com/ericoporto/fancy"]GitHub Repo[/url] | [url="https://github.com/ericoporto/fancy/releases/download/v0.7.5/fancy_demo_windows.zip"]Project with Demo![/url]
[url="https://github.com/ericoporto/fancy/actions"][img]https://github.com/ericoporto/fancy/actions/workflows/main.yml/badge.svg[/img][/url]
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.
[list]
[li]Color tag is [font=Courier New]"[c:123]"[/font] and [font=Courier New]"[/c]"[/font], where [font=Courier New]"123"[/font] is an ags color for the text.[/li]
[li]Outline color tag is [font=Courier New]"[o:123]"[/font] and [font=Courier New]"[/o]"[/font], where [font=Courier New]"123"[/font] is an ags color for the outline.[/li]
[li]Font tag is [font=Courier New]"[f:123]"[/font] and [font=Courier New]"[/f]"[/font], where [font=Courier New]"123"[/font] is an ags font index.[/li]
[li]Sprite tag is solo [font=Courier New]"[s:123]"[/font], where [font=Courier New]"123"[/font] is an ags sprite.[/li]
[/list]
[i]Note:[/i] use [font=Courier New]"\n"[/font] for linefeed, old lone [font=Courier New]"["[/font] 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.
[img width=640]https://i.imgur.com/w5olTxG.png[/img]
[hr]
[size=14pt][b]Usage[/b][/size]
I will improve this soon, for now some small examples
[i]Using a regular drawing surface:[/i]
[code]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);
}[/code]
[i]Simple not-useful typed text example:[/i]
[code]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);
}
}[/code]
[hr]
[size=14pt][b]Script API[/b][/size]
[spoiler]
[size=12pt][b]Script Extensions[/b][/size]
[font=Courier New][b]DrawingSurface.DrawFancyString[/b][/font]
[code]void DrawingSurface.DrawFancyString(int x, int y, const string text, optional FancyConfig* config, optional int width);[/code]
Draw the text from a fancy string on the drawing surface.
[font=Courier New][b]DynamicSprite.CreateFromFancyString[/b][/font]
[code]DynamicSprite* DynamicSprite.CreateFromFancyString(const string text, optional FancyConfig* config, optional width);[/code]
Create a sprite with the text of a fancy string
[font=Courier New][b]DynamicSprite.CreateFromFancyTextBox[/b][/font]
[code]DynamicSprite* DynamicSprite.CreateFromFancyTextBox(const string text, optional FancyConfig* config, optional width, optional Fancy9Piece* f9p);[/code]
Create a sprite of a textbox with a fancy string using a 9-piece.
[font=Courier New][b]Character.FancySay[/b][/font]
[code]void Character.FancySay( const string text, optional FancyConfig* config, optional int width, optional Fancy9Piece* f9p );[/code]
A Say alternative that support fancy strings
[font=Courier New][b]Character.FancySayTyped[/b][/font]
[code]void Character.FancySayTyped( const string text, optional FancyConfig* config, optional int width, optional Fancy9Piece* f9p );[/code]
A Say alternative that support fancy strings, it types it instead of readily drawing
[font=Courier New][b]Button.Fancify[/b][/font]
[code]void Button.Fancify(optional Fancy9Piece* normal, optional Fancy9Piece* mouse_over, optional Fancy9Piece* pushed);[/code]
Sets a button NormalGraphic and additional sprites from it's text, assumed as fancy string, and 9-piece.
[font=Courier New][b]Button.UnFancify[/b][/font]
[code]void Button.UnFancify();[/code]
Removes fancyness from button (clear any altered sprites)
[size=12pt][b]Fancy[/b][/size]
This is a global struct you can't instantiate, it contains static methods for global configuration meant to be used at game start.
[font=Courier New][b]Fancy.AddAlias[/b][/font]
[code]static void Fancy.AddAlias(String key, int value);[/code]
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.
[font=Courier New][b]Fancy.FancyConfig[/b][/font]
[code]static attribute FancyConfig* Fancy.FancyConfig;[/code]
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.
[size=12pt][b]Fancy9Piece[/b][/size]
This is a managed struct that holds a 9-piece that can be used for drawing text boxes.
[font=Courier New][b]Fancy9Piece.CreateFromTextWindowGui[/b][/font]
[code]static Fancy9Piece* Fancy9Piece.CreateFromTextWindowGui(GUI* text_window_gui);[/code]
Create a 9 piece fancy compatible from a Text Window GUI.
[font=Courier New][b]Fancy9Piece.CreateFrom9Sprites[/b][/font]
[code]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);[/code]
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.
[size=12pt][b]FancyConfig[/b][/size]
This is a managed struct meant to configure an instance from FancyTextBase and extensions, prefer using it's [font=Courier New]Create[/font] method.
[font=Courier New][b]FancyConfig.Create[/b][/font]
[code]static FancyConfig* FancyConfig.Create(FontType font, int color, int outline_color, int outline_width, Alignment align, int line_spacing);[/code]
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 [font=Courier New]COLOR_TRANSPARENT[/font] and outline width is initially set to 1, align is set to eAlignBottomLeft and line_spacing is 0.
[size=12pt][b]FancyTextBase[/b][/size]
[font=Courier New][b]FancyTextBase.SetDrawingArea[/b][/font]
[code]void FancyTextBase.SetDrawingArea(int x, int y, int width = FANCY_INFINITE_WIDTH);[/code]
Sets the area for drawing fancy text, specifying the position and width.
[font=Courier New][b]FancyTextBase.Text[/b][/font]
[code]attribute String FancyTextBase.Text;[/code]
Sets the text content for the fancy text, this is where the parsing of the text happens.
[font=Courier New][b]FancyTextBase.PlainText[/b][/font]
[code]attribute readonly String FancyTextBase.PlainText;[/code]
Get the set text without tags.
[font=Courier New][b]FancyTextBase.Draw[/b][/font]
[code]void FancyTextBase.Draw(DrawingSurface* surf);[/code]
Draws the fancy text on the specified drawing surface.
[font=Courier New][b]FancyTextBase.FancyConfig[/b][/font]
[code]attribute FancyConfig* FancyTextBase.FancyConfig;[/code]
Property to set the Fancy Text rendering configuration.
[size=12pt][b]FancyTextBox[/b][/size]
[font=Courier New][b]FancyTextBox.CreateTextBoxSprite[/b][/font]
[code]DynamicSprite* FancyTextBox.CreateTextBoxSprite();[/code]
Create a sprite of a textbox with a fancy string using the configured 9-piece
[font=Courier New][b]FancyTextBox.Fancy9Piece[/b][/font]
[code]atrribute Fancy9Piece* FancyTextBox.Fancy9Piece;[/code]
Setup the 9-piece for the Text Box creation.
[size=12pt][b]FancyTypedText[/b][/size]
[font=Courier New][b]FancyTypedText.Clear[/b][/font]
[code]void FancyTypedText.Clear();[/code]
Clears all text and resets everything for typed text.
[font=Courier New][b]FancyTypedText.Start[/b][/font]
[code]void FancyTypedText.Start(String text);[/code]
Sets a new string and resets everything to start typing. You can then use Tick repeatedly to advance the text.
[font=Courier New][b]FancyTypedText.Skip[/b][/font]
[code]void FancyTypedText.Skip();[/code]
Skips all remaining typing of the text.
[font=Courier New][b]FancyTypedText.Tick[/b][/font]
[code]void FancyTypedText.Tick();[/code]
Updates the typed text state, advancing it by a single tick.
[font=Courier New][b]FancyTypedText.DrawTyped[/b][/font]
[code]void FancyTypedText.DrawTyped(DrawingSurface* surf);[/code]
Draws the typed text in it's current state.
[font=Courier New][b]FancyTypedText.CreateTypedSprite[/b][/font]
[code]DynamicSprite* FancyTypedText.CreateTypedSprite();[/code]
Create a sprite of the text being typed.
[font=Courier New][b]FancyTypedText.IsTextBeingTyped[/b][/font]
[code]attribute readonly bool FancyTypedText.IsTextBeingTyped;[/code]
True if a text is being typed in the FancyTypedText, and not finished.
[/spoiler]
[hr]
[i][b]License[/b][/i]
This module is created by eri0o is provided with MIT License, see [url="https://github.com/ericoporto/fancy/blob/main/LICENSE"]LICENSE[/url] for more details.