diff --git a/README.md b/README.md index 74f680194..4f6cb8c41 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -

Scribble 5.3.3

+

Scribble 5.4.3

-

Download .yymp here

+

Download .yymp here

### @jujuadams Vertex buffer-based text engine. Faster and more comprehensive than GameMaker's native rendering. Shader-based processing allows for efficient and flexible dynamic effects without lots of expensive CPU-side draw_text() calls. -[Find out what's changed](https://github.com/JujuAdams/scribble/blob/dev/changes.md) since version 4.x.x. [A "lite" version is also available](https://github.com/JujuAdams/scribble/tree/lite). +[Find out what's changed](https://github.com/JujuAdams/scribble/blob/dev/changes.md) since version 4.x.x. With thanks to glitchroy, Mark Turner, DragoniteSpam, sp202, Rob van Saaze, soVes, and @stoozey_ for testing. @@ -20,7 +20,7 @@ GameMaker Studio 2.2.3 allows you to import assets, including scripts and shader **How do I set up Scribble?** -Scribble is made from 15 mandatory scripts and a shader. There are 10 optional scripts that unlock more advanced functionality, though they're not needed for basic use. The ["Lite" version](https://github.com/JujuAdams/scribble/tree/lite)() skips out the optional scripts which handle automatic typewriter effects, events, and various nuts-and-bolts options that are useful but not essential. +Scribble is made from 15 mandatory scripts and a shader. There are 17 extra scripts that unlock more advanced functionality, though they're not needed for basic use. The ["Lite" version](https://github.com/JujuAdams/scribble/tree/lite)() skips out the optional scripts which handle automatic typewriter effects, events, and various nuts-and-bolts options that are useful but not essential. Scribble requires that you explicitly initialise fonts for use with Scribble. This is a three-step process: diff --git a/Scribble.yyp b/Scribble.yyp index 0a2e42daa..4f66513f3 100644 --- a/Scribble.yyp +++ b/Scribble.yyp @@ -46,6 +46,14 @@ "resourceType": "GMFolder" } }, + { + "Key": "04acbfcf-ee17-4ded-b194-17bb72864ff0", + "Value": { + "id": "ca6c936c-b344-4af6-b6a4-9d859b39daaf", + "resourcePath": "scripts\\scribble_page_get\\scribble_page_get.yy", + "resourceType": "GMScript" + } + }, { "Key": "0983f652-6ae8-4dd0-b1df-11881acb290e", "Value": { @@ -286,6 +294,14 @@ "resourceType": "GMObject" } }, + { + "Key": "6e8352fc-78a8-490a-a4ab-9dacbaeb79f5", + "Value": { + "id": "76fa070b-8e2e-40b2-8d13-e714ed7540fb", + "resourcePath": "scripts\\scribble_page_set\\scribble_page_set.yy", + "resourceType": "GMScript" + } + }, { "Key": "70d306e8-47c9-45bd-95c7-4f4fafd7f3d1", "Value": { @@ -302,6 +318,14 @@ "resourceType": "GMFolder" } }, + { + "Key": "74d4828d-df60-4163-9a0f-713e1e653208", + "Value": { + "id": "4c990981-3742-44f0-9749-f5a58ddb3ae2", + "resourcePath": "scripts\\scribble_page_on_last\\scribble_page_on_last.yy", + "resourceType": "GMScript" + } + }, { "Key": "75ac291e-7061-4bcb-8e8a-3b3545332d41", "Value": { @@ -358,6 +382,14 @@ "resourceType": "GMFolder" } }, + { + "Key": "8419d4f0-d03e-4d98-8b9d-93e9ec832104", + "Value": { + "id": "de2a6485-db78-477b-a060-eb3f9a09b010", + "resourcePath": "scripts\\scribble_autotype_skip\\scribble_autotype_skip.yy", + "resourceType": "GMScript" + } + }, { "Key": "8427047f-9ef8-4c77-89f3-9c20623d07b6", "Value": { @@ -382,6 +414,14 @@ "resourceType": "GMScript" } }, + { + "Key": "85d381bf-3af3-491c-b197-63da24f6696b", + "Value": { + "id": "b71ff74b-680e-45a9-9d65-f6baf2da84d4", + "resourcePath": "views\\85d381bf-3af3-491c-b197-63da24f6696b.yy", + "resourceType": "GMFolder" + } + }, { "Key": "88f27f62-071a-4441-b908-675e356b8173", "Value": { @@ -502,6 +542,14 @@ "resourceType": "GMAmazonFireOptions" } }, + { + "Key": "a39a04ab-7eab-45b9-a5ac-dd51dc752f37", + "Value": { + "id": "1de702d8-9cec-4c5e-9d74-783e40a9a8eb", + "resourcePath": "views\\a39a04ab-7eab-45b9-a5ac-dd51dc752f37.yy", + "resourceType": "GMFolder" + } + }, { "Key": "a3d9edc7-bc39-46f3-b8c2-98bcc058ea2c", "Value": { @@ -582,6 +630,14 @@ "resourceType": "GMScript" } }, + { + "Key": "b7157de4-28d8-476e-b907-27576e4c9261", + "Value": { + "id": "aeb78a3e-1af2-4972-8be0-a37003b58052", + "resourcePath": "scripts\\scribble_page_count\\scribble_page_count.yy", + "resourceType": "GMScript" + } + }, { "Key": "b9c3b946-515e-4f7f-8f0e-687f9b63de18", "Value": { @@ -825,9 +881,14 @@ "0b7de2e4-423b-4049-ae3c-cefbec9a47a6", "59086829-c42b-46bc-b263-7ed41965b63c", "beea2a2b-8233-44bc-9d9d-0dfc652a6bd0", + "8419d4f0-d03e-4d98-8b9d-93e9ec832104", "24adc709-497e-43cb-9834-a1a8664cbe74", - "a3d9edc7-bc39-46f3-b8c2-98bcc058ea2c", "498aa41e-7fb7-49e3-b663-74ba62e7a8e6", + "a3d9edc7-bc39-46f3-b8c2-98bcc058ea2c", + "6e8352fc-78a8-490a-a4ab-9dacbaeb79f5", + "04acbfcf-ee17-4ded-b194-17bb72864ff0", + "b7157de4-28d8-476e-b907-27576e4c9261", + "74d4828d-df60-4163-9a0f-713e1e653208", "6646aeb5-5c20-419d-af6d-8d625871911d", "88f27f62-071a-4441-b908-675e356b8173", "69d1d72f-5451-469e-a947-62f1a426ec6b", diff --git a/objects/obj_example_autotype/Create_0.gml b/objects/obj_example_autotype/Create_0.gml index 0f124372b..2110baa36 100644 --- a/objects/obj_example_autotype/Create_0.gml +++ b/objects/obj_example_autotype/Create_0.gml @@ -6,10 +6,10 @@ var _mapstring = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 scribble_add_spritefont("spr_sprite_font", _mapstring, 0, 3); //Add some colour definitions that we'll use in the demo string -scribble_add_colour("c_coquelicot", $ff3800); -scribble_add_colour("c_smaragdine", $50c875); -scribble_add_colour("c_xanadu" , $738678); -scribble_add_colour("c_amaranth" , $e52b50); +scribble_add_color("c_coquelicot", $ff3800); +scribble_add_color("c_smaragdine", $50c875); +scribble_add_color("c_xanadu" , $738678); +scribble_add_color("c_amaranth" , $e52b50); scribble_autotype_add_event("test event", example_event); @@ -19,7 +19,7 @@ scribble_autotype_add_event("test event", example_event); var _demo_string = "[rainbow][pulse]abcdef[] ABCDEF[test event]##"; _demo_string += "[wave][c_orange]0123456789[] .,<>\"'&[c_white][spr_coin,0][spr_coin,1][spr_coin,2][spr_coin,3][shake][rainbow]!?[]\n"; _demo_string += "[fa_centre][spr_coin][spr_coin][spr_coin][spr_large_coin][test event]\n"; - _demo_string += "[spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; + _demo_string += "[fa_left][spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; _demo_string += "[fnt_test_0][fa_right]THE [fnt_test_1][#ff4499][shake]QUICK[fnt_test_0] [$D2691E]BROWN [$FF4499]FOX [fa_left]JUMPS OVER[$FFFF00] THE [/shake]LAZY [fnt_test_1][wobble]DOG[/wobble]."; element = scribble_draw(x - 150, y - 80, _demo_string); diff --git a/objects/obj_example_autotype__/Create_0.gml b/objects/obj_example_autotype__/Create_0.gml index 256ac5b53..5ddf3c828 100644 --- a/objects/obj_example_autotype__/Create_0.gml +++ b/objects/obj_example_autotype__/Create_0.gml @@ -3,10 +3,10 @@ scribble_init("Fonts", "fnt_test_0", true); var _mapstring = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.-;:_+-*/\\'\"!?~^°<>|(){[]}%&=#@$ÄÖÜäöüß"; scribble_add_spritefont("spr_sprite_font", _mapstring, 0, 3); -scribble_add_colour("c_coquelicot", $ff3800); -scribble_add_colour("c_smaragdine", $50c875); -scribble_add_colour("c_xanadu" , $738678); -scribble_add_colour("c_amaranth" , $e52b50); +scribble_add_color("c_coquelicot", $ff3800); +scribble_add_color("c_smaragdine", $50c875); +scribble_add_color("c_xanadu" , $738678); +scribble_add_color("c_amaranth" , $e52b50); scribble_autotype_add_event("test event", example_event); @@ -14,9 +14,10 @@ scribble_autotype_add_event("test event", example_event); var _demo_string = "[rainbow][pulse]abcdef[] ABCDEF[test event]##"; _demo_string += "[wave][c_orange]0123456789[] .,<>\"'&[c_white][spr_coin,0][spr_coin,1][spr_coin,2][spr_coin,3][shake][rainbow]!?[]\n"; - _demo_string += "[fa_centre][spr_coin][spr_coin][spr_coin][spr_coin]\n"; - _demo_string += "[spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; - _demo_string += "[fnt_test_0][fa_right]THE [fnt_test_1][#ff4499][shake]QUICK[fnt_test_0] [$D2691E]BROWN [$FF4499]FOX [fa_left]JUMPS OVER[$FFFF00] THE [/shake]LAZY [fnt_test_1][wobble]DOG[/wobble].[test event][test event] [test event]"; + _demo_string += "[fa_centre][spr_coin][spr_coin][spr_coin][spr_large_coin][test event]\n"; + _demo_string += "[fa_left][spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; + _demo_string += "[fnt_test_0][fa_right]THE [fnt_test_1][#ff4499][shake]QUICK[fnt_test_0] [$D2691E]BROWN [$FF4499]FOX [fa_left]JUMPS OVER[$FFFF00] THE [/shake]LAZY [fnt_test_1][wobble]DOG[/wobble]."; element = scribble_draw(x - 150, y - 80, _demo_string); -scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_CHARACTER, 0.5, 0); \ No newline at end of file +scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_CHARACTER, 0.5, 0); +scribble_autotype_set_sound(element, [snd_vowel_0, snd_vowel_1, snd_vowel_2, snd_vowel_3, snd_vowel_4], 30); \ No newline at end of file diff --git a/objects/obj_example_basic/Draw_0.gml b/objects/obj_example_basic/Draw_0.gml index 33fbb2083..8cfe4ae7f 100644 --- a/objects/obj_example_basic/Draw_0.gml +++ b/objects/obj_example_basic/Draw_0.gml @@ -1,7 +1,7 @@ var _demo_string = "[rainbow][pulse]abcdef[] ABCDEF##"; _demo_string += "[wave][c_orange]0123456789[] .,<>\"'&[c_white][spr_coin,0][spr_coin,1][spr_coin,2][spr_coin,3][shake][rainbow]!?[]\n"; _demo_string += "[fa_centre][spr_coin][spr_coin][spr_coin][spr_large_coin][fa_left]\n"; - _demo_string += "[spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; + _demo_string += "[fa_left][spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; _demo_string += "[fnt_test_0][fa_right]THE [fnt_test_1][#ff4499][shake]QUICK[fnt_test_0] [$D2691E]BROWN [$FF4499]FOX [fa_left]JUMPS OVER[$FFFF00] THE [/shake]LAZY [fnt_test_1][wobble]DOG[/wobble]."; //Draw the string diff --git a/objects/obj_example_basic__/Draw_0.gml b/objects/obj_example_basic__/Draw_0.gml index 27419bd06..cb488e859 100644 --- a/objects/obj_example_basic__/Draw_0.gml +++ b/objects/obj_example_basic__/Draw_0.gml @@ -1,7 +1,7 @@ var _demo_string = "[rainbow][pulse]abcdef[] ABCDEF##"; _demo_string += "[wave][c_orange]0123456789[] .,<>\"'&[c_white][spr_coin,0][spr_coin,1][spr_coin,2][spr_coin,3][shake][rainbow]!?[]\n"; - _demo_string += "[fa_centre][spr_coin][spr_coin][spr_coin][spr_coin]\n"; - _demo_string += "[spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; + _demo_string += "[fa_centre][spr_coin][spr_coin][spr_coin][spr_large_coin][fa_left]\n"; + _demo_string += "[fa_left][spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; _demo_string += "[fnt_test_0][fa_right]THE [fnt_test_1][#ff4499][shake]QUICK[fnt_test_0] [$D2691E]BROWN [$FF4499]FOX [fa_left]JUMPS OVER[$FFFF00] THE [/shake]LAZY [fnt_test_1][wobble]DOG[/wobble]."; scribble_draw(x - 150, y - 80, _demo_string); \ No newline at end of file diff --git a/objects/obj_example_precache/Create_0.gml b/objects/obj_example_precache/Create_0.gml index 1b1a26a8c..36bcdf283 100644 --- a/objects/obj_example_precache/Create_0.gml +++ b/objects/obj_example_precache/Create_0.gml @@ -6,10 +6,10 @@ var _mapstring = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 scribble_add_spritefont("spr_sprite_font", _mapstring, 0, 3); //Add some colour definitions -scribble_add_colour("c_coquelicot", $ff3800); -scribble_add_colour("c_smaragdine", $50c875); -scribble_add_colour("c_xanadu" , $738678); -scribble_add_colour("c_amaranth" , $e52b50); +scribble_add_color("c_coquelicot", $ff3800); +scribble_add_color("c_smaragdine", $50c875); +scribble_add_color("c_xanadu" , $738678); +scribble_add_color("c_amaranth" , $e52b50); //Some characters need a bit of fine adjustment in code since it's not always possible to fix this in the font itself scribble_set_glyph_property("spr_sprite_font", "f", SCRIBBLE_GLYPH.SEPARATION, -1, true); @@ -21,8 +21,8 @@ scribble_autotype_add_event("sound", example_event_sound); var _demo_string = "[sound,snd_crank][rainbow][pulse]abcdef[] ABCDEF##"; _demo_string += "[wave][c_orange]0123456789[] .,<>\"'&[c_white][spr_coin,0][sound,snd_switch][spr_coin,1][sound,snd_switch][spr_coin,2][sound,snd_switch][spr_coin,3][sound,snd_switch][][shake][rainbow]!?[]\n"; - _demo_string += "[spr_coin][spr_coin,1,0.1][spr_coin,2,0.1][spr_large_coin,3,0.1]\n"; - _demo_string += "[spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; + _demo_string += "[fa_center][spr_coin][spr_coin,1,0.1][spr_coin,2,0.1][spr_large_coin,3,0.1][]\n"; + _demo_string += "[fa_left][spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; _demo_string += "[fnt_test_0][fa_right]THE [fnt_test_1][#ff4499][shake]QUICK[fnt_test_0] [$D2691E]BROWN [$FF4499]FOX [fa_left]JUMPS OVER[$FFFF00] THE [/shake]LAZY [fnt_test_1][wobble]DOG[/wobble]."; //Now parse the string to make some Scribble data diff --git a/objects/obj_example_precache__/Create_0.gml b/objects/obj_example_precache__/Create_0.gml index 802642f2f..b2c001641 100644 --- a/objects/obj_example_precache__/Create_0.gml +++ b/objects/obj_example_precache__/Create_0.gml @@ -1,26 +1,27 @@ -//Setup scribble_init("Fonts", "fnt_test_0", true); var _mapstring = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.-;:_+-*/\\'\"!?~^°<>|(){[]}%&=#@$ÄÖÜäöüß"; scribble_add_spritefont("spr_sprite_font", _mapstring, 0, 3); -scribble_add_colour("c_coquelicot", $ff3800); -scribble_add_colour("c_smaragdine", $50c875); -scribble_add_colour("c_xanadu" , $738678); -scribble_add_colour("c_amaranth" , $e52b50); +scribble_add_color("c_coquelicot", $ff3800); +scribble_add_color("c_smaragdine", $50c875); +scribble_add_color("c_xanadu" , $738678); +scribble_add_color("c_amaranth" , $e52b50); scribble_set_glyph_property("spr_sprite_font", "f", SCRIBBLE_GLYPH.SEPARATION, -1, true); scribble_set_glyph_property("spr_sprite_font", "q", SCRIBBLE_GLYPH.SEPARATION, -1, true); +scribble_autotype_add_event("sound", example_event_sound); -//Create the text element -var _demo_string = "[rainbow][pulse]abcdef[] ABCDEF##"; - _demo_string += "[wave][c_orange]0123456789[] .,<>\"'&[c_white][spr_coin,0][spr_coin,1][spr_coin,2][spr_coin,3][][shake][rainbow]!?[]\n"; - _demo_string += "[spr_coin][spr_coin,1,0.1][spr_coin,2,0.1][spr_large_coin,3,0.1]\n"; - _demo_string += "[spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; + +var _demo_string = "[sound,snd_crank][rainbow][pulse]abcdef[] ABCDEF##"; + _demo_string += "[wave][c_orange]0123456789[] .,<>\"'&[c_white][spr_coin,0][sound,snd_switch][spr_coin,1][sound,snd_switch][spr_coin,2][sound,snd_switch][spr_coin,3][sound,snd_switch][][shake][rainbow]!?[]\n"; + _demo_string += "[fa_center][spr_coin][spr_coin,1,0.1][spr_coin,2,0.1][spr_large_coin,3,0.1][]\n"; + _demo_string += "[fa_left][spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; _demo_string += "[fnt_test_0][fa_right]THE [fnt_test_1][#ff4499][shake]QUICK[fnt_test_0] [$D2691E]BROWN [$FF4499]FOX [fa_left]JUMPS OVER[$FFFF00] THE [/shake]LAZY [fnt_test_1][wobble]DOG[/wobble]."; scribble_draw_set_cache_group("example cache group", false, false); -scribble = scribble_draw(0, 0, _demo_string); +element = scribble_draw(0, 0, _demo_string); + scribble_draw_reset(); \ No newline at end of file diff --git a/objects/obj_example_precache__/Draw_0.gml b/objects/obj_example_precache__/Draw_0.gml index e22eb7464..910d20c06 100644 --- a/objects/obj_example_precache__/Draw_0.gml +++ b/objects/obj_example_precache__/Draw_0.gml @@ -1,7 +1,8 @@ scribble_draw_set_box_align(fa_center, fa_middle); -scribble_draw(x, y, scribble); -var _bbox = scribble_get_bbox(scribble, x, y, 5, 5, 5, 5); -scribble_draw_reset(); +scribble_draw(x, y, element); +var _bbox = scribble_get_bbox(element, x, y, 5, 5, 5, 5); draw_rectangle(_bbox[SCRIBBLE_BBOX.L], _bbox[SCRIBBLE_BBOX.T], - _bbox[SCRIBBLE_BBOX.R], _bbox[SCRIBBLE_BBOX.B], true); \ No newline at end of file + _bbox[SCRIBBLE_BBOX.R], _bbox[SCRIBBLE_BBOX.B], true); + +scribble_draw_reset(); \ No newline at end of file diff --git a/objects/obj_test/Create_0.gml b/objects/obj_test/Create_0.gml index 995593c88..1990eca18 100644 --- a/objects/obj_test/Create_0.gml +++ b/objects/obj_test/Create_0.gml @@ -2,10 +2,10 @@ scribble_init("Fonts", "fnt_test_0", true); var _mapstring = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.-;:_+-*/\\'\"!?~^°<>|(){[]}%&=#@$ÄÖÜäöüß"; scribble_add_spritefont("spr_sprite_font", _mapstring, 0, 11); -scribble_add_colour("c_coquelicot", $ff3800); -scribble_add_colour("c_smaragdine", $50c875); -scribble_add_colour("c_xanadu" , $738678); -scribble_add_colour("c_amaranth" , $e52b50); +scribble_add_color("c_coquelicot", $ff3800); +scribble_add_color("c_smaragdine", $50c875); +scribble_add_color("c_xanadu" , $738678); +scribble_add_color("c_amaranth" , $e52b50); scribble_autotype_add_event("pause", example_pause); @@ -17,21 +17,24 @@ var _mapstring = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 test_string = "The Quick Brown Fox Jumps Over The Lazy Dog!"; spritefont = font_add_sprite_ext(spr_sprite_font, _mapstring, true, 0); -demo_string = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; -demo_string += "[rainbow][pulse]TEST[] [slant]AaBbCcDdEeFf[/slant]##"; -demo_string += "a b c d e f g h i j k l m n o p q r s t u v w x y z\n\n"; -demo_string += "[wave][c_orange]0123456789[] .,<>\"'&[c_white][spr_coin,0][spr_coin,1][spr_coin,2][spr_coin,3][][shake][rainbow]!?[]\n"; -demo_string += "[spr_coin][spr_coin,1,0.1][spr_coin,2,0.1][spr_large_coin,3,0.1] \n"; -demo_string += "[spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; -demo_string += "[fnt_test_0][fa_right]THE [fnt_test_1][#ff4499][shake]QUICK[fnt_test_0] [$D2691E]BROWN [$FF4499]FOX [fa_left]JUMPS OVER[$FFFF00] [/shake]THE LAZY [fnt_test_1][wobble]DOG[/wobble]."; -demo_string += "##[fnt_test_2][c_black]TESTING"; +//demo_string = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; +//demo_string += "[rainbow][pulse]TEST[] [slant]AaBbCcDdEeFf[/slant]##"; +//demo_string += "a b c d e f g h i j k l m n o p q r s t u v w x y z\n\n"; +//demo_string += "[wave][c_orange]0123456789[] .,<>\"'&[c_white][spr_coin,0][spr_coin,1][spr_coin,2][spr_coin,3][][shake][rainbow]!?[]\n"; +//demo_string += "[spr_coin][spr_coin,1,0.1][spr_coin,2,0.1][spr_large_coin,3,0.1] \n"; +//demo_string += "[spr_sprite_font]the quick brown fox [wave]jumps[/wave] over the lazy dog"; +//demo_string += "[fnt_test_0][fa_right]THE [fnt_test_1][#ff4499][shake]QUICK[fnt_test_0] [$D2691E]BROWN [$FF4499]FOX [fa_left]JUMPS OVER[$FFFF00] [/shake]THE LAZY [fnt_test_1][wobble]DOG[/wobble]."; +//demo_string += "##[fnt_test_2][c_black]TESTING"; + +demo_string = "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of \"de Finibus Bonorum et Malorum\" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, \"Lorem ipsum dolor sit amet...\", comes from a line in section 1.10.32."; //Now parse the string to make some Scribble data //We're using a cache group called "example cache group" to indicate we want to manage this memory ourselves scribble_draw_set_cache_group("example cache group", false, true); -scribble_draw_set_wrap(-1, 450, false); +scribble_draw_set_wrap(-1, 450, 100, false); element = scribble_draw(0, 0, demo_string); -scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_CHARACTER, 2, 0); +scribble_page_set(element, 0); +scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_CHARACTER, 1, 10); //Don't forget to reset the state otherwise all subsequent Scribble text elements will inherit these settings scribble_draw_reset(); \ No newline at end of file diff --git a/objects/obj_test/Draw_0.gml b/objects/obj_test/Draw_0.gml index b9b502fa3..910d20c06 100644 --- a/objects/obj_test/Draw_0.gml +++ b/objects/obj_test/Draw_0.gml @@ -1,15 +1,8 @@ scribble_draw_set_box_align(fa_center, fa_middle); - -//Draw our manually created Scribble data scribble_draw(x, y, element); -//Find the size and position of the bounding box (plus a bit) and draw it var _bbox = scribble_get_bbox(element, x, y, 5, 5, 5, 5); - -scribble_draw_reset(); - -//scribble_get_bbox() return 4 coordinate pairs, one for each corner of the box -//This means you can rotate the textbox and still get useful coordinates -//Most of the time, you'll only want to use the top-left and bottom-right corners draw_rectangle(_bbox[SCRIBBLE_BBOX.L], _bbox[SCRIBBLE_BBOX.T], - _bbox[SCRIBBLE_BBOX.R], _bbox[SCRIBBLE_BBOX.B], true); \ No newline at end of file + _bbox[SCRIBBLE_BBOX.R], _bbox[SCRIBBLE_BBOX.B], true); + +scribble_draw_reset(); \ No newline at end of file diff --git a/objects/obj_test/Step_0.gml b/objects/obj_test/Step_0.gml new file mode 100644 index 000000000..0c9b70d35 --- /dev/null +++ b/objects/obj_test/Step_0.gml @@ -0,0 +1,18 @@ +if (keyboard_check_pressed(vk_space)) +{ + if (scribble_autotype_get(element) < 1) + { + scribble_autotype_skip(element); + } + else if (!scribble_page_on_last(element)) + { + scribble_page_set(element, 1 + scribble_page_get(element)); + scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_CHARACTER, 1, 10); + } + else + { + //Loop back round to the first page + scribble_page_set(element, 0); + scribble_autotype_fade_in(element, SCRIBBLE_AUTOTYPE_PER_CHARACTER, 1, 10); + } +} \ No newline at end of file diff --git a/objects/obj_test/obj_test.yy b/objects/obj_test/obj_test.yy index 2f35f374e..f237138bc 100644 --- a/objects/obj_test/obj_test.yy +++ b/objects/obj_test/obj_test.yy @@ -33,6 +33,16 @@ "enumb": 0, "eventtype": 12, "m_owner": "6e50d4a6-cc45-413c-bd8b-e5c75c9e9ab8" + }, + { + "id": "a6132ec1-a6e1-4cdd-8a37-659f85d9f2ea", + "modelName": "GMEvent", + "mvc": "1.0", + "IsDnD": false, + "collisionObjectId": "00000000-0000-0000-0000-000000000000", + "enumb": 0, + "eventtype": 3, + "m_owner": "6e50d4a6-cc45-413c-bd8b-e5c75c9e9ab8" } ], "maskSpriteId": "00000000-0000-0000-0000-000000000000", diff --git a/options/windows/options_windows.yy b/options/windows/options_windows.yy index d508f80b2..8b5935853 100644 --- a/options/windows/options_windows.yy +++ b/options/windows/options_windows.yy @@ -33,7 +33,7 @@ "option_windows_version": { "build": 3, "major": 5, - "minor": 3, + "minor": 4, "revision": 0 }, "option_windows_vsync": false diff --git a/scripts/__scribble_config/__scribble_config.gml b/scripts/__scribble_config/__scribble_config.gml index 9241beaf1..bc9abe2e2 100644 --- a/scripts/__scribble_config/__scribble_config.gml +++ b/scripts/__scribble_config/__scribble_config.gml @@ -21,6 +21,7 @@ //Text wrapping #macro SCRIBBLE_DEFAULT_LINE_MIN_HEIGHT -1 //The default minimum height of each line of text. Set to a negative value to use the height of a space character of the default font. #macro SCRIBBLE_DEFAULT_MAX_WIDTH -1 //The default maximum horizontal size of the textbox. Set to a negative value for no limit. +#macro SCRIBBLE_DEFAULT_MAX_HEIGHT -1 //The default maximum vertical size of the textbox. Set to a negative value for no limit. //Transform #macro SCRIBBLE_DEFAULT_XSCALE 1 //The default x-scale of the textbox. diff --git a/scripts/scribble_autotype_fade_in/scribble_autotype_fade_in.gml b/scripts/scribble_autotype_fade_in/scribble_autotype_fade_in.gml index b65c9d096..b18de6aef 100644 --- a/scripts/scribble_autotype_fade_in/scribble_autotype_fade_in.gml +++ b/scripts/scribble_autotype_fade_in/scribble_autotype_fade_in.gml @@ -11,16 +11,18 @@ var _smoothness = argument3; //Check if this array is a relevant text element if (!is_array(_scribble_array) || (array_length_1d(_scribble_array) != __SCRIBBLE.__SIZE) -|| (_scribble_array[__SCRIBBLE.VERSION] != __SCRIBBLE_VERSION) -|| _scribble_array[__SCRIBBLE.FREED]) +|| (_scribble_array[__SCRIBBLE.VERSION] != __SCRIBBLE_VERSION)) { - if (SCRIBBLE_VERBOSE) show_debug_message("Scribble: Array passed to scribble_autotype_set() is not a valid Scribble text element."); + if (SCRIBBLE_VERBOSE) show_debug_message("Scribble: Array passed to scribble_autotype_fade_in() is not a valid Scribble text element."); exit; } +if (_scribble_array[__SCRIBBLE.FREED]) exit; + if ((_method != SCRIBBLE_AUTOTYPE_NONE) && (_method != SCRIBBLE_AUTOTYPE_PER_CHARACTER) -&& (_method != SCRIBBLE_AUTOTYPE_PER_LINE)) +&& (_method != SCRIBBLE_AUTOTYPE_PER_LINE) +&& (_method != undefined)) { show_error("Scribble:\nMethod not recognised.\nPlease use SCRIBBLE_AUTOTYPE_NONE, SCRIBBLE_AUTOTYPE_PER_CHARACTER, or SCRIBBLE_AUTOTYPE_PER_LINE.\n ", false); _method = SCRIBBLE_AUTOTYPE_NONE; @@ -28,7 +30,14 @@ if ((_method != SCRIBBLE_AUTOTYPE_NONE) //Update the remaining autotype state values _scribble_array[@ __SCRIBBLE.AUTOTYPE_POSITION ] = 0; -_scribble_array[@ __SCRIBBLE.AUTOTYPE_METHOD ] = _method; +if (_method != undefined) _scribble_array[@ __SCRIBBLE.AUTOTYPE_METHOD] = _method; _scribble_array[@ __SCRIBBLE.AUTOTYPE_SPEED ] = _speed; _scribble_array[@ __SCRIBBLE.AUTOTYPE_SMOOTHNESS] = _smoothness; -_scribble_array[@ __SCRIBBLE.AUTOTYPE_FADE_IN ] = true; \ No newline at end of file +_scribble_array[@ __SCRIBBLE.AUTOTYPE_FADE_IN ] = true; + +//Reset this page's previous event position too +var _pages_array = _scribble_array[@ __SCRIBBLE.PAGES_ARRAY]; +var _page_array = _pages_array[_scribble_array[__SCRIBBLE.AUTOTYPE_PAGE]]; + +_page_array[@ __SCRIBBLE_PAGE.EVENT_PREVIOUS ] = -1; +_page_array[@ __SCRIBBLE_PAGE.EVENT_CHAR_PREVIOUS] = -1; \ No newline at end of file diff --git a/scripts/scribble_autotype_fade_out/scribble_autotype_fade_out.gml b/scripts/scribble_autotype_fade_out/scribble_autotype_fade_out.gml index bcd1d4f60..de6582206 100644 --- a/scripts/scribble_autotype_fade_out/scribble_autotype_fade_out.gml +++ b/scripts/scribble_autotype_fade_out/scribble_autotype_fade_out.gml @@ -11,13 +11,14 @@ var _smoothness = argument3; //Check if this array is a relevant text element if (!is_array(_scribble_array) || (array_length_1d(_scribble_array) != __SCRIBBLE.__SIZE) -|| (_scribble_array[__SCRIBBLE.VERSION] != __SCRIBBLE_VERSION) -|| _scribble_array[__SCRIBBLE.FREED]) +|| (_scribble_array[__SCRIBBLE.VERSION] != __SCRIBBLE_VERSION)) { - if (SCRIBBLE_VERBOSE) show_debug_message("Scribble: Array passed to scribble_autotype_set() is not a valid Scribble text element."); + if (SCRIBBLE_VERBOSE) show_debug_message("Scribble: Array passed to scribble_autotype_fade_out() is not a valid Scribble text element."); exit; } +if (_scribble_array[__SCRIBBLE.FREED]) exit; + if ((_method != SCRIBBLE_AUTOTYPE_NONE) && (_method != SCRIBBLE_AUTOTYPE_PER_CHARACTER) && (_method != SCRIBBLE_AUTOTYPE_PER_LINE)) diff --git a/scripts/scribble_autotype_get/scribble_autotype_get.gml b/scripts/scribble_autotype_get/scribble_autotype_get.gml index d20e86368..0e8c74498 100644 --- a/scripts/scribble_autotype_get/scribble_autotype_get.gml +++ b/scripts/scribble_autotype_get/scribble_autotype_get.gml @@ -14,26 +14,30 @@ var _scribble_array = argument0; //Check if this array is a relevant text element if (!is_array(_scribble_array) || (array_length_1d(_scribble_array) != __SCRIBBLE.__SIZE) -|| (_scribble_array[__SCRIBBLE.VERSION] != __SCRIBBLE_VERSION) -|| _scribble_array[__SCRIBBLE.FREED]) +|| (_scribble_array[__SCRIBBLE.VERSION] != __SCRIBBLE_VERSION)) { if (SCRIBBLE_VERBOSE) show_debug_message("Scribble: Array passed to scribble_autotype_get() is not a valid Scribble text element."); exit; } -//Return an error code if the method is NONE +if (_scribble_array[__SCRIBBLE.FREED]) return 0; + +//Early out if the method is NONE var _typewriter_method = _scribble_array[__SCRIBBLE.AUTOTYPE_METHOD]; -if (_typewriter_method == SCRIBBLE_AUTOTYPE_NONE) return -1; +if (_typewriter_method == SCRIBBLE_AUTOTYPE_NONE) return 1; //Return an error code if the fade in state has not been set //(The fade in state is initialised as -1) var _typewriter_fade_in = _scribble_array[__SCRIBBLE.AUTOTYPE_FADE_IN]; if (_scribble_array[__SCRIBBLE.AUTOTYPE_FADE_IN] < 0) return -2; +var _element_pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; +var _page_array = _element_pages_array[_scribble_array[__SCRIBBLE.AUTOTYPE_PAGE]]; + switch(_typewriter_method) { - case SCRIBBLE_AUTOTYPE_PER_CHARACTER: var _typewriter_count = _scribble_array[__SCRIBBLE.CHARACTERS]; break; - case SCRIBBLE_AUTOTYPE_PER_LINE: var _typewriter_count = _scribble_array[__SCRIBBLE.LINES ]; break; + case SCRIBBLE_AUTOTYPE_PER_CHARACTER: var _typewriter_count = _page_array[__SCRIBBLE_PAGE.CHARACTERS]; break; + case SCRIBBLE_AUTOTYPE_PER_LINE: var _typewriter_count = _page_array[__SCRIBBLE_PAGE.LINES ]; break; } //Normalise the parameter from 0 -> 1 using the total counter diff --git a/scripts/scribble_autotype_skip/scribble_autotype_skip.gml b/scripts/scribble_autotype_skip/scribble_autotype_skip.gml new file mode 100644 index 000000000..0ccd25cc0 --- /dev/null +++ b/scripts/scribble_autotype_skip/scribble_autotype_skip.gml @@ -0,0 +1,28 @@ +/// @param textElement + +var _scribble_array = argument0; + +//Check if this array is a relevant text element +if (!is_array(_scribble_array) +|| (array_length_1d(_scribble_array) != __SCRIBBLE.__SIZE) +|| (_scribble_array[__SCRIBBLE.VERSION] != __SCRIBBLE_VERSION)) +{ + if (SCRIBBLE_VERBOSE) show_debug_message("Scribble: Array passed to scribble_autotype_skip() is not a valid Scribble text element."); + exit; +} + +if (_scribble_array[__SCRIBBLE.FREED]) exit; + +var _element_pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; +var _page_array = _element_pages_array[_scribble_array[__SCRIBBLE.AUTOTYPE_PAGE]]; + +var _max = 1; +switch(_scribble_array[__SCRIBBLE.AUTOTYPE_METHOD]) +{ + case SCRIBBLE_AUTOTYPE_PER_CHARACTER: var _max = _page_array[__SCRIBBLE_PAGE.CHARACTERS]; break; + case SCRIBBLE_AUTOTYPE_PER_LINE: var _max = _page_array[__SCRIBBLE_PAGE.LINES ]; break; +} + +_scribble_array[@ __SCRIBBLE.AUTOTYPE_POSITION] = _max + _scribble_array[__SCRIBBLE.AUTOTYPE_SMOOTHNESS]; + +return _max; \ No newline at end of file diff --git a/scripts/scribble_autotype_skip/scribble_autotype_skip.yy b/scripts/scribble_autotype_skip/scribble_autotype_skip.yy new file mode 100644 index 000000000..bc9d36cf0 --- /dev/null +++ b/scripts/scribble_autotype_skip/scribble_autotype_skip.yy @@ -0,0 +1,8 @@ +{ + "id": "8419d4f0-d03e-4d98-8b9d-93e9ec832104", + "modelName": "GMScript", + "mvc": "1.0", + "name": "scribble_autotype_skip", + "IsCompatibility": false, + "IsDnD": false +} \ No newline at end of file diff --git a/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml b/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml index 38a0d7736..aefd9f4ad 100644 --- a/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml +++ b/scripts/scribble_cache_group_flush/scribble_cache_group_flush.gml @@ -31,27 +31,37 @@ if (ds_map_exists(global.__scribble_cache_group_map, _target)) var _i = 0; repeat(ds_list_size(_list)) { - var _scribble_array = global.__scribble_global_cache_map[? _list[| _i]]; + var _scribble_array = _list[| _i]; if (is_array(_scribble_array) && (array_length_1d(_scribble_array) == __SCRIBBLE.__SIZE) && (_scribble_array[__SCRIBBLE.VERSION] == __SCRIBBLE_VERSION) - && _scribble_array[__SCRIBBLE.FREED]) + && !_scribble_array[__SCRIBBLE.FREED]) { + //Remove reference from cache + ds_map_delete(global.__scribble_global_cache_map,_scribble_array[__SCRIBBLE.CACHE_STRING]); + + //Remove global reference ds_map_delete(global.scribble_alive, _scribble_array[__SCRIBBLE.GLOBAL_INDEX]); - - var _vbuff_list = _scribble_array[__SCRIBBLE.VERTEX_BUFFER_LIST]; - var _count = ds_list_size(_vbuff_list); - for(var _i = 0; _i < _count; _i++) + + //Destroy vertex buffers + var _element_pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; + var _p = 0; + repeat(array_length_1d(_element_pages_array)) { - var _vbuff_data = _vbuff_list[| _i]; - var _vbuff = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER]; - vertex_delete_buffer(_vbuff); + var _page_array = _element_pages_array[_p]; + var _vertex_buffers_array = _page_array[__SCRIBBLE_PAGE.VERTEX_BUFFERS_ARRAY]; + var _v = 0; + repeat(array_length_1d(_vertex_buffers_array)) + { + var _vbuff_data = _vertex_buffers_array[_v]; + var _vbuff = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER]; + vertex_delete_buffer(_vbuff); + ++_v; + } + ++_p; } - ds_list_destroy(_scribble_array[@ __SCRIBBLE.LINE_LIST]); - ds_list_destroy(_vbuff_list); - _scribble_array[@ __SCRIBBLE.FREED] = true; } diff --git a/scripts/scribble_draw/scribble_draw.gml b/scripts/scribble_draw/scribble_draw.gml index fee3a7bda..46dfbfe77 100644 --- a/scripts/scribble_draw/scribble_draw.gml +++ b/scripts/scribble_draw/scribble_draw.gml @@ -10,6 +10,7 @@ /// /// Formatting commands: /// [] Reset formatting to defaults +/// [/page] Page break /// [] Set colour /// [#] Set colour via a hexcode, using the industry standard 24-bit RGB format (#RRGGBB) /// [/colour] [/c] Reset colour to the default @@ -29,6 +30,8 @@ /// [wave] [/wave] Set/unset text to wave up and down /// [shake] [/shake] Set/unset text to shake /// [rainbow] [/rainbow] Set/unset text to cycle through rainbow colours +/// [wobble] [/wobble] Set/unset text to wobble by rotating back and forth +/// [pulse] [/pulse] Set/unset text to shrink and grow rhythmically @@ -41,7 +44,7 @@ var _draw_string = argument2; if (!is_array(_draw_string)) { //Check the cache - var _cache_string = string(_draw_string) + ":" + string(global.scribble_state_line_min_height) + ":" + string(global.scribble_state_max_width); + var _cache_string = string(_draw_string) + ":" + string(global.scribble_state_line_min_height) + ":" + string(global.scribble_state_max_width) + ":" + string(global.scribble_state_max_height); if (ds_map_exists(global.__scribble_global_cache_map, _cache_string)) { //Grab the text element from the cache @@ -50,13 +53,20 @@ if (!is_array(_draw_string)) else { //Cache a new text element if we don't have a relevant one for this string + + //Record the start time so we can get a duration later var _timer_total = get_timer(); + //Create a couple data structures + var _parameters_list = ds_list_create(); + var _texture_to_buffer_map = ds_map_create(); + #region Process input parameters var _max_width = is_real(global.scribble_state_max_width)? global.scribble_state_max_width : SCRIBBLE_DEFAULT_MAX_WIDTH; + var _max_height = is_real(global.scribble_state_max_height)? global.scribble_state_max_height : SCRIBBLE_DEFAULT_MAX_HEIGHT; var _line_min_height = is_real(global.scribble_state_line_min_height)? global.scribble_state_line_min_height : SCRIBBLE_DEFAULT_LINE_MIN_HEIGHT; var _def_colour = SCRIBBLE_DEFAULT_TEXT_COLOUR; var _def_font = global.__scribble_default_font; @@ -104,23 +114,26 @@ if (!is_array(_draw_string)) - #region Create the text element (an array) + #region Create the base text element + + var _meta_element_characters = 0; + var _meta_element_lines = 0; + var _meta_element_pages = 0; + var _element_width = 0; + var _element_height = 0; - var _scribble_array = array_create(__SCRIBBLE.__SIZE); //The text element array - var _line_list = ds_list_create(); //Stores each line of text - var _vertex_buffer_list = ds_list_create(); //Stores all the vertex buffers needed to render the text and sprites - var _events_char_array = array_create(0); //Stores each event's triggering character - var _events_name_array = array_create(0); //Stores each event's name - var _events_data_array = array_create(0); //Stores each event's parameters - var _texture_to_buffer_map = ds_map_create(); + var _scribble_array = array_create(__SCRIBBLE.__SIZE); //The text element array + var _element_pages_array = []; //Stores each page of text _scribble_array[@ __SCRIBBLE.__SECTION0 ] = "-- Parameters --"; _scribble_array[@ __SCRIBBLE.VERSION ] = __SCRIBBLE_VERSION; _scribble_array[@ __SCRIBBLE.STRING ] = _draw_string; + _scribble_array[@ __SCRIBBLE.CACHE_STRING ] = _cache_string; _scribble_array[@ __SCRIBBLE.DEFAULT_FONT ] = _def_font; _scribble_array[@ __SCRIBBLE.DEFAULT_COLOUR ] = _def_colour; _scribble_array[@ __SCRIBBLE.DEFAULT_HALIGN ] = _def_halign; _scribble_array[@ __SCRIBBLE.WIDTH_LIMIT ] = _max_width; + _scribble_array[@ __SCRIBBLE.HEIGHT_LIMIT ] = _max_height; _scribble_array[@ __SCRIBBLE.LINE_HEIGHT ] = _line_min_height; _scribble_array[@ __SCRIBBLE.__SECTION1 ] = "-- Statistics --"; @@ -128,6 +141,7 @@ if (!is_array(_draw_string)) _scribble_array[@ __SCRIBBLE.HEIGHT ] = 0; _scribble_array[@ __SCRIBBLE.CHARACTERS ] = 0; _scribble_array[@ __SCRIBBLE.LINES ] = 0; + _scribble_array[@ __SCRIBBLE.PAGES ] = 0; _scribble_array[@ __SCRIBBLE.GLOBAL_INDEX ] = global.__scribble_global_count+1; _scribble_array[@ __SCRIBBLE.__SECTION2 ] = "-- State --"; @@ -136,26 +150,19 @@ if (!is_array(_draw_string)) _scribble_array[@ __SCRIBBLE.FREED ] = false; _scribble_array[@ __SCRIBBLE.SOUND_FINISH_TIME ] = current_time; - _scribble_array[@ __SCRIBBLE.__SECTION3 ] = "-- Lists --"; - _scribble_array[@ __SCRIBBLE.LINE_LIST ] = _line_list; - _scribble_array[@ __SCRIBBLE.VERTEX_BUFFER_LIST ] = _vertex_buffer_list; - + _scribble_array[@ __SCRIBBLE.__SECTION3 ] = "-- Pages --"; + _scribble_array[@ __SCRIBBLE.PAGES_ARRAY ] = _element_pages_array; + _scribble_array[@ __SCRIBBLE.__SECTION4 ] = "-- Autotype --"; + _scribble_array[@ __SCRIBBLE.AUTOTYPE_PAGE ] = 0; _scribble_array[@ __SCRIBBLE.AUTOTYPE_FADE_IN ] = -1; - _scribble_array[@ __SCRIBBLE.AUTOTYPE_SPEED ] = 0; - _scribble_array[@ __SCRIBBLE.AUTOTYPE_POSITION ] = 0; + _scribble_array[@ __SCRIBBLE.AUTOTYPE_SPEED ] = 0; + _scribble_array[@ __SCRIBBLE.AUTOTYPE_POSITION ] = 0; _scribble_array[@ __SCRIBBLE.AUTOTYPE_METHOD ] = SCRIBBLE_AUTOTYPE_NONE; - _scribble_array[@ __SCRIBBLE.AUTOTYPE_SMOOTHNESS ] = 0; + _scribble_array[@ __SCRIBBLE.AUTOTYPE_SMOOTHNESS ] = 0; _scribble_array[@ __SCRIBBLE.AUTOTYPE_SOUND_ARRAY ] = -1; - _scribble_array[@ __SCRIBBLE.AUTOTYPE_SOUND_OVERLAP] = 0; - - _scribble_array[@ __SCRIBBLE.__SECTION5 ] = "-- Events --"; - _scribble_array[@ __SCRIBBLE.EVENT_PREVIOUS ] = -1; - _scribble_array[@ __SCRIBBLE.EVENT_CHAR_PREVIOUS ] = -1; - _scribble_array[@ __SCRIBBLE.EVENT_CHAR_ARRAY ] = _events_char_array; //Stores each event's triggering cha - _scribble_array[@ __SCRIBBLE.EVENT_NAME_ARRAY ] = _events_name_array; //Stores each event's name - _scribble_array[@ __SCRIBBLE.EVENT_DATA_ARRAY ] = _events_data_array; //Stores each event's parameters - + _scribble_array[@ __SCRIBBLE.AUTOTYPE_SOUND_OVERLAP] = 0; + #endregion @@ -168,9 +175,10 @@ if (!is_array(_draw_string)) if (__SCRIBBLE_DEBUG) show_debug_message(global.scribble_state_allow_draw? ("Scribble: Caching \"" + _cache_string + "\"") : ("Scribble: Pre-caching \"" + _cache_string + "\"")); //Add this text element to the global cache lookup - if (global.scribble_state_cache_group == SCRIBBLE_DEFAULT_CACHE_GROUP) global.__scribble_global_cache_map[? _cache_string] = _scribble_array; + global.__scribble_global_cache_map[? _cache_string] = _scribble_array; //Find this cache group's list + //If we're using the default cache group, this list is the same as global.__scribble_global_cache_list var _list = global.__scribble_cache_group_map[? global.scribble_state_cache_group]; if (_list == undefined) { @@ -186,45 +194,78 @@ if (!is_array(_draw_string)) - #region Parse the string - - #region Initial parser state - - var _parameters_list = ds_list_create(); - - var _text_x = 0; - var _line_y = 0; - var _text_font = _def_font; - var _text_colour = _def_colour; - var _text_halign = _def_halign; - var _text_effect_flags = 0; - var _text_scale = 1; - var _text_slant = false; - + #region Add the first page to the text element + + var _meta_page_characters = 0; + var _meta_page_lines = 0; + + var _page_array = array_create(__SCRIBBLE_PAGE.__SIZE); + var _page_lines_array = []; //Stores each line of text (per page) + var _page_vbuffs_array = []; //Stores all the vertex buffers needed to render the text and sprites (per page) + var _events_char_array = []; //Stores each event's triggering character + var _events_name_array = []; //Stores each event's name + var _events_data_array = []; //Stores each event's parameters + + _page_array[@ __SCRIBBLE_PAGE.LINES ] = 0; + _page_array[@ __SCRIBBLE_PAGE.CHARACTERS ] = 0; + _page_array[@ __SCRIBBLE_PAGE.LINES_ARRAY ] = _page_lines_array; + _page_array[@ __SCRIBBLE_PAGE.VERTEX_BUFFERS_ARRAY] = _page_vbuffs_array; + + _page_array[@ __SCRIBBLE_PAGE.EVENT_PREVIOUS ] = -1; + _page_array[@ __SCRIBBLE_PAGE.EVENT_CHAR_PREVIOUS ] = -1; + _page_array[@ __SCRIBBLE_PAGE.EVENT_CHAR_ARRAY ] = _events_char_array; //Stores each event's triggering character + _page_array[@ __SCRIBBLE_PAGE.EVENT_NAME_ARRAY ] = _events_name_array; //Stores each event's name + _page_array[@ __SCRIBBLE_PAGE.EVENT_DATA_ARRAY ] = _events_data_array; //Stores each event's parameters + + _element_pages_array[@ array_length_1d(_element_pages_array)] = _page_array; + ++_meta_element_pages; + + #endregion + + + + #region Add the first line to the page + var _line_width = 0; var _line_height = _line_min_height; - + var _line_array = array_create(__SCRIBBLE_LINE.__SIZE); _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = 1; _line_array[@ __SCRIBBLE_LINE.Y ] = 0; _line_array[@ __SCRIBBLE_LINE.WIDTH ] = _line_width; _line_array[@ __SCRIBBLE_LINE.HEIGHT ] = _line_height; _line_array[@ __SCRIBBLE_LINE.HALIGN ] = _def_halign; - ds_list_add(_line_list, _line_array); - + _page_lines_array[@ array_length_1d(_page_lines_array)] = _line_array; + #endregion - - var _meta_characters = 0; - var _meta_lines = 0; - var _text_x_max = 0; - var _text_y_max = 0; - + + + + #region Set the initial parser state + + var _text_x = 0; + var _line_y = 0; + var _text_font = _def_font; + var _text_colour = _def_colour; + var _text_halign = _def_halign; + var _text_effect_flags = 0; + var _text_scale = 1; + var _text_slant = false; + var _previous_texture = -1; + + #endregion + + + + #region Parse the string + var _command_tag_start = -1; var _command_tag_parameters = 0; var _command_name = ""; - var _previous_texture = -1; var _force_newline = false; + var _force_newpage = false; var _char_width = 0; + var _add_character = true; //Write the string into a buffer for faster reading var _buffer_size = string_byte_length(_draw_string)+1; @@ -237,11 +278,14 @@ if (!is_array(_draw_string)) { var _character_code = buffer_read(_string_buffer, buffer_u8); if (_character_code == 0) break; - + _add_character = true; + if (_command_tag_start >= 0) //If we're in a command tag { if (_character_code == SCRIBBLE_COMMAND_TAG_CLOSE) //If we've hit a command tag close character (usually ]) { + _add_character = false; + //Increment the parameter count and place a null byte for string reading ++_command_tag_parameters; buffer_poke(_string_buffer, buffer_tell(_string_buffer)-1, buffer_u8, 0); @@ -318,7 +362,17 @@ if (!is_array(_draw_string)) continue; //Skip the rest of the parser step break; #endregion - + + #region Page break + + case "/page": + _force_newline = true; + _char_width = 0; + _force_newpage = true; + break; + + #endregion + #region Scale case "scale": if (_command_tag_parameters <= 1) @@ -346,18 +400,42 @@ if (!is_array(_draw_string)) case "fa_left": _text_halign = fa_left; - if (_text_x > 0) _force_newline = true else continue; //Skip the rest of the parser step + if (_text_x > 0) + { + _force_newline = true; + } + else + { + _line_array[@ __SCRIBBLE_LINE.HALIGN] = fa_left; + continue; //Skip the rest of the parser step + } break; case "fa_right": _text_halign = fa_right; - if (_text_x > 0) _force_newline = true else continue; //Skip the rest of the parser step + if (_text_x > 0) + { + _force_newline = true; + } + else + { + _line_array[@ __SCRIBBLE_LINE.HALIGN] = fa_right; + continue; //Skip the rest of the parser step + } break; case "fa_center": case "fa_centre": _text_halign = fa_center; - if (_text_x > 0) _force_newline = true else continue; //Skip the rest of the parser step + if (_text_x > 0) + { + _force_newline = true; + } + else + { + _line_array[@ __SCRIBBLE_LINE.HALIGN] = fa_center; + continue; //Skip the rest of the parser step + } break; #endregion @@ -375,7 +453,7 @@ if (!is_array(_draw_string)) } var _count = array_length_1d(_events_char_array); - _events_char_array[@ _count] = _meta_characters; + _events_char_array[@ _count] = _meta_page_characters; _events_name_array[@ _count] = _command_name; _events_data_array[@ _count] = _data; @@ -437,6 +515,8 @@ if (!is_array(_draw_string)) { #region Write sprites + _line_width = max(_line_width, _text_x); + var _sprite_index = asset_get_index(_command_name); var _sprite_width = _text_scale*sprite_get_width(_sprite_index); var _sprite_height = _text_scale*sprite_get_height(_sprite_index); @@ -453,7 +533,7 @@ if (!is_array(_draw_string)) var _sprite_y = -(_sprite_height div 2); } - var _packed_indexes = _meta_characters*SCRIBBLE_MAX_LINES + _meta_lines; + var _packed_indexes = _meta_page_characters*SCRIBBLE_MAX_LINES + _meta_page_lines; _char_width = _sprite_width; _line_height = max(_line_height, _sprite_height); @@ -519,7 +599,7 @@ if (!is_array(_draw_string)) var _vbuff_data = _texture_to_buffer_map[? _sprite_texture]; if (_vbuff_data == undefined) { - var _line_break_list = ds_list_create(); + var _vbuff_line_start_list = ds_list_create(); var _buffer = buffer_create(__SCRIBBLE_GLYPH_BYTE_SIZE, buffer_grow, 1); _vbuff_data = array_create(__SCRIBBLE_VERTEX_BUFFER.__SIZE); @@ -528,10 +608,10 @@ if (!is_array(_draw_string)) _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXTURE ] = _sprite_texture; _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.CHAR_START_TELL] = 0; _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = 0; - _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = _line_break_list; + _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = _vbuff_line_start_list; _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXEL_WIDTH ] = texture_get_texel_width( _sprite_texture); _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXEL_HEIGHT ] = texture_get_texel_height(_sprite_texture); - ds_list_add(_vertex_buffer_list, _vbuff_data); + _page_vbuffs_array[@ array_length_1d(_page_vbuffs_array)] = _vbuff_data; _texture_to_buffer_map[? _sprite_texture] = _vbuff_data; } @@ -540,11 +620,12 @@ if (!is_array(_draw_string)) var _buffer = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.BUFFER]; _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.CHAR_START_TELL] = buffer_tell(_buffer); _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = buffer_tell(_buffer); + _vbuff_line_start_list = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; } //Fill link break list var _tell = buffer_tell(_buffer); - repeat(ds_list_size(_line_list) - ds_list_size(_line_break_list)) ds_list_add(_line_break_list, _tell); + repeat(array_length_1d(_page_lines_array) - ds_list_size(_vbuff_line_start_list)) ds_list_add(_vbuff_line_start_list, _tell); ++_image; } @@ -596,7 +677,8 @@ if (!is_array(_draw_string)) #endregion _text_effect_flags = ~((~_text_effect_flags) | 1); //Reset animated sprite effect flag specifically - ++_meta_characters; + ++_meta_page_characters; + ++_meta_element_characters; #endregion } @@ -673,6 +755,10 @@ if (!is_array(_draw_string)) buffer_poke(_string_buffer, buffer_tell(_string_buffer)-1, buffer_u8, 0); continue; } + else if ((_character_code == SCRIBBLE_COMMAND_TAG_OPEN) && (buffer_tell(_string_buffer) - _command_tag_start == 1)) + { + _command_tag_start = -1; + } else { //If we're in a command tag and we've not read a close character or an argument delimiter, skip everything else @@ -692,29 +778,36 @@ if (!is_array(_draw_string)) || ((_character_code == 13) && (buffer_peek(_string_buffer, buffer_tell(_string_buffer)+1, buffer_u8) != 10))) { _force_newline = true; - _char_width = 0; - _line_height = max(_line_height, _font_line_height*_text_scale); + _char_width = 0; + _line_width = max(_line_width, _text_x); + _line_height = max(_line_height, _font_line_height*_text_scale); + + _add_character = false; } else if (_character_code == 32) //If we've hit a space { //Grab this characer's width/height _char_width = _font_space_width*_text_scale; + _line_width = max(_line_width, _text_x); _line_height = max(_line_height, _font_line_height*_text_scale); - + //Iterate over all the vertex buffers we've been using and reset the word start position var _v = 0; - repeat(ds_list_size(_vertex_buffer_list)) + repeat(array_length_1d(_page_vbuffs_array)) { - var _data = _vertex_buffer_list[| _v]; + var _data = _page_vbuffs_array[_v]; _data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = buffer_tell(_data[__SCRIBBLE_VERTEX_BUFFER.BUFFER]); ++_v; } + + _add_character = false; } else if (_character_code < 32) //If this character code is below a space then ignore it { continue; } - else//If this character is literally any other character at all + + if (_add_character) //If this character is literally any other character at all { #region Decode UTF8 @@ -748,35 +841,40 @@ if (!is_array(_draw_string)) var _vbuff_data = _texture_to_buffer_map[? _font_texture]; if (_vbuff_data == undefined) { - var _line_break_list = ds_list_create(); + var _vbuff_line_start_list = ds_list_create(); var _glyph_buffer = buffer_create(__SCRIBBLE_EXPECTED_GLYPHS*__SCRIBBLE_GLYPH_BYTE_SIZE, buffer_grow, 1); - + _vbuff_data = array_create(__SCRIBBLE_VERTEX_BUFFER.__SIZE); _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.BUFFER ] = _glyph_buffer; _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER ] = undefined; _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXTURE ] = _font_texture; _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.CHAR_START_TELL] = 0; _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = 0; - _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = _line_break_list; + _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = _vbuff_line_start_list; _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXEL_WIDTH ] = texture_get_texel_width( _font_texture); _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXEL_HEIGHT ] = texture_get_texel_height(_font_texture); - ds_list_add(_vertex_buffer_list, _vbuff_data); - + _page_vbuffs_array[@ array_length_1d(_page_vbuffs_array)] = _vbuff_data; + _texture_to_buffer_map[? _font_texture] = _vbuff_data; } else { var _glyph_buffer = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.BUFFER]; + _vbuff_line_start_list = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; } //Fill link break list var _tell = buffer_tell(_glyph_buffer); - repeat(ds_list_size(_line_list) - ds_list_size(_line_break_list)) ds_list_add(_line_break_list, _tell); + repeat(array_length_1d(_page_lines_array) - ds_list_size(_vbuff_line_start_list)) ds_list_add(_vbuff_line_start_list, _tell); } //Update CHAR_START_TELL, and WORD_START_TELL if needed _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.CHAR_START_TELL] = buffer_tell(_glyph_buffer); - if (global.scribble_state_character_wrap) _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = buffer_tell(_glyph_buffer); + if (global.scribble_state_character_wrap) + { + _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = buffer_tell(_glyph_buffer); + _line_width = max(_line_width, _text_x); + } #endregion @@ -806,7 +904,7 @@ if (!is_array(_draw_string)) _quad_r -= _quad_cx; _quad_b -= _quad_cy; - var _packed_indexes = _meta_characters*SCRIBBLE_MAX_LINES + _meta_lines; + var _packed_indexes = _meta_page_characters*SCRIBBLE_MAX_LINES + _meta_page_lines; var _colour = $FF000000 | _text_colour; var _slant_offset = SCRIBBLE_SLANT_AMOUNT*_text_scale*_text_slant*(_quad_b - _quad_t); @@ -823,7 +921,8 @@ if (!is_array(_draw_string)) buffer_write(_glyph_buffer, buffer_f32, _quad_cx); buffer_write(_glyph_buffer, buffer_f32, _quad_cy); buffer_write(_glyph_buffer, buffer_f32, _packed_indexes); buffer_write(_glyph_buffer, buffer_f32, _quad_r + _slant_offset); buffer_write(_glyph_buffer, buffer_f32, _quad_t); buffer_write(_glyph_buffer, buffer_f32, _text_effect_flags); buffer_write(_glyph_buffer, buffer_u32, _colour); buffer_write(_glyph_buffer, buffer_f32, _quad_u1); buffer_write(_glyph_buffer, buffer_f32, _quad_v0); buffer_write(_glyph_buffer, buffer_f32, _quad_cx); buffer_write(_glyph_buffer, buffer_f32, _quad_cy); buffer_write(_glyph_buffer, buffer_f32, _packed_indexes); buffer_write(_glyph_buffer, buffer_f32, _quad_l + _slant_offset); buffer_write(_glyph_buffer, buffer_f32, _quad_t); buffer_write(_glyph_buffer, buffer_f32, _text_effect_flags); buffer_write(_glyph_buffer, buffer_u32, _colour); buffer_write(_glyph_buffer, buffer_f32, _quad_u0); buffer_write(_glyph_buffer, buffer_f32, _quad_v0); - ++_meta_characters; + ++_meta_page_characters; + ++_meta_element_characters; _char_width = _glyph_array[SCRIBBLE_GLYPH.SEPARATION]*_text_scale; } else @@ -836,7 +935,9 @@ if (!is_array(_draw_string)) //Choose the height of a space for the character's height _line_height = max(_line_height, _font_line_height*_text_scale); } - + + + #region Handle new line creation if (_force_newline @@ -845,22 +946,22 @@ if (!is_array(_draw_string)) var _line_offset_x = -_text_x; var _v = 0; - repeat(ds_list_size(_vertex_buffer_list)) + repeat(array_length_1d(_page_vbuffs_array)) { - var _data = _vertex_buffer_list[| _v]; - - var _line_break_list = _data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; - var _buffer = _data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; - var _tell_b = buffer_tell(_buffer); - + var _data = _page_vbuffs_array[_v]; + + var _vbuff_line_start_list = _data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; + var _buffer = _data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; + if (_force_newline) { - ds_list_add(_line_break_list, _tell_b); + ds_list_add(_vbuff_line_start_list, buffer_tell(_buffer)); } else { var _tell_a = _data[__SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL]; - ds_list_add(_line_break_list, _tell_a); + var _tell_b = buffer_tell(_buffer); + ds_list_add(_vbuff_line_start_list, _tell_a); //If we've added anything to this buffer if (_tell_a < _tell_b) @@ -882,6 +983,7 @@ if (!is_array(_draw_string)) //Set our word start tell position to be the same as the character start tell //This allows us to handle single words that exceed the maximum textbox width multiple times (!) _data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = _tell_a; + _line_width = max(_line_width, _text_x); } else { @@ -901,7 +1003,6 @@ if (!is_array(_draw_string)) buffer_poke(_buffer, _tell + __SCRIBBLE_VERTEX.PACKED_INDEXES, buffer_f32, buffer_peek(_buffer, _tell + __SCRIBBLE_VERTEX.PACKED_INDEXES, buffer_f32) + 1 ); //Adjust glyph centre position buffer_poke(_buffer, _tell + __SCRIBBLE_VERTEX.CENTRE_X , buffer_f32, buffer_peek(_buffer, _tell + __SCRIBBLE_VERTEX.CENTRE_X , buffer_f32) + _line_offset_x); - buffer_poke(_buffer, _tell + __SCRIBBLE_VERTEX.CENTRE_Y , buffer_f32, buffer_peek(_buffer, _tell + __SCRIBBLE_VERTEX.CENTRE_Y , buffer_f32) + _line_height ); _tell += __SCRIBBLE_VERTEX.__SIZE; } } @@ -911,11 +1012,12 @@ if (!is_array(_draw_string)) ++_v; } - ++_meta_lines; - _text_x_max = max(_text_x_max, _line_width); + ++_meta_element_lines; + ++_meta_page_lines; + _element_width = max(_element_width, _line_width); //Update the last line - _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_characters-1; + _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_page_characters-1; _line_array[@ __SCRIBBLE_LINE.Y ] = _line_y + (_line_height div 2); _line_array[@ __SCRIBBLE_LINE.WIDTH ] = _line_width; _line_array[@ __SCRIBBLE_LINE.HEIGHT ] = _line_height; @@ -928,77 +1030,226 @@ if (!is_array(_draw_string)) //Create a new line var _line_array = array_create(__SCRIBBLE_LINE.__SIZE); - _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_characters; - _line_array[@ __SCRIBBLE_LINE.Y ] = 0; + _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_page_characters; + _line_array[@ __SCRIBBLE_LINE.Y ] = _line_y; _line_array[@ __SCRIBBLE_LINE.WIDTH ] = 0; _line_array[@ __SCRIBBLE_LINE.HEIGHT ] = _line_min_height; _line_array[@ __SCRIBBLE_LINE.HALIGN ] = _text_halign; - ds_list_add(_line_list, _line_array); - + _page_lines_array[@ array_length_1d(_page_lines_array)] = _line_array; //Add this line to the page _force_newline = false; } #endregion - + + + + #region Handle new page creation + + if (_force_newpage + || ((_line_height + _line_y > _max_height) && (_max_height >= 0))) + { + //Update the metadata of the previous page + _page_array[@ __SCRIBBLE_PAGE.LINES ] = _meta_page_lines; + _page_array[@ __SCRIBBLE_PAGE.CHARACTERS] = _meta_page_characters; + + //Wipe the texture -> vertex buffer map + ds_map_clear(_texture_to_buffer_map); + + //Create a new page + var _new_page_array = array_create(__SCRIBBLE_PAGE.__SIZE); + var _new_page_lines_array = []; //Stores each line of text (per page) + var _new_page_vbuffs_array = []; //Stores all the vertex buffers needed to render the text and sprites (per page) + var _events_char_array = []; //Stores each event's triggering character + var _events_name_array = []; //Stores each event's name + var _events_data_array = []; //Stores each event's parameters + + _new_page_array[@ __SCRIBBLE_PAGE.LINES ] = 1; + _new_page_array[@ __SCRIBBLE_PAGE.CHARACTERS ] = 0; + _new_page_array[@ __SCRIBBLE_PAGE.LINES_ARRAY ] = _new_page_lines_array; + _new_page_array[@ __SCRIBBLE_PAGE.VERTEX_BUFFERS_ARRAY] = _new_page_vbuffs_array; + + _new_page_array[@ __SCRIBBLE_PAGE.EVENT_PREVIOUS ] = -1; + _new_page_array[@ __SCRIBBLE_PAGE.EVENT_CHAR_PREVIOUS ] = -1; + _new_page_array[@ __SCRIBBLE_PAGE.EVENT_CHAR_ARRAY ] = _events_char_array; //Stores each event's triggering character + _new_page_array[@ __SCRIBBLE_PAGE.EVENT_NAME_ARRAY ] = _events_name_array; //Stores each event's name + _new_page_array[@ __SCRIBBLE_PAGE.EVENT_DATA_ARRAY ] = _events_data_array; //Stores each event's parameters + + _element_pages_array[@ array_length_1d(_element_pages_array)] = _new_page_array; + ++_meta_element_pages; + + if (_force_newpage) + { + //Reset state + _text_x = 0; + _line_width = 0; + _line_height = _line_min_height; + + //Create a brand new line to target + _line_array = array_create(__SCRIBBLE_LINE.__SIZE); + _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = 1; + _line_array[@ __SCRIBBLE_LINE.WIDTH ] = _line_width; + _line_array[@ __SCRIBBLE_LINE.HEIGHT ] = _line_height; + _line_array[@ __SCRIBBLE_LINE.HALIGN ] = _text_halign; + } + else + { + //Steal the last line from the previous page + _page_array[@ __SCRIBBLE_PAGE.LINES]--; + _page_lines_array[@ array_length_1d(_page_lines_array)-1] = undefined; + + //Iterate over every vertex buffer on the previous page and steal vertices where we need to + var _v = 0; + repeat(array_length_1d(_page_vbuffs_array)) + { + var _vbuff_data = _page_vbuffs_array[_v]; + + var _buffer = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; + var _vbuff_line_start_list = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; + var _line_tell_prev = _vbuff_line_start_list[| _meta_page_lines]; + var _line_tell = buffer_tell(_buffer); + + if (_line_tell_prev < _line_tell) //If we've added anything to this buffer on the previous line + { + var _bytes = _line_tell - _line_tell_prev; + + //Make a new vertex buffer for the new page + var _new_vbuff_data = array_create(__SCRIBBLE_VERTEX_BUFFER.__SIZE); + _new_page_vbuffs_array[@ array_length_1d(_new_page_vbuffs_array)] = _new_vbuff_data; + _texture_to_buffer_map[? _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXTURE]] = _new_vbuff_data; + + //Create new data structures + var _new_buffer = buffer_create(max(_bytes, __SCRIBBLE_EXPECTED_GLYPHS*__SCRIBBLE_GLYPH_BYTE_SIZE), buffer_grow, 1); + var _new_vbuff_line_start_list = ds_list_create(); + ds_list_add(_new_vbuff_line_start_list, 0); + + //Fill in vertex buffer data + _new_vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.BUFFER ] = _new_buffer; + _new_vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER ] = undefined; + _new_vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXTURE ] = _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXTURE ]; + _new_vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.CHAR_START_TELL] = _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.CHAR_START_TELL] - _line_tell_prev; + _new_vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] - _line_tell_prev; + _new_vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = _new_vbuff_line_start_list; + _new_vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXEL_WIDTH ] = _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXEL_WIDTH ]; + _new_vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXEL_HEIGHT ] = _vbuff_data[@ __SCRIBBLE_VERTEX_BUFFER.TEXEL_HEIGHT ]; + + //Copy the relevant vertices of the old buffer to the new buffer + buffer_copy(_buffer, _line_tell_prev, _bytes, _new_buffer, 0); + buffer_seek(_new_buffer, buffer_seek_start, _bytes); + + //Resize the old buffer to clip off the vertices we've stolen + buffer_resize(_buffer, _line_tell_prev); + buffer_seek(_buffer, buffer_seek_start, _line_tell_prev); //Resizing a buffer resets its tell + ds_list_delete(_vbuff_line_start_list, ds_list_size(_vbuff_line_start_list)-1); + + //Go through every vertex and set its line index to 0 + var _tell = __SCRIBBLE_VERTEX.PACKED_INDEXES; + repeat(_bytes / __SCRIBBLE_VERTEX.__SIZE) + { + buffer_poke(_new_buffer, _tell, buffer_f32, + SCRIBBLE_MAX_LINES*(buffer_peek(_buffer, _tell, buffer_f32) div SCRIBBLE_MAX_LINES)); + _tell += __SCRIBBLE_VERTEX.__SIZE; + } + } + + ++_v; + } + } + + //Add the line array to this page + _new_page_lines_array[@ array_length_1d(_new_page_lines_array)] = _line_array; + + //Transfer new page variables into current page variables + _page_array = _new_page_array; + _page_lines_array = _new_page_lines_array; + _page_vbuffs_array = _new_page_vbuffs_array; + + //Reset some state variables + _element_height = max(_element_height, _line_y); + _meta_page_characters = 0; + _meta_page_lines = 0; + _line_y = 0; + _previous_texture = -1; + _vbuff_line_start_list = -1; + + _force_newpage = false; + } + + #endregion + + + _text_x += _char_width; - _line_width = max(_line_width, _text_x); } - - //Update the last line - _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_characters-1; + + _line_width = max(_line_width, _text_x); + + _line_array[@ __SCRIBBLE_LINE.LAST_CHAR] = _meta_page_characters; _line_array[@ __SCRIBBLE_LINE.Y ] = _line_y + (_line_height div 2); _line_array[@ __SCRIBBLE_LINE.WIDTH ] = _line_width; _line_array[@ __SCRIBBLE_LINE.HEIGHT ] = _line_height; + + ++_meta_page_lines; + ++_meta_element_lines; + _element_width = max(_element_width , _line_width); + _element_height = max(_element_height, _line_y + _line_height); + + //Update metadata + _page_array[@ __SCRIBBLE_PAGE.LINES ] = _meta_page_lines; + _page_array[@ __SCRIBBLE_PAGE.CHARACTERS] = _meta_page_characters; - //Fill out metadata - ++_meta_lines; - _text_x_max = max(_text_x_max, _line_width); - _text_y_max = _line_y + _line_height; - - _scribble_array[@ __SCRIBBLE.LINES ] = _meta_lines; - _scribble_array[@ __SCRIBBLE.CHARACTERS] = _meta_characters; - _scribble_array[@ __SCRIBBLE.WIDTH ] = _text_x_max; - _scribble_array[@ __SCRIBBLE.HEIGHT ] = _text_y_max; + _scribble_array[@ __SCRIBBLE.LINES ] = _meta_element_lines; + _scribble_array[@ __SCRIBBLE.CHARACTERS] = _meta_element_characters; + _scribble_array[@ __SCRIBBLE.PAGES ] = _meta_element_pages; + _scribble_array[@ __SCRIBBLE.WIDTH ] = _element_width; + _scribble_array[@ __SCRIBBLE.HEIGHT ] = _element_height; #endregion #region Move glyphs around on a line to finalise alignment - - var _v = 0; - repeat(ds_list_size(_vertex_buffer_list)) + + //Iterate over every page + var _p = 0; + repeat(array_length_1d(_element_pages_array)) { - var _data = _vertex_buffer_list[| _v]; - - var _line_break_list = _data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; - var _buffer = _data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; - - var _buffer_tell = buffer_tell(_buffer); - ds_list_add(_line_break_list, _buffer_tell); - - var _l = 0; - repeat(ds_list_size(_line_break_list)-1) + var _page_array = _element_pages_array[_p]; + _page_lines_array = _page_array[__SCRIBBLE_PAGE.LINES_ARRAY ]; + _page_vbuffs_array = _page_array[__SCRIBBLE_PAGE.VERTEX_BUFFERS_ARRAY]; + + //Iterate over every vertex buffer for that page + var _v = 0; + repeat(array_length_1d(_page_vbuffs_array)) { - var _line_data = _line_list[| _l]; - var _line_y = _line_data[__SCRIBBLE_LINE.Y ]; - var _line_halign = _line_data[__SCRIBBLE_LINE.HALIGN]; - var _line_height = _line_data[__SCRIBBLE_LINE.HEIGHT]; + var _data = _page_vbuffs_array[_v]; - var _tell_a = _line_break_list[| _l ]; - var _tell_b = _line_break_list[| _l+1]; + var _vbuff_line_start_list = _data[__SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST]; + var _buffer = _data[__SCRIBBLE_VERTEX_BUFFER.BUFFER ]; - //Horizontal alignment - //We default to fa_left so this is only excuted if we need it - if (_line_halign != fa_left) + var _buffer_tell = buffer_tell(_buffer); + ds_list_add(_vbuff_line_start_list, _buffer_tell); + + //Iterate over every line on the page + var _l = 0; + repeat(ds_list_size(_vbuff_line_start_list)-1) { - var _offset = 0; - if (_line_halign == fa_right ) _offset = _text_x_max - _line_data[__SCRIBBLE_LINE.WIDTH]; - if (_line_halign == fa_center) _offset = (_text_x_max - _line_data[__SCRIBBLE_LINE.WIDTH]) div 2; + var _line_data = _page_lines_array[_l]; + var _line_y = _line_data[__SCRIBBLE_LINE.Y ]; + var _line_halign = _line_data[__SCRIBBLE_LINE.HALIGN]; + var _line_height = _line_data[__SCRIBBLE_LINE.HEIGHT]; + + var _tell_a = _vbuff_line_start_list[| _l ]; + var _tell_b = _vbuff_line_start_list[| _l+1]; - if (_offset != 0) + if (_line_halign != fa_left) { + var _line_width = _line_data[__SCRIBBLE_LINE.WIDTH]; + + var _offset = 0; + if (_line_halign == fa_right ) _offset = _element_width - _line_width; + if (_line_halign == fa_center) _offset = (_element_width - _line_width) div 2; + var _tell = _tell_a + __SCRIBBLE_VERTEX.CENTRE_X; repeat((_tell_b - _tell_a) / __SCRIBBLE_VERTEX.__SIZE) { @@ -1006,37 +1257,36 @@ if (!is_array(_draw_string)) _tell += __SCRIBBLE_VERTEX.__SIZE; } } + + var _tell = _tell_a + __SCRIBBLE_VERTEX.CENTRE_Y; + repeat((_tell_b - _tell_a) / __SCRIBBLE_VERTEX.__SIZE) + { + buffer_poke(_buffer, _tell, buffer_f32, _line_y + buffer_peek(_buffer, _tell, buffer_f32)); + _tell += __SCRIBBLE_VERTEX.__SIZE; + } + + ++_l; } - //Finalise line y-positions - //We do this here because we don't know the final height of the line - //TODO - Cache the expected y-position of lines and only move lines around if we've changed the height of the line - var _tell = _tell_a + __SCRIBBLE_VERTEX.CENTRE_Y; - repeat((_tell_b - _tell_a) / __SCRIBBLE_VERTEX.__SIZE) - { - buffer_poke(_buffer, _tell, buffer_f32, _line_y + buffer_peek(_buffer, _tell, buffer_f32)); - _tell += __SCRIBBLE_VERTEX.__SIZE; - } + //Wipe buffer start positions + _data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = undefined; + ds_list_destroy(_vbuff_line_start_list); + + //Create vertex buffer + var _vertex_buffer = vertex_create_buffer_from_buffer_ext(_buffer, global.__scribble_vertex_format, 0, _buffer_tell / __SCRIBBLE_VERTEX.__SIZE); + if (global.scribble_state_freeze) vertex_freeze(_vertex_buffer); + _data[@ __SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER] = _vertex_buffer; + _data[@ __SCRIBBLE_VERTEX_BUFFER.BUFFER ] = undefined; + buffer_delete(_buffer); - ++_l; + //Wipe CHAR_START_TELL and WORD_START_TELL + _data[@ __SCRIBBLE_VERTEX_BUFFER.CHAR_START_TELL] = undefined; + _data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = undefined; + + ++_v; } - - //Wipe buffer start positions - _data[@ __SCRIBBLE_VERTEX_BUFFER.LINE_START_LIST] = undefined; - ds_list_destroy(_line_break_list); - - //Create vertex buffer - var _vertex_buffer = vertex_create_buffer_from_buffer_ext(_buffer, global.__scribble_vertex_format, 0, _buffer_tell / __SCRIBBLE_VERTEX.__SIZE); - if (global.scribble_state_freeze) vertex_freeze(_vertex_buffer); - _data[@ __SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER] = _vertex_buffer; - _data[@ __SCRIBBLE_VERTEX_BUFFER.BUFFER ] = undefined; - buffer_delete(_buffer); - - //Wipe CHAR_START_TELL and WORD_START_TELL - _data[@ __SCRIBBLE_VERTEX_BUFFER.CHAR_START_TELL] = undefined; - _data[@ __SCRIBBLE_VERTEX_BUFFER.WORD_START_TELL] = undefined; - - ++_v; + + ++_p; } #endregion @@ -1075,6 +1325,9 @@ if (global.scribble_state_allow_draw) { #region Draw this text element + var _element_pages_array = _scribble_array[__SCRIBBLE.PAGES_ARRAY]; + var _page_array = _element_pages_array[_scribble_array[__SCRIBBLE.AUTOTYPE_PAGE]]; + //Figure out the left/top offset switch(global.scribble_state_box_halign) { @@ -1120,8 +1373,8 @@ if (global.scribble_state_allow_draw) _matrix = matrix_multiply(_matrix, _old_matrix); matrix_set(matrix_world, _matrix); - var _vbuff_list = _scribble_array[__SCRIBBLE.VERTEX_BUFFER_LIST]; - var _count = ds_list_size(_vbuff_list); + var _page_vbuffs_array = _page_array[__SCRIBBLE_PAGE.VERTEX_BUFFERS_ARRAY]; + var _count = array_length_1d(_page_vbuffs_array); if (_count > 0) { var _typewriter_method = _scribble_array[__SCRIBBLE.AUTOTYPE_METHOD]; @@ -1153,13 +1406,13 @@ if (global.scribble_state_allow_draw) break; case SCRIBBLE_AUTOTYPE_PER_LINE: - var _list = _scribble_array[__SCRIBBLE.LINE_LIST]; - var _line = _list[| min(ceil(_typewriter_position + _typewriter_speed), _scribble_array[__SCRIBBLE.LINES]-1)]; + var _page_lines_array = _page_array[__SCRIBBLE_PAGE.LINES_ARRAY]; + var _line = _page_lines_array[min(ceil(_typewriter_position + _typewriter_speed), _page_array[__SCRIBBLE_PAGE.LINES]-1)]; var _scan_b = _line[__SCRIBBLE_LINE.LAST_CHAR]; break; } - var _scan_a = _scribble_array[__SCRIBBLE.EVENT_CHAR_PREVIOUS]; + var _scan_a = _page_array[__SCRIBBLE_PAGE.EVENT_CHAR_PREVIOUS]; if (_scan_b > _scan_a) { //Play a sound effect as the text is revealed @@ -1174,10 +1427,10 @@ if (global.scribble_state_allow_draw) } } - var _event = _scribble_array[__SCRIBBLE.EVENT_PREVIOUS ]; - var _events_char_array = _scribble_array[__SCRIBBLE.EVENT_CHAR_ARRAY]; - var _events_name_array = _scribble_array[__SCRIBBLE.EVENT_NAME_ARRAY]; - var _events_data_array = _scribble_array[__SCRIBBLE.EVENT_DATA_ARRAY]; + var _event = _page_array[__SCRIBBLE_PAGE.EVENT_PREVIOUS ]; + var _events_char_array = _page_array[__SCRIBBLE_PAGE.EVENT_CHAR_ARRAY]; + var _events_name_array = _page_array[__SCRIBBLE_PAGE.EVENT_NAME_ARRAY]; + var _events_data_array = _page_array[__SCRIBBLE_PAGE.EVENT_DATA_ARRAY]; var _event_count = array_length_1d(_events_char_array); //Always start scanning at the next event @@ -1196,7 +1449,7 @@ if (global.scribble_state_allow_draw) var _script = global.__scribble_autotype_events[? _events_name_array[_event]]; if (_script != undefined) { - _scribble_array[@ __SCRIBBLE.EVENT_PREVIOUS] = _event; + _page_array[@ __SCRIBBLE_PAGE.EVENT_PREVIOUS] = _event; script_execute(_script, _scribble_array, _events_data_array[_event], _scan); } @@ -1218,11 +1471,11 @@ if (global.scribble_state_allow_draw) if (_break && (_typewriter_method == SCRIBBLE_AUTOTYPE_PER_CHARACTER)) _typewriter_position = _scan; - _scribble_array[@ __SCRIBBLE.EVENT_CHAR_PREVIOUS] = _scan; + _page_array[@ __SCRIBBLE_PAGE.EVENT_CHAR_PREVIOUS] = _scan; } else { - _scribble_array[@ __SCRIBBLE.EVENT_CHAR_PREVIOUS] = _scan_b; + _page_array[@ __SCRIBBLE_PAGE.EVENT_CHAR_PREVIOUS] = _scan_b; } } } @@ -1240,8 +1493,8 @@ if (global.scribble_state_allow_draw) { switch(_typewriter_method) { - case SCRIBBLE_AUTOTYPE_PER_CHARACTER: var _typewriter_count = _scribble_array[__SCRIBBLE.CHARACTERS]; break; - case SCRIBBLE_AUTOTYPE_PER_LINE: var _typewriter_count = _scribble_array[__SCRIBBLE.LINES ]; break; + case SCRIBBLE_AUTOTYPE_PER_CHARACTER: var _typewriter_count = _page_array[__SCRIBBLE_PAGE.CHARACTERS]; break; + case SCRIBBLE_AUTOTYPE_PER_LINE: var _typewriter_count = _page_array[__SCRIBBLE_PAGE.LINES ]; break; } var _typewriter_t = clamp(_typewriter_position, 0, _typewriter_count + _typewriter_smoothness); @@ -1279,7 +1532,7 @@ if (global.scribble_state_allow_draw) var _i = 0; repeat(_count) { - var _vbuff_data = _vbuff_list[| _i]; + var _vbuff_data = _page_vbuffs_array[_i]; shader_set_uniform_f(global.__scribble_uniform_texel, _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.TEXEL_WIDTH], _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.TEXEL_HEIGHT]); vertex_submit(_vbuff_data[__SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER], pr_trianglelist, _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.TEXTURE]); ++_i; @@ -1325,23 +1578,27 @@ if (SCRIBBLE_CACHE_TIMEOUT > 0) { if (__SCRIBBLE_DEBUG) show_debug_message("Scribble: Removing \"" + _cache_string + "\" from cache"); - //Free data (basically a duplicate of scribble_flush) - var _vbuff_list = _cache_array[__SCRIBBLE.VERTEX_BUFFER_LIST]; - var _count = ds_list_size(_vbuff_list); - for(var _i = 0; _i < _count; _i++) + var _element_pages_array = _cache_array[__SCRIBBLE.PAGES_ARRAY]; + var _p = 0; + repeat(array_length_1d(_element_pages_array)) { - var _vbuff_data = _vbuff_list[| _i]; - var _vbuff = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER]; - vertex_delete_buffer(_vbuff); + var _page_array = _element_pages_array[_p]; + var _vertex_buffers_array = _page_array[__SCRIBBLE_PAGE.VERTEX_BUFFERS_ARRAY]; + var _v = 0; + repeat(array_length_1d(_vertex_buffers_array)) + { + var _vbuff_data = _vertex_buffers_array[_v]; + var _vbuff = _vbuff_data[__SCRIBBLE_VERTEX_BUFFER.VERTEX_BUFFER]; + vertex_delete_buffer(_vbuff); + ++_v; + } + ++_p; } - ds_list_destroy(_cache_array[@ __SCRIBBLE.LINE_LIST]); - ds_list_destroy(_vbuff_list); - _cache_array[@ __SCRIBBLE.FREED] = true; //Remove reference from cache - ds_map_delete(global.__scribble_global_cache_map,_cache_string); + ds_map_delete(global.__scribble_global_cache_map, _cache_string); ds_list_delete(global.__scribble_global_cache_list, global.__scribble_cache_test_index); //Remove global reference diff --git a/scripts/scribble_draw_get_state/scribble_draw_get_state.gml b/scripts/scribble_draw_get_state/scribble_draw_get_state.gml index 066d52580..e490a28dd 100644 --- a/scripts/scribble_draw_get_state/scribble_draw_get_state.gml +++ b/scripts/scribble_draw_get_state/scribble_draw_get_state.gml @@ -2,25 +2,23 @@ /// This can be used to debug code, or used in combination with scribble_set_state() to create template draw states. var _array = array_create(SCRIBBLE_STATE.__SIZE); -_array[@ SCRIBBLE_STATE.XSCALE ] = global.scribble_state_xscale; -_array[@ SCRIBBLE_STATE.YSCALE ] = global.scribble_state_yscale; -_array[@ SCRIBBLE_STATE.ANGLE ] = global.scribble_state_angle; -_array[@ SCRIBBLE_STATE.COLOUR ] = global.scribble_state_colour; -_array[@ SCRIBBLE_STATE.ALPHA ] = global.scribble_state_alpha; -_array[@ SCRIBBLE_STATE.LINE_MIN_HEIGHT ] = global.scribble_state_line_min_height; -_array[@ SCRIBBLE_STATE.MIN_WIDTH ] = global.scribble_state_min_width; -_array[@ SCRIBBLE_STATE.MAX_WIDTH ] = global.scribble_state_max_width; -_array[@ SCRIBBLE_STATE.MIN_HEIGHT ] = global.scribble_state_min_height; -_array[@ SCRIBBLE_STATE.MAX_HEIGHT ] = global.scribble_state_max_height; -_array[@ SCRIBBLE_STATE.CHARACTER_WRAP ] = global.scribble_state_character_wrap; -_array[@ SCRIBBLE_STATE.HALIGN ] = global.scribble_state_box_halign; -_array[@ SCRIBBLE_STATE.VALIGN ] = global.scribble_state_box_valign; -_array[@ SCRIBBLE_STATE.TYPEWRITER_FADE_IN ] = global.scribble_state_tw_fade_in; -_array[@ SCRIBBLE_STATE.TYPEWRITER_POSITION ] = global.scribble_state_tw_position; -_array[@ SCRIBBLE_STATE.TYPEWRITER_METHOD ] = global.scribble_state_tw_method; -_array[@ SCRIBBLE_STATE.TYPEWRITER_SMOOTHNESS] = global.scribble_state_tw_smoothness; -_array[@ SCRIBBLE_STATE.ANIMATION_ARRAY ] = global.scribble_state_anim_array; -_array[@ SCRIBBLE_STATE.CACHE_GROUP ] = global.scribble_state_cache_group; -_array[@ SCRIBBLE_STATE.ALLOW_DRAW ] = global.scribble_state_allow_draw; -_array[@ SCRIBBLE_STATE.FREEZE ] = global.scribble_state_freeze; +_array[@ SCRIBBLE_STATE.XSCALE ] = global.scribble_state_xscale; +_array[@ SCRIBBLE_STATE.YSCALE ] = global.scribble_state_yscale; +_array[@ SCRIBBLE_STATE.ANGLE ] = global.scribble_state_angle; +_array[@ SCRIBBLE_STATE.COLOUR ] = global.scribble_state_colour; +_array[@ SCRIBBLE_STATE.ALPHA ] = global.scribble_state_alpha; +_array[@ SCRIBBLE_STATE.LINE_MIN_HEIGHT ] = global.scribble_state_line_min_height; +_array[@ SCRIBBLE_STATE.MAX_WIDTH ] = global.scribble_state_max_width; +_array[@ SCRIBBLE_STATE.MAX_HEIGHT ] = global.scribble_state_max_height; +_array[@ SCRIBBLE_STATE.CHARACTER_WRAP ] = global.scribble_state_character_wrap; +_array[@ SCRIBBLE_STATE.HALIGN ] = global.scribble_state_box_halign; +_array[@ SCRIBBLE_STATE.VALIGN ] = global.scribble_state_box_valign; +_array[@ SCRIBBLE_STATE.AUTOTYPE_FADE_IN ] = global.scribble_state_tw_fade_in; +_array[@ SCRIBBLE_STATE.AUTOTYPE_POSITION ] = global.scribble_state_tw_position; +_array[@ SCRIBBLE_STATE.AUTOTYPE_METHOD ] = global.scribble_state_tw_method; +_array[@ SCRIBBLE_STATE.AUTOTYPE_SMOOTHNESS] = global.scribble_state_tw_smoothness; +_array[@ SCRIBBLE_STATE.ANIMATION_ARRAY ] = global.scribble_state_anim_array; +_array[@ SCRIBBLE_STATE.CACHE_GROUP ] = global.scribble_state_cache_group; +_array[@ SCRIBBLE_STATE.ALLOW_DRAW ] = global.scribble_state_allow_draw; +_array[@ SCRIBBLE_STATE.FREEZE ] = global.scribble_state_freeze; return _array; \ No newline at end of file diff --git a/scripts/scribble_draw_reset/scribble_draw_reset.gml b/scripts/scribble_draw_reset/scribble_draw_reset.gml index 72aa8a387..6fdb4ff98 100644 --- a/scripts/scribble_draw_reset/scribble_draw_reset.gml +++ b/scripts/scribble_draw_reset/scribble_draw_reset.gml @@ -6,10 +6,8 @@ global.scribble_state_angle = SCRIBBLE_DEFAULT_ANGLE; global.scribble_state_colour = SCRIBBLE_DEFAULT_BLEND_COLOUR; global.scribble_state_alpha = SCRIBBLE_DEFAULT_BLEND_ALPHA; global.scribble_state_line_min_height = SCRIBBLE_DEFAULT_LINE_MIN_HEIGHT; -global.scribble_state_min_width = undefined; global.scribble_state_max_width = SCRIBBLE_DEFAULT_MAX_WIDTH; -global.scribble_state_min_height = undefined; -global.scribble_state_max_height = undefined; +global.scribble_state_max_height = SCRIBBLE_DEFAULT_MAX_HEIGHT; global.scribble_state_character_wrap = false; global.scribble_state_box_halign = SCRIBBLE_DEFAULT_BOX_HALIGN; global.scribble_state_box_valign = SCRIBBLE_DEFAULT_BOX_VALIGN; diff --git a/scripts/scribble_draw_set_state/scribble_draw_set_state.gml b/scripts/scribble_draw_set_state/scribble_draw_set_state.gml index 0f30a97c4..008fa8520 100644 --- a/scripts/scribble_draw_set_state/scribble_draw_set_state.gml +++ b/scripts/scribble_draw_set_state/scribble_draw_set_state.gml @@ -4,24 +4,22 @@ /// Updates Scribble's current draw state from an array. Any value that is will use the default value instead. /// This can be used in combination with scribble_get_state() to create template draw states. -global.scribble_state_xscale = argument0[SCRIBBLE_STATE.XSCALE ]; -global.scribble_state_yscale = argument0[SCRIBBLE_STATE.YSCALE ]; -global.scribble_state_angle = argument0[SCRIBBLE_STATE.ANGLE ]; -global.scribble_state_colour = argument0[SCRIBBLE_STATE.COLOUR ]; -global.scribble_state_alpha = argument0[SCRIBBLE_STATE.ALPHA ]; -global.scribble_state_line_min_height = argument0[SCRIBBLE_STATE.LINE_MIN_HEIGHT ]; -global.scribble_state_min_width = argument0[SCRIBBLE_STATE.MIN_WIDTH ]; -global.scribble_state_max_width = argument0[SCRIBBLE_STATE.MAX_WIDTH ]; -global.scribble_state_min_height = argument0[SCRIBBLE_STATE.MIN_HEIGHT ]; -global.scribble_state_max_height = argument0[SCRIBBLE_STATE.MAX_HEIGHT ]; -global.scribble_state_character_wrap = argument0[SCRIBBLE_STATE.CHARACTER_WRAP ]; -global.scribble_state_box_halign = argument0[SCRIBBLE_STATE.HALIGN ]; -global.scribble_state_box_valign = argument0[SCRIBBLE_STATE.VALIGN ]; -global.scribble_state_tw_fade_in = argument0[SCRIBBLE_STATE.TYPEWRITER_FADE_IN ]; -global.scribble_state_tw_position = argument0[SCRIBBLE_STATE.TYPEWRITER_POSITION ]; -global.scribble_state_tw_smoothness = argument0[SCRIBBLE_STATE.TYPEWRITER_SMOOTHNESS]; -global.scribble_state_tw_method = argument0[SCRIBBLE_STATE.TYPEWRITER_METHOD ]; -global.scribble_state_anim_array = argument0[SCRIBBLE_STATE.ANIMATION_ARRAY ]; -global.scribble_state_cache_group = argument0[SCRIBBLE_STATE.CACHE_GROUP ]; -global.scribble_state_allow_draw = argument0[SCRIBBLE_STATE.ALLOW_DRAW ]; -global.scribble_state_freeze = argument0[SCRIBBLE_STATE.FREEZE ]; \ No newline at end of file +global.scribble_state_xscale = argument0[SCRIBBLE_STATE.XSCALE ]; +global.scribble_state_yscale = argument0[SCRIBBLE_STATE.YSCALE ]; +global.scribble_state_angle = argument0[SCRIBBLE_STATE.ANGLE ]; +global.scribble_state_colour = argument0[SCRIBBLE_STATE.COLOUR ]; +global.scribble_state_alpha = argument0[SCRIBBLE_STATE.ALPHA ]; +global.scribble_state_line_min_height = argument0[SCRIBBLE_STATE.LINE_MIN_HEIGHT ]; +global.scribble_state_max_width = argument0[SCRIBBLE_STATE.MAX_WIDTH ]; +global.scribble_state_max_height = argument0[SCRIBBLE_STATE.MAX_HEIGHT ]; +global.scribble_state_character_wrap = argument0[SCRIBBLE_STATE.CHARACTER_WRAP ]; +global.scribble_state_box_halign = argument0[SCRIBBLE_STATE.HALIGN ]; +global.scribble_state_box_valign = argument0[SCRIBBLE_STATE.VALIGN ]; +global.scribble_state_tw_fade_in = argument0[SCRIBBLE_STATE.AUTOTYPE_FADE_IN ]; +global.scribble_state_tw_position = argument0[SCRIBBLE_STATE.AUTOTYPE_POSITION ]; +global.scribble_state_tw_smoothness = argument0[SCRIBBLE_STATE.AUTOTYPE_SMOOTHNESS]; +global.scribble_state_tw_method = argument0[SCRIBBLE_STATE.AUTOTYPE_METHOD ]; +global.scribble_state_anim_array = argument0[SCRIBBLE_STATE.ANIMATION_ARRAY ]; +global.scribble_state_cache_group = argument0[SCRIBBLE_STATE.CACHE_GROUP ]; +global.scribble_state_allow_draw = argument0[SCRIBBLE_STATE.ALLOW_DRAW ]; +global.scribble_state_freeze = argument0[SCRIBBLE_STATE.FREEZE ]; \ No newline at end of file diff --git a/scripts/scribble_draw_set_wrap/scribble_draw_set_wrap.gml b/scripts/scribble_draw_set_wrap/scribble_draw_set_wrap.gml index e6661d989..97b11da59 100644 --- a/scripts/scribble_draw_set_wrap/scribble_draw_set_wrap.gml +++ b/scripts/scribble_draw_set_wrap/scribble_draw_set_wrap.gml @@ -3,6 +3,7 @@ /// /// @param minLineHeight The minimum line height for each line of text. Use a negative number (the default) for the height of a space character of the default font /// @param maxLineWidth The maximum line width for each line of text. Use a negative number (the default) for no limit +/// @param [maxLineHeight] The maximum height for the whole textbox. Use a negative number (the default) for no limit /// @param [characterWrap] Whether to wrap text per character (rather than per word). Defaults to . This is useful for very tight textboxes and some East Asian languages /// /// @@ -13,4 +14,5 @@ global.scribble_state_line_min_height = argument[0]; global.scribble_state_max_width = argument[1]; -global.scribble_state_character_wrap = (argument_count > 2)? argument[2] : false; \ No newline at end of file +global.scribble_state_max_height = (argument_count > 2)? argument[2] : -1; +global.scribble_state_character_wrap = (argument_count > 3)? argument[3] : false; \ No newline at end of file diff --git a/scripts/scribble_get_quad/scribble_get_quad.gml b/scripts/scribble_get_quad/scribble_get_quad.gml index 59a228085..da1577e24 100644 --- a/scripts/scribble_get_quad/scribble_get_quad.gml +++ b/scripts/scribble_get_quad/scribble_get_quad.gml @@ -37,7 +37,7 @@ if (!is_array(_scribble_array) var _string = string(_scribble_array); //Check the cache - var _cache_string = _string + ":" + string(global.scribble_state_line_min_height) + ":" + string(global.scribble_state_max_width); + var _cache_string = _string + ":" + string(global.scribble_state_line_min_height) + ":" + string(global.scribble_state_max_width) + ":" + string(global.scribble_state_max_height); if (ds_map_exists(global.__scribble_global_cache_map, _cache_string)) { //Grab the text element, and update the TIME property diff --git a/scripts/scribble_init/scribble_init.gml b/scripts/scribble_init/scribble_init.gml index 793f1a63f..600813e34 100644 --- a/scripts/scribble_init/scribble_init.gml +++ b/scripts/scribble_init/scribble_init.gml @@ -19,17 +19,17 @@ /// 8) Automatically scans Included Files for fonts (if enabled) /// /// -/// Scribble v5.3.3 -/// 2020/02/11 +/// Scribble v5.4.3 +/// 2020-03-08 /// @jujuadams -/// With thanks to glitchroy, Mark Turner, Rob van Saaze, DragoniteSpam, and sp202 +/// With thanks to glitchroy, Mark Turner, DragoniteSpam, sp202, Rob van Saaze, soVes, and @stoozey_ /// /// For use with GMS2.2.2 and later #region Internal Macro Definitions -#macro __SCRIBBLE_VERSION "5.3.3" -#macro __SCRIBBLE_DATE "2020/02/11" +#macro __SCRIBBLE_VERSION "5.4.3" +#macro __SCRIBBLE_DATE "2020-03-08" #macro __SCRIBBLE_DEBUG false //You'll usually only want to modify SCRIBBLE_GLYPH.X_OFFSET, SCRIBBLE_GLYPH.Y_OFFSET, and SCRIBBLE_GLYPH.SEPARATION @@ -67,8 +67,24 @@ enum __SCRIBBLE_FONT enum __SCRIBBLE_FONT_TYPE { - FONT, - SPRITE + FONT, //0 + SPRITE //1 +} + +enum __SCRIBBLE_PAGE +{ + LINES, //0 + CHARACTERS, //1 + LINES_ARRAY, //2 + VERTEX_BUFFERS_ARRAY, //3 + + EVENT_PREVIOUS, //4 + EVENT_CHAR_PREVIOUS, //5 + EVENT_CHAR_ARRAY, //6 + EVENT_NAME_ARRAY, //7 + EVENT_DATA_ARRAY, //8 + + __SIZE } enum __SCRIBBLE_LINE @@ -119,17 +135,15 @@ enum SCRIBBLE_STATE COLOUR, ALPHA, LINE_MIN_HEIGHT, - MIN_WIDTH, MAX_WIDTH, - MIN_HEIGHT, MAX_HEIGHT, CHARACTER_WRAP, HALIGN, VALIGN, - TYPEWRITER_FADE_IN, - TYPEWRITER_POSITION, - TYPEWRITER_SMOOTHNESS, - TYPEWRITER_METHOD, + AUTOTYPE_FADE_IN, + AUTOTYPE_POSITION, + AUTOTYPE_SMOOTHNESS, + AUTOTYPE_METHOD, ANIMATION_ARRAY, CACHE_GROUP, ALLOW_DRAW, @@ -142,46 +156,42 @@ enum __SCRIBBLE __SECTION0, // 0 VERSION, // 1 STRING, // 2 + CACHE_STRING, // 3 DEFAULT_FONT, // 3 DEFAULT_COLOUR, // 4 DEFAULT_HALIGN, // 5 WIDTH_LIMIT, // 6 - LINE_HEIGHT, // 7 - - __SECTION1, // 8 - WIDTH, // 9 - HEIGHT, //10 - CHARACTERS, //11 - LINES, //12 - GLOBAL_INDEX, //13 + HEIGHT_LIMIT, // 7 + LINE_HEIGHT, // 8 - __SECTION2, //14 - ANIMATION_TIME, //15 - TIME, //16 - FREED, //17 - SOUND_FINISH_TIME, //18 + __SECTION1, // 9 + WIDTH, //10 + HEIGHT, //11 + CHARACTERS, //12 + LINES, //13 + PAGES, //14 + GLOBAL_INDEX, //15 - __SECTION3, //19 - LINE_LIST, //20 - VERTEX_BUFFER_LIST, //21 + __SECTION2, //16 + ANIMATION_TIME, //17 + TIME, //18 + FREED, //19 + SOUND_FINISH_TIME, //20 - __SECTION4, //22 - AUTOTYPE_FADE_IN, //23 - AUTOTYPE_SPEED, //24 - AUTOTYPE_POSITION, //25 - AUTOTYPE_METHOD, //26 - AUTOTYPE_SMOOTHNESS, //27 - AUTOTYPE_SOUND_ARRAY, //28 - AUTOTYPE_SOUND_OVERLAP, //29 + __SECTION3, //21 + PAGES_ARRAY, //22 - __SECTION5, //30 - EVENT_PREVIOUS, //31 - EVENT_CHAR_PREVIOUS, //32 - EVENT_CHAR_ARRAY, //33 - EVENT_NAME_ARRAY, //34 - EVENT_DATA_ARRAY, //35 + __SECTION4, //23 + AUTOTYPE_PAGE, //24 + AUTOTYPE_FADE_IN, //25 + AUTOTYPE_SPEED, //26 + AUTOTYPE_POSITION, //27 + AUTOTYPE_METHOD, //28 + AUTOTYPE_SMOOTHNESS, //29 + AUTOTYPE_SOUND_ARRAY, //30 + AUTOTYPE_SOUND_OVERLAP, //31 - __SIZE //36 + __SIZE //32 } #macro __SCRIBBLE_ON_DIRECTX ((os_type == os_windows) || (os_type == os_xboxone) || (os_type == os_uwp) || (os_type == os_win8native) || (os_type == os_winphone)) diff --git a/scripts/scribble_page_count/scribble_page_count.gml b/scripts/scribble_page_count/scribble_page_count.gml new file mode 100644 index 000000000..f5d33e9fb --- /dev/null +++ b/scripts/scribble_page_count/scribble_page_count.gml @@ -0,0 +1,29 @@ +/// @param string(orElement) + +var _scribble_array = argument0; + +if (!is_array(_scribble_array) +|| (array_length_1d(_scribble_array) != __SCRIBBLE.__SIZE) +|| (_scribble_array[__SCRIBBLE.VERSION] != __SCRIBBLE_VERSION) +|| _scribble_array[__SCRIBBLE.FREED]) +{ + var _string = string(_scribble_array); + + //Check the cache + var _cache_string = _string + ":" + string(global.scribble_state_line_min_height) + ":" + string(global.scribble_state_max_width) + ":" + string(global.scribble_state_max_height); + if (ds_map_exists(global.__scribble_global_cache_map, _cache_string)) + { + //Grab the text element, and update the TIME property + var _scribble_array = global.__scribble_global_cache_map[? _cache_string]; + _scribble_array[@ __SCRIBBLE.TIME] = current_time; + } + else + { + var _old_allow_draw = global.scribble_state_allow_draw; + global.scribble_state_allow_draw = false; + _scribble_array = scribble_draw(0, 0, _string); + global.scribble_state_allow_draw = _old_allow_draw; + } +} + +return _scribble_array[__SCRIBBLE.PAGES]; \ No newline at end of file diff --git a/scripts/scribble_page_count/scribble_page_count.yy b/scripts/scribble_page_count/scribble_page_count.yy new file mode 100644 index 000000000..0c3e1c971 --- /dev/null +++ b/scripts/scribble_page_count/scribble_page_count.yy @@ -0,0 +1,8 @@ +{ + "id": "b7157de4-28d8-476e-b907-27576e4c9261", + "modelName": "GMScript", + "mvc": "1.0", + "name": "scribble_page_count", + "IsCompatibility": false, + "IsDnD": false +} \ No newline at end of file diff --git a/scripts/scribble_page_get/scribble_page_get.gml b/scripts/scribble_page_get/scribble_page_get.gml new file mode 100644 index 000000000..68dc9c7be --- /dev/null +++ b/scripts/scribble_page_get/scribble_page_get.gml @@ -0,0 +1,5 @@ +/// @param element +/// @param page +/// @param [relative] + +return argument0[__SCRIBBLE.AUTOTYPE_PAGE]; \ No newline at end of file diff --git a/scripts/scribble_page_get/scribble_page_get.yy b/scripts/scribble_page_get/scribble_page_get.yy new file mode 100644 index 000000000..08c414e44 --- /dev/null +++ b/scripts/scribble_page_get/scribble_page_get.yy @@ -0,0 +1,8 @@ +{ + "id": "04acbfcf-ee17-4ded-b194-17bb72864ff0", + "modelName": "GMScript", + "mvc": "1.0", + "name": "scribble_page_get", + "IsCompatibility": false, + "IsDnD": false +} \ No newline at end of file diff --git a/scripts/scribble_page_on_last/scribble_page_on_last.gml b/scripts/scribble_page_on_last/scribble_page_on_last.gml new file mode 100644 index 000000000..1dce6db14 --- /dev/null +++ b/scripts/scribble_page_on_last/scribble_page_on_last.gml @@ -0,0 +1,4 @@ +/// @param element + + +return (argument0[__SCRIBBLE.AUTOTYPE_PAGE] >= (argument0[__SCRIBBLE.PAGES]-1)); \ No newline at end of file diff --git a/scripts/scribble_page_on_last/scribble_page_on_last.yy b/scripts/scribble_page_on_last/scribble_page_on_last.yy new file mode 100644 index 000000000..5e1483b95 --- /dev/null +++ b/scripts/scribble_page_on_last/scribble_page_on_last.yy @@ -0,0 +1,8 @@ +{ + "id": "74d4828d-df60-4163-9a0f-713e1e653208", + "modelName": "GMScript", + "mvc": "1.0", + "name": "scribble_page_on_last", + "IsCompatibility": false, + "IsDnD": false +} \ No newline at end of file diff --git a/scripts/scribble_page_set/scribble_page_set.gml b/scripts/scribble_page_set/scribble_page_set.gml new file mode 100644 index 000000000..6ab4879d5 --- /dev/null +++ b/scripts/scribble_page_set/scribble_page_set.gml @@ -0,0 +1,10 @@ +/// @param element +/// @param page + +var _scribble_array = argument0; +var _page = argument1; + +_page = clamp(_page, 0, _scribble_array[__SCRIBBLE.PAGES]-1); +_scribble_array[@ __SCRIBBLE.AUTOTYPE_PAGE] = _page; + +return _page; \ No newline at end of file diff --git a/scripts/scribble_page_set/scribble_page_set.yy b/scripts/scribble_page_set/scribble_page_set.yy new file mode 100644 index 000000000..fb10cb66e --- /dev/null +++ b/scripts/scribble_page_set/scribble_page_set.yy @@ -0,0 +1,8 @@ +{ + "id": "6e8352fc-78a8-490a-a4ab-9dacbaeb79f5", + "modelName": "GMScript", + "mvc": "1.0", + "name": "scribble_page_set", + "IsCompatibility": false, + "IsDnD": false +} \ No newline at end of file diff --git a/views/85d381bf-3af3-491c-b197-63da24f6696b.yy b/views/85d381bf-3af3-491c-b197-63da24f6696b.yy new file mode 100644 index 000000000..bf0529023 --- /dev/null +++ b/views/85d381bf-3af3-491c-b197-63da24f6696b.yy @@ -0,0 +1,16 @@ +{ + "id": "85d381bf-3af3-491c-b197-63da24f6696b", + "modelName": "GMFolder", + "mvc": "1.1", + "name": "85d381bf-3af3-491c-b197-63da24f6696b", + "children": [ + "6e8352fc-78a8-490a-a4ab-9dacbaeb79f5", + "04acbfcf-ee17-4ded-b194-17bb72864ff0", + "b7157de4-28d8-476e-b907-27576e4c9261", + "74d4828d-df60-4163-9a0f-713e1e653208" + ], + "filterType": "GMScript", + "folderName": "Pages", + "isDefaultView": false, + "localisedFolderName": "" +} \ No newline at end of file diff --git a/views/95e57154-061e-41b9-87cb-88e21f8fa68c.yy b/views/95e57154-061e-41b9-87cb-88e21f8fa68c.yy index fdfa546c0..5f32ee691 100644 --- a/views/95e57154-061e-41b9-87cb-88e21f8fa68c.yy +++ b/views/95e57154-061e-41b9-87cb-88e21f8fa68c.yy @@ -6,9 +6,10 @@ "children": [ "59086829-c42b-46bc-b263-7ed41965b63c", "beea2a2b-8233-44bc-9d9d-0dfc652a6bd0", + "8419d4f0-d03e-4d98-8b9d-93e9ec832104", "24adc709-497e-43cb-9834-a1a8664cbe74", - "a3d9edc7-bc39-46f3-b8c2-98bcc058ea2c", - "498aa41e-7fb7-49e3-b663-74ba62e7a8e6" + "498aa41e-7fb7-49e3-b663-74ba62e7a8e6", + "a3d9edc7-bc39-46f3-b8c2-98bcc058ea2c" ], "filterType": "GMScript", "folderName": "Auto Typewriter", diff --git a/views/a39a04ab-7eab-45b9-a5ac-dd51dc752f37.yy b/views/a39a04ab-7eab-45b9-a5ac-dd51dc752f37.yy new file mode 100644 index 000000000..f3f09e2c1 --- /dev/null +++ b/views/a39a04ab-7eab-45b9-a5ac-dd51dc752f37.yy @@ -0,0 +1,15 @@ +{ + "id": "a39a04ab-7eab-45b9-a5ac-dd51dc752f37", + "modelName": "GMFolder", + "mvc": "1.1", + "name": "a39a04ab-7eab-45b9-a5ac-dd51dc752f37", + "children": [ + "95e57154-061e-41b9-87cb-88e21f8fa68c", + "85d381bf-3af3-491c-b197-63da24f6696b", + "d0797c70-f098-4e2c-912e-f1225887182b" + ], + "filterType": "GMScript", + "folderName": "Extras", + "isDefaultView": false, + "localisedFolderName": "" +} \ No newline at end of file diff --git a/views/dab40804-067d-4898-b5fd-736906e548cf.yy b/views/dab40804-067d-4898-b5fd-736906e548cf.yy index f55ad16fa..0f09adba3 100644 --- a/views/dab40804-067d-4898-b5fd-736906e548cf.yy +++ b/views/dab40804-067d-4898-b5fd-736906e548cf.yy @@ -10,8 +10,7 @@ "5044992f-3fea-47aa-a11b-2b6d850ac7ee", "bf269b8e-eb65-4528-b05e-d89efb7d6c87", "bcd14081-de72-4eef-8094-64efd4aac382", - "95e57154-061e-41b9-87cb-88e21f8fa68c", - "d0797c70-f098-4e2c-912e-f1225887182b" + "a39a04ab-7eab-45b9-a5ac-dd51dc752f37" ], "filterType": "GMScript", "folderName": "Scribble",